diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-05-22 02:36:56 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-05-22 02:36:56 -0400 |
commit | cf9b59e9d3e008591d1f54830f570982bb307a0d (patch) | |
tree | 113478ce8fd8c832ba726ffdf59b82cb46356476 /drivers/i2c | |
parent | 44504b2bebf8b5823c59484e73096a7d6574471d (diff) | |
parent | f4b87dee923342505e1ddba8d34ce9de33e75050 (diff) |
Merge remote branch 'origin' into secretlab/next-devicetree
Merging in current state of Linus' tree to deal with merge conflicts and
build failures in vio.c after merge.
Conflicts:
drivers/i2c/busses/i2c-cpm.c
drivers/i2c/busses/i2c-mpc.c
drivers/net/gianfar.c
Also fixed up one line in arch/powerpc/kernel/vio.c to use the
correct node pointer.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/i2c')
50 files changed, 656 insertions, 431 deletions
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index dcdaf8e675bf..2b9a8f54bb2c 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c | |||
@@ -109,13 +109,13 @@ static void pca_stop(struct i2c_algo_pca_data *adap) | |||
109 | * returns after the address has been sent | 109 | * returns after the address has been sent |
110 | */ | 110 | */ |
111 | static int pca_address(struct i2c_algo_pca_data *adap, | 111 | static int pca_address(struct i2c_algo_pca_data *adap, |
112 | struct i2c_msg *msg) | 112 | struct i2c_msg *msg) |
113 | { | 113 | { |
114 | int sta = pca_get_con(adap); | 114 | int sta = pca_get_con(adap); |
115 | int addr; | 115 | int addr; |
116 | 116 | ||
117 | addr = ( (0x7f & msg->addr) << 1 ); | 117 | addr = ((0x7f & msg->addr) << 1); |
118 | if (msg->flags & I2C_M_RD ) | 118 | if (msg->flags & I2C_M_RD) |
119 | addr |= 1; | 119 | addr |= 1; |
120 | DEB2("=== SLAVE ADDRESS %#04x+%c=%#04x\n", | 120 | DEB2("=== SLAVE ADDRESS %#04x+%c=%#04x\n", |
121 | msg->addr, msg->flags & I2C_M_RD ? 'R' : 'W', addr); | 121 | msg->addr, msg->flags & I2C_M_RD ? 'R' : 'W', addr); |
@@ -134,7 +134,7 @@ static int pca_address(struct i2c_algo_pca_data *adap, | |||
134 | * Returns after the byte has been transmitted | 134 | * Returns after the byte has been transmitted |
135 | */ | 135 | */ |
136 | static int pca_tx_byte(struct i2c_algo_pca_data *adap, | 136 | static int pca_tx_byte(struct i2c_algo_pca_data *adap, |
137 | __u8 b) | 137 | __u8 b) |
138 | { | 138 | { |
139 | int sta = pca_get_con(adap); | 139 | int sta = pca_get_con(adap); |
140 | DEB2("=== WRITE %#04x\n", b); | 140 | DEB2("=== WRITE %#04x\n", b); |
@@ -164,13 +164,13 @@ static void pca_rx_byte(struct i2c_algo_pca_data *adap, | |||
164 | * Returns after next byte has arrived. | 164 | * Returns after next byte has arrived. |
165 | */ | 165 | */ |
166 | static int pca_rx_ack(struct i2c_algo_pca_data *adap, | 166 | static int pca_rx_ack(struct i2c_algo_pca_data *adap, |
167 | int ack) | 167 | int ack) |
168 | { | 168 | { |
169 | int sta = pca_get_con(adap); | 169 | int sta = pca_get_con(adap); |
170 | 170 | ||
171 | sta &= ~(I2C_PCA_CON_STO|I2C_PCA_CON_STA|I2C_PCA_CON_SI|I2C_PCA_CON_AA); | 171 | sta &= ~(I2C_PCA_CON_STO|I2C_PCA_CON_STA|I2C_PCA_CON_SI|I2C_PCA_CON_AA); |
172 | 172 | ||
173 | if ( ack ) | 173 | if (ack) |
174 | sta |= I2C_PCA_CON_AA; | 174 | sta |= I2C_PCA_CON_AA; |
175 | 175 | ||
176 | pca_set_con(adap, sta); | 176 | pca_set_con(adap, sta); |
@@ -178,12 +178,12 @@ static int pca_rx_ack(struct i2c_algo_pca_data *adap, | |||
178 | } | 178 | } |
179 | 179 | ||
180 | static int pca_xfer(struct i2c_adapter *i2c_adap, | 180 | static int pca_xfer(struct i2c_adapter *i2c_adap, |
181 | struct i2c_msg *msgs, | 181 | struct i2c_msg *msgs, |
182 | int num) | 182 | int num) |
183 | { | 183 | { |
184 | struct i2c_algo_pca_data *adap = i2c_adap->algo_data; | 184 | struct i2c_algo_pca_data *adap = i2c_adap->algo_data; |
185 | struct i2c_msg *msg = NULL; | 185 | struct i2c_msg *msg = NULL; |
186 | int curmsg; | 186 | int curmsg; |
187 | int numbytes = 0; | 187 | int numbytes = 0; |
188 | int state; | 188 | int state; |
189 | int ret; | 189 | int ret; |
@@ -202,21 +202,21 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, | |||
202 | 202 | ||
203 | DEB1("{{{ XFER %d messages\n", num); | 203 | DEB1("{{{ XFER %d messages\n", num); |
204 | 204 | ||
205 | if (i2c_debug>=2) { | 205 | if (i2c_debug >= 2) { |
206 | for (curmsg = 0; curmsg < num; curmsg++) { | 206 | for (curmsg = 0; curmsg < num; curmsg++) { |
207 | int addr, i; | 207 | int addr, i; |
208 | msg = &msgs[curmsg]; | 208 | msg = &msgs[curmsg]; |
209 | 209 | ||
210 | addr = (0x7f & msg->addr) ; | 210 | addr = (0x7f & msg->addr) ; |
211 | 211 | ||
212 | if (msg->flags & I2C_M_RD ) | 212 | if (msg->flags & I2C_M_RD) |
213 | printk(KERN_INFO " [%02d] RD %d bytes from %#02x [%#02x, ...]\n", | 213 | printk(KERN_INFO " [%02d] RD %d bytes from %#02x [%#02x, ...]\n", |
214 | curmsg, msg->len, addr, (addr<<1) | 1); | 214 | curmsg, msg->len, addr, (addr << 1) | 1); |
215 | else { | 215 | else { |
216 | printk(KERN_INFO " [%02d] WR %d bytes to %#02x [%#02x%s", | 216 | printk(KERN_INFO " [%02d] WR %d bytes to %#02x [%#02x%s", |
217 | curmsg, msg->len, addr, addr<<1, | 217 | curmsg, msg->len, addr, addr << 1, |
218 | msg->len == 0 ? "" : ", "); | 218 | msg->len == 0 ? "" : ", "); |
219 | for(i=0; i < msg->len; i++) | 219 | for (i = 0; i < msg->len; i++) |
220 | printk("%#04x%s", msg->buf[i], i == msg->len - 1 ? "" : ", "); | 220 | printk("%#04x%s", msg->buf[i], i == msg->len - 1 ? "" : ", "); |
221 | printk("]\n"); | 221 | printk("]\n"); |
222 | } | 222 | } |
@@ -305,7 +305,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, | |||
305 | goto out; | 305 | goto out; |
306 | 306 | ||
307 | case 0x58: /* Data byte has been received; NOT ACK has been returned */ | 307 | case 0x58: /* Data byte has been received; NOT ACK has been returned */ |
308 | if ( numbytes == msg->len - 1 ) { | 308 | if (numbytes == msg->len - 1) { |
309 | pca_rx_byte(adap, &msg->buf[numbytes], 0); | 309 | pca_rx_byte(adap, &msg->buf[numbytes], 0); |
310 | curmsg++; numbytes = 0; | 310 | curmsg++; numbytes = 0; |
311 | if (curmsg == num) | 311 | if (curmsg == num) |
@@ -352,7 +352,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, | |||
352 | 352 | ||
353 | static u32 pca_func(struct i2c_adapter *adap) | 353 | static u32 pca_func(struct i2c_adapter *adap) |
354 | { | 354 | { |
355 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; | 355 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; |
356 | } | 356 | } |
357 | 357 | ||
358 | static const struct i2c_algorithm pca_algo = { | 358 | static const struct i2c_algorithm pca_algo = { |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 9c6170cd9aac..87ab0568bb0e 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -564,7 +564,7 @@ config I2C_STU300 | |||
564 | 564 | ||
565 | config I2C_VERSATILE | 565 | config I2C_VERSATILE |
566 | tristate "ARM Versatile/Realview I2C bus support" | 566 | tristate "ARM Versatile/Realview I2C bus support" |
567 | depends on ARCH_VERSATILE || ARCH_REALVIEW | 567 | depends on ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS |
568 | select I2C_ALGOBIT | 568 | select I2C_ALGOBIT |
569 | help | 569 | help |
570 | Say yes if you want to support the I2C serial bus on ARMs Versatile | 570 | Say yes if you want to support the I2C serial bus on ARMs Versatile |
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index bd8f1e4d9e6c..906a3ca50db6 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -60,7 +60,7 @@ | |||
60 | #include <linux/i2c.h> | 60 | #include <linux/i2c.h> |
61 | #include <linux/init.h> | 61 | #include <linux/init.h> |
62 | #include <linux/acpi.h> | 62 | #include <linux/acpi.h> |
63 | #include <asm/io.h> | 63 | #include <linux/io.h> |
64 | 64 | ||
65 | 65 | ||
66 | /* ALI1535 SMBus address offsets */ | 66 | /* ALI1535 SMBus address offsets */ |
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 659f63f5e4af..b14f6d68221d 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c | |||
@@ -67,7 +67,7 @@ | |||
67 | #include <linux/i2c.h> | 67 | #include <linux/i2c.h> |
68 | #include <linux/init.h> | 68 | #include <linux/init.h> |
69 | #include <linux/acpi.h> | 69 | #include <linux/acpi.h> |
70 | #include <asm/io.h> | 70 | #include <linux/io.h> |
71 | 71 | ||
72 | /* ALI15X3 SMBus address offsets */ | 72 | /* ALI15X3 SMBus address offsets */ |
73 | #define SMBHSTSTS (0 + ali15x3_smba) | 73 | #define SMBHSTSTS (0 + ali15x3_smba) |
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index c5a9fa488e7f..03bcd07c4697 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include <linux/i2c.h> | 43 | #include <linux/i2c.h> |
44 | #include <linux/init.h> | 44 | #include <linux/init.h> |
45 | #include <linux/acpi.h> | 45 | #include <linux/acpi.h> |
46 | #include <asm/io.h> | 46 | #include <linux/io.h> |
47 | 47 | ||
48 | /* AMD756 SMBus address offsets */ | 48 | /* AMD756 SMBus address offsets */ |
49 | #define SMB_ADDR_OFFSET 0xE0 | 49 | #define SMB_ADDR_OFFSET 0xE0 |
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index 2fbef27b6cd6..af1e5e254b7b 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/acpi.h> | 19 | #include <linux/acpi.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <asm/io.h> | 21 | #include <linux/io.h> |
22 | 22 | ||
23 | MODULE_LICENSE("GPL"); | 23 | MODULE_LICENSE("GPL"); |
24 | MODULE_AUTHOR ("Vojtech Pavlik <vojtech@suse.cz>"); | 24 | MODULE_AUTHOR ("Vojtech Pavlik <vojtech@suse.cz>"); |
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 06e1ecb4919f..305c07504f7e 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -23,8 +23,7 @@ | |||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/clk.h> | 24 | #include <linux/clk.h> |
25 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | 26 | #include <linux/io.h> | |
27 | #include <asm/io.h> | ||
28 | 27 | ||
29 | #include <mach/at91_twi.h> | 28 | #include <mach/at91_twi.h> |
30 | #include <mach/board.h> | 29 | #include <mach/board.h> |
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c index f1e14dd590c9..fb26e5c67515 100644 --- a/drivers/i2c/busses/i2c-bfin-twi.c +++ b/drivers/i2c/busses/i2c-bfin-twi.c | |||
@@ -25,8 +25,6 @@ | |||
25 | #include <asm/portmux.h> | 25 | #include <asm/portmux.h> |
26 | #include <asm/irq.h> | 26 | #include <asm/irq.h> |
27 | 27 | ||
28 | #define POLL_TIMEOUT (2 * HZ) | ||
29 | |||
30 | /* SMBus mode*/ | 28 | /* SMBus mode*/ |
31 | #define TWI_I2C_MODE_STANDARD 1 | 29 | #define TWI_I2C_MODE_STANDARD 1 |
32 | #define TWI_I2C_MODE_STANDARDSUB 2 | 30 | #define TWI_I2C_MODE_STANDARDSUB 2 |
@@ -44,8 +42,6 @@ struct bfin_twi_iface { | |||
44 | int cur_mode; | 42 | int cur_mode; |
45 | int manual_stop; | 43 | int manual_stop; |
46 | int result; | 44 | int result; |
47 | int timeout_count; | ||
48 | struct timer_list timeout_timer; | ||
49 | struct i2c_adapter adap; | 45 | struct i2c_adapter adap; |
50 | struct completion complete; | 46 | struct completion complete; |
51 | struct i2c_msg *pmsg; | 47 | struct i2c_msg *pmsg; |
@@ -85,14 +81,15 @@ static const u16 pin_req[2][3] = { | |||
85 | {P_TWI1_SCL, P_TWI1_SDA, 0}, | 81 | {P_TWI1_SCL, P_TWI1_SDA, 0}, |
86 | }; | 82 | }; |
87 | 83 | ||
88 | static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface) | 84 | static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, |
85 | unsigned short twi_int_status) | ||
89 | { | 86 | { |
90 | unsigned short twi_int_status = read_INT_STAT(iface); | ||
91 | unsigned short mast_stat = read_MASTER_STAT(iface); | 87 | unsigned short mast_stat = read_MASTER_STAT(iface); |
92 | 88 | ||
93 | if (twi_int_status & XMTSERV) { | 89 | if (twi_int_status & XMTSERV) { |
94 | /* Transmit next data */ | 90 | /* Transmit next data */ |
95 | if (iface->writeNum > 0) { | 91 | if (iface->writeNum > 0) { |
92 | SSYNC(); | ||
96 | write_XMT_DATA8(iface, *(iface->transPtr++)); | 93 | write_XMT_DATA8(iface, *(iface->transPtr++)); |
97 | iface->writeNum--; | 94 | iface->writeNum--; |
98 | } | 95 | } |
@@ -114,10 +111,6 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface) | |||
114 | write_MASTER_CTL(iface, | 111 | write_MASTER_CTL(iface, |
115 | (read_MASTER_CTL(iface) | RSTART) & ~MDIR); | 112 | (read_MASTER_CTL(iface) | RSTART) & ~MDIR); |
116 | } | 113 | } |
117 | SSYNC(); | ||
118 | /* Clear status */ | ||
119 | write_INT_STAT(iface, XMTSERV); | ||
120 | SSYNC(); | ||
121 | } | 114 | } |
122 | if (twi_int_status & RCVSERV) { | 115 | if (twi_int_status & RCVSERV) { |
123 | if (iface->readNum > 0) { | 116 | if (iface->readNum > 0) { |
@@ -139,7 +132,6 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface) | |||
139 | } else if (iface->manual_stop) { | 132 | } else if (iface->manual_stop) { |
140 | write_MASTER_CTL(iface, | 133 | write_MASTER_CTL(iface, |
141 | read_MASTER_CTL(iface) | STOP); | 134 | read_MASTER_CTL(iface) | STOP); |
142 | SSYNC(); | ||
143 | } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && | 135 | } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && |
144 | iface->cur_msg + 1 < iface->msg_num) { | 136 | iface->cur_msg + 1 < iface->msg_num) { |
145 | if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD) | 137 | if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD) |
@@ -148,44 +140,37 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface) | |||
148 | else | 140 | else |
149 | write_MASTER_CTL(iface, | 141 | write_MASTER_CTL(iface, |
150 | (read_MASTER_CTL(iface) | RSTART) & ~MDIR); | 142 | (read_MASTER_CTL(iface) | RSTART) & ~MDIR); |
151 | SSYNC(); | ||
152 | } | 143 | } |
153 | /* Clear interrupt source */ | ||
154 | write_INT_STAT(iface, RCVSERV); | ||
155 | SSYNC(); | ||
156 | } | 144 | } |
157 | if (twi_int_status & MERR) { | 145 | if (twi_int_status & MERR) { |
158 | write_INT_STAT(iface, MERR); | ||
159 | write_INT_MASK(iface, 0); | 146 | write_INT_MASK(iface, 0); |
160 | write_MASTER_STAT(iface, 0x3e); | 147 | write_MASTER_STAT(iface, 0x3e); |
161 | write_MASTER_CTL(iface, 0); | 148 | write_MASTER_CTL(iface, 0); |
162 | SSYNC(); | ||
163 | iface->result = -EIO; | 149 | iface->result = -EIO; |
164 | /* if both err and complete int stats are set, return proper | 150 | |
165 | * results. | 151 | if (mast_stat & LOSTARB) |
152 | dev_dbg(&iface->adap.dev, "Lost Arbitration\n"); | ||
153 | if (mast_stat & ANAK) | ||
154 | dev_dbg(&iface->adap.dev, "Address Not Acknowledged\n"); | ||
155 | if (mast_stat & DNAK) | ||
156 | dev_dbg(&iface->adap.dev, "Data Not Acknowledged\n"); | ||
157 | if (mast_stat & BUFRDERR) | ||
158 | dev_dbg(&iface->adap.dev, "Buffer Read Error\n"); | ||
159 | if (mast_stat & BUFWRERR) | ||
160 | dev_dbg(&iface->adap.dev, "Buffer Write Error\n"); | ||
161 | |||
162 | /* If it is a quick transfer, only address without data, | ||
163 | * not an err, return 1. | ||
166 | */ | 164 | */ |
167 | if (twi_int_status & MCOMP) { | 165 | if (iface->cur_mode == TWI_I2C_MODE_STANDARD && |
168 | write_INT_STAT(iface, MCOMP); | 166 | iface->transPtr == NULL && |
169 | write_INT_MASK(iface, 0); | 167 | (twi_int_status & MCOMP) && (mast_stat & DNAK)) |
170 | write_MASTER_CTL(iface, 0); | 168 | iface->result = 1; |
171 | SSYNC(); | 169 | |
172 | /* If it is a quick transfer, only address bug no data, | ||
173 | * not an err, return 1. | ||
174 | */ | ||
175 | if (iface->writeNum == 0 && (mast_stat & BUFRDERR)) | ||
176 | iface->result = 1; | ||
177 | /* If address not acknowledged return -1, | ||
178 | * else return 0. | ||
179 | */ | ||
180 | else if (!(mast_stat & ANAK)) | ||
181 | iface->result = 0; | ||
182 | } | ||
183 | complete(&iface->complete); | 170 | complete(&iface->complete); |
184 | return; | 171 | return; |
185 | } | 172 | } |
186 | if (twi_int_status & MCOMP) { | 173 | if (twi_int_status & MCOMP) { |
187 | write_INT_STAT(iface, MCOMP); | ||
188 | SSYNC(); | ||
189 | if (iface->cur_mode == TWI_I2C_MODE_COMBINED) { | 174 | if (iface->cur_mode == TWI_I2C_MODE_COMBINED) { |
190 | if (iface->readNum == 0) { | 175 | if (iface->readNum == 0) { |
191 | /* set the read number to 1 and ask for manual | 176 | /* set the read number to 1 and ask for manual |
@@ -207,7 +192,6 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface) | |||
207 | /* remove restart bit and enable master receive */ | 192 | /* remove restart bit and enable master receive */ |
208 | write_MASTER_CTL(iface, | 193 | write_MASTER_CTL(iface, |
209 | read_MASTER_CTL(iface) & ~RSTART); | 194 | read_MASTER_CTL(iface) & ~RSTART); |
210 | SSYNC(); | ||
211 | } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && | 195 | } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && |
212 | iface->cur_msg+1 < iface->msg_num) { | 196 | iface->cur_msg+1 < iface->msg_num) { |
213 | iface->cur_msg++; | 197 | iface->cur_msg++; |
@@ -226,7 +210,6 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface) | |||
226 | write_XMT_DATA8(iface, | 210 | write_XMT_DATA8(iface, |
227 | *(iface->transPtr++)); | 211 | *(iface->transPtr++)); |
228 | iface->writeNum--; | 212 | iface->writeNum--; |
229 | SSYNC(); | ||
230 | } | 213 | } |
231 | } | 214 | } |
232 | 215 | ||
@@ -244,15 +227,13 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface) | |||
244 | /* remove restart bit and enable master receive */ | 227 | /* remove restart bit and enable master receive */ |
245 | write_MASTER_CTL(iface, | 228 | write_MASTER_CTL(iface, |
246 | read_MASTER_CTL(iface) & ~RSTART); | 229 | read_MASTER_CTL(iface) & ~RSTART); |
247 | SSYNC(); | ||
248 | } else { | 230 | } else { |
249 | iface->result = 1; | 231 | iface->result = 1; |
250 | write_INT_MASK(iface, 0); | 232 | write_INT_MASK(iface, 0); |
251 | write_MASTER_CTL(iface, 0); | 233 | write_MASTER_CTL(iface, 0); |
252 | SSYNC(); | ||
253 | complete(&iface->complete); | ||
254 | } | 234 | } |
255 | } | 235 | } |
236 | complete(&iface->complete); | ||
256 | } | 237 | } |
257 | 238 | ||
258 | /* Interrupt handler */ | 239 | /* Interrupt handler */ |
@@ -260,38 +241,26 @@ static irqreturn_t bfin_twi_interrupt_entry(int irq, void *dev_id) | |||
260 | { | 241 | { |
261 | struct bfin_twi_iface *iface = dev_id; | 242 | struct bfin_twi_iface *iface = dev_id; |
262 | unsigned long flags; | 243 | unsigned long flags; |
244 | unsigned short twi_int_status; | ||
263 | 245 | ||
264 | spin_lock_irqsave(&iface->lock, flags); | 246 | spin_lock_irqsave(&iface->lock, flags); |
265 | del_timer(&iface->timeout_timer); | 247 | while (1) { |
266 | bfin_twi_handle_interrupt(iface); | 248 | twi_int_status = read_INT_STAT(iface); |
267 | spin_unlock_irqrestore(&iface->lock, flags); | 249 | if (!twi_int_status) |
268 | return IRQ_HANDLED; | 250 | break; |
269 | } | 251 | /* Clear interrupt status */ |
270 | 252 | write_INT_STAT(iface, twi_int_status); | |
271 | static void bfin_twi_timeout(unsigned long data) | 253 | bfin_twi_handle_interrupt(iface, twi_int_status); |
272 | { | 254 | SSYNC(); |
273 | struct bfin_twi_iface *iface = (struct bfin_twi_iface *)data; | ||
274 | unsigned long flags; | ||
275 | |||
276 | spin_lock_irqsave(&iface->lock, flags); | ||
277 | bfin_twi_handle_interrupt(iface); | ||
278 | if (iface->result == 0) { | ||
279 | iface->timeout_count--; | ||
280 | if (iface->timeout_count > 0) { | ||
281 | iface->timeout_timer.expires = jiffies + POLL_TIMEOUT; | ||
282 | add_timer(&iface->timeout_timer); | ||
283 | } else { | ||
284 | iface->result = -1; | ||
285 | complete(&iface->complete); | ||
286 | } | ||
287 | } | 255 | } |
288 | spin_unlock_irqrestore(&iface->lock, flags); | 256 | spin_unlock_irqrestore(&iface->lock, flags); |
257 | return IRQ_HANDLED; | ||
289 | } | 258 | } |
290 | 259 | ||
291 | /* | 260 | /* |
292 | * Generic i2c master transfer entrypoint | 261 | * One i2c master transfer |
293 | */ | 262 | */ |
294 | static int bfin_twi_master_xfer(struct i2c_adapter *adap, | 263 | static int bfin_twi_do_master_xfer(struct i2c_adapter *adap, |
295 | struct i2c_msg *msgs, int num) | 264 | struct i2c_msg *msgs, int num) |
296 | { | 265 | { |
297 | struct bfin_twi_iface *iface = adap->algo_data; | 266 | struct bfin_twi_iface *iface = adap->algo_data; |
@@ -319,7 +288,6 @@ static int bfin_twi_master_xfer(struct i2c_adapter *adap, | |||
319 | iface->transPtr = pmsg->buf; | 288 | iface->transPtr = pmsg->buf; |
320 | iface->writeNum = iface->readNum = pmsg->len; | 289 | iface->writeNum = iface->readNum = pmsg->len; |
321 | iface->result = 0; | 290 | iface->result = 0; |
322 | iface->timeout_count = 10; | ||
323 | init_completion(&(iface->complete)); | 291 | init_completion(&(iface->complete)); |
324 | /* Set Transmit device address */ | 292 | /* Set Transmit device address */ |
325 | write_MASTER_ADDR(iface, pmsg->addr); | 293 | write_MASTER_ADDR(iface, pmsg->addr); |
@@ -358,30 +326,41 @@ static int bfin_twi_master_xfer(struct i2c_adapter *adap, | |||
358 | iface->manual_stop = 1; | 326 | iface->manual_stop = 1; |
359 | } | 327 | } |
360 | 328 | ||
361 | iface->timeout_timer.expires = jiffies + POLL_TIMEOUT; | ||
362 | add_timer(&iface->timeout_timer); | ||
363 | |||
364 | /* Master enable */ | 329 | /* Master enable */ |
365 | write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN | | 330 | write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN | |
366 | ((iface->read_write == I2C_SMBUS_READ) ? MDIR : 0) | | 331 | ((iface->read_write == I2C_SMBUS_READ) ? MDIR : 0) | |
367 | ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ > 100) ? FAST : 0)); | 332 | ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ > 100) ? FAST : 0)); |
368 | SSYNC(); | 333 | SSYNC(); |
369 | 334 | ||
370 | wait_for_completion(&iface->complete); | 335 | while (!iface->result) { |
371 | 336 | if (!wait_for_completion_timeout(&iface->complete, | |
372 | rc = iface->result; | 337 | adap->timeout)) { |
338 | iface->result = -1; | ||
339 | dev_err(&adap->dev, "master transfer timeout\n"); | ||
340 | } | ||
341 | } | ||
373 | 342 | ||
374 | if (rc == 1) | 343 | if (iface->result == 1) |
375 | return num; | 344 | rc = iface->cur_msg + 1; |
376 | else | 345 | else |
377 | return rc; | 346 | rc = iface->result; |
347 | |||
348 | return rc; | ||
378 | } | 349 | } |
379 | 350 | ||
380 | /* | 351 | /* |
381 | * SMBus type transfer entrypoint | 352 | * Generic i2c master transfer entrypoint |
382 | */ | 353 | */ |
354 | static int bfin_twi_master_xfer(struct i2c_adapter *adap, | ||
355 | struct i2c_msg *msgs, int num) | ||
356 | { | ||
357 | return bfin_twi_do_master_xfer(adap, msgs, num); | ||
358 | } | ||
383 | 359 | ||
384 | int bfin_twi_smbus_xfer(struct i2c_adapter *adap, u16 addr, | 360 | /* |
361 | * One I2C SMBus transfer | ||
362 | */ | ||
363 | int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr, | ||
385 | unsigned short flags, char read_write, | 364 | unsigned short flags, char read_write, |
386 | u8 command, int size, union i2c_smbus_data *data) | 365 | u8 command, int size, union i2c_smbus_data *data) |
387 | { | 366 | { |
@@ -469,7 +448,6 @@ int bfin_twi_smbus_xfer(struct i2c_adapter *adap, u16 addr, | |||
469 | iface->manual_stop = 0; | 448 | iface->manual_stop = 0; |
470 | iface->read_write = read_write; | 449 | iface->read_write = read_write; |
471 | iface->command = command; | 450 | iface->command = command; |
472 | iface->timeout_count = 10; | ||
473 | init_completion(&(iface->complete)); | 451 | init_completion(&(iface->complete)); |
474 | 452 | ||
475 | /* FIFO Initiation. Data in FIFO should be discarded before | 453 | /* FIFO Initiation. Data in FIFO should be discarded before |
@@ -486,9 +464,6 @@ int bfin_twi_smbus_xfer(struct i2c_adapter *adap, u16 addr, | |||
486 | write_MASTER_ADDR(iface, addr); | 464 | write_MASTER_ADDR(iface, addr); |
487 | SSYNC(); | 465 | SSYNC(); |
488 | 466 | ||
489 | iface->timeout_timer.expires = jiffies + POLL_TIMEOUT; | ||
490 | add_timer(&iface->timeout_timer); | ||
491 | |||
492 | switch (iface->cur_mode) { | 467 | switch (iface->cur_mode) { |
493 | case TWI_I2C_MODE_STANDARDSUB: | 468 | case TWI_I2C_MODE_STANDARDSUB: |
494 | write_XMT_DATA8(iface, iface->command); | 469 | write_XMT_DATA8(iface, iface->command); |
@@ -550,10 +525,8 @@ int bfin_twi_smbus_xfer(struct i2c_adapter *adap, u16 addr, | |||
550 | else if (iface->readNum > 255) { | 525 | else if (iface->readNum > 255) { |
551 | write_MASTER_CTL(iface, 0xff << 6); | 526 | write_MASTER_CTL(iface, 0xff << 6); |
552 | iface->manual_stop = 1; | 527 | iface->manual_stop = 1; |
553 | } else { | 528 | } else |
554 | del_timer(&iface->timeout_timer); | ||
555 | break; | 529 | break; |
556 | } | ||
557 | } | 530 | } |
558 | } | 531 | } |
559 | write_INT_MASK(iface, MCOMP | MERR | | 532 | write_INT_MASK(iface, MCOMP | MERR | |
@@ -569,7 +542,13 @@ int bfin_twi_smbus_xfer(struct i2c_adapter *adap, u16 addr, | |||
569 | } | 542 | } |
570 | SSYNC(); | 543 | SSYNC(); |
571 | 544 | ||
572 | wait_for_completion(&iface->complete); | 545 | while (!iface->result) { |
546 | if (!wait_for_completion_timeout(&iface->complete, | ||
547 | adap->timeout)) { | ||
548 | iface->result = -1; | ||
549 | dev_err(&adap->dev, "smbus transfer timeout\n"); | ||
550 | } | ||
551 | } | ||
573 | 552 | ||
574 | rc = (iface->result >= 0) ? 0 : -1; | 553 | rc = (iface->result >= 0) ? 0 : -1; |
575 | 554 | ||
@@ -577,6 +556,17 @@ int bfin_twi_smbus_xfer(struct i2c_adapter *adap, u16 addr, | |||
577 | } | 556 | } |
578 | 557 | ||
579 | /* | 558 | /* |
559 | * Generic I2C SMBus transfer entrypoint | ||
560 | */ | ||
561 | int bfin_twi_smbus_xfer(struct i2c_adapter *adap, u16 addr, | ||
562 | unsigned short flags, char read_write, | ||
563 | u8 command, int size, union i2c_smbus_data *data) | ||
564 | { | ||
565 | return bfin_twi_do_smbus_xfer(adap, addr, flags, | ||
566 | read_write, command, size, data); | ||
567 | } | ||
568 | |||
569 | /* | ||
580 | * Return what the adapter supports | 570 | * Return what the adapter supports |
581 | */ | 571 | */ |
582 | static u32 bfin_twi_functionality(struct i2c_adapter *adap) | 572 | static u32 bfin_twi_functionality(struct i2c_adapter *adap) |
@@ -667,10 +657,6 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev) | |||
667 | goto out_error_no_irq; | 657 | goto out_error_no_irq; |
668 | } | 658 | } |
669 | 659 | ||
670 | init_timer(&(iface->timeout_timer)); | ||
671 | iface->timeout_timer.function = bfin_twi_timeout; | ||
672 | iface->timeout_timer.data = (unsigned long)iface; | ||
673 | |||
674 | p_adap = &iface->adap; | 660 | p_adap = &iface->adap; |
675 | p_adap->nr = pdev->id; | 661 | p_adap->nr = pdev->id; |
676 | strlcpy(p_adap->name, pdev->name, sizeof(p_adap->name)); | 662 | strlcpy(p_adap->name, pdev->name, sizeof(p_adap->name)); |
@@ -678,6 +664,8 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev) | |||
678 | p_adap->algo_data = iface; | 664 | p_adap->algo_data = iface; |
679 | p_adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; | 665 | p_adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; |
680 | p_adap->dev.parent = &pdev->dev; | 666 | p_adap->dev.parent = &pdev->dev; |
667 | p_adap->timeout = 5 * HZ; | ||
668 | p_adap->retries = 3; | ||
681 | 669 | ||
682 | rc = peripheral_request_list(pin_req[pdev->id], "i2c-bfin-twi"); | 670 | rc = peripheral_request_list(pin_req[pdev->id], "i2c-bfin-twi"); |
683 | if (rc) { | 671 | if (rc) { |
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c index 7637e1234142..b02b4533651d 100644 --- a/drivers/i2c/busses/i2c-cpm.c +++ b/drivers/i2c/busses/i2c-cpm.c | |||
@@ -441,7 +441,7 @@ static int __devinit cpm_i2c_setup(struct cpm_i2c *cpm) | |||
441 | init_waitqueue_head(&cpm->i2c_wait); | 441 | init_waitqueue_head(&cpm->i2c_wait); |
442 | 442 | ||
443 | cpm->irq = of_irq_to_resource(ofdev->dev.of_node, 0, NULL); | 443 | cpm->irq = of_irq_to_resource(ofdev->dev.of_node, 0, NULL); |
444 | if (cpm->irq == NO_IRQ) | 444 | if (!cpm->irq) |
445 | return -EINVAL; | 445 | return -EINVAL; |
446 | 446 | ||
447 | /* Install interrupt handler. */ | 447 | /* Install interrupt handler. */ |
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c index 612255614a66..e5b1a3bf5b80 100644 --- a/drivers/i2c/busses/i2c-elektor.c +++ b/drivers/i2c/busses/i2c-elektor.c | |||
@@ -37,8 +37,8 @@ | |||
37 | #include <linux/isa.h> | 37 | #include <linux/isa.h> |
38 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
39 | #include <linux/i2c-algo-pcf.h> | 39 | #include <linux/i2c-algo-pcf.h> |
40 | #include <linux/io.h> | ||
40 | 41 | ||
41 | #include <asm/io.h> | ||
42 | #include <asm/irq.h> | 42 | #include <asm/irq.h> |
43 | 43 | ||
44 | #include "../algos/i2c-algo-pcf.h" | 44 | #include "../algos/i2c-algo-pcf.h" |
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index c21077d248af..d9aa9a649e35 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c | |||
@@ -211,7 +211,7 @@ static int __init i2c_gpio_init(void) | |||
211 | 211 | ||
212 | return ret; | 212 | return ret; |
213 | } | 213 | } |
214 | module_init(i2c_gpio_init); | 214 | subsys_initcall(i2c_gpio_init); |
215 | 215 | ||
216 | static void __exit i2c_gpio_exit(void) | 216 | static void __exit i2c_gpio_exit(void) |
217 | { | 217 | { |
diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c index ce87a902c94d..3df1bc80f37a 100644 --- a/drivers/i2c/busses/i2c-highlander.c +++ b/drivers/i2c/busses/i2c-highlander.c | |||
@@ -282,7 +282,6 @@ static int highlander_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, | |||
282 | union i2c_smbus_data *data) | 282 | union i2c_smbus_data *data) |
283 | { | 283 | { |
284 | struct highlander_i2c_dev *dev = i2c_get_adapdata(adap); | 284 | struct highlander_i2c_dev *dev = i2c_get_adapdata(adap); |
285 | int read = read_write & I2C_SMBUS_READ; | ||
286 | u16 tmp; | 285 | u16 tmp; |
287 | 286 | ||
288 | init_completion(&dev->cmd_complete); | 287 | init_completion(&dev->cmd_complete); |
@@ -337,11 +336,11 @@ static int highlander_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, | |||
337 | highlander_i2c_done(dev); | 336 | highlander_i2c_done(dev); |
338 | 337 | ||
339 | /* Set slave address */ | 338 | /* Set slave address */ |
340 | iowrite16((addr << 1) | read, dev->base + SMSMADR); | 339 | iowrite16((addr << 1) | read_write, dev->base + SMSMADR); |
341 | 340 | ||
342 | highlander_i2c_command(dev, command, dev->buf_len); | 341 | highlander_i2c_command(dev, command, dev->buf_len); |
343 | 342 | ||
344 | if (read) | 343 | if (read_write == I2C_SMBUS_READ) |
345 | return highlander_i2c_read(dev); | 344 | return highlander_i2c_read(dev); |
346 | else | 345 | else |
347 | return highlander_i2c_write(dev); | 346 | return highlander_i2c_write(dev); |
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c index c767295ad1fb..9ff1695d8458 100644 --- a/drivers/i2c/busses/i2c-hydra.c +++ b/drivers/i2c/busses/i2c-hydra.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/i2c-algo-bit.h> | 29 | #include <linux/i2c-algo-bit.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <asm/io.h> | 31 | #include <linux/io.h> |
32 | #include <asm/hydra.h> | 32 | #include <asm/hydra.h> |
33 | 33 | ||
34 | 34 | ||
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 299b918455a3..f4b21f2bb8ed 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -138,6 +138,17 @@ static struct pci_dev *I801_dev; | |||
138 | #define FEATURE_I2C_BLOCK_READ (1 << 3) | 138 | #define FEATURE_I2C_BLOCK_READ (1 << 3) |
139 | static unsigned int i801_features; | 139 | static unsigned int i801_features; |
140 | 140 | ||
141 | static const char *i801_feature_names[] = { | ||
142 | "SMBus PEC", | ||
143 | "Block buffer", | ||
144 | "Block process call", | ||
145 | "I2C block read", | ||
146 | }; | ||
147 | |||
148 | static unsigned int disable_features; | ||
149 | module_param(disable_features, uint, S_IRUGO | S_IWUSR); | ||
150 | MODULE_PARM_DESC(disable_features, "Disable selected driver features"); | ||
151 | |||
141 | /* Make sure the SMBus host is ready to start transmitting. | 152 | /* Make sure the SMBus host is ready to start transmitting. |
142 | Return 0 if it is, -EBUSY if it is not. */ | 153 | Return 0 if it is, -EBUSY if it is not. */ |
143 | static int i801_check_pre(void) | 154 | static int i801_check_pre(void) |
@@ -341,9 +352,8 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data, | |||
341 | do { | 352 | do { |
342 | msleep(1); | 353 | msleep(1); |
343 | status = inb_p(SMBHSTSTS); | 354 | status = inb_p(SMBHSTSTS); |
344 | } | 355 | } while ((!(status & SMBHSTSTS_BYTE_DONE)) |
345 | while ((!(status & SMBHSTSTS_BYTE_DONE)) | 356 | && (timeout++ < MAX_TIMEOUT)); |
346 | && (timeout++ < MAX_TIMEOUT)); | ||
347 | 357 | ||
348 | result = i801_check_post(status, timeout > MAX_TIMEOUT); | 358 | result = i801_check_post(status, timeout > MAX_TIMEOUT); |
349 | if (result < 0) | 359 | if (result < 0) |
@@ -440,9 +450,9 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, | |||
440 | } | 450 | } |
441 | 451 | ||
442 | /* Return negative errno on error. */ | 452 | /* Return negative errno on error. */ |
443 | static s32 i801_access(struct i2c_adapter * adap, u16 addr, | 453 | static s32 i801_access(struct i2c_adapter *adap, u16 addr, |
444 | unsigned short flags, char read_write, u8 command, | 454 | unsigned short flags, char read_write, u8 command, |
445 | int size, union i2c_smbus_data * data) | 455 | int size, union i2c_smbus_data *data) |
446 | { | 456 | { |
447 | int hwpec; | 457 | int hwpec; |
448 | int block = 0; | 458 | int block = 0; |
@@ -511,7 +521,7 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, | |||
511 | else | 521 | else |
512 | outb_p(inb_p(SMBAUXCTL) & (~SMBAUXCTL_CRC), SMBAUXCTL); | 522 | outb_p(inb_p(SMBAUXCTL) & (~SMBAUXCTL_CRC), SMBAUXCTL); |
513 | 523 | ||
514 | if(block) | 524 | if (block) |
515 | ret = i801_block_transaction(data, read_write, size, hwpec); | 525 | ret = i801_block_transaction(data, read_write, size, hwpec); |
516 | else | 526 | else |
517 | ret = i801_transaction(xact | ENABLE_INT9); | 527 | ret = i801_transaction(xact | ENABLE_INT9); |
@@ -523,9 +533,9 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, | |||
523 | outb_p(inb_p(SMBAUXCTL) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), | 533 | outb_p(inb_p(SMBAUXCTL) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), |
524 | SMBAUXCTL); | 534 | SMBAUXCTL); |
525 | 535 | ||
526 | if(block) | 536 | if (block) |
527 | return ret; | 537 | return ret; |
528 | if(ret) | 538 | if (ret) |
529 | return ret; | 539 | return ret; |
530 | if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) | 540 | if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) |
531 | return 0; | 541 | return 0; |
@@ -585,7 +595,7 @@ static const struct pci_device_id i801_ids[] = { | |||
585 | { 0, } | 595 | { 0, } |
586 | }; | 596 | }; |
587 | 597 | ||
588 | MODULE_DEVICE_TABLE (pci, i801_ids); | 598 | MODULE_DEVICE_TABLE(pci, i801_ids); |
589 | 599 | ||
590 | #if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE | 600 | #if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE |
591 | static unsigned char apanel_addr; | 601 | static unsigned char apanel_addr; |
@@ -689,10 +699,11 @@ static void __devinit dmi_check_onboard_devices(const struct dmi_header *dm, | |||
689 | } | 699 | } |
690 | #endif | 700 | #endif |
691 | 701 | ||
692 | static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id) | 702 | static int __devinit i801_probe(struct pci_dev *dev, |
703 | const struct pci_device_id *id) | ||
693 | { | 704 | { |
694 | unsigned char temp; | 705 | unsigned char temp; |
695 | int err; | 706 | int err, i; |
696 | #if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE | 707 | #if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE |
697 | const char *vendor; | 708 | const char *vendor; |
698 | #endif | 709 | #endif |
@@ -700,26 +711,28 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id | |||
700 | I801_dev = dev; | 711 | I801_dev = dev; |
701 | i801_features = 0; | 712 | i801_features = 0; |
702 | switch (dev->device) { | 713 | switch (dev->device) { |
703 | case PCI_DEVICE_ID_INTEL_82801EB_3: | 714 | default: |
704 | case PCI_DEVICE_ID_INTEL_ESB_4: | ||
705 | case PCI_DEVICE_ID_INTEL_ICH6_16: | ||
706 | case PCI_DEVICE_ID_INTEL_ICH7_17: | ||
707 | case PCI_DEVICE_ID_INTEL_ESB2_17: | ||
708 | case PCI_DEVICE_ID_INTEL_ICH8_5: | ||
709 | case PCI_DEVICE_ID_INTEL_ICH9_6: | ||
710 | case PCI_DEVICE_ID_INTEL_TOLAPAI_1: | ||
711 | case PCI_DEVICE_ID_INTEL_ICH10_4: | ||
712 | case PCI_DEVICE_ID_INTEL_ICH10_5: | ||
713 | case PCI_DEVICE_ID_INTEL_PCH_SMBUS: | ||
714 | case PCI_DEVICE_ID_INTEL_CPT_SMBUS: | ||
715 | i801_features |= FEATURE_I2C_BLOCK_READ; | 715 | i801_features |= FEATURE_I2C_BLOCK_READ; |
716 | /* fall through */ | 716 | /* fall through */ |
717 | case PCI_DEVICE_ID_INTEL_82801DB_3: | 717 | case PCI_DEVICE_ID_INTEL_82801DB_3: |
718 | i801_features |= FEATURE_SMBUS_PEC; | 718 | i801_features |= FEATURE_SMBUS_PEC; |
719 | i801_features |= FEATURE_BLOCK_BUFFER; | 719 | i801_features |= FEATURE_BLOCK_BUFFER; |
720 | /* fall through */ | ||
721 | case PCI_DEVICE_ID_INTEL_82801CA_3: | ||
722 | case PCI_DEVICE_ID_INTEL_82801BA_2: | ||
723 | case PCI_DEVICE_ID_INTEL_82801AB_3: | ||
724 | case PCI_DEVICE_ID_INTEL_82801AA_3: | ||
720 | break; | 725 | break; |
721 | } | 726 | } |
722 | 727 | ||
728 | /* Disable features on user request */ | ||
729 | for (i = 0; i < ARRAY_SIZE(i801_feature_names); i++) { | ||
730 | if (i801_features & disable_features & (1 << i)) | ||
731 | dev_notice(&dev->dev, "%s disabled by user\n", | ||
732 | i801_feature_names[i]); | ||
733 | } | ||
734 | i801_features &= ~disable_features; | ||
735 | |||
723 | err = pci_enable_device(dev); | 736 | err = pci_enable_device(dev); |
724 | if (err) { | 737 | if (err) { |
725 | dev_err(&dev->dev, "Failed to enable SMBus PCI device (%d)\n", | 738 | dev_err(&dev->dev, "Failed to enable SMBus PCI device (%d)\n", |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index 3876f993fe76..bf344135647a 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/interrupt.h> | 40 | #include <linux/interrupt.h> |
41 | #include <asm/irq.h> | 41 | #include <asm/irq.h> |
42 | #include <asm/io.h> | 42 | #include <linux/io.h> |
43 | #include <linux/i2c.h> | 43 | #include <linux/i2c.h> |
44 | #include <linux/i2c-id.h> | 44 | #include <linux/i2c-id.h> |
45 | #include <linux/of_platform.h> | 45 | #include <linux/of_platform.h> |
@@ -668,12 +668,12 @@ static int __devinit iic_request_irq(struct of_device *ofdev, | |||
668 | int irq; | 668 | int irq; |
669 | 669 | ||
670 | if (iic_force_poll) | 670 | if (iic_force_poll) |
671 | return NO_IRQ; | 671 | return 0; |
672 | 672 | ||
673 | irq = irq_of_parse_and_map(np, 0); | 673 | irq = irq_of_parse_and_map(np, 0); |
674 | if (irq == NO_IRQ) { | 674 | if (!irq) { |
675 | dev_err(&ofdev->dev, "irq_of_parse_and_map failed\n"); | 675 | dev_err(&ofdev->dev, "irq_of_parse_and_map failed\n"); |
676 | return NO_IRQ; | 676 | return 0; |
677 | } | 677 | } |
678 | 678 | ||
679 | /* Disable interrupts until we finish initialization, assumes | 679 | /* Disable interrupts until we finish initialization, assumes |
@@ -683,7 +683,7 @@ static int __devinit iic_request_irq(struct of_device *ofdev, | |||
683 | if (request_irq(irq, iic_handler, 0, "IBM IIC", dev)) { | 683 | if (request_irq(irq, iic_handler, 0, "IBM IIC", dev)) { |
684 | dev_err(&ofdev->dev, "request_irq %d failed\n", irq); | 684 | dev_err(&ofdev->dev, "request_irq %d failed\n", irq); |
685 | /* Fallback to the polling mode */ | 685 | /* Fallback to the polling mode */ |
686 | return NO_IRQ; | 686 | return 0; |
687 | } | 687 | } |
688 | 688 | ||
689 | return irq; | 689 | return irq; |
@@ -719,7 +719,7 @@ static int __devinit iic_probe(struct of_device *ofdev, | |||
719 | init_waitqueue_head(&dev->wq); | 719 | init_waitqueue_head(&dev->wq); |
720 | 720 | ||
721 | dev->irq = iic_request_irq(ofdev, dev); | 721 | dev->irq = iic_request_irq(ofdev, dev); |
722 | if (dev->irq == NO_IRQ) | 722 | if (!dev->irq) |
723 | dev_warn(&ofdev->dev, "using polling mode\n"); | 723 | dev_warn(&ofdev->dev, "using polling mode\n"); |
724 | 724 | ||
725 | /* Board specific settings */ | 725 | /* Board specific settings */ |
@@ -766,7 +766,7 @@ static int __devinit iic_probe(struct of_device *ofdev, | |||
766 | return 0; | 766 | return 0; |
767 | 767 | ||
768 | error_cleanup: | 768 | error_cleanup: |
769 | if (dev->irq != NO_IRQ) { | 769 | if (dev->irq) { |
770 | iic_interrupt_mode(dev, 0); | 770 | iic_interrupt_mode(dev, 0); |
771 | free_irq(dev->irq, dev); | 771 | free_irq(dev->irq, dev); |
772 | } | 772 | } |
@@ -790,7 +790,7 @@ static int __devexit iic_remove(struct of_device *ofdev) | |||
790 | 790 | ||
791 | i2c_del_adapter(&dev->adap); | 791 | i2c_del_adapter(&dev->adap); |
792 | 792 | ||
793 | if (dev->irq != NO_IRQ) { | 793 | if (dev->irq) { |
794 | iic_interrupt_mode(dev, 0); | 794 | iic_interrupt_mode(dev, 0); |
795 | free_irq(dev->irq, dev); | 795 | free_irq(dev->irq, dev); |
796 | } | 796 | } |
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index f7e27b702375..d1ff9408dc1f 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c | |||
@@ -146,10 +146,10 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy) | |||
146 | "<%s> I2C Interrupted\n", __func__); | 146 | "<%s> I2C Interrupted\n", __func__); |
147 | return -EINTR; | 147 | return -EINTR; |
148 | } | 148 | } |
149 | if (time_after(jiffies, orig_jiffies + HZ / 1000)) { | 149 | if (time_after(jiffies, orig_jiffies + msecs_to_jiffies(500))) { |
150 | dev_dbg(&i2c_imx->adapter.dev, | 150 | dev_dbg(&i2c_imx->adapter.dev, |
151 | "<%s> I2C bus is busy\n", __func__); | 151 | "<%s> I2C bus is busy\n", __func__); |
152 | return -EIO; | 152 | return -ETIMEDOUT; |
153 | } | 153 | } |
154 | schedule(); | 154 | schedule(); |
155 | } | 155 | } |
@@ -444,6 +444,8 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter, | |||
444 | result = i2c_imx_read(i2c_imx, &msgs[i]); | 444 | result = i2c_imx_read(i2c_imx, &msgs[i]); |
445 | else | 445 | else |
446 | result = i2c_imx_write(i2c_imx, &msgs[i]); | 446 | result = i2c_imx_write(i2c_imx, &msgs[i]); |
447 | if (result) | ||
448 | goto fail0; | ||
447 | } | 449 | } |
448 | 450 | ||
449 | fail0: | 451 | fail0: |
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index 5901707fc66a..112c61f7b8cd 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c | |||
@@ -38,8 +38,7 @@ | |||
38 | #include <linux/errno.h> | 38 | #include <linux/errno.h> |
39 | #include <linux/platform_device.h> | 39 | #include <linux/platform_device.h> |
40 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
41 | 41 | #include <linux/io.h> | |
42 | #include <asm/io.h> | ||
43 | 42 | ||
44 | #include "i2c-iop3xx.h" | 43 | #include "i2c-iop3xx.h" |
45 | 44 | ||
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 791b71f46f7b..df00eb1f11f9 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -118,7 +118,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing) | |||
118 | u32 x; | 118 | u32 x; |
119 | int result = 0; | 119 | int result = 0; |
120 | 120 | ||
121 | if (i2c->irq == NO_IRQ) { | 121 | if (!i2c->irq) { |
122 | while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) { | 122 | while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) { |
123 | schedule(); | 123 | schedule(); |
124 | if (time_after(jiffies, orig_jiffies + timeout)) { | 124 | if (time_after(jiffies, orig_jiffies + timeout)) { |
@@ -568,7 +568,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op, | |||
568 | } | 568 | } |
569 | 569 | ||
570 | i2c->irq = irq_of_parse_and_map(op->dev.of_node, 0); | 570 | i2c->irq = irq_of_parse_and_map(op->dev.of_node, 0); |
571 | if (i2c->irq != NO_IRQ) { /* i2c->irq = NO_IRQ implies polling */ | 571 | if (i2c->irq) { /* no i2c->irq implies polling */ |
572 | result = request_irq(i2c->irq, mpc_i2c_isr, | 572 | result = request_irq(i2c->irq, mpc_i2c_isr, |
573 | IRQF_SHARED, "i2c-mpc", i2c); | 573 | IRQF_SHARED, "i2c-mpc", i2c); |
574 | if (result < 0) { | 574 | if (result < 0) { |
@@ -628,7 +628,7 @@ static int __devexit fsl_i2c_remove(struct of_device *op) | |||
628 | i2c_del_adapter(&i2c->adap); | 628 | i2c_del_adapter(&i2c->adap); |
629 | dev_set_drvdata(&op->dev, NULL); | 629 | dev_set_drvdata(&op->dev, NULL); |
630 | 630 | ||
631 | if (i2c->irq != NO_IRQ) | 631 | if (i2c->irq) |
632 | free_irq(i2c->irq, i2c); | 632 | free_irq(i2c->irq, i2c); |
633 | 633 | ||
634 | irq_dispose_mapping(i2c->irq); | 634 | irq_dispose_mapping(i2c->irq); |
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 3623a4499084..16242063144f 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -17,8 +17,7 @@ | |||
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/mv643xx_i2c.h> | 18 | #include <linux/mv643xx_i2c.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | 20 | #include <linux/io.h> | |
21 | #include <asm/io.h> | ||
22 | 21 | ||
23 | /* Register defines */ | 22 | /* Register defines */ |
24 | #define MV64XXX_I2C_REG_SLAVE_ADDR 0x00 | 23 | #define MV64XXX_I2C_REG_SLAVE_ADDR 0x00 |
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 4a48dd4ef787..a605a5029cfe 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -57,7 +57,7 @@ | |||
57 | #include <linux/dmi.h> | 57 | #include <linux/dmi.h> |
58 | #include <linux/acpi.h> | 58 | #include <linux/acpi.h> |
59 | #include <linux/slab.h> | 59 | #include <linux/slab.h> |
60 | #include <asm/io.h> | 60 | #include <linux/io.h> |
61 | 61 | ||
62 | MODULE_LICENSE("GPL"); | 62 | MODULE_LICENSE("GPL"); |
63 | MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@gmx.net>"); | 63 | MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@gmx.net>"); |
@@ -404,10 +404,9 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_ | |||
404 | 404 | ||
405 | /* SMBus adapter 1 */ | 405 | /* SMBus adapter 1 */ |
406 | res1 = nforce2_probe_smb(dev, 4, NFORCE_PCI_SMB1, &smbuses[0], "SMB1"); | 406 | res1 = nforce2_probe_smb(dev, 4, NFORCE_PCI_SMB1, &smbuses[0], "SMB1"); |
407 | if (res1 < 0) { | 407 | if (res1 < 0) |
408 | dev_err(&dev->dev, "Error probing SMB1.\n"); | ||
409 | smbuses[0].base = 0; /* to have a check value */ | 408 | smbuses[0].base = 0; /* to have a check value */ |
410 | } | 409 | |
411 | /* SMBus adapter 2 */ | 410 | /* SMBus adapter 2 */ |
412 | if (dmi_check_system(nforce2_dmi_blacklist2)) { | 411 | if (dmi_check_system(nforce2_dmi_blacklist2)) { |
413 | dev_err(&dev->dev, "Disabling SMB2 for safety reasons.\n"); | 412 | dev_err(&dev->dev, "Disabling SMB2 for safety reasons.\n"); |
@@ -416,11 +415,10 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_ | |||
416 | } else { | 415 | } else { |
417 | res2 = nforce2_probe_smb(dev, 5, NFORCE_PCI_SMB2, &smbuses[1], | 416 | res2 = nforce2_probe_smb(dev, 5, NFORCE_PCI_SMB2, &smbuses[1], |
418 | "SMB2"); | 417 | "SMB2"); |
419 | if (res2 < 0) { | 418 | if (res2 < 0) |
420 | dev_err(&dev->dev, "Error probing SMB2.\n"); | ||
421 | smbuses[1].base = 0; /* to have a check value */ | 419 | smbuses[1].base = 0; /* to have a check value */ |
422 | } | ||
423 | } | 420 | } |
421 | |||
424 | if ((res1 < 0) && (res2 < 0)) { | 422 | if ((res1 < 0) && (res2 < 0)) { |
425 | /* we did not find even one of the SMBuses, so we give up */ | 423 | /* we did not find even one of the SMBuses, so we give up */ |
426 | kfree(smbuses); | 424 | kfree(smbuses); |
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index a4f8d33fa389..73de8ade10b1 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c | |||
@@ -704,7 +704,8 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
704 | case I2C_IT_MTD: | 704 | case I2C_IT_MTD: |
705 | case I2C_IT_MTDWS: | 705 | case I2C_IT_MTDWS: |
706 | if (dev->cli.operation == I2C_READ) { | 706 | if (dev->cli.operation == I2C_READ) { |
707 | while (!readl(dev->virtbase + I2C_RISR) & I2C_IT_RXFE) { | 707 | while (!(readl(dev->virtbase + I2C_RISR) |
708 | & I2C_IT_RXFE)) { | ||
708 | if (dev->cli.count == 0) | 709 | if (dev->cli.count == 0) |
709 | break; | 710 | break; |
710 | *dev->cli.buffer = | 711 | *dev->cli.buffer = |
@@ -914,6 +915,7 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) | |||
914 | 915 | ||
915 | static int __devexit nmk_i2c_remove(struct platform_device *pdev) | 916 | static int __devexit nmk_i2c_remove(struct platform_device *pdev) |
916 | { | 917 | { |
918 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
917 | struct nmk_i2c_dev *dev = platform_get_drvdata(pdev); | 919 | struct nmk_i2c_dev *dev = platform_get_drvdata(pdev); |
918 | 920 | ||
919 | i2c_del_adapter(&dev->adap); | 921 | i2c_del_adapter(&dev->adap); |
@@ -924,6 +926,8 @@ static int __devexit nmk_i2c_remove(struct platform_device *pdev) | |||
924 | i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE); | 926 | i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE); |
925 | free_irq(dev->irq, dev); | 927 | free_irq(dev->irq, dev); |
926 | iounmap(dev->virtbase); | 928 | iounmap(dev->virtbase); |
929 | if (res) | ||
930 | release_mem_region(res->start, resource_size(res)); | ||
927 | clk_disable(dev->clk); | 931 | clk_disable(dev->clk); |
928 | clk_put(dev->clk); | 932 | clk_put(dev->clk); |
929 | platform_set_drvdata(pdev, NULL); | 933 | platform_set_drvdata(pdev, NULL); |
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index b4ed4ca802ed..0070371b29f3 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/wait.h> | 19 | #include <linux/wait.h> |
20 | #include <linux/i2c-ocores.h> | 20 | #include <linux/i2c-ocores.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <asm/io.h> | 22 | #include <linux/io.h> |
23 | 23 | ||
24 | struct ocores_i2c { | 24 | struct ocores_i2c { |
25 | void __iomem *base; | 25 | void __iomem *base; |
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c index a2481f40ea1c..0e9f85d0a835 100644 --- a/drivers/i2c/busses/i2c-octeon.c +++ b/drivers/i2c/busses/i2c-octeon.c | |||
@@ -447,7 +447,7 @@ static struct i2c_adapter octeon_i2c_ops = { | |||
447 | /** | 447 | /** |
448 | * octeon_i2c_setclock - Calculate and set clock divisors. | 448 | * octeon_i2c_setclock - Calculate and set clock divisors. |
449 | */ | 449 | */ |
450 | static int __init octeon_i2c_setclock(struct octeon_i2c *i2c) | 450 | static int __devinit octeon_i2c_setclock(struct octeon_i2c *i2c) |
451 | { | 451 | { |
452 | int tclk, thp_base, inc, thp_idx, mdiv_idx, ndiv_idx, foscl, diff; | 452 | int tclk, thp_base, inc, thp_idx, mdiv_idx, ndiv_idx, foscl, diff; |
453 | int thp = 0x18, mdiv = 2, ndiv = 0, delta_hz = 1000000; | 453 | int thp = 0x18, mdiv = 2, ndiv = 0, delta_hz = 1000000; |
@@ -490,7 +490,7 @@ static int __init octeon_i2c_setclock(struct octeon_i2c *i2c) | |||
490 | return 0; | 490 | return 0; |
491 | } | 491 | } |
492 | 492 | ||
493 | static int __init octeon_i2c_initlowlevel(struct octeon_i2c *i2c) | 493 | static int __devinit octeon_i2c_initlowlevel(struct octeon_i2c *i2c) |
494 | { | 494 | { |
495 | u8 status; | 495 | u8 status; |
496 | int tries; | 496 | int tries; |
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 6bd0f19cd451..7674efb55378 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/clk.h> | 38 | #include <linux/clk.h> |
39 | #include <linux/io.h> | 39 | #include <linux/io.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/i2c-omap.h> | ||
41 | 42 | ||
42 | /* I2C controller revisions */ | 43 | /* I2C controller revisions */ |
43 | #define OMAP_I2C_REV_2 0x20 | 44 | #define OMAP_I2C_REV_2 0x20 |
@@ -45,29 +46,37 @@ | |||
45 | /* I2C controller revisions present on specific hardware */ | 46 | /* I2C controller revisions present on specific hardware */ |
46 | #define OMAP_I2C_REV_ON_2430 0x36 | 47 | #define OMAP_I2C_REV_ON_2430 0x36 |
47 | #define OMAP_I2C_REV_ON_3430 0x3C | 48 | #define OMAP_I2C_REV_ON_3430 0x3C |
49 | #define OMAP_I2C_REV_ON_4430 0x40 | ||
48 | 50 | ||
49 | /* timeout waiting for the controller to respond */ | 51 | /* timeout waiting for the controller to respond */ |
50 | #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) | 52 | #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) |
51 | 53 | ||
52 | #define OMAP_I2C_REV_REG 0x00 | ||
53 | #define OMAP_I2C_IE_REG 0x01 | ||
54 | #define OMAP_I2C_STAT_REG 0x02 | ||
55 | #define OMAP_I2C_IV_REG 0x03 | ||
56 | /* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */ | 54 | /* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */ |
57 | #define OMAP_I2C_WE_REG 0x03 | 55 | enum { |
58 | #define OMAP_I2C_SYSS_REG 0x04 | 56 | OMAP_I2C_REV_REG = 0, |
59 | #define OMAP_I2C_BUF_REG 0x05 | 57 | OMAP_I2C_IE_REG, |
60 | #define OMAP_I2C_CNT_REG 0x06 | 58 | OMAP_I2C_STAT_REG, |
61 | #define OMAP_I2C_DATA_REG 0x07 | 59 | OMAP_I2C_IV_REG, |
62 | #define OMAP_I2C_SYSC_REG 0x08 | 60 | OMAP_I2C_WE_REG, |
63 | #define OMAP_I2C_CON_REG 0x09 | 61 | OMAP_I2C_SYSS_REG, |
64 | #define OMAP_I2C_OA_REG 0x0a | 62 | OMAP_I2C_BUF_REG, |
65 | #define OMAP_I2C_SA_REG 0x0b | 63 | OMAP_I2C_CNT_REG, |
66 | #define OMAP_I2C_PSC_REG 0x0c | 64 | OMAP_I2C_DATA_REG, |
67 | #define OMAP_I2C_SCLL_REG 0x0d | 65 | OMAP_I2C_SYSC_REG, |
68 | #define OMAP_I2C_SCLH_REG 0x0e | 66 | OMAP_I2C_CON_REG, |
69 | #define OMAP_I2C_SYSTEST_REG 0x0f | 67 | OMAP_I2C_OA_REG, |
70 | #define OMAP_I2C_BUFSTAT_REG 0x10 | 68 | OMAP_I2C_SA_REG, |
69 | OMAP_I2C_PSC_REG, | ||
70 | OMAP_I2C_SCLL_REG, | ||
71 | OMAP_I2C_SCLH_REG, | ||
72 | OMAP_I2C_SYSTEST_REG, | ||
73 | OMAP_I2C_BUFSTAT_REG, | ||
74 | OMAP_I2C_REVNB_LO, | ||
75 | OMAP_I2C_REVNB_HI, | ||
76 | OMAP_I2C_IRQSTATUS_RAW, | ||
77 | OMAP_I2C_IRQENABLE_SET, | ||
78 | OMAP_I2C_IRQENABLE_CLR, | ||
79 | }; | ||
71 | 80 | ||
72 | /* I2C Interrupt Enable Register (OMAP_I2C_IE): */ | 81 | /* I2C Interrupt Enable Register (OMAP_I2C_IE): */ |
73 | #define OMAP_I2C_IE_XDR (1 << 14) /* TX Buffer drain int enable */ | 82 | #define OMAP_I2C_IE_XDR (1 << 14) /* TX Buffer drain int enable */ |
@@ -157,6 +166,9 @@ | |||
157 | #define SYSC_IDLEMODE_SMART 0x2 | 166 | #define SYSC_IDLEMODE_SMART 0x2 |
158 | #define SYSC_CLOCKACTIVITY_FCLK 0x2 | 167 | #define SYSC_CLOCKACTIVITY_FCLK 0x2 |
159 | 168 | ||
169 | /* Errata definitions */ | ||
170 | #define I2C_OMAP_ERRATA_I207 (1 << 0) | ||
171 | #define I2C_OMAP3_1P153 (1 << 1) | ||
160 | 172 | ||
161 | struct omap_i2c_dev { | 173 | struct omap_i2c_dev { |
162 | struct device *dev; | 174 | struct device *dev; |
@@ -167,9 +179,13 @@ struct omap_i2c_dev { | |||
167 | struct clk *fclk; /* Functional clock */ | 179 | struct clk *fclk; /* Functional clock */ |
168 | struct completion cmd_complete; | 180 | struct completion cmd_complete; |
169 | struct resource *ioarea; | 181 | struct resource *ioarea; |
182 | u32 latency; /* maximum mpu wkup latency */ | ||
183 | void (*set_mpu_wkup_lat)(struct device *dev, | ||
184 | long latency); | ||
170 | u32 speed; /* Speed of bus in Khz */ | 185 | u32 speed; /* Speed of bus in Khz */ |
171 | u16 cmd_err; | 186 | u16 cmd_err; |
172 | u8 *buf; | 187 | u8 *buf; |
188 | u8 *regs; | ||
173 | size_t buf_len; | 189 | size_t buf_len; |
174 | struct i2c_adapter adapter; | 190 | struct i2c_adapter adapter; |
175 | u8 fifo_size; /* use as flag and value | 191 | u8 fifo_size; /* use as flag and value |
@@ -186,17 +202,67 @@ struct omap_i2c_dev { | |||
186 | u16 bufstate; | 202 | u16 bufstate; |
187 | u16 syscstate; | 203 | u16 syscstate; |
188 | u16 westate; | 204 | u16 westate; |
205 | u16 errata; | ||
206 | }; | ||
207 | |||
208 | const static u8 reg_map[] = { | ||
209 | [OMAP_I2C_REV_REG] = 0x00, | ||
210 | [OMAP_I2C_IE_REG] = 0x01, | ||
211 | [OMAP_I2C_STAT_REG] = 0x02, | ||
212 | [OMAP_I2C_IV_REG] = 0x03, | ||
213 | [OMAP_I2C_WE_REG] = 0x03, | ||
214 | [OMAP_I2C_SYSS_REG] = 0x04, | ||
215 | [OMAP_I2C_BUF_REG] = 0x05, | ||
216 | [OMAP_I2C_CNT_REG] = 0x06, | ||
217 | [OMAP_I2C_DATA_REG] = 0x07, | ||
218 | [OMAP_I2C_SYSC_REG] = 0x08, | ||
219 | [OMAP_I2C_CON_REG] = 0x09, | ||
220 | [OMAP_I2C_OA_REG] = 0x0a, | ||
221 | [OMAP_I2C_SA_REG] = 0x0b, | ||
222 | [OMAP_I2C_PSC_REG] = 0x0c, | ||
223 | [OMAP_I2C_SCLL_REG] = 0x0d, | ||
224 | [OMAP_I2C_SCLH_REG] = 0x0e, | ||
225 | [OMAP_I2C_SYSTEST_REG] = 0x0f, | ||
226 | [OMAP_I2C_BUFSTAT_REG] = 0x10, | ||
227 | }; | ||
228 | |||
229 | const static u8 omap4_reg_map[] = { | ||
230 | [OMAP_I2C_REV_REG] = 0x04, | ||
231 | [OMAP_I2C_IE_REG] = 0x2c, | ||
232 | [OMAP_I2C_STAT_REG] = 0x28, | ||
233 | [OMAP_I2C_IV_REG] = 0x34, | ||
234 | [OMAP_I2C_WE_REG] = 0x34, | ||
235 | [OMAP_I2C_SYSS_REG] = 0x90, | ||
236 | [OMAP_I2C_BUF_REG] = 0x94, | ||
237 | [OMAP_I2C_CNT_REG] = 0x98, | ||
238 | [OMAP_I2C_DATA_REG] = 0x9c, | ||
239 | [OMAP_I2C_SYSC_REG] = 0x20, | ||
240 | [OMAP_I2C_CON_REG] = 0xa4, | ||
241 | [OMAP_I2C_OA_REG] = 0xa8, | ||
242 | [OMAP_I2C_SA_REG] = 0xac, | ||
243 | [OMAP_I2C_PSC_REG] = 0xb0, | ||
244 | [OMAP_I2C_SCLL_REG] = 0xb4, | ||
245 | [OMAP_I2C_SCLH_REG] = 0xb8, | ||
246 | [OMAP_I2C_SYSTEST_REG] = 0xbC, | ||
247 | [OMAP_I2C_BUFSTAT_REG] = 0xc0, | ||
248 | [OMAP_I2C_REVNB_LO] = 0x00, | ||
249 | [OMAP_I2C_REVNB_HI] = 0x04, | ||
250 | [OMAP_I2C_IRQSTATUS_RAW] = 0x24, | ||
251 | [OMAP_I2C_IRQENABLE_SET] = 0x2c, | ||
252 | [OMAP_I2C_IRQENABLE_CLR] = 0x30, | ||
189 | }; | 253 | }; |
190 | 254 | ||
191 | static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, | 255 | static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, |
192 | int reg, u16 val) | 256 | int reg, u16 val) |
193 | { | 257 | { |
194 | __raw_writew(val, i2c_dev->base + (reg << i2c_dev->reg_shift)); | 258 | __raw_writew(val, i2c_dev->base + |
259 | (i2c_dev->regs[reg] << i2c_dev->reg_shift)); | ||
195 | } | 260 | } |
196 | 261 | ||
197 | static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) | 262 | static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) |
198 | { | 263 | { |
199 | return __raw_readw(i2c_dev->base + (reg << i2c_dev->reg_shift)); | 264 | return __raw_readw(i2c_dev->base + |
265 | (i2c_dev->regs[reg] << i2c_dev->reg_shift)); | ||
200 | } | 266 | } |
201 | 267 | ||
202 | static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev) | 268 | static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev) |
@@ -265,7 +331,11 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev) | |||
265 | WARN_ON(dev->idle); | 331 | WARN_ON(dev->idle); |
266 | 332 | ||
267 | dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); | 333 | dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); |
268 | omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0); | 334 | if (dev->rev >= OMAP_I2C_REV_ON_4430) |
335 | omap_i2c_write_reg(dev, OMAP_I2C_IRQENABLE_CLR, 1); | ||
336 | else | ||
337 | omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0); | ||
338 | |||
269 | if (dev->rev < OMAP_I2C_REV_2) { | 339 | if (dev->rev < OMAP_I2C_REV_2) { |
270 | iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */ | 340 | iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */ |
271 | } else { | 341 | } else { |
@@ -330,7 +400,9 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
330 | * REVISIT: Some wkup sources might not be needed. | 400 | * REVISIT: Some wkup sources might not be needed. |
331 | */ | 401 | */ |
332 | dev->westate = OMAP_I2C_WE_ALL; | 402 | dev->westate = OMAP_I2C_WE_ALL; |
333 | omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate); | 403 | if (dev->rev < OMAP_I2C_REV_ON_4430) |
404 | omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, | ||
405 | dev->westate); | ||
334 | } | 406 | } |
335 | } | 407 | } |
336 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); | 408 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); |
@@ -357,7 +429,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
357 | psc = fclk_rate / 12000000; | 429 | psc = fclk_rate / 12000000; |
358 | } | 430 | } |
359 | 431 | ||
360 | if (cpu_is_omap2430() || cpu_is_omap34xx()) { | 432 | if (!(cpu_class_is_omap1() || cpu_is_omap2420())) { |
361 | 433 | ||
362 | /* | 434 | /* |
363 | * HSI2C controller internal clk rate should be 19.2 Mhz for | 435 | * HSI2C controller internal clk rate should be 19.2 Mhz for |
@@ -430,6 +502,11 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
430 | /* Take the I2C module out of reset: */ | 502 | /* Take the I2C module out of reset: */ |
431 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); | 503 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); |
432 | 504 | ||
505 | dev->errata = 0; | ||
506 | |||
507 | if (cpu_is_omap2430() || cpu_is_omap34xx()) | ||
508 | dev->errata |= I2C_OMAP_ERRATA_I207; | ||
509 | |||
433 | /* Enable interrupts */ | 510 | /* Enable interrupts */ |
434 | dev->iestate = (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | | 511 | dev->iestate = (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | |
435 | OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK | | 512 | OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK | |
@@ -539,8 +616,12 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, | |||
539 | * REVISIT: We should abort the transfer on signals, but the bus goes | 616 | * REVISIT: We should abort the transfer on signals, but the bus goes |
540 | * into arbitration and we're currently unable to recover from it. | 617 | * into arbitration and we're currently unable to recover from it. |
541 | */ | 618 | */ |
619 | if (dev->set_mpu_wkup_lat != NULL) | ||
620 | dev->set_mpu_wkup_lat(dev->dev, dev->latency); | ||
542 | r = wait_for_completion_timeout(&dev->cmd_complete, | 621 | r = wait_for_completion_timeout(&dev->cmd_complete, |
543 | OMAP_I2C_TIMEOUT); | 622 | OMAP_I2C_TIMEOUT); |
623 | if (dev->set_mpu_wkup_lat != NULL) | ||
624 | dev->set_mpu_wkup_lat(dev->dev, -1); | ||
544 | dev->buf_len = 0; | 625 | dev->buf_len = 0; |
545 | if (r < 0) | 626 | if (r < 0) |
546 | return r; | 627 | return r; |
@@ -623,6 +704,34 @@ omap_i2c_ack_stat(struct omap_i2c_dev *dev, u16 stat) | |||
623 | omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); | 704 | omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); |
624 | } | 705 | } |
625 | 706 | ||
707 | static inline void i2c_omap_errata_i207(struct omap_i2c_dev *dev, u16 stat) | ||
708 | { | ||
709 | /* | ||
710 | * I2C Errata(Errata Nos. OMAP2: 1.67, OMAP3: 1.8) | ||
711 | * Not applicable for OMAP4. | ||
712 | * Under certain rare conditions, RDR could be set again | ||
713 | * when the bus is busy, then ignore the interrupt and | ||
714 | * clear the interrupt. | ||
715 | */ | ||
716 | if (stat & OMAP_I2C_STAT_RDR) { | ||
717 | /* Step 1: If RDR is set, clear it */ | ||
718 | omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RDR); | ||
719 | |||
720 | /* Step 2: */ | ||
721 | if (!(omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG) | ||
722 | & OMAP_I2C_STAT_BB)) { | ||
723 | |||
724 | /* Step 3: */ | ||
725 | if (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG) | ||
726 | & OMAP_I2C_STAT_RDR) { | ||
727 | omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RDR); | ||
728 | dev_dbg(dev->dev, "RDR when bus is busy.\n"); | ||
729 | } | ||
730 | |||
731 | } | ||
732 | } | ||
733 | } | ||
734 | |||
626 | /* rev1 devices are apparently only on some 15xx */ | 735 | /* rev1 devices are apparently only on some 15xx */ |
627 | #ifdef CONFIG_ARCH_OMAP15XX | 736 | #ifdef CONFIG_ARCH_OMAP15XX |
628 | 737 | ||
@@ -684,6 +793,35 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id) | |||
684 | #define omap_i2c_rev1_isr NULL | 793 | #define omap_i2c_rev1_isr NULL |
685 | #endif | 794 | #endif |
686 | 795 | ||
796 | /* | ||
797 | * OMAP3430 Errata 1.153: When an XRDY/XDR is hit, wait for XUDF before writing | ||
798 | * data to DATA_REG. Otherwise some data bytes can be lost while transferring | ||
799 | * them from the memory to the I2C interface. | ||
800 | */ | ||
801 | static int errata_omap3_1p153(struct omap_i2c_dev *dev, u16 *stat, int *err) | ||
802 | { | ||
803 | unsigned long timeout = 10000; | ||
804 | |||
805 | while (--timeout && !(*stat & OMAP_I2C_STAT_XUDF)) { | ||
806 | if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { | ||
807 | omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY | | ||
808 | OMAP_I2C_STAT_XDR)); | ||
809 | *err |= OMAP_I2C_STAT_XUDF; | ||
810 | return -ETIMEDOUT; | ||
811 | } | ||
812 | |||
813 | cpu_relax(); | ||
814 | *stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); | ||
815 | } | ||
816 | |||
817 | if (!timeout) { | ||
818 | dev_err(dev->dev, "timeout waiting on XUDF bit\n"); | ||
819 | return 0; | ||
820 | } | ||
821 | |||
822 | return 0; | ||
823 | } | ||
824 | |||
687 | static irqreturn_t | 825 | static irqreturn_t |
688 | omap_i2c_isr(int this_irq, void *dev_id) | 826 | omap_i2c_isr(int this_irq, void *dev_id) |
689 | { | 827 | { |
@@ -733,6 +871,10 @@ complete: | |||
733 | } | 871 | } |
734 | if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) { | 872 | if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) { |
735 | u8 num_bytes = 1; | 873 | u8 num_bytes = 1; |
874 | |||
875 | if (dev->errata & I2C_OMAP_ERRATA_I207) | ||
876 | i2c_omap_errata_i207(dev, stat); | ||
877 | |||
736 | if (dev->fifo_size) { | 878 | if (dev->fifo_size) { |
737 | if (stat & OMAP_I2C_STAT_RRDY) | 879 | if (stat & OMAP_I2C_STAT_RRDY) |
738 | num_bytes = dev->fifo_size; | 880 | num_bytes = dev->fifo_size; |
@@ -747,9 +889,12 @@ complete: | |||
747 | if (dev->buf_len) { | 889 | if (dev->buf_len) { |
748 | *dev->buf++ = w; | 890 | *dev->buf++ = w; |
749 | dev->buf_len--; | 891 | dev->buf_len--; |
750 | /* Data reg from 2430 is 8 bit wide */ | 892 | /* |
751 | if (!cpu_is_omap2430() && | 893 | * Data reg in 2430, omap3 and |
752 | !cpu_is_omap34xx()) { | 894 | * omap4 is 8 bit wide |
895 | */ | ||
896 | if (cpu_class_is_omap1() || | ||
897 | cpu_is_omap2420()) { | ||
753 | if (dev->buf_len) { | 898 | if (dev->buf_len) { |
754 | *dev->buf++ = w >> 8; | 899 | *dev->buf++ = w >> 8; |
755 | dev->buf_len--; | 900 | dev->buf_len--; |
@@ -787,9 +932,12 @@ complete: | |||
787 | if (dev->buf_len) { | 932 | if (dev->buf_len) { |
788 | w = *dev->buf++; | 933 | w = *dev->buf++; |
789 | dev->buf_len--; | 934 | dev->buf_len--; |
790 | /* Data reg from 2430 is 8 bit wide */ | 935 | /* |
791 | if (!cpu_is_omap2430() && | 936 | * Data reg in 2430, omap3 and |
792 | !cpu_is_omap34xx()) { | 937 | * omap4 is 8 bit wide |
938 | */ | ||
939 | if (cpu_class_is_omap1() || | ||
940 | cpu_is_omap2420()) { | ||
793 | if (dev->buf_len) { | 941 | if (dev->buf_len) { |
794 | w |= *dev->buf++ << 8; | 942 | w |= *dev->buf++ << 8; |
795 | dev->buf_len--; | 943 | dev->buf_len--; |
@@ -807,25 +955,9 @@ complete: | |||
807 | break; | 955 | break; |
808 | } | 956 | } |
809 | 957 | ||
810 | /* | 958 | if ((dev->errata & I2C_OMAP3_1P153) && |
811 | * OMAP3430 Errata 1.153: When an XRDY/XDR | 959 | errata_omap3_1p153(dev, &stat, &err)) |
812 | * is hit, wait for XUDF before writing data | 960 | goto complete; |
813 | * to DATA_REG. Otherwise some data bytes can | ||
814 | * be lost while transferring them from the | ||
815 | * memory to the I2C interface. | ||
816 | */ | ||
817 | |||
818 | if (dev->rev <= OMAP_I2C_REV_ON_3430) { | ||
819 | while (!(stat & OMAP_I2C_STAT_XUDF)) { | ||
820 | if (stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { | ||
821 | omap_i2c_ack_stat(dev, stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)); | ||
822 | err |= OMAP_I2C_STAT_XUDF; | ||
823 | goto complete; | ||
824 | } | ||
825 | cpu_relax(); | ||
826 | stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); | ||
827 | } | ||
828 | } | ||
829 | 961 | ||
830 | omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); | 962 | omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); |
831 | } | 963 | } |
@@ -857,6 +989,7 @@ omap_i2c_probe(struct platform_device *pdev) | |||
857 | struct omap_i2c_dev *dev; | 989 | struct omap_i2c_dev *dev; |
858 | struct i2c_adapter *adap; | 990 | struct i2c_adapter *adap; |
859 | struct resource *mem, *irq, *ioarea; | 991 | struct resource *mem, *irq, *ioarea; |
992 | struct omap_i2c_bus_platform_data *pdata = pdev->dev.platform_data; | ||
860 | irq_handler_t isr; | 993 | irq_handler_t isr; |
861 | int r; | 994 | int r; |
862 | u32 speed = 0; | 995 | u32 speed = 0; |
@@ -886,10 +1019,13 @@ omap_i2c_probe(struct platform_device *pdev) | |||
886 | goto err_release_region; | 1019 | goto err_release_region; |
887 | } | 1020 | } |
888 | 1021 | ||
889 | if (pdev->dev.platform_data != NULL) | 1022 | if (pdata != NULL) { |
890 | speed = *(u32 *)pdev->dev.platform_data; | 1023 | speed = pdata->clkrate; |
891 | else | 1024 | dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; |
892 | speed = 100; /* Defualt speed */ | 1025 | } else { |
1026 | speed = 100; /* Default speed */ | ||
1027 | dev->set_mpu_wkup_lat = NULL; | ||
1028 | } | ||
893 | 1029 | ||
894 | dev->speed = speed; | 1030 | dev->speed = speed; |
895 | dev->idle = 1; | 1031 | dev->idle = 1; |
@@ -903,14 +1039,29 @@ omap_i2c_probe(struct platform_device *pdev) | |||
903 | 1039 | ||
904 | platform_set_drvdata(pdev, dev); | 1040 | platform_set_drvdata(pdev, dev); |
905 | 1041 | ||
1042 | if (cpu_is_omap7xx()) | ||
1043 | dev->reg_shift = 1; | ||
1044 | else if (cpu_is_omap44xx()) | ||
1045 | dev->reg_shift = 0; | ||
1046 | else | ||
1047 | dev->reg_shift = 2; | ||
1048 | |||
906 | if ((r = omap_i2c_get_clocks(dev)) != 0) | 1049 | if ((r = omap_i2c_get_clocks(dev)) != 0) |
907 | goto err_iounmap; | 1050 | goto err_iounmap; |
908 | 1051 | ||
1052 | if (cpu_is_omap44xx()) | ||
1053 | dev->regs = (u8 *) omap4_reg_map; | ||
1054 | else | ||
1055 | dev->regs = (u8 *) reg_map; | ||
1056 | |||
909 | omap_i2c_unidle(dev); | 1057 | omap_i2c_unidle(dev); |
910 | 1058 | ||
911 | dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff; | 1059 | dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff; |
912 | 1060 | ||
913 | if (cpu_is_omap2430() || cpu_is_omap34xx()) { | 1061 | if (dev->rev <= OMAP_I2C_REV_ON_3430) |
1062 | dev->errata |= I2C_OMAP3_1P153; | ||
1063 | |||
1064 | if (!(cpu_class_is_omap1() || cpu_is_omap2420())) { | ||
914 | u16 s; | 1065 | u16 s; |
915 | 1066 | ||
916 | /* Set up the fifo size - Get total size */ | 1067 | /* Set up the fifo size - Get total size */ |
@@ -922,15 +1073,19 @@ omap_i2c_probe(struct platform_device *pdev) | |||
922 | * size. This is to ensure that we can handle the status on int | 1073 | * size. This is to ensure that we can handle the status on int |
923 | * call back latencies. | 1074 | * call back latencies. |
924 | */ | 1075 | */ |
925 | dev->fifo_size = (dev->fifo_size / 2); | 1076 | if (dev->rev >= OMAP_I2C_REV_ON_4430) { |
926 | dev->b_hw = 1; /* Enable hardware fixes */ | 1077 | dev->fifo_size = 0; |
1078 | dev->b_hw = 0; /* Disable hardware fixes */ | ||
1079 | } else { | ||
1080 | dev->fifo_size = (dev->fifo_size / 2); | ||
1081 | dev->b_hw = 1; /* Enable hardware fixes */ | ||
1082 | } | ||
1083 | /* calculate wakeup latency constraint for MPU */ | ||
1084 | if (dev->set_mpu_wkup_lat != NULL) | ||
1085 | dev->latency = (1000000 * dev->fifo_size) / | ||
1086 | (1000 * speed / 8); | ||
927 | } | 1087 | } |
928 | 1088 | ||
929 | if (cpu_is_omap7xx()) | ||
930 | dev->reg_shift = 1; | ||
931 | else | ||
932 | dev->reg_shift = 2; | ||
933 | |||
934 | /* reset ASAP, clearing any IRQs */ | 1089 | /* reset ASAP, clearing any IRQs */ |
935 | omap_i2c_init(dev); | 1090 | omap_i2c_init(dev); |
936 | 1091 | ||
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c index 5f41ec0f72d2..fc5fbd1012c9 100644 --- a/drivers/i2c/busses/i2c-parport-light.c +++ b/drivers/i2c/busses/i2c-parport-light.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <linux/i2c-algo-bit.h> | 34 | #include <linux/i2c-algo-bit.h> |
35 | #include <linux/i2c-smbus.h> | 35 | #include <linux/i2c-smbus.h> |
36 | #include <asm/io.h> | 36 | #include <linux/io.h> |
37 | #include "i2c-parport.h" | 37 | #include "i2c-parport.h" |
38 | 38 | ||
39 | #define DEFAULT_BASE 0x378 | 39 | #define DEFAULT_BASE 0x378 |
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 846583ed4763..0eb1515541e7 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -137,7 +137,7 @@ static int parport_getsda(void *data) | |||
137 | copied. The attaching code will set getscl to NULL for adapters that | 137 | copied. The attaching code will set getscl to NULL for adapters that |
138 | cannot read SCL back, and will also make the data field point to | 138 | cannot read SCL back, and will also make the data field point to |
139 | the parallel port structure. */ | 139 | the parallel port structure. */ |
140 | static struct i2c_algo_bit_data parport_algo_data = { | 140 | static const struct i2c_algo_bit_data parport_algo_data = { |
141 | .setsda = parport_setsda, | 141 | .setsda = parport_setsda, |
142 | .setscl = parport_setscl, | 142 | .setscl = parport_setscl, |
143 | .getsda = parport_getsda, | 143 | .getsda = parport_getsda, |
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c index d3d4a4b43a1d..4174101660c9 100644 --- a/drivers/i2c/busses/i2c-pasemi.c +++ b/drivers/i2c/busses/i2c-pasemi.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <asm/io.h> | 28 | #include <linux/io.h> |
29 | 29 | ||
30 | static struct pci_driver pasemi_smb_driver; | 30 | static struct pci_driver pasemi_smb_driver; |
31 | 31 | ||
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c index f7346a9bd95f..bbd77603a417 100644 --- a/drivers/i2c/busses/i2c-pca-isa.c +++ b/drivers/i2c/busses/i2c-pca-isa.c | |||
@@ -30,8 +30,8 @@ | |||
30 | #include <linux/isa.h> | 30 | #include <linux/isa.h> |
31 | #include <linux/i2c.h> | 31 | #include <linux/i2c.h> |
32 | #include <linux/i2c-algo-pca.h> | 32 | #include <linux/i2c-algo-pca.h> |
33 | #include <linux/io.h> | ||
33 | 34 | ||
34 | #include <asm/io.h> | ||
35 | #include <asm/irq.h> | 35 | #include <asm/irq.h> |
36 | 36 | ||
37 | #define DRIVER "i2c-pca-isa" | 37 | #define DRIVER "i2c-pca-isa" |
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c index 5b2213df5ed0..ef5c78487eb7 100644 --- a/drivers/i2c/busses/i2c-pca-platform.c +++ b/drivers/i2c/busses/i2c-pca-platform.c | |||
@@ -23,9 +23,9 @@ | |||
23 | #include <linux/i2c-algo-pca.h> | 23 | #include <linux/i2c-algo-pca.h> |
24 | #include <linux/i2c-pca-platform.h> | 24 | #include <linux/i2c-pca-platform.h> |
25 | #include <linux/gpio.h> | 25 | #include <linux/gpio.h> |
26 | #include <linux/io.h> | ||
26 | 27 | ||
27 | #include <asm/irq.h> | 28 | #include <asm/irq.h> |
28 | #include <asm/io.h> | ||
29 | 29 | ||
30 | struct i2c_pca_pf_data { | 30 | struct i2c_pca_pf_data { |
31 | void __iomem *reg_base; | 31 | void __iomem *reg_base; |
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index ee9da6fcf69a..6d14ac2e3c41 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/dmi.h> | 40 | #include <linux/dmi.h> |
41 | #include <linux/acpi.h> | 41 | #include <linux/acpi.h> |
42 | #include <asm/io.h> | 42 | #include <linux/io.h> |
43 | 43 | ||
44 | 44 | ||
45 | /* PIIX4 SMBus address offsets */ | 45 | /* PIIX4 SMBus address offsets */ |
diff --git a/drivers/i2c/busses/i2c-pmcmsp.c b/drivers/i2c/busses/i2c-pmcmsp.c index 7b57d5f267e1..dfa7ae9c1b8e 100644 --- a/drivers/i2c/busses/i2c-pmcmsp.c +++ b/drivers/i2c/busses/i2c-pmcmsp.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/completion.h> | 33 | #include <linux/completion.h> |
34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <asm/io.h> | 36 | #include <linux/io.h> |
37 | 37 | ||
38 | #define DRV_NAME "pmcmsptwi" | 38 | #define DRV_NAME "pmcmsptwi" |
39 | 39 | ||
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index 247103372a06..a97e3fec8148 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -173,6 +173,9 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data) | |||
173 | /* We still have something to talk about... */ | 173 | /* We still have something to talk about... */ |
174 | val = *alg_data->mif.buf++; | 174 | val = *alg_data->mif.buf++; |
175 | 175 | ||
176 | if (alg_data->mif.len == 1) | ||
177 | val |= stop_bit; | ||
178 | |||
176 | alg_data->mif.len--; | 179 | alg_data->mif.len--; |
177 | iowrite32(val, I2C_REG_TX(alg_data)); | 180 | iowrite32(val, I2C_REG_TX(alg_data)); |
178 | 181 | ||
@@ -246,6 +249,9 @@ static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data) | |||
246 | __func__); | 249 | __func__); |
247 | 250 | ||
248 | if (alg_data->mif.len == 1) { | 251 | if (alg_data->mif.len == 1) { |
252 | /* Last byte, do not acknowledge next rcv. */ | ||
253 | val |= stop_bit; | ||
254 | |||
249 | /* | 255 | /* |
250 | * Enable interrupt RFDAIE (data in Rx fifo), | 256 | * Enable interrupt RFDAIE (data in Rx fifo), |
251 | * and disable DRMIE (need data for Tx) | 257 | * and disable DRMIE (need data for Tx) |
@@ -633,6 +639,8 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
633 | */ | 639 | */ |
634 | 640 | ||
635 | tmp = ((freq / 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2; | 641 | tmp = ((freq / 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2; |
642 | if (tmp > 0x3FF) | ||
643 | tmp = 0x3FF; | ||
636 | iowrite32(tmp, I2C_REG_CKH(alg_data)); | 644 | iowrite32(tmp, I2C_REG_CKH(alg_data)); |
637 | iowrite32(tmp, I2C_REG_CKL(alg_data)); | 645 | iowrite32(tmp, I2C_REG_CKL(alg_data)); |
638 | 646 | ||
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 14d249f5ed3f..020ff23d762f 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -34,9 +34,9 @@ | |||
34 | #include <linux/err.h> | 34 | #include <linux/err.h> |
35 | #include <linux/clk.h> | 35 | #include <linux/clk.h> |
36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
37 | #include <linux/io.h> | ||
37 | 38 | ||
38 | #include <asm/irq.h> | 39 | #include <asm/irq.h> |
39 | #include <asm/io.h> | ||
40 | #include <plat/i2c.h> | 40 | #include <plat/i2c.h> |
41 | 41 | ||
42 | /* | 42 | /* |
@@ -209,18 +209,6 @@ static void i2c_pxa_show_state(struct pxa_i2c *i2c, int lno, const char *fname) | |||
209 | } | 209 | } |
210 | 210 | ||
211 | #define show_state(i2c) i2c_pxa_show_state(i2c, __LINE__, __func__) | 211 | #define show_state(i2c) i2c_pxa_show_state(i2c, __LINE__, __func__) |
212 | #else | ||
213 | #define i2c_debug 0 | ||
214 | |||
215 | #define show_state(i2c) do { } while (0) | ||
216 | #define decode_ISR(val) do { } while (0) | ||
217 | #define decode_ICR(val) do { } while (0) | ||
218 | #endif | ||
219 | |||
220 | #define eedbg(lvl, x...) do { if ((lvl) < 1) { printk(KERN_DEBUG "" x); } } while(0) | ||
221 | |||
222 | static void i2c_pxa_master_complete(struct pxa_i2c *i2c, int ret); | ||
223 | static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id); | ||
224 | 212 | ||
225 | static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why) | 213 | static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why) |
226 | { | 214 | { |
@@ -236,6 +224,20 @@ static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why) | |||
236 | printk("\n"); | 224 | printk("\n"); |
237 | } | 225 | } |
238 | 226 | ||
227 | #else /* ifdef DEBUG */ | ||
228 | |||
229 | #define i2c_debug 0 | ||
230 | |||
231 | #define show_state(i2c) do { } while (0) | ||
232 | #define decode_ISR(val) do { } while (0) | ||
233 | #define decode_ICR(val) do { } while (0) | ||
234 | #define i2c_pxa_scream_blue_murder(i2c, why) do { } while (0) | ||
235 | |||
236 | #endif /* ifdef DEBUG / else */ | ||
237 | |||
238 | static void i2c_pxa_master_complete(struct pxa_i2c *i2c, int ret); | ||
239 | static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id); | ||
240 | |||
239 | static inline int i2c_pxa_is_slavemode(struct pxa_i2c *i2c) | 241 | static inline int i2c_pxa_is_slavemode(struct pxa_i2c *i2c) |
240 | { | 242 | { |
241 | return !(readl(_ICR(i2c)) & ICR_SCLE); | 243 | return !(readl(_ICR(i2c)) & ICR_SCLE); |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index d27072b2249f..72902e0bbfa7 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -35,9 +35,9 @@ | |||
35 | #include <linux/clk.h> | 35 | #include <linux/clk.h> |
36 | #include <linux/cpufreq.h> | 36 | #include <linux/cpufreq.h> |
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <linux/io.h> | ||
38 | 39 | ||
39 | #include <asm/irq.h> | 40 | #include <asm/irq.h> |
40 | #include <asm/io.h> | ||
41 | 41 | ||
42 | #include <plat/regs-iic.h> | 42 | #include <plat/regs-iic.h> |
43 | #include <plat/iic.h> | 43 | #include <plat/iic.h> |
@@ -482,7 +482,8 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c) | |||
482 | static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, | 482 | static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, |
483 | struct i2c_msg *msgs, int num) | 483 | struct i2c_msg *msgs, int num) |
484 | { | 484 | { |
485 | unsigned long timeout; | 485 | unsigned long iicstat, timeout; |
486 | int spins = 20; | ||
486 | int ret; | 487 | int ret; |
487 | 488 | ||
488 | if (i2c->suspended) | 489 | if (i2c->suspended) |
@@ -521,7 +522,21 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, | |||
521 | 522 | ||
522 | /* ensure the stop has been through the bus */ | 523 | /* ensure the stop has been through the bus */ |
523 | 524 | ||
524 | msleep(1); | 525 | dev_dbg(i2c->dev, "waiting for bus idle\n"); |
526 | |||
527 | /* first, try busy waiting briefly */ | ||
528 | do { | ||
529 | iicstat = readl(i2c->regs + S3C2410_IICSTAT); | ||
530 | } while ((iicstat & S3C2410_IICSTAT_START) && --spins); | ||
531 | |||
532 | /* if that timed out sleep */ | ||
533 | if (!spins) { | ||
534 | msleep(1); | ||
535 | iicstat = readl(i2c->regs + S3C2410_IICSTAT); | ||
536 | } | ||
537 | |||
538 | if (iicstat & S3C2410_IICSTAT_START) | ||
539 | dev_warn(i2c->dev, "timeout waiting for bus idle\n"); | ||
525 | 540 | ||
526 | out: | 541 | out: |
527 | return ret; | 542 | return ret; |
diff --git a/drivers/i2c/busses/i2c-s6000.c b/drivers/i2c/busses/i2c-s6000.c index c91359f4965c..cadc0216e02f 100644 --- a/drivers/i2c/busses/i2c-s6000.c +++ b/drivers/i2c/busses/i2c-s6000.c | |||
@@ -36,8 +36,8 @@ | |||
36 | #include <linux/completion.h> | 36 | #include <linux/completion.h> |
37 | #include <linux/interrupt.h> | 37 | #include <linux/interrupt.h> |
38 | #include <linux/platform_device.h> | 38 | #include <linux/platform_device.h> |
39 | #include <linux/io.h> | ||
39 | 40 | ||
40 | #include <asm/io.h> | ||
41 | #include "i2c-s6000.h" | 41 | #include "i2c-s6000.h" |
42 | 42 | ||
43 | #define DRV_NAME "i2c-s6000" | 43 | #define DRV_NAME "i2c-s6000" |
diff --git a/drivers/i2c/busses/i2c-sh7760.c b/drivers/i2c/busses/i2c-sh7760.c index b9680f50f541..4f93da31d3ad 100644 --- a/drivers/i2c/busses/i2c-sh7760.c +++ b/drivers/i2c/busses/i2c-sh7760.c | |||
@@ -16,10 +16,10 @@ | |||
16 | #include <linux/ioport.h> | 16 | #include <linux/ioport.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/io.h> | ||
19 | 20 | ||
20 | #include <asm/clock.h> | 21 | #include <asm/clock.h> |
21 | #include <asm/i2c-sh7760.h> | 22 | #include <asm/i2c-sh7760.h> |
22 | #include <asm/io.h> | ||
23 | 23 | ||
24 | /* register offsets */ | 24 | /* register offsets */ |
25 | #define I2CSCR 0x0 /* slave ctrl */ | 25 | #define I2CSCR 0x0 /* slave ctrl */ |
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c index 98b1ec489159..3d76a188e42f 100644 --- a/drivers/i2c/busses/i2c-sibyte.c +++ b/drivers/i2c/busses/i2c-sibyte.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <asm/io.h> | 25 | #include <linux/io.h> |
26 | #include <asm/sibyte/sb1250_regs.h> | 26 | #include <asm/sibyte/sb1250_regs.h> |
27 | #include <asm/sibyte/sb1250_smbus.h> | 27 | #include <asm/sibyte/sb1250_smbus.h> |
28 | 28 | ||
diff --git a/drivers/i2c/busses/i2c-simtec.c b/drivers/i2c/busses/i2c-simtec.c index 78b06107342c..2fc08fbf67a2 100644 --- a/drivers/i2c/busses/i2c-simtec.c +++ b/drivers/i2c/busses/i2c-simtec.c | |||
@@ -24,12 +24,11 @@ | |||
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/io.h> | ||
27 | 28 | ||
28 | #include <linux/i2c.h> | 29 | #include <linux/i2c.h> |
29 | #include <linux/i2c-algo-bit.h> | 30 | #include <linux/i2c-algo-bit.h> |
30 | 31 | ||
31 | #include <asm/io.h> | ||
32 | |||
33 | struct simtec_i2c_data { | 32 | struct simtec_i2c_data { |
34 | struct resource *ioarea; | 33 | struct resource *ioarea; |
35 | void __iomem *reg; | 34 | void __iomem *reg; |
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index 55a71370c79b..437586611d4a 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c | |||
@@ -61,7 +61,7 @@ | |||
61 | #include <linux/init.h> | 61 | #include <linux/init.h> |
62 | #include <linux/i2c.h> | 62 | #include <linux/i2c.h> |
63 | #include <linux/acpi.h> | 63 | #include <linux/acpi.h> |
64 | #include <asm/io.h> | 64 | #include <linux/io.h> |
65 | 65 | ||
66 | static int blacklist[] = { | 66 | static int blacklist[] = { |
67 | PCI_DEVICE_ID_SI_540, | 67 | PCI_DEVICE_ID_SI_540, |
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index 2309c7f1bde2..e6f539e26f65 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c | |||
@@ -53,7 +53,7 @@ | |||
53 | #include <linux/init.h> | 53 | #include <linux/init.h> |
54 | #include <linux/i2c.h> | 54 | #include <linux/i2c.h> |
55 | #include <linux/acpi.h> | 55 | #include <linux/acpi.h> |
56 | #include <asm/io.h> | 56 | #include <linux/io.h> |
57 | 57 | ||
58 | /* SIS630 SMBus registers */ | 58 | /* SIS630 SMBus registers */ |
59 | #define SMB_STS 0x80 /* status */ | 59 | #define SMB_STS 0x80 /* status */ |
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index d43d8f8943dd..86837f0c4cb9 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/acpi.h> | 40 | #include <linux/acpi.h> |
41 | #include <asm/io.h> | 41 | #include <linux/io.h> |
42 | 42 | ||
43 | /* base address register in PCI config space */ | 43 | /* base address register in PCI config space */ |
44 | #define SIS96x_BAR 0x04 | 44 | #define SIS96x_BAR 0x04 |
diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c index 1f5b38be73bc..495be451d326 100644 --- a/drivers/i2c/busses/i2c-stu300.c +++ b/drivers/i2c/busses/i2c-stu300.c | |||
@@ -498,7 +498,7 @@ static int stu300_set_clk(struct stu300_dev *dev, unsigned long clkrate) | |||
498 | int i = 0; | 498 | int i = 0; |
499 | 499 | ||
500 | /* Locate the apropriate clock setting */ | 500 | /* Locate the apropriate clock setting */ |
501 | while (i < ARRAY_SIZE(stu300_clktable) && | 501 | while (i < ARRAY_SIZE(stu300_clktable) - 1 && |
502 | stu300_clktable[i].rate < clkrate) | 502 | stu300_clktable[i].rate < clkrate) |
503 | i++; | 503 | i++; |
504 | 504 | ||
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c index 0c770eabe85e..b1b3447942c9 100644 --- a/drivers/i2c/busses/i2c-stub.c +++ b/drivers/i2c/busses/i2c-stub.c | |||
@@ -29,13 +29,16 @@ | |||
29 | #include <linux/i2c.h> | 29 | #include <linux/i2c.h> |
30 | 30 | ||
31 | #define MAX_CHIPS 10 | 31 | #define MAX_CHIPS 10 |
32 | #define STUB_FUNC (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | \ | ||
33 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | \ | ||
34 | I2C_FUNC_SMBUS_I2C_BLOCK) | ||
32 | 35 | ||
33 | static unsigned short chip_addr[MAX_CHIPS]; | 36 | static unsigned short chip_addr[MAX_CHIPS]; |
34 | module_param_array(chip_addr, ushort, NULL, S_IRUGO); | 37 | module_param_array(chip_addr, ushort, NULL, S_IRUGO); |
35 | MODULE_PARM_DESC(chip_addr, | 38 | MODULE_PARM_DESC(chip_addr, |
36 | "Chip addresses (up to 10, between 0x03 and 0x77)"); | 39 | "Chip addresses (up to 10, between 0x03 and 0x77)"); |
37 | 40 | ||
38 | static unsigned long functionality = ~0UL; | 41 | static unsigned long functionality = STUB_FUNC; |
39 | module_param(functionality, ulong, S_IRUGO | S_IWUSR); | 42 | module_param(functionality, ulong, S_IRUGO | S_IWUSR); |
40 | MODULE_PARM_DESC(functionality, "Override functionality bitfield"); | 43 | MODULE_PARM_DESC(functionality, "Override functionality bitfield"); |
41 | 44 | ||
@@ -156,9 +159,7 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags, | |||
156 | 159 | ||
157 | static u32 stub_func(struct i2c_adapter *adapter) | 160 | static u32 stub_func(struct i2c_adapter *adapter) |
158 | { | 161 | { |
159 | return (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | | 162 | return STUB_FUNC & functionality; |
160 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | | ||
161 | I2C_FUNC_SMBUS_I2C_BLOCK) & functionality; | ||
162 | } | 163 | } |
163 | 164 | ||
164 | static const struct i2c_algorithm smbus_algorithm = { | 165 | static const struct i2c_algorithm smbus_algorithm = { |
diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c index 5c473833d948..60556012312f 100644 --- a/drivers/i2c/busses/i2c-versatile.c +++ b/drivers/i2c/busses/i2c-versatile.c | |||
@@ -15,8 +15,7 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | 18 | #include <linux/io.h> | |
19 | #include <asm/io.h> | ||
20 | 19 | ||
21 | #define I2C_CONTROL 0x00 | 20 | #define I2C_CONTROL 0x00 |
22 | #define I2C_CONTROLS 0x00 | 21 | #define I2C_CONTROLS 0x00 |
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c index de78283bddbe..7799fe5bda88 100644 --- a/drivers/i2c/busses/i2c-via.c +++ b/drivers/i2c/busses/i2c-via.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/i2c-algo-bit.h> | 27 | #include <linux/i2c-algo-bit.h> |
28 | #include <asm/io.h> | 28 | #include <linux/io.h> |
29 | 29 | ||
30 | /* Power management registers */ | 30 | /* Power management registers */ |
31 | #define PM_CFG_REVID 0x08 /* silicon revision code */ | 31 | #define PM_CFG_REVID 0x08 /* silicon revision code */ |
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index d57292e5dae0..4c6fff5f330d 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c | |||
@@ -51,7 +51,7 @@ | |||
51 | #include <linux/i2c.h> | 51 | #include <linux/i2c.h> |
52 | #include <linux/init.h> | 52 | #include <linux/init.h> |
53 | #include <linux/acpi.h> | 53 | #include <linux/acpi.h> |
54 | #include <asm/io.h> | 54 | #include <linux/io.h> |
55 | 55 | ||
56 | static struct pci_dev *vt596_pdev; | 56 | static struct pci_dev *vt596_pdev; |
57 | 57 | ||
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index 684395b6f3e2..4cb4bb009950 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
33 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <asm/io.h> | 35 | #include <linux/io.h> |
36 | 36 | ||
37 | #include <linux/scx200.h> | 37 | #include <linux/scx200.h> |
38 | 38 | ||
@@ -552,7 +552,7 @@ static int __init scx200_create_isa(const char *text, unsigned long base, | |||
552 | * the name and the BAR where the I/O address resource is located. ISA | 552 | * the name and the BAR where the I/O address resource is located. ISA |
553 | * devices are flagged with a bar value of -1 */ | 553 | * devices are flagged with a bar value of -1 */ |
554 | 554 | ||
555 | static struct pci_device_id scx200_pci[] = { | 555 | static const struct pci_device_id scx200_pci[] __initconst = { |
556 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE), | 556 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE), |
557 | .driver_data = 0 }, | 557 | .driver_data = 0 }, |
558 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE), | 558 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE), |
diff --git a/drivers/i2c/busses/scx200_i2c.c b/drivers/i2c/busses/scx200_i2c.c index 42df0eca43d5..7ee0d502ceab 100644 --- a/drivers/i2c/busses/scx200_i2c.c +++ b/drivers/i2c/busses/scx200_i2c.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/i2c-algo-bit.h> | 29 | #include <linux/i2c-algo-bit.h> |
30 | #include <asm/io.h> | 30 | #include <linux/io.h> |
31 | 31 | ||
32 | #include <linux/scx200_gpio.h> | 32 | #include <linux/scx200_gpio.h> |
33 | 33 | ||
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 4099b2b8c392..e0f833cca3f1 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -40,12 +40,11 @@ | |||
40 | #include "i2c-core.h" | 40 | #include "i2c-core.h" |
41 | 41 | ||
42 | 42 | ||
43 | /* core_lock protects i2c_adapter_idr, userspace_devices, and guarantees | 43 | /* core_lock protects i2c_adapter_idr, and guarantees |
44 | that device detection, deletion of detected devices, and attach_adapter | 44 | that device detection, deletion of detected devices, and attach_adapter |
45 | and detach_adapter calls are serialized */ | 45 | and detach_adapter calls are serialized */ |
46 | static DEFINE_MUTEX(core_lock); | 46 | static DEFINE_MUTEX(core_lock); |
47 | static DEFINE_IDR(i2c_adapter_idr); | 47 | static DEFINE_IDR(i2c_adapter_idr); |
48 | static LIST_HEAD(userspace_devices); | ||
49 | 48 | ||
50 | static struct device_type i2c_client_type; | 49 | static struct device_type i2c_client_type; |
51 | static int i2c_check_addr(struct i2c_adapter *adapter, int addr); | 50 | static int i2c_check_addr(struct i2c_adapter *adapter, int addr); |
@@ -117,8 +116,10 @@ static int i2c_device_probe(struct device *dev) | |||
117 | dev_dbg(dev, "probe\n"); | 116 | dev_dbg(dev, "probe\n"); |
118 | 117 | ||
119 | status = driver->probe(client, i2c_match_id(driver->id_table, client)); | 118 | status = driver->probe(client, i2c_match_id(driver->id_table, client)); |
120 | if (status) | 119 | if (status) { |
121 | client->driver = NULL; | 120 | client->driver = NULL; |
121 | i2c_set_clientdata(client, NULL); | ||
122 | } | ||
122 | return status; | 123 | return status; |
123 | } | 124 | } |
124 | 125 | ||
@@ -139,8 +140,10 @@ static int i2c_device_remove(struct device *dev) | |||
139 | dev->driver = NULL; | 140 | dev->driver = NULL; |
140 | status = 0; | 141 | status = 0; |
141 | } | 142 | } |
142 | if (status == 0) | 143 | if (status == 0) { |
143 | client->driver = NULL; | 144 | client->driver = NULL; |
145 | i2c_set_clientdata(client, NULL); | ||
146 | } | ||
144 | return status; | 147 | return status; |
145 | } | 148 | } |
146 | 149 | ||
@@ -156,106 +159,130 @@ static void i2c_device_shutdown(struct device *dev) | |||
156 | driver->shutdown(client); | 159 | driver->shutdown(client); |
157 | } | 160 | } |
158 | 161 | ||
159 | #ifdef CONFIG_SUSPEND | 162 | #ifdef CONFIG_PM_SLEEP |
160 | static int i2c_device_pm_suspend(struct device *dev) | 163 | static int i2c_legacy_suspend(struct device *dev, pm_message_t mesg) |
161 | { | 164 | { |
162 | const struct dev_pm_ops *pm; | 165 | struct i2c_client *client = i2c_verify_client(dev); |
166 | struct i2c_driver *driver; | ||
163 | 167 | ||
164 | if (!dev->driver) | 168 | if (!client || !dev->driver) |
165 | return 0; | 169 | return 0; |
166 | pm = dev->driver->pm; | 170 | driver = to_i2c_driver(dev->driver); |
167 | if (!pm || !pm->suspend) | 171 | if (!driver->suspend) |
168 | return 0; | 172 | return 0; |
169 | return pm->suspend(dev); | 173 | return driver->suspend(client, mesg); |
170 | } | 174 | } |
171 | 175 | ||
172 | static int i2c_device_pm_resume(struct device *dev) | 176 | static int i2c_legacy_resume(struct device *dev) |
173 | { | 177 | { |
174 | const struct dev_pm_ops *pm; | 178 | struct i2c_client *client = i2c_verify_client(dev); |
179 | struct i2c_driver *driver; | ||
175 | 180 | ||
176 | if (!dev->driver) | 181 | if (!client || !dev->driver) |
177 | return 0; | 182 | return 0; |
178 | pm = dev->driver->pm; | 183 | driver = to_i2c_driver(dev->driver); |
179 | if (!pm || !pm->resume) | 184 | if (!driver->resume) |
180 | return 0; | 185 | return 0; |
181 | return pm->resume(dev); | 186 | return driver->resume(client); |
182 | } | 187 | } |
183 | #else | ||
184 | #define i2c_device_pm_suspend NULL | ||
185 | #define i2c_device_pm_resume NULL | ||
186 | #endif | ||
187 | 188 | ||
188 | #ifdef CONFIG_PM_RUNTIME | 189 | static int i2c_device_pm_suspend(struct device *dev) |
189 | static int i2c_device_runtime_suspend(struct device *dev) | ||
190 | { | 190 | { |
191 | const struct dev_pm_ops *pm; | 191 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
192 | 192 | ||
193 | if (!dev->driver) | 193 | if (pm_runtime_suspended(dev)) |
194 | return 0; | ||
195 | pm = dev->driver->pm; | ||
196 | if (!pm || !pm->runtime_suspend) | ||
197 | return 0; | 194 | return 0; |
198 | return pm->runtime_suspend(dev); | ||
199 | } | ||
200 | 195 | ||
201 | static int i2c_device_runtime_resume(struct device *dev) | 196 | if (pm) |
202 | { | 197 | return pm->suspend ? pm->suspend(dev) : 0; |
203 | const struct dev_pm_ops *pm; | ||
204 | 198 | ||
205 | if (!dev->driver) | 199 | return i2c_legacy_suspend(dev, PMSG_SUSPEND); |
206 | return 0; | ||
207 | pm = dev->driver->pm; | ||
208 | if (!pm || !pm->runtime_resume) | ||
209 | return 0; | ||
210 | return pm->runtime_resume(dev); | ||
211 | } | 200 | } |
212 | 201 | ||
213 | static int i2c_device_runtime_idle(struct device *dev) | 202 | static int i2c_device_pm_resume(struct device *dev) |
214 | { | 203 | { |
215 | const struct dev_pm_ops *pm = NULL; | 204 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
216 | int ret; | 205 | int ret; |
217 | 206 | ||
218 | if (dev->driver) | 207 | if (pm) |
219 | pm = dev->driver->pm; | 208 | ret = pm->resume ? pm->resume(dev) : 0; |
220 | if (pm && pm->runtime_idle) { | 209 | else |
221 | ret = pm->runtime_idle(dev); | 210 | ret = i2c_legacy_resume(dev); |
222 | if (ret) | 211 | |
223 | return ret; | 212 | if (!ret) { |
213 | pm_runtime_disable(dev); | ||
214 | pm_runtime_set_active(dev); | ||
215 | pm_runtime_enable(dev); | ||
224 | } | 216 | } |
225 | 217 | ||
226 | return pm_runtime_suspend(dev); | 218 | return ret; |
227 | } | 219 | } |
228 | #else | ||
229 | #define i2c_device_runtime_suspend NULL | ||
230 | #define i2c_device_runtime_resume NULL | ||
231 | #define i2c_device_runtime_idle NULL | ||
232 | #endif | ||
233 | 220 | ||
234 | static int i2c_device_suspend(struct device *dev, pm_message_t mesg) | 221 | static int i2c_device_pm_freeze(struct device *dev) |
235 | { | 222 | { |
236 | struct i2c_client *client = i2c_verify_client(dev); | 223 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
237 | struct i2c_driver *driver; | ||
238 | 224 | ||
239 | if (!client || !dev->driver) | 225 | if (pm_runtime_suspended(dev)) |
240 | return 0; | 226 | return 0; |
241 | driver = to_i2c_driver(dev->driver); | 227 | |
242 | if (!driver->suspend) | 228 | if (pm) |
243 | return 0; | 229 | return pm->freeze ? pm->freeze(dev) : 0; |
244 | return driver->suspend(client, mesg); | 230 | |
231 | return i2c_legacy_suspend(dev, PMSG_FREEZE); | ||
245 | } | 232 | } |
246 | 233 | ||
247 | static int i2c_device_resume(struct device *dev) | 234 | static int i2c_device_pm_thaw(struct device *dev) |
248 | { | 235 | { |
249 | struct i2c_client *client = i2c_verify_client(dev); | 236 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
250 | struct i2c_driver *driver; | ||
251 | 237 | ||
252 | if (!client || !dev->driver) | 238 | if (pm_runtime_suspended(dev)) |
253 | return 0; | 239 | return 0; |
254 | driver = to_i2c_driver(dev->driver); | 240 | |
255 | if (!driver->resume) | 241 | if (pm) |
242 | return pm->thaw ? pm->thaw(dev) : 0; | ||
243 | |||
244 | return i2c_legacy_resume(dev); | ||
245 | } | ||
246 | |||
247 | static int i2c_device_pm_poweroff(struct device *dev) | ||
248 | { | ||
249 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | ||
250 | |||
251 | if (pm_runtime_suspended(dev)) | ||
256 | return 0; | 252 | return 0; |
257 | return driver->resume(client); | 253 | |
254 | if (pm) | ||
255 | return pm->poweroff ? pm->poweroff(dev) : 0; | ||
256 | |||
257 | return i2c_legacy_suspend(dev, PMSG_HIBERNATE); | ||
258 | } | ||
259 | |||
260 | static int i2c_device_pm_restore(struct device *dev) | ||
261 | { | ||
262 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | ||
263 | int ret; | ||
264 | |||
265 | if (pm) | ||
266 | ret = pm->restore ? pm->restore(dev) : 0; | ||
267 | else | ||
268 | ret = i2c_legacy_resume(dev); | ||
269 | |||
270 | if (!ret) { | ||
271 | pm_runtime_disable(dev); | ||
272 | pm_runtime_set_active(dev); | ||
273 | pm_runtime_enable(dev); | ||
274 | } | ||
275 | |||
276 | return ret; | ||
258 | } | 277 | } |
278 | #else /* !CONFIG_PM_SLEEP */ | ||
279 | #define i2c_device_pm_suspend NULL | ||
280 | #define i2c_device_pm_resume NULL | ||
281 | #define i2c_device_pm_freeze NULL | ||
282 | #define i2c_device_pm_thaw NULL | ||
283 | #define i2c_device_pm_poweroff NULL | ||
284 | #define i2c_device_pm_restore NULL | ||
285 | #endif /* !CONFIG_PM_SLEEP */ | ||
259 | 286 | ||
260 | static void i2c_client_dev_release(struct device *dev) | 287 | static void i2c_client_dev_release(struct device *dev) |
261 | { | 288 | { |
@@ -298,9 +325,15 @@ static const struct attribute_group *i2c_dev_attr_groups[] = { | |||
298 | static const struct dev_pm_ops i2c_device_pm_ops = { | 325 | static const struct dev_pm_ops i2c_device_pm_ops = { |
299 | .suspend = i2c_device_pm_suspend, | 326 | .suspend = i2c_device_pm_suspend, |
300 | .resume = i2c_device_pm_resume, | 327 | .resume = i2c_device_pm_resume, |
301 | .runtime_suspend = i2c_device_runtime_suspend, | 328 | .freeze = i2c_device_pm_freeze, |
302 | .runtime_resume = i2c_device_runtime_resume, | 329 | .thaw = i2c_device_pm_thaw, |
303 | .runtime_idle = i2c_device_runtime_idle, | 330 | .poweroff = i2c_device_pm_poweroff, |
331 | .restore = i2c_device_pm_restore, | ||
332 | SET_RUNTIME_PM_OPS( | ||
333 | pm_generic_runtime_suspend, | ||
334 | pm_generic_runtime_resume, | ||
335 | pm_generic_runtime_idle | ||
336 | ) | ||
304 | }; | 337 | }; |
305 | 338 | ||
306 | struct bus_type i2c_bus_type = { | 339 | struct bus_type i2c_bus_type = { |
@@ -309,8 +342,6 @@ struct bus_type i2c_bus_type = { | |||
309 | .probe = i2c_device_probe, | 342 | .probe = i2c_device_probe, |
310 | .remove = i2c_device_remove, | 343 | .remove = i2c_device_remove, |
311 | .shutdown = i2c_device_shutdown, | 344 | .shutdown = i2c_device_shutdown, |
312 | .suspend = i2c_device_suspend, | ||
313 | .resume = i2c_device_resume, | ||
314 | .pm = &i2c_device_pm_ops, | 345 | .pm = &i2c_device_pm_ops, |
315 | }; | 346 | }; |
316 | EXPORT_SYMBOL_GPL(i2c_bus_type); | 347 | EXPORT_SYMBOL_GPL(i2c_bus_type); |
@@ -541,9 +572,9 @@ i2c_sysfs_new_device(struct device *dev, struct device_attribute *attr, | |||
541 | return -EEXIST; | 572 | return -EEXIST; |
542 | 573 | ||
543 | /* Keep track of the added device */ | 574 | /* Keep track of the added device */ |
544 | mutex_lock(&core_lock); | 575 | i2c_lock_adapter(adap); |
545 | list_add_tail(&client->detected, &userspace_devices); | 576 | list_add_tail(&client->detected, &adap->userspace_clients); |
546 | mutex_unlock(&core_lock); | 577 | i2c_unlock_adapter(adap); |
547 | dev_info(dev, "%s: Instantiated device %s at 0x%02hx\n", "new_device", | 578 | dev_info(dev, "%s: Instantiated device %s at 0x%02hx\n", "new_device", |
548 | info.type, info.addr); | 579 | info.type, info.addr); |
549 | 580 | ||
@@ -582,9 +613,10 @@ i2c_sysfs_delete_device(struct device *dev, struct device_attribute *attr, | |||
582 | 613 | ||
583 | /* Make sure the device was added through sysfs */ | 614 | /* Make sure the device was added through sysfs */ |
584 | res = -ENOENT; | 615 | res = -ENOENT; |
585 | mutex_lock(&core_lock); | 616 | i2c_lock_adapter(adap); |
586 | list_for_each_entry_safe(client, next, &userspace_devices, detected) { | 617 | list_for_each_entry_safe(client, next, &adap->userspace_clients, |
587 | if (client->addr == addr && client->adapter == adap) { | 618 | detected) { |
619 | if (client->addr == addr) { | ||
588 | dev_info(dev, "%s: Deleting device %s at 0x%02hx\n", | 620 | dev_info(dev, "%s: Deleting device %s at 0x%02hx\n", |
589 | "delete_device", client->name, client->addr); | 621 | "delete_device", client->name, client->addr); |
590 | 622 | ||
@@ -594,7 +626,7 @@ i2c_sysfs_delete_device(struct device *dev, struct device_attribute *attr, | |||
594 | break; | 626 | break; |
595 | } | 627 | } |
596 | } | 628 | } |
597 | mutex_unlock(&core_lock); | 629 | i2c_unlock_adapter(adap); |
598 | 630 | ||
599 | if (res < 0) | 631 | if (res < 0) |
600 | dev_err(dev, "%s: Can't find device in list\n", | 632 | dev_err(dev, "%s: Can't find device in list\n", |
@@ -676,6 +708,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap) | |||
676 | } | 708 | } |
677 | 709 | ||
678 | rt_mutex_init(&adap->bus_lock); | 710 | rt_mutex_init(&adap->bus_lock); |
711 | INIT_LIST_HEAD(&adap->userspace_clients); | ||
679 | 712 | ||
680 | /* Set default timeout to 1 second if not already set */ | 713 | /* Set default timeout to 1 second if not already set */ |
681 | if (adap->timeout == 0) | 714 | if (adap->timeout == 0) |
@@ -878,14 +911,15 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
878 | return res; | 911 | return res; |
879 | 912 | ||
880 | /* Remove devices instantiated from sysfs */ | 913 | /* Remove devices instantiated from sysfs */ |
881 | list_for_each_entry_safe(client, next, &userspace_devices, detected) { | 914 | i2c_lock_adapter(adap); |
882 | if (client->adapter == adap) { | 915 | list_for_each_entry_safe(client, next, &adap->userspace_clients, |
883 | dev_dbg(&adap->dev, "Removing %s at 0x%x\n", | 916 | detected) { |
884 | client->name, client->addr); | 917 | dev_dbg(&adap->dev, "Removing %s at 0x%x\n", client->name, |
885 | list_del(&client->detected); | 918 | client->addr); |
886 | i2c_unregister_device(client); | 919 | list_del(&client->detected); |
887 | } | 920 | i2c_unregister_device(client); |
888 | } | 921 | } |
922 | i2c_unlock_adapter(adap); | ||
889 | 923 | ||
890 | /* Detach any active clients. This can't fail, thus we do not | 924 | /* Detach any active clients. This can't fail, thus we do not |
891 | checking the returned value. */ | 925 | checking the returned value. */ |
@@ -1190,10 +1224,10 @@ EXPORT_SYMBOL(i2c_transfer); | |||
1190 | * | 1224 | * |
1191 | * Returns negative errno, or else the number of bytes written. | 1225 | * Returns negative errno, or else the number of bytes written. |
1192 | */ | 1226 | */ |
1193 | int i2c_master_send(struct i2c_client *client,const char *buf ,int count) | 1227 | int i2c_master_send(struct i2c_client *client, const char *buf, int count) |
1194 | { | 1228 | { |
1195 | int ret; | 1229 | int ret; |
1196 | struct i2c_adapter *adap=client->adapter; | 1230 | struct i2c_adapter *adap = client->adapter; |
1197 | struct i2c_msg msg; | 1231 | struct i2c_msg msg; |
1198 | 1232 | ||
1199 | msg.addr = client->addr; | 1233 | msg.addr = client->addr; |
@@ -1217,9 +1251,9 @@ EXPORT_SYMBOL(i2c_master_send); | |||
1217 | * | 1251 | * |
1218 | * Returns negative errno, or else the number of bytes read. | 1252 | * Returns negative errno, or else the number of bytes read. |
1219 | */ | 1253 | */ |
1220 | int i2c_master_recv(struct i2c_client *client, char *buf ,int count) | 1254 | int i2c_master_recv(struct i2c_client *client, char *buf, int count) |
1221 | { | 1255 | { |
1222 | struct i2c_adapter *adap=client->adapter; | 1256 | struct i2c_adapter *adap = client->adapter; |
1223 | struct i2c_msg msg; | 1257 | struct i2c_msg msg; |
1224 | int ret; | 1258 | int ret; |
1225 | 1259 | ||
@@ -1263,12 +1297,23 @@ static int i2c_detect_address(struct i2c_client *temp_client, | |||
1263 | return 0; | 1297 | return 0; |
1264 | 1298 | ||
1265 | /* Make sure there is something at this address */ | 1299 | /* Make sure there is something at this address */ |
1266 | if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) < 0) | 1300 | if (addr == 0x73 && (adapter->class & I2C_CLASS_HWMON)) { |
1267 | return 0; | 1301 | /* Special probe for FSC hwmon chips */ |
1302 | union i2c_smbus_data dummy; | ||
1268 | 1303 | ||
1269 | /* Prevent 24RF08 corruption */ | 1304 | if (i2c_smbus_xfer(adapter, addr, 0, I2C_SMBUS_READ, 0, |
1270 | if ((addr & ~0x0f) == 0x50) | 1305 | I2C_SMBUS_BYTE_DATA, &dummy) < 0) |
1271 | i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL); | 1306 | return 0; |
1307 | } else { | ||
1308 | if (i2c_smbus_xfer(adapter, addr, 0, I2C_SMBUS_WRITE, 0, | ||
1309 | I2C_SMBUS_QUICK, NULL) < 0) | ||
1310 | return 0; | ||
1311 | |||
1312 | /* Prevent 24RF08 corruption */ | ||
1313 | if ((addr & ~0x0f) == 0x50) | ||
1314 | i2c_smbus_xfer(adapter, addr, 0, I2C_SMBUS_WRITE, 0, | ||
1315 | I2C_SMBUS_QUICK, NULL); | ||
1316 | } | ||
1272 | 1317 | ||
1273 | /* Finally call the custom detection function */ | 1318 | /* Finally call the custom detection function */ |
1274 | memset(&info, 0, sizeof(struct i2c_board_info)); | 1319 | memset(&info, 0, sizeof(struct i2c_board_info)); |
@@ -1410,7 +1455,7 @@ i2c_new_probed_device(struct i2c_adapter *adap, | |||
1410 | } | 1455 | } |
1411 | EXPORT_SYMBOL_GPL(i2c_new_probed_device); | 1456 | EXPORT_SYMBOL_GPL(i2c_new_probed_device); |
1412 | 1457 | ||
1413 | struct i2c_adapter* i2c_get_adapter(int id) | 1458 | struct i2c_adapter *i2c_get_adapter(int id) |
1414 | { | 1459 | { |
1415 | struct i2c_adapter *adapter; | 1460 | struct i2c_adapter *adapter; |
1416 | 1461 | ||
@@ -1437,7 +1482,7 @@ static u8 crc8(u16 data) | |||
1437 | { | 1482 | { |
1438 | int i; | 1483 | int i; |
1439 | 1484 | ||
1440 | for(i = 0; i < 8; i++) { | 1485 | for (i = 0; i < 8; i++) { |
1441 | if (data & 0x8000) | 1486 | if (data & 0x8000) |
1442 | data = data ^ POLY; | 1487 | data = data ^ POLY; |
1443 | data = data << 1; | 1488 | data = data << 1; |
@@ -1450,7 +1495,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) | |||
1450 | { | 1495 | { |
1451 | int i; | 1496 | int i; |
1452 | 1497 | ||
1453 | for(i = 0; i < count; i++) | 1498 | for (i = 0; i < count; i++) |
1454 | crc = crc8((crc ^ p[i]) << 8); | 1499 | crc = crc8((crc ^ p[i]) << 8); |
1455 | return crc; | 1500 | return crc; |
1456 | } | 1501 | } |
@@ -1520,7 +1565,7 @@ EXPORT_SYMBOL(i2c_smbus_read_byte); | |||
1520 | */ | 1565 | */ |
1521 | s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) | 1566 | s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) |
1522 | { | 1567 | { |
1523 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 1568 | return i2c_smbus_xfer(client->adapter, client->addr, client->flags, |
1524 | I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); | 1569 | I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); |
1525 | } | 1570 | } |
1526 | EXPORT_SYMBOL(i2c_smbus_write_byte); | 1571 | EXPORT_SYMBOL(i2c_smbus_write_byte); |
@@ -1558,9 +1603,9 @@ s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value) | |||
1558 | { | 1603 | { |
1559 | union i2c_smbus_data data; | 1604 | union i2c_smbus_data data; |
1560 | data.byte = value; | 1605 | data.byte = value; |
1561 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 1606 | return i2c_smbus_xfer(client->adapter, client->addr, client->flags, |
1562 | I2C_SMBUS_WRITE,command, | 1607 | I2C_SMBUS_WRITE, command, |
1563 | I2C_SMBUS_BYTE_DATA,&data); | 1608 | I2C_SMBUS_BYTE_DATA, &data); |
1564 | } | 1609 | } |
1565 | EXPORT_SYMBOL(i2c_smbus_write_byte_data); | 1610 | EXPORT_SYMBOL(i2c_smbus_write_byte_data); |
1566 | 1611 | ||
@@ -1597,9 +1642,9 @@ s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value) | |||
1597 | { | 1642 | { |
1598 | union i2c_smbus_data data; | 1643 | union i2c_smbus_data data; |
1599 | data.word = value; | 1644 | data.word = value; |
1600 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 1645 | return i2c_smbus_xfer(client->adapter, client->addr, client->flags, |
1601 | I2C_SMBUS_WRITE,command, | 1646 | I2C_SMBUS_WRITE, command, |
1602 | I2C_SMBUS_WORD_DATA,&data); | 1647 | I2C_SMBUS_WORD_DATA, &data); |
1603 | } | 1648 | } |
1604 | EXPORT_SYMBOL(i2c_smbus_write_word_data); | 1649 | EXPORT_SYMBOL(i2c_smbus_write_word_data); |
1605 | 1650 | ||
@@ -1676,9 +1721,9 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, | |||
1676 | length = I2C_SMBUS_BLOCK_MAX; | 1721 | length = I2C_SMBUS_BLOCK_MAX; |
1677 | data.block[0] = length; | 1722 | data.block[0] = length; |
1678 | memcpy(&data.block[1], values, length); | 1723 | memcpy(&data.block[1], values, length); |
1679 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 1724 | return i2c_smbus_xfer(client->adapter, client->addr, client->flags, |
1680 | I2C_SMBUS_WRITE,command, | 1725 | I2C_SMBUS_WRITE, command, |
1681 | I2C_SMBUS_BLOCK_DATA,&data); | 1726 | I2C_SMBUS_BLOCK_DATA, &data); |
1682 | } | 1727 | } |
1683 | EXPORT_SYMBOL(i2c_smbus_write_block_data); | 1728 | EXPORT_SYMBOL(i2c_smbus_write_block_data); |
1684 | 1729 | ||
@@ -1720,10 +1765,10 @@ EXPORT_SYMBOL(i2c_smbus_write_i2c_block_data); | |||
1720 | 1765 | ||
1721 | /* Simulate a SMBus command using the i2c protocol | 1766 | /* Simulate a SMBus command using the i2c protocol |
1722 | No checking of parameters is done! */ | 1767 | No checking of parameters is done! */ |
1723 | static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | 1768 | static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, |
1724 | unsigned short flags, | 1769 | unsigned short flags, |
1725 | char read_write, u8 command, int size, | 1770 | char read_write, u8 command, int size, |
1726 | union i2c_smbus_data * data) | 1771 | union i2c_smbus_data *data) |
1727 | { | 1772 | { |
1728 | /* So we need to generate a series of msgs. In the case of writing, we | 1773 | /* So we need to generate a series of msgs. In the case of writing, we |
1729 | need to use only one message; when reading, we need two. We initialize | 1774 | need to use only one message; when reading, we need two. We initialize |
@@ -1731,7 +1776,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1731 | simpler. */ | 1776 | simpler. */ |
1732 | unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; | 1777 | unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; |
1733 | unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; | 1778 | unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; |
1734 | int num = read_write == I2C_SMBUS_READ?2:1; | 1779 | int num = read_write == I2C_SMBUS_READ ? 2 : 1; |
1735 | struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, | 1780 | struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, |
1736 | { addr, flags | I2C_M_RD, 0, msgbuf1 } | 1781 | { addr, flags | I2C_M_RD, 0, msgbuf1 } |
1737 | }; | 1782 | }; |
@@ -1740,7 +1785,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1740 | int status; | 1785 | int status; |
1741 | 1786 | ||
1742 | msgbuf0[0] = command; | 1787 | msgbuf0[0] = command; |
1743 | switch(size) { | 1788 | switch (size) { |
1744 | case I2C_SMBUS_QUICK: | 1789 | case I2C_SMBUS_QUICK: |
1745 | msg[0].len = 0; | 1790 | msg[0].len = 0; |
1746 | /* Special case: The read/write field is used as data */ | 1791 | /* Special case: The read/write field is used as data */ |
@@ -1767,7 +1812,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1767 | if (read_write == I2C_SMBUS_READ) | 1812 | if (read_write == I2C_SMBUS_READ) |
1768 | msg[1].len = 2; | 1813 | msg[1].len = 2; |
1769 | else { | 1814 | else { |
1770 | msg[0].len=3; | 1815 | msg[0].len = 3; |
1771 | msgbuf0[1] = data->word & 0xff; | 1816 | msgbuf0[1] = data->word & 0xff; |
1772 | msgbuf0[2] = data->word >> 8; | 1817 | msgbuf0[2] = data->word >> 8; |
1773 | } | 1818 | } |
@@ -1860,26 +1905,26 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1860 | } | 1905 | } |
1861 | 1906 | ||
1862 | if (read_write == I2C_SMBUS_READ) | 1907 | if (read_write == I2C_SMBUS_READ) |
1863 | switch(size) { | 1908 | switch (size) { |
1864 | case I2C_SMBUS_BYTE: | 1909 | case I2C_SMBUS_BYTE: |
1865 | data->byte = msgbuf0[0]; | 1910 | data->byte = msgbuf0[0]; |
1866 | break; | 1911 | break; |
1867 | case I2C_SMBUS_BYTE_DATA: | 1912 | case I2C_SMBUS_BYTE_DATA: |
1868 | data->byte = msgbuf1[0]; | 1913 | data->byte = msgbuf1[0]; |
1869 | break; | 1914 | break; |
1870 | case I2C_SMBUS_WORD_DATA: | 1915 | case I2C_SMBUS_WORD_DATA: |
1871 | case I2C_SMBUS_PROC_CALL: | 1916 | case I2C_SMBUS_PROC_CALL: |
1872 | data->word = msgbuf1[0] | (msgbuf1[1] << 8); | 1917 | data->word = msgbuf1[0] | (msgbuf1[1] << 8); |
1873 | break; | 1918 | break; |
1874 | case I2C_SMBUS_I2C_BLOCK_DATA: | 1919 | case I2C_SMBUS_I2C_BLOCK_DATA: |
1875 | for (i = 0; i < data->block[0]; i++) | 1920 | for (i = 0; i < data->block[0]; i++) |
1876 | data->block[i+1] = msgbuf1[i]; | 1921 | data->block[i+1] = msgbuf1[i]; |
1877 | break; | 1922 | break; |
1878 | case I2C_SMBUS_BLOCK_DATA: | 1923 | case I2C_SMBUS_BLOCK_DATA: |
1879 | case I2C_SMBUS_BLOCK_PROC_CALL: | 1924 | case I2C_SMBUS_BLOCK_PROC_CALL: |
1880 | for (i = 0; i < msgbuf1[0] + 1; i++) | 1925 | for (i = 0; i < msgbuf1[0] + 1; i++) |
1881 | data->block[i] = msgbuf1[i]; | 1926 | data->block[i] = msgbuf1[i]; |
1882 | break; | 1927 | break; |
1883 | } | 1928 | } |
1884 | return 0; | 1929 | return 0; |
1885 | } | 1930 | } |
@@ -1924,7 +1969,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, | |||
1924 | } | 1969 | } |
1925 | rt_mutex_unlock(&adapter->bus_lock); | 1970 | rt_mutex_unlock(&adapter->bus_lock); |
1926 | } else | 1971 | } else |
1927 | res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, | 1972 | res = i2c_smbus_xfer_emulated(adapter, addr, flags, read_write, |
1928 | command, protocol, data); | 1973 | command, protocol, data); |
1929 | 1974 | ||
1930 | return res; | 1975 | return res; |
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index f4110aa49600..e0694e4d86c7 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
36 | #include <linux/i2c-dev.h> | 36 | #include <linux/i2c-dev.h> |
37 | #include <linux/jiffies.h> | 37 | #include <linux/jiffies.h> |
38 | #include <asm/uaccess.h> | 38 | #include <linux/uaccess.h> |
39 | 39 | ||
40 | static struct i2c_driver i2cdev_driver; | 40 | static struct i2c_driver i2cdev_driver; |
41 | 41 | ||
@@ -132,45 +132,45 @@ static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); | |||
132 | * needed by those system calls and by this SMBus interface. | 132 | * needed by those system calls and by this SMBus interface. |
133 | */ | 133 | */ |
134 | 134 | ||
135 | static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count, | 135 | static ssize_t i2cdev_read(struct file *file, char __user *buf, size_t count, |
136 | loff_t *offset) | 136 | loff_t *offset) |
137 | { | 137 | { |
138 | char *tmp; | 138 | char *tmp; |
139 | int ret; | 139 | int ret; |
140 | 140 | ||
141 | struct i2c_client *client = (struct i2c_client *)file->private_data; | 141 | struct i2c_client *client = file->private_data; |
142 | 142 | ||
143 | if (count > 8192) | 143 | if (count > 8192) |
144 | count = 8192; | 144 | count = 8192; |
145 | 145 | ||
146 | tmp = kmalloc(count,GFP_KERNEL); | 146 | tmp = kmalloc(count, GFP_KERNEL); |
147 | if (tmp==NULL) | 147 | if (tmp == NULL) |
148 | return -ENOMEM; | 148 | return -ENOMEM; |
149 | 149 | ||
150 | pr_debug("i2c-dev: i2c-%d reading %zu bytes.\n", | 150 | pr_debug("i2c-dev: i2c-%d reading %zu bytes.\n", |
151 | iminor(file->f_path.dentry->d_inode), count); | 151 | iminor(file->f_path.dentry->d_inode), count); |
152 | 152 | ||
153 | ret = i2c_master_recv(client,tmp,count); | 153 | ret = i2c_master_recv(client, tmp, count); |
154 | if (ret >= 0) | 154 | if (ret >= 0) |
155 | ret = copy_to_user(buf,tmp,count)?-EFAULT:ret; | 155 | ret = copy_to_user(buf, tmp, count) ? -EFAULT : ret; |
156 | kfree(tmp); | 156 | kfree(tmp); |
157 | return ret; | 157 | return ret; |
158 | } | 158 | } |
159 | 159 | ||
160 | static ssize_t i2cdev_write (struct file *file, const char __user *buf, size_t count, | 160 | static ssize_t i2cdev_write(struct file *file, const char __user *buf, |
161 | loff_t *offset) | 161 | size_t count, loff_t *offset) |
162 | { | 162 | { |
163 | int ret; | 163 | int ret; |
164 | char *tmp; | 164 | char *tmp; |
165 | struct i2c_client *client = (struct i2c_client *)file->private_data; | 165 | struct i2c_client *client = file->private_data; |
166 | 166 | ||
167 | if (count > 8192) | 167 | if (count > 8192) |
168 | count = 8192; | 168 | count = 8192; |
169 | 169 | ||
170 | tmp = kmalloc(count,GFP_KERNEL); | 170 | tmp = kmalloc(count, GFP_KERNEL); |
171 | if (tmp==NULL) | 171 | if (tmp == NULL) |
172 | return -ENOMEM; | 172 | return -ENOMEM; |
173 | if (copy_from_user(tmp,buf,count)) { | 173 | if (copy_from_user(tmp, buf, count)) { |
174 | kfree(tmp); | 174 | kfree(tmp); |
175 | return -EFAULT; | 175 | return -EFAULT; |
176 | } | 176 | } |
@@ -178,7 +178,7 @@ static ssize_t i2cdev_write (struct file *file, const char __user *buf, size_t c | |||
178 | pr_debug("i2c-dev: i2c-%d writing %zu bytes.\n", | 178 | pr_debug("i2c-dev: i2c-%d writing %zu bytes.\n", |
179 | iminor(file->f_path.dentry->d_inode), count); | 179 | iminor(file->f_path.dentry->d_inode), count); |
180 | 180 | ||
181 | ret = i2c_master_send(client,tmp,count); | 181 | ret = i2c_master_send(client, tmp, count); |
182 | kfree(tmp); | 182 | kfree(tmp); |
183 | return ret; | 183 | return ret; |
184 | } | 184 | } |
@@ -369,13 +369,13 @@ static noinline int i2cdev_ioctl_smbus(struct i2c_client *client, | |||
369 | 369 | ||
370 | static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 370 | static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
371 | { | 371 | { |
372 | struct i2c_client *client = (struct i2c_client *)file->private_data; | 372 | struct i2c_client *client = file->private_data; |
373 | unsigned long funcs; | 373 | unsigned long funcs; |
374 | 374 | ||
375 | dev_dbg(&client->adapter->dev, "ioctl, cmd=0x%02x, arg=0x%02lx\n", | 375 | dev_dbg(&client->adapter->dev, "ioctl, cmd=0x%02x, arg=0x%02lx\n", |
376 | cmd, arg); | 376 | cmd, arg); |
377 | 377 | ||
378 | switch ( cmd ) { | 378 | switch (cmd) { |
379 | case I2C_SLAVE: | 379 | case I2C_SLAVE: |
380 | case I2C_SLAVE_FORCE: | 380 | case I2C_SLAVE_FORCE: |
381 | /* NOTE: devices set up to work with "new style" drivers | 381 | /* NOTE: devices set up to work with "new style" drivers |
@@ -601,7 +601,7 @@ static void __exit i2c_dev_exit(void) | |||
601 | { | 601 | { |
602 | i2c_del_driver(&i2cdev_driver); | 602 | i2c_del_driver(&i2cdev_driver); |
603 | class_destroy(i2c_dev_class); | 603 | class_destroy(i2c_dev_class); |
604 | unregister_chrdev(I2C_MAJOR,"i2c"); | 604 | unregister_chrdev(I2C_MAJOR, "i2c"); |
605 | } | 605 | } |
606 | 606 | ||
607 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and " | 607 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and " |