Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp514388imm; Tue, 15 May 2018 05:14:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqCOxSK6Xma1CnveM+pKpKqVyIJhYNz6U7wSzFHZ9KSddh2XKIiE/ib54XaMpcskTQEF8Xd X-Received: by 2002:a63:824a:: with SMTP id w71-v6mr12207591pgd.37.1526386467604; Tue, 15 May 2018 05:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526386467; cv=none; d=google.com; s=arc-20160816; b=WGzDyZRNgrqr79EJ5ZSmxWuCH3b26e5GvTWD5X58wUUTa7BbEbyJ25LGDv50ZV+lk2 nhzKWr6uAEL16lWAeEgxeQ2iK/IhCBh+ffNVLPnV+izW6HDq14pLpvmTtuoLv+peZl+B 023tbjkR6wEJgCSes1T1QbSvcnfj3tGyKu7++IM699z0cqrPPXJBJFmXD8pPczNFF907 iv7/j3JhjEqcmnMH0UQb3EExSW7VLunl3HlaeilLvlXONRMReq48X03g8wrObYMg503L gb+V/zsjN4rehk+6gc3Fw5qzsJs5tBh7/zGlPJGGoCoD6S/QSMR/c4zZ7AM9nVV5R/0g 8vcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=HYKp90v9oUNuIQOqpI8/xOhxCImXYwzjtOzHtT42krM=; b=nUNZxKtvZStrNE9cpIFaxkLLQgxz0n/idGG/YL7lEwK1+J4nUDA9T8uk8ApcP2bv3V 5RTLfRk6P9clEFLxxWwRq4GmzI/1j1pEJ/njOjnEz/32ZM36hrxvv2iOVol4ryXf1iUf 5YY4igIwj4x85DIWdV4VHvBmOOInn7/hOrdTrwrqJ5kwJCSPYZmkwztK09QkL7AegRWG 6mSkHd2F1i0bI64++JVZ1gO4jWt1J08v+jS+aeL7/ABJ/gxWt8Oz5Z1y35RHD25fyP3A 3PYyv+docZaHVSVAdHF0sqqABBcWW75O8ykcNIaVukbDWkDK7QQ3ji4+6ItyxKT2zQBZ dvAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=toodlmxK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b60-v6si11966905plc.270.2018.05.15.05.13.57; Tue, 15 May 2018 05:14:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=toodlmxK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753214AbeEOMNC (ORCPT + 99 others); Tue, 15 May 2018 08:13:02 -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 n1FCrIllxZW5hxglOJiVRHh3GwGFeFMSK6tSi/Lji0pzUosPMUpzsCiJ88Zp1EUJCaQnlqRm p6YWpBbB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msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180515121251eucas1p290dce20660eb0008f6eeff30fc42443e X-RootMTR: 20180515121251eucas1p290dce20660eb0008f6eeff30fc42443e References: <20180515121239.18192-1-a.hajda@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.17.0