Skip to content

Commit

Permalink
usb: musb: ux500: add otg notifier support
Browse files Browse the repository at this point in the history
Add transceiver notifier event handling to the ux500 driver to set vbus
on specific transceiver events.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>

[ balbi@ti.com: fix build error due to missing
	otg_state_string() ]

Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Fabio Baltieri authored and Felipe Balbi committed Mar 18, 2013
1 parent 996a9d2 commit 0135522
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions drivers/usb/musb/ux500.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,37 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
musb_readb(musb->mregs, MUSB_DEVCTL));
}

static int musb_otg_notifications(struct notifier_block *nb,
unsigned long event, void *unused)
{
struct musb *musb = container_of(nb, struct musb, nb);

dev_dbg(musb->controller, "musb_otg_notifications %ld %s\n",
event, usb_otg_state_string(musb->xceiv->state));

switch (event) {
case USB_EVENT_ID:
dev_dbg(musb->controller, "ID GND\n");
ux500_musb_set_vbus(musb, 1);
break;
case USB_EVENT_VBUS:
dev_dbg(musb->controller, "VBUS Connect\n");
ux500_musb_set_vbus(musb, 0);
break;
case USB_EVENT_NONE:
dev_dbg(musb->controller, "VBUS Disconnect\n");
if (is_host_active(musb))
ux500_musb_set_vbus(musb, 0);
else
musb->xceiv->state = OTG_STATE_B_IDLE;
break;
default:
dev_dbg(musb->controller, "ID float\n");
return NOTIFY_DONE;
}
return NOTIFY_OK;
}

static irqreturn_t ux500_musb_interrupt(int irq, void *__hci)
{
unsigned long flags;
Expand All @@ -120,19 +151,30 @@ static irqreturn_t ux500_musb_interrupt(int irq, void *__hci)

static int ux500_musb_init(struct musb *musb)
{
int status;

musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (IS_ERR_OR_NULL(musb->xceiv)) {
pr_err("HS USB OTG: no transceiver configured\n");
return -EPROBE_DEFER;
}

musb->nb.notifier_call = musb_otg_notifications;
status = usb_register_notifier(musb->xceiv, &musb->nb);
if (status < 0) {
dev_dbg(musb->controller, "notification register failed\n");
return status;
}

musb->isr = ux500_musb_interrupt;

return 0;
}

static int ux500_musb_exit(struct musb *musb)
{
usb_unregister_notifier(musb->xceiv, &musb->nb);

usb_put_phy(musb->xceiv);

return 0;
Expand Down

0 comments on commit 0135522

Please sign in to comment.