ARM: pxa: tavorevb: Use PWM lookup table
authorThierry Reding <thierry.reding@gmail.com>
Mon, 5 Oct 2015 08:49:54 +0000 (10:49 +0200)
committerRobert Jarzmik <robert.jarzmik@free.fr>
Wed, 14 Oct 2015 21:06:51 +0000 (23:06 +0200)
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 <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
arch/arm/mach-pxa/tavorevb.c

index a71da84..349a13a 100644 (file)
@@ -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);