From patchwork Tue Dec 16 23:16:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 5504201 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@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 70E57BEEA8 for ; Tue, 16 Dec 2014 23:16:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 92F4220A1B for ; Tue, 16 Dec 2014 23:16:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9A41A20A16 for ; Tue, 16 Dec 2014 23:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751075AbaLPXQh (ORCPT ); Tue, 16 Dec 2014 18:16:37 -0500 Received: from mail-lb0-f174.google.com ([209.85.217.174]:54561 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750905AbaLPXQg (ORCPT ); Tue, 16 Dec 2014 18:16:36 -0500 Received: by mail-lb0-f174.google.com with SMTP id 10so11786388lbg.19 for ; Tue, 16 Dec 2014 15:16:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:mime-version:content-transfer-encoding:content-type; bh=12xjEWbQFuAvlxfDF235rmKHXRn2ByzZQLekhZpmYVs=; b=cDswT0ymR2zorhkDO8xuKQRB6IG126bmNEJqpyvmzfwATdueQjeh4KD77MweexcnI9 GS+xCQ1wQ232wvHPCz83o7HFDBPIdVOKpb/Xjs04ioPpPE76Z/KAXYwqfG0HxIxMbhvC ZD8qi5UkCM7439UHpYZNiOjkmWcBCHapSWaaoFehKn7+29Aq0iolNh0xpssklDWxCmGa UUcYg/aNTQ0QNuhY+9d5gIYCfhGP//4Oh/Sllv8GaiTiok/Z+BOeOMqulhMcCr7cSiHk gwdEzK/sgK0w8OhgpGUrfmU5nXlBgWNdjFqjrV/gm0N6pUvWZgGoBTDxwcmCXkaEBPy/ Oz0Q== X-Gm-Message-State: ALoCoQmJ1QJUMXpmUOTWqD6qrSd72pSgyhdhhEPoIFjFTO1wTrIiGv1sGm9MgP5z2eJGZk2wO/Sz X-Received: by 10.152.3.100 with SMTP id b4mr36728173lab.68.1418771794718; Tue, 16 Dec 2014 15:16:34 -0800 (PST) Received: from wasted.cogentembedded.com (ppp83-237-255-220.pppoe.mtu-net.ru. [83.237.255.220]) by mx.google.com with ESMTPSA id g10sm511565laa.12.2014.12.16.15.16.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Dec 2014 15:16:33 -0800 (PST) From: Sergei Shtylyov To: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org Cc: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: hcd: add OTG ID signal sensing Date: Wed, 17 Dec 2014 02:16:31 +0300 Message-ID: <3663198.HSrURZGche@wasted.cogentembedded.com> Organization: Cogent Embedded Inc. User-Agent: KMail/4.14.3 (Linux/3.17.4-200.fc20.x86_64; KDE/4.14.3; x86_64; ; ) MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 On the Renesas R8A7791 SoC based boards there's MAX3355 USB OTG chip and mini-AB USB connector corresponding to USB port 0 driven either by EHCI/OHCI or Renesas USBHS gadget controller. And we'd like the host/gadget drivers to work based on the cable type connected. An 'extcon' driver for MAX3355 has been written, so we only need to bind to it via device tree which I'm doing in this patch. I wasn't able to find a solution better than checking the cable type at the host driver probe time and refusing to drive a host if B-cable is connected. Signed-off-by: Sergei Shtylyov --- The patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. It needs the recent 'extcon' core in order to properly handle probe deferral. drivers/usb/core/hcd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: usb/drivers/usb/core/hcd.c =================================================================== --- usb.orig/drivers/usb/core/hcd.c +++ usb/drivers/usb/core/hcd.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -2632,6 +2633,23 @@ int usb_add_hcd(struct usb_hcd *hcd, int retval; struct usb_device *rhdev; + if (IS_ENABLED(CONFIG_EXTCON) && + of_property_read_bool(hcd->self.controller->of_node, "extcon")) { + struct extcon_dev *edev; + + edev = extcon_get_edev_by_phandle(hcd->self.controller, 0); + if (IS_ERR(edev)) + return PTR_ERR(edev); + + retval = extcon_get_cable_state(edev, "USB-HOST"); + if (!retval) { + dev_err(hcd->self.controller, + "OTG B-cable plugged in, host driver won't load\n"); + return -EINVAL; + } else if (retval < 0) + return retval; + } + if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->usb_phy) { struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0);