ARM: pxa: Use PWM lookup tables
Subsystems (3)
cover ARM: pxa: Use PWM lookup tables
Back when the PWM framework was introduced the concept of PWM lookup tables was added to allow board code to register a table of PWM devices and their association with consumers. The goal is to allow drivers to use a unified method to request PWM devices. At the same time, since no boards were exposing these tables, fallback code was kept in drivers to allow old code to remain functional. Unfortunately I got the numbering of PWM devices wrong, so all these boards should now be without working backlight control, though only a few cases have been fixed since, so I guess most of this hardware is largely unused.
This series aims at finally fixing this up. It converts all PXA boards that hook up a pwm-backlight device to use the new PWM lookup tables. All patches have been compile-tested, but I don't have access to any of these boards, so I couldn't verify that they really work.
Thierry
Thierry Reding (17):
ARM: pxa: cm-x300: Use PWM lookup table
ARM: pxa: colibri-pxa270-income: Use PWM lookup table
ARM: pxa: ezx: Use PWM lookup table
ARM: pxa: hx4700: Remove unused field initializers
ARM: pxa: lpd270: Use PWM lookup table
ARM: pxa: magician: Use PWM lookup table
ARM: pxa: mainstone: Use PWM lookup table
ARM: pxa: mioa701: Use PWM lookup table
ARM: pxa: palm27x: Use PWM lookup table
ARM: pxa: palmtc: Use PWM lookup table
ARM: pxa: palmte2: Use PWM lookup table
ARM: pxa: pcm990: Use PWM lookup table
ARM: pxa: raumfeld: Use PWM lookup table
ARM: pxa: tavorevb: Use PWM lookup table
ARM: pxa: viper: Use PWM lookup table
ARM: pxa: z2: Use PWM lookup table
ARM: pxa: zylonite: Use PWM lookup table
arch/arm/mach-pxa/cm-x300.c | 9 +++++++-- arch/arm/mach-pxa/colibri-pxa270-income.c | 9 +++++++-- arch/arm/mach-pxa/ezx.c | 9 +++++++-- arch/arm/mach-pxa/hx4700.c | 2 -- arch/arm/mach-pxa/lpd270.c | 9 +++++++-- arch/arm/mach-pxa/magician.c | 9 +++++++-- arch/arm/mach-pxa/mainstone.c | 18 ++++++++++++++---- arch/arm/mach-pxa/mioa701.c | 9 +++++++-- arch/arm/mach-pxa/palm27x.c | 9 +++++++-- arch/arm/mach-pxa/palmtc.c | 9 +++++++-- arch/arm/mach-pxa/palmte2.c | 9 +++++++-- arch/arm/mach-pxa/pcm990-baseboard.c | 9 +++++++-- arch/arm/mach-pxa/raumfeld.c | 11 ++++++++--- arch/arm/mach-pxa/tavorevb.c | 13 +++++++++---- arch/arm/mach-pxa/viper.c | 9 +++++++-- arch/arm/mach-pxa/z2.c | 13 +++++++++---- arch/arm/mach-pxa/zylonite.c | 9 +++++++-- 17 files changed, 124 insertions(+), 41 deletions(-)
Signature · 1 line
2.5.0
PATCH 1/17 ARM: pxa: cm-x300: Use PWM lookup table
Use a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/cm-x300.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/cm-x300.c +7 -2
@@ -26,6 +26,7 @@#include <linux/dm9000.h> #include <linux/leds.h> #include <linux/rtc-v3020.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/i2c.h>
@@ -305,11 +306,14 @@ static inline void cm_x300_init_lcd(void) {}#endif #if defined(CONFIG_BACKLIGHT_PWM ) || defined(CONFIG_BACKLIGHT_PWM_MODULE ) +static struct pwm_lookup cm_x300_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,1 ,"pwm-backlight.0" ,NULL ,10000 , +PWM_POLARITY_NORMAL ), +}; +static struct platform_pwm_backlight_data cm_x300_backlight_data = { - .pwm_id =2 , .max_brightness =100 , .dft_brightness =100 , - .pwm_period_ns =10000 , .enable_gpio =-1 , };
@@ -323,6 +327,7 @@ static struct platform_device cm_x300_backlight_device = {static void cm_x300_init_bl (void ) { +pwm_add_table (cm_x300_pwm_lookup,ARRAY_SIZE (cm_x300_pwm_lookup));platform_device_register (&cm_x300_backlight_device); }#else
Signature · 1 line
2.5.0
Robert Jarzmik
maintainerPATCH 1/17 ARM: pxa: cm-x300: Use PWM lookup table
arch/arm/mach-pxa/cm-x300.c static inline void cm_x300_init_lcd(void) {} · line 312
Quoted 8 lines · Thierry Reding
arch/arm/mach-pxa/cm-x300.c +4
-0@@ -305,11 +306,14 @@ static inline void cm_x300_init_lcd(void) {}#endif #if defined(CONFIG_BACKLIGHT_PWM ) || defined(CONFIG_BACKLIGHT_PWM_MODULE ) +static struct pwm_lookup cm_x300_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,1 ,"pwm-backlight.0" ,NULL ,10000 , +PWM_POLARITY_NORMAL ), +};
That looks weird. It was pwm_id = 2, and I can't find the "2" in the statement above. I would gladly fix it myself, but I wonder where that "2" should go ...
arch/arm/mach-pxa/cm-x300.c static inline void cm_x300_init_lcd(void) {} · line 318
Quoted 8 lines
arch/arm/mach-pxa/cm-x300.c +1
-2+static struct platform_pwm_backlight_data cm_x300_backlight_data = { - .pwm_id =2 , .max_brightness =100 , .dft_brightness =100 , - .pwm_period_ns =10000 , .enable_gpio =-1 , };
Cheers.
Signature · 1 line
Robert
PATCH 1/17 ARM: pxa: cm-x300: Use PWM lookup table
Quoted 5 lines · Robert Jarzmik
Quoted 3 lines · Thierry Reding
(quoted diff) +0
-0@@ -305,11 +306,14 @@ static inline void cm_x300_init_lcd(void) {} #endif
Quoted 7 lines
arch/arm/mach-pxa/cm-x300.c static inline void cm_x300_init_lcd(void) {} · line 312
Quoted 5 lines
arch/arm/mach-pxa/cm-x300.c +4
-0#if defined(CONFIG_BACKLIGHT_PWM ) || defined(CONFIG_BACKLIGHT_PWM_MODULE ) +static struct pwm_lookup cm_x300_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,1 ,"pwm-backlight.0" ,NULL ,10000 , +PWM_POLARITY_NORMAL ), +};That looks weird. It was
pwm_id= 2, and I can't find the "2" in the statement above. I would gladly fix it myself, but I wonder where that "2" should go ...
pwm_id = 2 should be equivalent to the 1 in the second argument of the PWM_LOOKUP macro (i.e. the PWM index). The rationale for that change is given in an old commit by Paul Parsons:
commit 8d6b00f5d639cfc28487ef412589e35b4e6ac7c7
Author: Paul Parsons <[email protected]>
Date: Fri Oct 19 13:15:30 2012 +0100
ARM: pxa: hx4700: Fix backlight PWM device number
Recent changes to PXA PWM support changed the PXA27X PWM device numbering scheme.
The linux-3.5 PXA PWM driver followed the hardware numbering scheme for the 4 PWMs, while the linux-3.6-rc1 PXA PWM driver has adopted a linear numbering scheme:
Address Hardware 3.5 pwm_id 3.6-rc1 pwm_id
0x40b00000 PWM0 0 0
0x40b00010 PWM2 2 1
0x40c00000 PWM1 1 2
0x40c00010 PWM3 3 3
The hx4700 backlight uses PWM1 at 0x40c00000. Consequently the pwm_id must be changed from 1 to 2.
This patch fixes the backlight PWM device number and at the same time moves from the legacy PWM API (pwm_id) to the new PWM API (pwm_lookup).
With the lookup tables the situation is somewhat more complicated because the indices are relative to the provider. The above would therefore map to something like this:
Address Hardware Device Index
0x40b00000 PWM0 pxa2{5,7}x-pwm.0 0
0x40b00010 PWM2 pxa27x-pwm.0 1
0x40c00000 PWM1 pxa2{5,7}x-pwm.1 0
0x40c00010 PWM3 pxa27x-pwm.1 1Does that clarify the situation?
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151006/dfb67962/attachment.sig>
Robert Jarzmik
maintainerPATCH 1/17 ARM: pxa: cm-x300: Use PWM lookup table
Quoted 21 lines · Thierry Reding
Quoted 5 lines · Robert Jarzmik
Quoted 3 lines · Thierry Reding
(quoted diff) +0
-0@@ -305,11 +306,14 @@ static inline void cm_x300_init_lcd(void) {} #endifQuoted 7 lines
arch/arm/mach-pxa/cm-x300.c static inline void cm_x300_init_lcd(void) {} · line 312
Quoted 5 lines
arch/arm/mach-pxa/cm-x300.c +4
-0#if defined(CONFIG_BACKLIGHT_PWM ) || defined(CONFIG_BACKLIGHT_PWM_MODULE ) +static struct pwm_lookup cm_x300_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,1 ,"pwm-backlight.0" ,NULL ,10000 , +PWM_POLARITY_NORMAL ), +};That looks weird. It was
pwm_id= 2, and I can't find the "2" in the statement above. I would gladly fix it myself, but I wonder where that "2" should go ...
pwm_id= 2 should be equivalent to the 1 in the second argument of thePWM_LOOKUPmacro (i.e. the PWM index). The rationale for that change is given in an old commit by Paul Parsons:
With the lookup tables the situation is somewhat more complicated because the indices are relative to the provider. The above would therefore map to something like this:
Quoted 7 lines
Address Hardware Device Index 0x40b00000 PWM0 pxa2{5,7}x-pwm.0 0 0x40b00010 PWM2 pxa27x-pwm.0 1 0x40c00000 PWM1 pxa2{5,7}x-pwm.1 0 0x40c00010 PWM3 pxa27x-pwm.1 1Does that clarify the situation?
Yes, very much, thanks. That settles the situation for the patches I had not understood so far, ie. patches 1, 14,16,17.
Therefore, I'll apply the whole serie this week. Thanks for your work.
Cheers.
Signature · 1 line
Robert
PATCH 2/17 ARM: pxa: colibri-pxa270-income: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/colibri-pxa270-income.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/colibri-pxa270-income.c +7 -2
@@ -20,6 +20,7 @@#include <linux/ioport.h> #include <linux/kernel.h> #include <linux/platform_device.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/i2c/pxa-i2c.h>
@@ -184,11 +185,14 @@ static inline void income_lcd_init(void) {}* Backlight ******************************************************************************/ #if defined(CONFIG_BACKLIGHT_PWM ) || defined(CONFIG_BACKLIGHT_PWM_MODULE ) +static struct pwm_lookup income_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,0 ,"pwm-backlight.0" ,NULL ,1000000 , +PWM_POLARITY_NORMAL ), +}; +static struct platform_pwm_backlight_data income_backlight_data = { - .pwm_id =0 , .max_brightness =0x3ff , .dft_brightness =0x1ff , - .pwm_period_ns =1000000 , .enable_gpio =-1 , };
@@ -202,6 +206,7 @@ static struct platform_device income_backlight = {static void __init income_pwm_init (void ) { +pwm_add_table (income_pwm_lookup,ARRAY_SIZE (income_pwm_lookup));platform_device_register (&income_backlight); }#else
Signature · 1 line
2.5.0
PATCH 3/17 ARM: pxa: ezx: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/ezx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/ezx.c +7 -2
@@ -15,6 +15,7 @@#include <linux/init.h> #include <linux/platform_device.h> #include <linux/delay.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/input.h> #include <linux/gpio.h>
@@ -49,11 +50,14 @@#define GPIO19_GEN1_CAM_RST 19#define GPIO28_GEN2_CAM_RST 28 +static struct pwm_lookup ezx_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,0 ,"pwm-backlight.0" ,NULL ,78700 , +PWM_POLARITY_NORMAL ), +}; +static struct platform_pwm_backlight_data ezx_backlight_data = { - .pwm_id =0 , .max_brightness =1023 , .dft_brightness =1023 , - .pwm_period_ns =78770 , .enable_gpio =-1 , };
@@ -817,6 +821,7 @@ static void __init a780_init(void)platform_device_register (&a780_camera); } +pwm_add_table (ezx_pwm_lookup,ARRAY_SIZE (ezx_pwm_lookup));platform_add_devices (ARRAY_AND_SIZE (ezx_devices));platform_add_devices (ARRAY_AND_SIZE (a780_devices)); }
Signature · 1 line
2.5.0
PATCH 4/17 ARM: pxa: hx4700: Remove unused field initializers
In reply to Thierry RedingThe ID and period for the backlight PWM are obtained from a PWM lookup table, so the corresponding values don't need to be duplicated into the platform data.
--- arch/arm/mach-pxa/hx4700.c | 2 -- 1 file changed, 2 deletions(-)
arch/arm/mach-pxa/hx4700.c +0 -2
@@ -557,10 +557,8 @@ static struct platform_device hx4700_lcd = {*/ static struct platform_pwm_backlight_data backlight_data = { - .pwm_id =-1 ,/* Superseded by pwm_lookup */ .max_brightness =200 , .dft_brightness =100 , - .pwm_period_ns =30923 , .enable_gpio =-1 , };
Signature · 1 line
2.5.0
PATCH 4/17 ARM: pxa: hx4700: Remove unused field initializers
Quoted 8 lines · Thierry Reding
The ID and period for the backlight PWM are obtained from a PWM lookup table, so the corresponding values don't need to be duplicated into the platform data.
Cc Daniel Mack <[email protected]>Cc Haojian Zhuang <[email protected]>Cc Robert Jarzmik <[email protected]>Signed-off-by Thierry Reding <[email protected]>
regards
Philipp
PATCH 5/17 ARM: pxa: lpd270: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/lpd270.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/lpd270.c +7 -2
@@ -23,6 +23,7 @@#include <linux/ioport.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/smc91x.h>
@@ -271,11 +272,14 @@ static struct platform_device lpd270_flash_device[2] = { }, }; +static struct pwm_lookup lpd270_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,0 ,"pwm-backlight.0" ,NULL ,78770 , +PWM_POLARITY_NORMAL ), +}; +static struct platform_pwm_backlight_data lpd270_backlight_data = { - .pwm_id =0 , .max_brightness =1 , .dft_brightness =1 , - .pwm_period_ns =78770 , .enable_gpio =-1 , };
@@ -474,6 +478,7 @@ static void __init lpd270_init(void)*/ ARB_CNTRL =ARB_CORE_PARK |0x234 ; +pwm_add_table (lpd270_pwm_lookup,ARRAY_SIZE (lpd270_pwm_lookup));platform_add_devices (platform_devices,ARRAY_SIZE (platform_devices));pxa_set_ac97_info (NULL );
Signature · 1 line
2.5.0
PATCH 6/17 ARM: pxa: magician: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/magician.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/magician.c +7 -2
@@ -24,6 +24,7 @@#include <linux/mfd/htc-pasic3.h> #include <linux/mtd/physmap.h> #include <linux/pda_power.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/regulator/driver.h> #include <linux/regulator/gpio-regulator.h>
@@ -346,6 +347,11 @@ static struct pxafb_mach_info samsung_info = {* Backlight */ +static struct pwm_lookup magician_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,0 ,"pwm-backlight" ,NULL ,30923 , +PWM_POLARITY_NORMAL ), +}; +static struct gpio magician_bl_gpios[] = { {EGPIO_MAGICIAN_BL_POWER ,GPIOF_DIR_OUT ,"Backlight power" }, {EGPIO_MAGICIAN_BL_POWER2 ,GPIOF_DIR_OUT ,"Backlight power 2" },
@@ -374,10 +380,8 @@ static void magician_backlight_exit(struct device *dev) }static struct platform_pwm_backlight_data backlight_data = { - .pwm_id =0 , .max_brightness =272 , .dft_brightness =100 , - .pwm_period_ns =30923 , .enable_gpio =-1 , .init = magician_backlight_init, .notify = magician_backlight_notify,
@@ -743,6 +747,7 @@ static void __init magician_init(void)pxa_set_btuart_info (NULL );pxa_set_stuart_info (NULL ); +pwm_add_table (magician_pwm_lookup,ARRAY_SIZE (magician_pwm_lookup));platform_add_devices (ARRAY_AND_SIZE (devices));pxa_set_ficp_info (&magician_ficp_info);
Signature · 1 line
2.5.0
PATCH 6/17 ARM: pxa: magician: Use PWM lookup table
Quoted 9 lines · Thierry Reding
Use a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
Cc Daniel Mack <[email protected]>Cc Haojian Zhuang <[email protected]>Cc Robert Jarzmik <[email protected]>Signed-off-by Thierry Reding <[email protected]>
regards
Philipp
PATCH 7/17 ARM: pxa: mainstone: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/mainstone.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
arch/arm/mach-pxa/mainstone.c +14 -4
@@ -26,6 +26,7 @@#include <linux/mtd/partitions.h> #include <linux/input.h> #include <linux/gpio_keys.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/smc91x.h> #include <linux/i2c/pxa-i2c.h>
@@ -248,11 +249,14 @@ static struct platform_device mst_flash_device[2] = { };#if defined(CONFIG_FB_PXA ) || defined(CONFIG_FB_PXA_MODULE ) +static struct pwm_lookup mainstone_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,0 ,"pwm-backlight.0" ,NULL ,78770 , +PWM_POLARITY_NORMAL ), +}; +static struct platform_pwm_backlight_data mainstone_backlight_data = { - .pwm_id =0 , .max_brightness =1023 , .dft_brightness =1023 , - .pwm_period_ns =78770 , .enable_gpio =-1 , };
@@ -266,9 +270,15 @@ static struct platform_device mainstone_backlight_device = {static void __init mainstone_backlight_register (void ) { -int ret =platform_device_register (&mainstone_backlight_device); -if (ret) +int ret; + +pwm_add_table (mainstone_pwm_lookup,ARRAY_SIZE (mainstone_pwm_lookup)); + + ret =platform_device_register (&mainstone_backlight_device); +if (ret) {printk (KERN_ERR "mainstone: failed to register backlight device: %d\n" , ret); +pwm_remove_table (mainstone_pwm_lookup,ARRAY_SIZE (mainstone_pwm_lookup)); + } }#else #define mainstone_backlight_register () do { } while (0)
Signature · 1 line
2.5.0
PATCH 8/17 ARM: pxa: mioa701: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/mioa701.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/mioa701.c +7 -2
@@ -26,6 +26,7 @@#include <linux/input.h> #include <linux/delay.h> #include <linux/gpio_keys.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/rtc.h> #include <linux/leds.h>
@@ -181,12 +182,15 @@ static unsigned long mioa701_pin_config[] = { MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH), }; +static struct pwm_lookup mioa701_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,0 ,"pwm-backlight" ,NULL ,4000 *1024 , +PWM_POLARITY_NORMAL ), +}; +/* LCD Screen and Backlight */ static struct platform_pwm_backlight_data mioa701_backlight_data = { - .pwm_id =0 , .max_brightness =100 , .dft_brightness =50 , - .pwm_period_ns =4000 *1024 ,/* Fl = 250kHz */ .enable_gpio =-1 , };
@@ -751,6 +755,7 @@ static void __init mioa701_machine_init(void)pxa_set_udc_info (&mioa701_udc_info);pxa_set_ac97_info (&mioa701_ac97_info); pm_power_off = mioa701_poweroff; +pwm_add_table (mioa701_pwm_lookup,ARRAY_SIZE (mioa701_pwm_lookup));platform_add_devices (devices,ARRAY_SIZE (devices));gsm_init ();
Signature · 1 line
2.5.0
PATCH 9/17 ARM: pxa: palm27x: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/palm27x.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/palm27x.c +7 -2
@@ -15,6 +15,7 @@#include <linux/gpio_keys.h> #include <linux/input.h> #include <linux/pda_power.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/gpio.h> #include <linux/wm97xx.h>
@@ -270,6 +271,11 @@ void __init palm27x_ac97_init(int minv, int maxv, int jack, int reset)* Backlight ******************************************************************************/ #if defined(CONFIG_BACKLIGHT_PWM ) || defined(CONFIG_BACKLIGHT_PWM_MODULE ) +static struct pwm_lookup palm27x_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,0 ,"pwm-backlight.0" ,NULL ,3500 *1024 , +PWM_POLARITY_NORMAL ), +}; +static int palm_bl_power;static int palm_lcd_power;
@@ -318,10 +324,8 @@ static void palm27x_backlight_exit(struct device *dev) }static struct platform_pwm_backlight_data palm27x_backlight_data = { - .pwm_id =0 , .max_brightness =0xfe , .dft_brightness =0x7e , - .pwm_period_ns =3500 *1024 , .enable_gpio =-1 , .init = palm27x_backlight_init, .notify = palm27x_backlight_notify,
@@ -340,6 +344,7 @@ void __init palm27x_pwm_init(int bl, int lcd) { palm_bl_power = bl; palm_lcd_power = lcd; +pwm_add_lookup (palm27x_pwm_lookup,ARRAY_SIZE (palm27x_pwm_lookup));platform_device_register (&palm27x_backlight); }#endif
Signature · 1 line
2.5.0
PATCH 10/17 ARM: pxa: palmtc: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/palmtc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/palmtc.c +7 -2
@@ -18,6 +18,7 @@#include <linux/delay.h> #include <linux/irq.h> #include <linux/input.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/gpio.h> #include <linux/input/matrix_keypad.h>
@@ -166,11 +167,14 @@ static inline void palmtc_keys_init(void) {}* Backlight ******************************************************************************/ #if defined(CONFIG_BACKLIGHT_PWM ) || defined(CONFIG_BACKLIGHT_PWM_MODULE ) +static struct pwm_lookup palmtc_pwm_lookup[] = { +PWM_LOOKUP ("pxa25x-pwm.1" ,0 ,"pwm-backlight.0" ,NULL ,PALMTC_PERIOD_NS , +PWM_PERIOD_NORMAL ), +}; +static struct platform_pwm_backlight_data palmtc_backlight_data = { - .pwm_id =1 , .max_brightness =PALMTC_MAX_INTENSITY , .dft_brightness =PALMTC_MAX_INTENSITY , - .pwm_period_ns =PALMTC_PERIOD_NS , .enable_gpio =GPIO_NR_PALMTC_BL_POWER , };
@@ -184,6 +188,7 @@ static struct platform_device palmtc_backlight = {static void __init palmtc_pwm_init (void ) { +pwm_add_table (palmtc_pwm_lookup,ARRAY_SIZE (palmtc_pwm_lookup));platform_device_register (&palmtc_backlight); }#else
Signature · 1 line
2.5.0
PATCH 11/17 ARM: pxa: palmte2: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/palmte2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/palmte2.c +7 -2
@@ -21,6 +21,7 @@#include <linux/gpio_keys.h> #include <linux/input.h> #include <linux/pda_power.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/gpio.h> #include <linux/wm97xx.h>
@@ -138,6 +139,11 @@ static struct platform_device palmte2_pxa_keys = {/****************************************************************************** * Backlight ******************************************************************************/ +static struct pwm_lookup palmte2_pwm_lookup[] = { +PWM_LOOKUP ("pxa25x-pwm.0" ,0 ,"pwm-backlight.0" ,NULL , +PALMTE2_PERIOD_NS ,PWM_POLARITY_NORMAL ), +}; +static struct gpio palmte_bl_gpios[] = { {GPIO_NR_PALMTE2_BL_POWER ,GPIOF_INIT_LOW ,"Backlight power" }, {GPIO_NR_PALMTE2_LCD_POWER ,GPIOF_INIT_LOW ,"LCD power" },
@@ -161,10 +167,8 @@ static void palmte2_backlight_exit(struct device *dev) }static struct platform_pwm_backlight_data palmte2_backlight_data = { - .pwm_id =0 , .max_brightness =PALMTE2_MAX_INTENSITY , .dft_brightness =PALMTE2_MAX_INTENSITY , - .pwm_period_ns =PALMTE2_PERIOD_NS , .enable_gpio =-1 , .init = palmte2_backlight_init, .notify = palmte2_backlight_notify,
@@ -355,6 +359,7 @@ static void __init palmte2_init(void)pxa_set_ac97_info (&palmte2_ac97_pdata);pxa_set_ficp_info (&palmte2_ficp_platform_data); +pwm_add_table (palmte2_pwm_lookup,ARRAY_SIZE (palmte2_pwm_lookup));platform_add_devices (devices,ARRAY_SIZE (devices)); }
Signature · 1 line
2.5.0
PATCH 12/17 ARM: pxa: pcm990: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/pcm990-baseboard.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/pcm990-baseboard.c +7 -2
@@ -24,6 +24,7 @@#include <linux/platform_device.h> #include <linux/i2c.h> #include <linux/i2c/pxa-i2c.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <media/mt9v022.h>
@@ -148,11 +149,14 @@ static struct pxafb_mach_info pcm990_fbinfo __initdata = { };#endif +static struct pwm_lookup pcm990_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,0 ,"pwm-backlight.0" ,NULL ,78770 , +PWM_POLARITY_NORMAL ), +}; +static struct platform_pwm_backlight_data pcm990_backlight_data = { - .pwm_id =0 , .max_brightness =1023 , .dft_brightness =1023 , - .pwm_period_ns =78770 , .enable_gpio =-1 , };
@@ -542,6 +546,7 @@ void __init pcm990_baseboard_init(void)#ifndef CONFIG_PCM990_DISPLAY_NONE pxa_set_fb_info (NULL , &pcm990_fbinfo);#endif +pwm_add_table (pcm990_pwm_lookup,ARRAY_SIZE (pcm990_pwm_lookup));platform_device_register (&pcm990_backlight_device);/* MMC */
Signature · 1 line
2.5.0
PATCH 13/17 ARM: pxa: raumfeld: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/raumfeld.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/arm/mach-pxa/raumfeld.c +8 -3
@@ -29,6 +29,7 @@#include <linux/leds.h> #include <linux/w1-gpio.h> #include <linux/sched.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/i2c.h> #include <linux/i2c/pxa-i2c.h>
@@ -531,13 +532,15 @@ static void __init raumfeld_w1_init(void)* Framebuffer device */ +static struct pwm_lookup raumfeld_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,0 ,"pwm-backlight" ,NULL ,10000 , +PWM_POLARITY_NORMAL ), +}; +/* PWM controlled backlight */ static struct platform_pwm_backlight_data raumfeld_pwm_backlight_data = { - .pwm_id =0 , .max_brightness =100 , .dft_brightness =100 , -/* 10000 ns = 10 ms ^= 100 kHz */ - .pwm_period_ns =10000 , .enable_gpio =-1 , };
@@ -618,6 +621,8 @@ static void __init raumfeld_lcd_init(void) }else {mfp_cfg_t raumfeld_pwm_pin_config =GPIO17_PWM0_OUT ;pxa3xx_mfp_config (&raumfeld_pwm_pin_config,1 ); +pwm_add_table (raumfeld_pwm_lookup, +ARRAY_SIZE (raumfeld_pwm_lookup));platform_device_register (&raumfeld_pwm_backlight_device); }
Signature · 1 line
2.5.0
PATCH 14/17 ARM: pxa: tavorevb: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/tavorevb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
arch/arm/mach-pxa/tavorevb.c +9 -4
@@ -18,6 +18,7 @@#include <linux/clk.h> #include <linux/gpio.h> #include <linux/smc91x.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <asm/mach-types.h>
@@ -168,21 +169,24 @@ static inline void tavorevb_init_keypad(void) {}#endif /* CONFIG_KEYBOARD_PXA27x || CONFIG_KEYBOARD_PXA27x_MODULE */ #if defined(CONFIG_FB_PXA ) || defined(CONFIG_FB_PXA_MODULE ) +static struct pwm_lookup tavorevb_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.0" ,1 ,"pwm-backlight.0" ,NULL ,100000 , +PWM_POLARITY_NORMAL ), +PWM_LOOKUP ("pxa27x-pwm.0" ,0 ,"pwm-backlight.1" ,NULL ,100000 , +PWM_POLARITY_NORMAL ), +}; +static struct platform_pwm_backlight_data tavorevb_backlight_data[] = { [0 ] = {/* primary backlight */ - .pwm_id =2 , .max_brightness =100 , .dft_brightness =100 , - .pwm_period_ns =100000 , .enable_gpio =-1 , }, [1 ] = {/* secondary backlight */ - .pwm_id =0 , .max_brightness =100 , .dft_brightness =100 , - .pwm_period_ns =100000 , .enable_gpio =-1 , }, };
@@ -470,6 +474,7 @@ static struct pxafb_mach_info tavorevb_lcd_info = {static void __init tavorevb_init_lcd (void ) { +pwm_add_table (tavorevb_pwm_lookup,ARRAY_SIZE (tavorevb_pwm_lookup));platform_device_register (&tavorevb_backlight_devices[0 ]);platform_device_register (&tavorevb_backlight_devices[1 ]);pxa_set_fb_info (NULL , &tavorevb_lcd_info);
Signature · 1 line
2.5.0
PATCH 15/17 ARM: pxa: viper: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/viper.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/viper.c +7 -2
@@ -39,6 +39,7 @@#include <linux/i2c/pxa-i2c.h> #include <linux/serial_8250.h> #include <linux/smc91x.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/usb/isp116x.h> #include <linux/mtd/mtd.h>
@@ -350,6 +351,11 @@ static struct pxafb_mach_info fb_info = { .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, }; +static struct pwm_lookup viper_pwm_lookup[] = { +PWM_LOOKUP ("pxa25x-pwm.0" ,0 ,"pwm-backlight.0" ,NULL ,1000000 , +PWM_POLARITY_NORMAL ), +}; +static int viper_backlight_init (struct device *dev) {int ret;
@@ -398,10 +404,8 @@ static void viper_backlight_exit(struct device *dev) }static struct platform_pwm_backlight_data viper_backlight_data = { - .pwm_id =0 , .max_brightness =100 , .dft_brightness =100 , - .pwm_period_ns =1000000 , .enable_gpio =-1 , .init = viper_backlight_init, .notify = viper_backlight_notify,
@@ -939,6 +943,7 @@ static void __init viper_init(void) smc91x_device.num_resources--;pxa_set_i2c_info (NULL ); +pwm_add_table (viper_pwm_lookup,ARRAY_SIZE (viper_pwm_lookup));platform_add_devices (viper_devs,ARRAY_SIZE (viper_devs));viper_init_vcore_gpios ();
Signature · 1 line
2.5.0
PATCH 16/17 ARM: pxa: z2: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/z2.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
arch/arm/mach-pxa/z2.c +9 -4
@@ -16,6 +16,7 @@#include <linux/platform_device.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/z2_battery.h> #include <linux/dma-mapping.h>
@@ -199,21 +200,24 @@ static inline void z2_nor_init(void) {}* Backlight ******************************************************************************/ #if defined(CONFIG_BACKLIGHT_PWM ) || defined(CONFIG_BACKLIGHT_PWM_MODULE ) +static struct pwm_lookup z2_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.1" ,0 ,"pwm-backlight.0" ,NULL ,1260320 , +PWM_POLARITY_NORMAL ), +PWM_LOOKUP ("pxa27x-pwm.0" ,1 ,"pwm-backlight.1" ,NULL ,1260320 , +PWM_POLARITY_NORMAL ), +}; +static struct platform_pwm_backlight_data z2_backlight_data[] = { [0 ] = {/* Keypad Backlight */ - .pwm_id =1 , .max_brightness =1023 , .dft_brightness =0 , - .pwm_period_ns =1260320 , .enable_gpio =-1 , }, [1 ] = {/* LCD Backlight */ - .pwm_id =2 , .max_brightness =1023 , .dft_brightness =512 , - .pwm_period_ns =1260320 , .enable_gpio =-1 , }, };
@@ -236,6 +240,7 @@ static struct platform_device z2_backlight_devices[2] = { };static void __init z2_pwm_init (void ) { +pwm_add_table (z2_pwm_lookup,ARRAY_SIZE (z2_pwm_lookup));platform_device_register (&z2_backlight_devices[0 ]);platform_device_register (&z2_backlight_devices[1 ]); }
Signature · 1 line
2.5.0
PATCH 17/17 ARM: pxa: zylonite: Use PWM lookup table
In reply to Thierry RedingUse a PWM lookup table to provide the PWM to the pwm-backlight device. The driver has a legacy code path that is required only because boards still use the legacy method of requesting PWMs by global ID. Replacing these usages allows that legacy fallback to be removed.
--- arch/arm/mach-pxa/zylonite.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/zylonite.c +7 -2
@@ -19,6 +19,7 @@#include <linux/init.h> #include <linux/platform_device.h> #include <linux/gpio.h> +#include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <linux/smc91x.h>
@@ -120,11 +121,14 @@ static inline void zylonite_init_leds(void) {}#endif #if defined(CONFIG_FB_PXA ) || defined(CONFIG_FB_PXA_MODULE ) +static struct pwm_lookup zylonite_pwm_lookup[] = { +PWM_LOOKUP ("pxa27x-pwm.1" ,1 ,"pwm-backlight.0" ,NULL ,10000 , +PWM_POLARITY_NORMAL ), +}; +static struct platform_pwm_backlight_data zylonite_backlight_data = { - .pwm_id =3 , .max_brightness =100 , .dft_brightness =100 , - .pwm_period_ns =10000 , .enable_gpio =-1 , };
@@ -206,6 +210,7 @@ static struct pxafb_mach_info zylonite_sharp_lcd_info = {static void __init zylonite_init_lcd (void ) { +pwm_add_table (zylonite_pwm_lookup,ARRAY_SIZE (zylonite_pwm_lookup));platform_device_register (&zylonite_backlight_device);if (lcd_id &0x20 ) {
Signature · 1 line
2.5.0
Robert Jarzmik
maintainercover ARM: pxa: Use PWM lookup tables
In reply to Thierry RedingQuoted 10 lines · Thierry Reding
Back when the PWM framework was introduced the concept of PWM lookup tables was added to allow board code to register a table of PWM devices and their association with consumers. The goal is to allow drivers to use a unified method to request PWM devices. At the same time, since no boards were exposing these tables, fallback code was kept in drivers to allow old code to remain functional. Unfortunately I got the numbering of PWM devices wrong, so all these boards should now be without working backlight control, though only a few cases have been fixed since, so I guess most of this hardware is largely unused.
Quoted 4 lines
This series aims at finally fixing this up. It converts all PXA boards that hook up a pwm-backlight device to use the new PWM lookup tables. All patches have been compile-tested, but I don't have access to any of these boards, so I couldn't verify that they really work.
Hi Thierry,
Thanks for this serie. I'll test it in the next days. It looks good to me, at least the 5 patches I had a look into, so if it works on the 5 boards I have, I'll queue it up in pxa/for-next.
Cheers.
Signature · 4 lines
Robert PS: removed all the addresses at openezx.org, don't see to work, or at least make my MTA very angry.