From patchwork Wed Jan 15 14:13:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 11334891 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6D7792A for ; Wed, 15 Jan 2020 14:14:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95A7C2468A for ; Wed, 15 Jan 2020 14:14:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UFhBroBK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730684AbgAOOOb (ORCPT ); Wed, 15 Jan 2020 09:14:31 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44451 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730038AbgAOONW (ORCPT ); Wed, 15 Jan 2020 09:13:22 -0500 Received: by mail-wr1-f66.google.com with SMTP id q10so15889793wrm.11 for ; Wed, 15 Jan 2020 06:13:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6uupSatp1wSHjPtFQUOGaipgCxDGUITI3uZDbwiKKdA=; b=UFhBroBK623fOOHnv4hUWAelOBD5EEl7ceoSImfULI8dolkMB+xHhasMiFDPwGSYIE QtN15Zcg4KPJfGlLYfSu0WUWPYTmUaHfBm7TtjbLu5zHpflqnwQLrO+Mp8Aq53kY/0U0 n7+vdXVA+Q20n7vjII7/IE38b4DhF3T0sM492xNPTBwDS2v9GuSIR3WO113is9NkaR0J BmXUtWz1dmXSbmRVqCa9Do65TQDEPN89g0CcJIG37KUnCi0o7KLAmLVG/d+0gTjocA9t WRcB82VLLqn2PJolZL4RZa2CpZx2zlzOhf8+3cg6+iH3yAY9p88tlKDaD6H8ujwL7DTo sQAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6uupSatp1wSHjPtFQUOGaipgCxDGUITI3uZDbwiKKdA=; b=Z72OdxIqH0g4M7QCJgQmcODXMPuNhHXXvil+gtPWJCdS6Fmh6z/2xEhfAofwHVFrcB dWcMTBb9Q9w4cpPVV/a/+eIXgSbMM5yo+C3kA7VA3aNLZOi/sZ2fDN8Acy9ooO8e32/U mM0+JjsmXSPytMqQBA1hXs3AZZhVh3tt1HkjpcEjcpeKw6tNBWf2AfgPWw+KGOUFlmSy RPCluex41q5LD/SUSWB96rbDc1J9sN1aGhU/s2Tb7LRalGS03FwW1yUbM2HC6SfQ2+bA Bfc5RahcAeG8KIG0AmHPi6IqkVjWvUcgaflenGWEh7qbjzg5X3O6Q64qKpOhCRrLeVRw p6fw== X-Gm-Message-State: APjAAAVensIH8Gg8viXhYFTU8YnZM1TnnzvLy1d2o+5nAnmRMQtmaPC8 nA7M9V2o39LyQ7myNgUOwqqwsw== X-Google-Smtp-Source: APXvYqy+y5/WNIlUiRygmiwuZvM1BhCHTwU0YKhbrM9Q0bpz03HYrEIConEdEnUwSo0oTxImfTY/WQ== X-Received: by 2002:a5d:4481:: with SMTP id j1mr32581140wrq.348.1579097600477; Wed, 15 Jan 2020 06:13:20 -0800 (PST) Received: from localhost.localdomain ([176.61.57.127]) by smtp.gmail.com with ESMTPSA id m21sm23730720wmi.27.2020.01.15.06.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2020 06:13:19 -0800 (PST) From: Bryan O'Donoghue To: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, gregkh@linuxfoundation.org, jackp@codeaurora.org, balbi@kernel.org, bjorn.andersson@linaro.org Cc: linux-kernel@vger.kernel.org, Bryan O'Donoghue , John Stultz , Lee Jones , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Yu Chen , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , devicetree@vger.kernel.org Subject: [PATCH 11/19] usb: dwc3: Add support for usb-conn-gpio connectors Date: Wed, 15 Jan 2020 14:13:25 +0000 Message-Id: <20200115141333.1222676-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200115141333.1222676-1-bryan.odonoghue@linaro.org> References: <20200115141333.1222676-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch adds the ability to probe and enumerate a connector based on usb-conn-gpio. A device node label gpio_usb_connector is used to identify a usb-conn-gpio as a child of the USB interface. You would use usb-conn-gpio when a regulator in your system provides VBUS directly to the connector instead of supplying via the USB PHY. The parent device must have the "usb-role-switch" property, so that when the usb-conn-gpio driver calls usb_role_switch_set_role() the notification in dwc3 will run and the block registers will be updated to match the state detected at the connector. Cc: John Stultz Cc: Bjorn Andersson Cc: Lee Jones Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Signed-off-by: Bryan O'Donoghue --- drivers/usb/dwc3/drd.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index 865341facece..c6bb7cb809d5 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "debug.h" #include "core.h" @@ -557,9 +558,32 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc) dwc3_set_mode(dwc, mode); return 0; } + +static int dwc3_register_gpio_usb_connector(struct dwc3 *dwc) +{ + struct device *dev = dwc->dev; + struct device_node *np = dev->of_node, *con_np; + int ret; + + con_np = of_get_child_by_name(np, "gpio_usb_connector"); + if (!np) { + dev_dbg(dev, "no usb_connector child node specified\n"); + return 0; + } + + ret = of_platform_populate(np, NULL, NULL, dev); + if (ret) { + dev_err(dev, "failed to register usb_connector - %d\n", ret); + return ret; + } + + return 0; +} + #else #define ROLE_SWITCH 0 #define dwc3_setup_role_switch(x) 0 +#define dwc3_register_gpio_usb_connector(x) 0 #endif int dwc3_drd_init(struct dwc3 *dwc) @@ -575,6 +599,9 @@ int dwc3_drd_init(struct dwc3 *dwc) ret = dwc3_setup_role_switch(dwc); if (ret < 0) return ret; + ret = dwc3_register_gpio_usb_connector(dwc); + if (ret < 0) + return ret; } else if (dwc->edev) { dwc->edev_nb.notifier_call = dwc3_drd_notifier; ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,