regulator pre-enable
Subsystems (2)
cover 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(-)
Signature · 9 lines
2.25.1 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
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.
--- include/linux/regulator/consumer.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/regulator/consumer.h +2 -0
@@ -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
Signature · 9 lines
2.25.1 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH 2/4 regulator: core: notify regulator enable with the voltage value
In reply to Jianqun XuGet the voltage of regulator and then pass it as the parameter of notify, the driver could take it.
The origin parameter for notify is NULL, so this patch do nothing effect to other driver who not care about the voltage value.
--- drivers/regulator/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/regulator/core.c +5 -1
@@ -2658,8 +2658,12 @@ static int _regulator_enable(struct regulator *regulator)if (ret <0 ) goto err_consumer_disable; + ret =_regulator_get_voltage (rdev); +if (ret <0 ) + ret =0 ; +_notifier_call_chain (rdev,REGULATOR_EVENT_ENABLE , -NULL ); + &ret); }else if (ret <0 ) {rdev_err (rdev,"is_enabled() failed: %pe\n" ,ERR_PTR (ret)); goto err_consumer_disable;
Signature · 9 lines
2.25.1 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
Mark Brown
maintainerRe: [PATCH 2/4] regulator: core: notify regulator enable with the voltage value
drivers/regulator/core.c static int _regulator_enable(struct regulator *regulator) · line 2666
Quoted 7 lines · Jianqun Xu
drivers/regulator/core.c +5
-1+ ret =_regulator_get_voltage (rdev); +if (ret <0 ) + ret =0 ; +_notifier_call_chain (rdev,REGULATOR_EVENT_ENABLE , -NULL ); + &ret);
This is going to be really expensive for devices without a cache and it's going to be *very* rarely used if ever.
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Re: Re: [PATCH 2/4] regulator: core: notify regulator enable with the voltage value
Hi, Mark
--------------
[email protected]
Quoted 12 lines · Jianqun Xu
drivers/regulator/core.c static int _regulator_enable(struct regulator *regulator) · line 2666
Quoted 8 lines
drivers/regulator/core.c +4
-0+ ret =_regulator_get_voltage (rdev); +if (ret <0 ) + ret =0 ; +_notifier_call_chain(rdev,
REGULATOR_EVENT_ENABLE,drivers/regulator/core.c +1
-1- NULL); + &ret);This is going to be really expensive for devices without a cache and it's going to be *very* rarely used if ever.
How about to only to notify the EVENT_ENABLE without get voltage, then driver who care about this event could get the voltage itself ?
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Re: Re: [PATCH 2/4] regulator: core: notify regulator enable with the voltage value
--------------
[email protected]
Quoted 16 lines
Hi, Mark
--------------
[email protected]Quoted 12 lines · Jianqun Xu
drivers/regulator/core.c static int _regulator_enable(struct regulator *regulator) · line 2666
Quoted 8 lines
drivers/regulator/core.c +4
-0+ ret =_regulator_get_voltage (rdev); +if (ret <0 ) + ret =0 ; +_notifier_call_chain(rdev,
REGULATOR_EVENT_ENABLE,drivers/regulator/core.c +1
-1- NULL); + &ret);This is going to be really expensive for devices without a cache and it's going to be *very* rarely used if ever.
Quoted 2 lines
How about to only to notify the
EVENT_ENABLEwithout get voltage, then driver who care about this event could get the voltage itself ?
ignore my reply here about EVENT_ENABLE, sorry
How about the next patch about PRE_ENABLE ? At least I need a notify without voltage
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH 3/4 regulator: core: add pre-enable event notify to regulator
In reply to Jianqun XuNotify 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.
--- drivers/regulator/core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/regulator/core.c +3 -0
@@ -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;
Signature · 9 lines
2.25.1 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH 4/4 soc: rockchip: io-domain: do more thing about regulator notify
In reply to Jianqun XuDo 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.
--- drivers/soc/rockchip/io-domain.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/soc/rockchip/io-domain.c +6 -0
@@ -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 ®ULATOR_EVENT_PRE_ENABLE ) { + uV =MAX_VOLTAGE_3_3 ; + }else if (event ®ULATOR_EVENT_PRE_DISABLE ) { + uV =MAX_VOLTAGE_3_3 ; + }else if (event ®ULATOR_EVENT_ENABLE ) { + uV = (unsigned long )data; }else {return NOTIFY_OK ; }
Signature · 9 lines
2.25.1 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
Re: [PATCH 4/4] soc: rockchip: io-domain: do more thing about regulator notify
Quoted 8 lines · Jianqun Xu
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
Quoted 6 lines
* system running state
-> io-domain vsel to 3.3V-> regulator_disableFound 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
Quoted 24 lines
Signed-off-by Jianqun Xu <[email protected]>--- drivers/soc/rockchip/io-domain.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/soc/rockchip/io-domain.c +6
-1@@ -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 ®ULATOR_EVENT_PRE_ENABLE ) { + uV =MAX_VOLTAGE_3_3 ; + }else if (event ®ULATOR_EVENT_PRE_DISABLE ) { + uV =MAX_VOLTAGE_3_3 ; + }else if (event ®ULATOR_EVENT_ENABLE ) { + uV = (unsigned long )data; }else {return NOTIFY_OK ; } --
Quoted 4 lines
2.25.1
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip