backlight: pwm_bl: Do not make the regulator mandatory
Subsystems (5)
PATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
Commit 22ceeee1 (pwm-backlight: Add power supply support) caused breakage on boards that do not define the backlight regulator on their dts files.
Instead of making the backlight regulator mandatory, treat it as optional instead, so that we do not have breakage.
This avoids the need for adding a dummy regulator on every dts file that uses the pwm-backlight.
Tested on a mx6qsabresd.
--- .../devicetree/bindings/video/backlight/pwm-backlight.txt | 2 +- drivers/video/backlight/pwm_bl.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +1 -1
@@ -10,13 +10,13 @@ Required properties: last value in the array represents a 100% duty cycle (brightest). - default-brightness-level: the default brightness level (index into the array defined by the "brightness-levels" property) - - power-supply: regulator for supply voltage Optional properties: - pwm-names: a list of names for the PWM devices specified in the "pwms" property (see PWM binding[0]) - enable-gpios: contains a single GPIO specifier for the GPIO which enables and disables the backlight (see GPIO binding[1]) + - power-supply: regulator for supply voltage [0]: Documentation/devicetree/bindings/pwm/pwm.txt [1]: Documentation/devicetree/bindings/gpio/gpio.txt
drivers/video/backlight/pwm_bl.c +7 -8
@@ -50,9 +50,11 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness)if (pb->enabled)return ; - err =regulator_enable (pb->power_supply); -if (err <0 ) -dev_err (pb->dev,"failed to enable power supply\n" ); +if (!IS_ERR (pb->power_supply)) { + err =regulator_enable (pb->power_supply); +if (err <0 ) +dev_err (pb->dev,"failed to enable power supply\n" ); + }if (gpio_is_valid (pb->enable_gpio)) {if (pb->enable_gpio_flags &PWM_BACKLIGHT_GPIO_ACTIVE_LOW )
@@ -80,7 +82,8 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb)gpio_set_value (pb->enable_gpio,0 ); } -regulator_disable (pb->power_supply); +if (!IS_ERR (pb->power_supply)) +regulator_disable (pb->power_supply); pb->enabled = false; }
@@ -283,10 +286,6 @@ static int pwm_backlight_probe(struct platform_device *pdev) } pb->power_supply =devm_regulator_get (&pdev->dev,"power" ); -if (IS_ERR (pb->power_supply)) { - ret =PTR_ERR (pb->power_supply); - goto err_gpio; - } pb->pwm =devm_pwm_get (&pdev->dev,NULL );if (IS_ERR (pb->pwm)) {
Signature · 1 line
1.8.1.2
PATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
Dear Fabio Estevam,
Quoted 10 lines
Commit
22ceeee1(pwm-backlight: Add power supply support) caused breakage on boards that do not define the backlight regulator on their dts files.Instead of making the backlight regulator mandatory, treat it as optional instead, so that we do not have breakage.
This avoids the need for adding a dummy regulator on every dts file that uses the pwm-backlight.
Tested on a mx6qsabresd.
This patch certainly makes sense, there are plenty of simple boards that have no actual supply for the PWM.
Best regards,
Marek Vasut
PATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
In reply to Fabio EstevamQuoted 8 lines · Fabio Estevam
Commit
22ceeee1(pwm-backlight: Add power supply support) caused breakage on boards that do not define the backlight regulator on their dts files.Instead of making the backlight regulator mandatory, treat it as optional instead, so that we do not have breakage.
This avoids the need for adding a dummy regulator on every dts file that uses the pwm-backlight.
That was actually part of an earlier version of this patch. It was rejected on the grounds that regulators really aren't optional. They are there, but in most cases just not described in DT (most likely because they aren't controllable and always on).
But even so, the regulator core now has functionality to return a dummy regulator if none is specified in DT, specifically so that users don't have to special case the handling of "optional" regulators. That should be enough to keep all boards working even if no power-supply property was given in the DTS. As a matter of fact it's a constellation that I explicitly tested and found to work well.
Cc'ing Mark Brown, perhaps he can help figure out what's causing this.
Thierry
Quoted 72 lines
Tested on a mx6qsabresd.
Signed-off-by Fabio Estevam <[email protected]>--- .../devicetree/bindings/video/backlight/pwm-backlight.txt | 2 +- drivers/video/backlight/pwm_bl.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-)Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +1
-1@@ -10,13 +10,13 @@ Required properties: last value in the array represents a 100% duty cycle (brightest). - default-brightness-level: the default brightness level (index into the array defined by the "brightness-levels" property) - - power-supply: regulator for supply voltage Optional properties: - pwm-names: a list of names for the PWM devices specified in the "pwms" property (see PWM binding[0]) - enable-gpios: contains a single GPIO specifier for the GPIO which enables and disables the backlight (see GPIO binding[1]) + - power-supply: regulator for supply voltage [0]: Documentation/devicetree/bindings/pwm/pwm.txt [1]: Documentation/devicetree/bindings/gpio/gpio.txtdrivers/video/backlight/pwm_bl.c +7
-8@@ -50,9 +50,11 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness)if (pb->enabled)return ; - err =regulator_enable (pb->power_supply); -if (err <0 ) -dev_err (pb->dev,"failed to enable power supply\n" ); +if (!IS_ERR (pb->power_supply)) { + err =regulator_enable (pb->power_supply); +if (err <0 ) +dev_err (pb->dev,"failed to enable power supply\n" ); + }if (gpio_is_valid (pb->enable_gpio)) {if (pb->enable_gpio_flags &PWM_BACKLIGHT_GPIO_ACTIVE_LOW )@@ -80,7 +82,8 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb)gpio_set_value (pb->enable_gpio,0 ); } -regulator_disable (pb->power_supply); +if (!IS_ERR (pb->power_supply)) +regulator_disable (pb->power_supply); pb->enabled = false; }@@ -283,10 +286,6 @@ static int pwm_backlight_probe(struct platform_device *pdev) } pb->power_supply =devm_regulator_get (&pdev->dev,"power" ); -if (IS_ERR (pb->power_supply)) { - ret =PTR_ERR (pb->power_supply); - goto err_gpio; - } pb->pwm =devm_pwm_get (&pdev->dev,NULL );if (IS_ERR (pb->pwm)) {Signature · 1 line
1.8.1.2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131122/b1a2ee3c/attachment.sig>
Mark Brown
maintainerPATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
Quoted 1 line · Thierry Reding
Cc'ing Mark Brown, perhaps he can help figure out what's causing this.
The obvious question is what kernel this is being tested on...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131122/12ee085f/attachment.sig>
PATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
Quoted 5 lines · Mark Brown
Quoted 1 line · Thierry Reding
Cc'ing Mark Brown, perhaps he can help figure out what's causing this.
The obvious question is what kernel this is being tested on...
Tested linux-next 20131120 originally and display was blank.
Now on 20131122 the display works fine.
Regards,
Fabio Estevam
PATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
In reply to Mark BrownQuoted 5 lines · Mark Brown
Quoted 1 line · Thierry Reding
Cc'ing Mark Brown, perhaps he can help figure out what's causing this.
The obvious question is what kernel this is being tested on...
Hmm, I'm seeing this breakage on v3.13-rc1 now with the following line in the kernel log.
pwm-backlight backlight.18: dummy supplies not allowed
What's missing here?
Shawn
PATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
Hi Shawn,
Quoted 6 lines · Shawn Guo
Hmm, I'm seeing this breakage on v3.13-rc1 now with the following line in the kernel log.
pwm-backlight backlight.18: dummy supplies not allowed
What's missing here?
Yes, this is weird.
linux-next 20131120: backlight fails
linux-next 20131122: backlight works
linux-next 20131125: backlight fails
Looks like we need to apply this one to make sure backlight works:
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/281826
Regards,
Fabio Estevam
PATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
Quoted 2 lines · Fabio Estevam
Looks like we need to apply this one to make sure backlight works:
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/281826
But per Thierry's comment below, this is the exactly the case that we should avoid - patch individual board DTS file to add a dummy/fake regulator to get it through.
| But even so, the regulator core now has functionality to return a dummy | regulator if none is specified in DT, specifically so that users don't | have to special case the handling of "optional" regulators. That should | be enough to keep all boards working even if no power-supply property | was given in the DTS. As a matter of fact it's a constellation that I | explicitly tested and found to work well.
Shawn
PATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
Mark/Thierry,
Quoted 10 lines · Shawn Guo
Quoted 2 lines · Fabio Estevam
Looks like we need to apply this one to make sure backlight works:
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/281826But per Thierry's comment below, this is the exactly the case that we should avoid - patch individual board DTS file to add a dummy/fake regulator to get it through.
| But even so, the regulator core now has functionality to return a dummy | regulator if none is specified in DT, specifically so that users don't
What commit provides this regulator core functionality?
Looks like it has not reached 3.13-rc1.
Regards,
Fabio Estevam
Mark Brown
maintainerPATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
Quoted 1 line · Fabio Estevam
What commit provides this regulator core functionality?
regulator: core: Provide a dummy regulator with full constraints
Quoted 1 line
Looks like it has not reached 3.13-rc1.
Yes, it did.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131125/650b4eb8/attachment.sig>
PATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
Quoted 9 lines · Mark Brown
Quoted 1 line · Fabio Estevam
What commit provides this regulator core functionality?
regulator: core: Provide a dummy regulator with full constraints
Quoted 1 line
Looks like it has not reached 3.13-rc1.
Yes, it did.
Ok, I see.
Another way to have LCD working is on a 3.13-rc1 (without passing the fake regulator node in dt):
drivers/video/backlight/pwm_bl.c +1 -1
@@ -284,7 +284,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->power_supply =devm_regulator_get (&pdev->dev,"power" );if (IS_ERR (pb->power_supply)) { - ret =PTR_ERR (pb->power_supply); + ret = -EPROBE_DEFER ; goto err_gpio; }
At least mx28evk and mx6qsabresd have no LCD output in 3.13-rc1.
Not sure what is the proper fix though.
Regards,
Fabio Estevam
PATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
Quoted 3 lines · Fabio Estevam
At least mx28evk and mx6qsabresd have no LCD output in 3.13-rc1.
Not sure what is the proper fix though.
What about this?
drivers/regulator/core.c +1 -1
@@ -3850,4 +3850,4 @@ unlock:return 0 ; } -late_initcall (regulator_init_complete); +core_initcall (regulator_init_complete);
Mark Brown
maintainerPATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
drivers/regulator/core.c unlock: · line 3853
Quoted 2 lines · Fabio Estevam
drivers/regulator/core.c +1
-1-late_initcall (regulator_init_complete); +core_initcall (regulator_init_complete);
No, like I said previously fiddling about with the initcall order is not
going to help.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131126/ed2c619b/attachment.sig>
Mark Brown
maintainerPATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
In reply to Fabio EstevamQuoted 3 lines · Fabio Estevam
linux-next 20131120: backlight fails
linux-next 20131122: backlight works
linux-next 20131125: backlight fails
What are the differences between those kernels? I'm not aware of any regulator core changes at all there and diff isn't showing me any - are you sure you used a consistent kernel configuration? Have you tried to look at what happens when we should provide the dummy regulator, and do the logs say anything?
Quoted 2 lines
Looks like we need to apply this one to make sure backlight works:
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/281826
Please always provide plain text versions of links and SHA1s... that
link is to a patch adding a fixed regulator which you should do but
ought not to need to do.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131125/dd9cf2a7/attachment-0001.sig>
Mark Brown
maintainerPATCH 1/1 backlight: pwm_bl: Do not make the regulator mandatory
In reply to Shawn GuoQuoted 6 lines · Shawn Guo
Hmm, I'm seeing this breakage on v3.13-rc1 now with the following line in the kernel log.
pwm-backlight backlight.18: dummy supplies not allowed
What's missing here?
Are you racing with the late initcall to flag that DT is present? Wei
Ni was looking at hooking this into DT so that when we pass the DT over
we flag that we have full constraints (or provide a notifier to let
subsystems do that) but that ground to a halt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131125/729043dc/attachment.sig>