From patchwork Thu Feb 28 10:38:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 15152 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 4AC3E23E27 for ; Thu, 28 Feb 2013 10:39:39 +0000 (UTC) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by fiordland.canonical.com (Postfix) with ESMTP id 02335A18EA5 for ; Thu, 28 Feb 2013 10:39:38 +0000 (UTC) Received: by mail-ve0-f176.google.com with SMTP id cz10so1620261veb.21 for ; Thu, 28 Feb 2013 02:39:38 -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=4ILE1KMlzsHzTso7iMrp09ytYhdPif9OqvqKZIT7JCc=; b=A/o/fiY2Pye6Gfmj3//UG0874weQMgiPjTwbbfp8w/hgyjZCBuwewbYEAKtEPZ0DWO Me7HSWgEPMpzV+gXJHgMRP5TX5et6ygPZA4P1EkxahRiY1x4KbX6fhirK6/3yrcUHrwv vpqYJcPVdOaAhMmyGGkUsuMwDImzCt3ZOWfx76blyCL1wMbR1JFPA6WRqx5mD/XzyKjD 90GRj/tY0mSxDaKGgjMDkGMFhQFwNMnEuEIbSuL7CGhNYwJx9ur1S9LLCN57X5peWb8U kqwMY5SQkKQhhotbJYwKnEgwZsO2JOWWrcuC0lMMzTSDmIeJif1MPq9rDDsNSHnY/qb5 tbKA== X-Received: by 10.52.18.148 with SMTP id w20mr2062799vdd.8.1362047978499; Thu, 28 Feb 2013 02:39:38 -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.145.101 with SMTP id st5csp218170veb; Thu, 28 Feb 2013 02:39:37 -0800 (PST) X-Received: by 10.180.73.238 with SMTP id o14mr9445755wiv.32.1362047977335; Thu, 28 Feb 2013 02:39:37 -0800 (PST) Received: from mail-wg0-f54.google.com (mail-wg0-f54.google.com [74.125.82.54]) by mx.google.com with ESMTPS id w8si3623738wiz.91.2013.02.28.02.39.36 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Feb 2013 02:39:37 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.54 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=74.125.82.54; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.54 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-wg0-f54.google.com with SMTP id fm10so1349260wgb.9 for ; Thu, 28 Feb 2013 02:39:36 -0800 (PST) X-Received: by 10.180.83.10 with SMTP id m10mr31981779wiy.5.1362047976573; Thu, 28 Feb 2013 02:39:36 -0800 (PST) Received: from localhost ([2a01:2003:1:1e91:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPS id fx5sm14446589wib.11.2013.02.28.02.39.31 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 28 Feb 2013 02:39:35 -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 3/5] usb: musb: ux500: add otg notifier support Date: Thu, 28 Feb 2013 11:38:52 +0100 Message-Id: <1362047934-22337-4-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1362047934-22337-1-git-send-email-fabio.baltieri@linaro.org> References: <1362047934-22337-1-git-send-email-fabio.baltieri@linaro.org> X-Gm-Message-State: ALoCoQnRQ2fF7rJNfrJL9+8hMMpNyxLpW0Mnfoi38lpUoYrGFnBF5vUGqzmMZVpdXcmhrSmYlBcG 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 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c index 5b742ba..b20326bb 100644 --- a/drivers/usb/musb/ux500.c +++ b/drivers/usb/musb/ux500.c @@ -98,6 +98,36 @@ 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"); + 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 +150,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 +172,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;