From patchwork Thu Nov 15 13:16:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 10684311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 09B5E17F3 for ; Thu, 15 Nov 2018 13:16:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED2362C5C8 for ; Thu, 15 Nov 2018 13:16:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0E8D2C5D4; Thu, 15 Nov 2018 13:16:27 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 87F112C5C8 for ; Thu, 15 Nov 2018 13:16:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387548AbeKOXYP (ORCPT ); Thu, 15 Nov 2018 18:24:15 -0500 Received: from mga18.intel.com ([134.134.136.126]:9880 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731710AbeKOXYO (ORCPT ); Thu, 15 Nov 2018 18:24:14 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Nov 2018 05:16:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,236,1539673200"; d="scan'208";a="91350166" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 15 Nov 2018 05:16:23 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 496F03EA; Thu, 15 Nov 2018 15:16:22 +0200 (EET) From: Andy Shevchenko To: Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Guenter Roeck , Heikki Krogerus , Roger Quadros , Hans de Goede Cc: Andy Shevchenko Subject: [PATCH v2 3/3] usb: dwc3: drd: Add support for DR detection through extcon Date: Thu, 15 Nov 2018 15:16:21 +0200 Message-Id: <20181115131621.44187-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115131621.44187-1-andriy.shevchenko@linux.intel.com> References: <20181115131621.44187-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow extcon device, found by name, to provide DR status for USB. This is needed, for example, in case of Intel Merrifield platform, where the Intel Basin Cove PMIC provides an extcon device to communicate the detected role. Note, that the "linux,extcon-name" property name is only for kernel internal use by X86/ACPI platform code and as such is not documented in the device tree bindings. Signed-off-by: Andy Shevchenko Acked-by: Hans de Goede --- drivers/usb/dwc3/drd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 2401bd504891..726100d1ac0d 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -446,10 +446,25 @@ static 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; + const char *name; if (device_property_read_bool(dev, "extcon")) return extcon_get_edev_by_phandle(dev, 0); + /* + * Device tree platforms should get extcon via phandle. + * On ACPI platforms, we get the name from a device property. + * This device property is for kernel internal use only and + * is expected to be set by the glue code. + */ + if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) { + edev = extcon_get_extcon_dev(name); + if (!edev) + return ERR_PTR(-EPROBE_DEFER); + + return edev; + } + np_phy = of_parse_phandle(dev->of_node, "phys", 0); np_conn = of_graph_get_remote_node(np_phy, -1, -1);