aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/otg/twl6030-usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/otg/twl6030-usb.c')
-rw-r--r--drivers/usb/otg/twl6030-usb.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c
index dbee00aea755..6c758836cfb1 100644
--- a/drivers/usb/otg/twl6030-usb.c
+++ b/drivers/usb/otg/twl6030-usb.c
@@ -26,10 +26,10 @@
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/usb/otg.h> 28#include <linux/usb/otg.h>
29#include <linux/usb/musb-omap.h>
29#include <linux/i2c/twl.h> 30#include <linux/i2c/twl.h>
30#include <linux/regulator/consumer.h> 31#include <linux/regulator/consumer.h>
31#include <linux/err.h> 32#include <linux/err.h>
32#include <linux/notifier.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35 35
@@ -100,7 +100,7 @@ struct twl6030_usb {
100 100
101 int irq1; 101 int irq1;
102 int irq2; 102 int irq2;
103 u8 linkstat; 103 enum omap_musb_vbus_id_status linkstat;
104 u8 asleep; 104 u8 asleep;
105 bool irq_enabled; 105 bool irq_enabled;
106 bool vbus_enable; 106 bool vbus_enable;
@@ -147,7 +147,7 @@ static int twl6030_phy_init(struct usb_phy *x)
147 dev = twl->dev; 147 dev = twl->dev;
148 pdata = dev->platform_data; 148 pdata = dev->platform_data;
149 149
150 if (twl->linkstat == USB_EVENT_ID) 150 if (twl->linkstat == OMAP_MUSB_ID_GROUND)
151 pdata->phy_power(twl->dev, 1, 1); 151 pdata->phy_power(twl->dev, 1, 1);
152 else 152 else
153 pdata->phy_power(twl->dev, 0, 1); 153 pdata->phy_power(twl->dev, 0, 1);
@@ -235,13 +235,13 @@ static ssize_t twl6030_usb_vbus_show(struct device *dev,
235 spin_lock_irqsave(&twl->lock, flags); 235 spin_lock_irqsave(&twl->lock, flags);
236 236
237 switch (twl->linkstat) { 237 switch (twl->linkstat) {
238 case USB_EVENT_VBUS: 238 case OMAP_MUSB_VBUS_VALID:
239 ret = snprintf(buf, PAGE_SIZE, "vbus\n"); 239 ret = snprintf(buf, PAGE_SIZE, "vbus\n");
240 break; 240 break;
241 case USB_EVENT_ID: 241 case OMAP_MUSB_ID_GROUND:
242 ret = snprintf(buf, PAGE_SIZE, "id\n"); 242 ret = snprintf(buf, PAGE_SIZE, "id\n");
243 break; 243 break;
244 case USB_EVENT_NONE: 244 case OMAP_MUSB_VBUS_OFF:
245 ret = snprintf(buf, PAGE_SIZE, "none\n"); 245 ret = snprintf(buf, PAGE_SIZE, "none\n");
246 break; 246 break;
247 default: 247 default:
@@ -257,7 +257,7 @@ static irqreturn_t twl6030_usb_irq(int irq, void *_twl)
257{ 257{
258 struct twl6030_usb *twl = _twl; 258 struct twl6030_usb *twl = _twl;
259 struct usb_otg *otg = twl->phy.otg; 259 struct usb_otg *otg = twl->phy.otg;
260 int status; 260 enum omap_musb_vbus_id_status status = OMAP_MUSB_UNKNOWN;
261 u8 vbus_state, hw_state; 261 u8 vbus_state, hw_state;
262 262
263 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS); 263 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS);
@@ -268,22 +268,20 @@ static irqreturn_t twl6030_usb_irq(int irq, void *_twl)
268 if (vbus_state & VBUS_DET) { 268 if (vbus_state & VBUS_DET) {
269 regulator_enable(twl->usb3v3); 269 regulator_enable(twl->usb3v3);
270 twl->asleep = 1; 270 twl->asleep = 1;
271 status = USB_EVENT_VBUS; 271 status = OMAP_MUSB_VBUS_VALID;
272 otg->default_a = false; 272 otg->default_a = false;
273 twl->phy.state = OTG_STATE_B_IDLE; 273 twl->phy.state = OTG_STATE_B_IDLE;
274 twl->linkstat = status; 274 twl->linkstat = status;
275 twl->phy.last_event = status; 275 omap_musb_mailbox(status);
276 atomic_notifier_call_chain(&twl->phy.notifier,
277 status, otg->gadget);
278 } else { 276 } else {
279 status = USB_EVENT_NONE; 277 if (twl->linkstat != OMAP_MUSB_UNKNOWN) {
280 twl->linkstat = status; 278 status = OMAP_MUSB_VBUS_OFF;
281 twl->phy.last_event = status; 279 twl->linkstat = status;
282 atomic_notifier_call_chain(&twl->phy.notifier, 280 omap_musb_mailbox(status);
283 status, otg->gadget); 281 if (twl->asleep) {
284 if (twl->asleep) { 282 regulator_disable(twl->usb3v3);
285 regulator_disable(twl->usb3v3); 283 twl->asleep = 0;
286 twl->asleep = 0; 284 }
287 } 285 }
288 } 286 }
289 } 287 }
@@ -296,7 +294,7 @@ static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl)
296{ 294{
297 struct twl6030_usb *twl = _twl; 295 struct twl6030_usb *twl = _twl;
298 struct usb_otg *otg = twl->phy.otg; 296 struct usb_otg *otg = twl->phy.otg;
299 int status = USB_EVENT_NONE; 297 enum omap_musb_vbus_id_status status = OMAP_MUSB_UNKNOWN;
300 u8 hw_state; 298 u8 hw_state;
301 299
302 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS); 300 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS);
@@ -308,13 +306,11 @@ static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl)
308 twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_CLR, 0x1); 306 twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_CLR, 0x1);
309 twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET, 307 twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET,
310 0x10); 308 0x10);
311 status = USB_EVENT_ID; 309 status = OMAP_MUSB_ID_GROUND;
312 otg->default_a = true; 310 otg->default_a = true;
313 twl->phy.state = OTG_STATE_A_IDLE; 311 twl->phy.state = OTG_STATE_A_IDLE;
314 twl->linkstat = status; 312 twl->linkstat = status;
315 twl->phy.last_event = status; 313 omap_musb_mailbox(status);
316 atomic_notifier_call_chain(&twl->phy.notifier, status,
317 otg->gadget);
318 } else { 314 } else {
319 twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_CLR, 315 twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_CLR,
320 0x10); 316 0x10);
@@ -419,6 +415,7 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev)
419 twl->irq1 = platform_get_irq(pdev, 0); 415 twl->irq1 = platform_get_irq(pdev, 0);
420 twl->irq2 = platform_get_irq(pdev, 1); 416 twl->irq2 = platform_get_irq(pdev, 1);
421 twl->features = pdata->features; 417 twl->features = pdata->features;
418 twl->linkstat = OMAP_MUSB_UNKNOWN;
422 419
423 twl->phy.dev = twl->dev; 420 twl->phy.dev = twl->dev;
424 twl->phy.label = "twl6030"; 421 twl->phy.label = "twl6030";
@@ -449,8 +446,6 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev)
449 if (device_create_file(&pdev->dev, &dev_attr_vbus)) 446 if (device_create_file(&pdev->dev, &dev_attr_vbus))
450 dev_warn(&pdev->dev, "could not create sysfs file\n"); 447 dev_warn(&pdev->dev, "could not create sysfs file\n");
451 448
452 ATOMIC_INIT_NOTIFIER_HEAD(&twl->phy.notifier);
453
454 INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work); 449 INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work);
455 450
456 twl->irq_enabled = true; 451 twl->irq_enabled = true;