From: Pablo Mazzini <pmazzini@gmail.com>
To: Mark Brown <broonie@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>
Cc: Pablo Mazzini <pmazzini@gmail.com>,
Andreas Kemnade <andreas@kemnade.info>,
Alistair Francis <alistair@alistair23.me>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/7] regulator: sy7636a: add VCOM voltage control
Date: Sun, 1 Nov 2026 22:31:20 +0000 [thread overview]
Message-ID: <20261101223125.302001-3-pmazzini@gmail.com> (raw)
In-Reply-To: <20261101223125.302001-1-pmazzini@gmail.com>
VCOM is panel specific, so let boards set it in the devicetree. Switch
to the selector ops and add the write side.
Per the datasheet, VCOM bit 8 is bit 7 of register 0x02, not bit 0.
Reviewed-by: Andreas Kemnade <andreas@kemnade.info>
Signed-off-by: Pablo Mazzini <pmazzini@gmail.com>
---
drivers/regulator/sy7636a-regulator.c | 31 +++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/sy7636a-regulator.c b/drivers/regulator/sy7636a-regulator.c
index 015227cb113e..382bab017784 100644
--- a/drivers/regulator/sy7636a-regulator.c
+++ b/drivers/regulator/sy7636a-regulator.c
@@ -24,7 +24,7 @@ struct sy7636a_data {
struct gpio_desc *vcom_en_gpio;
};
-static int sy7636a_get_vcom_voltage_op(struct regulator_dev *rdev)
+static int sy7636a_get_vcom_voltage_sel(struct regulator_dev *rdev)
{
int ret;
unsigned int val, val_h;
@@ -37,9 +37,20 @@ static int sy7636a_get_vcom_voltage_op(struct regulator_dev *rdev)
if (ret)
return ret;
- val |= (val_h << VCOM_ADJUST_CTRL_SHIFT);
+ /* VCOM[8] is bit 7 of register 0x02 */
+ return val | (val_h & BIT(7)) << 1;
+}
- return (val & VCOM_ADJUST_CTRL_MASK) * VCOM_ADJUST_CTRL_SCAL;
+static int sy7636a_set_vcom_voltage_sel(struct regulator_dev *rdev, unsigned int sel)
+{
+ int ret;
+
+ ret = regmap_write(rdev->regmap, SY7636A_REG_VCOM_ADJUST_CTRL_L, sel & 0xff);
+ if (ret)
+ return ret;
+
+ return regmap_update_bits(rdev->regmap, SY7636A_REG_VCOM_ADJUST_CTRL_H, BIT(7),
+ (sel & BIT(8)) >> 1);
}
static int sy7636a_get_status(struct regulator_dev *rdev)
@@ -55,19 +66,31 @@ static int sy7636a_get_status(struct regulator_dev *rdev)
}
static const struct regulator_ops sy7636a_vcom_volt_ops = {
- .get_voltage = sy7636a_get_vcom_voltage_op,
+ .list_voltage = regulator_list_voltage_linear_range,
+ .map_voltage = regulator_map_voltage_linear_range,
+ .get_voltage_sel = sy7636a_get_vcom_voltage_sel,
+ .set_voltage_sel = sy7636a_set_vcom_voltage_sel,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.get_status = sy7636a_get_status,
};
+/* 10 mV steps up to 5 V, higher codes also give 5 V */
+static const struct linear_range sy7636a_vcom_ranges[] = {
+ REGULATOR_LINEAR_RANGE(0, 0x000, 0x1f4, VCOM_ADJUST_CTRL_SCAL),
+ REGULATOR_LINEAR_RANGE(5000000, 0x1f5, 0x1ff, 0),
+};
+
static const struct regulator_desc desc = {
.name = "vcom",
.id = 0,
.ops = &sy7636a_vcom_volt_ops,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
+ .n_voltages = VCOM_ADJUST_CTRL_MASK + 1,
+ .linear_ranges = sy7636a_vcom_ranges,
+ .n_linear_ranges = ARRAY_SIZE(sy7636a_vcom_ranges),
.enable_reg = SY7636A_REG_OPERATION_MODE_CRL,
.enable_mask = SY7636A_OPERATION_MODE_CRL_ONOFF,
.regulators_node = of_match_ptr("regulators"),
--
2.52.0
next prev parent reply other threads:[~2026-11-01 22:32 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-01 22:31 [PATCH v2 0/7] sy7636a: power the panel only during updates Pablo Mazzini
2026-11-01 22:31 ` [PATCH v2 1/7] regulator: sy7636a: fix the chip name Pablo Mazzini
2026-11-01 22:31 ` Pablo Mazzini [this message]
2026-11-01 22:31 ` [PATCH v2 3/7] regulator: sy7636a: wait for power good on enable Pablo Mazzini
2026-11-02 7:28 ` Andreas Kemnade
2026-11-02 13:30 ` Mark Brown
2026-11-02 17:08 ` Pablo Mazzini
2026-11-02 17:17 ` Mark Brown
2026-11-01 22:31 ` [PATCH v2 4/7] hwmon: sy7636a: fix negative temperatures Pablo Mazzini
2026-11-01 22:37 ` sashiko-bot
2026-11-01 22:31 ` [PATCH v2 5/7] hwmon: sy7636a: read the temperature only while the rails are on Pablo Mazzini
2026-11-01 22:51 ` sashiko-bot
2026-11-01 23:19 ` Pablo Mazzini
2026-11-02 0:54 ` Guenter Roeck
2026-11-02 3:35 ` Guenter Roeck
2026-11-02 8:09 ` Pablo Mazzini
2026-11-02 14:41 ` Guenter Roeck
2026-11-02 10:25 ` Andreas Kemnade
2026-11-02 14:43 ` Guenter Roeck
2026-11-02 17:09 ` Pablo Mazzini
2026-11-01 22:31 ` [PATCH v2 6/7] regulator: sy7636a: bind to the I2C device directly Pablo Mazzini
2026-11-01 22:40 ` sashiko-bot
2026-11-04 18:28 ` Andreas Kemnade
2026-11-04 19:31 ` Pablo Mazzini
2026-11-01 22:31 ` [PATCH v2 7/7] ARM: imx_v6_v7_defconfig: drop the SY7636A MFD option Pablo Mazzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261101223125.302001-3-pmazzini@gmail.com \
--to=pmazzini@gmail.com \
--cc=alistair@alistair23.me \
--cc=andreas@kemnade.info \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.