wgt634u.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
  7. */
  8. #include <linux/platform_device.h>
  9. #include <linux/module.h>
  10. #include <linux/leds.h>
  11. #include <linux/ssb/ssb.h>
  12. #include <asm/mach-bcm47xx/bcm47xx.h>
  13. /* GPIO definitions for the WGT634U */
  14. #define WGT634U_GPIO_LED 3
  15. #define WGT634U_GPIO_RESET 2
  16. #define WGT634U_GPIO_TP1 7
  17. #define WGT634U_GPIO_TP2 6
  18. #define WGT634U_GPIO_TP3 5
  19. #define WGT634U_GPIO_TP4 4
  20. #define WGT634U_GPIO_TP5 1
  21. static struct gpio_led wgt634u_leds[] = {
  22. {
  23. .name = "power",
  24. .gpio = WGT634U_GPIO_LED,
  25. .active_low = 1,
  26. .default_trigger = "heartbeat",
  27. },
  28. };
  29. static struct gpio_led_platform_data wgt634u_led_data = {
  30. .num_leds = ARRAY_SIZE(wgt634u_leds),
  31. .leds = wgt634u_leds,
  32. };
  33. static struct platform_device wgt634u_gpio_leds = {
  34. .name = "leds-gpio",
  35. .id = -1,
  36. .dev = {
  37. .platform_data = &wgt634u_led_data,
  38. }
  39. };
  40. static int __init wgt634u_init(void)
  41. {
  42. /* There is no easy way to detect that we are running on a WGT634U
  43. * machine. Use the MAC address as an heuristic. Netgear Inc. has
  44. * been allocated ranges 00:09:5b:xx:xx:xx and 00:0f:b5:xx:xx:xx.
  45. */
  46. u8 *et0mac = ssb_bcm47xx.sprom.r1.et0mac;
  47. if (et0mac[0] == 0x00 &&
  48. ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) ||
  49. (et0mac[1] == 0x0f && et0mac[2] == 0xb5)))
  50. return platform_device_register(&wgt634u_gpio_leds);
  51. else
  52. return -ENODEV;
  53. }
  54. module_init(wgt634u_init);