comparison driver/pt1_i2c.c @ 77:517e61637f7b

a bit cleanup
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 01 Dec 2009 18:33:01 +0900
parents 67e8eca28a80
children 3c2123189edf
comparison
equal deleted inserted replaced
76:d1c740aa1b67 77:517e61637f7b
33 void makei2c(void __iomem *regs, __u32 base_addr, __u32 i2caddr, __u32 writemode, __u32 data_en, __u32 clock, __u32 busy) 33 void makei2c(void __iomem *regs, __u32 base_addr, __u32 i2caddr, __u32 writemode, __u32 data_en, __u32 clock, __u32 busy)
34 { 34 {
35 35
36 __u32 val ; 36 __u32 val ;
37 val = ((base_addr << I2C_DATA) | (writemode << I2C_WRIET_MODE) | 37 val = ((base_addr << I2C_DATA) | (writemode << I2C_WRIET_MODE) |
38 ( data_en << I2C_DATA_EN) | 38 ( data_en << I2C_DATA_EN) |
39 (clock << I2C_CLOCK) | (busy << I2C_BUSY) | i2caddr) ; 39 (clock << I2C_CLOCK) | (busy << I2C_BUSY) | i2caddr) ;
40 writel(val, regs + FIFO_ADDR); 40 writel(val, regs + FIFO_ADDR);
41 } 41 }
42 42
43 int xc3s_init(void __iomem *regs) 43 int xc3s_init(void __iomem *regs)
55 BIT 17, 17+8 ON 55 BIT 17, 17+8 ON
56 */ 56 */
57 // XC3S初期化 57 // XC3S初期化
58 for(lp = 0 ; lp < PROGRAM_ADDRESS ; lp++){ 58 for(lp = 0 ; lp < PROGRAM_ADDRESS ; lp++){
59 makei2c(regs, lp, 0, READ_EN, DATA_DIS, CLOCK_DIS, BUSY_DIS); 59 makei2c(regs, lp, 0, READ_EN, DATA_DIS, CLOCK_DIS, BUSY_DIS);
60 } 60 }
61 // XC3S 初期化待ち (512 PCI Clocks) 61 // XC3S 初期化待ち (512 PCI Clocks)
62 for(lp = 0 ; lp < XC3S_PCI_CLOCK ; lp++){ 62 for(lp = 0 ; lp < XC3S_PCI_CLOCK ; lp++){
63 makei2c(regs, 0, 0, READ_EN, DATA_DIS, CLOCK_DIS, BUSY_DIS); 63 makei2c(regs, 0, 0, READ_EN, DATA_DIS, CLOCK_DIS, BUSY_DIS);
64 } 64 }
65 // プロテクト解除 65 // プロテクト解除
289 // Clock negedge 289 // Clock negedge
290 makei2c(regs, address, address + 1, 0, (old_bits ^ 1), 1, 1); 290 makei2c(regs, address, address + 1, 0, (old_bits ^ 1), 1, 1);
291 clock = TRUE ; 291 clock = TRUE ;
292 address += 1 ; 292 address += 1 ;
293 293
294 // ここから Read 294 // ここから Read
295 start_i2c(regs, &address, &clock, old_bits); 295 start_i2c(regs, &address, &clock, old_bits);
296 old_bits = 0 ; 296 old_bits = 0 ;
297 // まずアドレスを書く 297 // まずアドレスを書く
298 for(bitpos = 0 ; bitpos < 7 ; bitpos++){ 298 for(bitpos = 0 ; bitpos < 7 ; bitpos++){
299 bits = ((wblock->addr >> (6 - bitpos)) & 1); 299 bits = ((wblock->addr >> (6 - bitpos)) & 1);