netspace_v2-setup.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <mach/kirkwood.h>
  35. #include <mach/leds-ns2.h>
  36. #include "common.h"
  37. #include "mpp.h"
  38. #include "lacie_v2-common.h"
  39. /*****************************************************************************
  40. * Ethernet
  41. ****************************************************************************/
  42. static struct mv643xx_eth_platform_data netspace_v2_ge00_data = {
  43. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  44. };
  45. /*****************************************************************************
  46. * SATA
  47. ****************************************************************************/
  48. static struct mv_sata_platform_data netspace_v2_sata_data = {
  49. .n_ports = 2,
  50. };
  51. /*****************************************************************************
  52. * GPIO keys
  53. ****************************************************************************/
  54. #define NETSPACE_V2_PUSH_BUTTON 32
  55. static struct gpio_keys_button netspace_v2_buttons[] = {
  56. [0] = {
  57. .code = KEY_POWER,
  58. .gpio = NETSPACE_V2_PUSH_BUTTON,
  59. .desc = "Power push button",
  60. .active_low = 0,
  61. },
  62. };
  63. static struct gpio_keys_platform_data netspace_v2_button_data = {
  64. .buttons = netspace_v2_buttons,
  65. .nbuttons = ARRAY_SIZE(netspace_v2_buttons),
  66. };
  67. static struct platform_device netspace_v2_gpio_buttons = {
  68. .name = "gpio-keys",
  69. .id = -1,
  70. .dev = {
  71. .platform_data = &netspace_v2_button_data,
  72. },
  73. };
  74. /*****************************************************************************
  75. * GPIO LEDs
  76. ****************************************************************************/
  77. #define NETSPACE_V2_GPIO_RED_LED 12
  78. static struct gpio_led netspace_v2_gpio_led_pins[] = {
  79. {
  80. .name = "ns_v2:red:fail",
  81. .gpio = NETSPACE_V2_GPIO_RED_LED,
  82. },
  83. };
  84. static struct gpio_led_platform_data netspace_v2_gpio_leds_data = {
  85. .num_leds = ARRAY_SIZE(netspace_v2_gpio_led_pins),
  86. .leds = netspace_v2_gpio_led_pins,
  87. };
  88. static struct platform_device netspace_v2_gpio_leds = {
  89. .name = "leds-gpio",
  90. .id = -1,
  91. .dev = {
  92. .platform_data = &netspace_v2_gpio_leds_data,
  93. },
  94. };
  95. /*****************************************************************************
  96. * Dual-GPIO CPLD LEDs
  97. ****************************************************************************/
  98. #define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29
  99. #define NETSPACE_V2_GPIO_BLUE_LED_CMD 30
  100. static struct ns2_led netspace_v2_led_pins[] = {
  101. {
  102. .name = "ns_v2:blue:sata",
  103. .cmd = NETSPACE_V2_GPIO_BLUE_LED_CMD,
  104. .slow = NETSPACE_V2_GPIO_BLUE_LED_SLOW,
  105. },
  106. };
  107. static struct ns2_led_platform_data netspace_v2_leds_data = {
  108. .num_leds = ARRAY_SIZE(netspace_v2_led_pins),
  109. .leds = netspace_v2_led_pins,
  110. };
  111. static struct platform_device netspace_v2_leds = {
  112. .name = "leds-ns2",
  113. .id = -1,
  114. .dev = {
  115. .platform_data = &netspace_v2_leds_data,
  116. },
  117. };
  118. /*****************************************************************************
  119. * General Setup
  120. ****************************************************************************/
  121. static unsigned int netspace_v2_mpp_config[] __initdata = {
  122. MPP0_SPI_SCn,
  123. MPP1_SPI_MOSI,
  124. MPP2_SPI_SCK,
  125. MPP3_SPI_MISO,
  126. MPP4_NF_IO6,
  127. MPP5_NF_IO7,
  128. MPP6_SYSRST_OUTn,
  129. MPP7_GPO, /* Fan speed (bit 1) */
  130. MPP8_TW0_SDA,
  131. MPP9_TW0_SCK,
  132. MPP10_UART0_TXD,
  133. MPP11_UART0_RXD,
  134. MPP12_GPO, /* Red led */
  135. MPP14_GPIO, /* USB fuse */
  136. MPP16_GPIO, /* SATA 0 power */
  137. MPP17_GPIO, /* SATA 1 power */
  138. MPP18_NF_IO0,
  139. MPP19_NF_IO1,
  140. MPP20_SATA1_ACTn,
  141. MPP21_SATA0_ACTn,
  142. MPP22_GPIO, /* Fan speed (bit 0) */
  143. MPP23_GPIO, /* Fan power */
  144. MPP24_GPIO, /* USB mode select */
  145. MPP25_GPIO, /* Fan rotation fail */
  146. MPP26_GPIO, /* USB device vbus */
  147. MPP28_GPIO, /* USB enable host vbus */
  148. MPP29_GPIO, /* Blue led (slow register) */
  149. MPP30_GPIO, /* Blue led (command register) */
  150. MPP31_GPIO, /* Board power off */
  151. MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */
  152. MPP33_GPO, /* Fan speed (bit 2) */
  153. 0
  154. };
  155. #define NETSPACE_V2_GPIO_POWER_OFF 31
  156. static void netspace_v2_power_off(void)
  157. {
  158. gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1);
  159. }
  160. static void __init netspace_v2_init(void)
  161. {
  162. /*
  163. * Basic setup. Needs to be called early.
  164. */
  165. kirkwood_init();
  166. kirkwood_mpp_conf(netspace_v2_mpp_config);
  167. if (machine_is_netspace_max_v2())
  168. lacie_v2_hdd_power_init(2);
  169. else
  170. lacie_v2_hdd_power_init(1);
  171. kirkwood_ehci_init();
  172. kirkwood_ge00_init(&netspace_v2_ge00_data);
  173. kirkwood_sata_init(&netspace_v2_sata_data);
  174. kirkwood_uart0_init();
  175. lacie_v2_register_flash();
  176. lacie_v2_register_i2c_devices();
  177. platform_device_register(&netspace_v2_leds);
  178. platform_device_register(&netspace_v2_gpio_leds);
  179. platform_device_register(&netspace_v2_gpio_buttons);
  180. if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 &&
  181. gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0)
  182. pm_power_off = netspace_v2_power_off;
  183. else
  184. pr_err("netspace_v2: failed to configure power-off GPIO\n");
  185. }
  186. #ifdef CONFIG_MACH_NETSPACE_V2
  187. MACHINE_START(NETSPACE_V2, "LaCie Network Space v2")
  188. .phys_io = KIRKWOOD_REGS_PHYS_BASE,
  189. .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
  190. .boot_params = 0x00000100,
  191. .init_machine = netspace_v2_init,
  192. .map_io = kirkwood_map_io,
  193. .init_irq = kirkwood_init_irq,
  194. .timer = &lacie_v2_timer,
  195. MACHINE_END
  196. #endif
  197. #ifdef CONFIG_MACH_INETSPACE_V2
  198. MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2")
  199. .phys_io = KIRKWOOD_REGS_PHYS_BASE,
  200. .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
  201. .boot_params = 0x00000100,
  202. .init_machine = netspace_v2_init,
  203. .map_io = kirkwood_map_io,
  204. .init_irq = kirkwood_init_irq,
  205. .timer = &lacie_v2_timer,
  206. MACHINE_END
  207. #endif
  208. #ifdef CONFIG_MACH_NETSPACE_MAX_V2
  209. MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2")
  210. .phys_io = KIRKWOOD_REGS_PHYS_BASE,
  211. .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
  212. .boot_params = 0x00000100,
  213. .init_machine = netspace_v2_init,
  214. .map_io = kirkwood_map_io,
  215. .init_irq = kirkwood_init_irq,
  216. .timer = &lacie_v2_timer,
  217. MACHINE_END
  218. #endif