From patchwork Wed Jan 31 15:57:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10194161 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 0537960380 for ; Wed, 31 Jan 2018 15:59:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E6B3287C9 for ; Wed, 31 Jan 2018 15:59:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 032C328762; Wed, 31 Jan 2018 15:59:04 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E16AB287D4 for ; Wed, 31 Jan 2018 15:59:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752061AbeAaP5n (ORCPT ); Wed, 31 Jan 2018 10:57:43 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:41197 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265AbeAaP5i (ORCPT ); Wed, 31 Jan 2018 10:57:38 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180131155735euoutp02736f126991becd175918e4545d890111~O8DnmDrY81003310033euoutp02K; Wed, 31 Jan 2018 15:57:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180131155735euoutp02736f126991becd175918e4545d890111~O8DnmDrY81003310033euoutp02K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1517414255; bh=lWp0YZFwslxrk1JiVJOKwILj7MGU0A8BkOo5YxgrX2w=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=GTvVWKfC9ly/dpip2mJubMvOrtggw7383uKKd1HNhIllXik2Su8n9XdpID/WdWfAP kSs9D2m6vwSvLQBg7PgSBA9+HTZU65S7jEi6jnWM0/a94U3QpBBA6FuzqdyFcFlbTg Gad6m9D09sUkEkejk/bxCy5tsANK1wt6QfX7j6JE= Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180131155735eucas1p290edb296d8425b78f8fe8f16ee135360~O8Dmzoybq0311603116eucas1p2k; Wed, 31 Jan 2018 15:57:35 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 2F.D8.12907.E67E17A5; Wed, 31 Jan 2018 15:57:34 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180131155734eucas1p2b55ad1aab1d5086566dad7a79b25ccf3~O8DmI0k5U2702727027eucas1p2V; Wed, 31 Jan 2018 15:57:34 +0000 (GMT) X-AuditID: cbfec7f1-f793a6d00000326b-a9-5a71e76e2802 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 95.65.18832.E67E17A5; Wed, 31 Jan 2018 15:57:34 +0000 (GMT) Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P3F006FAGBWIT00@eusync4.samsung.com>; Wed, 31 Jan 2018 15:57:34 +0000 (GMT) From: Andrzej Hajda To: linux-usb@vger.kernel.org (open list:DESIGNWARE USB3 DRD IP DRIVER) Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), Felipe Balbi , Greg Kroah-Hartman , Inki Dae , Rob Herring , Mark Rutland , Krzysztof Kozlowski , Chanwoo Choi , Laurent Pinchart , linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 1/2] USB: dwc3: get extcon device by OF graph bindings Date: Wed, 31 Jan 2018 16:57:17 +0100 Message-id: <20180131155718.5237-2-a.hajda@samsung.com> X-Mailer: git-send-email 2.15.1 In-reply-to: <20180131155718.5237-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFIsWRmVeSWpSXmKPExsWy7djPc7p5zwujDFa9NrS4te4cq8XGGetZ LY61PWG3uP7lOavF/CNAsebF69ksJt2fwGJx/vwGdovOiUvYLS7vmsNmMeP8PiaLRctamS3W HrnLbrH0+kUmi9a9R9gd+D3WzFvD6DG7Yyarx6ZVnWwe++euYffo27KK0ePzJrkAtigum5TU nMyy1CJ9uwSujB8nL7AXvBSv+HpvAnsD4x7hLkYODgkBE4nG13xdjJxAppjEhXvr2boYuTiE BJYySuw8cZgJwvnMKNG84A8jRJWJxKyX86ESyxgltu+4zQrh/GeUuH3rOxNIFZuApsTfzTfZ QGwRAXeJZcuvgRUxC3xkkWjp+giWEBZwk+h8dIgV5A4WAVWJc3fNQcK8AuYSk/fMZIbYJi8x YUsTC4jNKWAhsbKnHew+CYHLbBKTv/9jgvjBReJRTxJEvbDEq+Nb2CFsGYnOjoNMEPXdjBKf +k+wQzhTGCX+fZgBtcFa4vDxi6wgNrMAn8SkbdOZIYbySnS0CUGYHhJ3d1dAVDtK/J++lR3i YaCZbduOsU5glF7AyLCKUSS1tDg3PbXYSK84Mbe4NC9dLzk/dxMjMAWc/nf84w7G9yesDjEK c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ajEXFScCAFCobP9T AgAA X-CMS-MailID: 20180131155734eucas1p2b55ad1aab1d5086566dad7a79b25ccf3 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180131155734eucas1p2b55ad1aab1d5086566dad7a79b25ccf3 X-RootMTR: 20180131155734eucas1p2b55ad1aab1d5086566dad7a79b25ccf3 References: <20180131155718.5237-1-a.hajda@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP extcon device is used to detect host/device connection. Since extcon OF property is deprecated, alternative method should be added. This method uses OF graph bindings to locate extcon. Signed-off-by: Andrzej Hajda --- Hi all, This patch implements alternative method to get extcon from DWC3. The code works but is hacky, as DWC3 must traverse different DT nodes to get extcon, in case of TM2 it is USB-PHY and MUIC, but other platforms can have different paths. I would be glad if it can be merged as is for now, but additional work must be done to make it generic. I guess on DT binding side it is OK. So the problem should be addressed in the code. My rough idea is to implement kind of extcon aliases/forwarder mechanism, ie. USB-PHY will expect on its output remote port extcon, and it should register extcon-forwarder pointing to this extcon. This way DWC3 can look for the extcon on its PHY phandle, and it will receive via forwarding mechanism extcon exposed by MUIC. As I said this is rough idea for discussion, other propositions are welcome. Regards Andrzej --- drivers/usb/dwc3/drd.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index cc8ab9a8e9d2..eee2eca3d513 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -8,6 +8,7 @@ */ #include +#include #include "debug.h" #include "core.h" @@ -38,24 +39,38 @@ static int dwc3_drd_notifier(struct notifier_block *nb, return NOTIFY_DONE; } +struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) +{ + struct device *dev = dwc->dev; + struct device_node *np_phy, *np_conn; + struct extcon_dev *edev; + + if (of_property_read_bool(dev->of_node, "extcon")) + return extcon_get_edev_by_phandle(dwc->dev, 0); + + np_phy = of_parse_phandle(dev->of_node, "phys", 0); + np_conn = of_graph_get_remote_node(np_phy, -1, -1); + edev = extcon_get_edev_by_of_node(np_conn); + of_node_put(np_conn); + of_node_put(np_phy); + + return edev; +} + int dwc3_drd_init(struct dwc3 *dwc) { int ret; - if (dwc->dev->of_node) { - if (of_property_read_bool(dwc->dev->of_node, "extcon")) - dwc->edev = extcon_get_edev_by_phandle(dwc->dev, 0); - - if (IS_ERR(dwc->edev)) - return PTR_ERR(dwc->edev); + dwc->edev = dwc3_get_extcon(dwc); + if (IS_ERR(dwc->edev)) + return PTR_ERR(dwc->edev); - dwc->edev_nb.notifier_call = dwc3_drd_notifier; - ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST, - &dwc->edev_nb); - if (ret < 0) { - dev_err(dwc->dev, "couldn't register cable notifier\n"); - return ret; - } + dwc->edev_nb.notifier_call = dwc3_drd_notifier; + ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST, + &dwc->edev_nb); + if (ret < 0) { + dev_err(dwc->dev, "couldn't register cable notifier\n"); + return ret; } dwc3_drd_update(dwc);