2021-08-16 03:21:25

by Jianqun Xu

[permalink] [raw]
Subject: [PATCH 0/4] regulator pre-enable

Rockchip io-domain care about regulator pre-enable

Jianqun Xu (4):
regulator: add PRE_ENABLE event define
regulator: core: notify regulator enable with the voltage value
regulator: core: add pre-enable event notify to regulator
soc: rockchip: io-domain: do more thing about regulator notify

drivers/regulator/core.c | 9 ++++++++-
drivers/soc/rockchip/io-domain.c | 6 ++++++
include/linux/regulator/consumer.h | 2 ++
3 files changed, 16 insertions(+), 1 deletion(-)

--
2.25.1




2021-08-16 03:21:48

by Jianqun Xu

[permalink] [raw]
Subject: [PATCH 3/4] regulator: core: add pre-enable event notify to regulator

Notify the event about regulator to be enabled to driver.

The IO-DOMAIN driver on Rockchip SoCs will take this event and then to
configure the io-domain mode before regualtor_enable.

Signed-off-by: Jianqun Xu <[email protected]>
---
drivers/regulator/core.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a53f1644a6f4..0eb7af487931 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2654,6 +2654,9 @@ static int _regulator_enable(struct regulator *regulator)
goto err_consumer_disable;
}

+ _notifier_call_chain(rdev, REGULATOR_EVENT_PRE_ENABLE,
+ NULL);
+
ret = _regulator_do_enable(rdev);
if (ret < 0)
goto err_consumer_disable;
--
2.25.1



2021-08-16 03:22:12

by Jianqun Xu

[permalink] [raw]
Subject: [PATCH 1/4] regulator: add PRE_ENABLE event define

Add REGULATOR_EVENT_PRE_ENABLE to allow to notify driver that the
regulator is about to enabled.

Signed-off-by: Jianqun Xu <[email protected]>
---
include/linux/regulator/consumer.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 20e84a84fb77..edd31f0dad17 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -102,6 +102,7 @@ struct regulator_dev;
* Data passed is old voltage cast to (void *).
* PRE_DISABLE Regulator is about to be disabled
* ABORT_DISABLE Regulator disable failed for some reason
+ * PRE_ENABLE Regulator is about to be enabled
*
* NOTE: These events can be OR'ed together when passed into handler.
*/
@@ -119,6 +120,7 @@ struct regulator_dev;
#define REGULATOR_EVENT_PRE_DISABLE 0x400
#define REGULATOR_EVENT_ABORT_DISABLE 0x800
#define REGULATOR_EVENT_ENABLE 0x1000
+#define REGULATOR_EVENT_PRE_ENABLE 0x2000

/*
* Regulator errors that can be queried using regulator_get_error_flags
--
2.25.1



2021-08-16 03:22:37

by Jianqun Xu

[permalink] [raw]
Subject: [PATCH 4/4] soc: rockchip: io-domain: do more thing about regulator notify

Do a fix to rockchip io-domain, follow this orders:

* system running state
-> io-domain vsel to 3.3V
-> regulator_enable
-> vsel change according to regulator voltage

* system running state
-> io-domain vsel to 3.3V
-> regulator_disable

Found on some Rockchip SoCs, the regulator enable or disable without
care about the io-domain maybe caused soc damaged.

Signed-off-by: Jianqun Xu <[email protected]>
---
drivers/soc/rockchip/io-domain.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/soc/rockchip/io-domain.c b/drivers/soc/rockchip/io-domain.c
index cf8182fc3642..af5fb11ad9a3 100644
--- a/drivers/soc/rockchip/io-domain.c
+++ b/drivers/soc/rockchip/io-domain.c
@@ -123,6 +123,12 @@ static int rockchip_iodomain_notify(struct notifier_block *nb,
} else if (event & (REGULATOR_EVENT_VOLTAGE_CHANGE |
REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE)) {
uV = (unsigned long)data;
+ } else if (event & REGULATOR_EVENT_PRE_ENABLE) {
+ uV = MAX_VOLTAGE_3_3;
+ } else if (event & REGULATOR_EVENT_PRE_DISABLE) {
+ uV = MAX_VOLTAGE_3_3;
+ } else if (event & REGULATOR_EVENT_ENABLE) {
+ uV = (unsigned long)data;
} else {
return NOTIFY_OK;
}
--
2.25.1



2021-08-16 12:44:39

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH 4/4] soc: rockchip: io-domain: do more thing about regulator notify

On Mon, 16 Aug 2021 at 05:20, Jianqun Xu <[email protected]> wrote:
>
> Do a fix to rockchip io-domain, follow this orders:
>
> * system running state
> -> io-domain vsel to 3.3V
> -> regulator_enable
> -> vsel change according to regulator voltage
>
> * system running state
> -> io-domain vsel to 3.3V
> -> regulator_disable
>
> Found on some Rockchip SoCs, the regulator enable or disable without
> care about the io-domain maybe caused soc damaged.

Can you please try to elaborate on the problem a bit more, as I don't
quite get the problem.

What regulator is causing this problem? Who is the consumer of the regulator?

Kind regards
Uffe

>
> Signed-off-by: Jianqun Xu <[email protected]>
> ---
> drivers/soc/rockchip/io-domain.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/soc/rockchip/io-domain.c b/drivers/soc/rockchip/io-domain.c
> index cf8182fc3642..af5fb11ad9a3 100644
> --- a/drivers/soc/rockchip/io-domain.c
> +++ b/drivers/soc/rockchip/io-domain.c
> @@ -123,6 +123,12 @@ static int rockchip_iodomain_notify(struct notifier_block *nb,
> } else if (event & (REGULATOR_EVENT_VOLTAGE_CHANGE |
> REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE)) {
> uV = (unsigned long)data;
> + } else if (event & REGULATOR_EVENT_PRE_ENABLE) {
> + uV = MAX_VOLTAGE_3_3;
> + } else if (event & REGULATOR_EVENT_PRE_DISABLE) {
> + uV = MAX_VOLTAGE_3_3;
> + } else if (event & REGULATOR_EVENT_ENABLE) {
> + uV = (unsigned long)data;
> } else {
> return NOTIFY_OK;
> }
> --
> 2.25.1
>
>
>