From patchwork Mon Aug 15 19:21:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9281991 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 609FA60467 for ; Mon, 15 Aug 2016 19:25:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 535D828E52 for ; Mon, 15 Aug 2016 19:25:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4825528E5B; Mon, 15 Aug 2016 19:25:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B888428E52 for ; Mon, 15 Aug 2016 19:25:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZNUY-0000br-Rt; Mon, 15 Aug 2016 19:24:10 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZNSg-0007sl-6G for linux-arm-kernel@lists.infradead.org; Mon, 15 Aug 2016 19:22:16 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 77F45C05680F; Mon, 15 Aug 2016 19:21:57 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-4-16.ams2.redhat.com [10.36.4.16]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7FJLYYx002825; Mon, 15 Aug 2016 15:21:54 -0400 From: Hans de Goede To: Bin Liu , Greg Kroah-Hartman , Kishon Vijay Abraham I , Rob Herring Subject: [PATCH v2 6/7] phy-sun4i-usb: Add "allwinner, usb0-usb-a-connector" dt property Date: Mon, 15 Aug 2016 21:21:31 +0200 Message-Id: <1471288892-21702-7-git-send-email-hdegoede@redhat.com> In-Reply-To: <1471288892-21702-1-git-send-email-hdegoede@redhat.com> References: <1471288892-21702-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 15 Aug 2016 19:21:57 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160815_122214_395296_1BE07A86 X-CRM114-Status: GOOD ( 16.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans de Goede , Maxime Ripard , linux-usb@vger.kernel.org, Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On some devices the musb otg controller can be used in both device and host mode, but requires software mode switching since there is no id pin connected. The usb0 phy code will default to device mode in this case. On some systems usb0 is connected to a female USB-A port. It can still be used in device mode when using software mode switching and a USB A to A cable. To configure the controller to support both modes we must set its "dr_mode" dt property to "otg" (*). For these setups the device mode default is wrong, for a female USB-A port the default should be host mode. This commit adds support to the sun4i phy code for a new "allwinner,usb0-usb-a-connector" dt property which can be used in dt files to indicate this scenario and when present it changes the default mode to host mode. *) dr_mode = "host" is used when device mode is _never_ used. E.g. a wifi module soldered onto the PCB is connected to the musb controller. Signed-off-by: Hans de Goede --- Changes in v2: -New patch in v2 of this patchset --- Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt | 2 ++ drivers/phy/phy-sun4i-usb.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt b/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt index 287150d..8646b53 100644 --- a/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt +++ b/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt @@ -35,6 +35,8 @@ Optional properties: - usb0_vbus-supply : regulator phandle for controller usb0 vbus - usb1_vbus-supply : regulator phandle for controller usb1 vbus - usb2_vbus-supply : regulator phandle for controller usb2 vbus +- allwinner,usb0-usb-a-connector: usb0 is connected to an USB-A connector, + rather then an USB-B connector as one would expect (bool) Example: usbphy: phy@0x01c13400 { diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c index c17b099..82fb46a 100644 --- a/drivers/phy/phy-sun4i-usb.c +++ b/drivers/phy/phy-sun4i-usb.c @@ -137,6 +137,7 @@ struct sun4i_usb_phy_data { int vbus_det_irq; int id_det; int vbus_det; + int id_det_default; struct delayed_work detect; }; @@ -328,7 +329,7 @@ static int sun4i_usb_phy0_get_id_det(struct sun4i_usb_phy_data *data) if (data->id_det_gpio) return gpiod_get_value_cansleep(data->id_det_gpio); else - return 1; /* Fallback to peripheral mode */ + return data->id_det_default; case USB_DR_MODE_HOST: return 0; case USB_DR_MODE_PERIPHERAL: @@ -621,6 +622,12 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev) if (IS_ERR(data->base)) return PTR_ERR(data->base); + /* Set id-det default for when there is no id-det gpio */ + if (of_property_read_bool(np, "allwinner,usb0-usb-a-connector")) + data->id_det_default = 0; /* Host (USB-A connector) */ + else + data->id_det_default = 1; /* Device (USB-B connector) */ + data->id_det_gpio = devm_gpiod_get_optional(dev, "usb0_id_det", GPIOD_IN); if (IS_ERR(data->id_det_gpio))