leds.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #include "gpio.h"
  18. /* ------------------------------------------------------------------------- */
  19. #if defined(CONFIG_NEW_LEDS)
  20. /*
  21. * New cross-platform LED support.
  22. */
  23. static struct gpio_led_platform_data led_data;
  24. static struct platform_device at91_gpio_leds_device = {
  25. .name = "leds-gpio",
  26. .id = -1,
  27. .dev.platform_data = &led_data,
  28. };
  29. void __init at91_gpio_leds(struct gpio_led *leds, int nr)
  30. {
  31. int i;
  32. if (!nr)
  33. return;
  34. for (i = 0; i < nr; i++)
  35. at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
  36. led_data.leds = leds;
  37. led_data.num_leds = nr;
  38. platform_device_register(&at91_gpio_leds_device);
  39. }
  40. #else
  41. void __init at91_gpio_leds(struct gpio_led *leds, int nr) {}
  42. #endif
  43. /* ------------------------------------------------------------------------- */
  44. #if defined (CONFIG_LEDS_ATMEL_PWM)
  45. /*
  46. * PWM Leds
  47. */
  48. static struct gpio_led_platform_data pwm_led_data;
  49. static struct platform_device at91_pwm_leds_device = {
  50. .name = "leds-atmel-pwm",
  51. .id = -1,
  52. .dev.platform_data = &pwm_led_data,
  53. };
  54. void __init at91_pwm_leds(struct gpio_led *leds, int nr)
  55. {
  56. int i;
  57. u32 pwm_mask = 0;
  58. if (!nr)
  59. return;
  60. for (i = 0; i < nr; i++)
  61. pwm_mask |= (1 << leds[i].gpio);
  62. pwm_led_data.leds = leds;
  63. pwm_led_data.num_leds = nr;
  64. at91_add_device_pwm(pwm_mask);
  65. platform_device_register(&at91_pwm_leds_device);
  66. }
  67. #else
  68. void __init at91_pwm_leds(struct gpio_led *leds, int nr){}
  69. #endif