Received: by 10.223.176.5 with SMTP id f5csp1628082wra; Wed, 31 Jan 2018 09:07:52 -0800 (PST) X-Google-Smtp-Source: AH8x224qZZSGS5uV+3BVFf4c7/plJgmfwXVmb6UAkTMhbNRM9LKndnyoWtFo6GKxncVcLcOgjiEJ X-Received: by 10.98.232.14 with SMTP id c14mr34742454pfi.215.1517418472520; Wed, 31 Jan 2018 09:07:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517418472; cv=none; d=google.com; s=arc-20160816; b=z8NWfuxh+UEbnClhyfpyT6ki9gJAmXHexIgbaENS+1s3T/rAkSHkEE5cHZjdK0GC1m Z359EM7c3NwGbySGUsphB2O8iyITVo2wetOcwzDiUpLtobu8VAdMqVBsGLh95d6+E3fE wHOAunc4kgGrKUFvdFc3jqWqwPOgE9hJBZJpSRRLqhjVpyxq6MqdG/GqzJMhJCjW78P5 +byYOn0nnND1CRAxx/kLvIHeWozLZxWQhI4EqgUufOLiIAes9kYy2QRjxmZFtY/mTN49 hmrMVNN4qsxmebe/1m/5SmnjmnVIEB20oakwybLYMoK1WxOd/Vz+xkW7pHDMh9zl+KIX tAvg== 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=lWp0YZFwslxrk1JiVJOKwILj7MGU0A8BkOo5YxgrX2w=; b=l0XMEQFo0K7ojNeMpsqYXHSpcUQ634Ib2m9Sp/WatlACpoabxGZXhMDY6kb9TEwg48 tZRKUSdk0e3f/E75hMolmdQprYD8i3QRPbQ+v1TRw7drtZpcSLIO0E7if+Jo7wUdwemI OQW2hX0LtZBF+qCOGxoSfemhT80ZC4TnWZjf0iOyNT/3PM6Kd78F//ypW/+rT0+x9/5X Mk6Q+8eUefuNk2VaGfrY1Xf7B4Sl4vEWpSWfim/xgonA524v2bi+oDJfP884R/FdIrJx TolQhuoYDAOD3xg4TtQNbgJPbUvYlxVVR2rdKt1/a4+H2dF8eoqCTQDQSrC06wc65Z4H vUHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=GTvVWKfC; 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 z72si2386230pff.100.2018.01.31.09.07.38; Wed, 31 Jan 2018 09:07:52 -0800 (PST) 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=GTvVWKfC; 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 S1753521AbeAaP5o (ORCPT + 99 others); Wed, 31 Jan 2018 10:57:44 -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 cDAq8fC+uFQYJcSaWFZcmXuIUYKDWUmEd89FoBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFe26i2 SCGB9MSS1OzU1ILUIpgsEwenVAOj/XPp1FMbl11kTmYo3hBlaLNuXkdoSdG5st/a3/QannFE B1j4Z6/JSLnlt8rB6VzTO6+8wszAXX/s2DX27I3uednhvohrzY84mTMrFcxeikvtvWB1ZKrV sy+nlDsurY+yDVORSJfbwcx5amLiZNX0MF0vtwPnZtXz8dqays25fOU5+5Ut2q+VWIozEg21 mIuKEwF0acRX/QIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrALMWRmVeSWpSXmKPExsVy+t/xa7p5zwujDLbtFrG4te4cq8XGGetZ LY61PWG3uP7lOavF/CNAsebF69ksJt2fwGJx/vwGdovOiUvYLS7vmsNmMeP8PiaLRctamS3W HrnLbrH0+kUmi9a9R9gd+D3WzFvD6DG7Yyarx6ZVnWwe++euYffo27KK0ePzJrkAtigum5TU nMyy1CJ9uwSujB8nL7AXvBSv+HpvAnsD4x7hLkZODgkBE4lZL+czQdhiEhfurWfrYuTiEBJY wiixeNMcVginkUni2ol2VpAqNgFNib+bb7KB2CIC7hLLll8DK2IW+MoiMen7S3aQhLCAm0Tn o0NACQ4OFgFViXN3zUHCvALmEpP3zGSG2CYvMWFLEwuIzSlgIbGypx1sphBQzZ7NV5kmMPIu YGRYxSiSWlqcm55bbKhXnJhbXJqXrpecn7uJERiu24793LyD8dLG4EOMAhyMSjy8Ly4VRgmx JpYVV+YeYpTgYFYS4d1zESjEm5JYWZValB9fVJqTWnyIUZqDRUmct3fP6kghgfTEktTs1NSC 1CKYLBMHp1QDY1tbw7kHpduXfApjuittJrLDOU71hqQa233jP1uaQ7T9r9hKtnz/InU//PzS J5xdf3Zeic2Rn1Y0vXf+qnCXJLse5h9Od3wDCk4cP27UUDa7XDn2TFW17PprDvv+rO0OM9if c+scs0yM/PLP274LqH+YLll0auaOhMY/+bW9UvlCn5x0vKM3K7EUZyQaajEXFScCAFCobP9T 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-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 --- 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); -- 2.15.1