From patchwork Tue May 15 12:12:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10400869 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 0E3F7601F9 for ; Tue, 15 May 2018 12:14:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E982C2836F for ; Tue, 15 May 2018 12:14:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDE74287AA; Tue, 15 May 2018 12:14:11 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham 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 50D2C2836F for ; Tue, 15 May 2018 12:14:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753201AbeEOMNA (ORCPT ); Tue, 15 May 2018 08:13:00 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:45768 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752794AbeEOMMz (ORCPT ); Tue, 15 May 2018 08:12:55 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180515121252euoutp013905b05509e21823ccd6b7b13e6bf635~u0FGmV-0J2727427274euoutp01F; Tue, 15 May 2018 12:12:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180515121252euoutp013905b05509e21823ccd6b7b13e6bf635~u0FGmV-0J2727427274euoutp01F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1526386372; bh=HYKp90v9oUNuIQOqpI8/xOhxCImXYwzjtOzHtT42krM=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=toodlmxK2z4mphKEDGcuwvWHskaqcjQNt/oQLLJtXPtFRmM/S/qCdL6l0dezXlRft h44y7hgokOeV85pMahlu6F2HeXv3mmqdMPZNWFx76X5vXymDKGc7rlCkUEpKPzViDz n/ojvWXIz5HH4pOOCbkpK9Y4P/qM12oDU4NCjARc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180515121251eucas1p143a53d9ac7b523c38432a28e6fefd099~u0FFzHAKz1327713277eucas1p1K; Tue, 15 May 2018 12:12:51 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 12.33.10409.3CECAFA5; Tue, 15 May 2018 13:12:51 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180515121251eucas1p290dce20660eb0008f6eeff30fc42443e~u0FE_iS1J2155121551eucas1p2_; Tue, 15 May 2018 12:12:51 +0000 (GMT) X-AuditID: cbfec7f5-b45ff700000028a9-60-5afacec3897e Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 72.F8.04183.2CECAFA5; Tue, 15 May 2018 13:12:51 +0100 (BST) 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 <0P8R00C6NR9DS130@eusync4.samsung.com>; Tue, 15 May 2018 13:12:50 +0100 (BST) 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 v2 1/2] USB: dwc3: get extcon device by OF graph bindings Date: Tue, 15 May 2018 14:12:38 +0200 Message-id: <20180515121239.18192-2-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.0 In-reply-to: <20180515121239.18192-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEIsWRmVeSWpSXmKPExsWy7djP87qHz/2KMth0Scvi1rpzrBYbZ6xn tTjW9oTd4vqX56wW848AxZoXr2ezmHR/AovF+fMb2C06Jy5ht7i8aw6bxYzz+5gsFi1rZbZY e+Quu8XS6xeZLFr3HmF34PdYM28No8fsjpmsHptWdbJ57J+7ht2jb8sqRo/Pm+QC2KK4bFJS czLLUov07RK4Ml4+/8FUcJOvYlFPL1sD40SeLkZODgkBE4kdX6+wdjFycQgJrGCUaF16nAXC +cwo8fraHXaYqrVHusFsIYFljBKXjxRB2P8ZJc4d0Qax2QQ0Jf5uvskGYosIuEssW34NbCqz wEcWiZauj2AJYQFPiednHjKC2CwCqhIrDixgAbF5BSwkmldfZINYJi/xbPo8sGWcApYS6yc8 AbtIQuAIm0TrjdOMEEUuEmu7r7NA2MISr45vgbpURuLy5G6oeLXEzRdNUM0djBL3f7dDbbCW OHz8IiuIzSzAJzFp23TmLkYOoDivREebEESJh8TXk8eYIWxHidb5+9ghwdLDKPHsXjvTBEap BYwMqxjFU0uLc9NTi43zUsv1ihNzi0vz0vWS83M3MQJj/vS/4193MO77k3SIUYCDUYmHd8eM n1FCrIllxZW5hxglOJiVR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SIAKNkTmUcCAAA= X-CMS-MailID: 20180515121251eucas1p290dce20660eb0008f6eeff30fc42443e X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180515121251eucas1p290dce20660eb0008f6eeff30fc42443e X-RootMTR: 20180515121251eucas1p290dce20660eb0008f6eeff30fc42443e References: <20180515121239.18192-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 --- drivers/usb/dwc3/drd.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 1d8c557e97e0..270682486f82 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -8,6 +8,7 @@ */ #include +#include #include #include "debug.h" @@ -439,17 +440,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); + + if (np_conn) + edev = extcon_find_edev_by_node(np_conn); + else + edev = NULL; + + of_node_put(np_conn); + of_node_put(np_phy); + + return edev; +} + int dwc3_drd_init(struct dwc3 *dwc) { int ret, irq; - if (dwc->dev->of_node && - 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); + if (dwc->edev) { dwc->edev_nb.notifier_call = dwc3_drd_notifier; ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST, &dwc->edev_nb);