pwm-backlight: add subdrivers & Tegra support
Subsystems (5)
cover pwm-backlight: add subdrivers & Tegra support
This series introduces a way to use pwm-backlight hooks with platforms that use the device tree through a subdriver system. It also adds support for the Tegra-based Ventana board, adding the last missing block to enable its panel. Support for other Tegra board can thus be easily added.
I have something else in mind to properly support this (power sequences), but this work relies on the GPIO subsystem redesign which will take some time. The pwm-backlight subdrivers can do the job by the meantime.
There are a few design points that might need to be discussed:
1) Link order is important: subdrivers register themselves in their module_init function, which must be called before pwm-backlight's probe. This forbids linking subdrivers as separate modules from pwm-backlight.
2) The subdriver's data is temporarily passed through the backlight device's driver data. This should not hurt, but maybe there is a better way to do this.
3) Subdrivers must add themselves into pwm-backlight's own of_device_id table. It would be cleaner to not have to list subdrivers into pwm-backlight's main file, but I cannot think of a way to do otherwise.
Suggestions for the 3 points listed above are very welcome - in any case, I hope to make this converge into something mergeable quickly.
Note that these patches are the last missing block to get a functional panel on Tegra boards. Using 3.8rc4 and these patches, the internal panel on Ventana is usable out-of-the-box. Yay.
Alexandre Courbot (3):
pwm-backlight: add subdriver mechanism
tegra: pwm-backlight: add tegra pwm-bl driver
tegra: ventana: of: add host1x device to DT
arch/arm/boot/dts/tegra20-ventana.dts | 29 +++++- arch/arm/configs/tegra_defconfig | 1 + drivers/video/backlight/Kconfig | 7 ++ drivers/video/backlight/Makefile | 4 + drivers/video/backlight/pwm_bl.c | 70 ++++++++++++++- drivers/video/backlight/pwm_bl_tegra.c | 159 +++++++++++++++++++++++++++++++++ include/linux/pwm_backlight.h | 15 ++++ 7 files changed, 281 insertions(+), 4 deletions(-) create mode 100644 drivers/video/backlight/pwm_bl_tegra.c
Signature · 1 line
1.8.1.1
PATCH 1/3 pwm-backlight: add subdriver mechanism
PWM-controlled backlights often need additional power control prior to activating the PWM, typically switching regulators or GPIOs. This has been done so far through hooks defined in board files, but this mechanism cannot be used on platforms that rely on the device tree.
This patch introduces a "subdriver" mechanism to the pwm-backlight driver that allows such hooks to be defined in optionally-compiled sub-drivers. Every subdriver has its own device tree properties, which sets the correct hooks to the pwm-backlight driver.
--- drivers/video/backlight/Makefile | 4 +++ drivers/video/backlight/pwm_bl.c | 67 +++++++++++++++++++++++++++++++++++++++- include/linux/pwm_backlight.h | 15 +++++++++ 3 files changed, 85 insertions(+), 1 deletion(-)
drivers/video/backlight/Makefile +4 -0
@@ -29,6 +29,10 @@ obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o +# pwm-backlight subdrivers must be listed *before* pwm_bl.o. +# Link order is important as subdrivers must register themselves +# before pwm-backlight's probe function can be called. +obj-$(CONFIG_BACKLIGHT_PWM_TEGRA) += pwm_bl_tegra.o obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o obj-$(CONFIG_BACKLIGHT_DA9052) += da9052_bl.o
drivers/video/backlight/pwm_bl.c +66 -1
106 lines not on this page · raw message
include/linux/pwm_backlight.h +15 -0
@@ -20,4 +20,19 @@ struct platform_pwm_backlight_data {int (*check_fb)(struct device *dev,struct fb_info *info); }; +struct pwm_backlight_subdriver { +struct list_head list; +const char *name; +int (*init)(struct device *dev); +int (*notify)(struct device *dev,int brightness); +void (*notify_after)(struct device *dev,int brightness); +void (*exit)(struct device *dev); +int (*check_fb)(struct device *dev,struct fb_info *info); +}; + +void pwm_backlight_add_subdriver (struct pwm_backlight_subdriver *driver); +void pwm_backlight_remove_subdriver (struct pwm_backlight_subdriver *driver); + +void pwm_backlight_set_subdriver_data (struct device *dev,void *data); +void *pwm_backlight_get_subdriver_data (struct device *dev);#endif
Signature · 1 line
1.8.1.1
PATCH 3/3 tegra: ventana: of: add host1x device to DT
In reply to Alexandre CourbotAdd the host1x device and DDC i2c bus to enable internal panel on Ventana.
--- arch/arm/boot/dts/tegra20-ventana.dts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/arm/boot/dts/tegra20-ventana.dts +10 -1
@@ -10,6 +10,15 @@ reg = <0x00000000 0x40000000>; }; + host1x { + dc@54200000 { + rgb { + status = "okay"; + nvidia,ddc-i2c-bus = <&lcd_ddc>; + }; + }; + }; + pinmux { pinctrl-names = "default"; pinctrl-0 = <&state_default>;
@@ -341,7 +350,7 @@ #size-cells = <0>; }; - i2c@1 { + lcd_ddc: i2c@1 { reg = <1>; #address-cells = <1>; #size-cells = <0>;
Signature · 1 line
1.8.1.1
PATCH 2/3 tegra: pwm-backlight: add tegra pwm-bl driver
In reply to Alexandre CourbotAdd a PWM-backlight subdriver for Tegra boards, with support for Ventana.
--- arch/arm/boot/dts/tegra20-ventana.dts | 18 +++- arch/arm/configs/tegra_defconfig | 1 + drivers/video/backlight/Kconfig | 7 ++ drivers/video/backlight/pwm_bl.c | 3 + drivers/video/backlight/pwm_bl_tegra.c | 159 +++++++++++++++++++++++++++++++++ 5 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 drivers/video/backlight/pwm_bl_tegra.c
arch/arm/boot/dts/tegra20-ventana.dts +16 -2
@@ -516,6 +516,20 @@ bus-width = <8>; }; + backlight { + compatible = "pwm-backlight-ventana"; + brightness-levels = <0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 255>; + default-brightness-level = <12>; + + pwms = <&pwm 2 5000000>; + pwm-names = "backlight"; + + power-supply = <&vdd_bl_reg>; + panel-supply = <&vdd_pnl_reg>; + bl-gpio = <&gpio 28 0>; + bl-panel = <&gpio 10 0>; + }; + regulators { compatible = "simple-bus"; #address-cells = <1>;
@@ -549,7 +563,7 @@ enable-active-high; }; - regulator@3 { + vdd_pnl_reg: regulator@3 { compatible = "regulator-fixed"; reg = <3>; regulator-name = "vdd_pnl";
@@ -559,7 +573,7 @@ enable-active-high; }; - regulator@4 { + vdd_bl_reg: regulator@4 { compatible = "regulator-fixed"; reg = <4>; regulator-name = "vdd_bl";
arch/arm/configs/tegra_defconfig +1 -0
@@ -150,6 +150,7 @@ CONFIG_BACKLIGHT_LCD_SUPPORT=y CONFIG_BACKLIGHT_CLASS_DEVICE=y # CONFIG_BACKLIGHT_GENERIC is not set CONFIG_BACKLIGHT_PWM=y +CONFIG_BACKLIGHT_PWM_TEGRA=y CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_LOGO=y CONFIG_SOUND=y
drivers/video/backlight/Kconfig +7 -0
@@ -244,6 +244,13 @@ config BACKLIGHT_PWM If you have a LCD backlight adjustable by PWM, say Y to enable this driver. +config BACKLIGHT_PWM_TEGRA + bool "PWM Backlight Driver for Tegra boards" + depends on BACKLIGHT_PWM && ARCH_TEGRA + help + Support backlight power sequencing for Tegra boards. + Supported boards: Ventana. + config BACKLIGHT_DA903X tristate "Backlight Driver for DA9030/DA9034 using WLED" depends on PMIC_DA903X
drivers/video/backlight/pwm_bl.c +3 -0
@@ -217,6 +217,9 @@ static int pwm_backlight_parse_dt(struct device *dev,static struct of_device_id pwm_backlight_of_match[] = { { .compatible ="pwm-backlight" }, +#ifdef CONFIG_BACKLIGHT_PWM_TEGRA + { .compatible ="pwm-backlight-ventana" }, +#endif { } };
drivers/video/backlight/pwm_bl_tegra.c new file +159 -0
159 lines not on this page · raw message
Signature · 1 line
1.8.1.1
Yeah, thanks Alex. :)
So this is a non power sequence version of backlight & panel enabling, isn't it? I remember we talked about this several days ago and you mentioned kernel guys want an ad-hoc version(power sequence logics inside driver, not in DT) and I believe this is it, right?
I think finally I can enable Tegra30 cardhu's display after this patch merged.
Mark
Quoted 42 lines · Alexandre Courbot
This series introduces a way to use pwm-backlight hooks with platforms that use the device tree through a subdriver system. It also adds support for the Tegra-based Ventana board, adding the last missing block to enable its panel. Support for other Tegra board can thus be easily added.
I have something else in mind to properly support this (power sequences), but this work relies on the GPIO subsystem redesign which will take some time. The pwm-backlight subdrivers can do the job by the meantime.
There are a few design points that might need to be discussed:
1) Link order is important: subdrivers register themselves in theirmodule_initfunction, which must be called before pwm-backlight's probe. This forbids linking subdrivers as separate modules from pwm-backlight.
2) The subdriver's data is temporarily passed through the backlight device's driver data. This should not hurt, but maybe there is a better way to do this.
3) Subdrivers must add themselves into pwm-backlight's ownof_device_idtable. It would be cleaner to not have to list subdrivers into pwm-backlight's main file, but I cannot think of a way to do otherwise.Suggestions for the 3 points listed above are very welcome - in any case, I hope to make this converge into something mergeable quickly.
Note that these patches are the last missing block to get a functional panel on Tegra boards. Using 3.8rc4 and these patches, the internal panel on Ventana is usable out-of-the-box. Yay.
Alexandre Courbot (3):
pwm-backlight: add subdriver mechanism
tegra: pwm-backlight: add tegra pwm-bl driver
tegra: ventana: of: add host1x device to DTarch/arm/boot/dts/tegra20-ventana.dts | 29 +++++- arch/arm/configs/tegra_defconfig | 1 + drivers/video/backlight/Kconfig | 7 ++ drivers/video/backlight/Makefile | 4 + drivers/video/backlight/pwm_bl.c | 70 ++++++++++++++- drivers/video/backlight/pwm_bl_tegra.c | 159 +++++++++++++++++++++++++++++++++ include/linux/pwm_backlight.h | 15 ++++ 7 files changed, 281 insertions(+), 4 deletions(-) create mode 100644 drivers/video/backlight/pwm_bl_tegra.c
Quoted 4 lines · Mark Zhang
So this is a non power sequence version of backlight & panel enabling, isn't it? I remember we talked about this several days ago and you mentioned kernel guys want an ad-hoc
version(power sequence logics inside driver, not in DT)and I believe this is it, right?
Basically, yes - I still think power-seqs could be useful here (especially after seeing the size of these sub-drivers if you want to do error checking properly) and plan to give it another shot without DT, but this will not happen soon since we need to do some GPIO redesign before. You can see what's wrong in the init() function of the subdriver: we call a device tree function to obtain the GPIO as there is no get function.
Quoted 2 lines
I think finally I can enable Tegra30 cardhu's display after this patch merged.
Yes, feel free to write a subdriver for Cardhu if you like - I'd like to see all T20 and T30 boards supported by the time this gets merged.
Thanks,
Alex.
Quoted 6 lines · Alexandre Courbot
Quoted 4 lines · Mark Zhang
So this is a non power sequence version of backlight & panel enabling, isn't it? I remember we talked about this several days ago and you mentioned kernel guys want an ad-hoc
version(power sequence logics inside driver, not in DT)and I believe this is it, right?
Quoted 8 lines
Basically, yes - I still think power-seqs could be useful here (especially after seeing the size of these sub-drivers if you want to do error checking properly) and plan to give it another shot without DT, but this will not happen soon since we need to do some GPIO redesign before. You can see what's wrong in the
init()function of the subdriver: we call a device tree function to obtain the GPIO as there is no get function.
Okay. I think I got the picture. I'll read the codes when I'm free and I think I'll understand this better after that.
Quoted 6 lines
Quoted 2 lines
I think finally I can enable Tegra30 cardhu's display after this patch merged.
Yes, feel free to write a subdriver for Cardhu if you like - I'd like to see all T20 and T30 boards supported by the time this gets merged.
Yep, I can try to do that. I'll let you know if I have problems.
Mark
Quoted 3 lines
Thanks,
Alex.
Hi Alex,
This patch set applies failed on tot linux-next(0118). Here is the log:
markz@markz-hp6200:~/tegradrm/official-upstream-kernel$ git am ~/Desktop/*.eml Applying: pwm-backlight: add subdriver mechanism error: patch failed: drivers/video/backlight/pwm_bl.c:35 error: drivers/video/backlight/pwm_bl.c: patch does not apply Patch failed at 0001 pwm-backlight: add subdriver mechanism When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort".
Anyway, I'll try to apply this on 3.8-rc4.
Mark
Quoted 42 lines · Alexandre Courbot
This series introduces a way to use pwm-backlight hooks with platforms that use the device tree through a subdriver system. It also adds support for the Tegra-based Ventana board, adding the last missing block to enable its panel. Support for other Tegra board can thus be easily added.
I have something else in mind to properly support this (power sequences), but this work relies on the GPIO subsystem redesign which will take some time. The pwm-backlight subdrivers can do the job by the meantime.
There are a few design points that might need to be discussed:
1) Link order is important: subdrivers register themselves in theirmodule_initfunction, which must be called before pwm-backlight's probe. This forbids linking subdrivers as separate modules from pwm-backlight.
2) The subdriver's data is temporarily passed through the backlight device's driver data. This should not hurt, but maybe there is a better way to do this.
3) Subdrivers must add themselves into pwm-backlight's ownof_device_idtable. It would be cleaner to not have to list subdrivers into pwm-backlight's main file, but I cannot think of a way to do otherwise.Suggestions for the 3 points listed above are very welcome - in any case, I hope to make this converge into something mergeable quickly.
Note that these patches are the last missing block to get a functional panel on Tegra boards. Using 3.8rc4 and these patches, the internal panel on Ventana is usable out-of-the-box. Yay.
Alexandre Courbot (3):
pwm-backlight: add subdriver mechanism
tegra: pwm-backlight: add tegra pwm-bl driver
tegra: ventana: of: add host1x device to DTarch/arm/boot/dts/tegra20-ventana.dts | 29 +++++- arch/arm/configs/tegra_defconfig | 1 + drivers/video/backlight/Kconfig | 7 ++ drivers/video/backlight/Makefile | 4 + drivers/video/backlight/pwm_bl.c | 70 ++++++++++++++- drivers/video/backlight/pwm_bl_tegra.c | 159 +++++++++++++++++++++++++++++++++ include/linux/pwm_backlight.h | 15 ++++ 7 files changed, 281 insertions(+), 4 deletions(-) create mode 100644 drivers/video/backlight/pwm_bl_tegra.c
Patch is applied OK on 3.8-rc4.
Hmmm.. But I think it's better to make the patch can be applied on linux-next.
Mark
Quoted 60 lines · Mark Zhang
Hi Alex,
This patch set applies failed on tot linux-next(0118). Here is the log:
markz@markz-hp6200:~/tegradrm/official-upstream-kernel$ git am ~/Desktop/*.eml Applying: pwm-backlight: add subdriver mechanism error: patch failed: drivers/video/backlight/pwm_bl.c:35 error: drivers/video/backlight/pwm_bl.c: patch does not apply Patch failed at 0001 pwm-backlight: add subdriver mechanism When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort".Anyway, I'll try to apply this on 3.8-rc4.
Mark
Quoted 42 lines · Alexandre Courbot
This series introduces a way to use pwm-backlight hooks with platforms that use the device tree through a subdriver system. It also adds support for the Tegra-based Ventana board, adding the last missing block to enable its panel. Support for other Tegra board can thus be easily added.
I have something else in mind to properly support this (power sequences), but this work relies on the GPIO subsystem redesign which will take some time. The pwm-backlight subdrivers can do the job by the meantime.
There are a few design points that might need to be discussed:
1) Link order is important: subdrivers register themselves in theirmodule_initfunction, which must be called before pwm-backlight's probe. This forbids linking subdrivers as separate modules from pwm-backlight.
2) The subdriver's data is temporarily passed through the backlight device's driver data. This should not hurt, but maybe there is a better way to do this.
3) Subdrivers must add themselves into pwm-backlight's ownof_device_idtable. It would be cleaner to not have to list subdrivers into pwm-backlight's main file, but I cannot think of a way to do otherwise.Suggestions for the 3 points listed above are very welcome - in any case, I hope to make this converge into something mergeable quickly.
Note that these patches are the last missing block to get a functional panel on Tegra boards. Using 3.8rc4 and these patches, the internal panel on Ventana is usable out-of-the-box. Yay.
Alexandre Courbot (3):
pwm-backlight: add subdriver mechanism
tegra: pwm-backlight: add tegra pwm-bl driver
tegra: ventana: of: add host1x device to DTarch/arm/boot/dts/tegra20-ventana.dts | 29 +++++- arch/arm/configs/tegra_defconfig | 1 + drivers/video/backlight/Kconfig | 7 ++ drivers/video/backlight/Makefile | 4 + drivers/video/backlight/pwm_bl.c | 70 ++++++++++++++- drivers/video/backlight/pwm_bl_tegra.c | 159 +++++++++++++++++++++++++++++++++ include/linux/pwm_backlight.h | 15 ++++ 7 files changed, 281 insertions(+), 4 deletions(-) create mode 100644 drivers/video/backlight/pwm_bl_tegra.c
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
In reply to Alexandre CourbotQuoted 5 lines · Alexandre Courbot
Add a PWM-backlight subdriver for Tegra boards, with support for Ventana.
Signed-off-by Alexandre Courbot <[email protected]>---
[...]
arch/arm/boot/dts/tegra20-ventana.dts line 524
Quoted 7 lines
arch/arm/boot/dts/tegra20-ventana.dts +6
-0+ backlight { + compatible = "pwm-backlight-ventana"; + brightness-levels = <0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 255>; + default-brightness-level = <12>; + + pwms = <&pwm 2 5000000>;
After read the codes of tegra pwm driver & pwm framework, I got to know the meaning of this property. So I think we need to add a doc(e.g:Documentation/devicetree/bindings/video/backlight/nvidia,tegra20-bl.txt) to explain this, "Documentation/devicetree/bindings/pwm/pwm.txt" doesn't explain this, because this may be different between different pwm drivers.
Quoted 8 lines
arch/arm/boot/dts/tegra20-ventana.dts +8
-0+ pwm-names = "backlight"; + + power-supply = <&vdd_bl_reg>; + panel-supply = <&vdd_pnl_reg>; + bl-gpio = <&gpio 28 0>; + bl-panel = <&gpio 10 0>; + }; +
[...]
drivers/video/backlight/pwm_bl_tegra.c
Quoted 5 lines
drivers/video/backlight/pwm_bl_tegra.c new file +0
-0
So according to the filename, I think we can put all tegra boards codes here, right? Just like what you do for Ventana, if I wanna add support for cardhu, I can define similar functions -- let's say "init_cardhu", "exit_cardhu", "notify_cardhu" and "notify_after_cardhu", right?
But I think if we do in this way, the file will become very long soon. And there are a lot of redundant codes in it. So do you have any suggestions?
Mark
Quoted 16 lines
drivers/video/backlight/pwm_bl_tegra.c new file +15
-0@@ -0,0 +1,159 @@ +/* +* pwm-backlight subdriver for Tegra. +* +* Copyright (c) 2013 NVIDIA CORPORATION. All rights reserved. +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/
[...]
Quoted 6 lines
drivers/video/backlight/pwm_bl_tegra.c new file +5
-0+MODULE_DESCRIPTION ("Backlight Driver for Tegra boards" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:pwm-tegra-backlight" ); + +
Quoted 20 lines · Alexandre Courbot
This series introduces a way to use pwm-backlight hooks with platforms that use the device tree through a subdriver system. It also adds support for the Tegra-based Ventana board, adding the last missing block to enable its panel. Support for other Tegra board can thus be easily added.
I have something else in mind to properly support this (power sequences), but this work relies on the GPIO subsystem redesign which will take some time. The pwm-backlight subdrivers can do the job by the meantime.
There are a few design points that might need to be discussed:
1) Link order is important: subdrivers register themselves in theirmodule_initfunction, which must be called before pwm-backlight's probe. This forbids linking subdrivers as separate modules from pwm-backlight.
2) The subdriver's data is temporarily passed through the backlight device's driver data. This should not hurt, but maybe there is a better way to do this.
3) Subdrivers must add themselves into pwm-backlight's ownof_device_idtable. It would be cleaner to not have to list subdrivers into pwm-backlight's main file, but I cannot think of a way to do otherwise.
Quoted 6 lines
Suggestions for the 3 points listed above are very welcome - in any case, I hope to make this converge into something mergeable quickly.
Note that these patches are the last missing block to get a functional panel on Tegra boards. Using 3.8rc4 and these patches, the internal panel on Ventana is usable out-of-the-box. Yay.
Hi Alexandre,
It's great to see you pick this up. I've been meaning to do this myself but I just can't find the time right now. Generally I think the approach you've chosen looks good, but I don't think doing it in pwm-backlight is the right way.
Eventually this should all be covered by the CDF, but since that's not ready yet we want something ad-hoc to get the hardware supported. As such I would like to see this go into some sort of minimalistic, Tegra- specific display/panel framework. I'd prefer to keep the pwm-backlight driver as simple and generic as possible, that is, a driver for a PWM- controlled backlight.
Another advantage of moving this into a sort of display framework is that it may help in defining the requirements for a CDF and that moving the code to the CDF should be easier once it is done.
Last but not least, abstracting away the panel allows other things such as physical dimensions and display modes to be properly encapsulated. I think that power-on/off timing requirements for panels also belong to this set since they are usually specific to a given panel.
Maybe adding these drivers to tegra-drm for now would be a good option. That way the corresponding glue can be added without a need for inter- tree dependencies.
Thierry
Hi Thierry,
Quoted 11 lines · On Monday 21 January 2013 15:49:28 Thierry Reding wrote:
Eventually this should all be covered by the CDF, but since that's not ready yet we want something ad-hoc to get the hardware supported. As such I would like to see this go into some sort of minimalistic, Tegra- specific display/panel framework. I'd prefer to keep the pwm-backlight driver as simple and generic as possible, that is, a driver for a PWM- controlled backlight.
Another advantage of moving this into a sort of display framework is that it may help in defining the requirements for a CDF and that moving the code to the CDF should be easier once it is done.
Quoted 8 lines
Last but not least, abstracting away the panel allows other things such as physical dimensions and display modes to be properly encapsulated. I think that power-on/off timing requirements for panels also belong to this set since they are usually specific to a given panel.
Maybe adding these drivers to tegra-drm for now would be a good option. That way the corresponding glue can be added without a need for inter- tree dependencies.
IIRC (because that was a while ago already) having a Tegra-only display framework is exactly what we wanted to avoid in the first place. This series does nothing but leverage the callbacks mechanism that already exists in pwm- backlight and make it available to DT systems. If we start making a Tegra- specific solution, then other architectures will have to reinvent the wheel again. I really don't think we want to go that way.
These patches only makes slight changes to pwm_bl.c and do not extend its capabilities. I agree that a suitable solution will require the CDF, but by the meantime, let's go for the practical route instead of repeating the same mistakes (i.e. architecture-specific frameworks) again.
There are certainly better ways to do this, but I'm not convinced at all that a Tegra-only solution is one of them.
Alex.
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
In reply to Mark ZhangQuoted 3 lines · On Monday 21 January 2013 15:35:58 Mark Zhang wrote:
arch/arm/boot/dts/tegra20-ventana.dts
Quoted 3 lines
arch/arm/boot/dts/tegra20-ventana.dts +3
-0+ backlight { + compatible = "pwm-backlight-ventana"; + brightness-levels = <0 16 32 48 64 80 96 112 128 144 160 176 192
208
Quoted 9 lines
arch/arm/boot/dts/tegra20-ventana.dts line 524
Quoted 3 lines
224 240 255>; + default-brightness-level = <12>;
arch/arm/boot/dts/tegra20-ventana.dts +2
-0+ + pwms = <&pwm 2 5000000>;After read the codes of tegra pwm driver & pwm framework, I got to know the meaning of this property. So I think we need to add a doc(e.g:
Documentation/devicetree/bindings/video/backlight/nvidia,tegra20-bl.txt) to explain this, "Documentation/devicetree/bindings/pwm/pwm.txt" doesn't explain this, because this may be different between different pwm drivers.
The bindings are in Documentation/devicetree/bindings/video/backlight/pwm- backlight.txt . But you are right that the power supplies and GPIO will require a description of their own - I omitted it for this version because I am not sure what the driver should be called.
The panel used on Ventana is a Chunghwa CLAA101WA01A, maybe that's the name we should use for the compatible string instead (and rename the driver accordingly).
Quoted 4 lines
So according to the filename, I think we can put all tegra boards codes here, right? Just like what you do for Ventana, if I wanna add support for cardhu, I can define similar functions -- let's say "
init_cardhu", "exit_cardhu", "notify_cardhu" and "notify_after_cardhu", right?
That was my initial intention, yes.
Quoted 3 lines
But I think if we do in this way, the file will become very long soon. And there are a lot of redundant codes in it. So do you have any suggestions?
If we decide to make a "Tegra" driver, then I don't think the size of the file is a big issues, as long as one can easily navigate into it. It will make sense to do this since Tegra kernels should include support for all the boards.
If we go and name the drivers after their actual panel names, we should definitely put them into separate files. The Tegra configuration could then include them all by default to make sure all boards are supported.
Alex.
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
Quoted 15 lines · Alex Courbot
Quoted 3 lines · On Monday 21 January 2013 15:35:58 Mark Zhang wrote:
arch/arm/boot/dts/tegra20-ventana.dts
Quoted 3 lines
arch/arm/boot/dts/tegra20-ventana.dts +3
-0+ backlight { + compatible = "pwm-backlight-ventana"; + brightness-levels = <0 16 32 48 64 80 96 112 128 144 160 176 192208
Quoted 9 lines
arch/arm/boot/dts/tegra20-ventana.dts line 524
Quoted 3 lines
224 240 255>; + default-brightness-level = <12>;
arch/arm/boot/dts/tegra20-ventana.dts +2
-0+ + pwms = <&pwm 2 5000000>;After read the codes of tegra pwm driver & pwm framework, I got to know the meaning of this property. So I think we need to add a doc(e.g:
Documentation/devicetree/bindings/video/backlight/nvidia,tegra20-bl.txt) to explain this, "Documentation/devicetree/bindings/pwm/pwm.txt" doesn't explain this, because this may be different between different pwm drivers.
Quoted 5 lines
The bindings are in
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt . But you are right that the power supplies and GPIO will require a description of their own - I omitted it for this version because I am not sure what the driver should be called.
The description of this property in pwm-backlight.txt is:
"pwms: OF device-tree PWM specification (see PWM binding[0])
[0]: Documentation/devicetree/bindings/pwm/pwm.txt"
So you can't get any useful infos from that. That's why I propose to add a tegra specific doc in "Documentation/devicetree/bindings/video/backlight" directory.
Quoted 15 lines
The panel used on Ventana is a Chunghwa CLAA101WA01A, maybe that's the name we should use for the compatible string instead (and rename the driver accordingly).
Quoted 4 lines
So according to the filename, I think we can put all tegra boards codes here, right? Just like what you do for Ventana, if I wanna add support for cardhu, I can define similar functions -- let's say "
init_cardhu", "exit_cardhu", "notify_cardhu" and "notify_after_cardhu", right?That was my initial intention, yes.
Quoted 3 lines
But I think if we do in this way, the file will become very long soon. And there are a lot of redundant codes in it. So do you have any suggestions?
Quoted 8 lines
If we decide to make a "Tegra" driver, then I don't think the size of the file is a big issues, as long as one can easily navigate into it. It will make sense to do this since Tegra kernels should include support for all the boards.
If we go and name the drivers after their actual panel names, we should definitely put them into separate files. The Tegra configuration could then include them all by default to make sure all boards are supported.
I don't think use panel name instead of board name is a good idea. Developers may not be familiar with panel names. So if we use panel name, we have to search and read a lot of manual to find out what the panel is.
I'd rather putting all stuffs in pwm_bl_tegra.c than separating them.
Mark
Quoted 3 lines
Alex.
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
In reply to Mark ZhangHi,
Quoted 11 lines
drivers/video/backlight/pwm_bl_tegra.c
Quoted 5 lines
(quoted diff) +0
-0
b/drivers/video/backlight/pwm_bl_tegra.cnew file mode 100644 index 0000000..8f2195bdrivers/video/backlight/pwm_bl_tegra.c new file +0
-0So according to the filename, I think we can put all tegra boards codes here, right? Just like what you do for Ventana, if I wanna add support for cardhu, I can define similar functions -- let's say "
init_cardhu", "exit_cardhu", "notify_cardhu" and "notify_after_cardhu", right?
Quoted 3 lines
But I think if we do in this way, the file will become very long soon. And there are a lot of redundant codes in it. So do you have any suggestions?
I think we (for PAZ00) will just reuse the ventana code which is sufficient for us. But adding "pwm-backlight-ventana" to our DTS may look a bit strange. On the other hand, I guess that's why the property is called "compatible".
Marc
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
Quoted 13 lines · Marc Dietrich
Hi,
Quoted 11 lines
drivers/video/backlight/pwm_bl_tegra.c
Quoted 5 lines
(quoted diff) +0
-0
b/drivers/video/backlight/pwm_bl_tegra.cnew file mode 100644 index 0000000..8f2195bdrivers/video/backlight/pwm_bl_tegra.c new file +0
-0So according to the filename, I think we can put all tegra boards codes here, right? Just like what you do for Ventana, if I wanna add support for cardhu, I can define similar functions -- let's say "
init_cardhu", "exit_cardhu", "notify_cardhu" and "notify_after_cardhu", right?
Quoted 8 lines
Quoted 3 lines
But I think if we do in this way, the file will become very long soon. And there are a lot of redundant codes in it. So do you have any suggestions?
I think we (for PAZ00) will just reuse the ventana code which is sufficient for us. But adding "pwm-backlight-ventana" to our DTS may look a bit strange. On the other hand, I guess that's why the property is called "compatible".
Ah, yeah, that looks strange. :)
Okay, so I know why Alex wants to use panel name while not board name...
Quoted 2 lines
Marc
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
In reply to Alexandre CourbotQuoted 10 lines · Alexandre Courbot
Add a PWM-backlight subdriver for Tegra boards, with support for Ventana.
Signed-off-by Alexandre Courbot <[email protected]>--- arch/arm/boot/dts/tegra20-ventana.dts | 18 +++- arch/arm/configs/tegra_defconfig | 1 + drivers/video/backlight/Kconfig | 7 ++ drivers/video/backlight/pwm_bl.c | 3 + drivers/video/backlight/pwm_bl_tegra.c | 159 +++++++++++++++++++++++++++++++++
This should be at least 3 separate patches: (1) Driver code (2) Ventana .dts file (3) Tegra defconfig.
arch/arm/boot/dts/tegra20-ventana.dts line 520
Quoted 4 lines
arch/arm/boot/dts/tegra20-ventana.dts +2
-0+ backlight { + compatible = "pwm-backlight-ventana";
If this is Ventana-specific, this should have a vendor prefix; "nvidia," would be appropriate.
But, why is this Ventana-specific; surely it's at most panel-specific, or perhaps even generic across any/most LCD panels?
There needs to be binding documentation.
arch/arm/boot/dts/tegra20-ventana.dts line 527
Quoted 7 lines
arch/arm/boot/dts/tegra20-ventana.dts +7
-0+ brightness-levels = <0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 255>; + default-brightness-level = <12>; + + pwms = <&pwm 2 5000000>; + pwm-names = "backlight"; + + power-supply = <&vdd_bl_reg>;
"power" doesn't seem like a good regulator name; power to what? Is this for the backlight, since I see there's a panel-supply below?
arch/arm/boot/dts/tegra20-ventana.dts line 530
Quoted 4 lines
arch/arm/boot/dts/tegra20-ventana.dts +3
-0+ panel-supply = <&vdd_pnl_reg>; + bl-gpio = <&gpio 28 0>; + bl-panel = <&gpio 10 0>;
GPIO names usually have "gpios" in their name, so I assume those should be bl-enable-gpios, panel-enable-gpios?
drivers/video/backlight/pwm_bl_tegra.c line 99
Quoted 12 lines
drivers/video/backlight/pwm_bl_tegra.c +10
-0+static void exit_ventana (struct device *dev) +{ +struct ventana_bl_data *data =pwm_backlight_get_subdriver_data (dev); + +devm_gpio_free (dev, data->panel_gpio); +devm_gpio_free (dev, data->bl_gpio); +devm_regulator_put (data->vdd_panel); +devm_regulator_put (data->vdd_power); +devm_kfree (dev, data); +}
There shouldn't be a need to explicitly free devm-allocated objects in almost all cases; that's the whole point of the devm APIs.
drivers/video/backlight/pwm_bl_tegra.c line 139
Quoted 7 lines
drivers/video/backlight/pwm_bl_tegra.c +7
-0+static struct pwm_backlight_subdriver pwm_backlight_ventana_subdriver = { + .name ="pwm-backlight-ventana" , + .init = init_ventana, + .exit = exit_ventana, + .notify = notify_ventana, + .notify_after = notify_after_ventana, +};
It seems like all of that code should be completely generic.
drivers/video/backlight/pwm_bl_tegra.c line 153
Quoted 13 lines
drivers/video/backlight/pwm_bl_tegra.c +13
-0+static int __init pwm_backlight_tegra_init (void ) +{ +pwm_backlight_add_subdriver (&pwm_backlight_ventana_subdriver); +return 0 ; +} + +static void __exit pwm_backlight_tegra_exit(void) +{ +pwm_backlight_remove_subdriver (&pwm_backlight_ventana_subdriver); +} + +module_init (pwm_backlight_tegra_init); +module_exit (pwm_backlight_tegra_exit);
Rather than invent some new registration mechanism, if we need board-/panel-/...-specific drivers, it'd be better to make each of those specific drivers a full platform device in an of itself (i.e. regular Linux platform device/driver, have its own probe(), etc.), and have those specific drivers call into the base PWM backlight code, treating it like a utility API.
drivers/video/backlight/pwm_bl_tegra.c line 159
Quoted 5 lines
drivers/video/backlight/pwm_bl_tegra.c +5
-0+MODULE_DESCRIPTION ("Backlight Driver for Tegra boards" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:pwm-tegra-backlight" ); + +
Some extra blank lines there.
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
Quoted 8 lines · On Tuesday 22 January 2013 01:46:33 Stephen Warren wrote:
Quoted 6 lines
arch/arm/boot/dts/tegra20-ventana.dts | 18 +++- arch/arm/configs/tegra_defconfig | 1 + drivers/video/backlight/Kconfig | 7 ++ drivers/video/backlight/pwm_bl.c | 3 + drivers/video/backlight/pwm_bl_tegra.c | 159+++++++++++++++++++++++++++++++++
This should be at least 3 separate patches: (1) Driver code (2) Ventana .dts file (3) Tegra defconfig.
Will do that.
Quoted 5 lines
If this is Ventana-specific, this should have a vendor prefix; "nvidia," would be appropriate.
But, why is this Ventana-specific; surely it's at most panel-specific, or perhaps even generic across any/most LCD panels?
Yes, we could use the panel model here instead. Not sure how many other panels follow the same powering sequence though.
Making it Ventana-specific would have allowed to group all Tegra board support into the same driver, and considering that probably not many devices use the same panels as we do this seemed to make sense at first.
Quoted 5 lines
arch/arm/boot/dts/tegra20-ventana.dts line 527
Quoted 1 line
arch/arm/boot/dts/tegra20-ventana.dts +1
-0+ power-supply = <&vdd_bl_reg>;"power" doesn't seem like a good regulator name; power to what? Is this for the backlight, since I see there's a panel-supply below?
Quoted 7 lines
arch/arm/boot/dts/tegra20-ventana.dts line 530
Quoted 4 lines
arch/arm/boot/dts/tegra20-ventana.dts +3
-0+ panel-supply = <&vdd_pnl_reg>; + bl-gpio = <&gpio 28 0>; + bl-panel = <&gpio 10 0>;GPIO names usually have "gpios" in their name, so I assume those should be bl-enable-gpios, panel-enable-gpios?
Indeed, even though there is only one gpio here. Maybe we could group them into a single property and retrieve them by index - that's what the DT GPIO APIs seem to be designed for initially.
Quoted 9 lines
drivers/video/backlight/pwm_bl_tegra.c line 139
Quoted 7 lines
drivers/video/backlight/pwm_bl_tegra.c new file +7
-0+static struct pwm_backlight_subdriver pwm_backlight_ventana_subdriver = { + .name ="pwm-backlight-ventana" , + .init = init_ventana, + .exit = exit_ventana, + .notify = notify_ventana, + .notify_after = notify_after_ventana, +};It seems like all of that code should be completely generic.
Sorry, I don't get your point here - could you elaborate?
Quoted 6 lines
Rather than invent some new registration mechanism, if we need board-/panel-/...-specific drivers, it'd be better to make each of those specific drivers a full platform device in an of itself (i.e. regular Linux platform device/driver, have its own
probe(), etc.), and have those specific drivers call into the base PWM backlight code, treating it like a utility API.
That's what would make the most sense indeed, but would require some extra changes in pwm-backlight and might go against Thierry's wish to keep it simple. On the other hand I totally agree this would be more elegant. Every pwm-backlight based driver would just need to invoke pwm_bl's probe/remove function from its own. Thierry, would that be an acceptable alternative to the sub-driver thing despite the slightly deeper changes this involves?
Thanks,
Alex.
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
Quoted 61 lines · Alex Courbot
Quoted 8 lines · On Tuesday 22 January 2013 01:46:33 Stephen Warren wrote:
Quoted 6 lines
arch/arm/boot/dts/tegra20-ventana.dts | 18 +++- arch/arm/configs/tegra_defconfig | 1 + drivers/video/backlight/Kconfig | 7 ++ drivers/video/backlight/pwm_bl.c | 3 + drivers/video/backlight/pwm_bl_tegra.c | 159+++++++++++++++++++++++++++++++++
This should be at least 3 separate patches: (1) Driver code (2) Ventana .dts file (3) Tegra defconfig.
Will do that.
Quoted 5 lines
If this is Ventana-specific, this should have a vendor prefix; "nvidia," would be appropriate.
But, why is this Ventana-specific; surely it's at most panel-specific, or perhaps even generic across any/most LCD panels?
Yes, we could use the panel model here instead. Not sure how many other panels follow the same powering sequence though.
Making it Ventana-specific would have allowed to group all Tegra board support into the same driver, and considering that probably not many devices use the same panels as we do this seemed to make sense at first.
Quoted 5 lines
arch/arm/boot/dts/tegra20-ventana.dts line 527
Quoted 1 line
arch/arm/boot/dts/tegra20-ventana.dts +1
-0+ power-supply = <&vdd_bl_reg>;"power" doesn't seem like a good regulator name; power to what? Is this for the backlight, since I see there's a panel-supply below?
Quoted 7 lines
arch/arm/boot/dts/tegra20-ventana.dts line 530
Quoted 4 lines
arch/arm/boot/dts/tegra20-ventana.dts +3
-0+ panel-supply = <&vdd_pnl_reg>; + bl-gpio = <&gpio 28 0>; + bl-panel = <&gpio 10 0>;GPIO names usually have "gpios" in their name, so I assume those should be bl-enable-gpios, panel-enable-gpios?
Indeed, even though there is only one gpio here. Maybe we could group them into a single property and retrieve them by index - that's what the DT GPIO APIs seem to be designed for initially.
Quoted 9 lines
drivers/video/backlight/pwm_bl_tegra.c line 139
Quoted 7 lines
drivers/video/backlight/pwm_bl_tegra.c new file +7
-0+static struct pwm_backlight_subdriver pwm_backlight_ventana_subdriver = { + .name ="pwm-backlight-ventana" , + .init = init_ventana, + .exit = exit_ventana, + .notify = notify_ventana, + .notify_after = notify_after_ventana, +};It seems like all of that code should be completely generic.
Sorry, I don't get your point here - could you elaborate?
Quoted 6 lines
Rather than invent some new registration mechanism, if we need board-/panel-/...-specific drivers, it'd be better to make each of those specific drivers a full platform device in an of itself (i.e. regular Linux platform device/driver, have its own
probe(), etc.), and have those specific drivers call into the base PWM backlight code, treating it like a utility API.
Quoted 6 lines
That's what would make the most sense indeed, but would require some extra changes in pwm-backlight and might go against Thierry's wish to keep it simple. On the other hand I totally agree this would be more elegant. Every pwm-backlight based driver would just need to invoke pwm_bl's probe/remove function from its own. Thierry, would that be an acceptable alternative to the sub-driver thing despite the slightly deeper changes this involves?
I'm confused. Why would you want to call into pwm_bl directly? If we're going to split this up into separate platform devices, why not look up a given backlight device and use the backlight API on that? The pieces of the puzzle are all there: you can use of_find_backlight_by_node() to obtain a backlight device from a device tree node, so I'd expect the DT to look something like this:
backlight: backlight {
compatible = "pwm-backlight";
...
};
panel: panel {
compatible = "...";
...
backlight = <&backlight>;
...
};After that you can wire it up with host1x using something like:
host1x {
dc@54200000 {
rgb {
status = "okay";
nvidia,panel = <&panel>;
};
};
};Maybe with such a binding, we should move the various display-timings properties to the panel node as well and have an API to retrieve them for use by tegra-drm.
Thierry
Quoted 30 lines · Alex Courbot
Hi Thierry,
Quoted 11 lines · On Monday 21 January 2013 15:49:28 Thierry Reding wrote:
Eventually this should all be covered by the CDF, but since that's not ready yet we want something ad-hoc to get the hardware supported. As such I would like to see this go into some sort of minimalistic, Tegra- specific display/panel framework. I'd prefer to keep the pwm-backlight driver as simple and generic as possible, that is, a driver for a PWM- controlled backlight.
Another advantage of moving this into a sort of display framework is that it may help in defining the requirements for a CDF and that moving the code to the CDF should be easier once it is done.
Quoted 8 lines
Last but not least, abstracting away the panel allows other things such as physical dimensions and display modes to be properly encapsulated. I think that power-on/off timing requirements for panels also belong to this set since they are usually specific to a given panel.
Maybe adding these drivers to tegra-drm for now would be a good option. That way the corresponding glue can be added without a need for inter- tree dependencies.
IIRC (because that was a while ago already) having a Tegra-only display framework is exactly what we wanted to avoid in the first place. This series does nothing but leverage the callbacks mechanism that already exists in pwm- backlight and make it available to DT systems. If we start making a Tegra- specific solution, then other architectures will have to reinvent the wheel again. I really don't think we want to go that way.
Quoted 7 lines
These patches only makes slight changes to
pwm_bl.cand do not extend its capabilities. I agree that a suitable solution will require the CDF, but by the meantime, let's go for the practical route instead of repeating the same mistakes (i.e. architecture-specific frameworks) again.There are certainly better ways to do this, but I'm not convinced at all that a Tegra-only solution is one of them.
Well, your proposal is a Tegra-only solution as well. Anything we come up with now will be Tegra-only because it will eventually be integrated with the CDF.
Trying to come up with something generic would be counter-productive. CDF *is* the generic solution. All we would be doing is add a competing framework.
Thierry
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
In reply to Alex CourbotQuoted 17 lines · Alex Courbot
Quoted 6 lines · On Tuesday 22 January 2013 01:46:33 Stephen Warren wrote:
Quoted 5 lines
arch/arm/boot/dts/tegra20-ventana.dts | 18 +++- arch/arm/configs/tegra_defconfig | 1 + drivers/video/backlight/Kconfig | 7 ++ drivers/video/backlight/pwm_bl.c | 3 + drivers/video/backlight/pwm_bl_tegra.c | 159Quoted 9 lines
drivers/video/backlight/pwm_bl_tegra.c line 139
Quoted 7 lines
drivers/video/backlight/pwm_bl_tegra.c new file +7
-0+static struct pwm_backlight_subdriver pwm_backlight_ventana_subdriver = { + .name ="pwm-backlight-ventana" , + .init = init_ventana, + .exit = exit_ventana, + .notify = notify_ventana, + .notify_after = notify_after_ventana, +};It seems like all of that code should be completely generic.
Quoted 1 line
Sorry, I don't get your point here - could you elaborate?
Nothing there (i.e. in the body of any of those functions) seems remotely specific to Ventana or even Ventana's panel; presumably it would work for any built-in LCD panel?
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
In reply to Thierry RedingQuoted 11 lines
I'm confused. Why would you want to call into
pwm_bldirectly? If we're going to split this up into separate platform devices, why not look up a given backlight device and use the backlight API on that? The pieces of the puzzle are all there: you can useof_find_backlight_by_node()to obtain a backlight device from a device tree node, so I'd expect the DT to look something like this:backlight: backlight { compatible = "pwm-backlight"; ... };
This would still prevent any power control from the backlight driver. I.e. if someone sets the brightness to 0 through sysfs, we cannot power the backlight off as pwm-backlight cannot control more than the PWM without platform callbacks. Backlight could only be powered off as a result of a fb blank event.
Quoted 6 lines
panel: panel {
compatible = "...";
...
backlight = <&backlight>;
...
};So all the power control of both the panel and backlight would be performed from this device's driver. How would it plug into tegra-drm? I would see tegra_panel as a new member of the tegra_output structure, with one callback invoked from tegra_encoder_dpms(). Does that look sane?
Quoted 11 lines
After that you can wire it up with host1x using something like:
host1x { dc@54200000 { rgb { status = "okay"; nvidia,panel = <&panel>; }; }; };
Indeed. So if we do that, the DRM DPMS functions would take care of the panel/backlight powering and the backlight driver will control the PWM after this, through the FB notifier. This is a little bit different from the "official" power sequence, but I just tested controlling the PWM at the very end of the sequence and it works just as well. If you think this looks better I don't mind doing it that way, it is actually a good excuse for me to dive into the DRM code.
Anyway, this will only be a temporary solution, CDF is the only way to do this right.
Alex.
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
In reply to Alexandre CourbotHello Alex,
Quoted 190 lines · Alexandre Courbot
Add a PWM-backlight subdriver for Tegra boards, with support for Ventana.
Signed-off-by Alexandre Courbot <[email protected]>--- arch/arm/boot/dts/tegra20-ventana.dts | 18 +++- arch/arm/configs/tegra_defconfig | 1 + drivers/video/backlight/Kconfig | 7 ++ drivers/video/backlight/pwm_bl.c | 3 + drivers/video/backlight/pwm_bl_tegra.c | 159 +++++++++++++++++++++++++++++++++ 5 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 drivers/video/backlight/pwm_bl_tegra.carch/arm/boot/dts/tegra20-ventana.dts +14
-0@@ -516,6 +516,20 @@ bus-width = <8>; }; + backlight { + compatible = "pwm-backlight-ventana"; + brightness-levels = <0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 255>; + default-brightness-level = <12>; + + pwms = <&pwm 2 5000000>; + pwm-names = "backlight"; + + power-supply = <&vdd_bl_reg>; + panel-supply = <&vdd_pnl_reg>; + bl-gpio = <&gpio 28 0>; + bl-panel = <&gpio 10 0>; + }; + regulators { compatible = "simple-bus";#address-cells = <1>;arch/arm/boot/dts/tegra20-ventana.dts +2
-2@@ -549,7 +563,7 @@ enable-active-high; }; - regulator@3 { + vdd_pnl_reg: regulator@3 { compatible = "regulator-fixed"; reg = <3>; regulator-name = "vdd_pnl";@@ -559,7 +573,7 @@ enable-active-high; }; - regulator@4 { + vdd_bl_reg: regulator@4 { compatible = "regulator-fixed"; reg = <4>; regulator-name = "vdd_bl";arch/arm/configs/tegra_defconfig +1
-0@@ -150,6 +150,7 @@ CONFIG_BACKLIGHT_LCD_SUPPORT=y CONFIG_BACKLIGHT_CLASS_DEVICE=y # CONFIG_BACKLIGHT_GENERIC is not set CONFIG_BACKLIGHT_PWM=y +CONFIG_BACKLIGHT_PWM_TEGRA=y CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_LOGO=y CONFIG_SOUND=ydrivers/video/backlight/Kconfig +7
-0@@ -244,6 +244,13 @@ config BACKLIGHT_PWM If you have a LCD backlight adjustable by PWM, say Y to enable this driver. +config BACKLIGHT_PWM_TEGRA + bool "PWM Backlight Driver for Tegra boards" + depends on BACKLIGHT_PWM && ARCH_TEGRA + help + Support backlight power sequencing for Tegra boards. + Supported boards: Ventana. + config BACKLIGHT_DA903X tristate "Backlight Driver for DA9030/DA9034 using WLED" depends on PMIC_DA903Xdrivers/video/backlight/pwm_bl.c +3
-0@@ -217,6 +217,9 @@ static int pwm_backlight_parse_dt(struct device *dev,static struct of_device_id pwm_backlight_of_match[] = { { .compatible ="pwm-backlight" }, +#ifdef CONFIG_BACKLIGHT_PWM_TEGRA + { .compatible ="pwm-backlight-ventana" }, +#endif { } };drivers/video/backlight/pwm_bl_tegra.c new file +39
-0@@ -0,0 +1,159 @@ +/* +* pwm-backlight subdriver for Tegra. +* +* Copyright (c) 2013 NVIDIA CORPORATION. All rights reserved. +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ +#include <linux/err.h> +#include <linux/module.h> +#include <linux/pwm_backlight.h> +#include <linux/regulator/consumer.h> +#include <linux/gpio.h> +#include <linux/of_gpio.h> +#include <linux/list.h> +#include <linux/delay.h> +#include <linux/slab.h> + +struct ventana_bl_data { +struct regulator *vdd_power; +struct regulator *vdd_panel; +int bl_gpio; +int panel_gpio; +bool is_on; +}; + +static int init_ventana (struct device *dev) +{ +struct ventana_bl_data *data; +int ret; + + data = devm_kzalloc(dev, sizeof(struct ventana_bl_data),
GFP_KERNEL);drivers/video/backlight/pwm_bl_tegra.c new file +36
-0+if (!data) +return -ENOMEM ; + + data->vdd_power =devm_regulator_get (dev,"power" ); +if (IS_ERR (data->vdd_power)) { +dev_err (dev,"cannot get power regulator!\n" ); +return PTR_ERR (data->vdd_power); + } + + data->vdd_panel =devm_regulator_get (dev,"panel" ); +if (IS_ERR (data->vdd_panel)) { +dev_err (dev,"cannot get panel regulator!\n" ); +return PTR_ERR (data->vdd_panel); + } + + ret =of_get_named_gpio (dev->of_node,"bl-gpio" ,0 ); +if (ret <0 ) { +dev_err (dev,"cannot find backlight GPIO!\n" ); +return ret; + } + data->bl_gpio = ret; + + ret =of_get_named_gpio (dev->of_node,"bl-panel" ,0 ); +if (ret <0 ) { +dev_err (dev,"cannot find panel GPIO!\n" ); +return ret; + } + data->panel_gpio = ret; + + ret =devm_gpio_request_one (dev, data->bl_gpio, +GPIOF_DIR_OUT |GPIOF_OUT_INIT_LOW , +"backlight" ); +if (ret <0 ) { +dev_err (dev,"cannot request backlight GPIO!\n" ); +return ret; + }
drivers/video/backlight/pwm_bl_tegra.c line 85
Quoted 10 lines
drivers/video/backlight/pwm_bl_tegra.c new file +10
-0+ + ret =devm_gpio_request_one (dev, data->panel_gpio, +GPIOF_DIR_OUT |GPIOF_OUT_INIT_LOW , +"panel" ); +if (ret <0 ) { +dev_err (dev,"cannot request panel GPIO!\n" ); +return ret; + } + +pwm_backlight_set_subdriver_data (dev, data);
Here you are passing ventana_bl_data pointer as input and in the pwm_backlight_get_subdriver_data() function you are assigning the received driver data to backlight_device pointer. As both are two different structures with different structure fields in it. There can be a chance for a crash.
Please correct me if I'm wrong.
Best Wishes,
Leela Krishna Amudala.
Quoted 84 lines
drivers/video/backlight/pwm_bl_tegra.c new file +7
-0+ +return 0 ; +} + +static void exit_ventana (struct device *dev) +{ + struct ventana_bl_data *data =
pwm_backlight_get_subdriver_data(dev);drivers/video/backlight/pwm_bl_tegra.c new file +11
-0+ +devm_gpio_free (dev, data->panel_gpio); +devm_gpio_free (dev, data->bl_gpio); +devm_regulator_put (data->vdd_panel); +devm_regulator_put (data->vdd_power); +devm_kfree (dev, data); +} + +static int notify_ventana (struct device *dev,int brightness) +{ + struct ventana_bl_data *data =
pwm_backlight_get_subdriver_data(dev);drivers/video/backlight/pwm_bl_tegra.c new file +16
-0+if (brightness && !data->is_on) { +regulator_enable (data->vdd_panel); +gpio_set_value (data->panel_gpio,1 ); +usleep_range (200000 ,200000 ); +regulator_enable (data->vdd_power); +usleep_range (10000 ,10000 ); + }else if (!brightness && data->is_on) { +gpio_set_value (data->bl_gpio,0 ); + } + +return brightness; +} + +static void notify_after_ventana (struct device *dev,int brightness) +{ + struct ventana_bl_data *data =
pwm_backlight_get_subdriver_data(dev);drivers/video/backlight/pwm_bl_tegra.c new file +40
-1+if (brightness && !data->is_on) { +gpio_set_value (data->bl_gpio,1 ); + data->is_on = true; + }else if (!brightness && data->is_on) { +usleep_range (10000 ,10000 ); +regulator_disable (data->vdd_power); +usleep_range (200000 ,200000 ); +gpio_set_value (data->panel_gpio,0 ); +regulator_disable (data->vdd_panel); + data->is_on = false; + } +} + +static struct pwm_backlight_subdriver pwm_backlight_ventana_subdriver = { + .name ="pwm-backlight-ventana" , + .init = init_ventana, + .exit = exit_ventana, + .notify = notify_ventana, + .notify_after = notify_after_ventana, +}; + +static int __init pwm_backlight_tegra_init (void ) +{ +pwm_backlight_add_subdriver (&pwm_backlight_ventana_subdriver); +return 0 ; +} + +static void __exit pwm_backlight_tegra_exit(void) +{ +pwm_backlight_remove_subdriver (&pwm_backlight_ventana_subdriver); +} + +module_init (pwm_backlight_tegra_init); +module_exit (pwm_backlight_tegra_exit); + +MODULE_DESCRIPTION ("Backlight Driver for Tegra boards" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:pwm-tegra-backlight" ); + + --1.8.1.1
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
Quoted 7 lines · On Wednesday 23 January 2013 18:15:30 Leela Krishna Amudala wrote:
Quoted 1 line
+
pwm_backlight_set_subdriver_data(dev, data);Here you are passing
ventana_bl_datapointer as input and in thepwm_backlight_get_subdriver_data()function you are assigning the received driver data tobacklight_devicepointer. As both are two different structures with different structure fields in it. There can be a chance for a crash.
That's because the following happens later in pwm_backlight_probe():
pb->subdriver_data = dev_get_drvdata(&pdev->dev); ... bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb, &pwm_backlight_ops, &props); ... platform_set_drvdata(pdev, bl);
So from then on the result of dev_get_drvdata() is indeed an instance of backlight_device from which we can retrieve the subdriver data. I'm not really proud of this. But fortunately it seems like we are going to do things differently.
Alex.
Re: [PATCH 2/3] tegra: pwm-backlight: add tegra pwm-bl driver
In reply to Alex CourbotQuoted 11 lines · On Wednesday 23 January 2013 17:45:39 Alex Courbot wrote:
Quoted 11 lines
I'm confused. Why would you want to call into
pwm_bldirectly? If we're going to split this up into separate platform devices, why not look up a given backlight device and use the backlight API on that? The pieces of the puzzle are all there: you can useof_find_backlight_by_node()to obtain a backlight device from a device tree node, so I'd expect the DT to look something like this:backlight: backlight { compatible = "pwm-backlight"; ...
Quoted 7 lines
Quoted 1 line
};This would still prevent any power control from the backlight driver. I.e. if someone sets the brightness to 0 through sysfs, we cannot power the backlight off as pwm-backlight cannot control more than the PWM without platform callbacks. Backlight could only be powered off as a result of a fb blank event.
In order to solve this, how about adding a backlight notifier call chain to broadcast backlight events in a fashion similar to what is done in fbmem/fbcon? Then backlight_update_status() could send events like BACKLIGHT_EARLY_EVENT_UPDATE and BACKLIGHT_EVENT_UPDATE to which panel drivers could subscribe in order to power the backlight up and down as needed.
Then as the backlight is mentioned in the panel's DT node,
Quoted 6 lines
panel: panel {
compatible = "...";
...
backlight = <&backlight>;
...
};the panel's driver could listen to backlight-related events and do its stuff transparently, without changing anything to the backlight drivers. This would be a good way to replace pwm-backlight's callbacks for platforms that use the DT, and would also be applicable to any backlight class device.
Generally speaking, having a mean to monitor backlights state in the kernel does not seem too crazy, especially since we already have a way to notify user space through backlight_generate_event().
Richard, does that sound ok to you?
Alex.