leds.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * LED driver for Atmel AT91-based boards.
  3. *
  4. * Copyright (C) SAN People (Pty) Ltd
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/gpio.h>
  12. #include <linux/kernel.h>
  13. #include <linux/module.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include "board.h"
  17. /* ------------------------------------------------------------------------- */
  18. #if defined(CONFIG_NEW_LEDS)
  19. /*
  20. * New cross-platform LED support.
  21. */
  22. static struct gpio_led_platform_data led_data;
  23. static struct platform_device at91_gpio_leds_device = {
  24. .name = "leds-gpio",
  25. .id = -1,
  26. .dev.platform_data = &led_data,
  27. };
  28. void __init at91_gpio_leds(struct gpio_led *leds, int nr)
  29. {
  30. int i;
  31. if (!nr)
  32. return;
  33. for (i = 0; i < nr; i++)
  34. at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
  35. led_data.leds = leds;
  36. led_data.num_leds = nr;
  37. platform_device_register(&at91_gpio_leds_device);
  38. }
  39. #else
  40. void __init at91_gpio_leds(struct gpio_led *leds, int nr) {}
  41. #endif
  42. /* ------------------------------------------------------------------------- */
  43. #if defined (CONFIG_LEDS_ATMEL_PWM)
  44. /*
  45. * PWM Leds
  46. */
  47. static struct gpio_led_platform_data pwm_led_data;
  48. static struct platform_device at91_pwm_leds_device = {
  49. .name = "leds-atmel-pwm",
  50. .id = -1,
  51. .dev.platform_data = &pwm_led_data,
  52. };
  53. void __init at91_pwm_leds(struct gpio_led *leds, int nr)
  54. {
  55. int i;
  56. u32 pwm_mask = 0;
  57. if (!nr)
  58. return;
  59. for (i = 0; i < nr; i++)
  60. pwm_mask |= (1 << leds[i].gpio);
  61. pwm_led_data.leds = leds;
  62. pwm_led_data.num_leds = nr;
  63. at91_add_device_pwm(pwm_mask);
  64. platform_device_register(&at91_pwm_leds_device);
  65. }
  66. #else
  67. void __init at91_pwm_leds(struct gpio_led *leds, int nr){}
  68. #endif