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

leds: lp5562: support the device tree feature

The LP55xx DT structure is applicable to the LP5562 device.
The driver and documentation are updated.

Compatible property of the DT
: LP5521 and LP5223 were manufactured by National Semiconductor.
LP5562 is a new device from Texas Instruments.

Cc: Gabriel Fernandez <gabriel.fernandez@stericsson.com>
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>

authored by

Kim, Milo and committed by
Bryan Wu
e015050c 2dac9128

+48 -6
+35 -2
Documentation/devicetree/bindings/leds/leds-lp55xx.txt
··· 1 - Binding for National Semiconductor LP55xx Led Drivers 1 + Binding for TI/National Semiconductor LP55xx Led Drivers 2 2 3 3 Required properties: 4 - - compatible: "national,lp5521" or "national,lp5523" 4 + - compatible: "national,lp5521" or "national,lp5523" or "ti,lp5562" 5 5 - reg: I2C slave address 6 6 - clock-mode: Input clock mode, (0: automode, 1: internal, 2: external) 7 7 ··· 110 110 chan-name = "d9"; 111 111 led-cur = /bits/ 8 <0x14>; 112 112 max-cur = /bits/ 8 <0x20>; 113 + }; 114 + }; 115 + 116 + example 3) LP5562 117 + 4 channels are defined. 118 + 119 + lp5562@30 { 120 + compatible = "ti,lp5562"; 121 + reg = <0x30>; 122 + clock-mode = /bits/8 <2>; 123 + 124 + chan0 { 125 + chan-name = "R"; 126 + led-cur = /bits/ 8 <0x20>; 127 + max-cur = /bits/ 8 <0x60>; 128 + }; 129 + 130 + chan1 { 131 + chan-name = "G"; 132 + led-cur = /bits/ 8 <0x20>; 133 + max-cur = /bits/ 8 <0x60>; 134 + }; 135 + 136 + chan2 { 137 + chan-name = "B"; 138 + led-cur = /bits/ 8 <0x20>; 139 + max-cur = /bits/ 8 <0x60>; 140 + }; 141 + 142 + chan3 { 143 + chan-name = "W"; 144 + led-cur = /bits/ 8 <0x20>; 145 + max-cur = /bits/ 8 <0x60>; 113 146 }; 114 147 };
+13 -4
drivers/leds/leds-lp5562.c
··· 515 515 int ret; 516 516 struct lp55xx_chip *chip; 517 517 struct lp55xx_led *led; 518 - struct lp55xx_platform_data *pdata = client->dev.platform_data; 518 + struct lp55xx_platform_data *pdata; 519 + struct device_node *np = client->dev.of_node; 519 520 520 - if (!pdata) { 521 - dev_err(&client->dev, "no platform data\n"); 522 - return -EINVAL; 521 + if (!client->dev.platform_data) { 522 + if (np) { 523 + ret = lp55xx_of_populate_pdata(&client->dev, np); 524 + if (ret < 0) 525 + return ret; 526 + } else { 527 + dev_err(&client->dev, "no platform data\n"); 528 + return -EINVAL; 529 + } 523 530 } 531 + pdata = client->dev.platform_data; 524 532 525 533 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); 526 534 if (!chip) ··· 587 579 588 580 static const struct i2c_device_id lp5562_id[] = { 589 581 { "lp5562", 0 }, 582 + { "ti,lp5562", 0 }, /* OF compatible */ 590 583 { } 591 584 }; 592 585 MODULE_DEVICE_TABLE(i2c, lp5562_id);