From patchwork Sun Jan 22 23:46:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1730216 X-Patchwork-Delegate: andre.przywara@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm1 header.b=SF7vD64R; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=b38LJkKq; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P0VJ60vtMz23gd for ; Mon, 23 Jan 2023 10:46:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BE975856D8; Mon, 23 Jan 2023 00:46:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (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=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="SF7vD64R"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="b38LJkKq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7DCE7856D0; Mon, 23 Jan 2023 00:46:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (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 40A28856AF for ; Mon, 23 Jan 2023 00:46:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 7B8CD3200786; Sun, 22 Jan 2023 18:46:24 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 22 Jan 2023 18:46:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1674431184; x=1674517584; bh=rP 3s++VHNtGmnF+WBg1nDuDLeYW3xgXPJ/J0twebLDs=; b=SF7vD64RWUNGls+76u BSf/Y/saWytR0WoAkoaK+jONXFRCopCYLzHjZNhZUIDAKvdm1aUFY3pT0jKWbPGe gA46+oY30e2ivYijJsz3UlkiRUeXa07MrccwqMByiam97JfmtcmfOwBalZWHq0ki BQc9BsIj/BRvVD8//FVfoDMIapSZXm9cfsEMbS6YZPFfYm675/edRGoGXTO8UPgp sR9awfTzye/1AhrQwIcL5fCTynZD4SDM/LHOdl5j5Il4gW5ijiEa+YEVAj5e7qCP dgUEsJBMpm+Cq0M6R6K0f/4Kmci5NEuddzQmfnrbJdOTnYwsNEWtuW4YXwx6S4Kf 8PPw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1674431184; x=1674517584; bh=rP3s++VHNtGmn F+WBg1nDuDLeYW3xgXPJ/J0twebLDs=; b=b38LJkKqPvNNGyn3KF97cYmUsjKz1 TPCgYw1u5Pz9jDVonoEKRx5OM21FPW4zh9iJpbM1ObaZSYD72MVdXRqc/xO/ag6O blajLQNsAPtoDK8BNn+VGeni9dOPRnIXX0iJQtM/lnNj8qk1AlXZho79HoKwsJJu rVdv454kvskULTKOg2Kw3Dzl94BQARmJzNpTCa/qD/dF9drTP9DDTpwdPwvNhL1+ U2Od033dPriz18UuCwggO58PcSIPJklHVW8/S5myGYZbiOIDwLsdmDw3fZ9KTpSr LPqPscplHyy7DK23s54b7kyZK28UZi5OmcK/kqcYw9kw1tj3GbWw16WKQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddujedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 22 Jan 2023 18:46:23 -0500 (EST) From: Samuel Holland To: Andre Przywara , Jagan Teki , Jaehoon Chung Cc: u-boot@lists.denx.de, Samuel Holland Subject: [PATCH 1/3] power: regulator: Add a driver for the AXP USB power supply Date: Sun, 22 Jan 2023 17:46:20 -0600 Message-Id: <20230122234623.1636-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20230122234623.1636-1-samuel@sholland.org> References: <20230122234623.1636-1-samuel@sholland.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean This driver reports the presence/absence of voltage on the PMIC's USB VBUS pin. This information is used by the USB PHY driver. The corresponding Linux driver uses the power supply class, which does not exist in U-Boot. UCLASS_REGULATOR seems to be the closest match. Signed-off-by: Samuel Holland Acked-by: Andre Przywara --- drivers/power/regulator/Kconfig | 7 ++++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/axp_usb_power.c | 49 +++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 drivers/power/regulator/axp_usb_power.c diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index c346d03507..eb5aa38c1c 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -57,6 +57,13 @@ config SPL_REGULATOR_AXP Enable support in SPL for the regulators (DCDCs, LDOs) in the X-Powers AXP152, AXP2xx, and AXP8xx PMICs. +config REGULATOR_AXP_USB_POWER + bool "Enable driver for X-Powers AXP PMIC USB power supply" + depends on DM_REGULATOR && PMIC_AXP + help + Enable support for reading the USB power supply status from + X-Powers AXP2xx and AXP8xx PMICs. + config DM_REGULATOR_BD71837 bool "Enable Driver Model for ROHM BD71837/BD71847 regulators" depends on DM_REGULATOR && DM_PMIC_BD71837 diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile index 2d97e1033a..d9e0cd5949 100644 --- a/drivers/power/regulator/Makefile +++ b/drivers/power/regulator/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_$(SPL_)DM_REGULATOR) += regulator-uclass.o obj-$(CONFIG_REGULATOR_ACT8846) += act8846.o obj-$(CONFIG_REGULATOR_AS3722) += as3722_regulator.o obj-$(CONFIG_$(SPL_)REGULATOR_AXP) += axp_regulator.o +obj-$(CONFIG_$(SPL_)REGULATOR_AXP_USB_POWER) += axp_usb_power.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_DA9063) += da9063.o obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o obj-$(CONFIG_DM_REGULATOR_NPCM8XX) += npcm8xx_regulator.o diff --git a/drivers/power/regulator/axp_usb_power.c b/drivers/power/regulator/axp_usb_power.c new file mode 100644 index 0000000000..f32fb6a92d --- /dev/null +++ b/drivers/power/regulator/axp_usb_power.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include +#include + +#define AXP_POWER_STATUS 0x00 +#define AXP_POWER_STATUS_VBUS_PRESENT BIT(5) + +static int axp_usb_power_get_enable(struct udevice *dev) +{ + int ret; + + ret = pmic_reg_read(dev->parent, AXP_POWER_STATUS); + if (ret < 0) + return ret; + + return !!(ret & AXP_POWER_STATUS_VBUS_PRESENT); +} + +static const struct dm_regulator_ops axp_usb_power_ops = { + .get_enable = axp_usb_power_get_enable, +}; + +static int axp_usb_power_probe(struct udevice *dev) +{ + struct dm_regulator_uclass_plat *uc_plat = dev_get_uclass_plat(dev); + + uc_plat->type = REGULATOR_TYPE_FIXED; + + return 0; +} + +static const struct udevice_id axp_usb_power_ids[] = { + { .compatible = "x-powers,axp202-usb-power-supply" }, + { .compatible = "x-powers,axp221-usb-power-supply" }, + { .compatible = "x-powers,axp223-usb-power-supply" }, + { .compatible = "x-powers,axp813-usb-power-supply" }, + { } +}; + +U_BOOT_DRIVER(axp_usb_power) = { + .name = "axp_usb_power", + .id = UCLASS_REGULATOR, + .of_match = axp_usb_power_ids, + .probe = axp_usb_power_probe, + .ops = &axp_usb_power_ops, +};