From patchwork Fri Nov 22 15:55:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Jackson X-Patchwork-Id: 3222991 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 2E2E69F26C for ; Fri, 22 Nov 2013 15:56:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 07506207A4 for ; Fri, 22 Nov 2013 15:56:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E3B76200F4 for ; Fri, 22 Nov 2013 15:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755560Ab3KVP4E (ORCPT ); Fri, 22 Nov 2013 10:56:04 -0500 Received: from 217-155-41-104.dsl.in-addr.zen.co.uk ([217.155.41.104]:43167 "EHLO centos1.newflow.co.uk" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1755505Ab3KVP4A (ORCPT ); Fri, 22 Nov 2013 10:56:00 -0500 Received: from [10.0.0.111] (unknown [10.0.0.111]) by centos1.newflow.co.uk (Postfix) with ESMTP id 3174826B8039; Fri, 22 Nov 2013 15:55:59 +0000 (GMT) Message-ID: <528F7E8F.5050807@newflow.co.uk> Date: Fri, 22 Nov 2013 15:55:59 +0000 From: Mark Jackson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: linux-usb@vger.kernel.org CC: lkml , Felipe Balbi , bigeasy@linutronix.de, Greg KH , jkosina@suse.cz, anatol.pomozov@gmail.com, "linux-omap@vger.kernel.org" Subject: [PATCH] Allow MUSB DSPS to use "force host" mode Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 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, .iddig = 8, .usb_shift = 0, .usb_mask = 0x1ff, diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index eb50525..a0a81c5 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -75,6 +75,7 @@ struct musb_hdrc_config { unsigned high_iso_rx:1; /* Rx ep required for HD iso */ unsigned dma:1 __deprecated; /* supports DMA */ unsigned vendor_req:1 __deprecated; /* vendor registers required */ + unsigned force_host:1; /* force host mode */ u8 num_eps; /* number of endpoints _with_ ep0 */ u8 dma_channels __deprecated; /* number of dma channels */