Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72247C433F5 for ; Sun, 12 Sep 2021 14:23:36 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F1276108C for ; Sun, 12 Sep 2021 14:23:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8F1276108C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F188783925; Sun, 12 Sep 2021 16:23:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="RHUdP/xO"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="Pr4zwE+H"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5AAF183914; Sun, 12 Sep 2021 16:22:56 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8FFE583912 for ; Sun, 12 Sep 2021 16:22:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D491E5C0078; Sun, 12 Sep 2021 10:22:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 12 Sep 2021 10:22:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=4bPAzLyhU2Vk7 aR0X9uX6HA76Q9i9ESCHh4cJ7OiG3w=; b=RHUdP/xOgchpDZ5IsPRPd1Nj5Ofkz VrTj8EOzHzGaplrjwgSM8FcxQIcgfWdWHbu2jEPoWO8sAWszMTJd7XG9FGhX4c4G 3G0SbIrBVrgGDLu/WMmw7rKJKPe7faI39WRuCrt/TkT69CR8G5xPUI/uPg7INd1w q7yWbdWpeabfdcxnlbm8Eb9kQ54kRmv9MM3BTSWNBtMLCsJRy185h6PSXsWsYxUS vzT3F0v1vEXXfRYCmtSK/QpGvzDDCQyEMFJQX3br7BjzwQ+mT23k/hcPAXxv3P7v SYrrRse4VULlFs7cdoOB/3LOaEumE92XPCXVtqh22O4iwHvqg8ZMIfyqg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=4bPAzLyhU2Vk7aR0X9uX6HA76Q9i9ESCHh4cJ7OiG3w=; b=Pr4zwE+H hRN7GIDN1gJBx11WVMYtyWQqiR7CuDAdGFXFNKTZDgn35Qf4PEeHdfKagrAV9K6W oJrwMMwV5ncQk01FplOoYOb+rQ8vNg6numGV01oez5b2xz2aaucmLSLh3nZI6b3M p9zYJ4MLy1gzg4UiSXa34djfjqOcxpvoDerMCGK2V14pqdGREuMhMGMy2H7O0Dj7 JHJikVlYFXWOnqbjalSD3Sot0kQ/evLBKGtrgETUM8Mr3xxkjpvrWetHqYw3GMT4 0nJMqNHQvv5MTjbwLK/jAy39c1VkazpBMFPjZSieXJUHn0dz+yZt1sB8ubE8RBcp uAMR+IRFtKMY4w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeghedgjeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 12 Sep 2021 10:22:49 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara Cc: Samuel Holland , Joe Hershberger Subject: [PATCH 3/3] phy: sun4i-usb: Support VBUS detection via power supply Date: Sun, 12 Sep 2021 09:22:42 -0500 Message-Id: <20210912142243.9912-4-samuel@sholland.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210912142243.9912-1-samuel@sholland.org> References: <20210912142243.9912-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean The device tree binding provides for getting VBUS state from a device referenced by phandle, as an optional alternative to using a GPIO. In U-Boot, where there is no power supply class, this VBUS detection will be implemented using a regulator device and its get_enable method. Let's hook this up to the PHY driver. Signed-off-by: Samuel Holland --- drivers/phy/allwinner/Kconfig | 1 + drivers/phy/allwinner/phy-sun4i-usb.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/drivers/phy/allwinner/Kconfig b/drivers/phy/allwinner/Kconfig index dba3bae61c4..aa9d0e7e6a5 100644 --- a/drivers/phy/allwinner/Kconfig +++ b/drivers/phy/allwinner/Kconfig @@ -4,6 +4,7 @@ config PHY_SUN4I_USB bool "Allwinner Sun4I USB PHY driver" depends on ARCH_SUNXI + select DM_REGULATOR select PHY help Enable this to support the transceiver that is part of Allwinner diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c index 827ecd70f27..ab2a5d17fcf 100644 --- a/drivers/phy/allwinner/phy-sun4i-usb.c +++ b/drivers/phy/allwinner/phy-sun4i-usb.c @@ -26,6 +26,7 @@ #include #include #include +#include #define REG_ISCR 0x00 #define REG_PHYCTL_A10 0x04 @@ -137,6 +138,7 @@ struct sun4i_usb_phy_data { void __iomem *base; const struct sun4i_usb_phy_cfg *cfg; struct sun4i_usb_phy_plat *usb_phy; + struct udevice *vbus_power_supply; }; static int initial_usb_scan_delay = CONFIG_INITIAL_USB_SCAN_DELAY; @@ -404,6 +406,8 @@ int sun4i_usb_phy_vbus_detect(struct phy *phy) mdelay(100); err = gpio_get_value(usb_phy->gpio_vbus_det); } + } else if (data->vbus_power_supply) { + err = regulator_get_enable(data->vbus_power_supply); } return err; @@ -447,6 +451,9 @@ static int sun4i_usb_phy_probe(struct udevice *dev) if (IS_ERR(data->base)) return PTR_ERR(data->base); + device_get_supply_regulator(dev, "usb0_vbus_power-supply", + &data->vbus_power_supply); + data->usb_phy = plat; for (i = 0; i < data->cfg->num_phys; i++) { struct sun4i_usb_phy_plat *phy = &plat[i]; -- 2.31.1