board-d2net.c 2.8 KB

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