Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 847E0C433EF for ; Thu, 23 Jun 2022 17:42:35 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4CC17842AD; Thu, 23 Jun 2022 19:42:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=fris.de 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=fris.de header.i=@fris.de header.b="B5kFZ7v+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8D3A5842F1; Thu, 23 Jun 2022 19:42:32 +0200 (CEST) Received: from mail.fris.de (mail.fris.de [116.203.77.234]) (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 CEF8083C97 for ; Thu, 23 Jun 2022 19:42:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=fris.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=frieder@fris.de Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7ECFFBFAD2; Thu, 23 Jun 2022 19:42:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1656006147; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=9MkhpswOG8LerarIJRYzEjoInuJaBdDq+0jcNCedSuI=; b=B5kFZ7v+8z47Nn76MocwEGJfgSUjwAjthY2ySL3V8fiuBceMsvlMk1x+6Da44qkW66LY16 yDrtPgff/HYgT1u0Y3myPQ1PmH2cdXsRFeKj766PefeoV/9COAoDho+ewYwvy9tNJs39kV 7Cr9exxVq1IhXObFz+InijFWQcE1Dd8EdKQRSmD2feoFFxHryuTE7mZNVGj/BbkKCEPMbT VQpj5ZviDfykvWpiPqAdedwaxnLCf1EfkRFyvsLDDyIr7HyPmTJNVqk7t/iIhdNqZXFxuh dMA9MUrI7PW5HcwspZFfdm6ziE/zZawMczPFHN21c4Vxcds1+ldmmFSqg5PRug== From: Frieder Schrempf To: Jaehoon Chung , u-boot@lists.denx.de Cc: Heiko Thiery , Tom Rini , Frieder Schrempf , Fabio Estevam , Marek Vasut Subject: [PATCH 1/2] pmic: pca9450: Add optional SD_VSEL GPIO for LDO5 Date: Thu, 23 Jun 2022 19:42:14 +0200 Message-Id: <20220623174215.299989-1-frieder@fris.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 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 From: Frieder Schrempf LDO5 has two separate control registers. LDO5CTRL_L is used if the input signal SD_VSEL is low and LDO5CTRL_H if it is high. The current driver implementation only uses LDO5CTRL_H. To make this work on boards that have SD_VSEL connected to a GPIO, we add support for specifying an optional GPIO and setting it to high at probe time. In the future we might also want to add support for boards that have SD_VSEL set to a fixed low level. In this case we need to change the driver to be able to use the LDO5CTRL_L register. This is a port of the same change in the Linux kernel: 8c67a11bae88 ("regulator: pca9450: Add SD_VSEL GPIO for LDO5") Signed-off-by: Frieder Schrempf --- drivers/power/pmic/pca9450.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/power/pmic/pca9450.c b/drivers/power/pmic/pca9450.c index 116ac49a8db..6b9befba18c 100644 --- a/drivers/power/pmic/pca9450.c +++ b/drivers/power/pmic/pca9450.c @@ -7,9 +7,12 @@ #include #include #include +#include #include +#include #include #include +#include #include #include #include @@ -26,6 +29,10 @@ static const struct pmic_child_info pmic_children_info[] = { { }, }; +struct pca9450_priv { + struct gpio_desc *sd_vsel_gpio; +}; + static int pca9450_reg_count(struct udevice *dev) { return PCA9450_REG_NUM; @@ -76,6 +83,24 @@ static int pca9450_bind(struct udevice *dev) return 0; } +static int pca9450_probe(struct udevice *dev) +{ + struct pca9450_priv *priv = dev_get_priv(dev); + int ret = 0; + + if (IS_ENABLED(CONFIG_DM_GPIO) && IS_ENABLED(CONFIG_DM_REGULATOR_PCA9450)) { + priv->sd_vsel_gpio = devm_gpiod_get_optional(dev, "sd-vsel", + GPIOD_IS_OUT | + GPIOD_IS_OUT_ACTIVE); + if (IS_ERR(priv->sd_vsel_gpio)) { + ret = PTR_ERR(priv->sd_vsel_gpio); + dev_err(dev, "Failed to request SD_VSEL GPIO: %d\n", ret); + } + } + + return ret; +} + static struct dm_pmic_ops pca9450_ops = { .reg_count = pca9450_reg_count, .read = pca9450_read, @@ -94,5 +119,7 @@ U_BOOT_DRIVER(pmic_pca9450) = { .id = UCLASS_PMIC, .of_match = pca9450_ids, .bind = pca9450_bind, + .probe = pca9450_probe, .ops = &pca9450_ops, + .priv_auto = sizeof(struct pca9450_priv), }; -- 2.36.1