Skip to contentSkip to conversation

Add mandatory regulator for all users of pwm-backlight.

PATCH Superseded Andrew Chew 4 participants 13 messages Mar 13, 2013 – Apr 9, 2013

Subsystems (6)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add mandatory regulator for all users of pwm-backlight.

Many backlights are enabled via GPIO. We can generalize the GPIO to a fixed regulator.

The enable regulator needs to be mandatory because there was no good way to determine the difference between opting out of the regulator, and probe deferral.

This series of patches is intended to add a dummy regulator (or a GPIO regulator) for all users of the pwm-backlight.

The last patch in the series will always be the pwm-backlight change to add this mandatory regulator. Patches following up to that patch add the mandatory regulator on a per mach family basis. Once all users of pwm-backlight have been patched, this series can be applied in order to maintain bisectability.

Andrew Chew (2):
ARM: OMAP: board-4430sdp: Provide regulator to pwm-backlight
pwm_bl: Add mandatory backlight enable regulator

 .../bindings/video/backlight/pwm-backlight.txt     |   14 +++++
 arch/arm/mach-omap2/board-4430sdp.c                |    5 ++
 drivers/video/backlight/pwm_bl.c                   |   55 ++++++++++++++++----
 3 files changed, 64 insertions(+), 10 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/2 ARM: OMAP: board-4430sdp: Provide regulator to pwm-backlight

The pwm-backlight driver now takes a mandatory regulator that is gotten during driver probe. Initialize a dummy regulator to satisfy this requirement.

---
Changed the device name of the backlight regulator supply to "pwm-backlight", per Peter's comment.

Changed the name of the regulator to "backlight-enable", per Thierry's suggestion.

 arch/arm/mach-omap2/board-4430sdp.c |    6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/mach-omap2/board-4430sdp.c +6 -0
index 35f3ad0..a01a39a 100644
@@ -291,6 +291,10 @@ static struct platform_device sdp4430_leds_pwm = {
 	},
 };
 
+/* Dummy regulator for pwm-backlight driver */
+static struct regulator_consumer_supply backlight_supply =
+	REGULATOR_SUPPLY("enable", "pwm-backlight");
+
 static struct platform_pwm_backlight_data sdp4430_backlight_data = {
 	.max_brightness = 127,
 	.dft_brightness = 127,
@@ -718,6 +722,8 @@ static void __init omap_4430sdp_init(void)
 
 	omap4_i2c_init();
 	omap_sfh7741prox_init();
+	regulator_register_always_on(-1, "backlight-enable",
+				     &backlight_supply, 1, 0);
 	platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
 	omap_serial_init();
 	omap_sdrc_init(NULL, NULL);
Signature · 1 line
1.7.9.5
maintainer
#2 lore raw

Re: [PATCH V3 1/2] ARM: OMAP: board-4430sdp: Provide regulator to pwm-backlight

Quoted 11 lines · Andrew Chew

The pwm-backlight driver now takes a mandatory regulator that is gotten during driver probe. Initialize a dummy regulator to satisfy this requirement.

---
Changed the device name of the backlight regulator supply to "pwm-backlight", per Peter's comment.

Changed the name of the regulator to "backlight-enable", per Thierry's suggestion.

Thanks applying into omap-for-v3.10/board. Note that I'm not taking the second one, that should be resent to the related driver maintainers. You can get that list by running scripts/get_maintainer.pl against it.

Regards,

Tony

Quoted 34 lines
 arch/arm/mach-omap2/board-4430sdp.c |    6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/mach-omap2/board-4430sdp.c +6 -0
index 35f3ad0..a01a39a 100644
@@ -291,6 +291,10 @@ static struct platform_device sdp4430_leds_pwm = {
 	},
 };
 
+/* Dummy regulator for pwm-backlight driver */
+static struct regulator_consumer_supply backlight_supply =
+	REGULATOR_SUPPLY("enable", "pwm-backlight");
+
 static struct platform_pwm_backlight_data sdp4430_backlight_data = {
 	.max_brightness = 127,
 	.dft_brightness = 127,
@@ -718,6 +722,8 @@ static void __init omap_4430sdp_init(void)
 
 	omap4_i2c_init();
 	omap_sfh7741prox_init();
+	regulator_register_always_on(-1, "backlight-enable",
+				     &backlight_supply, 1, 0);
 	platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
 	omap_serial_init();
 	omap_sdrc_init(NULL, NULL);
Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

Re: [PATCH V3 1/2] ARM: OMAP: board-4430sdp: Provide regulator to pwm-backlight

Quoted 10 lines · Tony Lindgren
Quoted 9 lines · Andrew Chew

The pwm-backlight driver now takes a mandatory regulator that is gotten during driver probe. Initialize a dummy regulator to satisfy this requirement.

---
Changed the device name of the backlight regulator supply to "pwm-backlight", per Peter's comment.

Quoted 6 lines
Quoted 2 lines

Changed the name of the regulator to "backlight-enable", per Thierry's suggestion.

Thanks applying into omap-for-v3.10/board. Note that I'm not taking the second one, that should be resent to the related driver maintainers. You can get that list by running scripts/get_maintainer.pl against it.

The plan was to take these all through one tree, preferably the PWM tree because it's all PWM related and the pwm-backlight change will go through that tree as well. Technically these individual patches can be applied as is and aren't harmful, but keeping track of the dependencies might be difficult if they go in via separate trees.

Thierry

maintainer
#4 lore raw

Re: [PATCH V3 1/2] ARM: OMAP: board-4430sdp: Provide regulator to pwm-backlight

Quoted 18 lines · Thierry Reding
Quoted 10 lines · Tony Lindgren
Quoted 9 lines · Andrew Chew

The pwm-backlight driver now takes a mandatory regulator that is gotten during driver probe. Initialize a dummy regulator to satisfy this requirement.

---
Changed the device name of the backlight regulator supply to "pwm-backlight", per Peter's comment.

Quoted 6 lines
Quoted 2 lines

Changed the name of the regulator to "backlight-enable", per Thierry's suggestion.

Thanks applying into omap-for-v3.10/board. Note that I'm not taking the second one, that should be resent to the related driver maintainers. You can get that list by running scripts/get_maintainer.pl against it.

Quoted 5 lines

The plan was to take these all through one tree, preferably the PWM tree because it's all PWM related and the pwm-backlight change will go through that tree as well. Technically these individual patches can be applied as is and aren't harmful, but keeping track of the dependencies might be difficult if they go in via separate trees.

Registering the regulator alone should not do anything. Also the driver should do the right thing if the regulator is not yet registered.

Can you please check your driver patch so the driver won't do anything if the regulator is not (yet) registered and repost it alone as I've already applied the board-*.c change.

The reason why we want to do queue these patches separately is to cut away the dependency between drivers and the core arch/arm changes. Otherwise we'll end up with pointless merge conflicts as we've seen earlier several times with the USB patches for example.

Regards,

Tony

#5 lore raw

Re: [PATCH V3 1/2] ARM: OMAP: board-4430sdp: Provide regulator to pwm-backlight

Quoted 25 lines · Tony Lindgren
Quoted 18 lines · Thierry Reding
Quoted 10 lines · Tony Lindgren
Quoted 9 lines · Andrew Chew

The pwm-backlight driver now takes a mandatory regulator that is gotten during driver probe. Initialize a dummy regulator to satisfy this requirement.

---
Changed the device name of the backlight regulator supply to "pwm-backlight", per Peter's comment.

Quoted 6 lines
Quoted 2 lines

Changed the name of the regulator to "backlight-enable", per Thierry's suggestion.

Thanks applying into omap-for-v3.10/board. Note that I'm not taking the second one, that should be resent to the related driver maintainers. You can get that list by running scripts/get_maintainer.pl against it.

Quoted 5 lines

The plan was to take these all through one tree, preferably the PWM tree because it's all PWM related and the pwm-backlight change will go through that tree as well. Technically these individual patches can be applied as is and aren't harmful, but keeping track of the dependencies might be difficult if they go in via separate trees.

Quoted 6 lines

Registering the regulator alone should not do anything. Also the driver should do the right thing if the regulator is not yet registered.

Can you please check your driver patch so the driver won't do anything if the regulator is not (yet) registered and repost it alone as I've already applied the board-*.c change.

That's not the way that the regulator subsystem works, unfortunately. There's no way you can distinguish between the case where a regulator just hasn't been registered yet, or whether it's missing. That's the whole reason why we need to add the dummy regulators in the first place.

Quoted 4 lines

The reason why we want to do queue these patches separately is to cut away the dependency between drivers and the core arch/arm changes. Otherwise we'll end up with pointless merge conflicts as we've seen earlier several times with the USB patches for example.

We could possibly postpone merging the pwm-backlight changes until all other patches have been merged. If you have this in you for-3.10 branch I guess it will go into linux-next when the 3.9 merge window closes? If so I could possibly base my for-3.10 branch on your branch if you can provide a stable one that you can guarantee not to rebase. There are other alternatives too, but certainly the easiest would've been to take all patches through the PWM tree. The potential for merge conflicts should be rather minimal.

Thierry

maintainer
#6 lore raw

Re: [PATCH V3 1/2] ARM: OMAP: board-4430sdp: Provide regulator to pwm-backlight

Quoted 33 lines · Thierry Reding
Quoted 25 lines · Tony Lindgren
Quoted 18 lines · Thierry Reding
Quoted 10 lines · Tony Lindgren
Quoted 9 lines · Andrew Chew

The pwm-backlight driver now takes a mandatory regulator that is gotten during driver probe. Initialize a dummy regulator to satisfy this requirement.

---
Changed the device name of the backlight regulator supply to "pwm-backlight", per Peter's comment.

Quoted 6 lines
Quoted 2 lines

Changed the name of the regulator to "backlight-enable", per Thierry's suggestion.

Thanks applying into omap-for-v3.10/board. Note that I'm not taking the second one, that should be resent to the related driver maintainers. You can get that list by running scripts/get_maintainer.pl against it.

Quoted 5 lines

The plan was to take these all through one tree, preferably the PWM tree because it's all PWM related and the pwm-backlight change will go through that tree as well. Technically these individual patches can be applied as is and aren't harmful, but keeping track of the dependencies might be difficult if they go in via separate trees.

Quoted 6 lines

Registering the regulator alone should not do anything. Also the driver should do the right thing if the regulator is not yet registered.

Can you please check your driver patch so the driver won't do anything if the regulator is not (yet) registered and repost it alone as I've already applied the board-*.c change.

Quoted 5 lines

That's not the way that the regulator subsystem works, unfortunately. There's no way you can distinguish between the case where a regulator just hasn't been registered yet, or whether it's missing. That's the whole reason why we need to add the dummy regulators in the first place.

But then the regulator is not found and the driver should just exit, or do nothing. If this is an optional regulator, then that should be indicated in some platform data flags?

Quoted 5 lines
Quoted 4 lines

The reason why we want to do queue these patches separately is to cut away the dependency between drivers and the core arch/arm changes. Otherwise we'll end up with pointless merge conflicts as we've seen earlier several times with the USB patches for example.

Quoted 8 lines

We could possibly postpone merging the pwm-backlight changes until all other patches have been merged. If you have this in you for-3.10 branch I guess it will go into linux-next when the 3.9 merge window closes? If so I could possibly base my for-3.10 branch on your branch if you can provide a stable one that you can guarantee not to rebase. There are other alternatives too, but certainly the easiest would've been to take all patches through the PWM tree. The potential for merge conflicts should be rather minimal.

The driver parts really must be done in independently from any platform data or .dts changes. The only common part needed should be changes to include/linux/platform_data/*.h files.

Regards,

Tony

#7 lore raw

Re: [PATCH V3 1/2] ARM: OMAP: board-4430sdp: Provide regulator to pwm-backlight

On Tue, Apr 09, 2013 at 09:40:04AM -0700, Tony Lindgren wrote:
[...]

Quoted 3 lines

But then the regulator is not found and the driver should just exit, or do nothing. If this is an optional regulator, then that should be indicated in some platform data flags?

Yes, if the regulator isn't found then the driver fails. However the goal was to maintain bisectability. If we apply them in the wrong order we can't guarantee that because pwm-backlight will fail to work between both patches.

Quoted 3 lines

The driver parts really must be done in independently from any platform data or .dts changes. The only common part needed should be changes to include/linux/platform_data/*.h files.

We don't even need to touch platform data because the regulators are looked up via a global table. And the changes are all done independently but as I mentioned above, bisectability isn't maintained, so the preferred patch order is the one in which pwm-backlight keeps working at each point in the commit history.

Thierry

maintainer
#8 lore raw

Re: [PATCH V3 1/2] ARM: OMAP: board-4430sdp: Provide regulator to pwm-backlight

Quoted 10 lines · Thierry Reding

On Tue, Apr 09, 2013 at 09:40:04AM -0700, Tony Lindgren wrote:
[...]

Quoted 3 lines

But then the regulator is not found and the driver should just exit, or do nothing. If this is an optional regulator, then that should be indicated in some platform data flags?

Yes, if the regulator isn't found then the driver fails. However the goal was to maintain bisectability. If we apply them in the wrong order we can't guarantee that because pwm-backlight will fail to work between both patches.

But it's fixing something that's not working anyways for board-4430sdp.c, It seems so as these patches just add new features?

Quoted 9 lines
Quoted 3 lines

The driver parts really must be done in independently from any platform data or .dts changes. The only common part needed should be changes to include/linux/platform_data/*.h files.

We don't even need to touch platform data because the regulators are looked up via a global table. And the changes are all done independently but as I mentioned above, bisectability isn't maintained, so the preferred patch order is the one in which pwm-backlight keeps working at each point in the commit history.

Bisectability is a good point. But in the 4430sdp case I'm sure it's enough that it builds and boots no matter how the patches get merged :)

Regards,

Tony

#9 lore raw

Re: [PATCH V3 1/2] ARM: OMAP: board-4430sdp: Provide regulator to pwm-backlight

Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Thierry Reding

On Tue, Apr 09, 2013 at 09:40:04AM -0700, Tony Lindgren wrote:
[...]

Quoted 3 lines

But then the regulator is not found and the driver should just exit, or do nothing. If this is an optional regulator, then that should be indicated in some platform data flags?

Quoted 7 lines
Quoted 4 lines

Yes, if the regulator isn't found then the driver fails. However the goal was to maintain bisectability. If we apply them in the wrong order we can't guarantee that because pwm-backlight will fail to work between both patches.

But it's fixing something that's not working anyways for board-4430sdp.c, It seems so as these patches just add new features?

Not quite. It's adding a dummy regulator to represent hardware where the enable pin is always high. So I think pwm-backlight will work in the current state, but if we make the pwm-backlight driver change without adding the dummy regulator, then pwm-backlight will fail to probe and therefore the PWM won't be enabled either and the display will stay black.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

The driver parts really must be done in independently from any platform data or .dts changes. The only common part needed should be changes to include/linux/platform_data/*.h files.

Quoted 8 lines
Quoted 5 lines

We don't even need to touch platform data because the regulators are looked up via a global table. And the changes are all done independently but as I mentioned above, bisectability isn't maintained, so the preferred patch order is the one in which pwm-backlight keeps working at each point in the commit history.

Bisectability is a good point. But in the 4430sdp case I'm sure it's enough that it builds and boots no matter how the patches get merged :)

If you don't mind some intermediary breakage, I will no longer object.

Thierry

maintainer
#10 lore raw

Re: [PATCH V3 1/2] ARM: OMAP: board-4430sdp: Provide regulator to pwm-backlight

Quoted 16 lines · Thierry Reding
Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Thierry Reding

On Tue, Apr 09, 2013 at 09:40:04AM -0700, Tony Lindgren wrote:
[...]

Quoted 3 lines

But then the regulator is not found and the driver should just exit, or do nothing. If this is an optional regulator, then that should be indicated in some platform data flags?

Quoted 7 lines
Quoted 4 lines

Yes, if the regulator isn't found then the driver fails. However the goal was to maintain bisectability. If we apply them in the wrong order we can't guarantee that because pwm-backlight will fail to work between both patches.

But it's fixing something that's not working anyways for board-4430sdp.c, It seems so as these patches just add new features?

Quoted 6 lines

Not quite. It's adding a dummy regulator to represent hardware where the enable pin is always high. So I think pwm-backlight will work in the current state, but if we make the pwm-backlight driver change without adding the dummy regulator, then pwm-backlight will fail to probe and therefore the PWM won't be enabled either and the display will stay black.

OK

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines

The driver parts really must be done in independently from any platform data or .dts changes. The only common part needed should be changes to include/linux/platform_data/*.h files.

We don't even need to touch platform data because the regulators are looked up via a global table. And the changes are all done independently but as I mentioned above, bisectability isn't maintained, so the preferred patch order is the one in which pwm-backlight keeps working at each point in the commit history.

Quoted 4 lines
Quoted 2 lines

Bisectability is a good point. But in the 4430sdp case I'm sure it's enough that it builds and boots no matter how the patches get merged :)

If you don't mind some intermediary breakage, I will no longer object.

In this case it should be fine. If you are worried about it, you could add something that enables the new features in the driver only in a follow-up patch after the merge window. But I doubt that it's needed.

Regards,

Tony

#11 lore raw

PATCH v3 2/2 pwm_bl: Add mandatory backlight enable regulator

In reply to Andrew Chew

Many backlights need to be explicitly enabled. Typically, this is done with a GPIO. For flexibility, we generalize the enable mechanism to a regulator.

If an enable regulator is not needed, then a dummy regulator can be given to the backlight driver. If a GPIO is used to enable the backlight, then a fixed regulator can be instantiated to control the GPIO.

The backlight enable regulator can be specified in the device tree node for the backlight, or can be done with legacy board setup code in the usual way.

---
Minor modification to pwm_backlight_enable() and pwm_backlight_disable(), to keep the error value of the regulator call and report the error value in the case of an error, from Peter and Thierry's feedback. Used "ret" to be consistent with the rest of the driver.

 .../bindings/video/backlight/pwm-backlight.txt     |   14 +++++
 drivers/video/backlight/pwm_bl.c                   |   59 ++++++++++++++++----
 2 files changed, 63 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +14 -0
index 1e4fc72..7e2e089 100644
@@ -10,6 +10,11 @@ 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)
+  - enable-supply: A phandle to the regulator device tree node. This
+      regulator will be turned on and off as the pwm is enabled and disabled.
+      Many backlights are enabled via a GPIO. In this case, we instantiate
+      a fixed regulator and give that to enable-supply. If a regulator
+      is not needed, then provide a dummy fixed regulator.
 
 Optional properties:
   - pwm-names: a list of names for the PWM devices specified in the
@@ -19,10 +24,19 @@ Optional properties:
 
 Example:
 
+	bl_en: fixed-regulator {
+                compatible = "regulator-fixed";
+                regulator-name = "bl-en-supply";
+                regulator-boot-on;
+                gpio = <&some_gpio>;
+                enable-active-high;
+	};
+
 	backlight {
 		compatible = "pwm-backlight";
 		pwms = <&pwm 0 5000000>;
 
 		brightness-levels = <0 4 8 16 32 64 128 255>;
 		default-brightness-level = <6>;
+		enable-supply = <&bl_en>;
 	};
drivers/video/backlight/pwm_bl.c +49 -10

111 lines not on this page · raw message

Signature · 1 line
1.7.9.5
Tested-by on the v3 series
#12 lore raw
In reply to Andrew Chew
Quoted 7 lines · Andrew Chew

Many backlights are enabled via GPIO. We can generalize the GPIO to a fixed regulator.

The enable regulator needs to be mandatory because there was no good way to determine the difference between opting out of the regulator, and probe deferral.

Quoted 8 lines

This series of patches is intended to add a dummy regulator (or a GPIO regulator) for all users of the pwm-backlight.

The last patch in the series will always be the pwm-backlight change to add this mandatory regulator. Patches following up to that patch add the mandatory regulator on a per mach family basis. Once all users of pwm-backlight have been patched, this series can be applied in order to maintain bisectability.

I'm not really happy with the mandatory regulator since for example the SDP4430 should not need one... Other than that the backlight works after the series.

To both patch: