netspace_v2-setup.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /*
  2. * arch/arm/mach-kirkwood/netspace_v2-setup.c
  3. *
  4. * LaCie Network Space v2 board setup
  5. *
  6. * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com>
  7. * Copyright (C) 2009 Benoît Canet <benoit.canet@gmail.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include <linux/kernel.h>
  24. #include <linux/init.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/ata_platform.h>
  27. #include <linux/mv643xx_eth.h>
  28. #include <linux/input.h>
  29. #include <linux/gpio.h>
  30. #include <linux/gpio_keys.h>
  31. #include <linux/leds.h>
  32. #include <linux/gpio-fan.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <mach/kirkwood.h>
  36. #include <mach/leds-ns2.h>
  37. #include "common.h"
  38. #include "mpp.h"
  39. #include "lacie_v2-common.h"
  40. /*****************************************************************************
  41. * Ethernet
  42. ****************************************************************************/
  43. static struct mv643xx_eth_platform_data netspace_v2_ge00_data = {
  44. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  45. };
  46. /*****************************************************************************
  47. * SATA
  48. ****************************************************************************/
  49. static struct mv_sata_platform_data netspace_v2_sata_data = {
  50. .n_ports = 2,
  51. };
  52. /*****************************************************************************
  53. * GPIO keys
  54. ****************************************************************************/
  55. #define NETSPACE_V2_PUSH_BUTTON 32
  56. static struct gpio_keys_button netspace_v2_buttons[] = {
  57. [0] = {
  58. .code = KEY_POWER,
  59. .gpio = NETSPACE_V2_PUSH_BUTTON,
  60. .desc = "Power push button",
  61. .active_low = 0,
  62. },
  63. };
  64. static struct gpio_keys_platform_data netspace_v2_button_data = {
  65. .buttons = netspace_v2_buttons,
  66. .nbuttons = ARRAY_SIZE(netspace_v2_buttons),
  67. };
  68. static struct platform_device netspace_v2_gpio_buttons = {
  69. .name = "gpio-keys",
  70. .id = -1,
  71. .dev = {
  72. .platform_data = &netspace_v2_button_data,
  73. },
  74. };
  75. /*****************************************************************************
  76. * GPIO LEDs
  77. ****************************************************************************/
  78. #define NETSPACE_V2_GPIO_RED_LED 12
  79. static struct gpio_led netspace_v2_gpio_led_pins[] = {
  80. {
  81. .name = "ns_v2:red:fail",
  82. .gpio = NETSPACE_V2_GPIO_RED_LED,
  83. },
  84. };
  85. static struct gpio_led_platform_data netspace_v2_gpio_leds_data = {
  86. .num_leds = ARRAY_SIZE(netspace_v2_gpio_led_pins),
  87. .leds = netspace_v2_gpio_led_pins,
  88. };
  89. static struct platform_device netspace_v2_gpio_leds = {
  90. .name = "leds-gpio",
  91. .id = -1,
  92. .dev = {
  93. .platform_data = &netspace_v2_gpio_leds_data,
  94. },
  95. };
  96. /*****************************************************************************
  97. * Dual-GPIO CPLD LEDs
  98. ****************************************************************************/
  99. #define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29
  100. #define NETSPACE_V2_GPIO_BLUE_LED_CMD 30
  101. static struct ns2_led netspace_v2_led_pins[] = {
  102. {
  103. .name = "ns_v2:blue:sata",
  104. .cmd = NETSPACE_V2_GPIO_BLUE_LED_CMD,
  105. .slow = NETSPACE_V2_GPIO_BLUE_LED_SLOW,
  106. },
  107. };
  108. static struct ns2_led_platform_data netspace_v2_leds_data = {
  109. .num_leds = ARRAY_SIZE(netspace_v2_led_pins),
  110. .leds = netspace_v2_led_pins,
  111. };
  112. static struct platform_device netspace_v2_leds = {
  113. .name = "leds-ns2",
  114. .id = -1,
  115. .dev = {
  116. .platform_data = &netspace_v2_leds_data,
  117. },
  118. };
  119. /*****************************************************************************
  120. * GPIO fan
  121. ****************************************************************************/
  122. /* Designed for fan 40x40x16: ADDA AD0412LB-D50 6000rpm@12v */
  123. static struct gpio_fan_speed netspace_max_v2_fan_speed[] = {
  124. { 0, 0 },
  125. { 1500, 15 },
  126. { 1700, 14 },
  127. { 1800, 13 },
  128. { 2100, 12 },
  129. { 3100, 11 },
  130. { 3300, 10 },
  131. { 4300, 9 },
  132. { 5500, 8 },
  133. };
  134. static unsigned netspace_max_v2_fan_ctrl[] = { 22, 7, 33, 23 };
  135. static struct gpio_fan_alarm netspace_max_v2_fan_alarm = {
  136. .gpio = 25,
  137. .active_low = 1,
  138. };
  139. static struct gpio_fan_platform_data netspace_max_v2_fan_data = {
  140. .num_ctrl = ARRAY_SIZE(netspace_max_v2_fan_ctrl),
  141. .ctrl = netspace_max_v2_fan_ctrl,
  142. .alarm = &netspace_max_v2_fan_alarm,
  143. .num_speed = ARRAY_SIZE(netspace_max_v2_fan_speed),
  144. .speed = netspace_max_v2_fan_speed,
  145. };
  146. static struct platform_device netspace_max_v2_gpio_fan = {
  147. .name = "gpio-fan",
  148. .id = -1,
  149. .dev = {
  150. .platform_data = &netspace_max_v2_fan_data,
  151. },
  152. };
  153. /*****************************************************************************
  154. * General Setup
  155. ****************************************************************************/
  156. static unsigned int netspace_v2_mpp_config[] __initdata = {
  157. MPP0_SPI_SCn,
  158. MPP1_SPI_MOSI,
  159. MPP2_SPI_SCK,
  160. MPP3_SPI_MISO,
  161. MPP4_NF_IO6,
  162. MPP5_NF_IO7,
  163. MPP6_SYSRST_OUTn,
  164. MPP7_GPO, /* Fan speed (bit 1) */
  165. MPP8_TW0_SDA,
  166. MPP9_TW0_SCK,
  167. MPP10_UART0_TXD,
  168. MPP11_UART0_RXD,
  169. MPP12_GPO, /* Red led */
  170. MPP14_GPIO, /* USB fuse */
  171. MPP16_GPIO, /* SATA 0 power */
  172. MPP17_GPIO, /* SATA 1 power */
  173. MPP18_NF_IO0,
  174. MPP19_NF_IO1,
  175. MPP20_SATA1_ACTn,
  176. MPP21_SATA0_ACTn,
  177. MPP22_GPIO, /* Fan speed (bit 0) */
  178. MPP23_GPIO, /* Fan power */
  179. MPP24_GPIO, /* USB mode select */
  180. MPP25_GPIO, /* Fan rotation fail */
  181. MPP26_GPIO, /* USB device vbus */
  182. MPP28_GPIO, /* USB enable host vbus */
  183. MPP29_GPIO, /* Blue led (slow register) */
  184. MPP30_GPIO, /* Blue led (command register) */
  185. MPP31_GPIO, /* Board power off */
  186. MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */
  187. MPP33_GPO, /* Fan speed (bit 2) */
  188. 0
  189. };
  190. #define NETSPACE_V2_GPIO_POWER_OFF 31
  191. static void netspace_v2_power_off(void)
  192. {
  193. gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1);
  194. }
  195. static void __init netspace_v2_init(void)
  196. {
  197. /*
  198. * Basic setup. Needs to be called early.
  199. */
  200. kirkwood_init();
  201. kirkwood_mpp_conf(netspace_v2_mpp_config);
  202. if (machine_is_netspace_max_v2())
  203. lacie_v2_hdd_power_init(2);
  204. else
  205. lacie_v2_hdd_power_init(1);
  206. kirkwood_ehci_init();
  207. kirkwood_ge00_init(&netspace_v2_ge00_data);
  208. kirkwood_sata_init(&netspace_v2_sata_data);
  209. kirkwood_uart0_init();
  210. lacie_v2_register_flash();
  211. lacie_v2_register_i2c_devices();
  212. platform_device_register(&netspace_v2_leds);
  213. platform_device_register(&netspace_v2_gpio_leds);
  214. platform_device_register(&netspace_v2_gpio_buttons);
  215. if (machine_is_netspace_max_v2())
  216. platform_device_register(&netspace_max_v2_gpio_fan);
  217. if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 &&
  218. gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0)
  219. pm_power_off = netspace_v2_power_off;
  220. else
  221. pr_err("netspace_v2: failed to configure power-off GPIO\n");
  222. }
  223. #ifdef CONFIG_MACH_NETSPACE_V2
  224. MACHINE_START(NETSPACE_V2, "LaCie Network Space v2")
  225. .atag_offset = 0x100,
  226. .init_machine = netspace_v2_init,
  227. .map_io = kirkwood_map_io,
  228. .init_early = kirkwood_init_early,
  229. .init_irq = kirkwood_init_irq,
  230. .timer = &kirkwood_timer,
  231. .restart = kirkwood_restart,
  232. MACHINE_END
  233. #endif
  234. #ifdef CONFIG_MACH_INETSPACE_V2
  235. MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2")
  236. .atag_offset = 0x100,
  237. .init_machine = netspace_v2_init,
  238. .map_io = kirkwood_map_io,
  239. .init_early = kirkwood_init_early,
  240. .init_irq = kirkwood_init_irq,
  241. .timer = &kirkwood_timer,
  242. .restart = kirkwood_restart,
  243. MACHINE_END
  244. #endif
  245. #ifdef CONFIG_MACH_NETSPACE_MAX_V2
  246. MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2")
  247. .atag_offset = 0x100,
  248. .init_machine = netspace_v2_init,
  249. .map_io = kirkwood_map_io,
  250. .init_early = kirkwood_init_early,
  251. .init_irq = kirkwood_init_irq,
  252. .timer = &kirkwood_timer,
  253. .restart = kirkwood_restart,
  254. MACHINE_END
  255. #endif