From patchwork Thu Mar 7 08:57:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 15268 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 2A33C23E39 for ; Thu, 7 Mar 2013 08:58:07 +0000 (UTC) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by fiordland.canonical.com (Postfix) with ESMTP id 8AE04A18818 for ; Thu, 7 Mar 2013 08:58:06 +0000 (UTC) Received: by mail-vc0-f173.google.com with SMTP id fy27so128067vcb.4 for ; Thu, 07 Mar 2013 00:58:06 -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=YKloQcHW4s8mi7dfKtcGOPDCSDf3AmEVNRzq9QgpikT17TNR9J6AH5B+vFODlra669 TKhU9FjHhPap1Z1pKG0Gb7ucteCUQOCHKhQC+Tb+Pp4icFthG9t1eXG8Ghjhj8je3b9H /RaX5S4r8er/IwpkzvYCboQEuQnUBT2AdtgFppbb/EKJBYZWx0BOIm/r+Sv+5jFYYqFu jK65Ng27I2SqUUjKP3FGZ1QsJoggWNVQ4cRvcF5S7tPviCpi949GVUM2ae5G6vv0jEkM 5I4PQfkj+VmoE4osnpkynsrLYS9Ga4ebzYBzCtdD7y9M5HBh4W+anEzfeEMTG3k9fLhk XdGg== X-Received: by 10.52.177.163 with SMTP id cr3mr11096069vdc.94.1362646686042; Thu, 07 Mar 2013 00:58:06 -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 nf2csp59592veb; Thu, 7 Mar 2013 00:58:05 -0800 (PST) X-Received: by 10.66.120.33 with SMTP id kz1mr1837203pab.66.1362646684316; Thu, 07 Mar 2013 00:58:04 -0800 (PST) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx.google.com with ESMTPS id wg6si1189041pac.343.2013.03.07.00.58.03 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Mar 2013 00:58:04 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.46 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=209.85.220.46; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.46 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-f46.google.com with SMTP id kp14so310207pab.5 for ; Thu, 07 Mar 2013 00:58:03 -0800 (PST) X-Received: by 10.66.119.200 with SMTP id kw8mr1835162pab.52.1362646683631; Thu, 07 Mar 2013 00:58:03 -0800 (PST) Received: from localhost ([118.143.64.134]) by mx.google.com with ESMTPS id 1sm1003646pbg.18.2013.03.07.00.57.59 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 07 Mar 2013 00:58:02 -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, 7 Mar 2013 16:57:40 +0800 Message-Id: <1362646660-22688-1-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <20130306085446.GI28587@arwen.pp.htv.fi> References: <20130306085446.GI28587@arwen.pp.htv.fi> X-Gm-Message-State: ALoCoQk1q1RjCJxJ7y97Q1sUJKToKnUay+fpBF/Hlm6bks7XFUUDTE4FNnWyWhQyL4P9YLW3Xpzn 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;