board-d2net.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * arch/arm/mach-orion5x/board-d2net.c
  3. *
  4. * LaCie d2Network and Big Disk Network NAS setup
  5. *
  6. * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com>
  7. *
  8. * This file is licensed under the terms of the GNU General Public
  9. * License version 2. This program is licensed "as is" without any
  10. * warranty of any kind, whether express or implied.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/pci.h>
  16. #include <linux/irq.h>
  17. #include <linux/leds.h>
  18. #include <linux/gpio.h>
  19. #include <asm/mach-types.h>
  20. #include <asm/mach/arch.h>
  21. #include <asm/mach/pci.h>
  22. #include <plat/orion-gpio.h>
  23. #include "common.h"
  24. #include "orion5x.h"
  25. /*****************************************************************************
  26. * LaCie d2 Network Info
  27. ****************************************************************************/
  28. /*****************************************************************************
  29. * GPIO LED's
  30. ****************************************************************************/
  31. /*
  32. * The blue front LED is wired to the CPLD and can blink in relation with the
  33. * SATA activity.
  34. *
  35. * The following array detail the different LED registers and the combination
  36. * of their possible values:
  37. *
  38. * led_off | blink_ctrl | SATA active | LED state
  39. * | | |
  40. * 1 | x | x | off
  41. * 0 | 0 | 0 | off
  42. * 0 | 1 | 0 | blink (rate 300ms)
  43. * 0 | x | 1 | on
  44. *
  45. * Notes: The blue and the red front LED's can't be on at the same time.
  46. * Red LED have priority.
  47. */
  48. #define D2NET_GPIO_RED_LED 6
  49. #define D2NET_GPIO_BLUE_LED_BLINK_CTRL 16
  50. #define D2NET_GPIO_BLUE_LED_OFF 23
  51. static struct gpio_led d2net_leds[] = {
  52. {
  53. .name = "d2net:blue:sata",
  54. .default_trigger = "default-on",
  55. .gpio = D2NET_GPIO_BLUE_LED_OFF,
  56. .active_low = 1,
  57. },
  58. {
  59. .name = "d2net:red:fail",
  60. .gpio = D2NET_GPIO_RED_LED,
  61. },
  62. };
  63. static struct gpio_led_platform_data d2net_led_data = {
  64. .num_leds = ARRAY_SIZE(d2net_leds),
  65. .leds = d2net_leds,
  66. };
  67. static struct platform_device d2net_gpio_leds = {
  68. .name = "leds-gpio",
  69. .id = -1,
  70. .dev = {
  71. .platform_data = &d2net_led_data,
  72. },
  73. };
  74. static void __init d2net_gpio_leds_init(void)
  75. {
  76. int err;
  77. /* Configure register blink_ctrl to allow SATA activity LED blinking. */
  78. err = gpio_request(D2NET_GPIO_BLUE_LED_BLINK_CTRL, "blue LED blink");
  79. if (err == 0) {
  80. err = gpio_direction_output(D2NET_GPIO_BLUE_LED_BLINK_CTRL, 1);
  81. if (err)
  82. gpio_free(D2NET_GPIO_BLUE_LED_BLINK_CTRL);
  83. }
  84. if (err)
  85. pr_err("d2net: failed to configure blue LED blink GPIO\n");
  86. platform_device_register(&d2net_gpio_leds);
  87. }
  88. /*****************************************************************************
  89. * General Setup
  90. ****************************************************************************/
  91. void __init d2net_init(void)
  92. {
  93. d2net_gpio_leds_init();
  94. pr_notice("d2net: Flash write are not yet supported.\n");
  95. }