From patchwork Thu Aug 28 06:58:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 4795101 Return-Path: X-Original-To: patchwork-ltsi-dev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6C20BC0338 for ; Thu, 28 Aug 2014 07:38:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D9D32015A for ; Thu, 28 Aug 2014 07:38:37 +0000 (UTC) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C50B32011D for ; Thu, 28 Aug 2014 07:38:36 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B703DC5C; Thu, 28 Aug 2014 07:27:03 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 3EBD0C46 for ; Thu, 28 Aug 2014 07:27:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from kirsty.vergenet.net (kirsty.vergenet.net [202.4.237.240]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 835DA1F88A for ; Thu, 28 Aug 2014 07:27:01 +0000 (UTC) Received: from ayumi.isobedori.kobe.vergenet.net (p4222-ipbfp1605kobeminato.hyogo.ocn.ne.jp [114.154.95.222]) by kirsty.vergenet.net (Postfix) with ESMTP id 23B9E2672E4; Thu, 28 Aug 2014 17:08:24 +1000 (EST) Received: by ayumi.isobedori.kobe.vergenet.net (Postfix, from userid 7100) id 9F978EDE601; Thu, 28 Aug 2014 16:08:22 +0900 (JST) From: Simon Horman To: ltsi-dev@lists.linuxfoundation.org Date: Thu, 28 Aug 2014 15:58:59 +0900 Message-Id: <1409209620-24487-414-git-send-email-horms+renesas@verge.net.au> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1409209620-24487-1-git-send-email-horms+renesas@verge.net.au> References: <1409209620-24487-1-git-send-email-horms+renesas@verge.net.au> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Cc: Magnus Damm Subject: [LTSI-dev] [PATCH LTSI-3.14 413/894] ARM: shmobile: Lager USB0 cable detection workaround X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org X-Virus-Scanned: ClamAV using ClamSMTP From: Magnus Damm Add Lager board code to check the PWEN GPIO signal and refuse to allow probe of the USBHS driver in case of DIP misconfiguration. For correct operation Lager DIP switches SW5 and SW6 shall be configured in 2-3 position to enable USB Function support. If the DIP switch is configured incorrectly then the user can simply adjust the hardware and either reboot or use the bind interface to try to probe again: # echo renesas_usbhs > /sys/bus/platform/drivers/renesas_usbhs/bind Signed-off-by: Magnus Damm Signed-off-by: Simon Horman (cherry picked from commit 36be7686caa05334ca8d52df157b373a41d8d9f1) Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/board-lager.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index 30ebd08..6a7041f 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c @@ -408,13 +408,30 @@ static int usbhs_hardware_init(struct platform_device *pdev) { struct usbhs_private *priv = usbhs_get_priv(pdev); struct usb_phy *phy; + int ret; + + /* USB0 Function - use PWEN as GPIO input to detect DIP Switch SW5 + * setting to avoid VBUS short circuit due to wrong cable. + * PWEN should be pulled up high if USB Function is selected by SW5 + */ + gpio_request_one(RCAR_GP_PIN(5, 18), GPIOF_IN, NULL); /* USB0_PWEN */ + if (!gpio_get_value(RCAR_GP_PIN(5, 18))) { + pr_warn("Error: USB Function not selected - check SW5 + SW6\n"); + ret = -ENOTSUPP; + goto error; + } phy = usb_get_phy_dev(&pdev->dev, 0); - if (IS_ERR(phy)) - return PTR_ERR(phy); + if (IS_ERR(phy)) { + ret = PTR_ERR(phy); + goto error; + } priv->phy = phy; return 0; + error: + gpio_free(RCAR_GP_PIN(5, 18)); + return ret; } static int usbhs_hardware_exit(struct platform_device *pdev) @@ -426,6 +443,8 @@ static int usbhs_hardware_exit(struct platform_device *pdev) usb_put_phy(priv->phy); priv->phy = NULL; + + gpio_free(RCAR_GP_PIN(5, 18)); return 0; } @@ -536,7 +555,7 @@ static const struct pinctrl_map lager_pinctrl_map[] = { "vin1_clk", "vin1"), /* USB0 */ PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-r8a7790", - "usb0", "usb0"), + "usb0_ovc_vbus", "usb0"), }; static void __init lager_add_standard_devices(void)