backlight: pwm_bl: Switch to full GPIO descriptor
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 10 Feb 2020 10:15:46 +0000 (11:15 +0100)
committerLee Jones <lee.jones@linaro.org>
Wed, 18 Mar 2020 15:05:57 +0000 (15:05 +0000)
The PWM backlight still supports passing a enable GPIO line as
platform data using the legacy <linux/gpio.h> API.

It turns out that ever board using this mechanism except one
is pass .enable_gpio = -1. So we drop all these cargo-culted -1's
from all instances of this platform data in the kernel.

The remaning board, Palm TC, is converted to pass a machine
descriptior table with the "enable" GPIO instead, and delete the
platform data entry for enable_gpio and the code handling it
and things should work smoothly with the new API.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
26 files changed:
arch/arm/mach-pxa/cm-x300.c
arch/arm/mach-pxa/colibri-pxa270-income.c
arch/arm/mach-pxa/ezx.c
arch/arm/mach-pxa/hx4700.c
arch/arm/mach-pxa/lpd270.c
arch/arm/mach-pxa/magician.c
arch/arm/mach-pxa/mainstone.c
arch/arm/mach-pxa/mioa701.c
arch/arm/mach-pxa/palm27x.c
arch/arm/mach-pxa/palmtc.c
arch/arm/mach-pxa/palmte2.c
arch/arm/mach-pxa/pcm990-baseboard.c
arch/arm/mach-pxa/tavorevb.c
arch/arm/mach-pxa/viper.c
arch/arm/mach-pxa/z2.c
arch/arm/mach-pxa/zylonite.c
arch/arm/mach-s3c24xx/mach-h1940.c
arch/arm/mach-s3c24xx/mach-rx1950.c
arch/arm/mach-s3c64xx/dev-backlight.c
arch/arm/mach-s3c64xx/mach-crag6410.c
arch/arm/mach-s3c64xx/mach-hmt.c
arch/arm/mach-s3c64xx/mach-smartq.c
arch/arm/mach-s3c64xx/mach-smdk6410.c
arch/unicore32/kernel/puv3-nb0916.c
drivers/video/backlight/pwm_bl.c
include/linux/pwm_backlight.h

index 425855f456f2bdaa842cc740820762e1134e00cb..2e35354b61f56436745af60a67e2143e816cbdde 100644 (file)
@@ -312,7 +312,6 @@ static struct pwm_lookup cm_x300_pwm_lookup[] = {
 static struct platform_pwm_backlight_data cm_x300_backlight_data = {
        .max_brightness = 100,
        .dft_brightness = 100,
-       .enable_gpio    = -1,
 };
 
 static struct platform_device cm_x300_backlight_device = {
index dbad2f13706c8c659c31cbcf7e4b9a25d5fd04a0..e5879e8b068243eca8357226d58bc429c66a5cff 100644 (file)
@@ -202,7 +202,6 @@ static struct pwm_lookup income_pwm_lookup[] = {
 static struct platform_pwm_backlight_data income_backlight_data = {
        .max_brightness = 0x3ff,
        .dft_brightness = 0x1ff,
-       .enable_gpio    = -1,
 };
 
 static struct platform_device income_backlight = {
index ec10851b63cf1767430999a8ed4f14dd48cd45df..eb85950e7c0e8afef641b5f6dc94e727d6010aff 100644 (file)
@@ -55,7 +55,6 @@ static struct pwm_lookup ezx_pwm_lookup[] __maybe_unused = {
 static struct platform_pwm_backlight_data ezx_backlight_data = {
        .max_brightness = 1023,
        .dft_brightness = 1023,
-       .enable_gpio    = -1,
 };
 
 static struct platform_device ezx_backlight_device = {
index 238a751a87974e977cca61d4aec9e11f9369299c..1d4c5db54be29ff9831ff72dde1908b566f30f70 100644 (file)
@@ -556,7 +556,6 @@ static struct platform_device hx4700_lcd = {
 static struct platform_pwm_backlight_data backlight_data = {
        .max_brightness = 200,
        .dft_brightness = 100,
-       .enable_gpio    = -1,
 };
 
 static struct platform_device backlight = {
index 20e00e97038591ab88f2e7e55c9c9871207d3533..6fc40bc06910478afd9200aaf97dbbe7ae620af3 100644 (file)
@@ -277,7 +277,6 @@ static struct pwm_lookup lpd270_pwm_lookup[] = {
 static struct platform_pwm_backlight_data lpd270_backlight_data = {
        .max_brightness = 1,
        .dft_brightness = 1,
-       .enable_gpio    = -1,
 };
 
 static struct platform_device lpd270_backlight_device = {
index 5d0591f93f4d06cbb864e864645430758ceb0783..cd9fa465b9b2a6c62e007c23746fa72f9654b37b 100644 (file)
@@ -401,7 +401,6 @@ static void magician_backlight_exit(struct device *dev)
 static struct platform_pwm_backlight_data backlight_data = {
        .max_brightness = 272,
        .dft_brightness = 100,
-       .enable_gpio    = -1,
        .init           = magician_backlight_init,
        .notify         = magician_backlight_notify,
        .exit           = magician_backlight_exit,
index 1b78829201641e1e7397483b534ef77060cf5cb6..d1010ec26e9f6d54e430f7e65c7d937e873ed83a 100644 (file)
@@ -256,7 +256,6 @@ static struct pwm_lookup mainstone_pwm_lookup[] = {
 static struct platform_pwm_backlight_data mainstone_backlight_data = {
        .max_brightness = 1023,
        .dft_brightness = 1023,
-       .enable_gpio    = -1,
 };
 
 static struct platform_device mainstone_backlight_device = {
index 0b8bae9610f1fbd728f837e0475e00c5ea09a871..d3af80317f2dab5b80e5f153097148b5a238472e 100644 (file)
@@ -176,7 +176,6 @@ static struct pwm_lookup mioa701_pwm_lookup[] = {
 static struct platform_pwm_backlight_data mioa701_backlight_data = {
        .max_brightness = 100,
        .dft_brightness = 50,
-       .enable_gpio    = -1,
 };
 
 /*
index b600b63af3a67561db30a92ef6197ef6f89a4b98..0d246a1aebbcd624d77183efac8b3833b1f63a50 100644 (file)
@@ -318,7 +318,6 @@ static void palm27x_backlight_exit(struct device *dev)
 static struct platform_pwm_backlight_data palm27x_backlight_data = {
        .max_brightness = 0xfe,
        .dft_brightness = 0x7e,
-       .enable_gpio    = -1,
        .init           = palm27x_backlight_init,
        .notify         = palm27x_backlight_notify,
        .exit           = palm27x_backlight_exit,
index fda9deaaae022a22db00054079f74dcfbf6f9c31..455cb8ccaf26f85ac4f46915b328908a5016e7a8 100644 (file)
@@ -174,6 +174,15 @@ static inline void palmtc_keys_init(void) {}
  * Backlight
  ******************************************************************************/
 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
+
+static struct gpiod_lookup_table palmtc_pwm_bl_gpio_table = {
+       .dev_id = "pwm-backlight.0",
+       .table = {
+               GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_BL_POWER,
+                           "enable", GPIO_ACTIVE_HIGH),
+       },
+};
+
 static struct pwm_lookup palmtc_pwm_lookup[] = {
        PWM_LOOKUP("pxa25x-pwm.1", 0, "pwm-backlight.0", NULL, PALMTC_PERIOD_NS,
                   PWM_POLARITY_NORMAL),
@@ -182,7 +191,6 @@ static struct pwm_lookup palmtc_pwm_lookup[] = {
 static struct platform_pwm_backlight_data palmtc_backlight_data = {
        .max_brightness = PALMTC_MAX_INTENSITY,
        .dft_brightness = PALMTC_MAX_INTENSITY,
-       .enable_gpio    = GPIO_NR_PALMTC_BL_POWER,
 };
 
 static struct platform_device palmtc_backlight = {
@@ -195,6 +203,7 @@ static struct platform_device palmtc_backlight = {
 
 static void __init palmtc_pwm_init(void)
 {
+       gpiod_add_lookup_table(&palmtc_pwm_bl_gpio_table);
        pwm_add_table(palmtc_pwm_lookup, ARRAY_SIZE(palmtc_pwm_lookup));
        platform_device_register(&palmtc_backlight);
 }
index 7171014fd31179cb2793e1f05938db8371064db4..e3bcf58b4e6399325d3d6dd8eea3902d4ef23d19 100644 (file)
@@ -175,7 +175,6 @@ static void palmte2_backlight_exit(struct device *dev)
 static struct platform_pwm_backlight_data palmte2_backlight_data = {
        .max_brightness = PALMTE2_MAX_INTENSITY,
        .dft_brightness = PALMTE2_MAX_INTENSITY,
-       .enable_gpio    = -1,
        .init           = palmte2_backlight_init,
        .notify         = palmte2_backlight_notify,
        .exit           = palmte2_backlight_exit,
index cb1c56769fbc5f7761267b7d89a2c1c5b32cf4f6..bf613f88d70b178cca1160e3bf6937e13c03974a 100644 (file)
@@ -154,7 +154,6 @@ static struct pwm_lookup pcm990_pwm_lookup[] = {
 static struct platform_pwm_backlight_data pcm990_backlight_data = {
        .max_brightness = 1023,
        .dft_brightness = 1023,
-       .enable_gpio    = -1,
 };
 
 static struct platform_device pcm990_backlight_device = {
index 93466fa3b0fe11c8e86c58127116f28992cad18f..a15eb3b9484d2d7b7781542760783ab9779a27f1 100644 (file)
@@ -178,13 +178,11 @@ static struct platform_pwm_backlight_data tavorevb_backlight_data[] = {
                /* primary backlight */
                .max_brightness = 100,
                .dft_brightness = 100,
-               .enable_gpio    = -1,
        },
        [1] = {
                /* secondary backlight */
                .max_brightness = 100,
                .dft_brightness = 100,
-               .enable_gpio    = -1,
        },
 };
 
index c06031da66763bffe6a9203615883a63c93aabc0..3aa34e9a15d3b01fe6e97c752d2ae09d33adac3c 100644 (file)
@@ -404,7 +404,6 @@ static void viper_backlight_exit(struct device *dev)
 static struct platform_pwm_backlight_data viper_backlight_data = {
        .max_brightness = 100,
        .dft_brightness = 100,
-       .enable_gpio    = -1,
        .init           = viper_backlight_init,
        .notify         = viper_backlight_notify,
        .exit           = viper_backlight_exit,
index 900cefc4c5ea6ea0726640fd762e21129b1e28b6..21fd76bb09cdf2946e8177202467edd8fd8de84c 100644 (file)
@@ -210,13 +210,11 @@ static struct platform_pwm_backlight_data z2_backlight_data[] = {
                /* Keypad Backlight */
                .max_brightness = 1023,
                .dft_brightness = 0,
-               .enable_gpio    = -1,
        },
        [1] = {
                /* LCD Backlight */
                .max_brightness = 1023,
                .dft_brightness = 512,
-               .enable_gpio    = -1,
        },
 };
 
index bf2ab5bd49ec9676b87537aa1b78e46d4ed5163b..79f0025fa17a5c5fe621707d4cf922ab6e296db3 100644 (file)
@@ -117,7 +117,6 @@ static struct pwm_lookup zylonite_pwm_lookup[] = {
 static struct platform_pwm_backlight_data zylonite_backlight_data = {
        .max_brightness = 100,
        .dft_brightness = 100,
-       .enable_gpio    = -1,
 };
 
 static struct platform_device zylonite_backlight_device = {
index 74d6b68e91c7437aa756cdf453644968818d883e..e1c372e5447b6a5b9bb9707da961b872a4782c47 100644 (file)
@@ -516,7 +516,6 @@ static void h1940_backlight_exit(struct device *dev)
 static struct platform_pwm_backlight_data backlight_data = {
        .max_brightness = 100,
        .dft_brightness = 50,
-       .enable_gpio    = -1,
        .init           = h1940_backlight_init,
        .notify         = h1940_backlight_notify,
        .exit           = h1940_backlight_exit,
index 03d8f27cdc32fc6205accebb5eaeba8884677717..fde98b175c7521ea5e621adcda7b6370cc8edff6 100644 (file)
@@ -534,7 +534,6 @@ static int rx1950_backlight_notify(struct device *dev, int brightness)
 static struct platform_pwm_backlight_data rx1950_backlight_data = {
        .max_brightness = 24,
        .dft_brightness = 4,
-       .enable_gpio = -1,
        .init = rx1950_backlight_init,
        .notify = rx1950_backlight_notify,
        .exit = rx1950_backlight_exit,
index 799cfdf0606b300ca11cb493bcc511d7ccd81bff..09e6da305f6071bdd386fb4c96f184c72b3900ca 100644 (file)
@@ -65,7 +65,6 @@ static struct samsung_bl_drvdata samsung_dfl_bl_data __initdata = {
        .plat_data = {
                .max_brightness = 255,
                .dft_brightness = 255,
-               .enable_gpio    = -1,
                .init           = samsung_bl_init,
                .exit           = samsung_bl_exit,
        },
@@ -111,8 +110,6 @@ void __init samsung_bl_set(struct samsung_bl_gpio_info *gpio_info,
                samsung_bl_data->dft_brightness = bl_data->dft_brightness;
        if (bl_data->lth_brightness)
                samsung_bl_data->lth_brightness = bl_data->lth_brightness;
-       if (bl_data->enable_gpio >= 0)
-               samsung_bl_data->enable_gpio = bl_data->enable_gpio;
        if (bl_data->init)
                samsung_bl_data->init = bl_data->init;
        if (bl_data->notify)
index 8ec6a4f5eb050cacdcade6ad1044253fe60a38c4..da9654255e3f0251b8318d715b6ba0a63a98d334 100644 (file)
@@ -114,7 +114,6 @@ static struct pwm_lookup crag6410_pwm_lookup[] = {
 static struct platform_pwm_backlight_data crag6410_backlight_data = {
        .max_brightness = 1000,
        .dft_brightness = 600,
-       .enable_gpio    = -1,
 };
 
 static struct platform_device crag6410_backlight_device = {
index bfe9881d12cc7daf73a57706d198bcb7039e0ca1..e7080215c624c91aafede19a5374756bb7807e0f 100644 (file)
@@ -115,7 +115,6 @@ static void hmt_bl_exit(struct device *dev)
 static struct platform_pwm_backlight_data hmt_backlight_data = {
        .max_brightness = 100 * 256,
        .dft_brightness = 40 * 256,
-       .enable_gpio    = -1,
        .init           = hmt_bl_init,
        .notify         = hmt_bl_notify,
        .exit           = hmt_bl_exit,
index 829d5dbd69eefe4242ab3e810e7a72489b9cf188..5025db607c0fbaa80b575c387749448e03f8bf77 100644 (file)
@@ -150,7 +150,6 @@ static int smartq_bl_init(struct device *dev)
 static struct platform_pwm_backlight_data smartq_backlight_data = {
        .max_brightness = 1000,
        .dft_brightness = 600,
-       .enable_gpio    = -1,
        .init           = smartq_bl_init,
 };
 
index 908e5aa831c81cb234e145e29189a1659e62908a..56f406c0c3dde6e36b21417332ca3be579584227 100644 (file)
@@ -623,7 +623,7 @@ static struct pwm_lookup smdk6410_pwm_lookup[] = {
 };
 
 static struct platform_pwm_backlight_data smdk6410_bl_data = {
-       .enable_gpio = -1,
+       /* Intentionally blank */
 };
 
 static struct dwc2_hsotg_plat smdk6410_hsotg_pdata;
index a3bf2ffc54dde57a71d7e785c2caf95e3cef405e..e251f502839624941dc8cb336b19ae8b16eb6d2f 100644 (file)
@@ -55,7 +55,6 @@ static struct pwm_lookup nb0916_pwm_lookup[] = {
 static struct platform_pwm_backlight_data nb0916_backlight_data = {
        .max_brightness = 100,
        .dft_brightness = 100,
-       .enable_gpio    = -1,
 };
 
 static struct gpio_keys_button nb0916_gpio_keys[] = {
index efb4efc2a13d2fa697e384403be86ac988faffeb..82b8d7594701d00e9b4fab22c346e55dc92bcc7a 100644 (file)
@@ -7,7 +7,6 @@
 
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
-#include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -258,8 +257,6 @@ static int pwm_backlight_parse_dt(struct device *dev,
                             &data->post_pwm_on_delay);
        of_property_read_u32(node, "pwm-off-delay-ms", &data->pwm_off_delay);
 
-       data->enable_gpio = -EINVAL;
-
        /*
         * Determine the number of brightness levels, if this property is not
         * set a default table of brightness levels will be used.
@@ -502,22 +499,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
                goto err_alloc;
        }
 
-       /*
-        * Compatibility fallback for drivers still using the integer GPIO
-        * platform data. Must go away soon.
-        */
-       if (!pb->enable_gpio && gpio_is_valid(data->enable_gpio)) {
-               ret = devm_gpio_request_one(&pdev->dev, data->enable_gpio,
-                                           GPIOF_OUT_INIT_HIGH, "enable");
-               if (ret < 0) {
-                       dev_err(&pdev->dev, "failed to request GPIO#%d: %d\n",
-                               data->enable_gpio, ret);
-                       goto err_alloc;
-               }
-
-               pb->enable_gpio = gpio_to_desc(data->enable_gpio);
-       }
-
        /*
         * If the GPIO is not known to be already configured as output, that
         * is, if gpiod_get_direction returns either 1 or -EINVAL, change the
index 8ea265a022fdb3752476ea1e1e2ef8def054b041..06086cb93b6ffdf0baef4cc7e33581c61971cf5d 100644 (file)
@@ -16,8 +16,6 @@ struct platform_pwm_backlight_data {
        unsigned int *levels;
        unsigned int post_pwm_on_delay;
        unsigned int pwm_off_delay;
-       /* TODO remove once all users are switched to gpiod_* API */
-       int enable_gpio;
        int (*init)(struct device *dev);
        int (*notify)(struct device *dev, int brightness);
        void (*notify_after)(struct device *dev, int brightness);