Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

backlight: pwm_bl: Switch to full GPIO descriptor

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>

authored by

Linus Walleij and committed by
Lee Jones
2644f912 bb6d3fb3

+11 -49
-1
arch/arm/mach-pxa/cm-x300.c
··· 312 312 static struct platform_pwm_backlight_data cm_x300_backlight_data = { 313 313 .max_brightness = 100, 314 314 .dft_brightness = 100, 315 - .enable_gpio = -1, 316 315 }; 317 316 318 317 static struct platform_device cm_x300_backlight_device = {
-1
arch/arm/mach-pxa/colibri-pxa270-income.c
··· 202 202 static struct platform_pwm_backlight_data income_backlight_data = { 203 203 .max_brightness = 0x3ff, 204 204 .dft_brightness = 0x1ff, 205 - .enable_gpio = -1, 206 205 }; 207 206 208 207 static struct platform_device income_backlight = {
-1
arch/arm/mach-pxa/ezx.c
··· 55 55 static struct platform_pwm_backlight_data ezx_backlight_data = { 56 56 .max_brightness = 1023, 57 57 .dft_brightness = 1023, 58 - .enable_gpio = -1, 59 58 }; 60 59 61 60 static struct platform_device ezx_backlight_device = {
-1
arch/arm/mach-pxa/hx4700.c
··· 556 556 static struct platform_pwm_backlight_data backlight_data = { 557 557 .max_brightness = 200, 558 558 .dft_brightness = 100, 559 - .enable_gpio = -1, 560 559 }; 561 560 562 561 static struct platform_device backlight = {
-1
arch/arm/mach-pxa/lpd270.c
··· 277 277 static struct platform_pwm_backlight_data lpd270_backlight_data = { 278 278 .max_brightness = 1, 279 279 .dft_brightness = 1, 280 - .enable_gpio = -1, 281 280 }; 282 281 283 282 static struct platform_device lpd270_backlight_device = {
-1
arch/arm/mach-pxa/magician.c
··· 401 401 static struct platform_pwm_backlight_data backlight_data = { 402 402 .max_brightness = 272, 403 403 .dft_brightness = 100, 404 - .enable_gpio = -1, 405 404 .init = magician_backlight_init, 406 405 .notify = magician_backlight_notify, 407 406 .exit = magician_backlight_exit,
-1
arch/arm/mach-pxa/mainstone.c
··· 256 256 static struct platform_pwm_backlight_data mainstone_backlight_data = { 257 257 .max_brightness = 1023, 258 258 .dft_brightness = 1023, 259 - .enable_gpio = -1, 260 259 }; 261 260 262 261 static struct platform_device mainstone_backlight_device = {
-1
arch/arm/mach-pxa/mioa701.c
··· 176 176 static struct platform_pwm_backlight_data mioa701_backlight_data = { 177 177 .max_brightness = 100, 178 178 .dft_brightness = 50, 179 - .enable_gpio = -1, 180 179 }; 181 180 182 181 /*
-1
arch/arm/mach-pxa/palm27x.c
··· 318 318 static struct platform_pwm_backlight_data palm27x_backlight_data = { 319 319 .max_brightness = 0xfe, 320 320 .dft_brightness = 0x7e, 321 - .enable_gpio = -1, 322 321 .init = palm27x_backlight_init, 323 322 .notify = palm27x_backlight_notify, 324 323 .exit = palm27x_backlight_exit,
+10 -1
arch/arm/mach-pxa/palmtc.c
··· 174 174 * Backlight 175 175 ******************************************************************************/ 176 176 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE) 177 + 178 + static struct gpiod_lookup_table palmtc_pwm_bl_gpio_table = { 179 + .dev_id = "pwm-backlight.0", 180 + .table = { 181 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_BL_POWER, 182 + "enable", GPIO_ACTIVE_HIGH), 183 + }, 184 + }; 185 + 177 186 static struct pwm_lookup palmtc_pwm_lookup[] = { 178 187 PWM_LOOKUP("pxa25x-pwm.1", 0, "pwm-backlight.0", NULL, PALMTC_PERIOD_NS, 179 188 PWM_POLARITY_NORMAL), ··· 191 182 static struct platform_pwm_backlight_data palmtc_backlight_data = { 192 183 .max_brightness = PALMTC_MAX_INTENSITY, 193 184 .dft_brightness = PALMTC_MAX_INTENSITY, 194 - .enable_gpio = GPIO_NR_PALMTC_BL_POWER, 195 185 }; 196 186 197 187 static struct platform_device palmtc_backlight = { ··· 203 195 204 196 static void __init palmtc_pwm_init(void) 205 197 { 198 + gpiod_add_lookup_table(&palmtc_pwm_bl_gpio_table); 206 199 pwm_add_table(palmtc_pwm_lookup, ARRAY_SIZE(palmtc_pwm_lookup)); 207 200 platform_device_register(&palmtc_backlight); 208 201 }
-1
arch/arm/mach-pxa/palmte2.c
··· 175 175 static struct platform_pwm_backlight_data palmte2_backlight_data = { 176 176 .max_brightness = PALMTE2_MAX_INTENSITY, 177 177 .dft_brightness = PALMTE2_MAX_INTENSITY, 178 - .enable_gpio = -1, 179 178 .init = palmte2_backlight_init, 180 179 .notify = palmte2_backlight_notify, 181 180 .exit = palmte2_backlight_exit,
-1
arch/arm/mach-pxa/pcm990-baseboard.c
··· 154 154 static struct platform_pwm_backlight_data pcm990_backlight_data = { 155 155 .max_brightness = 1023, 156 156 .dft_brightness = 1023, 157 - .enable_gpio = -1, 158 157 }; 159 158 160 159 static struct platform_device pcm990_backlight_device = {
-2
arch/arm/mach-pxa/tavorevb.c
··· 178 178 /* primary backlight */ 179 179 .max_brightness = 100, 180 180 .dft_brightness = 100, 181 - .enable_gpio = -1, 182 181 }, 183 182 [1] = { 184 183 /* secondary backlight */ 185 184 .max_brightness = 100, 186 185 .dft_brightness = 100, 187 - .enable_gpio = -1, 188 186 }, 189 187 }; 190 188
-1
arch/arm/mach-pxa/viper.c
··· 404 404 static struct platform_pwm_backlight_data viper_backlight_data = { 405 405 .max_brightness = 100, 406 406 .dft_brightness = 100, 407 - .enable_gpio = -1, 408 407 .init = viper_backlight_init, 409 408 .notify = viper_backlight_notify, 410 409 .exit = viper_backlight_exit,
-2
arch/arm/mach-pxa/z2.c
··· 210 210 /* Keypad Backlight */ 211 211 .max_brightness = 1023, 212 212 .dft_brightness = 0, 213 - .enable_gpio = -1, 214 213 }, 215 214 [1] = { 216 215 /* LCD Backlight */ 217 216 .max_brightness = 1023, 218 217 .dft_brightness = 512, 219 - .enable_gpio = -1, 220 218 }, 221 219 }; 222 220
-1
arch/arm/mach-pxa/zylonite.c
··· 117 117 static struct platform_pwm_backlight_data zylonite_backlight_data = { 118 118 .max_brightness = 100, 119 119 .dft_brightness = 100, 120 - .enable_gpio = -1, 121 120 }; 122 121 123 122 static struct platform_device zylonite_backlight_device = {
-1
arch/arm/mach-s3c24xx/mach-h1940.c
··· 516 516 static struct platform_pwm_backlight_data backlight_data = { 517 517 .max_brightness = 100, 518 518 .dft_brightness = 50, 519 - .enable_gpio = -1, 520 519 .init = h1940_backlight_init, 521 520 .notify = h1940_backlight_notify, 522 521 .exit = h1940_backlight_exit,
-1
arch/arm/mach-s3c24xx/mach-rx1950.c
··· 534 534 static struct platform_pwm_backlight_data rx1950_backlight_data = { 535 535 .max_brightness = 24, 536 536 .dft_brightness = 4, 537 - .enable_gpio = -1, 538 537 .init = rx1950_backlight_init, 539 538 .notify = rx1950_backlight_notify, 540 539 .exit = rx1950_backlight_exit,
-3
arch/arm/mach-s3c64xx/dev-backlight.c
··· 65 65 .plat_data = { 66 66 .max_brightness = 255, 67 67 .dft_brightness = 255, 68 - .enable_gpio = -1, 69 68 .init = samsung_bl_init, 70 69 .exit = samsung_bl_exit, 71 70 }, ··· 110 111 samsung_bl_data->dft_brightness = bl_data->dft_brightness; 111 112 if (bl_data->lth_brightness) 112 113 samsung_bl_data->lth_brightness = bl_data->lth_brightness; 113 - if (bl_data->enable_gpio >= 0) 114 - samsung_bl_data->enable_gpio = bl_data->enable_gpio; 115 114 if (bl_data->init) 116 115 samsung_bl_data->init = bl_data->init; 117 116 if (bl_data->notify)
-1
arch/arm/mach-s3c64xx/mach-crag6410.c
··· 114 114 static struct platform_pwm_backlight_data crag6410_backlight_data = { 115 115 .max_brightness = 1000, 116 116 .dft_brightness = 600, 117 - .enable_gpio = -1, 118 117 }; 119 118 120 119 static struct platform_device crag6410_backlight_device = {
-1
arch/arm/mach-s3c64xx/mach-hmt.c
··· 115 115 static struct platform_pwm_backlight_data hmt_backlight_data = { 116 116 .max_brightness = 100 * 256, 117 117 .dft_brightness = 40 * 256, 118 - .enable_gpio = -1, 119 118 .init = hmt_bl_init, 120 119 .notify = hmt_bl_notify, 121 120 .exit = hmt_bl_exit,
-1
arch/arm/mach-s3c64xx/mach-smartq.c
··· 150 150 static struct platform_pwm_backlight_data smartq_backlight_data = { 151 151 .max_brightness = 1000, 152 152 .dft_brightness = 600, 153 - .enable_gpio = -1, 154 153 .init = smartq_bl_init, 155 154 }; 156 155
+1 -1
arch/arm/mach-s3c64xx/mach-smdk6410.c
··· 623 623 }; 624 624 625 625 static struct platform_pwm_backlight_data smdk6410_bl_data = { 626 - .enable_gpio = -1, 626 + /* Intentionally blank */ 627 627 }; 628 628 629 629 static struct dwc2_hsotg_plat smdk6410_hsotg_pdata;
-1
arch/unicore32/kernel/puv3-nb0916.c
··· 55 55 static struct platform_pwm_backlight_data nb0916_backlight_data = { 56 56 .max_brightness = 100, 57 57 .dft_brightness = 100, 58 - .enable_gpio = -1, 59 58 }; 60 59 61 60 static struct gpio_keys_button nb0916_gpio_keys[] = {
-19
drivers/video/backlight/pwm_bl.c
··· 7 7 8 8 #include <linux/delay.h> 9 9 #include <linux/gpio/consumer.h> 10 - #include <linux/gpio.h> 11 10 #include <linux/module.h> 12 11 #include <linux/kernel.h> 13 12 #include <linux/init.h> ··· 257 258 &data->post_pwm_on_delay); 258 259 of_property_read_u32(node, "pwm-off-delay-ms", &data->pwm_off_delay); 259 260 260 - data->enable_gpio = -EINVAL; 261 - 262 261 /* 263 262 * Determine the number of brightness levels, if this property is not 264 263 * set a default table of brightness levels will be used. ··· 497 500 if (IS_ERR(pb->enable_gpio)) { 498 501 ret = PTR_ERR(pb->enable_gpio); 499 502 goto err_alloc; 500 - } 501 - 502 - /* 503 - * Compatibility fallback for drivers still using the integer GPIO 504 - * platform data. Must go away soon. 505 - */ 506 - if (!pb->enable_gpio && gpio_is_valid(data->enable_gpio)) { 507 - ret = devm_gpio_request_one(&pdev->dev, data->enable_gpio, 508 - GPIOF_OUT_INIT_HIGH, "enable"); 509 - if (ret < 0) { 510 - dev_err(&pdev->dev, "failed to request GPIO#%d: %d\n", 511 - data->enable_gpio, ret); 512 - goto err_alloc; 513 - } 514 - 515 - pb->enable_gpio = gpio_to_desc(data->enable_gpio); 516 503 } 517 504 518 505 /*
-2
include/linux/pwm_backlight.h
··· 16 16 unsigned int *levels; 17 17 unsigned int post_pwm_on_delay; 18 18 unsigned int pwm_off_delay; 19 - /* TODO remove once all users are switched to gpiod_* API */ 20 - int enable_gpio; 21 19 int (*init)(struct device *dev); 22 20 int (*notify)(struct device *dev, int brightness); 23 21 void (*notify_after)(struct device *dev, int brightness);