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

Merge tag 'backlight-next-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight

Pull backlight updates from Lee Jones:
"Core Frameworks
- Provide helpers to enable/disable backlight
- Provide standard and devres versions OF find helpers

New Drivers:
- Add support for the Zodiac Inflight Innovations RAVE Supervisory
Processor

New Functionality:
- Allow pwm-on/pwm-off delay to be specified via DT

Bug Fixes:
- Fix ordering of the power {en,dis}able and PWM {en,dis}able
signals
- Fix Device Tree node look-up"

* tag 'backlight-next-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
backlight: as3711_bl: Fix Device Tree node leaks
backlight: tps65217_bl: Fix Device Tree node lookup
backlight: max8925_bl: Fix Device Tree node lookup
backlight: as3711_bl: Fix Device Tree node lookup
MAINTAINERS: Add dri-devel for backlight subsystem patches
backlight: Nuke BL_CORE_DRIVER1
staging: fbtft: Stop using BL_CORE_DRIVER1
backlight: pandora: Stop using BL_CORE_DRIVER1
backlight: generic-bl: Remove DRIVER1 state
backlight: Nuke unused backlight.props.state states
backlight: otm3225a: Add support for ORISE OTM3225A LCD SoC
backlight: pwm_bl: Don't use GPIOF_* with gpiod_get_direction
pwm-backlight: Add support for PWM delays proprieties.
dt-bindings: pwm-backlight: Add PWM delay proprieties.
pwm-backlight: Enable/disable the PWM before/after LCD enable toggle.
dt-bindings: backlight: Add binding for RAVE SP backlight driver
backlight: Add RAVE SP backlight driver

+466 -46
+6
Documentation/devicetree/bindings/leds/backlight/pwm-backlight.txt
··· 17 17 "pwms" property (see PWM binding[0]) 18 18 - enable-gpios: contains a single GPIO specifier for the GPIO which enables 19 19 and disables the backlight (see GPIO binding[1]) 20 + - post-pwm-on-delay-ms: Delay in ms between setting an initial (non-zero) PWM 21 + and enabling the backlight using GPIO. 22 + - pwm-off-delay-ms: Delay in ms between disabling the backlight using GPIO 23 + and setting PWM value to 0. 20 24 21 25 [0]: Documentation/devicetree/bindings/pwm/pwm.txt 22 26 [1]: Documentation/devicetree/bindings/gpio/gpio.txt ··· 36 32 37 33 power-supply = <&vdd_bl_reg>; 38 34 enable-gpios = <&gpio 58 0>; 35 + post-pwm-on-delay-ms = <10>; 36 + pwm-off-delay-ms = <10>; 39 37 };
+23
Documentation/devicetree/bindings/leds/backlight/zii,rave-sp-backlight.txt
··· 1 + Zodiac Inflight Innovations RAVE Supervisory Processor Backlight Bindings 2 + 3 + RAVE SP backlight device is a "MFD cell" device corresponding to 4 + backlight functionality of RAVE Supervisory Processor. It is expected 5 + that its Device Tree node is specified as a child of the node 6 + corresponding to the parent RAVE SP device (as documented in 7 + Documentation/devicetree/bindings/mfd/zii,rave-sp.txt) 8 + 9 + Required properties: 10 + 11 + - compatible: Should be "zii,rave-sp-backlight" 12 + 13 + Example: 14 + 15 + rave-sp { 16 + compatible = "zii,rave-sp-rdu1"; 17 + current-speed = <38400>; 18 + 19 + backlight { 20 + compatible = "zii,rave-sp-backlight"; 21 + }; 22 + } 23 +
+1
MAINTAINERS
··· 2606 2606 M: Lee Jones <lee.jones@linaro.org> 2607 2607 M: Daniel Thompson <daniel.thompson@linaro.org> 2608 2608 M: Jingoo Han <jingoohan1@gmail.com> 2609 + L: dri-devel@lists.freedesktop.org 2609 2610 T: git git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight.git 2610 2611 S: Maintained 2611 2612 F: drivers/video/backlight/
+2 -2
drivers/staging/fbtft/fbtft-core.c
··· 246 246 static int fbtft_backlight_update_status(struct backlight_device *bd) 247 247 { 248 248 struct fbtft_par *par = bl_get_data(bd); 249 - bool polarity = !!(bd->props.state & BL_CORE_DRIVER1); 249 + bool polarity = par->polarity; 250 250 251 251 fbtft_par_dbg(DEBUG_BACKLIGHT, par, 252 252 "%s: polarity=%d, power=%d, fb_blank=%d\n", ··· 296 296 /* Assume backlight is off, get polarity from current state of pin */ 297 297 bl_props.power = FB_BLANK_POWERDOWN; 298 298 if (!gpio_get_value(par->gpio.led[0])) 299 - bl_props.state |= BL_CORE_DRIVER1; 299 + par->polarity = true; 300 300 301 301 bd = backlight_device_register(dev_driver_string(par->info->device), 302 302 par->info->device, par,
+1
drivers/staging/fbtft/fbtft.h
··· 229 229 ktime_t update_time; 230 230 bool bgr; 231 231 void *extra; 232 + bool polarity; 232 233 }; 233 234 234 235 #define NUMARGS(...) (sizeof((int[]){__VA_ARGS__})/sizeof(int))
+13
drivers/video/backlight/Kconfig
··· 150 150 If you have a HX-8357 LCD panel, say Y to enable its LCD control 151 151 driver. 152 152 153 + config LCD_OTM3225A 154 + tristate "ORISE Technology OTM3225A support" 155 + depends on SPI 156 + help 157 + If you have a panel based on the OTM3225A controller 158 + chip then say y to include a driver for it. 159 + 153 160 endif # LCD_CLASS_DEVICE 154 161 155 162 # ··· 473 466 help 474 467 If you have an ARCxCnnnn family backlight say Y to enable 475 468 the backlight driver. 469 + 470 + config BACKLIGHT_RAVE_SP 471 + tristate "RAVE SP Backlight driver" 472 + depends on RAVE_SP_CORE 473 + help 474 + Support for backlight control on RAVE SP device. 476 475 477 476 endif # BACKLIGHT_CLASS_DEVICE 478 477
+2
drivers/video/backlight/Makefile
··· 13 13 obj-$(CONFIG_LCD_LMS283GF05) += lms283gf05.o 14 14 obj-$(CONFIG_LCD_LMS501KF03) += lms501kf03.o 15 15 obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o 16 + obj-$(CONFIG_LCD_OTM3225A) += otm3225a.o 16 17 obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o 17 18 obj-$(CONFIG_LCD_S6E63M0) += s6e63m0.o 18 19 obj-$(CONFIG_LCD_TDO24M) += tdo24m.o ··· 58 57 obj-$(CONFIG_BACKLIGHT_TPS65217) += tps65217_bl.o 59 58 obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o 60 59 obj-$(CONFIG_BACKLIGHT_ARCXCNN) += arcxcnn_bl.o 60 + obj-$(CONFIG_BACKLIGHT_RAVE_SP) += rave-sp-backlight.o
+29 -16
drivers/video/backlight/as3711_bl.c
··· 28 28 29 29 struct as3711_bl_data { 30 30 bool powered; 31 - const char *fb_name; 32 - struct device *fb_dev; 33 31 enum as3711_bl_type type; 34 32 int brightness; 35 33 struct backlight_device *bl; ··· 260 262 static int as3711_backlight_parse_dt(struct device *dev) 261 263 { 262 264 struct as3711_bl_pdata *pdata = dev_get_platdata(dev); 263 - struct device_node *bl = 264 - of_find_node_by_name(dev->parent->of_node, "backlight"), *fb; 265 + struct device_node *bl, *fb; 265 266 int ret; 266 267 268 + bl = of_get_child_by_name(dev->parent->of_node, "backlight"); 267 269 if (!bl) { 268 270 dev_dbg(dev, "backlight node not found\n"); 269 271 return -ENODEV; ··· 271 273 272 274 fb = of_parse_phandle(bl, "su1-dev", 0); 273 275 if (fb) { 274 - pdata->su1_fb = fb->full_name; 276 + of_node_put(fb); 277 + 278 + pdata->su1_fb = true; 275 279 276 280 ret = of_property_read_u32(bl, "su1-max-uA", &pdata->su1_max_uA); 277 281 if (pdata->su1_max_uA <= 0) 278 282 ret = -EINVAL; 279 283 if (ret < 0) 280 - return ret; 284 + goto err_put_bl; 281 285 } 282 286 283 287 fb = of_parse_phandle(bl, "su2-dev", 0); 284 288 if (fb) { 285 289 int count = 0; 286 290 287 - pdata->su2_fb = fb->full_name; 291 + of_node_put(fb); 292 + 293 + pdata->su2_fb = true; 288 294 289 295 ret = of_property_read_u32(bl, "su2-max-uA", &pdata->su2_max_uA); 290 296 if (pdata->su2_max_uA <= 0) 291 297 ret = -EINVAL; 292 298 if (ret < 0) 293 - return ret; 299 + goto err_put_bl; 294 300 295 301 if (of_find_property(bl, "su2-feedback-voltage", NULL)) { 296 302 pdata->su2_feedback = AS3711_SU2_VOLTAGE; ··· 316 314 pdata->su2_feedback = AS3711_SU2_CURR_AUTO; 317 315 count++; 318 316 } 319 - if (count != 1) 320 - return -EINVAL; 317 + if (count != 1) { 318 + ret = -EINVAL; 319 + goto err_put_bl; 320 + } 321 321 322 322 count = 0; 323 323 if (of_find_property(bl, "su2-fbprot-lx-sd4", NULL)) { ··· 338 334 pdata->su2_fbprot = AS3711_SU2_GPIO4; 339 335 count++; 340 336 } 341 - if (count != 1) 342 - return -EINVAL; 337 + if (count != 1) { 338 + ret = -EINVAL; 339 + goto err_put_bl; 340 + } 343 341 344 342 count = 0; 345 343 if (of_find_property(bl, "su2-auto-curr1", NULL)) { ··· 361 355 * At least one su2-auto-curr* must be specified iff 362 356 * AS3711_SU2_CURR_AUTO is used 363 357 */ 364 - if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) 365 - return -EINVAL; 358 + if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) { 359 + ret = -EINVAL; 360 + goto err_put_bl; 361 + } 366 362 } 367 363 364 + of_node_put(bl); 365 + 368 366 return 0; 367 + 368 + err_put_bl: 369 + of_node_put(bl); 370 + 371 + return ret; 369 372 } 370 373 371 374 static int as3711_backlight_probe(struct platform_device *pdev) ··· 427 412 428 413 if (pdata->su1_fb) { 429 414 su = &supply->su1; 430 - su->fb_name = pdata->su1_fb; 431 415 su->type = AS3711_BL_SU1; 432 416 433 417 max_brightness = min(pdata->su1_max_uA, 31); ··· 437 423 438 424 if (pdata->su2_fb) { 439 425 su = &supply->su2; 440 - su->fb_name = pdata->su2_fb; 441 426 su->type = AS3711_BL_SU2; 442 427 443 428 switch (pdata->su2_fbprot) {
-5
drivers/video/backlight/generic_bl.c
··· 21 21 static struct backlight_device *generic_backlight_device; 22 22 static struct generic_bl_info *bl_machinfo; 23 23 24 - /* Flag to signal when the battery is low */ 25 - #define GENERICBL_BATTLOW BL_CORE_DRIVER1 26 - 27 24 static int genericbl_send_intensity(struct backlight_device *bd) 28 25 { 29 26 int intensity = bd->props.brightness; ··· 31 34 intensity = 0; 32 35 if (bd->props.state & BL_CORE_SUSPENDED) 33 36 intensity = 0; 34 - if (bd->props.state & GENERICBL_BATTLOW) 35 - intensity &= bl_machinfo->limit_mask; 36 37 37 38 bl_machinfo->set_bl_intensity(intensity); 38 39
+3 -1
drivers/video/backlight/max8925_bl.c
··· 116 116 if (!pdata) 117 117 return; 118 118 119 - np = of_find_node_by_name(nproot, "backlight"); 119 + np = of_get_child_by_name(nproot, "backlight"); 120 120 if (!np) { 121 121 dev_err(&pdev->dev, "failed to find backlight node\n"); 122 122 return; ··· 124 124 125 125 if (!of_property_read_u32(np, "maxim,max8925-dual-string", &val)) 126 126 pdata->dual_string = val; 127 + 128 + of_node_put(np); 127 129 128 130 pdev->dev.platform_data = pdata; 129 131 }
+252
drivers/video/backlight/otm3225a.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Driver for ORISE Technology OTM3225A SOC for TFT LCD 3 + * Copyright (C) 2017, EETS GmbH, Felix Brack <fb@ltec.ch> 4 + * 5 + * This driver implements a lcd device for the ORISE OTM3225A display 6 + * controller. The control interface to the display is SPI and the display's 7 + * memory is updated over the 16-bit RGB interface. 8 + * The main source of information for writing this driver was provided by the 9 + * OTM3225A datasheet from ORISE Technology. Some information arise from the 10 + * ILI9328 datasheet from ILITEK as well as from the datasheets and sample code 11 + * provided by Crystalfontz America Inc. who sells the CFAF240320A-032T, a 3.2" 12 + * TFT LC display using the OTM3225A controller. 13 + */ 14 + 15 + #include <linux/delay.h> 16 + #include <linux/device.h> 17 + #include <linux/kernel.h> 18 + #include <linux/lcd.h> 19 + #include <linux/module.h> 20 + #include <linux/spi/spi.h> 21 + 22 + #define OTM3225A_INDEX_REG 0x70 23 + #define OTM3225A_DATA_REG 0x72 24 + 25 + /* instruction register list */ 26 + #define DRIVER_OUTPUT_CTRL_1 0x01 27 + #define DRIVER_WAVEFORM_CTRL 0x02 28 + #define ENTRY_MODE 0x03 29 + #define SCALING_CTRL 0x04 30 + #define DISPLAY_CTRL_1 0x07 31 + #define DISPLAY_CTRL_2 0x08 32 + #define DISPLAY_CTRL_3 0x09 33 + #define FRAME_CYCLE_CTRL 0x0A 34 + #define EXT_DISP_IFACE_CTRL_1 0x0C 35 + #define FRAME_MAKER_POS 0x0D 36 + #define EXT_DISP_IFACE_CTRL_2 0x0F 37 + #define POWER_CTRL_1 0x10 38 + #define POWER_CTRL_2 0x11 39 + #define POWER_CTRL_3 0x12 40 + #define POWER_CTRL_4 0x13 41 + #define GRAM_ADDR_HORIZ_SET 0x20 42 + #define GRAM_ADDR_VERT_SET 0x21 43 + #define GRAM_READ_WRITE 0x22 44 + #define POWER_CTRL_7 0x29 45 + #define FRAME_RATE_CTRL 0x2B 46 + #define GAMMA_CTRL_1 0x30 47 + #define GAMMA_CTRL_2 0x31 48 + #define GAMMA_CTRL_3 0x32 49 + #define GAMMA_CTRL_4 0x35 50 + #define GAMMA_CTRL_5 0x36 51 + #define GAMMA_CTRL_6 0x37 52 + #define GAMMA_CTRL_7 0x38 53 + #define GAMMA_CTRL_8 0x39 54 + #define GAMMA_CTRL_9 0x3C 55 + #define GAMMA_CTRL_10 0x3D 56 + #define WINDOW_HORIZ_RAM_START 0x50 57 + #define WINDOW_HORIZ_RAM_END 0x51 58 + #define WINDOW_VERT_RAM_START 0x52 59 + #define WINDOW_VERT_RAM_END 0x53 60 + #define DRIVER_OUTPUT_CTRL_2 0x60 61 + #define BASE_IMG_DISPLAY_CTRL 0x61 62 + #define VERT_SCROLL_CTRL 0x6A 63 + #define PD1_DISPLAY_POS 0x80 64 + #define PD1_RAM_START 0x81 65 + #define PD1_RAM_END 0x82 66 + #define PD2_DISPLAY_POS 0x83 67 + #define PD2_RAM_START 0x84 68 + #define PD2_RAM_END 0x85 69 + #define PANEL_IFACE_CTRL_1 0x90 70 + #define PANEL_IFACE_CTRL_2 0x92 71 + #define PANEL_IFACE_CTRL_4 0x95 72 + #define PANEL_IFACE_CTRL_5 0x97 73 + 74 + struct otm3225a_data { 75 + struct spi_device *spi; 76 + struct lcd_device *ld; 77 + int power; 78 + }; 79 + 80 + struct otm3225a_spi_instruction { 81 + unsigned char reg; /* register to write */ 82 + unsigned short value; /* data to write to 'reg' */ 83 + unsigned short delay; /* delay in ms after write */ 84 + }; 85 + 86 + static struct otm3225a_spi_instruction display_init[] = { 87 + { DRIVER_OUTPUT_CTRL_1, 0x0000, 0 }, 88 + { DRIVER_WAVEFORM_CTRL, 0x0700, 0 }, 89 + { ENTRY_MODE, 0x50A0, 0 }, 90 + { SCALING_CTRL, 0x0000, 0 }, 91 + { DISPLAY_CTRL_2, 0x0606, 0 }, 92 + { DISPLAY_CTRL_3, 0x0000, 0 }, 93 + { FRAME_CYCLE_CTRL, 0x0000, 0 }, 94 + { EXT_DISP_IFACE_CTRL_1, 0x0000, 0 }, 95 + { FRAME_MAKER_POS, 0x0000, 0 }, 96 + { EXT_DISP_IFACE_CTRL_2, 0x0002, 0 }, 97 + { POWER_CTRL_2, 0x0007, 0 }, 98 + { POWER_CTRL_3, 0x0000, 0 }, 99 + { POWER_CTRL_4, 0x0000, 200 }, 100 + { DISPLAY_CTRL_1, 0x0101, 0 }, 101 + { POWER_CTRL_1, 0x12B0, 0 }, 102 + { POWER_CTRL_2, 0x0007, 0 }, 103 + { POWER_CTRL_3, 0x01BB, 50 }, 104 + { POWER_CTRL_4, 0x0013, 0 }, 105 + { POWER_CTRL_7, 0x0010, 50 }, 106 + { GAMMA_CTRL_1, 0x000A, 0 }, 107 + { GAMMA_CTRL_2, 0x1326, 0 }, 108 + { GAMMA_CTRL_3, 0x0A29, 0 }, 109 + { GAMMA_CTRL_4, 0x0A0A, 0 }, 110 + { GAMMA_CTRL_5, 0x1E03, 0 }, 111 + { GAMMA_CTRL_6, 0x031E, 0 }, 112 + { GAMMA_CTRL_7, 0x0706, 0 }, 113 + { GAMMA_CTRL_8, 0x0303, 0 }, 114 + { GAMMA_CTRL_9, 0x010E, 0 }, 115 + { GAMMA_CTRL_10, 0x040E, 0 }, 116 + { WINDOW_HORIZ_RAM_START, 0x0000, 0 }, 117 + { WINDOW_HORIZ_RAM_END, 0x00EF, 0 }, 118 + { WINDOW_VERT_RAM_START, 0x0000, 0 }, 119 + { WINDOW_VERT_RAM_END, 0x013F, 0 }, 120 + { DRIVER_OUTPUT_CTRL_2, 0x2700, 0 }, 121 + { BASE_IMG_DISPLAY_CTRL, 0x0001, 0 }, 122 + { VERT_SCROLL_CTRL, 0x0000, 0 }, 123 + { PD1_DISPLAY_POS, 0x0000, 0 }, 124 + { PD1_RAM_START, 0x0000, 0 }, 125 + { PD1_RAM_END, 0x0000, 0 }, 126 + { PD2_DISPLAY_POS, 0x0000, 0 }, 127 + { PD2_RAM_START, 0x0000, 0 }, 128 + { PD2_RAM_END, 0x0000, 0 }, 129 + { PANEL_IFACE_CTRL_1, 0x0010, 0 }, 130 + { PANEL_IFACE_CTRL_2, 0x0000, 0 }, 131 + { PANEL_IFACE_CTRL_4, 0x0210, 0 }, 132 + { PANEL_IFACE_CTRL_5, 0x0000, 0 }, 133 + { DISPLAY_CTRL_1, 0x0133, 0 }, 134 + }; 135 + 136 + static struct otm3225a_spi_instruction display_enable_rgb_interface[] = { 137 + { ENTRY_MODE, 0x1080, 0 }, 138 + { GRAM_ADDR_HORIZ_SET, 0x0000, 0 }, 139 + { GRAM_ADDR_VERT_SET, 0x0000, 0 }, 140 + { EXT_DISP_IFACE_CTRL_1, 0x0111, 500 }, 141 + }; 142 + 143 + static struct otm3225a_spi_instruction display_off[] = { 144 + { DISPLAY_CTRL_1, 0x0131, 100 }, 145 + { DISPLAY_CTRL_1, 0x0130, 100 }, 146 + { DISPLAY_CTRL_1, 0x0100, 0 }, 147 + { POWER_CTRL_1, 0x0280, 0 }, 148 + { POWER_CTRL_3, 0x018B, 0 }, 149 + }; 150 + 151 + static struct otm3225a_spi_instruction display_on[] = { 152 + { POWER_CTRL_1, 0x1280, 0 }, 153 + { DISPLAY_CTRL_1, 0x0101, 100 }, 154 + { DISPLAY_CTRL_1, 0x0121, 0 }, 155 + { DISPLAY_CTRL_1, 0x0123, 100 }, 156 + { DISPLAY_CTRL_1, 0x0133, 10 }, 157 + }; 158 + 159 + static void otm3225a_write(struct spi_device *spi, 160 + struct otm3225a_spi_instruction *instruction, 161 + unsigned int count) 162 + { 163 + unsigned char buf[3]; 164 + 165 + while (count--) { 166 + /* address register using index register */ 167 + buf[0] = OTM3225A_INDEX_REG; 168 + buf[1] = 0x00; 169 + buf[2] = instruction->reg; 170 + spi_write(spi, buf, 3); 171 + 172 + /* write data to addressed register */ 173 + buf[0] = OTM3225A_DATA_REG; 174 + buf[1] = (instruction->value >> 8) & 0xff; 175 + buf[2] = instruction->value & 0xff; 176 + spi_write(spi, buf, 3); 177 + 178 + /* execute delay if any */ 179 + if (instruction->delay) 180 + msleep(instruction->delay); 181 + instruction++; 182 + } 183 + } 184 + 185 + static int otm3225a_set_power(struct lcd_device *ld, int power) 186 + { 187 + struct otm3225a_data *dd = lcd_get_data(ld); 188 + 189 + if (power == dd->power) 190 + return 0; 191 + 192 + if (power > FB_BLANK_UNBLANK) 193 + otm3225a_write(dd->spi, display_off, ARRAY_SIZE(display_off)); 194 + else 195 + otm3225a_write(dd->spi, display_on, ARRAY_SIZE(display_on)); 196 + dd->power = power; 197 + 198 + return 0; 199 + } 200 + 201 + static int otm3225a_get_power(struct lcd_device *ld) 202 + { 203 + struct otm3225a_data *dd = lcd_get_data(ld); 204 + 205 + return dd->power; 206 + } 207 + 208 + static struct lcd_ops otm3225a_ops = { 209 + .set_power = otm3225a_set_power, 210 + .get_power = otm3225a_get_power, 211 + }; 212 + 213 + static int otm3225a_probe(struct spi_device *spi) 214 + { 215 + struct otm3225a_data *dd; 216 + struct lcd_device *ld; 217 + struct device *dev = &spi->dev; 218 + 219 + dd = devm_kzalloc(dev, sizeof(struct otm3225a_data), GFP_KERNEL); 220 + if (dd == NULL) 221 + return -ENOMEM; 222 + 223 + ld = devm_lcd_device_register(dev, dev_name(dev), dev, dd, 224 + &otm3225a_ops); 225 + if (IS_ERR(ld)) 226 + return PTR_ERR(ld); 227 + 228 + dd->spi = spi; 229 + dd->ld = ld; 230 + dev_set_drvdata(dev, dd); 231 + 232 + dev_info(dev, "Initializing and switching to RGB interface"); 233 + otm3225a_write(spi, display_init, ARRAY_SIZE(display_init)); 234 + otm3225a_write(spi, display_enable_rgb_interface, 235 + ARRAY_SIZE(display_enable_rgb_interface)); 236 + return 0; 237 + } 238 + 239 + static struct spi_driver otm3225a_driver = { 240 + .driver = { 241 + .name = "otm3225a", 242 + .owner = THIS_MODULE, 243 + }, 244 + .probe = otm3225a_probe, 245 + }; 246 + 247 + module_spi_driver(otm3225a_driver); 248 + 249 + MODULE_AUTHOR("Felix Brack <fb@ltec.ch>"); 250 + MODULE_DESCRIPTION("OTM3225A TFT LCD driver"); 251 + MODULE_VERSION("1.0.0"); 252 + MODULE_LICENSE("GPL v2");
+18 -7
drivers/video/backlight/pandora_bl.c
··· 35 35 #define MAX_VALUE 63 36 36 #define MAX_USER_VALUE (MAX_VALUE - MIN_VALUE) 37 37 38 - #define PANDORABL_WAS_OFF BL_CORE_DRIVER1 38 + struct pandora_private { 39 + unsigned old_state; 40 + #define PANDORABL_WAS_OFF 1 41 + }; 39 42 40 43 static int pandora_backlight_update_status(struct backlight_device *bl) 41 44 { 42 45 int brightness = bl->props.brightness; 46 + struct pandora_private *priv = bl_get_data(bl); 43 47 u8 r; 44 48 45 49 if (bl->props.power != FB_BLANK_UNBLANK) ··· 57 53 brightness = MAX_USER_VALUE; 58 54 59 55 if (brightness == 0) { 60 - if (bl->props.state & PANDORABL_WAS_OFF) 56 + if (priv->old_state == PANDORABL_WAS_OFF) 61 57 goto done; 62 58 63 59 /* first disable PWM0 output, then clock */ ··· 70 66 goto done; 71 67 } 72 68 73 - if (bl->props.state & PANDORABL_WAS_OFF) { 69 + if (priv->old_state == PANDORABL_WAS_OFF) { 74 70 /* 75 71 * set PWM duty cycle to max. TPS61161 seems to use this 76 72 * to calibrate it's PWM sensitivity when it starts. ··· 97 93 98 94 done: 99 95 if (brightness != 0) 100 - bl->props.state &= ~PANDORABL_WAS_OFF; 96 + priv->old_state = 0; 101 97 else 102 - bl->props.state |= PANDORABL_WAS_OFF; 98 + priv->old_state = PANDORABL_WAS_OFF; 103 99 104 100 return 0; 105 101 } ··· 113 109 { 114 110 struct backlight_properties props; 115 111 struct backlight_device *bl; 112 + struct pandora_private *priv; 116 113 u8 r; 114 + 115 + priv = devm_kmalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 116 + if (!priv) { 117 + dev_err(&pdev->dev, "failed to allocate driver private data\n"); 118 + return -ENOMEM; 119 + } 117 120 118 121 memset(&props, 0, sizeof(props)); 119 122 props.max_brightness = MAX_USER_VALUE; 120 123 props.type = BACKLIGHT_RAW; 121 124 bl = devm_backlight_device_register(&pdev->dev, pdev->name, &pdev->dev, 122 - NULL, &pandora_backlight_ops, &props); 125 + priv, &pandora_backlight_ops, &props); 123 126 if (IS_ERR(bl)) { 124 127 dev_err(&pdev->dev, "failed to register backlight\n"); 125 128 return PTR_ERR(bl); ··· 137 126 /* 64 cycle period, ON position 0 */ 138 127 twl_i2c_write_u8(TWL_MODULE_PWM, 0x80, TWL_PWM0_ON); 139 128 140 - bl->props.state |= PANDORABL_WAS_OFF; 129 + priv->old_state = PANDORABL_WAS_OFF; 141 130 bl->props.brightness = MAX_USER_VALUE; 142 131 backlight_update_status(bl); 143 132
+27 -7
drivers/video/backlight/pwm_bl.c
··· 10 10 * published by the Free Software Foundation. 11 11 */ 12 12 13 + #include <linux/delay.h> 13 14 #include <linux/gpio/consumer.h> 14 15 #include <linux/gpio.h> 15 16 #include <linux/module.h> ··· 36 35 struct gpio_desc *enable_gpio; 37 36 unsigned int scale; 38 37 bool legacy; 38 + unsigned int post_pwm_on_delay; 39 + unsigned int pwm_off_delay; 39 40 int (*notify)(struct device *, 40 41 int brightness); 41 42 void (*notify_after)(struct device *, ··· 57 54 if (err < 0) 58 55 dev_err(pb->dev, "failed to enable power supply\n"); 59 56 57 + pwm_enable(pb->pwm); 58 + 59 + if (pb->post_pwm_on_delay) 60 + msleep(pb->post_pwm_on_delay); 61 + 60 62 if (pb->enable_gpio) 61 63 gpiod_set_value_cansleep(pb->enable_gpio, 1); 62 64 63 - pwm_enable(pb->pwm); 64 65 pb->enabled = true; 65 66 } 66 67 ··· 73 66 if (!pb->enabled) 74 67 return; 75 68 76 - pwm_config(pb->pwm, 0, pb->period); 77 - pwm_disable(pb->pwm); 78 - 79 69 if (pb->enable_gpio) 80 70 gpiod_set_value_cansleep(pb->enable_gpio, 0); 71 + 72 + if (pb->pwm_off_delay) 73 + msleep(pb->pwm_off_delay); 74 + 75 + pwm_config(pb->pwm, 0, pb->period); 76 + pwm_disable(pb->pwm); 81 77 82 78 regulator_disable(pb->power_supply); 83 79 pb->enabled = false; ··· 187 177 data->max_brightness--; 188 178 } 189 179 180 + /* 181 + * These values are optional and set as 0 by default, the out values 182 + * are modified only if a valid u32 value can be decoded. 183 + */ 184 + of_property_read_u32(node, "post-pwm-on-delay-ms", 185 + &data->post_pwm_on_delay); 186 + of_property_read_u32(node, "pwm-off-delay-ms", &data->pwm_off_delay); 187 + 190 188 data->enable_gpio = -EINVAL; 191 189 return 0; 192 190 } ··· 293 275 pb->exit = data->exit; 294 276 pb->dev = &pdev->dev; 295 277 pb->enabled = false; 278 + pb->post_pwm_on_delay = data->post_pwm_on_delay; 279 + pb->pwm_off_delay = data->pwm_off_delay; 296 280 297 281 pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", 298 282 GPIOD_ASIS); ··· 321 301 322 302 /* 323 303 * If the GPIO is not known to be already configured as output, that 324 - * is, if gpiod_get_direction returns either GPIOF_DIR_IN or -EINVAL, 325 - * change the direction to output and set the GPIO as active. 304 + * is, if gpiod_get_direction returns either 1 or -EINVAL, change the 305 + * direction to output and set the GPIO as active. 326 306 * Do not force the GPIO to active when it was already output as it 327 307 * could cause backlight flickering or we would enable the backlight too 328 308 * early. Leave the decision of the initial backlight state for later. 329 309 */ 330 310 if (pb->enable_gpio && 331 - gpiod_get_direction(pb->enable_gpio) != GPIOF_DIR_OUT) 311 + gpiod_get_direction(pb->enable_gpio) != 0) 332 312 gpiod_direction_output(pb->enable_gpio, 1); 333 313 334 314 pb->power_supply = devm_regulator_get(&pdev->dev, "power");
+82
drivers/video/backlight/rave-sp-backlight.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + 3 + /* 4 + * LCD Backlight driver for RAVE SP 5 + * 6 + * Copyright (C) 2018 Zodiac Inflight Innovations 7 + * 8 + */ 9 + 10 + #include <linux/backlight.h> 11 + #include <linux/kernel.h> 12 + #include <linux/module.h> 13 + #include <linux/mfd/rave-sp.h> 14 + #include <linux/platform_device.h> 15 + 16 + #define RAVE_SP_BACKLIGHT_LCD_EN BIT(7) 17 + 18 + static int rave_sp_backlight_update_status(struct backlight_device *bd) 19 + { 20 + const struct backlight_properties *p = &bd->props; 21 + const u8 intensity = 22 + (p->power == FB_BLANK_UNBLANK) ? p->brightness : 0; 23 + struct rave_sp *sp = dev_get_drvdata(&bd->dev); 24 + u8 cmd[] = { 25 + [0] = RAVE_SP_CMD_SET_BACKLIGHT, 26 + [1] = 0, 27 + [2] = intensity ? RAVE_SP_BACKLIGHT_LCD_EN | intensity : 0, 28 + [3] = 0, 29 + [4] = 0, 30 + }; 31 + 32 + return rave_sp_exec(sp, cmd, sizeof(cmd), NULL, 0); 33 + } 34 + 35 + static const struct backlight_ops rave_sp_backlight_ops = { 36 + .options = BL_CORE_SUSPENDRESUME, 37 + .update_status = rave_sp_backlight_update_status, 38 + }; 39 + 40 + static struct backlight_properties rave_sp_backlight_props = { 41 + .type = BACKLIGHT_PLATFORM, 42 + .max_brightness = 100, 43 + .brightness = 50, 44 + }; 45 + 46 + static int rave_sp_backlight_probe(struct platform_device *pdev) 47 + { 48 + struct device *dev = &pdev->dev; 49 + struct backlight_device *bd; 50 + 51 + bd = devm_backlight_device_register(dev, pdev->name, dev->parent, 52 + dev_get_drvdata(dev->parent), 53 + &rave_sp_backlight_ops, 54 + &rave_sp_backlight_props); 55 + if (IS_ERR(bd)) 56 + return PTR_ERR(bd); 57 + 58 + backlight_update_status(bd); 59 + 60 + return 0; 61 + } 62 + 63 + static const struct of_device_id rave_sp_backlight_of_match[] = { 64 + { .compatible = "zii,rave-sp-backlight" }, 65 + {} 66 + }; 67 + 68 + static struct platform_driver rave_sp_backlight_driver = { 69 + .probe = rave_sp_backlight_probe, 70 + .driver = { 71 + .name = KBUILD_MODNAME, 72 + .of_match_table = rave_sp_backlight_of_match, 73 + }, 74 + }; 75 + module_platform_driver(rave_sp_backlight_driver); 76 + 77 + MODULE_DEVICE_TABLE(of, rave_sp_backlight_of_match); 78 + MODULE_LICENSE("GPL"); 79 + MODULE_AUTHOR("Andrey Vostrikov <andrey.vostrikov@cogentembedded.com>"); 80 + MODULE_AUTHOR("Nikita Yushchenko <nikita.yoush@cogentembedded.com>"); 81 + MODULE_AUTHOR("Andrey Smirnov <andrew.smirnov@gmail.com>"); 82 + MODULE_DESCRIPTION("RAVE SP Backlight driver");
+2 -2
drivers/video/backlight/tps65217_bl.c
··· 184 184 tps65217_bl_parse_dt(struct platform_device *pdev) 185 185 { 186 186 struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); 187 - struct device_node *node = of_node_get(tps->dev->of_node); 187 + struct device_node *node; 188 188 struct tps65217_bl_pdata *pdata, *err; 189 189 u32 val; 190 190 191 - node = of_find_node_by_name(node, "backlight"); 191 + node = of_get_child_by_name(tps->dev->of_node, "backlight"); 192 192 if (!node) 193 193 return ERR_PTR(-ENODEV); 194 194
-4
include/linux/backlight.h
··· 84 84 85 85 #define BL_CORE_SUSPENDED (1 << 0) /* backlight is suspended */ 86 86 #define BL_CORE_FBBLANK (1 << 1) /* backlight is under an fb blank event */ 87 - #define BL_CORE_DRIVER4 (1 << 28) /* reserved for driver specific use */ 88 - #define BL_CORE_DRIVER3 (1 << 29) /* reserved for driver specific use */ 89 - #define BL_CORE_DRIVER2 (1 << 30) /* reserved for driver specific use */ 90 - #define BL_CORE_DRIVER1 (1 << 31) /* reserved for driver specific use */ 91 87 92 88 }; 93 89
+2 -2
include/linux/mfd/as3711.h
··· 108 108 }; 109 109 110 110 struct as3711_bl_pdata { 111 - const char *su1_fb; 111 + bool su1_fb; 112 112 int su1_max_uA; 113 - const char *su2_fb; 113 + bool su2_fb; 114 114 int su2_max_uA; 115 115 enum as3711_su2_feedback su2_feedback; 116 116 enum as3711_su2_fbprot su2_fbprot;
+1
include/linux/mfd/rave-sp.h
··· 21 21 RAVE_SP_CMD_STATUS = 0xA0, 22 22 RAVE_SP_CMD_SW_WDT = 0xA1, 23 23 RAVE_SP_CMD_PET_WDT = 0xA2, 24 + RAVE_SP_CMD_SET_BACKLIGHT = 0xA6, 24 25 RAVE_SP_CMD_RESET = 0xA7, 25 26 RAVE_SP_CMD_RESET_REASON = 0xA8, 26 27
+2
include/linux/pwm_backlight.h
··· 14 14 unsigned int lth_brightness; 15 15 unsigned int pwm_period_ns; 16 16 unsigned int *levels; 17 + unsigned int post_pwm_on_delay; 18 + unsigned int pwm_off_delay; 17 19 /* TODO remove once all users are switched to gpiod_* API */ 18 20 int enable_gpio; 19 21 int (*init)(struct device *dev);