From patchwork Wed Jan 29 23:10:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 3555081 Return-Path: X-Original-To: patchwork-linux-arm@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 509329F2E9 for ; Wed, 29 Jan 2014 23:11:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C00C20160 for ; Wed, 29 Jan 2014 23:11:29 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 89D2B2015E for ; Wed, 29 Jan 2014 23:11:28 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W8eHA-0007Ih-Ul; Wed, 29 Jan 2014 23:10:33 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W8eGq-0004mp-9z; Wed, 29 Jan 2014 23:10:12 +0000 Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W8eGM-0004jJ-0b for linux-arm-kernel@lists.infradead.org; Wed, 29 Jan 2014 23:10:02 +0000 Received: by mail-pa0-f54.google.com with SMTP id fa1so2379041pad.13 for ; Wed, 29 Jan 2014 15:09:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:in-reply-to:references:subject; bh=ptMtMY35ASUK2nKagTe4i16OIDwoHmn3H6rShdBehKQ=; b=w2ZRU1+fFBdKQViyzLMX7ijljG0IwNRqBbh0UoMeQcRdAqTLt33p/6R/eEsrXp4IHX XPpTHlzolmUI4VoOvuGA24T1FTPckKnWiVoGq3Lvxr6ery81aqy2vhQnxozNfyNdmflm UEK0fnv7+PNv4/KTA92jdWq1z6lKtSa1E+YoHAkp3h6LO5cKWITQyDrcRBRt+/KsYY/8 wkd8T9kVY/hOC+oO0DSsgjCEV/NazkzFQFTfRhyeLRz1GOb1urZJjrp3vj3rNXBMGKQH FZxJave1JWC/B2JGcDvk+SCgZImG5mPDyG6K7KlyDD1Ula4rOaTYGb6Nuwe/07tQ8a7G De1w== X-Received: by 10.66.41.106 with SMTP id e10mr10801065pal.109.1391036960467; Wed, 29 Jan 2014 15:09:20 -0800 (PST) Received: from [127.0.0.1] (s214090.ppp.asahi-net.or.jp. [220.157.214.90]) by mx.google.com with ESMTPSA id oa3sm10805325pbb.15.2014.01.29.15.09.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jan 2014 15:09:19 -0800 (PST) From: Magnus Damm To: linux-sh@vger.kernel.org Date: Thu, 30 Jan 2014 08:10:29 +0900 Message-Id: <20140129231029.22655.58864.sendpatchset@w520> In-Reply-To: <20140129230959.22655.55645.sendpatchset@w520> References: <20140129230959.22655.55645.sendpatchset@w520> Subject: [PATCH 03/03] ARM: shmobile: Lager USB0 cable detection workaround X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140129_181000_826911_0E3FDEA8 X-CRM114-Status: GOOD ( 12.62 ) X-Spam-Score: -2.0 (--) Cc: horms@verge.net.au, Magnus Damm , valentine.barshak@cogentembedded.com, ben.dooks@codethink.co.uk, laurent.pinchart@ideasonboard.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 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 --- Depends on "[PATCH 02/03] pinctrl: sh-pfc: r8a7790: Break out USB0 OVC/VBUS" arch/arm/mach-shmobile/board-lager.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) --- 0004/arch/arm/mach-shmobile/board-lager.c +++ work/arch/arm/mach-shmobile/board-lager.c 2014-01-24 10:17:20.000000000 +0900 @@ -406,13 +406,30 @@ static int usbhs_hardware_init(struct pl { 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) @@ -424,6 +441,8 @@ static int usbhs_hardware_exit(struct pl usb_put_phy(priv->phy); priv->phy = NULL; + + gpio_free(RCAR_GP_PIN(5, 18)); return 0; } @@ -534,7 +553,7 @@ static const struct pinctrl_map lager_pi "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)