aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHema HK <hemahk@ti.com>2011-02-17 01:36:04 -0500
committerFelipe Balbi <balbi@ti.com>2011-02-17 14:11:46 -0500
commit6dc2503b81a0171e68766f722a452e97a7da320b (patch)
tree4c784d66bf2d7fd79449f55973d75f83db1a0188
parent207b0e1f1655bd7008b7322cdc3f84fb171c546d (diff)
usb: otg: enable regulator only on cable/device connect
Remove the regulator enable while driver loading and enable it only when the cable/device is connected and disable it when disconnected. Remove the configuration of config_state and config_trans register configuration as these registers are programmed when regulator enable/disable is called. Signed-off-by: Hema HK <hemahk@ti.com> Cc: Tony Lindgren <tony@atomide.com> Cc: Paul Walmsley <paul@pwsan.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/otg/twl6030-usb.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c
index 28f770103640..eca459126db7 100644
--- a/drivers/usb/otg/twl6030-usb.c
+++ b/drivers/usb/otg/twl6030-usb.c
@@ -158,8 +158,6 @@ static int twl6030_phy_init(struct otg_transceiver *x)
158 dev = twl->dev; 158 dev = twl->dev;
159 pdata = dev->platform_data; 159 pdata = dev->platform_data;
160 160
161 regulator_enable(twl->usb3v3);
162
163 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS); 161 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS);
164 162
165 if (hw_state & STS_USB_ID) 163 if (hw_state & STS_USB_ID)
@@ -180,7 +178,6 @@ static void twl6030_phy_shutdown(struct otg_transceiver *x)
180 dev = twl->dev; 178 dev = twl->dev;
181 pdata = dev->platform_data; 179 pdata = dev->platform_data;
182 pdata->phy_power(twl->dev, 0, 0); 180 pdata->phy_power(twl->dev, 0, 0);
183 regulator_disable(twl->usb3v3);
184} 181}
185 182
186static int twl6030_usb_ldo_init(struct twl6030_usb *twl) 183static int twl6030_usb_ldo_init(struct twl6030_usb *twl)
@@ -199,16 +196,6 @@ static int twl6030_usb_ldo_init(struct twl6030_usb *twl)
199 if (IS_ERR(twl->usb3v3)) 196 if (IS_ERR(twl->usb3v3))
200 return -ENODEV; 197 return -ENODEV;
201 198
202 regulator_enable(twl->usb3v3);
203
204 /* Program the VUSB_CFG_TRANS for ACTIVE state. */
205 twl6030_writeb(twl, TWL_MODULE_PM_RECEIVER, 0x3F,
206 VUSB_CFG_TRANS);
207
208 /* Program the VUSB_CFG_STATE register to ON on all groups. */
209 twl6030_writeb(twl, TWL_MODULE_PM_RECEIVER, 0xE1,
210 VUSB_CFG_STATE);
211
212 /* Program the USB_VBUS_CTRL_SET and set VBUS_ACT_COMP bit */ 199 /* Program the USB_VBUS_CTRL_SET and set VBUS_ACT_COMP bit */
213 twl6030_writeb(twl, TWL_MODULE_USB, 0x4, USB_VBUS_CTRL_SET); 200 twl6030_writeb(twl, TWL_MODULE_USB, 0x4, USB_VBUS_CTRL_SET);
214 201
@@ -261,16 +248,23 @@ static irqreturn_t twl6030_usb_irq(int irq, void *_twl)
261 CONTROLLER_STAT1); 248 CONTROLLER_STAT1);
262 if (!(hw_state & STS_USB_ID)) { 249 if (!(hw_state & STS_USB_ID)) {
263 if (vbus_state & VBUS_DET) { 250 if (vbus_state & VBUS_DET) {
251 regulator_enable(twl->usb3v3);
252 twl->asleep = 1;
264 status = USB_EVENT_VBUS; 253 status = USB_EVENT_VBUS;
265 twl->otg.default_a = false; 254 twl->otg.default_a = false;
266 twl->otg.state = OTG_STATE_B_IDLE; 255 twl->otg.state = OTG_STATE_B_IDLE;
256 twl->linkstat = status;
257 blocking_notifier_call_chain(&twl->otg.notifier,
258 status, twl->otg.gadget);
267 } else { 259 } else {
268 status = USB_EVENT_NONE; 260 status = USB_EVENT_NONE;
269 }
270 if (status >= 0) {
271 twl->linkstat = status; 261 twl->linkstat = status;
272 blocking_notifier_call_chain(&twl->otg.notifier, 262 blocking_notifier_call_chain(&twl->otg.notifier,
273 status, twl->otg.gadget); 263 status, twl->otg.gadget);
264 if (twl->asleep) {
265 regulator_disable(twl->usb3v3);
266 twl->asleep = 0;
267 }
274 } 268 }
275 } 269 }
276 sysfs_notify(&twl->dev->kobj, NULL, "vbus"); 270 sysfs_notify(&twl->dev->kobj, NULL, "vbus");
@@ -288,6 +282,8 @@ static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl)
288 282
289 if (hw_state & STS_USB_ID) { 283 if (hw_state & STS_USB_ID) {
290 284
285 regulator_enable(twl->usb3v3);
286 twl->asleep = 1;
291 twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_CLR, 0x1); 287 twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_CLR, 0x1);
292 twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET, 288 twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET,
293 0x10); 289 0x10);
@@ -437,6 +433,7 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev)
437 return status; 433 return status;
438 } 434 }
439 435
436 twl->asleep = 0;
440 pdata->phy_init(dev); 437 pdata->phy_init(dev);
441 twl6030_enable_irq(&twl->otg); 438 twl6030_enable_irq(&twl->otg);
442 dev_info(&pdev->dev, "Initialized TWL6030 USB module\n"); 439 dev_info(&pdev->dev, "Initialized TWL6030 USB module\n");