From patchwork Fri Mar 8 02:27:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 15272 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0E8A923E2E for ; Fri, 8 Mar 2013 02:27:36 +0000 (UTC) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by fiordland.canonical.com (Postfix) with ESMTP id D2FE7A19F6E for ; Fri, 8 Mar 2013 02:27:35 +0000 (UTC) Received: by mail-vc0-f181.google.com with SMTP id f13so648329vcb.40 for ; Thu, 07 Mar 2013 18:27:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=gQQvpLSqD8guPfdZg/Dl8LddCQTp8/6LGOUn8+P3+n8=; b=STohwhS/6AZ8lkKwxhywp4I1lJtgtJfhn8ej6uF0/IqWEpqw1/qs6GZAzpvakfthAp i0hfo7WLX1JzP9iiB3ktD8R5h4qCxjUZBt4OSITnQ2eGxx9a1UkPn392NW/YlkvDVdoX vPKiGKYJLMrCV6OWoxk8mF9/9ikWmKJRJ4ZaoR9z1NQ5BI/OgFPl9rPEsUzMBmUPXZxU FsQ0Icn16Cg0NwDuKWeCYkZhhah/EB5FpuLr0tsHQiUX1Dk569Sq/571kp47zqrcFukJ dCnTjolTJ/P0e5AzFiM6dK04lQ8ECN66Zs37SbUvKYdGLfZ6ivYqIIAEoHgSBsFXEJV/ pIwA== X-Received: by 10.52.29.18 with SMTP id f18mr214294vdh.57.1362709655324; Thu, 07 Mar 2013 18:27:35 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp98707veb; Thu, 7 Mar 2013 18:27:34 -0800 (PST) X-Received: by 10.68.190.99 with SMTP id gp3mr808127pbc.117.1362709653570; Thu, 07 Mar 2013 18:27:33 -0800 (PST) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by mx.google.com with ESMTPS id si3si3852697pbc.131.2013.03.07.18.27.33 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Mar 2013 18:27:33 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.48 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=209.85.220.48; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.48 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) smtp.mail=fabio.baltieri@linaro.org Received: by mail-pa0-f48.google.com with SMTP id hz10so922252pad.7 for ; Thu, 07 Mar 2013 18:27:33 -0800 (PST) X-Received: by 10.66.186.40 with SMTP id fh8mr1685979pac.18.1362709652963; Thu, 07 Mar 2013 18:27:32 -0800 (PST) Received: from localhost ([118.143.64.134]) by mx.google.com with ESMTPS id ri1sm3697719pbc.16.2013.03.07.18.27.29 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 07 Mar 2013 18:27:32 -0800 (PST) From: Fabio Baltieri To: Felipe Balbi Cc: Linus Walleij , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Fabio Baltieri Subject: [PATCH v2 3/5] usb: musb: ux500: add otg notifier support Date: Fri, 8 Mar 2013 10:27:07 +0800 Message-Id: <1362709629-27238-4-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1362709629-27238-1-git-send-email-fabio.baltieri@linaro.org> References: <1362709629-27238-1-git-send-email-fabio.baltieri@linaro.org> X-Gm-Message-State: ALoCoQk8RhSqwmslRSQFYnsgpnsy6C5FQ2kZ+o82q77IiUq2GQ2vfbEIebl772I9qySraRAQ6Km3 Add transceiver notifier event handling to the ux500 driver to set vbus on specific transceiver events. Acked-by: Linus Walleij Signed-off-by: Fabio Baltieri --- drivers/usb/musb/ux500.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c index 5b742ba..55f24c6 100644 --- a/drivers/usb/musb/ux500.c +++ b/drivers/usb/musb/ux500.c @@ -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, 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; @@ -120,12 +151,21 @@ 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; @@ -133,6 +173,8 @@ static int ux500_musb_init(struct musb *musb) static int ux500_musb_exit(struct musb *musb) { + usb_unregister_notifier(musb->xceiv, &musb->nb); + usb_put_phy(musb->xceiv); return 0;