d2net_v2-setup.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*
  2. * arch/arm/mach-kirkwood/d2net_v2-setup.c
  3. *
  4. * LaCie d2 Network Space v2 Board Setup
  5. *
  6. * Copyright (C) 2010 Simon Guinot <sguinot@lacie.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/ata_platform.h>
  26. #include <linux/mv643xx_eth.h>
  27. #include <linux/input.h>
  28. #include <linux/gpio.h>
  29. #include <linux/gpio_keys.h>
  30. #include <linux/leds.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <mach/kirkwood.h>
  34. #include <mach/leds-ns2.h>
  35. #include "common.h"
  36. #include "mpp.h"
  37. #include "lacie_v2-common.h"
  38. /*****************************************************************************
  39. * Ethernet
  40. ****************************************************************************/
  41. static struct mv643xx_eth_platform_data d2net_v2_ge00_data = {
  42. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  43. };
  44. /*****************************************************************************
  45. * SATA
  46. ****************************************************************************/
  47. static struct mv_sata_platform_data d2net_v2_sata_data = {
  48. .n_ports = 2,
  49. };
  50. /*****************************************************************************
  51. * GPIO keys
  52. ****************************************************************************/
  53. #define D2NET_V2_GPIO_PUSH_BUTTON 34
  54. #define D2NET_V2_GPIO_POWER_SWITCH_ON 13
  55. #define D2NET_V2_GPIO_POWER_SWITCH_OFF 15
  56. #define D2NET_V2_SWITCH_POWER_ON 0x1
  57. #define D2NET_V2_SWITCH_POWER_OFF 0x2
  58. static struct gpio_keys_button d2net_v2_buttons[] = {
  59. [0] = {
  60. .type = EV_SW,
  61. .code = D2NET_V2_SWITCH_POWER_ON,
  62. .gpio = D2NET_V2_GPIO_POWER_SWITCH_ON,
  63. .desc = "Back power switch (on|auto)",
  64. .active_low = 0,
  65. },
  66. [1] = {
  67. .type = EV_SW,
  68. .code = D2NET_V2_SWITCH_POWER_OFF,
  69. .gpio = D2NET_V2_GPIO_POWER_SWITCH_OFF,
  70. .desc = "Back power switch (auto|off)",
  71. .active_low = 0,
  72. },
  73. [2] = {
  74. .code = KEY_POWER,
  75. .gpio = D2NET_V2_GPIO_PUSH_BUTTON,
  76. .desc = "Front Push Button",
  77. .active_low = 1,
  78. },
  79. };
  80. static struct gpio_keys_platform_data d2net_v2_button_data = {
  81. .buttons = d2net_v2_buttons,
  82. .nbuttons = ARRAY_SIZE(d2net_v2_buttons),
  83. };
  84. static struct platform_device d2net_v2_gpio_buttons = {
  85. .name = "gpio-keys",
  86. .id = -1,
  87. .dev = {
  88. .platform_data = &d2net_v2_button_data,
  89. },
  90. };
  91. /*****************************************************************************
  92. * GPIO LEDs
  93. ****************************************************************************/
  94. #define D2NET_V2_GPIO_RED_LED 12
  95. static struct gpio_led d2net_v2_gpio_led_pins[] = {
  96. {
  97. .name = "d2net_v2:red:fail",
  98. .gpio = D2NET_V2_GPIO_RED_LED,
  99. },
  100. };
  101. static struct gpio_led_platform_data d2net_v2_gpio_leds_data = {
  102. .num_leds = ARRAY_SIZE(d2net_v2_gpio_led_pins),
  103. .leds = d2net_v2_gpio_led_pins,
  104. };
  105. static struct platform_device d2net_v2_gpio_leds = {
  106. .name = "leds-gpio",
  107. .id = -1,
  108. .dev = {
  109. .platform_data = &d2net_v2_gpio_leds_data,
  110. },
  111. };
  112. /*****************************************************************************
  113. * Dual-GPIO CPLD LEDs
  114. ****************************************************************************/
  115. #define D2NET_V2_GPIO_BLUE_LED_SLOW 29
  116. #define D2NET_V2_GPIO_BLUE_LED_CMD 30
  117. static struct ns2_led d2net_v2_led_pins[] = {
  118. {
  119. .name = "d2net_v2:blue:sata",
  120. .cmd = D2NET_V2_GPIO_BLUE_LED_CMD,
  121. .slow = D2NET_V2_GPIO_BLUE_LED_SLOW,
  122. },
  123. };
  124. static struct ns2_led_platform_data d2net_v2_leds_data = {
  125. .num_leds = ARRAY_SIZE(d2net_v2_led_pins),
  126. .leds = d2net_v2_led_pins,
  127. };
  128. static struct platform_device d2net_v2_leds = {
  129. .name = "leds-ns2",
  130. .id = -1,
  131. .dev = {
  132. .platform_data = &d2net_v2_leds_data,
  133. },
  134. };
  135. /*****************************************************************************
  136. * General Setup
  137. ****************************************************************************/
  138. static unsigned int d2net_v2_mpp_config[] __initdata = {
  139. MPP0_SPI_SCn,
  140. MPP1_SPI_MOSI,
  141. MPP2_SPI_SCK,
  142. MPP3_SPI_MISO,
  143. MPP6_SYSRST_OUTn,
  144. MPP7_GPO, /* Request power-off */
  145. MPP8_TW0_SDA,
  146. MPP9_TW0_SCK,
  147. MPP10_UART0_TXD,
  148. MPP11_UART0_RXD,
  149. MPP12_GPO, /* Red led */
  150. MPP13_GPIO, /* Rear power switch (on|auto) */
  151. MPP14_GPIO, /* USB fuse */
  152. MPP15_GPIO, /* Rear power switch (auto|off) */
  153. MPP16_GPIO, /* SATA 0 power */
  154. MPP21_SATA0_ACTn,
  155. MPP24_GPIO, /* USB mode select */
  156. MPP26_GPIO, /* USB device vbus */
  157. MPP28_GPIO, /* USB enable host vbus */
  158. MPP29_GPIO, /* Blue led (slow register) */
  159. MPP30_GPIO, /* Blue led (command register) */
  160. MPP34_GPIO, /* Power button (1 = Released, 0 = Pushed) */
  161. MPP35_GPIO, /* Inhibit power-off */
  162. 0
  163. };
  164. #define D2NET_V2_GPIO_POWER_OFF 7
  165. static void d2net_v2_power_off(void)
  166. {
  167. gpio_set_value(D2NET_V2_GPIO_POWER_OFF, 1);
  168. }
  169. static void __init d2net_v2_init(void)
  170. {
  171. /*
  172. * Basic setup. Needs to be called early.
  173. */
  174. kirkwood_init();
  175. kirkwood_mpp_conf(d2net_v2_mpp_config);
  176. lacie_v2_hdd_power_init(1);
  177. kirkwood_ehci_init();
  178. kirkwood_ge00_init(&d2net_v2_ge00_data);
  179. kirkwood_sata_init(&d2net_v2_sata_data);
  180. kirkwood_uart0_init();
  181. lacie_v2_register_flash();
  182. lacie_v2_register_i2c_devices();
  183. platform_device_register(&d2net_v2_leds);
  184. platform_device_register(&d2net_v2_gpio_leds);
  185. platform_device_register(&d2net_v2_gpio_buttons);
  186. if (gpio_request(D2NET_V2_GPIO_POWER_OFF, "power-off") == 0 &&
  187. gpio_direction_output(D2NET_V2_GPIO_POWER_OFF, 0) == 0)
  188. pm_power_off = d2net_v2_power_off;
  189. else
  190. pr_err("d2net_v2: failed to configure power-off GPIO\n");
  191. }
  192. MACHINE_START(D2NET_V2, "LaCie d2 Network v2")
  193. .atag_offset = 0x100,
  194. .init_machine = d2net_v2_init,
  195. .map_io = kirkwood_map_io,
  196. .init_early = kirkwood_init_early,
  197. .init_irq = kirkwood_init_irq,
  198. .timer = &kirkwood_timer,
  199. .restart = kirkwood_restart,
  200. MACHINE_END