From mboxrd@z Thu Jan 1 00:00:00 1970 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 AF57CC43334 for ; Mon, 27 Jun 2022 11:01:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B0BC83AE6; Mon, 27 Jun 2022 13:01:11 +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="CqBnHuUA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 82E1B842E0; Mon, 27 Jun 2022 13:01:09 +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 0E3ED83AE6 for ; Mon, 27 Jun 2022 13:01:07 +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 56743C0112; Mon, 27 Jun 2022 13:01:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1656327665; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=grq52laGoTKgvAbYA3+WieFuPBZdxFVlmQVUq0OjOjw=; b=CqBnHuUA4BSkuIGogjAnSDaXm1+19Da/OF2hZJOVL4hsu5/d9FpvO0ukBhIwbcruYfiIWI /65C77pRne0fav7/TSZhLt90XvSJqHVHRi1b+7gJoIvRgnWBJi+wA8yzY7bOFS3XwegJc4 gSWunBJlrD+PBKt8m8od6vpzEe6X9H5lUXWLLqo/XIqBVwrlm4BVHmsjcnSOf3jU4qxYD9 8cTcQyQM5llwhHig3cTflY7Y+nLf6siK49AHtlnLayK6mh65ynFqV7aJQgjhWpgZ8bT2u4 ngQDSfdojH+hwf503C4Phjv4pAuiZt26vt8DEkXZ8vsxHDVr+/+MdWllgCFoJA== From: Frieder Schrempf To: Tom Rini , Jaehoon Chung , u-boot@lists.denx.de Cc: Heiko Thiery , Frieder Schrempf , Fabio Estevam , Marek Vasut Subject: [PATCH v2 1/2] pmic: pca9450: Add optional SD_VSEL GPIO for LDO5 Date: Mon, 27 Jun 2022 13:00:58 +0200 Message-Id: <20220627110100.130033-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 Reviewed-by: Fabio Estevam --- Changes in v2: * Add Fabio's R-b (Thanks!) * Use CONFIG_IS_ENABLED() instead of IS_ENABLED(CONFIG_*) to properly detect the options for SPL. --- 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..a186edc08da 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 (CONFIG_IS_ENABLED(DM_GPIO) && CONFIG_IS_ENABLED(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