From patchwork Mon Nov 25 21:24:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 3234471 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C0E7B9F3B8 for ; Mon, 25 Nov 2013 21:25:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E66B4202D1 for ; Mon, 25 Nov 2013 21:25:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE451202A1 for ; Mon, 25 Nov 2013 21:25:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752823Ab3KYVZE (ORCPT ); Mon, 25 Nov 2013 16:25:04 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:56984 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751612Ab3KYVZC (ORCPT ); Mon, 25 Nov 2013 16:25:02 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id rAPLOi5I003138; Mon, 25 Nov 2013 15:24:44 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id rAPLOiGD007163; Mon, 25 Nov 2013 15:24:44 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Mon, 25 Nov 2013 15:24:43 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id rAPLOgwQ005415; Mon, 25 Nov 2013 15:24:43 -0600 Date: Mon, 25 Nov 2013 15:24:15 -0600 From: Felipe Balbi To: Mark Jackson CC: , lkml , Felipe Balbi , , Greg KH , , , "linux-omap@vger.kernel.org" Subject: Re: [PATCH] Allow MUSB DSPS to use "force host" mode Message-ID: <20131125212415.GS18046@saruman.home> Reply-To: References: <528F7E8F.5050807@newflow.co.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <528F7E8F.5050807@newflow.co.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, On Fri, Nov 22, 2013 at 03:55:59PM +0000, Mark Jackson wrote: > The IDDIG input pin is normally used to determine the USB mode > (i.e. HOST or DEVICE). > > On some systems (e.g. AM335x) leaving this pin floating allows > the USB mode to be set via software. > > This patch adds support for this via the device tree. > > Signed-off-by: Mark Jackson > --- > .../devicetree/bindings/usb/am33xx-usb.txt | 2 ++ > drivers/usb/musb/musb_dsps.c | 14 ++++++++++++++ > include/linux/usb/musb.h | 1 + > 3 files changed, 17 insertions(+) > > diff --git a/Documentation/devicetree/bindings/usb/am33xx-usb.txt b/Documentation/devicetree/bindings/usb/am33xx-usb.txt > index 20c2ff2..560b7ff 100644 > --- a/Documentation/devicetree/bindings/usb/am33xx-usb.txt > +++ b/Documentation/devicetree/bindings/usb/am33xx-usb.txt > @@ -47,6 +47,8 @@ USB > - dmas: specifies the dma channels > - dma-names: specifies the names of the channels. Use "rxN" for receive > and "txN" for transmit endpoints. N specifies the endpoint number. > +- ti,force-host: specifies that the IDDIG input be ignored and the device be > + put into host mode regardless. > > The controller should have an "usb" alias numbered properly in the alias > node. > diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c > index 1901f6f..6439809 100644 > --- a/drivers/usb/musb/musb_dsps.c > +++ b/drivers/usb/musb/musb_dsps.c > @@ -105,6 +105,7 @@ struct dsps_musb_wrapper { > unsigned otg_disable:5; > > /* bit positions for mode */ > + unsigned iddig_mux:5; > unsigned iddig:5; > /* miscellaneous stuff */ > u8 poll_seconds; > @@ -387,6 +388,15 @@ static int dsps_musb_init(struct musb *musb) > > musb->isr = dsps_interrupt; > > + /* Force host mode, rather than relying on IDDIG input */ > + if (musb->config->force_host) { > + val = dsps_readl(reg_base, wrp->mode); > + /* clear IDDIG bit, set IDDIG_MUX bit */ > + val &= ~(1 << wrp->iddig); > + val |= (1 << wrp->iddig_mux); > + dsps_writel(musb->ctrl_base, wrp->mode, val); > + } > + > /* reset the otgdisable bit, needed for host mode to work */ > val = dsps_readl(reg_base, wrp->phy_utmi); > val &= ~(1 << wrp->otg_disable); > @@ -512,6 +522,9 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, > pdata.power = get_int_prop(dn, "mentor,power") / 2; > config->multipoint = of_property_read_bool(dn, "mentor,multipoint"); > > + if (of_property_read_bool(dn, "ti,force-host")) > + config->force_host = true; > + > ret = platform_device_add_data(musb, &pdata, sizeof(pdata)); > if (ret) { > dev_err(dev, "failed to add platform_data\n"); > @@ -607,6 +620,7 @@ static const struct dsps_musb_wrapper am33xx_driver_data = { > .mode = 0xe8, > .reset = 0, > .otg_disable = 21, > + .iddig_mux = 7, I recently sent a patch to make this work, I'm attaching it here in case it didn't reach mailing list. From c9dfe3d2b4c3f00951839eb17835daa0c5c19d71 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Tue, 29 Oct 2013 12:17:17 -0500 Subject: [PATCH 2/2] usb: musb: core: call musb_platform_set_mode() during probe This will tell glue layer which mode we want port to be in. Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 0a43329..377ef9b 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1941,17 +1941,26 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) switch (musb->port_mode) { case MUSB_PORT_MODE_HOST: status = musb_host_setup(musb, plat->power); + if (status < 0) + goto fail3; + status = musb_platform_set_mode(musb, MUSB_HOST); break; case MUSB_PORT_MODE_GADGET: status = musb_gadget_setup(musb); + if (status < 0) + goto fail3; + status = musb_platform_set_mode(musb, MUSB_PERIPHERAL); break; case MUSB_PORT_MODE_DUAL_ROLE: status = musb_host_setup(musb, plat->power); if (status < 0) goto fail3; status = musb_gadget_setup(musb); - if (status) + if (status) { musb_host_cleanup(musb); + goto fail3; + } + status = musb_platform_set_mode(musb, MUSB_OTG); break; default: dev_err(dev, "unsupported port mode %d\n", musb->port_mode); -- 1.8.4.GIT