Skip to content

Commit c16bfeb

Browse files
committed
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds
Pull LED subsystem updates from Bryan Wu: - lp55xx device tree updates - mc13xxx driver updates - some clean up * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: leds: mc13783: Fix "uninitialized variable" warning leds: Convert led class driver from legacy pm ops to dev_pm_ops leds: leds-mc13783: Add MC13892 LED support leds: leds-mc13783: Prepare driver to support MC13892 LEDs leds: renesas-tpu: cleanup a small type issue leds: use platform_{get,set}_drvdata() leds: leds-gpio: Let device core handle pinctrl leds: lp5562: Properly setup of_device_id table leds: lp5523: Properly setup of_device_id table leds: lp5521: Properly setup of_device_id table leds: lp5562: support the device tree feature leds: lp55xx: support dynamic channel settings in the device tree structure leds: leds-ns2: remove unnecessary platform_set_drvdata() leds: leds-mc13783: remove unnecessary platform_set_drvdata() leds: leds-gpio: remove unnecessary platform_set_drvdata() leds: atmel-pwm: remove unnecessary platform_set_drvdata() leds: lp55xx: add support for Device Tree bindings
2 parents 1286da8 + cf3b1c2 commit c16bfeb

File tree

18 files changed

+553
-346
lines changed

18 files changed

+553
-346
lines changed
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
Binding for TI/National Semiconductor LP55xx Led Drivers
2+
3+
Required properties:
4+
- compatible: "national,lp5521" or "national,lp5523" or "ti,lp5562"
5+
- reg: I2C slave address
6+
- clock-mode: Input clock mode, (0: automode, 1: internal, 2: external)
7+
8+
Each child has own specific current settings
9+
- led-cur: Current setting at each led channel (mA x10, 0 if led is not connected)
10+
- max-cur: Maximun current at each led channel.
11+
12+
Optional properties:
13+
- label: Used for naming LEDs
14+
15+
Alternatively, each child can have specific channel name
16+
- chan-name: Name of each channel name
17+
18+
example 1) LP5521
19+
3 LED channels, external clock used. Channel names are 'lp5521_pri:channel0',
20+
'lp5521_pri:channel1' and 'lp5521_pri:channel2'
21+
22+
lp5521@32 {
23+
compatible = "national,lp5521";
24+
reg = <0x32>;
25+
label = "lp5521_pri";
26+
clock-mode = /bits/ 8 <2>;
27+
28+
chan0 {
29+
led-cur = /bits/ 8 <0x2f>;
30+
max-cur = /bits/ 8 <0x5f>;
31+
};
32+
33+
chan1 {
34+
led-cur = /bits/ 8 <0x2f>;
35+
max-cur = /bits/ 8 <0x5f>;
36+
};
37+
38+
chan2 {
39+
led-cur = /bits/ 8 <0x2f>;
40+
max-cur = /bits/ 8 <0x5f>;
41+
};
42+
};
43+
44+
example 2) LP5523
45+
9 LED channels with specific name. Internal clock used.
46+
The I2C slave address is configurable with ASEL1 and ASEL0 pins.
47+
Available addresses are 32/33/34/35h.
48+
49+
ASEL1 ASEL0 Address
50+
-------------------------
51+
GND GND 32h
52+
GND VEN 33h
53+
VEN GND 34h
54+
VEN VEN 35h
55+
56+
lp5523@32 {
57+
compatible = "national,lp5523";
58+
reg = <0x32>;
59+
clock-mode = /bits/ 8 <1>;
60+
61+
chan0 {
62+
chan-name = "d1";
63+
led-cur = /bits/ 8 <0x14>;
64+
max-cur = /bits/ 8 <0x20>;
65+
};
66+
67+
chan1 {
68+
chan-name = "d2";
69+
led-cur = /bits/ 8 <0x14>;
70+
max-cur = /bits/ 8 <0x20>;
71+
};
72+
73+
chan2 {
74+
chan-name = "d3";
75+
led-cur = /bits/ 8 <0x14>;
76+
max-cur = /bits/ 8 <0x20>;
77+
};
78+
79+
chan3 {
80+
chan-name = "d4";
81+
led-cur = /bits/ 8 <0x14>;
82+
max-cur = /bits/ 8 <0x20>;
83+
};
84+
85+
chan4 {
86+
chan-name = "d5";
87+
led-cur = /bits/ 8 <0x14>;
88+
max-cur = /bits/ 8 <0x20>;
89+
};
90+
91+
chan5 {
92+
chan-name = "d6";
93+
led-cur = /bits/ 8 <0x14>;
94+
max-cur = /bits/ 8 <0x20>;
95+
};
96+
97+
chan6 {
98+
chan-name = "d7";
99+
led-cur = /bits/ 8 <0x14>;
100+
max-cur = /bits/ 8 <0x20>;
101+
};
102+
103+
chan7 {
104+
chan-name = "d8";
105+
led-cur = /bits/ 8 <0x14>;
106+
max-cur = /bits/ 8 <0x20>;
107+
};
108+
109+
chan8 {
110+
chan-name = "d9";
111+
led-cur = /bits/ 8 <0x14>;
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>;
146+
};
147+
};

arch/arm/mach-imx/mach-mx31moboard.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,11 @@ static struct mc13xxx_led_platform_data moboard_led[] = {
268268
static struct mc13xxx_leds_platform_data moboard_leds = {
269269
.num_leds = ARRAY_SIZE(moboard_led),
270270
.led = moboard_led,
271-
.flags = MC13783_LED_SLEWLIMTC,
272-
.abmode = MC13783_LED_AB_DISABLED,
273-
.tc1_period = MC13783_LED_PERIOD_10MS,
274-
.tc2_period = MC13783_LED_PERIOD_10MS,
271+
.led_control[0] = MC13783_LED_C0_ENABLE | MC13783_LED_C0_ABMODE(0),
272+
.led_control[1] = MC13783_LED_C1_SLEWLIM,
273+
.led_control[2] = MC13783_LED_C2_SLEWLIM,
274+
.led_control[3] = MC13783_LED_C3_PERIOD(0),
275+
.led_control[4] = MC13783_LED_C3_PERIOD(0),
275276
};
276277

277278
static struct mc13xxx_buttons_platform_data moboard_buttons = {

drivers/leds/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,12 @@ config LEDS_DELL_NETBOOKS
388388
notebooks that have an external LED.
389389

390390
config LEDS_MC13783
391-
tristate "LED Support for MC13783 PMIC"
391+
tristate "LED Support for MC13XXX PMIC"
392392
depends on LEDS_CLASS
393-
depends on MFD_MC13783
393+
depends on MFD_MC13XXX
394394
help
395395
This option enable support for on-chip LED drivers found
396-
on Freescale Semiconductor MC13783 PMIC.
396+
on Freescale Semiconductor MC13783/MC13892 PMIC.
397397

398398
config LEDS_NS2
399399
tristate "LED support for Network Space v2 GPIO LEDs"

drivers/leds/led-class.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void led_classdev_resume(struct led_classdev *led_cdev)
156156
}
157157
EXPORT_SYMBOL_GPL(led_classdev_resume);
158158

159-
static int led_suspend(struct device *dev, pm_message_t state)
159+
static int led_suspend(struct device *dev)
160160
{
161161
struct led_classdev *led_cdev = dev_get_drvdata(dev);
162162

@@ -176,6 +176,11 @@ static int led_resume(struct device *dev)
176176
return 0;
177177
}
178178

179+
static const struct dev_pm_ops leds_class_dev_pm_ops = {
180+
.suspend = led_suspend,
181+
.resume = led_resume,
182+
};
183+
179184
/**
180185
* led_classdev_register - register a new object of led_classdev class.
181186
* @parent: The device to register.
@@ -252,8 +257,7 @@ static int __init leds_init(void)
252257
leds_class = class_create(THIS_MODULE, "leds");
253258
if (IS_ERR(leds_class))
254259
return PTR_ERR(leds_class);
255-
leds_class->suspend = led_suspend;
256-
leds_class->resume = led_resume;
260+
leds_class->pm = &leds_class_dev_pm_ops;
257261
leds_class->dev_attrs = led_class_attrs;
258262
return 0;
259263
}

drivers/leds/leds-88pm860x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static int pm860x_led_probe(struct platform_device *pdev)
204204
sprintf(data->name, "led1-blue");
205205
break;
206206
}
207-
dev_set_drvdata(&pdev->dev, data);
207+
platform_set_drvdata(pdev, data);
208208
data->chip = chip;
209209
data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion;
210210
data->port = pdev->id;

drivers/leds/leds-atmel-pwm.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ static int pwmled_remove(struct platform_device *pdev)
129129
pwm_channel_free(&led->pwmc);
130130
}
131131

132-
platform_set_drvdata(pdev, NULL);
133132
return 0;
134133
}
135134

drivers/leds/leds-gpio.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <linux/slab.h>
2121
#include <linux/workqueue.h>
2222
#include <linux/module.h>
23-
#include <linux/pinctrl/consumer.h>
2423
#include <linux/err.h>
2524

2625
struct gpio_led_data {
@@ -236,13 +235,8 @@ static int gpio_led_probe(struct platform_device *pdev)
236235
{
237236
struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
238237
struct gpio_leds_priv *priv;
239-
struct pinctrl *pinctrl;
240238
int i, ret = 0;
241239

242-
pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
243-
if (IS_ERR(pinctrl))
244-
dev_warn(&pdev->dev,
245-
"pins are not configured from the driver\n");
246240

247241
if (pdata && pdata->num_leds) {
248242
priv = devm_kzalloc(&pdev->dev,
@@ -282,8 +276,6 @@ static int gpio_led_remove(struct platform_device *pdev)
282276
for (i = 0; i < priv->num_leds; i++)
283277
delete_gpio_led(&priv->leds[i]);
284278

285-
platform_set_drvdata(pdev, NULL);
286-
287279
return 0;
288280
}
289281

drivers/leds/leds-lp5521.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/mutex.h>
3232
#include <linux/platform_data/leds-lp55xx.h>
3333
#include <linux/slab.h>
34+
#include <linux/of.h>
3435

3536
#include "leds-lp55xx-common.h"
3637

@@ -416,12 +417,20 @@ static int lp5521_probe(struct i2c_client *client,
416417
int ret;
417418
struct lp55xx_chip *chip;
418419
struct lp55xx_led *led;
419-
struct lp55xx_platform_data *pdata = client->dev.platform_data;
420-
421-
if (!pdata) {
422-
dev_err(&client->dev, "no platform data\n");
423-
return -EINVAL;
420+
struct lp55xx_platform_data *pdata;
421+
struct device_node *np = client->dev.of_node;
422+
423+
if (!client->dev.platform_data) {
424+
if (np) {
425+
ret = lp55xx_of_populate_pdata(&client->dev, np);
426+
if (ret < 0)
427+
return ret;
428+
} else {
429+
dev_err(&client->dev, "no platform data\n");
430+
return -EINVAL;
431+
}
424432
}
433+
pdata = client->dev.platform_data;
425434

426435
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
427436
if (!chip)
@@ -485,9 +494,18 @@ static const struct i2c_device_id lp5521_id[] = {
485494
};
486495
MODULE_DEVICE_TABLE(i2c, lp5521_id);
487496

497+
#ifdef CONFIG_OF
498+
static const struct of_device_id of_lp5521_leds_match[] = {
499+
{ .compatible = "national,lp5521", },
500+
{},
501+
};
502+
503+
MODULE_DEVICE_TABLE(of, of_lp5521_leds_match);
504+
#endif
488505
static struct i2c_driver lp5521_driver = {
489506
.driver = {
490507
.name = "lp5521",
508+
.of_match_table = of_match_ptr(of_lp5521_leds_match),
491509
},
492510
.probe = lp5521_probe,
493511
.remove = lp5521_remove,

drivers/leds/leds-lp5523.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,20 @@ static int lp5523_probe(struct i2c_client *client,
429429
int ret;
430430
struct lp55xx_chip *chip;
431431
struct lp55xx_led *led;
432-
struct lp55xx_platform_data *pdata = client->dev.platform_data;
433-
434-
if (!pdata) {
435-
dev_err(&client->dev, "no platform data\n");
436-
return -EINVAL;
432+
struct lp55xx_platform_data *pdata;
433+
struct device_node *np = client->dev.of_node;
434+
435+
if (!client->dev.platform_data) {
436+
if (np) {
437+
ret = lp55xx_of_populate_pdata(&client->dev, np);
438+
if (ret < 0)
439+
return ret;
440+
} else {
441+
dev_err(&client->dev, "no platform data\n");
442+
return -EINVAL;
443+
}
437444
}
445+
pdata = client->dev.platform_data;
438446

439447
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
440448
if (!chip)
@@ -500,9 +508,19 @@ static const struct i2c_device_id lp5523_id[] = {
500508

501509
MODULE_DEVICE_TABLE(i2c, lp5523_id);
502510

511+
#ifdef CONFIG_OF
512+
static const struct of_device_id of_lp5523_leds_match[] = {
513+
{ .compatible = "national,lp5523", },
514+
{},
515+
};
516+
517+
MODULE_DEVICE_TABLE(of, of_lp5523_leds_match);
518+
#endif
519+
503520
static struct i2c_driver lp5523_driver = {
504521
.driver = {
505522
.name = "lp5523x",
523+
.of_match_table = of_match_ptr(of_lp5523_leds_match),
506524
},
507525
.probe = lp5523_probe,
508526
.remove = lp5523_remove,

0 commit comments

Comments
 (0)