diff options
-rw-r--r-- | drivers/i2c/chips/isp1301_omap.c | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 4655b794ebe3..8444fc6fbf61 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -49,7 +49,8 @@ MODULE_LICENSE("GPL"); | |||
49 | 49 | ||
50 | struct isp1301 { | 50 | struct isp1301 { |
51 | struct otg_transceiver otg; | 51 | struct otg_transceiver otg; |
52 | struct i2c_client client; | 52 | struct i2c_client *client; |
53 | struct i2c_client c; | ||
53 | void (*i2c_release)(struct device *dev); | 54 | void (*i2c_release)(struct device *dev); |
54 | 55 | ||
55 | int irq; | 56 | int irq; |
@@ -153,25 +154,25 @@ static struct i2c_driver isp1301_driver; | |||
153 | static inline u8 | 154 | static inline u8 |
154 | isp1301_get_u8(struct isp1301 *isp, u8 reg) | 155 | isp1301_get_u8(struct isp1301 *isp, u8 reg) |
155 | { | 156 | { |
156 | return i2c_smbus_read_byte_data(&isp->client, reg + 0); | 157 | return i2c_smbus_read_byte_data(isp->client, reg + 0); |
157 | } | 158 | } |
158 | 159 | ||
159 | static inline int | 160 | static inline int |
160 | isp1301_get_u16(struct isp1301 *isp, u8 reg) | 161 | isp1301_get_u16(struct isp1301 *isp, u8 reg) |
161 | { | 162 | { |
162 | return i2c_smbus_read_word_data(&isp->client, reg); | 163 | return i2c_smbus_read_word_data(isp->client, reg); |
163 | } | 164 | } |
164 | 165 | ||
165 | static inline int | 166 | static inline int |
166 | isp1301_set_bits(struct isp1301 *isp, u8 reg, u8 bits) | 167 | isp1301_set_bits(struct isp1301 *isp, u8 reg, u8 bits) |
167 | { | 168 | { |
168 | return i2c_smbus_write_byte_data(&isp->client, reg + 0, bits); | 169 | return i2c_smbus_write_byte_data(isp->client, reg + 0, bits); |
169 | } | 170 | } |
170 | 171 | ||
171 | static inline int | 172 | static inline int |
172 | isp1301_clear_bits(struct isp1301 *isp, u8 reg, u8 bits) | 173 | isp1301_clear_bits(struct isp1301 *isp, u8 reg, u8 bits) |
173 | { | 174 | { |
174 | return i2c_smbus_write_byte_data(&isp->client, reg + 1, bits); | 175 | return i2c_smbus_write_byte_data(isp->client, reg + 1, bits); |
175 | } | 176 | } |
176 | 177 | ||
177 | /*-------------------------------------------------------------------------*/ | 178 | /*-------------------------------------------------------------------------*/ |
@@ -349,10 +350,10 @@ isp1301_defer_work(struct isp1301 *isp, int work) | |||
349 | int status; | 350 | int status; |
350 | 351 | ||
351 | if (isp && !test_and_set_bit(work, &isp->todo)) { | 352 | if (isp && !test_and_set_bit(work, &isp->todo)) { |
352 | (void) get_device(&isp->client.dev); | 353 | (void) get_device(&isp->client->dev); |
353 | status = schedule_work(&isp->work); | 354 | status = schedule_work(&isp->work); |
354 | if (!status && !isp->working) | 355 | if (!status && !isp->working) |
355 | dev_vdbg(&isp->client.dev, | 356 | dev_vdbg(&isp->client->dev, |
356 | "work item %d may be lost\n", work); | 357 | "work item %d may be lost\n", work); |
357 | } | 358 | } |
358 | } | 359 | } |
@@ -1135,7 +1136,7 @@ isp1301_work(struct work_struct *work) | |||
1135 | /* transfer state from otg engine to isp1301 */ | 1136 | /* transfer state from otg engine to isp1301 */ |
1136 | if (test_and_clear_bit(WORK_UPDATE_ISP, &isp->todo)) { | 1137 | if (test_and_clear_bit(WORK_UPDATE_ISP, &isp->todo)) { |
1137 | otg_update_isp(isp); | 1138 | otg_update_isp(isp); |
1138 | put_device(&isp->client.dev); | 1139 | put_device(&isp->client->dev); |
1139 | } | 1140 | } |
1140 | #endif | 1141 | #endif |
1141 | /* transfer state from isp1301 to otg engine */ | 1142 | /* transfer state from isp1301 to otg engine */ |
@@ -1143,7 +1144,7 @@ isp1301_work(struct work_struct *work) | |||
1143 | u8 stat = isp1301_clear_latch(isp); | 1144 | u8 stat = isp1301_clear_latch(isp); |
1144 | 1145 | ||
1145 | isp_update_otg(isp, stat); | 1146 | isp_update_otg(isp, stat); |
1146 | put_device(&isp->client.dev); | 1147 | put_device(&isp->client->dev); |
1147 | } | 1148 | } |
1148 | 1149 | ||
1149 | if (test_and_clear_bit(WORK_HOST_RESUME, &isp->todo)) { | 1150 | if (test_and_clear_bit(WORK_HOST_RESUME, &isp->todo)) { |
@@ -1178,7 +1179,7 @@ isp1301_work(struct work_struct *work) | |||
1178 | } | 1179 | } |
1179 | host_resume(isp); | 1180 | host_resume(isp); |
1180 | // mdelay(10); | 1181 | // mdelay(10); |
1181 | put_device(&isp->client.dev); | 1182 | put_device(&isp->client->dev); |
1182 | } | 1183 | } |
1183 | 1184 | ||
1184 | if (test_and_clear_bit(WORK_TIMER, &isp->todo)) { | 1185 | if (test_and_clear_bit(WORK_TIMER, &isp->todo)) { |
@@ -1187,15 +1188,15 @@ isp1301_work(struct work_struct *work) | |||
1187 | if (!stop) | 1188 | if (!stop) |
1188 | mod_timer(&isp->timer, jiffies + TIMER_JIFFIES); | 1189 | mod_timer(&isp->timer, jiffies + TIMER_JIFFIES); |
1189 | #endif | 1190 | #endif |
1190 | put_device(&isp->client.dev); | 1191 | put_device(&isp->client->dev); |
1191 | } | 1192 | } |
1192 | 1193 | ||
1193 | if (isp->todo) | 1194 | if (isp->todo) |
1194 | dev_vdbg(&isp->client.dev, | 1195 | dev_vdbg(&isp->client->dev, |
1195 | "work done, todo = 0x%lx\n", | 1196 | "work done, todo = 0x%lx\n", |
1196 | isp->todo); | 1197 | isp->todo); |
1197 | if (stop) { | 1198 | if (stop) { |
1198 | dev_dbg(&isp->client.dev, "stop\n"); | 1199 | dev_dbg(&isp->client->dev, "stop\n"); |
1199 | break; | 1200 | break; |
1200 | } | 1201 | } |
1201 | } while (isp->todo); | 1202 | } while (isp->todo); |
@@ -1219,7 +1220,7 @@ static void isp1301_release(struct device *dev) | |||
1219 | { | 1220 | { |
1220 | struct isp1301 *isp; | 1221 | struct isp1301 *isp; |
1221 | 1222 | ||
1222 | isp = container_of(dev, struct isp1301, client.dev); | 1223 | isp = dev_get_drvdata(dev); |
1223 | 1224 | ||
1224 | /* ugly -- i2c hijacks our memory hook to wait_for_completion() */ | 1225 | /* ugly -- i2c hijacks our memory hook to wait_for_completion() */ |
1225 | if (isp->i2c_release) | 1226 | if (isp->i2c_release) |
@@ -1233,7 +1234,7 @@ static int isp1301_detach_client(struct i2c_client *i2c) | |||
1233 | { | 1234 | { |
1234 | struct isp1301 *isp; | 1235 | struct isp1301 *isp; |
1235 | 1236 | ||
1236 | isp = container_of(i2c, struct isp1301, client); | 1237 | isp = i2c_get_clientdata(i2c); |
1237 | 1238 | ||
1238 | isp1301_clear_bits(isp, ISP1301_INTERRUPT_FALLING, ~0); | 1239 | isp1301_clear_bits(isp, ISP1301_INTERRUPT_FALLING, ~0); |
1239 | isp1301_clear_bits(isp, ISP1301_INTERRUPT_RISING, ~0); | 1240 | isp1301_clear_bits(isp, ISP1301_INTERRUPT_RISING, ~0); |
@@ -1285,7 +1286,7 @@ static int isp1301_otg_enable(struct isp1301 *isp) | |||
1285 | isp1301_set_bits(isp, ISP1301_INTERRUPT_FALLING, | 1286 | isp1301_set_bits(isp, ISP1301_INTERRUPT_FALLING, |
1286 | INTR_VBUS_VLD | INTR_SESS_VLD | INTR_ID_GND); | 1287 | INTR_VBUS_VLD | INTR_SESS_VLD | INTR_ID_GND); |
1287 | 1288 | ||
1288 | dev_info(&isp->client.dev, "ready for dual-role USB ...\n"); | 1289 | dev_info(&isp->client->dev, "ready for dual-role USB ...\n"); |
1289 | 1290 | ||
1290 | return 0; | 1291 | return 0; |
1291 | } | 1292 | } |
@@ -1310,7 +1311,7 @@ isp1301_set_host(struct otg_transceiver *otg, struct usb_bus *host) | |||
1310 | 1311 | ||
1311 | #ifdef CONFIG_USB_OTG | 1312 | #ifdef CONFIG_USB_OTG |
1312 | isp->otg.host = host; | 1313 | isp->otg.host = host; |
1313 | dev_dbg(&isp->client.dev, "registered host\n"); | 1314 | dev_dbg(&isp->client->dev, "registered host\n"); |
1314 | host_suspend(isp); | 1315 | host_suspend(isp); |
1315 | if (isp->otg.gadget) | 1316 | if (isp->otg.gadget) |
1316 | return isp1301_otg_enable(isp); | 1317 | return isp1301_otg_enable(isp); |
@@ -1325,7 +1326,7 @@ isp1301_set_host(struct otg_transceiver *otg, struct usb_bus *host) | |||
1325 | if (machine_is_omap_h2()) | 1326 | if (machine_is_omap_h2()) |
1326 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0); | 1327 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0); |
1327 | 1328 | ||
1328 | dev_info(&isp->client.dev, "A-Host sessions ok\n"); | 1329 | dev_info(&isp->client->dev, "A-Host sessions ok\n"); |
1329 | isp1301_set_bits(isp, ISP1301_INTERRUPT_RISING, | 1330 | isp1301_set_bits(isp, ISP1301_INTERRUPT_RISING, |
1330 | INTR_ID_GND); | 1331 | INTR_ID_GND); |
1331 | isp1301_set_bits(isp, ISP1301_INTERRUPT_FALLING, | 1332 | isp1301_set_bits(isp, ISP1301_INTERRUPT_FALLING, |
@@ -1343,7 +1344,7 @@ isp1301_set_host(struct otg_transceiver *otg, struct usb_bus *host) | |||
1343 | return 0; | 1344 | return 0; |
1344 | 1345 | ||
1345 | #else | 1346 | #else |
1346 | dev_dbg(&isp->client.dev, "host sessions not allowed\n"); | 1347 | dev_dbg(&isp->client->dev, "host sessions not allowed\n"); |
1347 | return -EINVAL; | 1348 | return -EINVAL; |
1348 | #endif | 1349 | #endif |
1349 | 1350 | ||
@@ -1370,7 +1371,7 @@ isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) | |||
1370 | 1371 | ||
1371 | #ifdef CONFIG_USB_OTG | 1372 | #ifdef CONFIG_USB_OTG |
1372 | isp->otg.gadget = gadget; | 1373 | isp->otg.gadget = gadget; |
1373 | dev_dbg(&isp->client.dev, "registered gadget\n"); | 1374 | dev_dbg(&isp->client->dev, "registered gadget\n"); |
1374 | /* gadget driver may be suspended until vbus_connect () */ | 1375 | /* gadget driver may be suspended until vbus_connect () */ |
1375 | if (isp->otg.host) | 1376 | if (isp->otg.host) |
1376 | return isp1301_otg_enable(isp); | 1377 | return isp1301_otg_enable(isp); |
@@ -1395,7 +1396,7 @@ isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) | |||
1395 | INTR_SESS_VLD); | 1396 | INTR_SESS_VLD); |
1396 | isp1301_set_bits(isp, ISP1301_INTERRUPT_FALLING, | 1397 | isp1301_set_bits(isp, ISP1301_INTERRUPT_FALLING, |
1397 | INTR_VBUS_VLD); | 1398 | INTR_VBUS_VLD); |
1398 | dev_info(&isp->client.dev, "B-Peripheral sessions ok\n"); | 1399 | dev_info(&isp->client->dev, "B-Peripheral sessions ok\n"); |
1399 | dump_regs(isp, __func__); | 1400 | dump_regs(isp, __func__); |
1400 | 1401 | ||
1401 | /* If this has a Mini-AB connector, this mode is highly | 1402 | /* If this has a Mini-AB connector, this mode is highly |
@@ -1408,7 +1409,7 @@ isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) | |||
1408 | return 0; | 1409 | return 0; |
1409 | 1410 | ||
1410 | #else | 1411 | #else |
1411 | dev_dbg(&isp->client.dev, "peripheral sessions not allowed\n"); | 1412 | dev_dbg(&isp->client->dev, "peripheral sessions not allowed\n"); |
1412 | return -EINVAL; | 1413 | return -EINVAL; |
1413 | #endif | 1414 | #endif |
1414 | } | 1415 | } |
@@ -1528,12 +1529,12 @@ static int isp1301_probe(struct i2c_adapter *bus, int address, int kind) | |||
1528 | isp->timer.data = (unsigned long) isp; | 1529 | isp->timer.data = (unsigned long) isp; |
1529 | 1530 | ||
1530 | isp->irq = -1; | 1531 | isp->irq = -1; |
1531 | isp->client.addr = address; | 1532 | isp->c.addr = address; |
1532 | i2c_set_clientdata(&isp->client, isp); | 1533 | i2c_set_clientdata(&isp->c, isp); |
1533 | isp->client.adapter = bus; | 1534 | isp->c.adapter = bus; |
1534 | isp->client.driver = &isp1301_driver; | 1535 | isp->c.driver = &isp1301_driver; |
1535 | strlcpy(isp->client.name, DRIVER_NAME, I2C_NAME_SIZE); | 1536 | strlcpy(isp->c.name, DRIVER_NAME, I2C_NAME_SIZE); |
1536 | i2c = &isp->client; | 1537 | isp->client = i2c = &isp->c; |
1537 | 1538 | ||
1538 | /* if this is a true probe, verify the chip ... */ | 1539 | /* if this is a true probe, verify the chip ... */ |
1539 | if (kind < 0) { | 1540 | if (kind < 0) { |
@@ -1618,7 +1619,7 @@ fail2: | |||
1618 | goto fail1; | 1619 | goto fail1; |
1619 | } | 1620 | } |
1620 | 1621 | ||
1621 | isp->otg.dev = &isp->client.dev; | 1622 | isp->otg.dev = &isp->client->dev; |
1622 | isp->otg.label = DRIVER_NAME; | 1623 | isp->otg.label = DRIVER_NAME; |
1623 | 1624 | ||
1624 | isp->otg.set_host = isp1301_set_host, | 1625 | isp->otg.set_host = isp1301_set_host, |