diff options
Diffstat (limited to 'drivers/i2c/algos/i2c-algo-pca.c')
-rw-r--r-- | drivers/i2c/algos/i2c-algo-pca.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index 2a16211f12e5..ebec91d71e1e 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * i2c-algo-pca.c i2c driver algorithms for PCA9564 adapters | 2 | * i2c-algo-pca.c i2c driver algorithms for PCA9564 adapters |
3 | * Copyright (C) 2004 Arcom Control Systems | 3 | * Copyright (C) 2004 Arcom Control Systems |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
@@ -99,7 +99,7 @@ static void pca_stop(struct i2c_algo_pca_data *adap) | |||
99 | * | 99 | * |
100 | * returns after the address has been sent | 100 | * returns after the address has been sent |
101 | */ | 101 | */ |
102 | static void pca_address(struct i2c_algo_pca_data *adap, | 102 | static void pca_address(struct i2c_algo_pca_data *adap, |
103 | struct i2c_msg *msg) | 103 | struct i2c_msg *msg) |
104 | { | 104 | { |
105 | int sta = pca_get_con(adap); | 105 | int sta = pca_get_con(adap); |
@@ -108,9 +108,9 @@ static void pca_address(struct i2c_algo_pca_data *adap, | |||
108 | addr = ( (0x7f & msg->addr) << 1 ); | 108 | addr = ( (0x7f & msg->addr) << 1 ); |
109 | if (msg->flags & I2C_M_RD ) | 109 | if (msg->flags & I2C_M_RD ) |
110 | addr |= 1; | 110 | addr |= 1; |
111 | DEB2("=== SLAVE ADDRESS %#04x+%c=%#04x\n", | 111 | DEB2("=== SLAVE ADDRESS %#04x+%c=%#04x\n", |
112 | msg->addr, msg->flags & I2C_M_RD ? 'R' : 'W', addr); | 112 | msg->addr, msg->flags & I2C_M_RD ? 'R' : 'W', addr); |
113 | 113 | ||
114 | pca_outw(adap, I2C_PCA_DAT, addr); | 114 | pca_outw(adap, I2C_PCA_DAT, addr); |
115 | 115 | ||
116 | sta &= ~(I2C_PCA_CON_STO|I2C_PCA_CON_STA|I2C_PCA_CON_SI); | 116 | sta &= ~(I2C_PCA_CON_STO|I2C_PCA_CON_STA|I2C_PCA_CON_SI); |
@@ -124,7 +124,7 @@ static void pca_address(struct i2c_algo_pca_data *adap, | |||
124 | * | 124 | * |
125 | * Returns after the byte has been transmitted | 125 | * Returns after the byte has been transmitted |
126 | */ | 126 | */ |
127 | static void pca_tx_byte(struct i2c_algo_pca_data *adap, | 127 | static void pca_tx_byte(struct i2c_algo_pca_data *adap, |
128 | __u8 b) | 128 | __u8 b) |
129 | { | 129 | { |
130 | int sta = pca_get_con(adap); | 130 | int sta = pca_get_con(adap); |
@@ -142,19 +142,19 @@ static void pca_tx_byte(struct i2c_algo_pca_data *adap, | |||
142 | * | 142 | * |
143 | * returns immediately. | 143 | * returns immediately. |
144 | */ | 144 | */ |
145 | static void pca_rx_byte(struct i2c_algo_pca_data *adap, | 145 | static void pca_rx_byte(struct i2c_algo_pca_data *adap, |
146 | __u8 *b, int ack) | 146 | __u8 *b, int ack) |
147 | { | 147 | { |
148 | *b = pca_inw(adap, I2C_PCA_DAT); | 148 | *b = pca_inw(adap, I2C_PCA_DAT); |
149 | DEB2("=== READ %#04x %s\n", *b, ack ? "ACK" : "NACK"); | 149 | DEB2("=== READ %#04x %s\n", *b, ack ? "ACK" : "NACK"); |
150 | } | 150 | } |
151 | 151 | ||
152 | /* | 152 | /* |
153 | * Setup ACK or NACK for next received byte and wait for it to arrive. | 153 | * Setup ACK or NACK for next received byte and wait for it to arrive. |
154 | * | 154 | * |
155 | * Returns after next byte has arrived. | 155 | * Returns after next byte has arrived. |
156 | */ | 156 | */ |
157 | static void pca_rx_ack(struct i2c_algo_pca_data *adap, | 157 | static void pca_rx_ack(struct i2c_algo_pca_data *adap, |
158 | int ack) | 158 | int ack) |
159 | { | 159 | { |
160 | int sta = pca_get_con(adap); | 160 | int sta = pca_get_con(adap); |
@@ -168,8 +168,8 @@ static void pca_rx_ack(struct i2c_algo_pca_data *adap, | |||
168 | pca_wait(adap); | 168 | pca_wait(adap); |
169 | } | 169 | } |
170 | 170 | ||
171 | /* | 171 | /* |
172 | * Reset the i2c bus / SIO | 172 | * Reset the i2c bus / SIO |
173 | */ | 173 | */ |
174 | static void pca_reset(struct i2c_algo_pca_data *adap) | 174 | static void pca_reset(struct i2c_algo_pca_data *adap) |
175 | { | 175 | { |
@@ -203,14 +203,14 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, | |||
203 | for (curmsg = 0; curmsg < num; curmsg++) { | 203 | for (curmsg = 0; curmsg < num; curmsg++) { |
204 | int addr, i; | 204 | int addr, i; |
205 | msg = &msgs[curmsg]; | 205 | msg = &msgs[curmsg]; |
206 | 206 | ||
207 | addr = (0x7f & msg->addr) ; | 207 | addr = (0x7f & msg->addr) ; |
208 | 208 | ||
209 | if (msg->flags & I2C_M_RD ) | 209 | if (msg->flags & I2C_M_RD ) |
210 | printk(KERN_INFO " [%02d] RD %d bytes from %#02x [%#02x, ...]\n", | 210 | printk(KERN_INFO " [%02d] RD %d bytes from %#02x [%#02x, ...]\n", |
211 | curmsg, msg->len, addr, (addr<<1) | 1); | 211 | curmsg, msg->len, addr, (addr<<1) | 1); |
212 | else { | 212 | else { |
213 | printk(KERN_INFO " [%02d] WR %d bytes to %#02x [%#02x%s", | 213 | printk(KERN_INFO " [%02d] WR %d bytes to %#02x [%#02x%s", |
214 | curmsg, msg->len, addr, addr<<1, | 214 | curmsg, msg->len, addr, addr<<1, |
215 | msg->len == 0 ? "" : ", "); | 215 | msg->len == 0 ? "" : ", "); |
216 | for(i=0; i < msg->len; i++) | 216 | for(i=0; i < msg->len; i++) |
@@ -237,7 +237,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, | |||
237 | case 0x10: /* A repeated start condition has been transmitted */ | 237 | case 0x10: /* A repeated start condition has been transmitted */ |
238 | pca_address(adap, msg); | 238 | pca_address(adap, msg); |
239 | break; | 239 | break; |
240 | 240 | ||
241 | case 0x18: /* SLA+W has been transmitted; ACK has been received */ | 241 | case 0x18: /* SLA+W has been transmitted; ACK has been received */ |
242 | case 0x28: /* Data byte in I2CDAT has been transmitted; ACK has been received */ | 242 | case 0x28: /* Data byte in I2CDAT has been transmitted; ACK has been received */ |
243 | if (numbytes < msg->len) { | 243 | if (numbytes < msg->len) { |
@@ -287,7 +287,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, | |||
287 | case 0x38: /* Arbitration lost during SLA+W, SLA+R or data bytes */ | 287 | case 0x38: /* Arbitration lost during SLA+W, SLA+R or data bytes */ |
288 | DEB2("Arbitration lost\n"); | 288 | DEB2("Arbitration lost\n"); |
289 | goto out; | 289 | goto out; |
290 | 290 | ||
291 | case 0x58: /* Data byte has been received; NOT ACK has been returned */ | 291 | case 0x58: /* Data byte has been received; NOT ACK has been returned */ |
292 | if ( numbytes == msg->len - 1 ) { | 292 | if ( numbytes == msg->len - 1 ) { |
293 | pca_rx_byte(adap, &msg->buf[numbytes], 0); | 293 | pca_rx_byte(adap, &msg->buf[numbytes], 0); |
@@ -320,13 +320,13 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, | |||
320 | printk(KERN_ERR DRIVER ": unhandled SIO state 0x%02x\n", state); | 320 | printk(KERN_ERR DRIVER ": unhandled SIO state 0x%02x\n", state); |
321 | break; | 321 | break; |
322 | } | 322 | } |
323 | 323 | ||
324 | } | 324 | } |
325 | 325 | ||
326 | ret = curmsg; | 326 | ret = curmsg; |
327 | out: | 327 | out: |
328 | DEB1(KERN_CRIT "}}} transfered %d/%d messages. " | 328 | DEB1(KERN_CRIT "}}} transfered %d/%d messages. " |
329 | "status is %#04x. control is %#04x\n", | 329 | "status is %#04x. control is %#04x\n", |
330 | curmsg, num, pca_status(adap), | 330 | curmsg, num, pca_status(adap), |
331 | pca_get_con(adap)); | 331 | pca_get_con(adap)); |
332 | return ret; | 332 | return ret; |
@@ -350,7 +350,7 @@ static int pca_init(struct i2c_algo_pca_data *adap) | |||
350 | pca_outw(adap, I2C_PCA_ADR, own << 1); | 350 | pca_outw(adap, I2C_PCA_ADR, own << 1); |
351 | 351 | ||
352 | pca_set_con(adap, I2C_PCA_CON_ENSIO | clock); | 352 | pca_set_con(adap, I2C_PCA_CON_ENSIO | clock); |
353 | udelay(500); /* 500 ยตs for oscilator to stabilise */ | 353 | udelay(500); /* 500 us for oscilator to stabilise */ |
354 | 354 | ||
355 | return 0; | 355 | return 0; |
356 | } | 356 | } |
@@ -360,8 +360,8 @@ static const struct i2c_algorithm pca_algo = { | |||
360 | .functionality = pca_func, | 360 | .functionality = pca_func, |
361 | }; | 361 | }; |
362 | 362 | ||
363 | /* | 363 | /* |
364 | * registering functions to load algorithms at runtime | 364 | * registering functions to load algorithms at runtime |
365 | */ | 365 | */ |
366 | int i2c_pca_add_bus(struct i2c_adapter *adap) | 366 | int i2c_pca_add_bus(struct i2c_adapter *adap) |
367 | { | 367 | { |