aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2012-11-26 04:04:39 -0500
committerOlof Johansson <olof@lixom.net>2012-11-26 04:04:39 -0500
commit0d5c2e21d3151f13812bc562544f5eda9c9c9abc (patch)
treef0db9a6df5a29a7daaa25cf3bd942a496cf637e6 /drivers
parent48b71e3ac138469e83d044db22020424aaa44753 (diff)
parentf17073a3aec601cb9aba6d8c1c6dbc8c6a919c07 (diff)
Merge tag 'orion_boards_for_3.8' of git://git.infradead.org/users/jcooper/linux into next/boards
From Jason Cooper: orion boards for v3.8 - mach-orion5x/ joins the dark side! (devicetree) - Lacie Network Space family - Lacie Ethernet Disk mini v2 - USI TopKick - ZyXEL NSA310 - MPL CEC4 - Plat'Home OpenBlocks A6 (kirkwood, AX3-4 is armada xp) * tag 'orion_boards_for_3.8' of git://git.infradead.org/users/jcooper/linux: ARM: kirkwood: Add Plat'Home OpenBlocks A6 support ARM: Dove: update defconfig ARM: Kirkwood: update defconfig for new boards arm: orion5x: add DT related options in defconfig arm: orion5x: convert 'LaCie Ethernet Disk mini v2' to Device Tree arm: orion5x: basic Device Tree support arm: orion5x: mechanical defconfig update ARM: kirkwood: Add support for the MPL CEC4 arm: kirkwood: add support for ZyXEL NSA310 ARM: Kirkwood: new board USI Topkick ARM: kirkwood: use gpio-fan DT binding on lsxl ARM: Kirkwood: add Netspace boards to defconfig ARM: kirkwood: DT board setup for Network Space Mini v2 ARM: kirkwood: DT board setup for Network Space Lite v2 ARM: kirkwood: DT board setup for Network Space v2 and parents leds: leds-ns2: add device tree binding ARM: Kirkwood: Enable the second I2C bus
Diffstat (limited to 'drivers')
-rw-r--r--drivers/leds/Kconfig4
-rw-r--r--drivers/leds/leds-ns2.c78
2 files changed, 78 insertions, 4 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index f508defc0d96..b58bc8a14b9c 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -379,7 +379,9 @@ config LEDS_NS2
379 tristate "LED support for Network Space v2 GPIO LEDs" 379 tristate "LED support for Network Space v2 GPIO LEDs"
380 depends on LEDS_CLASS 380 depends on LEDS_CLASS
381 depends on MACH_NETSPACE_V2 || MACH_INETSPACE_V2 || \ 381 depends on MACH_NETSPACE_V2 || MACH_INETSPACE_V2 || \
382 MACH_NETSPACE_MAX_V2 || MACH_D2NET_V2 382 MACH_NETSPACE_MAX_V2 || MACH_D2NET_V2 || \
383 MACH_NETSPACE_V2_DT || MACH_INETSPACE_V2_DT || \
384 MACH_NETSPACE_MAX_V2_DT || MACH_NETSPACE_MINI_V2_DT
383 default y 385 default y
384 help 386 help
385 This option enable support for the dual-GPIO LED found on the 387 This option enable support for the dual-GPIO LED found on the
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c
index d176ec83f5d9..d64cc2227fd9 100644
--- a/drivers/leds/leds-ns2.c
+++ b/drivers/leds/leds-ns2.c
@@ -30,6 +30,7 @@
30#include <linux/leds.h> 30#include <linux/leds.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/platform_data/leds-kirkwood-ns2.h> 32#include <linux/platform_data/leds-kirkwood-ns2.h>
33#include <linux/of_gpio.h>
33 34
34/* 35/*
35 * The Network Space v2 dual-GPIO LED is wired to a CPLD and can blink in 36 * The Network Space v2 dual-GPIO LED is wired to a CPLD and can blink in
@@ -263,6 +264,62 @@ static void delete_ns2_led(struct ns2_led_data *led_dat)
263 gpio_free(led_dat->slow); 264 gpio_free(led_dat->slow);
264} 265}
265 266
267#ifdef CONFIG_OF_GPIO
268/*
269 * Translate OpenFirmware node properties into platform_data.
270 */
271static int __devinit
272ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata)
273{
274 struct device_node *np = dev->of_node;
275 struct device_node *child;
276 struct ns2_led *leds;
277 int num_leds = 0;
278 int i = 0;
279
280 num_leds = of_get_child_count(np);
281 if (!num_leds)
282 return -ENODEV;
283
284 leds = devm_kzalloc(dev, num_leds * sizeof(struct ns2_led),
285 GFP_KERNEL);
286 if (!leds)
287 return -ENOMEM;
288
289 for_each_child_of_node(np, child) {
290 const char *string;
291 int ret;
292
293 ret = of_get_named_gpio(child, "cmd-gpio", 0);
294 if (ret < 0)
295 return ret;
296 leds[i].cmd = ret;
297 ret = of_get_named_gpio(child, "slow-gpio", 0);
298 if (ret < 0)
299 return ret;
300 leds[i].slow = ret;
301 ret = of_property_read_string(child, "label", &string);
302 leds[i].name = (ret == 0) ? string : child->name;
303 ret = of_property_read_string(child, "linux,default-trigger",
304 &string);
305 if (ret == 0)
306 leds[i].default_trigger = string;
307
308 i++;
309 }
310
311 pdata->leds = leds;
312 pdata->num_leds = num_leds;
313
314 return 0;
315}
316
317static const struct of_device_id of_ns2_leds_match[] = {
318 { .compatible = "lacie,ns2-leds", },
319 {},
320};
321#endif /* CONFIG_OF_GPIO */
322
266static int __devinit ns2_led_probe(struct platform_device *pdev) 323static int __devinit ns2_led_probe(struct platform_device *pdev)
267{ 324{
268 struct ns2_led_platform_data *pdata = pdev->dev.platform_data; 325 struct ns2_led_platform_data *pdata = pdev->dev.platform_data;
@@ -270,11 +327,25 @@ static int __devinit ns2_led_probe(struct platform_device *pdev)
270 int i; 327 int i;
271 int ret; 328 int ret;
272 329
330#ifdef CONFIG_OF_GPIO
331 if (!pdata) {
332 pdata = devm_kzalloc(&pdev->dev,
333 sizeof(struct ns2_led_platform_data),
334 GFP_KERNEL);
335 if (!pdata)
336 return -ENOMEM;
337
338 ret = ns2_leds_get_of_pdata(&pdev->dev, pdata);
339 if (ret)
340 return ret;
341 }
342#else
273 if (!pdata) 343 if (!pdata)
274 return -EINVAL; 344 return -EINVAL;
345#endif /* CONFIG_OF_GPIO */
275 346
276 leds_data = devm_kzalloc(&pdev->dev, sizeof(struct ns2_led_data) * 347 leds_data = devm_kzalloc(&pdev->dev, sizeof(struct ns2_led_data) *
277 pdata->num_leds, GFP_KERNEL); 348 pdata->num_leds, GFP_KERNEL);
278 if (!leds_data) 349 if (!leds_data)
279 return -ENOMEM; 350 return -ENOMEM;
280 351
@@ -312,8 +383,9 @@ static struct platform_driver ns2_led_driver = {
312 .probe = ns2_led_probe, 383 .probe = ns2_led_probe,
313 .remove = __devexit_p(ns2_led_remove), 384 .remove = __devexit_p(ns2_led_remove),
314 .driver = { 385 .driver = {
315 .name = "leds-ns2", 386 .name = "leds-ns2",
316 .owner = THIS_MODULE, 387 .owner = THIS_MODULE,
388 .of_match_table = of_match_ptr(of_ns2_leds_match),
317 }, 389 },
318}; 390};
319 391