aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy
diff options
context:
space:
mode:
authorGrazvydas Ignotas <notasas@gmail.com>2013-03-24 11:36:53 -0400
committerFelipe Balbi <balbi@ti.com>2013-04-02 04:42:41 -0400
commitf65f4f40fb23b64a59adbe8629e8e7e6fea279cf (patch)
tree647535e5bb45b0c0e753e8baad0ff4c328ef0787 /drivers/usb/phy
parent6b0cfc656f8a649fbfbe11e76e0aa301ee26879e (diff)
usb: phy: twl4030-usb: check if vbus is driven by twl itself
At least on pandora, STS_VBUS gets set even when VBUS is driven by twl itself. Reporting VBUS in this case confuses OMAP musb glue and charger driver, so check if OTG VBUS charge pump is on before reporting VBUS event to avoid this problem. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/phy')
-rw-r--r--drivers/usb/phy/phy-twl4030-usb.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/usb/phy/phy-twl4030-usb.c
index 61fe7e29c9c3..3f9858fbebc2 100644
--- a/drivers/usb/phy/phy-twl4030-usb.c
+++ b/drivers/usb/phy/phy-twl4030-usb.c
@@ -248,6 +248,25 @@ twl4030_usb_clear_bits(struct twl4030_usb *twl, u8 reg, u8 bits)
248 248
249/*-------------------------------------------------------------------------*/ 249/*-------------------------------------------------------------------------*/
250 250
251static bool twl4030_is_driving_vbus(struct twl4030_usb *twl)
252{
253 int ret;
254
255 ret = twl4030_usb_read(twl, PHY_CLK_CTRL_STS);
256 if (ret < 0 || !(ret & PHY_DPLL_CLK))
257 /*
258 * if clocks are off, registers are not updated,
259 * but we can assume we don't drive VBUS in this case
260 */
261 return false;
262
263 ret = twl4030_usb_read(twl, ULPI_OTG_CTRL);
264 if (ret < 0)
265 return false;
266
267 return (ret & (ULPI_OTG_DRVVBUS | ULPI_OTG_CHRGVBUS)) ? true : false;
268}
269
251static enum omap_musb_vbus_id_status 270static enum omap_musb_vbus_id_status
252 twl4030_usb_linkstat(struct twl4030_usb *twl) 271 twl4030_usb_linkstat(struct twl4030_usb *twl)
253{ 272{
@@ -270,13 +289,19 @@ static enum omap_musb_vbus_id_status
270 if (status < 0) 289 if (status < 0)
271 dev_err(twl->dev, "USB link status err %d\n", status); 290 dev_err(twl->dev, "USB link status err %d\n", status);
272 else if (status & (BIT(7) | BIT(2))) { 291 else if (status & (BIT(7) | BIT(2))) {
273 if (status & (BIT(7))) 292 if (status & BIT(7)) {
274 twl->vbus_supplied = true; 293 if (twl4030_is_driving_vbus(twl))
294 status &= ~BIT(7);
295 else
296 twl->vbus_supplied = true;
297 }
275 298
276 if (status & BIT(2)) 299 if (status & BIT(2))
277 linkstat = OMAP_MUSB_ID_GROUND; 300 linkstat = OMAP_MUSB_ID_GROUND;
278 else 301 else if (status & BIT(7))
279 linkstat = OMAP_MUSB_VBUS_VALID; 302 linkstat = OMAP_MUSB_VBUS_VALID;
303 else
304 linkstat = OMAP_MUSB_VBUS_OFF;
280 } else { 305 } else {
281 if (twl->linkstat != OMAP_MUSB_UNKNOWN) 306 if (twl->linkstat != OMAP_MUSB_UNKNOWN)
282 linkstat = OMAP_MUSB_VBUS_OFF; 307 linkstat = OMAP_MUSB_VBUS_OFF;