summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-28 21:53:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-28 21:53:01 -0500
commit268943fb7529a15254a5247372119ba4bd735e94 (patch)
tree790d42cfade2a35b0eec5e1b7e0ac3795d399bcc
parent2ad48ee810335bdd99de96e1a0796ba34c0e8301 (diff)
parent3cb6f44aedf519dce4a9106dec675b94d675c539 (diff)
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds
Pull LED subsystem update from Bryan Wu: "Basically this cycle is mostly cleanup for LED subsystem" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: leds: s3c24xx: Remove hardware.h inclusion leds: replace list_for_each with list_for_each_entry leds: kirkwood: Cleanup in header files leds: pwm: Remove a warning on non-DT platforms leds: leds-pwm: fix duty time overflow. leds: leds-mc13783: Remove unneeded mc13xxx_{un}lock leds: leds-mc13783: Remove duplicate field in platform data drivers: leds: leds-tca6507: check CONFIG_GPIOLIB whether defined for 'gpio_base' leds: lp5523: Support LED MUX configuration on running a pattern leds: lp5521/5523: Fix multiple engine usage bug LEDS: tca6507 - fix up some comments. LEDS: tca6507: add device-tree support for GPIO configuration. LEDS: tca6507 - fix bugs in parsing of device-tree configuration.
-rw-r--r--Documentation/devicetree/bindings/leds/tca6507.txt16
-rw-r--r--Documentation/leds/leds-lp55xx.txt10
-rw-r--r--arch/arm/mach-imx/mach-mx31moboard.c16
-rw-r--r--drivers/leds/led-triggers.c15
-rw-r--r--drivers/leds/leds-lp5521.c18
-rw-r--r--drivers/leds/leds-lp5523.c20
-rw-r--r--drivers/leds/leds-lp55xx-common.c2
-rw-r--r--drivers/leds/leds-mc13783.c89
-rw-r--r--drivers/leds/leds-pwm.c9
-rw-r--r--drivers/leds/leds-s3c24xx.c3
-rw-r--r--drivers/leds/leds-tca6507.c207
-rw-r--r--include/linux/mfd/mc13xxx.h37
-rw-r--r--include/linux/platform_data/leds-kirkwood-netxbig.h8
-rw-r--r--include/linux/platform_data/leds-kirkwood-ns2.h8
14 files changed, 227 insertions, 231 deletions
diff --git a/Documentation/devicetree/bindings/leds/tca6507.txt b/Documentation/devicetree/bindings/leds/tca6507.txt
index 80ff3dfb1f32..d7221b84987c 100644
--- a/Documentation/devicetree/bindings/leds/tca6507.txt
+++ b/Documentation/devicetree/bindings/leds/tca6507.txt
@@ -2,6 +2,13 @@ LEDs connected to tca6507
2 2
3Required properties: 3Required properties:
4- compatible : should be : "ti,tca6507". 4- compatible : should be : "ti,tca6507".
5- #address-cells: must be 1
6- #size-cells: must be 0
7- reg: typically 0x45.
8
9Optional properties:
10- gpio-controller: allows lines to be used as output-only GPIOs.
11- #gpio-cells: if present, must be 0.
5 12
6Each led is represented as a sub-node of the ti,tca6507 device. 13Each led is represented as a sub-node of the ti,tca6507 device.
7 14
@@ -10,6 +17,7 @@ LED sub-node properties:
10- reg : number of LED line (could be from 0 to 6) 17- reg : number of LED line (could be from 0 to 6)
11- linux,default-trigger : (optional) 18- linux,default-trigger : (optional)
12 see Documentation/devicetree/bindings/leds/common.txt 19 see Documentation/devicetree/bindings/leds/common.txt
20- compatible: either "led" (the default) or "gpio".
13 21
14Examples: 22Examples:
15 23
@@ -19,6 +27,9 @@ tca6507@45 {
19 #size-cells = <0>; 27 #size-cells = <0>;
20 reg = <0x45>; 28 reg = <0x45>;
21 29
30 gpio-controller;
31 #gpio-cells = <2>;
32
22 led0: red-aux@0 { 33 led0: red-aux@0 {
23 label = "red:aux"; 34 label = "red:aux";
24 reg = <0x0>; 35 reg = <0x0>;
@@ -29,5 +40,10 @@ tca6507@45 {
29 reg = <0x5>; 40 reg = <0x5>;
30 linux,default-trigger = "default-on"; 41 linux,default-trigger = "default-on";
31 }; 42 };
43
44 wifi-reset@6 {
45 reg = <0x6>;
46 compatible = "gpio";
47 };
32}; 48};
33 49
diff --git a/Documentation/leds/leds-lp55xx.txt b/Documentation/leds/leds-lp55xx.txt
index 82713ff92eb3..bcea12a0c584 100644
--- a/Documentation/leds/leds-lp55xx.txt
+++ b/Documentation/leds/leds-lp55xx.txt
@@ -73,6 +73,10 @@ select_engine : Select which engine is used for running program
73run_engine : Start program which is loaded via the firmware interface 73run_engine : Start program which is loaded via the firmware interface
74firmware : Load program data 74firmware : Load program data
75 75
76In case of LP5523, one more command is required, 'enginex_leds'.
77It is used for selecting LED output(s) at each engine number.
78In more details, please refer to 'leds-lp5523.txt'.
79
76For example, run blinking pattern in engine #1 of LP5521 80For example, run blinking pattern in engine #1 of LP5521
77echo 1 > /sys/bus/i2c/devices/xxxx/select_engine 81echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
78echo 1 > /sys/class/firmware/lp5521/loading 82echo 1 > /sys/class/firmware/lp5521/loading
@@ -81,10 +85,12 @@ echo 0 > /sys/class/firmware/lp5521/loading
81echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 85echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
82 86
83For example, run blinking pattern in engine #3 of LP55231 87For example, run blinking pattern in engine #3 of LP55231
88Two LEDs are configured as pattern output channels.
84echo 3 > /sys/bus/i2c/devices/xxxx/select_engine 89echo 3 > /sys/bus/i2c/devices/xxxx/select_engine
85echo 1 > /sys/class/firmware/lp55231/loading 90echo 1 > /sys/class/firmware/lp55231/loading
86echo "9d0740ff7e0040007e00a0010000" > /sys/class/firmware/lp55231/data 91echo "9d0740ff7e0040007e00a0010000" > /sys/class/firmware/lp55231/data
87echo 0 > /sys/class/firmware/lp55231/loading 92echo 0 > /sys/class/firmware/lp55231/loading
93echo "000001100" > /sys/bus/i2c/devices/xxxx/engine3_leds
88echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 94echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
89 95
90To start blinking patterns in engine #2 and #3 simultaneously, 96To start blinking patterns in engine #2 and #3 simultaneously,
@@ -99,17 +105,19 @@ done
99echo 1 > /sys/class/leds/red/device/run_engine 105echo 1 > /sys/class/leds/red/device/run_engine
100 106
101Here is another example for LP5523. 107Here is another example for LP5523.
108Full LED strings are selected by 'engine2_leds'.
102echo 2 > /sys/bus/i2c/devices/xxxx/select_engine 109echo 2 > /sys/bus/i2c/devices/xxxx/select_engine
103echo 1 > /sys/class/firmware/lp5523/loading 110echo 1 > /sys/class/firmware/lp5523/loading
104echo "9d80400004ff05ff437f0000" > /sys/class/firmware/lp5523/data 111echo "9d80400004ff05ff437f0000" > /sys/class/firmware/lp5523/data
105echo 0 > /sys/class/firmware/lp5523/loading 112echo 0 > /sys/class/firmware/lp5523/loading
113echo "111111111" > /sys/bus/i2c/devices/xxxx/engine2_leds
106echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 114echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
107 115
108As soon as 'loading' is set to 0, registered callback is called. 116As soon as 'loading' is set to 0, registered callback is called.
109Inside the callback, the selected engine is loaded and memory is updated. 117Inside the callback, the selected engine is loaded and memory is updated.
110To run programmed pattern, 'run_engine' attribute should be enabled. 118To run programmed pattern, 'run_engine' attribute should be enabled.
111 119
112The pattern sqeuence of LP8501 is same as LP5523. 120The pattern sqeuence of LP8501 is similar to LP5523.
113However pattern data is specific. 121However pattern data is specific.
114Ex 1) Engine 1 is used 122Ex 1) Engine 1 is used
115echo 1 > /sys/bus/i2c/devices/xxxx/select_engine 123echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c
index 6f424eced181..b3738e616f19 100644
--- a/arch/arm/mach-imx/mach-mx31moboard.c
+++ b/arch/arm/mach-imx/mach-mx31moboard.c
@@ -236,32 +236,26 @@ static struct mc13xxx_led_platform_data moboard_led[] = {
236 { 236 {
237 .id = MC13783_LED_R1, 237 .id = MC13783_LED_R1,
238 .name = "coreboard-led-4:red", 238 .name = "coreboard-led-4:red",
239 .max_current = 2,
240 }, 239 },
241 { 240 {
242 .id = MC13783_LED_G1, 241 .id = MC13783_LED_G1,
243 .name = "coreboard-led-4:green", 242 .name = "coreboard-led-4:green",
244 .max_current = 2,
245 }, 243 },
246 { 244 {
247 .id = MC13783_LED_B1, 245 .id = MC13783_LED_B1,
248 .name = "coreboard-led-4:blue", 246 .name = "coreboard-led-4:blue",
249 .max_current = 2,
250 }, 247 },
251 { 248 {
252 .id = MC13783_LED_R2, 249 .id = MC13783_LED_R2,
253 .name = "coreboard-led-5:red", 250 .name = "coreboard-led-5:red",
254 .max_current = 3,
255 }, 251 },
256 { 252 {
257 .id = MC13783_LED_G2, 253 .id = MC13783_LED_G2,
258 .name = "coreboard-led-5:green", 254 .name = "coreboard-led-5:green",
259 .max_current = 3,
260 }, 255 },
261 { 256 {
262 .id = MC13783_LED_B2, 257 .id = MC13783_LED_B2,
263 .name = "coreboard-led-5:blue", 258 .name = "coreboard-led-5:blue",
264 .max_current = 3,
265 }, 259 },
266}; 260};
267 261
@@ -271,8 +265,14 @@ static struct mc13xxx_leds_platform_data moboard_leds = {
271 .led_control[0] = MC13783_LED_C0_ENABLE | MC13783_LED_C0_ABMODE(0), 265 .led_control[0] = MC13783_LED_C0_ENABLE | MC13783_LED_C0_ABMODE(0),
272 .led_control[1] = MC13783_LED_C1_SLEWLIM, 266 .led_control[1] = MC13783_LED_C1_SLEWLIM,
273 .led_control[2] = MC13783_LED_C2_SLEWLIM, 267 .led_control[2] = MC13783_LED_C2_SLEWLIM,
274 .led_control[3] = MC13783_LED_C3_PERIOD(0), 268 .led_control[3] = MC13783_LED_C3_PERIOD(0) |
275 .led_control[4] = MC13783_LED_C3_PERIOD(0), 269 MC13783_LED_C3_CURRENT_R1(2) |
270 MC13783_LED_C3_CURRENT_G1(2) |
271 MC13783_LED_C3_CURRENT_B1(2),
272 .led_control[4] = MC13783_LED_C4_PERIOD(0) |
273 MC13783_LED_C4_CURRENT_R2(3) |
274 MC13783_LED_C4_CURRENT_G2(3) |
275 MC13783_LED_C4_CURRENT_B2(3),
276}; 276};
277 277
278static struct mc13xxx_buttons_platform_data moboard_buttons = { 278static struct mc13xxx_buttons_platform_data moboard_buttons = {
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 3c972b2f9893..e387f41a9cb7 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -242,18 +242,14 @@ EXPORT_SYMBOL_GPL(led_trigger_unregister);
242void led_trigger_event(struct led_trigger *trig, 242void led_trigger_event(struct led_trigger *trig,
243 enum led_brightness brightness) 243 enum led_brightness brightness)
244{ 244{
245 struct list_head *entry; 245 struct led_classdev *led_cdev;
246 246
247 if (!trig) 247 if (!trig)
248 return; 248 return;
249 249
250 read_lock(&trig->leddev_list_lock); 250 read_lock(&trig->leddev_list_lock);
251 list_for_each(entry, &trig->led_cdevs) { 251 list_for_each_entry(led_cdev, &trig->led_cdevs, trig_list)
252 struct led_classdev *led_cdev;
253
254 led_cdev = list_entry(entry, struct led_classdev, trig_list);
255 led_set_brightness(led_cdev, brightness); 252 led_set_brightness(led_cdev, brightness);
256 }
257 read_unlock(&trig->leddev_list_lock); 253 read_unlock(&trig->leddev_list_lock);
258} 254}
259EXPORT_SYMBOL_GPL(led_trigger_event); 255EXPORT_SYMBOL_GPL(led_trigger_event);
@@ -264,16 +260,13 @@ static void led_trigger_blink_setup(struct led_trigger *trig,
264 int oneshot, 260 int oneshot,
265 int invert) 261 int invert)
266{ 262{
267 struct list_head *entry; 263 struct led_classdev *led_cdev;
268 264
269 if (!trig) 265 if (!trig)
270 return; 266 return;
271 267
272 read_lock(&trig->leddev_list_lock); 268 read_lock(&trig->leddev_list_lock);
273 list_for_each(entry, &trig->led_cdevs) { 269 list_for_each_entry(led_cdev, &trig->led_cdevs, trig_list) {
274 struct led_classdev *led_cdev;
275
276 led_cdev = list_entry(entry, struct led_classdev, trig_list);
277 if (oneshot) 270 if (oneshot)
278 led_blink_set_oneshot(led_cdev, delay_on, delay_off, 271 led_blink_set_oneshot(led_cdev, delay_on, delay_off,
279 invert); 272 invert);
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index a97263e902ff..2ec34cfcedce 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -152,12 +152,26 @@ static void lp5521_load_engine(struct lp55xx_chip *chip)
152 lp5521_wait_opmode_done(); 152 lp5521_wait_opmode_done();
153} 153}
154 154
155static void lp5521_stop_engine(struct lp55xx_chip *chip) 155static void lp5521_stop_all_engines(struct lp55xx_chip *chip)
156{ 156{
157 lp55xx_write(chip, LP5521_REG_OP_MODE, 0); 157 lp55xx_write(chip, LP5521_REG_OP_MODE, 0);
158 lp5521_wait_opmode_done(); 158 lp5521_wait_opmode_done();
159} 159}
160 160
161static void lp5521_stop_engine(struct lp55xx_chip *chip)
162{
163 enum lp55xx_engine_index idx = chip->engine_idx;
164 u8 mask[] = {
165 [LP55XX_ENGINE_1] = LP5521_MODE_R_M,
166 [LP55XX_ENGINE_2] = LP5521_MODE_G_M,
167 [LP55XX_ENGINE_3] = LP5521_MODE_B_M,
168 };
169
170 lp55xx_update_bits(chip, LP5521_REG_OP_MODE, mask[idx], 0);
171
172 lp5521_wait_opmode_done();
173}
174
161static void lp5521_run_engine(struct lp55xx_chip *chip, bool start) 175static void lp5521_run_engine(struct lp55xx_chip *chip, bool start)
162{ 176{
163 int ret; 177 int ret;
@@ -564,7 +578,7 @@ static int lp5521_remove(struct i2c_client *client)
564 struct lp55xx_led *led = i2c_get_clientdata(client); 578 struct lp55xx_led *led = i2c_get_clientdata(client);
565 struct lp55xx_chip *chip = led->chip; 579 struct lp55xx_chip *chip = led->chip;
566 580
567 lp5521_stop_engine(chip); 581 lp5521_stop_all_engines(chip);
568 lp55xx_unregister_sysfs(chip); 582 lp55xx_unregister_sysfs(chip);
569 lp55xx_unregister_leds(led, chip); 583 lp55xx_unregister_leds(led, chip);
570 lp55xx_deinit_device(chip); 584 lp55xx_deinit_device(chip);
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 3a0bc886a87a..4ade66a2d9d4 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -195,12 +195,26 @@ static void lp5523_load_engine_and_select_page(struct lp55xx_chip *chip)
195 lp55xx_write(chip, LP5523_REG_PROG_PAGE_SEL, page_sel[idx]); 195 lp55xx_write(chip, LP5523_REG_PROG_PAGE_SEL, page_sel[idx]);
196} 196}
197 197
198static void lp5523_stop_engine(struct lp55xx_chip *chip) 198static void lp5523_stop_all_engines(struct lp55xx_chip *chip)
199{ 199{
200 lp55xx_write(chip, LP5523_REG_OP_MODE, 0); 200 lp55xx_write(chip, LP5523_REG_OP_MODE, 0);
201 lp5523_wait_opmode_done(); 201 lp5523_wait_opmode_done();
202} 202}
203 203
204static void lp5523_stop_engine(struct lp55xx_chip *chip)
205{
206 enum lp55xx_engine_index idx = chip->engine_idx;
207 u8 mask[] = {
208 [LP55XX_ENGINE_1] = LP5523_MODE_ENG1_M,
209 [LP55XX_ENGINE_2] = LP5523_MODE_ENG2_M,
210 [LP55XX_ENGINE_3] = LP5523_MODE_ENG3_M,
211 };
212
213 lp55xx_update_bits(chip, LP5523_REG_OP_MODE, mask[idx], 0);
214
215 lp5523_wait_opmode_done();
216}
217
204static void lp5523_turn_off_channels(struct lp55xx_chip *chip) 218static void lp5523_turn_off_channels(struct lp55xx_chip *chip)
205{ 219{
206 int i; 220 int i;
@@ -311,7 +325,7 @@ static int lp5523_init_program_engine(struct lp55xx_chip *chip)
311 } 325 }
312 326
313out: 327out:
314 lp5523_stop_engine(chip); 328 lp5523_stop_all_engines(chip);
315 return ret; 329 return ret;
316} 330}
317 331
@@ -782,7 +796,7 @@ static int lp5523_remove(struct i2c_client *client)
782 struct lp55xx_led *led = i2c_get_clientdata(client); 796 struct lp55xx_led *led = i2c_get_clientdata(client);
783 struct lp55xx_chip *chip = led->chip; 797 struct lp55xx_chip *chip = led->chip;
784 798
785 lp5523_stop_engine(chip); 799 lp5523_stop_all_engines(chip);
786 lp55xx_unregister_sysfs(chip); 800 lp55xx_unregister_sysfs(chip);
787 lp55xx_unregister_leds(led, chip); 801 lp55xx_unregister_leds(led, chip);
788 lp55xx_deinit_device(chip); 802 lp55xx_deinit_device(chip);
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c
index 9acc6bb7deef..88317b4f7bf3 100644
--- a/drivers/leds/leds-lp55xx-common.c
+++ b/drivers/leds/leds-lp55xx-common.c
@@ -210,6 +210,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)
210{ 210{
211 struct lp55xx_chip *chip = context; 211 struct lp55xx_chip *chip = context;
212 struct device *dev = &chip->cl->dev; 212 struct device *dev = &chip->cl->dev;
213 enum lp55xx_engine_index idx = chip->engine_idx;
213 214
214 if (!fw) { 215 if (!fw) {
215 dev_err(dev, "firmware request failed\n"); 216 dev_err(dev, "firmware request failed\n");
@@ -219,6 +220,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)
219 /* handling firmware data is chip dependent */ 220 /* handling firmware data is chip dependent */
220 mutex_lock(&chip->lock); 221 mutex_lock(&chip->lock);
221 222
223 chip->engines[idx - 1].mode = LP55XX_ENGINE_LOAD;
222 chip->fw = fw; 224 chip->fw = fw;
223 if (chip->cfg->firmware_cb) 225 if (chip->cfg->firmware_cb)
224 chip->cfg->firmware_cb(chip); 226 chip->cfg->firmware_cb(chip);
diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c
index fa9b439323bd..ca87a1b4a0db 100644
--- a/drivers/leds/leds-mc13783.c
+++ b/drivers/leds/leds-mc13783.c
@@ -117,9 +117,7 @@ static void mc13xxx_led_work(struct work_struct *work)
117 BUG(); 117 BUG();
118 } 118 }
119 119
120 mc13xxx_lock(led->master);
121 mc13xxx_reg_rmw(led->master, reg, mask << shift, value << shift); 120 mc13xxx_reg_rmw(led->master, reg, mask << shift, value << shift);
122 mc13xxx_unlock(led->master);
123} 121}
124 122
125static void mc13xxx_led_set(struct led_classdev *led_cdev, 123static void mc13xxx_led_set(struct led_classdev *led_cdev,
@@ -132,75 +130,6 @@ static void mc13xxx_led_set(struct led_classdev *led_cdev,
132 schedule_work(&led->work); 130 schedule_work(&led->work);
133} 131}
134 132
135static int __init mc13xxx_led_setup(struct mc13xxx_led *led, int max_current)
136{
137 int shift, mask, reg, ret, bank;
138
139 switch (led->id) {
140 case MC13783_LED_MD:
141 reg = MC13XXX_REG_LED_CONTROL(2);
142 shift = 0;
143 mask = 0x07;
144 break;
145 case MC13783_LED_AD:
146 reg = MC13XXX_REG_LED_CONTROL(2);
147 shift = 3;
148 mask = 0x07;
149 break;
150 case MC13783_LED_KP:
151 reg = MC13XXX_REG_LED_CONTROL(2);
152 shift = 6;
153 mask = 0x07;
154 break;
155 case MC13783_LED_R1:
156 case MC13783_LED_G1:
157 case MC13783_LED_B1:
158 case MC13783_LED_R2:
159 case MC13783_LED_G2:
160 case MC13783_LED_B2:
161 case MC13783_LED_R3:
162 case MC13783_LED_G3:
163 case MC13783_LED_B3:
164 bank = (led->id - MC13783_LED_R1) / 3;
165 reg = MC13XXX_REG_LED_CONTROL(3) + bank;
166 shift = ((led->id - MC13783_LED_R1) - bank * 3) * 2;
167 mask = 0x03;
168 break;
169 case MC13892_LED_MD:
170 reg = MC13XXX_REG_LED_CONTROL(0);
171 shift = 9;
172 mask = 0x07;
173 break;
174 case MC13892_LED_AD:
175 reg = MC13XXX_REG_LED_CONTROL(0);
176 shift = 21;
177 mask = 0x07;
178 break;
179 case MC13892_LED_KP:
180 reg = MC13XXX_REG_LED_CONTROL(1);
181 shift = 9;
182 mask = 0x07;
183 break;
184 case MC13892_LED_R:
185 case MC13892_LED_G:
186 case MC13892_LED_B:
187 bank = (led->id - MC13892_LED_R) / 2;
188 reg = MC13XXX_REG_LED_CONTROL(2) + bank;
189 shift = ((led->id - MC13892_LED_R) - bank * 2) * 12 + 9;
190 mask = 0x07;
191 break;
192 default:
193 BUG();
194 }
195
196 mc13xxx_lock(led->master);
197 ret = mc13xxx_reg_rmw(led->master, reg, mask << shift,
198 max_current << shift);
199 mc13xxx_unlock(led->master);
200
201 return ret;
202}
203
204static int __init mc13xxx_led_probe(struct platform_device *pdev) 133static int __init mc13xxx_led_probe(struct platform_device *pdev)
205{ 134{
206 struct mc13xxx_leds_platform_data *pdata = dev_get_platdata(&pdev->dev); 135 struct mc13xxx_leds_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -233,31 +162,22 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)
233 leds->num_leds = num_leds; 162 leds->num_leds = num_leds;
234 platform_set_drvdata(pdev, leds); 163 platform_set_drvdata(pdev, leds);
235 164
236 mc13xxx_lock(mcdev);
237 for (i = 0; i < devtype->num_regs; i++) { 165 for (i = 0; i < devtype->num_regs; i++) {
238 reg = pdata->led_control[i]; 166 reg = pdata->led_control[i];
239 WARN_ON(reg >= (1 << 24)); 167 WARN_ON(reg >= (1 << 24));
240 ret = mc13xxx_reg_write(mcdev, MC13XXX_REG_LED_CONTROL(i), reg); 168 ret = mc13xxx_reg_write(mcdev, MC13XXX_REG_LED_CONTROL(i), reg);
241 if (ret) 169 if (ret)
242 break; 170 return ret;
243 }
244 mc13xxx_unlock(mcdev);
245
246 if (ret) {
247 dev_err(&pdev->dev, "Unable to init LED driver\n");
248 return ret;
249 } 171 }
250 172
251 for (i = 0; i < num_leds; i++) { 173 for (i = 0; i < num_leds; i++) {
252 const char *name, *trig; 174 const char *name, *trig;
253 char max_current;
254 175
255 ret = -EINVAL; 176 ret = -EINVAL;
256 177
257 id = pdata->led[i].id; 178 id = pdata->led[i].id;
258 name = pdata->led[i].name; 179 name = pdata->led[i].name;
259 trig = pdata->led[i].default_trigger; 180 trig = pdata->led[i].default_trigger;
260 max_current = pdata->led[i].max_current;
261 181
262 if ((id > devtype->led_max) || (id < devtype->led_min)) { 182 if ((id > devtype->led_max) || (id < devtype->led_min)) {
263 dev_err(&pdev->dev, "Invalid ID %i\n", id); 183 dev_err(&pdev->dev, "Invalid ID %i\n", id);
@@ -280,11 +200,6 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)
280 200
281 INIT_WORK(&leds->led[i].work, mc13xxx_led_work); 201 INIT_WORK(&leds->led[i].work, mc13xxx_led_work);
282 202
283 ret = mc13xxx_led_setup(&leds->led[i], max_current);
284 if (ret) {
285 dev_err(&pdev->dev, "Unable to setup LED %i\n", id);
286 break;
287 }
288 ret = led_classdev_register(pdev->dev.parent, 203 ret = led_classdev_register(pdev->dev.parent,
289 &leds->led[i].cdev); 204 &leds->led[i].cdev);
290 if (ret) { 205 if (ret) {
@@ -313,10 +228,8 @@ static int mc13xxx_led_remove(struct platform_device *pdev)
313 cancel_work_sync(&leds->led[i].work); 228 cancel_work_sync(&leds->led[i].work);
314 } 229 }
315 230
316 mc13xxx_lock(mcdev);
317 for (i = 0; i < leds->devtype->num_regs; i++) 231 for (i = 0; i < leds->devtype->num_regs; i++)
318 mc13xxx_reg_write(mcdev, MC13XXX_REG_LED_CONTROL(i), 0); 232 mc13xxx_reg_write(mcdev, MC13XXX_REG_LED_CONTROL(i), 0);
319 mc13xxx_unlock(mcdev);
320 233
321 return 0; 234 return 0;
322} 235}
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index b31d8e99c419..605047428b5a 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -66,9 +66,11 @@ static void led_pwm_set(struct led_classdev *led_cdev,
66 struct led_pwm_data *led_dat = 66 struct led_pwm_data *led_dat =
67 container_of(led_cdev, struct led_pwm_data, cdev); 67 container_of(led_cdev, struct led_pwm_data, cdev);
68 unsigned int max = led_dat->cdev.max_brightness; 68 unsigned int max = led_dat->cdev.max_brightness;
69 unsigned int period = led_dat->period; 69 unsigned long long duty = led_dat->period;
70 70
71 led_dat->duty = brightness * period / max; 71 duty *= brightness;
72 do_div(duty, max);
73 led_dat->duty = duty;
72 74
73 if (led_dat->can_sleep) 75 if (led_dat->can_sleep)
74 schedule_work(&led_dat->work); 76 schedule_work(&led_dat->work);
@@ -85,11 +87,10 @@ static inline size_t sizeof_pwm_leds_priv(int num_leds)
85static int led_pwm_create_of(struct platform_device *pdev, 87static int led_pwm_create_of(struct platform_device *pdev,
86 struct led_pwm_priv *priv) 88 struct led_pwm_priv *priv)
87{ 89{
88 struct device_node *node = pdev->dev.of_node;
89 struct device_node *child; 90 struct device_node *child;
90 int ret; 91 int ret;
91 92
92 for_each_child_of_node(node, child) { 93 for_each_child_of_node(pdev->dev.of_node, child) {
93 struct led_pwm_data *led_dat = &priv->leds[priv->num_leds]; 94 struct led_pwm_data *led_dat = &priv->leds[priv->num_leds];
94 95
95 led_dat->cdev.name = of_get_property(child, "label", 96 led_dat->cdev.name = of_get_property(child, "label",
diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
index 87cf215af798..98174e7240ee 100644
--- a/drivers/leds/leds-s3c24xx.c
+++ b/drivers/leds/leds-s3c24xx.c
@@ -18,11 +18,10 @@
18#include <linux/gpio.h> 18#include <linux/gpio.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/platform_data/leds-s3c24xx.h>
21 22
22#include <mach/hardware.h>
23#include <mach/regs-gpio.h> 23#include <mach/regs-gpio.h>
24#include <plat/gpio-cfg.h> 24#include <plat/gpio-cfg.h>
25#include <linux/platform_data/leds-s3c24xx.h>
26 25
27/* our context */ 26/* our context */
28 27
diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index 8cc304f36728..3d9e267a56c4 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -4,77 +4,87 @@
4 * The TCA6507 is a programmable LED controller that can drive 7 4 * The TCA6507 is a programmable LED controller that can drive 7
5 * separate lines either by holding them low, or by pulsing them 5 * separate lines either by holding them low, or by pulsing them
6 * with modulated width. 6 * with modulated width.
7 * The modulation can be varied in a simple pattern to produce a blink or 7 * The modulation can be varied in a simple pattern to produce a
8 * double-blink. 8 * blink or double-blink.
9 * 9 *
10 * This driver can configure each line either as a 'GPIO' which is out-only 10 * This driver can configure each line either as a 'GPIO' which is
11 * (no pull-up) or as an LED with variable brightness and hardware-assisted 11 * out-only (pull-up resistor required) or as an LED with variable
12 * blinking. 12 * brightness and hardware-assisted blinking.
13 * 13 *
14 * Apart from OFF and ON there are three programmable brightness levels which 14 * Apart from OFF and ON there are three programmable brightness
15 * can be programmed from 0 to 15 and indicate how many 500usec intervals in 15 * levels which can be programmed from 0 to 15 and indicate how many
16 * each 8msec that the led is 'on'. The levels are named MASTER, BANK0 and 16 * 500usec intervals in each 8msec that the led is 'on'. The levels
17 * BANK1. 17 * are named MASTER, BANK0 and BANK1.
18 * 18 *
19 * There are two different blink rates that can be programmed, each with 19 * There are two different blink rates that can be programmed, each
20 * separate time for rise, on, fall, off and second-off. Thus if 3 or more 20 * with separate time for rise, on, fall, off and second-off. Thus if
21 * different non-trivial rates are required, software must be used for the extra 21 * 3 or more different non-trivial rates are required, software must
22 * rates. The two different blink rates must align with the two levels BANK0 and 22 * be used for the extra rates. The two different blink rates must
23 * BANK1. 23 * align with the two levels BANK0 and BANK1. This driver does not
24 * This driver does not support double-blink so 'second-off' always matches 24 * support double-blink so 'second-off' always matches 'off'.
25 * 'off'.
26 * 25 *
27 * Only 16 different times can be programmed in a roughly logarithmic scale from 26 * Only 16 different times can be programmed in a roughly logarithmic
28 * 64ms to 16320ms. To be precise the possible times are: 27 * scale from 64ms to 16320ms. To be precise the possible times are:
29 * 0, 64, 128, 192, 256, 384, 512, 768, 28 * 0, 64, 128, 192, 256, 384, 512, 768,
30 * 1024, 1536, 2048, 3072, 4096, 5760, 8128, 16320 29 * 1024, 1536, 2048, 3072, 4096, 5760, 8128, 16320
31 * 30 *
32 * Times that cannot be closely matched with these must be 31 * Times that cannot be closely matched with these must be handled in
33 * handled in software. This driver allows 12.5% error in matching. 32 * software. This driver allows 12.5% error in matching.
34 * 33 *
35 * This driver does not allow rise/fall rates to be set explicitly. When trying 34 * This driver does not allow rise/fall rates to be set explicitly.
36 * to match a given 'on' or 'off' period, an appropriate pair of 'change' and 35 * When trying to match a given 'on' or 'off' period, an appropriate
37 * 'hold' times are chosen to get a close match. If the target delay is even, 36 * pair of 'change' and 'hold' times are chosen to get a close match.
38 * the 'change' number will be the smaller; if odd, the 'hold' number will be 37 * If the target delay is even, the 'change' number will be the
39 * the smaller. 38 * smaller; if odd, the 'hold' number will be the smaller.
40 39
41 * Choosing pairs of delays with 12.5% errors allows us to match delays in the 40 * Choosing pairs of delays with 12.5% errors allows us to match
42 * ranges: 56-72, 112-144, 168-216, 224-27504, 28560-36720. 41 * delays in the ranges: 56-72, 112-144, 168-216, 224-27504,
43 * 26% of the achievable sums can be matched by multiple pairings. For example 42 * 28560-36720.
44 * 1536 == 1536+0, 1024+512, or 768+768. This driver will always choose the 43 * 26% of the achievable sums can be matched by multiple pairings.
45 * pairing with the least maximum - 768+768 in this case. Other pairings are 44 * For example 1536 == 1536+0, 1024+512, or 768+768.
46 * not available. 45 * This driver will always choose the pairing with the least
46 * maximum - 768+768 in this case. Other pairings are not available.
47 * 47 *
48 * Access to the 3 levels and 2 blinks are on a first-come, first-served basis. 48 * Access to the 3 levels and 2 blinks are on a first-come,
49 * Access can be shared by multiple leds if they have the same level and 49 * first-served basis. Access can be shared by multiple leds if they
50 * either same blink rates, or some don't blink. 50 * have the same level and either same blink rates, or some don't
51 * When a led changes, it relinquishes access and tries again, so it might 51 * blink. When a led changes, it relinquishes access and tries again,
52 * lose access to hardware blink. 52 * so it might lose access to hardware blink.
53 * If a blink engine cannot be allocated, software blink is used.
54 * If the desired brightness cannot be allocated, the closest available non-zero
55 * brightness is used. As 'full' is always available, the worst case would be
56 * to have two different blink rates at '1', with Max at '2', then other leds
57 * will have to choose between '2' and '16'. Hopefully this is not likely.
58 * 53 *
59 * Each bank (BANK0 and BANK1) has two usage counts - LEDs using the brightness 54 * If a blink engine cannot be allocated, software blink is used. If
60 * and LEDs using the blink. It can only be reprogrammed when the appropriate 55 * the desired brightness cannot be allocated, the closest available
61 * counter is zero. The MASTER level has a single usage count. 56 * non-zero brightness is used. As 'full' is always available, the
57 * worst case would be to have two different blink rates at '1', with
58 * Max at '2', then other leds will have to choose between '2' and
59 * '16'. Hopefully this is not likely.
62 * 60 *
63 * Each Led has programmable 'on' and 'off' time as milliseconds. With each 61 * Each bank (BANK0 and BANK1) has two usage counts - LEDs using the
64 * there is a flag saying if it was explicitly requested or defaulted. 62 * brightness and LEDs using the blink. It can only be reprogrammed
65 * Similarly the banks know if each time was explicit or a default. Defaults 63 * when the appropriate counter is zero. The MASTER level has a
66 * are permitted to be changed freely - they are not recognised when matching. 64 * single usage count.
67 * 65 *
66 * Each LED has programmable 'on' and 'off' time as milliseconds.
67 * With each there is a flag saying if it was explicitly requested or
68 * defaulted. Similarly the banks know if each time was explicit or a
69 * default. Defaults are permitted to be changed freely - they are
70 * not recognised when matching.
68 * 71 *
69 * An led-tca6507 device must be provided with platform data. This data
70 * lists for each output: the name, default trigger, and whether the signal
71 * is being used as a GPiO rather than an led. 'struct led_plaform_data'
72 * is used for this. If 'name' is NULL, the output isn't used. If 'flags'
73 * is TCA6507_MAKE_CPIO, the output is a GPO.
74 * The "struct led_platform_data" can be embedded in a
75 * "struct tca6507_platform_data" which adds a 'gpio_base' for the GPiOs,
76 * and a 'setup' callback which is called once the GPiOs are available.
77 * 72 *
73 * An led-tca6507 device must be provided with platform data or
74 * configured via devicetree.
75 *
76 * The platform-data lists for each output: the name, default trigger,
77 * and whether the signal is being used as a GPIO rather than an LED.
78 * 'struct led_plaform_data' is used for this. If 'name' is NULL, the
79 * output isn't used. If 'flags' is TCA6507_MAKE_GPIO, the output is
80 * a GPO. The "struct led_platform_data" can be embedded in a "struct
81 * tca6507_platform_data" which adds a 'gpio_base' for the GPIOs, and
82 * a 'setup' callback which is called once the GPIOs are available.
83 *
84 * When configured via devicetree there is one child for each output.
85 * The "reg" determines the output number and "compatible" determines
86 * whether it is an LED or a GPIO. "linux,default-trigger" can set a
87 * default trigger.
78 */ 88 */
79 89
80#include <linux/module.h> 90#include <linux/module.h>
@@ -192,17 +202,18 @@ MODULE_DEVICE_TABLE(i2c, tca6507_id);
192static int choose_times(int msec, int *c1p, int *c2p) 202static int choose_times(int msec, int *c1p, int *c2p)
193{ 203{
194 /* 204 /*
195 * Choose two timecodes which add to 'msec' as near as possible. 205 * Choose two timecodes which add to 'msec' as near as
196 * The first returned is the 'on' or 'off' time. The second is to be 206 * possible. The first returned is the 'on' or 'off' time.
197 * used as a 'fade-on' or 'fade-off' time. If 'msec' is even, 207 * The second is to be used as a 'fade-on' or 'fade-off' time.
198 * the first will not be smaller than the second. If 'msec' is odd, 208 * If 'msec' is even, the first will not be smaller than the
199 * the first will not be larger than the second. 209 * second. If 'msec' is odd, the first will not be larger
200 * If we cannot get a sum within 1/8 of 'msec' fail with -EINVAL, 210 * than the second.
201 * otherwise return the sum that was achieved, plus 1 if the first is 211 * If we cannot get a sum within 1/8 of 'msec' fail with
202 * smaller. 212 * -EINVAL, otherwise return the sum that was achieved, plus 1
203 * If two possibilities are equally good (e.g. 512+0, 256+256), choose 213 * if the first is smaller.
204 * the first pair so there is more change-time visible (i.e. it is 214 * If two possibilities are equally good (e.g. 512+0,
205 * softer). 215 * 256+256), choose the first pair so there is more
216 * change-time visible (i.e. it is softer).
206 */ 217 */
207 int c1, c2; 218 int c1, c2;
208 int tmax = msec * 9 / 8; 219 int tmax = msec * 9 / 8;
@@ -255,8 +266,8 @@ static int choose_times(int msec, int *c1p, int *c2p)
255} 266}
256 267
257/* 268/*
258 * Update the register file with the appropriate 3-bit state for 269 * Update the register file with the appropriate 3-bit state for the
259 * the given led. 270 * given led.
260 */ 271 */
261static void set_select(struct tca6507_chip *tca, int led, int val) 272static void set_select(struct tca6507_chip *tca, int led, int val)
262{ 273{
@@ -274,9 +285,9 @@ static void set_select(struct tca6507_chip *tca, int led, int val)
274 } 285 }
275} 286}
276 287
277/* Update the register file with the appropriate 4-bit code for 288/* Update the register file with the appropriate 4-bit code for one
278 * one bank or other. This can be used for timers, for levels, or 289 * bank or other. This can be used for timers, for levels, or for
279 * for initialisation. 290 * initialization.
280 */ 291 */
281static void set_code(struct tca6507_chip *tca, int reg, int bank, int new) 292static void set_code(struct tca6507_chip *tca, int reg, int bank, int new)
282{ 293{
@@ -309,7 +320,7 @@ static void set_level(struct tca6507_chip *tca, int bank, int level)
309 tca->bank[bank].level = level; 320 tca->bank[bank].level = level;
310} 321}
311 322
312/* Record all relevant time code for a given bank */ 323/* Record all relevant time codes for a given bank */
313static void set_times(struct tca6507_chip *tca, int bank) 324static void set_times(struct tca6507_chip *tca, int bank)
314{ 325{
315 int c1, c2; 326 int c1, c2;
@@ -317,7 +328,8 @@ static void set_times(struct tca6507_chip *tca, int bank)
317 328
318 result = choose_times(tca->bank[bank].ontime, &c1, &c2); 329 result = choose_times(tca->bank[bank].ontime, &c1, &c2);
319 dev_dbg(&tca->client->dev, 330 dev_dbg(&tca->client->dev,
320 "Chose on times %d(%d) %d(%d) for %dms\n", c1, time_codes[c1], 331 "Chose on times %d(%d) %d(%d) for %dms\n",
332 c1, time_codes[c1],
321 c2, time_codes[c2], tca->bank[bank].ontime); 333 c2, time_codes[c2], tca->bank[bank].ontime);
322 set_code(tca, TCA6507_FADE_ON, bank, c2); 334 set_code(tca, TCA6507_FADE_ON, bank, c2);
323 set_code(tca, TCA6507_FULL_ON, bank, c1); 335 set_code(tca, TCA6507_FULL_ON, bank, c1);
@@ -325,7 +337,8 @@ static void set_times(struct tca6507_chip *tca, int bank)
325 337
326 result = choose_times(tca->bank[bank].offtime, &c1, &c2); 338 result = choose_times(tca->bank[bank].offtime, &c1, &c2);
327 dev_dbg(&tca->client->dev, 339 dev_dbg(&tca->client->dev,
328 "Chose off times %d(%d) %d(%d) for %dms\n", c1, time_codes[c1], 340 "Chose off times %d(%d) %d(%d) for %dms\n",
341 c1, time_codes[c1],
329 c2, time_codes[c2], tca->bank[bank].offtime); 342 c2, time_codes[c2], tca->bank[bank].offtime);
330 set_code(tca, TCA6507_FADE_OFF, bank, c2); 343 set_code(tca, TCA6507_FADE_OFF, bank, c2);
331 set_code(tca, TCA6507_FIRST_OFF, bank, c1); 344 set_code(tca, TCA6507_FIRST_OFF, bank, c1);
@@ -373,7 +386,8 @@ static void led_release(struct tca6507_led *led)
373 386
374static int led_prepare(struct tca6507_led *led) 387static int led_prepare(struct tca6507_led *led)
375{ 388{
376 /* Assign this led to a bank, configuring that bank if necessary. */ 389 /* Assign this led to a bank, configuring that bank if
390 * necessary. */
377 int level = TO_LEVEL(led->led_cdev.brightness); 391 int level = TO_LEVEL(led->led_cdev.brightness);
378 struct tca6507_chip *tca = led->chip; 392 struct tca6507_chip *tca = led->chip;
379 int c1, c2; 393 int c1, c2;
@@ -389,10 +403,10 @@ static int led_prepare(struct tca6507_led *led)
389 403
390 if (led->ontime == 0 || led->offtime == 0) { 404 if (led->ontime == 0 || led->offtime == 0) {
391 /* 405 /*
392 * Just set the brightness, choosing first usable bank. 406 * Just set the brightness, choosing first usable
393 * If none perfect, choose best. 407 * bank. If none perfect, choose best. Count
394 * Count backwards so we check MASTER bank first 408 * backwards so we check MASTER bank first to avoid
395 * to avoid wasting a timer. 409 * wasting a timer.
396 */ 410 */
397 int best = -1;/* full-on */ 411 int best = -1;/* full-on */
398 int diff = 15-level; 412 int diff = 15-level;
@@ -433,9 +447,9 @@ static int led_prepare(struct tca6507_led *led)
433 } 447 }
434 448
435 /* 449 /*
436 * We have on/off time so we need to try to allocate a timing bank. 450 * We have on/off time so we need to try to allocate a timing
437 * First check if times are compatible with hardware and give up if 451 * bank. First check if times are compatible with hardware
438 * not. 452 * and give up if not.
439 */ 453 */
440 if (choose_times(led->ontime, &c1, &c2) < 0) 454 if (choose_times(led->ontime, &c1, &c2) < 0)
441 return -EINVAL; 455 return -EINVAL;
@@ -523,8 +537,8 @@ static int led_assign(struct tca6507_led *led)
523 err = led_prepare(led); 537 err = led_prepare(led);
524 if (err) { 538 if (err) {
525 /* 539 /*
526 * Can only fail on timer setup. In that case we need to 540 * Can only fail on timer setup. In that case we need
527 * re-establish as steady level. 541 * to re-establish as steady level.
528 */ 542 */
529 led->ontime = 0; 543 led->ontime = 0;
530 led->offtime = 0; 544 led->offtime = 0;
@@ -594,8 +608,8 @@ static void tca6507_gpio_set_value(struct gpio_chip *gc,
594 608
595 spin_lock_irqsave(&tca->lock, flags); 609 spin_lock_irqsave(&tca->lock, flags);
596 /* 610 /*
597 * 'OFF' is floating high, and 'ON' is pulled down, so it has the 611 * 'OFF' is floating high, and 'ON' is pulled down, so it has
598 * inverse sense of 'val'. 612 * the inverse sense of 'val'.
599 */ 613 */
600 set_select(tca, tca->gpio_map[offset], 614 set_select(tca, tca->gpio_map[offset],
601 val ? TCA6507_LS_LED_OFF : TCA6507_LS_LED_ON); 615 val ? TCA6507_LS_LED_OFF : TCA6507_LS_LED_ON);
@@ -638,6 +652,9 @@ static int tca6507_probe_gpios(struct i2c_client *client,
638 tca->gpio.direction_output = tca6507_gpio_direction_output; 652 tca->gpio.direction_output = tca6507_gpio_direction_output;
639 tca->gpio.set = tca6507_gpio_set_value; 653 tca->gpio.set = tca6507_gpio_set_value;
640 tca->gpio.dev = &client->dev; 654 tca->gpio.dev = &client->dev;
655#ifdef CONFIG_OF_GPIO
656 tca->gpio.of_node = of_node_get(client->dev.of_node);
657#endif
641 err = gpiochip_add(&tca->gpio); 658 err = gpiochip_add(&tca->gpio);
642 if (err) { 659 if (err) {
643 tca->gpio.ngpio = 0; 660 tca->gpio.ngpio = 0;
@@ -682,7 +699,7 @@ tca6507_led_dt_init(struct i2c_client *client)
682 return ERR_PTR(-ENODEV); 699 return ERR_PTR(-ENODEV);
683 700
684 tca_leds = devm_kzalloc(&client->dev, 701 tca_leds = devm_kzalloc(&client->dev,
685 sizeof(struct led_info) * count, GFP_KERNEL); 702 sizeof(struct led_info) * NUM_LEDS, GFP_KERNEL);
686 if (!tca_leds) 703 if (!tca_leds)
687 return ERR_PTR(-ENOMEM); 704 return ERR_PTR(-ENOMEM);
688 705
@@ -695,9 +712,11 @@ tca6507_led_dt_init(struct i2c_client *client)
695 of_get_property(child, "label", NULL) ? : child->name; 712 of_get_property(child, "label", NULL) ? : child->name;
696 led.default_trigger = 713 led.default_trigger =
697 of_get_property(child, "linux,default-trigger", NULL); 714 of_get_property(child, "linux,default-trigger", NULL);
698 715 led.flags = 0;
716 if (of_property_match_string(child, "compatible", "gpio") >= 0)
717 led.flags |= TCA6507_MAKE_GPIO;
699 ret = of_property_read_u32(child, "reg", &reg); 718 ret = of_property_read_u32(child, "reg", &reg);
700 if (ret != 0) 719 if (ret != 0 || reg < 0 || reg >= NUM_LEDS)
701 continue; 720 continue;
702 721
703 tca_leds[reg] = led; 722 tca_leds[reg] = led;
@@ -708,8 +727,10 @@ tca6507_led_dt_init(struct i2c_client *client)
708 return ERR_PTR(-ENOMEM); 727 return ERR_PTR(-ENOMEM);
709 728
710 pdata->leds.leds = tca_leds; 729 pdata->leds.leds = tca_leds;
711 pdata->leds.num_leds = count; 730 pdata->leds.num_leds = NUM_LEDS;
712 731#ifdef CONFIG_GPIOLIB
732 pdata->gpio_base = -1;
733#endif
713 return pdata; 734 return pdata;
714} 735}
715 736
diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h
index 6156686bf108..ac39d910e70b 100644
--- a/include/linux/mfd/mc13xxx.h
+++ b/include/linux/mfd/mc13xxx.h
@@ -110,9 +110,6 @@ struct mc13xxx_led_platform_data {
110 int id; 110 int id;
111 const char *name; 111 const char *name;
112 const char *default_trigger; 112 const char *default_trigger;
113
114/* Three or two bits current selection depending on the led */
115 char max_current;
116}; 113};
117 114
118#define MAX_LED_CONTROL_REGS 6 115#define MAX_LED_CONTROL_REGS 6
@@ -121,7 +118,7 @@ struct mc13xxx_leds_platform_data {
121 struct mc13xxx_led_platform_data *led; 118 struct mc13xxx_led_platform_data *led;
122 int num_leds; 119 int num_leds;
123 120
124/* LED Control 0 */ 121/* MC13783 LED Control 0 */
125#define MC13783_LED_C0_ENABLE (1 << 0) 122#define MC13783_LED_C0_ENABLE (1 << 0)
126#define MC13783_LED_C0_TRIODE_MD (1 << 7) 123#define MC13783_LED_C0_TRIODE_MD (1 << 7)
127#define MC13783_LED_C0_TRIODE_AD (1 << 8) 124#define MC13783_LED_C0_TRIODE_AD (1 << 8)
@@ -129,21 +126,43 @@ struct mc13xxx_leds_platform_data {
129#define MC13783_LED_C0_BOOST (1 << 10) 126#define MC13783_LED_C0_BOOST (1 << 10)
130#define MC13783_LED_C0_ABMODE(x) (((x) & 0x7) << 11) 127#define MC13783_LED_C0_ABMODE(x) (((x) & 0x7) << 11)
131#define MC13783_LED_C0_ABREF(x) (((x) & 0x3) << 14) 128#define MC13783_LED_C0_ABREF(x) (((x) & 0x3) << 14)
132/* LED Control 1 */ 129/* MC13783 LED Control 1 */
133#define MC13783_LED_C1_TC1HALF (1 << 18) 130#define MC13783_LED_C1_TC1HALF (1 << 18)
134#define MC13783_LED_C1_SLEWLIM (1 << 23) 131#define MC13783_LED_C1_SLEWLIM (1 << 23)
135/* LED Control 2 */ 132/* MC13783 LED Control 2 */
133#define MC13783_LED_C2_CURRENT_MD(x) (((x) & 0x7) << 0)
134#define MC13783_LED_C2_CURRENT_AD(x) (((x) & 0x7) << 3)
135#define MC13783_LED_C2_CURRENT_KP(x) (((x) & 0x7) << 6)
136#define MC13783_LED_C2_PERIOD(x) (((x) & 0x3) << 21) 136#define MC13783_LED_C2_PERIOD(x) (((x) & 0x3) << 21)
137#define MC13783_LED_C2_SLEWLIM (1 << 23) 137#define MC13783_LED_C2_SLEWLIM (1 << 23)
138/* LED Control 3 */ 138/* MC13783 LED Control 3 */
139#define MC13783_LED_C3_CURRENT_R1(x) (((x) & 0x3) << 0)
140#define MC13783_LED_C3_CURRENT_G1(x) (((x) & 0x3) << 2)
141#define MC13783_LED_C3_CURRENT_B1(x) (((x) & 0x3) << 4)
139#define MC13783_LED_C3_PERIOD(x) (((x) & 0x3) << 21) 142#define MC13783_LED_C3_PERIOD(x) (((x) & 0x3) << 21)
140#define MC13783_LED_C3_TRIODE_TC1 (1 << 23) 143#define MC13783_LED_C3_TRIODE_TC1 (1 << 23)
141/* LED Control 4 */ 144/* MC13783 LED Control 4 */
145#define MC13783_LED_C4_CURRENT_R2(x) (((x) & 0x3) << 0)
146#define MC13783_LED_C4_CURRENT_G2(x) (((x) & 0x3) << 2)
147#define MC13783_LED_C4_CURRENT_B2(x) (((x) & 0x3) << 4)
142#define MC13783_LED_C4_PERIOD(x) (((x) & 0x3) << 21) 148#define MC13783_LED_C4_PERIOD(x) (((x) & 0x3) << 21)
143#define MC13783_LED_C4_TRIODE_TC2 (1 << 23) 149#define MC13783_LED_C4_TRIODE_TC2 (1 << 23)
144/* LED Control 5 */ 150/* MC13783 LED Control 5 */
151#define MC13783_LED_C5_CURRENT_R3(x) (((x) & 0x3) << 0)
152#define MC13783_LED_C5_CURRENT_G3(x) (((x) & 0x3) << 2)
153#define MC13783_LED_C5_CURRENT_B3(x) (((x) & 0x3) << 4)
145#define MC13783_LED_C5_PERIOD(x) (((x) & 0x3) << 21) 154#define MC13783_LED_C5_PERIOD(x) (((x) & 0x3) << 21)
146#define MC13783_LED_C5_TRIODE_TC3 (1 << 23) 155#define MC13783_LED_C5_TRIODE_TC3 (1 << 23)
156/* MC13892 LED Control 0 */
157#define MC13892_LED_C0_CURRENT_MD(x) (((x) & 0x7) << 9)
158#define MC13892_LED_C0_CURRENT_AD(x) (((x) & 0x7) << 21)
159/* MC13892 LED Control 1 */
160#define MC13892_LED_C1_CURRENT_KP(x) (((x) & 0x7) << 9)
161/* MC13892 LED Control 2 */
162#define MC13892_LED_C2_CURRENT_R(x) (((x) & 0x7) << 9)
163#define MC13892_LED_C2_CURRENT_G(x) (((x) & 0x7) << 21)
164/* MC13892 LED Control 3 */
165#define MC13892_LED_C3_CURRENT_B(x) (((x) & 0x7) << 9)
147 u32 led_control[MAX_LED_CONTROL_REGS]; 166 u32 led_control[MAX_LED_CONTROL_REGS];
148}; 167};
149 168
diff --git a/include/linux/platform_data/leds-kirkwood-netxbig.h b/include/linux/platform_data/leds-kirkwood-netxbig.h
index 24b536ebdf13..d2be19a51acd 100644
--- a/include/linux/platform_data/leds-kirkwood-netxbig.h
+++ b/include/linux/platform_data/leds-kirkwood-netxbig.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/arm/mach-kirkwood/include/mach/leds-netxbig.h
3 *
4 * Platform data structure for netxbig LED driver 2 * Platform data structure for netxbig LED driver
5 * 3 *
6 * This file is licensed under the terms of the GNU General Public 4 * This file is licensed under the terms of the GNU General Public
@@ -8,8 +6,8 @@
8 * warranty of any kind, whether express or implied. 6 * warranty of any kind, whether express or implied.
9 */ 7 */
10 8
11#ifndef __MACH_LEDS_NETXBIG_H 9#ifndef __LEDS_KIRKWOOD_NETXBIG_H
12#define __MACH_LEDS_NETXBIG_H 10#define __LEDS_KIRKWOOD_NETXBIG_H
13 11
14struct netxbig_gpio_ext { 12struct netxbig_gpio_ext {
15 unsigned *addr; 13 unsigned *addr;
@@ -52,4 +50,4 @@ struct netxbig_led_platform_data {
52 int num_leds; 50 int num_leds;
53}; 51};
54 52
55#endif /* __MACH_LEDS_NETXBIG_H */ 53#endif /* __LEDS_KIRKWOOD_NETXBIG_H */
diff --git a/include/linux/platform_data/leds-kirkwood-ns2.h b/include/linux/platform_data/leds-kirkwood-ns2.h
index e21272e5f668..6a9fed57f346 100644
--- a/include/linux/platform_data/leds-kirkwood-ns2.h
+++ b/include/linux/platform_data/leds-kirkwood-ns2.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/arm/mach-kirkwood/include/mach/leds-ns2.h
3 *
4 * Platform data structure for Network Space v2 LED driver 2 * Platform data structure for Network Space v2 LED driver
5 * 3 *
6 * This file is licensed under the terms of the GNU General Public 4 * This file is licensed under the terms of the GNU General Public
@@ -8,8 +6,8 @@
8 * warranty of any kind, whether express or implied. 6 * warranty of any kind, whether express or implied.
9 */ 7 */
10 8
11#ifndef __MACH_LEDS_NS2_H 9#ifndef __LEDS_KIRKWOOD_NS2_H
12#define __MACH_LEDS_NS2_H 10#define __LEDS_KIRKWOOD_NS2_H
13 11
14struct ns2_led { 12struct ns2_led {
15 const char *name; 13 const char *name;
@@ -23,4 +21,4 @@ struct ns2_led_platform_data {
23 struct ns2_led *leds; 21 struct ns2_led *leds;
24}; 22};
25 23
26#endif /* __MACH_LEDS_NS2_H */ 24#endif /* __LEDS_KIRKWOOD_NS2_H */