From: Andreas Kemnade <andreas@kemnade.info>
To: Pablo Mazzini <pmazzini@gmail.com>
Cc: Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Alistair Francis <alistair@alistair23.me>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/7] regulator: sy7636a: wait for power good on enable
Date: Mon, 2 Nov 2026 08:28:34 +0100 [thread overview]
Message-ID: <20261102082834.0f808c8a@kemnade.info> (raw)
In-Reply-To: <20261101223125.302001-4-pmazzini@gmail.com>
On Sun, 1 Nov 2026 22:31:21 +0000
Pablo Mazzini <pmazzini@gmail.com> wrote:
> Wait for power good on enable, as the TPS65185 and FP9931 drivers do,
> so that consumers can use the rails once the enable returns.
>
> Signed-off-by: Pablo Mazzini <pmazzini@gmail.com>
Reviewed-by: Andreas Kemnade <andreas@kemnade.info>
Regards,
Andreas
> ---
> drivers/regulator/sy7636a-regulator.c | 52 +++++++++++++++++++++++++--
> 1 file changed, 50 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/regulator/sy7636a-regulator.c b/drivers/regulator/sy7636a-regulator.c
> index 382bab017784..f87144e921da 100644
> --- a/drivers/regulator/sy7636a-regulator.c
> +++ b/drivers/regulator/sy7636a-regulator.c
> @@ -7,8 +7,10 @@
> // Authors: Lars Ivar Miljeteig <lars.ivar.miljeteig@remarkable.com>
> // Alistair Francis <alistair@alistair23.me>
>
> +#include <linux/completion.h>
> #include <linux/gpio/consumer.h>
> #include <linux/i2c.h>
> +#include <linux/interrupt.h>
> #include <linux/mfd/sy7636a.h>
> #include <linux/module.h>
> #include <linux/platform_device.h>
> @@ -17,11 +19,14 @@
> #include <linux/regulator/machine.h>
> #include <linux/regmap.h>
>
> +#define PGOOD_TIMEOUT_MSECS 200
> +
> struct sy7636a_data {
> struct regmap *regmap;
> struct gpio_desc *pgood_gpio;
> struct gpio_desc *en_gpio;
> struct gpio_desc *vcom_en_gpio;
> + struct completion pgood_completion;
> };
>
> static int sy7636a_get_vcom_voltage_sel(struct regulator_dev *rdev)
> @@ -65,12 +70,43 @@ static int sy7636a_get_status(struct regulator_dev *rdev)
> return ret;
> }
>
> +static irqreturn_t sy7636a_pgood_handler(int irq, void *dev_id)
> +{
> + struct sy7636a_data *data = dev_id;
> +
> + complete(&data->pgood_completion);
> +
> + return IRQ_HANDLED;
> +}
> +
> +/* return once the rails are good, so that consumers can use them */
> +static int sy7636a_enable(struct regulator_dev *rdev)
> +{
> + struct sy7636a_data *data = dev_get_drvdata(rdev->dev.parent);
> + int ret;
> +
> + reinit_completion(&data->pgood_completion);
> + ret = regulator_enable_regmap(rdev);
> + if (ret)
> + return ret;
> +
> + wait_for_completion_timeout(&data->pgood_completion,
> + msecs_to_jiffies(PGOOD_TIMEOUT_MSECS));
> + ret = gpiod_get_value_cansleep(data->pgood_gpio);
> + if (ret <= 0) {
> + regulator_disable_regmap(rdev);
> + return ret ? ret : -ETIMEDOUT;
> + }
> +
> + return 0;
> +}
> +
> static const struct regulator_ops sy7636a_vcom_volt_ops = {
> .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,
> + .enable = sy7636a_enable,
> .disable = regulator_disable_regmap,
> .is_enabled = regulator_is_enabled_regmap,
> .get_status = sy7636a_get_status,
> @@ -104,7 +140,7 @@ static int sy7636a_regulator_probe(struct platform_device *pdev)
> struct regulator_dev *rdev;
> struct gpio_desc *gdp;
> struct sy7636a_data *data;
> - int ret;
> + int irq, ret;
>
> if (!regmap)
> return -EPROBE_DEFER;
> @@ -156,6 +192,18 @@ static int sy7636a_regulator_probe(struct platform_device *pdev)
> return ret;
> }
>
> + irq = gpiod_to_irq(data->pgood_gpio);
> + if (irq < 0)
> + return dev_err_probe(&pdev->dev, irq, "no power good interrupt\n");
> +
> + init_completion(&data->pgood_completion);
> + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, sy7636a_pgood_handler,
> + IRQF_TRIGGER_RISING | IRQF_ONESHOT,
> + "sy7636a-pgood", data);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "failed to request power good interrupt\n");
> +
> config.dev = &pdev->dev;
> config.regmap = regmap;
>
next prev parent reply other threads:[~2026-11-02 7:28 UTC|newest]
Thread overview: 12+ 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 ` [PATCH v2 2/7] regulator: sy7636a: add VCOM voltage control Pablo Mazzini
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 [this message]
2026-11-01 22:31 ` [PATCH v2 4/7] hwmon: sy7636a: fix negative temperatures Pablo Mazzini
2026-11-01 22:31 ` [PATCH v2 5/7] hwmon: sy7636a: read the temperature only while the rails are on Pablo Mazzini
2026-11-02 3:35 ` Guenter Roeck
2026-11-02 8:09 ` Pablo Mazzini
2026-11-02 10:25 ` Andreas Kemnade
2026-11-01 22:31 ` [PATCH v2 6/7] regulator: sy7636a: bind to the I2C device directly 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=20261102082834.0f808c8a@kemnade.info \
--to=andreas@kemnade.info \
--cc=alistair@alistair23.me \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmazzini@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®