From nobody Fri Apr 10 02:09:53 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3DAAC636D4 for ; Mon, 13 Feb 2023 15:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231316AbjBMP76 (ORCPT ); Mon, 13 Feb 2023 10:59:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231310AbjBMP7q (ORCPT ); Mon, 13 Feb 2023 10:59:46 -0500 Received: from mail.fris.de (mail.fris.de [IPv6:2a01:4f8:c2c:390b::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 028182687; Mon, 13 Feb 2023 07:59:45 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2F64DC0176; Mon, 13 Feb 2023 16:59:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1676303984; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=1hMuNgLfmYKnEteM9D2HKTHTutb/TpNG5wgcFSK2t6I=; b=EYOHLaahGl9AS5iE/8SSCDIFFURc8P60qTcUkxBkiX+UIXON6UQC+WV3qmIwjAQmyUp6iS 01fYBcrJOXFxoOnhZ/NxCFoINDiNw5CuU6m4zL2lol829B2DEvVMGpw+Ka2r4K1GiNtohP LZaWUFbQvPH4AygtVS84gUZT8TsAmqelmsVW3IOA67Fl4u40xHr9UvOkrQKVgXL4iz3/bK rD0Vap2FcH68o11+3G1A0pZDyGT2Y09t+i0ekuqhqUHcMJQWzjt8i/3qCMP6hUnW2B7xw7 N7b3wJh+dDIs5CEGTvTbVhuGjfEw6IEWGMAf4GxsP764IPKUM751BZHog+azPg== From: Frieder Schrempf To: devicetree@vger.kernel.org, Krzysztof Kozlowski , Liam Girdwood , linux-kernel@vger.kernel.org, Mark Brown , Rob Herring , Robin Gong Cc: Marek Vasut , Frieder Schrempf , Per-Daniel Olsson , Rickard x Andersson Subject: [PATCH 1/6] dt-bindings: regulator: pca9450: Document new usage of sd-vsel-gpios Date: Mon, 13 Feb 2023 16:58:19 +0100 Message-Id: <20230213155833.1644366-2-frieder@fris.de> In-Reply-To: <20230213155833.1644366-1-frieder@fris.de> References: <20230213155833.1644366-1-frieder@fris.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Frieder Schrempf The sd-vsel-gpios property is abandoned in its current meaning as an output. We now use it to specify an optional signal that can be evaluated by the driver in order to retrieve the current status of the SD_VSEL signal that is used to select the control register of LDO5. Signed-off-by: Frieder Schrempf --- .../regulator/nxp,pca9450-regulator.yaml | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/regulator/nxp,pca9450-regula= tor.yaml b/Documentation/devicetree/bindings/regulator/nxp,pca9450-regulato= r.yaml index 835b53302db8..c86534538a4e 100644 --- a/Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml @@ -40,8 +40,24 @@ properties: description: | list of regulators provided by this controller =20 + properties: + LDO5: + type: object + $ref: regulator.yaml# + description: + Properties for single LDO5 regulator. + + properties: + sd-vsel-gpios: + description: + GPIO that can be used to read the current status of the SD_V= SEL + signal in order for the driver to know if LDO5CTRL_L or LDO5= CTRL_H + is used by the hardware. + + unevaluatedProperties: false + patternProperties: - "^LDO[1-5]$": + "^LDO[1-4]$": type: object $ref: regulator.yaml# description: @@ -76,11 +92,6 @@ properties: =20 additionalProperties: false =20 - sd-vsel-gpios: - description: GPIO that is used to switch LDO5 between being configured= by - LDO5CTRL_L or LDO5CTRL_H register. Use this if the SD_VSEL signal is - connected to a host GPIO. - nxp,i2c-lt-enable: type: boolean description: --=20 2.39.1 From nobody Fri Apr 10 02:09:53 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B4CAC6379F for ; Mon, 13 Feb 2023 16:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231332AbjBMQAB (ORCPT ); Mon, 13 Feb 2023 11:00:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231342AbjBMP7t (ORCPT ); Mon, 13 Feb 2023 10:59:49 -0500 Received: from mail.fris.de (mail.fris.de [116.203.77.234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19783170B for ; Mon, 13 Feb 2023 07:59:49 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EC8DAC02BF; Mon, 13 Feb 2023 16:59:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1676303987; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=6iA7zvhCM9q7q6dbgNS6li/HQ1lUJFB2cdCiJIYXUAY=; b=f8mC/UOC3TTm5KwZSo3d8k+CF/vb70jWnIhv9+6rT3k/T/rdQr7/xvnmyrP7ZW1TiUYiMr wWQ9OB1WOJs/6lc3xu/459Q/2PHcyP+P3MuJyuaN7SOH/fvI9OWCDF3i4B+KOhTqcfy23d /VM9bE0Q2tI4UDlZzPe53PvvSmvEZoggp0S8fWHoq5A+k+hSGR/QtR4ATRBqmveKRo7HDY NZNRJpfRCX8U7TvnXjYgIJ02HZpHFZnC+61jdkVMVhUmx173aFWqkqKQI63oo/wYHz1Fh9 LhUanw4BF3IL5Nd2qKxE7hQkqNdEEWO7LtZDOsOsslIbWnrzCukbwSEQaeCTFA== From: Frieder Schrempf To: Frieder Schrempf , Liam Girdwood , linux-kernel@vger.kernel.org, Mark Brown , Robin Gong Cc: Marek Vasut , Per-Daniel Olsson , Rickard x Andersson , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Subject: [PATCH 2/6] regulator: pca9450: Fix enable register for LDO5 Date: Mon, 13 Feb 2023 16:58:20 +0100 Message-Id: <20230213155833.1644366-3-frieder@fris.de> In-Reply-To: <20230213155833.1644366-1-frieder@fris.de> References: <20230213155833.1644366-1-frieder@fris.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Frieder Schrempf The LDO5 regulator has two configuration registers, but only LDO5CTRL_L contains the bits for enabling/disabling the regulator. Fixes: 0935ff5f1f0a ("regulator: pca9450: add pca9450 pmic driver") Signed-off-by: Frieder Schrempf Reviewed-by: Marek Vasut --- drivers/regulator/pca9450-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/pca9450-regulator.c b/drivers/regulator/pca9= 450-regulator.c index c6351fac9f4d..a815666566b5 100644 --- a/drivers/regulator/pca9450-regulator.c +++ b/drivers/regulator/pca9450-regulator.c @@ -447,7 +447,7 @@ static const struct pca9450_regulator_desc pca9450a_reg= ulators[] =3D { .n_linear_ranges =3D ARRAY_SIZE(pca9450_ldo5_volts), .vsel_reg =3D PCA9450_REG_LDO5CTRL_H, .vsel_mask =3D LDO5HOUT_MASK, - .enable_reg =3D PCA9450_REG_LDO5CTRL_H, + .enable_reg =3D PCA9450_REG_LDO5CTRL_L, .enable_mask =3D LDO5H_EN_MASK, .owner =3D THIS_MODULE, }, @@ -656,7 +656,7 @@ static const struct pca9450_regulator_desc pca9450bc_re= gulators[] =3D { .n_linear_ranges =3D ARRAY_SIZE(pca9450_ldo5_volts), .vsel_reg =3D PCA9450_REG_LDO5CTRL_H, .vsel_mask =3D LDO5HOUT_MASK, - .enable_reg =3D PCA9450_REG_LDO5CTRL_H, + .enable_reg =3D PCA9450_REG_LDO5CTRL_L, .enable_mask =3D LDO5H_EN_MASK, .owner =3D THIS_MODULE, }, --=20 2.39.1 From nobody Fri Apr 10 02:09:53 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 157E5C636D4 for ; Mon, 13 Feb 2023 16:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231342AbjBMQAE (ORCPT ); Mon, 13 Feb 2023 11:00:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231377AbjBMP7y (ORCPT ); Mon, 13 Feb 2023 10:59:54 -0500 Received: from mail.fris.de (mail.fris.de [116.203.77.234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3061B170B for ; Mon, 13 Feb 2023 07:59:53 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 62C89C02BC; Mon, 13 Feb 2023 16:59:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1676303991; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=ewI3/QSFAFiKru2ko/nlJ095/aScxxTskV5+d8BLT6c=; b=MkxlcLA52COrYKwd2SoBvgutpxQZJImOoLVAkw9FeZ0nceRbak4lumMdpIsJWoWID4tQRy hXWpOQsrdLwCpl6poVxqDhir0lWNz+xjFxc+tiVvZIKLci6ydHnApMYS2+PvXWL076oQoF 9PXOo4LXv3qKFGSpwp00Up0AGN+l52Gj0j9BeCYNS3261Ixeeh9F5jUZMICnG+6nm8EXrN F9HcpKZYsherzW3CZcwXkhAZQGwsEa6F72qeP4N+qIhTQFAK5SUDmjsgoqqQBE3WQdvrWF onBq0yzO+ykz3kQC+lggNTL5DTqfHpbx72fqzWH3cLOsXV7ttWhy49Bdv2VTqQ== From: Frieder Schrempf To: Liam Girdwood , linux-kernel@vger.kernel.org, Mark Brown Cc: Marek Vasut , Frieder Schrempf , Per-Daniel Olsson , Rickard x Andersson , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Subject: [PATCH 3/6] Revert "regulator: pca9450: Add SD_VSEL GPIO for LDO5" Date: Mon, 13 Feb 2023 16:58:21 +0100 Message-Id: <20230213155833.1644366-4-frieder@fris.de> In-Reply-To: <20230213155833.1644366-1-frieder@fris.de> References: <20230213155833.1644366-1-frieder@fris.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Frieder Schrempf This reverts commit 8c67a11bae889f51fe5054364c3c789dfae3ad73. It turns out that all boards using the PCA9450 actually have the SD_VSEL input conencted to the VSELECT signal of the SoCs SD/MMC interface. Therefore we don't need manual control for this signal via GPIO and threre aren't any users. Signed-off-by: Frieder Schrempf --- drivers/regulator/pca9450-regulator.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/regulator/pca9450-regulator.c b/drivers/regulator/pca9= 450-regulator.c index a815666566b5..804a22c0e376 100644 --- a/drivers/regulator/pca9450-regulator.c +++ b/drivers/regulator/pca9450-regulator.c @@ -5,7 +5,6 @@ */ =20 #include -#include #include #include #include @@ -33,7 +32,6 @@ struct pca9450_regulator_desc { struct pca9450 { struct device *dev; struct regmap *regmap; - struct gpio_desc *sd_vsel_gpio; enum pca9450_chip_type type; unsigned int rcnt; int irq; @@ -834,18 +832,6 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) } } =20 - /* - * The driver uses the LDO5CTRL_H register to control the LDO5 regulator. - * This is only valid if the SD_VSEL input of the PMIC is high. Let's - * check if the pin is available as GPIO and set it to high. - */ - pca9450->sd_vsel_gpio =3D gpiod_get_optional(pca9450->dev, "sd-vsel", GPI= OD_OUT_HIGH); - - if (IS_ERR(pca9450->sd_vsel_gpio)) { - dev_err(&i2c->dev, "Failed to get SD_VSEL GPIO\n"); - return PTR_ERR(pca9450->sd_vsel_gpio); - } - dev_info(&i2c->dev, "%s probed.\n", type =3D=3D PCA9450_TYPE_PCA9450A ? "pca9450a" : "pca9450bc"); =20 --=20 2.39.1 From nobody Fri Apr 10 02:09:53 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A3F4C636D4 for ; Mon, 13 Feb 2023 16:00:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231339AbjBMQAK (ORCPT ); Mon, 13 Feb 2023 11:00:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231334AbjBMQAF (ORCPT ); Mon, 13 Feb 2023 11:00:05 -0500 Received: from mail.fris.de (mail.fris.de [116.203.77.234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA741E5E5 for ; Mon, 13 Feb 2023 08:00:01 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 44F21BFC15; Mon, 13 Feb 2023 16:59:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1676304000; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=puyx+iiRxk3cL3YhVNnHADs9ip7L0cjTR7aBYLsdwyo=; b=tmp9fOASxyTRGGPhZxA+uJ0cpOaxeKHEW7pENeYZ2WDn4rMWliOwJ3O7kG1j342DA7FyNy RZOLozTbA2I5K6Q4b1MHUWN1Zl2IEUH965pSkIwnUPJJBaQQP5nKqtiUo2oBiaTjrQOPwd eeUKCbdp1G29MGQz+n2lWzvurenzsPS3aSty2HDdjiLq5hxdBNCBhD/evPzxeZab//S09j AFakjs0zCwqgKVI/ggtzhJUpU3XrYYS8qXhmOjqNmYTh2qrk5hp/J39kc2AUFAi4rKDyI7 9kXiMB/JZLoJMO8S8DNGH3nBCtKRY8UwEJr9iM34MYsOY21N2y6/zDNctmHE8Q== From: Frieder Schrempf To: Liam Girdwood , linux-kernel@vger.kernel.org, Mark Brown Cc: Marek Vasut , Frieder Schrempf , ChiYuan Huang , Mauro Carvalho Chehab Subject: [PATCH 4/6] regulator: Add operation to let drivers select vsel register Date: Mon, 13 Feb 2023 16:58:22 +0100 Message-Id: <20230213155833.1644366-5-frieder@fris.de> In-Reply-To: <20230213155833.1644366-1-frieder@fris.de> References: <20230213155833.1644366-1-frieder@fris.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Frieder Schrempf There are regulators that use multiple registers for storing the voltage. Add a get_reg_voltage_sel member to struct regulator_ops in order to let drivers register a function that returns the currently used register. The pca9450 driver will be a user of this as the LDO5 regulator of that chip uses two different control registers depending on the state of an external signal. Signed-off-by: Frieder Schrempf --- drivers/regulator/helpers.c | 16 ++++++++++++++-- include/linux/regulator/driver.h | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index ad2237a95572..e629b0bea3d0 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -223,6 +223,16 @@ int regulator_set_voltage_sel_pickable_regmap(struct r= egulator_dev *rdev, } EXPORT_SYMBOL_GPL(regulator_set_voltage_sel_pickable_regmap); =20 +unsigned int regulator_get_hwreg_voltage_sel_regmap(struct regulator_dev *= rdev) +{ + const struct regulator_ops *ops =3D rdev->desc->ops; + + if (ops->get_reg_voltage_sel) + return ops->get_reg_voltage_sel(rdev); + + return rdev->desc->vsel_reg; +} + /** * regulator_get_voltage_sel_regmap - standard get_voltage_sel for regmap = users * @@ -234,10 +244,11 @@ EXPORT_SYMBOL_GPL(regulator_set_voltage_sel_pickable_= regmap); */ int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev) { + unsigned int vsel_reg =3D regulator_get_hwreg_voltage_sel_regmap(rdev); unsigned int val; int ret; =20 - ret =3D regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); + ret =3D regmap_read(rdev->regmap, vsel_reg, &val); if (ret !=3D 0) return ret; =20 @@ -260,11 +271,12 @@ EXPORT_SYMBOL_GPL(regulator_get_voltage_sel_regmap); */ int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned = sel) { + unsigned int vsel_reg =3D regulator_get_hwreg_voltage_sel_regmap(rdev); int ret; =20 sel <<=3D ffs(rdev->desc->vsel_mask) - 1; =20 - ret =3D regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg, + ret =3D regmap_update_bits(rdev->regmap, vsel_reg, rdev->desc->vsel_mask, sel); if (ret) return ret; diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/dri= ver.h index d3b4a3d4514a..c9953b2f63d5 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -77,6 +77,10 @@ enum regulator_detection_severity { * @get_voltage_sel: Return the currently configured voltage selector for = the * regulator; return -ENOTRECOVERABLE if regulator can't * be read at bootup and hasn't been set yet. + * @get_reg_voltage_sel: Return the register used for getting/setting the + * voltage of the regulator. This is useful if the + * regulator uses multiple registers internally, swi= tched + * by some condition like the state of an external s= ignal. * @list_voltage: Return one of the supported voltages, in microvolts; zero * if the selector indicates a voltage that is unusable on this system; * or negative errno. Selectors range from zero to one less than @@ -168,6 +172,7 @@ struct regulator_ops { int (*set_voltage_sel) (struct regulator_dev *, unsigned selector); int (*get_voltage) (struct regulator_dev *); int (*get_voltage_sel) (struct regulator_dev *); + unsigned int (*get_reg_voltage_sel) (struct regulator_dev *); =20 /* get/set regulator current */ int (*set_current_limit) (struct regulator_dev *, --=20 2.39.1 From nobody Fri Apr 10 02:09:53 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8066EC636CC for ; Mon, 13 Feb 2023 16:00:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbjBMQAX (ORCPT ); Mon, 13 Feb 2023 11:00:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231350AbjBMQAS (ORCPT ); Mon, 13 Feb 2023 11:00:18 -0500 Received: from mail.fris.de (mail.fris.de [116.203.77.234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3BB91C5B4 for ; Mon, 13 Feb 2023 08:00:07 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1D720BFC15; Mon, 13 Feb 2023 17:00:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1676304005; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=hUmCZGE2wb9knP0v6NH5JhHMF782alLAiH/tuWKzmDI=; b=CA2KQRUaBqNL3lxReuQirhcBjLTKO4rM3/huFqcxhar9gVyheiCLb+3i//IttMumrfJtqy tB0oCBpnSetCEqlQ3i/Y36KbHYo93Uwx0V4TlQh57MRgCK2DP/XHkobUVftj83QCcqa5bm spg+7uyL4fI7No4HAH/iavXn3MWSFSI8+XdoWlPqwKPc5Bxa5ddj1ru1Ugogt/YW8KApfR J03OQf+8zlEbbiiO4dfzTTuHZ3R8duWPvFe2Gk27Ma4KgUfClLW4Ykfka8nC8a/1vmdtxh 8DuL9b0jS7rFZyZ0s86ErGXorNcUCdC0IfQgtxovX0sRjG/nbgjbcL2kGIDwrQ== From: Frieder Schrempf To: Liam Girdwood , linux-kernel@vger.kernel.org, Mark Brown Cc: Marek Vasut , Frieder Schrempf , Per-Daniel Olsson , Rickard x Andersson , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Subject: [PATCH 5/6] regulator: pca9450: Fix control register for LDO5 Date: Mon, 13 Feb 2023 16:58:23 +0100 Message-Id: <20230213155833.1644366-6-frieder@fris.de> In-Reply-To: <20230213155833.1644366-1-frieder@fris.de> References: <20230213155833.1644366-1-frieder@fris.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Frieder Schrempf For LDO5 we need to be able to check the status of the SD_VSEL input in order to know which control register is used. Read the status of the SD_VSEL signal via GPIO and add a get_reg_voltage_sel operation for LDO5 that returns the register that is currently in use to the core. Signed-off-by: Frieder Schrempf --- drivers/regulator/pca9450-regulator.c | 45 ++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/pca9450-regulator.c b/drivers/regulator/pca9= 450-regulator.c index 804a22c0e376..a0802c6cb259 100644 --- a/drivers/regulator/pca9450-regulator.c +++ b/drivers/regulator/pca9450-regulator.c @@ -5,6 +5,7 @@ */ =20 #include +#include #include #include #include @@ -32,6 +33,7 @@ struct pca9450_regulator_desc { struct pca9450 { struct device *dev; struct regmap *regmap; + struct gpio_desc *sd_vsel_gpio; enum pca9450_chip_type type; unsigned int rcnt; int irq; @@ -55,6 +57,16 @@ static const struct regmap_config pca9450_regmap_config = =3D { .cache_type =3D REGCACHE_RBTREE, }; =20 +static unsigned int pca9450_ldo5_get_reg_voltage_sel(struct regulator_dev = *rdev) +{ + struct pca9450 *pca9450 =3D rdev_get_drvdata(rdev); + + if (pca9450->sd_vsel_gpio && !gpiod_get_value(pca9450->sd_vsel_gpio)) + return PCA9450_REG_LDO5CTRL_L; + + return PCA9450_REG_LDO5CTRL_H; +} + /* * BUCK1/2/3 * BUCK1RAM[1:0] BUCK1 DVS ramp rate setting @@ -97,6 +109,16 @@ static const struct regulator_ops pca9450_ldo_regulator= _ops =3D { .get_voltage_sel =3D regulator_get_voltage_sel_regmap, }; =20 +static const struct regulator_ops pca9450_ldo5_regulator_ops =3D { + .enable =3D regulator_enable_regmap, + .disable =3D regulator_disable_regmap, + .is_enabled =3D regulator_is_enabled_regmap, + .list_voltage =3D regulator_list_voltage_linear_range, + .set_voltage_sel =3D regulator_set_voltage_sel_regmap, + .get_voltage_sel =3D regulator_get_voltage_sel_regmap, + .get_reg_voltage_sel =3D pca9450_ldo5_get_reg_voltage_sel, +}; + /* * BUCK1/2/3 * 0.60 to 2.1875V (12.5mV step) @@ -438,12 +460,11 @@ static const struct pca9450_regulator_desc pca9450a_r= egulators[] =3D { .of_match =3D of_match_ptr("LDO5"), .regulators_node =3D of_match_ptr("regulators"), .id =3D PCA9450_LDO5, - .ops =3D &pca9450_ldo_regulator_ops, + .ops =3D &pca9450_ldo5_regulator_ops, .type =3D REGULATOR_VOLTAGE, .n_voltages =3D PCA9450_LDO5_VOLTAGE_NUM, .linear_ranges =3D pca9450_ldo5_volts, .n_linear_ranges =3D ARRAY_SIZE(pca9450_ldo5_volts), - .vsel_reg =3D PCA9450_REG_LDO5CTRL_H, .vsel_mask =3D LDO5HOUT_MASK, .enable_reg =3D PCA9450_REG_LDO5CTRL_L, .enable_mask =3D LDO5H_EN_MASK, @@ -647,12 +668,11 @@ static const struct pca9450_regulator_desc pca9450bc_= regulators[] =3D { .of_match =3D of_match_ptr("LDO5"), .regulators_node =3D of_match_ptr("regulators"), .id =3D PCA9450_LDO5, - .ops =3D &pca9450_ldo_regulator_ops, + .ops =3D &pca9450_ldo5_regulator_ops, .type =3D REGULATOR_VOLTAGE, .n_voltages =3D PCA9450_LDO5_VOLTAGE_NUM, .linear_ranges =3D pca9450_ldo5_volts, .n_linear_ranges =3D ARRAY_SIZE(pca9450_ldo5_volts), - .vsel_reg =3D PCA9450_REG_LDO5CTRL_H, .vsel_mask =3D LDO5HOUT_MASK, .enable_reg =3D PCA9450_REG_LDO5CTRL_L, .enable_mask =3D LDO5H_EN_MASK, @@ -705,6 +725,7 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) of_device_get_match_data(&i2c->dev); const struct pca9450_regulator_desc *regulator_desc; struct regulator_config config =3D { }; + struct regulator_dev *ldo5; struct pca9450 *pca9450; unsigned int device_id, i; unsigned int reset_ctrl; @@ -770,6 +791,7 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) =20 config.regmap =3D pca9450->regmap; config.dev =3D pca9450->dev; + config.driver_data =3D pca9450; =20 rdev =3D devm_regulator_register(pca9450->dev, desc, &config); if (IS_ERR(rdev)) { @@ -779,6 +801,9 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) desc->name, ret); return ret; } + + if (!strcmp(desc->name, "ldo5")) + ldo5 =3D rdev; } =20 ret =3D devm_request_threaded_irq(pca9450->dev, pca9450->irq, NULL, @@ -832,6 +857,18 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) } } =20 + /* + * For LDO5 we need to be able to check the status of the SD_VSEL input in + * order to know which control register is used. Most boards connect SD_V= SEL + * to the VSELECT signal, so we can use the GPIO that is internally routed + * to this signal (if SION bit is set in IOMUX). + */ + pca9450->sd_vsel_gpio =3D gpiod_get_optional(&ldo5->dev, "sd-vsel", GPIOD= _IN); + if (IS_ERR(pca9450->sd_vsel_gpio)) { + dev_err(&i2c->dev, "Failed to get SD_VSEL GPIO\n"); + return ret; + } + dev_info(&i2c->dev, "%s probed.\n", type =3D=3D PCA9450_TYPE_PCA9450A ? "pca9450a" : "pca9450bc"); =20 --=20 2.39.1 From nobody Fri Apr 10 02:09:53 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 167D5C636D4 for ; Mon, 13 Feb 2023 16:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231348AbjBMQBG (ORCPT ); Mon, 13 Feb 2023 11:01:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbjBMQBE (ORCPT ); Mon, 13 Feb 2023 11:01:04 -0500 Received: from mail.fris.de (mail.fris.de [IPv6:2a01:4f8:c2c:390b::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADFE6170B; Mon, 13 Feb 2023 08:00:53 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EBEF3BFBAC; Mon, 13 Feb 2023 17:00:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1676304051; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=64grUIMOl3DlMA5X19kZ/0poE7psMX9YME1d/5PcVes=; b=L1VOGI7OPRvZoeEBiIL1YvtAeloc7cXo3N7YfGaR5Hi1zjjfZ5jesKbiFzSvYqAhnI9AZF 5OSEmWIZIcsKIWFFN1UTBEljQoqM3M9ZjYKXJTZu8ycyPP/T0eusqmZKlgyWhMVdos9mwR fE20FwWJbTN6Ez+EuVTv2B5PcQuHrgdQVCaWncDr6laHOVhuIT0B/UcFZa2qdvp/KupjFm Qqcdwu+SFZDcrbZwnyl4oHCjvhMzQ1tm++X+d+hm01mV/d8Qcc0An/a2Ua9m7jkCZDR8W0 mbch8+RupRbo5WEChlWVcAwnBvBRaMVywoVog+751zcBgsztjq5hR2bBeTPk8g== From: Frieder Schrempf To: devicetree@vger.kernel.org, Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Rob Herring , Sascha Hauer , Shawn Guo Cc: Marek Vasut , Frieder Schrempf , Fabio Estevam , Heiko Thiery , Krzysztof Kozlowski , NXP Linux Team , Oleksij Rempel , Pengutronix Kernel Team Subject: [PATCH 6/6] arm64: dts: imx8mm-kontron: Add support for reading SD_VSEL signal Date: Mon, 13 Feb 2023 16:58:24 +0100 Message-Id: <20230213155833.1644366-7-frieder@fris.de> In-Reply-To: <20230213155833.1644366-1-frieder@fris.de> References: <20230213155833.1644366-1-frieder@fris.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Frieder Schrempf This fixes the LDO5 regulator handling of the pca9450 driver by taking the status of the SD_VSEL into account to determine which configuration register is used for the voltage setting. Even without this change there is no functional issue, as the code for switching the voltage in sdhci.c currently switches both, the VSELECT/SD_VSEL signal and the regulator voltage at the same time and doesn't run into an invalid corner case. We should still make sure, that we always use the correct register when controlling the regulator. At least in U-Boot this fixes an actual bug where the wrong IO voltage is used. Signed-off-by: Frieder Schrempf --- arch/arm64/boot/dts/freescale/imx8mm-kontron-bl-osm-s.dts | 6 +++--- arch/arm64/boot/dts/freescale/imx8mm-kontron-bl.dts | 6 +++--- arch/arm64/boot/dts/freescale/imx8mm-kontron-osm-s.dtsi | 1 + arch/arm64/boot/dts/freescale/imx8mm-kontron-sl.dtsi | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mm-kontron-bl-osm-s.dts b/ar= ch/arm64/boot/dts/freescale/imx8mm-kontron-bl-osm-s.dts index 8b16bd68576c..bdcd9cd843c7 100644 --- a/arch/arm64/boot/dts/freescale/imx8mm-kontron-bl-osm-s.dts +++ b/arch/arm64/boot/dts/freescale/imx8mm-kontron-bl-osm-s.dts @@ -344,7 +344,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d0 MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d0 MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d0 MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO12 0x019 - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x1d0 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x400001d0 >; }; =20 @@ -357,7 +357,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d4 MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d4 MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d4 MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO12 0x019 - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x1d0 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x400001d0 >; }; =20 @@ -370,7 +370,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d6 MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d6 MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d6 MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO12 0x019 - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x1d0 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x400001d0 >; }; }; diff --git a/arch/arm64/boot/dts/freescale/imx8mm-kontron-bl.dts b/arch/arm= 64/boot/dts/freescale/imx8mm-kontron-bl.dts index a079322a3793..ba2a4491cf31 100644 --- a/arch/arm64/boot/dts/freescale/imx8mm-kontron-bl.dts +++ b/arch/arm64/boot/dts/freescale/imx8mm-kontron-bl.dts @@ -321,7 +321,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d0 MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d0 MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d0 MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO12 0x019 - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x1d0 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x400001d0 >; }; =20 @@ -334,7 +334,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d4 MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d4 MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d4 MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO12 0x019 - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x1d0 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x400001d0 >; }; =20 @@ -347,7 +347,7 @@ MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1 0x1d6 MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d6 MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d6 MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO12 0x019 - MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x1d0 + MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT 0x400001d0 >; }; }; diff --git a/arch/arm64/boot/dts/freescale/imx8mm-kontron-osm-s.dtsi b/arch= /arm64/boot/dts/freescale/imx8mm-kontron-osm-s.dtsi index 5172883717d1..90daaf54e704 100644 --- a/arch/arm64/boot/dts/freescale/imx8mm-kontron-osm-s.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8mm-kontron-osm-s.dtsi @@ -196,6 +196,7 @@ reg_nvcc_sd: LDO5 { regulator-name =3D "NVCC_SD (LDO5)"; regulator-min-microvolt =3D <1800000>; regulator-max-microvolt =3D <3300000>; + sd-vsel-gpios =3D <&gpio1 4 GPIO_ACTIVE_HIGH>; }; }; }; diff --git a/arch/arm64/boot/dts/freescale/imx8mm-kontron-sl.dtsi b/arch/ar= m64/boot/dts/freescale/imx8mm-kontron-sl.dtsi index 1f8326613ee9..7468a8aa771d 100644 --- a/arch/arm64/boot/dts/freescale/imx8mm-kontron-sl.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8mm-kontron-sl.dtsi @@ -195,6 +195,7 @@ reg_nvcc_sd: LDO5 { regulator-name =3D "NVCC_SD (LDO5)"; regulator-min-microvolt =3D <1800000>; regulator-max-microvolt =3D <3300000>; + sd-vsel-gpios =3D <&gpio1 4 GPIO_ACTIVE_HIGH>; }; }; }; --=20 2.39.1