netxbig_v2-setup.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. /*
  2. * arch/arm/mach-kirkwood/netxbig_v2-setup.c
  3. *
  4. * LaCie 2Big and 5Big Network 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/mtd/physmap.h>
  26. #include <linux/spi/flash.h>
  27. #include <linux/spi/spi.h>
  28. #include <linux/ata_platform.h>
  29. #include <linux/mv643xx_eth.h>
  30. #include <linux/i2c.h>
  31. #include <linux/i2c/at24.h>
  32. #include <linux/input.h>
  33. #include <linux/gpio.h>
  34. #include <linux/gpio_keys.h>
  35. #include <linux/leds.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach/time.h>
  39. #include <mach/kirkwood.h>
  40. #include <plat/time.h>
  41. #include "common.h"
  42. #include "mpp.h"
  43. /*****************************************************************************
  44. * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
  45. ****************************************************************************/
  46. static struct mtd_partition netxbig_v2_flash_parts[] = {
  47. {
  48. .name = "u-boot",
  49. .size = MTDPART_SIZ_FULL,
  50. .offset = 0,
  51. .mask_flags = MTD_WRITEABLE, /* force read-only */
  52. },
  53. };
  54. static const struct flash_platform_data netxbig_v2_flash = {
  55. .type = "mx25l4005a",
  56. .name = "spi_flash",
  57. .parts = netxbig_v2_flash_parts,
  58. .nr_parts = ARRAY_SIZE(netxbig_v2_flash_parts),
  59. };
  60. static struct spi_board_info __initdata netxbig_v2_spi_slave_info[] = {
  61. {
  62. .modalias = "m25p80",
  63. .platform_data = &netxbig_v2_flash,
  64. .irq = -1,
  65. .max_speed_hz = 20000000,
  66. .bus_num = 0,
  67. .chip_select = 0,
  68. },
  69. };
  70. /*****************************************************************************
  71. * Ethernet
  72. ****************************************************************************/
  73. static struct mv643xx_eth_platform_data netxbig_v2_ge00_data = {
  74. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  75. };
  76. static struct mv643xx_eth_platform_data netxbig_v2_ge01_data = {
  77. .phy_addr = MV643XX_ETH_PHY_ADDR(0),
  78. };
  79. /*****************************************************************************
  80. * I2C devices
  81. ****************************************************************************/
  82. static struct at24_platform_data at24c04 = {
  83. .byte_len = SZ_4K / 8,
  84. .page_size = 16,
  85. };
  86. /*
  87. * i2c addr | chip | description
  88. * 0x50 | HT24LC04 | eeprom (512B)
  89. */
  90. static struct i2c_board_info __initdata netxbig_v2_i2c_info[] = {
  91. {
  92. I2C_BOARD_INFO("24c04", 0x50),
  93. .platform_data = &at24c04,
  94. }
  95. };
  96. /*****************************************************************************
  97. * SATA
  98. ****************************************************************************/
  99. static struct mv_sata_platform_data netxbig_v2_sata_data = {
  100. .n_ports = 2,
  101. };
  102. static int __initdata netxbig_v2_gpio_hdd_power[] = { 16, 17, 41, 42, 43 };
  103. static void __init netxbig_v2_sata_power_init(void)
  104. {
  105. int i;
  106. int err;
  107. int hdd_nb;
  108. if (machine_is_net2big_v2())
  109. hdd_nb = 2;
  110. else
  111. hdd_nb = 5;
  112. /* Power up all hard disks. */
  113. for (i = 0; i < hdd_nb; i++) {
  114. err = gpio_request(netxbig_v2_gpio_hdd_power[i], NULL);
  115. if (err == 0) {
  116. err = gpio_direction_output(
  117. netxbig_v2_gpio_hdd_power[i], 1);
  118. /* Free the HDD power GPIOs. This allow user-space to
  119. * configure them via the gpiolib sysfs interface. */
  120. gpio_free(netxbig_v2_gpio_hdd_power[i]);
  121. }
  122. if (err)
  123. pr_err("netxbig_v2: failed to power up HDD%d\n", i + 1);
  124. }
  125. }
  126. /*****************************************************************************
  127. * GPIO keys
  128. ****************************************************************************/
  129. #define NETXBIG_V2_GPIO_SWITCH_POWER_ON 13
  130. #define NETXBIG_V2_GPIO_SWITCH_POWER_OFF 15
  131. #define NETXBIG_V2_GPIO_FUNC_BUTTON 34
  132. #define NETXBIG_V2_SWITCH_POWER_ON 0x1
  133. #define NETXBIG_V2_SWITCH_POWER_OFF 0x2
  134. static struct gpio_keys_button netxbig_v2_buttons[] = {
  135. [0] = {
  136. .type = EV_SW,
  137. .code = NETXBIG_V2_SWITCH_POWER_ON,
  138. .gpio = NETXBIG_V2_GPIO_SWITCH_POWER_ON,
  139. .desc = "Back power switch (on|auto)",
  140. .active_low = 1,
  141. },
  142. [1] = {
  143. .type = EV_SW,
  144. .code = NETXBIG_V2_SWITCH_POWER_OFF,
  145. .gpio = NETXBIG_V2_GPIO_SWITCH_POWER_OFF,
  146. .desc = "Back power switch (auto|off)",
  147. .active_low = 1,
  148. },
  149. [2] = {
  150. .code = KEY_OPTION,
  151. .gpio = NETXBIG_V2_GPIO_FUNC_BUTTON,
  152. .desc = "Function button",
  153. .active_low = 1,
  154. },
  155. };
  156. static struct gpio_keys_platform_data netxbig_v2_button_data = {
  157. .buttons = netxbig_v2_buttons,
  158. .nbuttons = ARRAY_SIZE(netxbig_v2_buttons),
  159. };
  160. static struct platform_device netxbig_v2_gpio_buttons = {
  161. .name = "gpio-keys",
  162. .id = -1,
  163. .dev = {
  164. .platform_data = &netxbig_v2_button_data,
  165. },
  166. };
  167. /*****************************************************************************
  168. * GPIO LEDs
  169. ****************************************************************************/
  170. /*
  171. * The LEDs are controlled by a CPLD and can be configured through a GPIO
  172. * extension bus:
  173. *
  174. * - address register : bit [0-2] -> GPIO [47-49]
  175. * - data register : bit [0-2] -> GPIO [44-46]
  176. * - enable register : GPIO 29
  177. *
  178. * Address register selection:
  179. *
  180. * addr | register
  181. * ----------------------------
  182. * 0 | front LED
  183. * 1 | front LED brightness
  184. * 2 | HDD LED brightness
  185. * 3 | HDD1 LED
  186. * 4 | HDD2 LED
  187. * 5 | HDD3 LED
  188. * 6 | HDD4 LED
  189. * 7 | HDD5 LED
  190. *
  191. * Data register configuration:
  192. *
  193. * data | LED brightness
  194. * -------------------------------------------------
  195. * 0 | min (off)
  196. * - | -
  197. * 7 | max
  198. *
  199. * data | front LED mode
  200. * -------------------------------------------------
  201. * 0 | fix off
  202. * 1 | fix blue on
  203. * 2 | fix red on
  204. * 3 | blink blue on=1 sec and blue off=1 sec
  205. * 4 | blink red on=1 sec and red off=1 sec
  206. * 5 | blink blue on=2.5 sec and red on=0.5 sec
  207. * 6 | blink blue on=1 sec and red on=1 sec
  208. * 7 | blink blue on=0.5 sec and blue off=2.5 sec
  209. *
  210. * data | HDD LED mode
  211. * -------------------------------------------------
  212. * 0 | fix blue on
  213. * 1 | SATA activity blink
  214. * 2 | fix red on
  215. * 3 | blink blue on=1 sec and blue off=1 sec
  216. * 4 | blink red on=1 sec and red off=1 sec
  217. * 5 | blink blue on=2.5 sec and red on=0.5 sec
  218. * 6 | blink blue on=1 sec and red on=1 sec
  219. * 7 | blink blue on=0.5 sec and blue off=2.5 sec
  220. */
  221. /*****************************************************************************
  222. * Timer
  223. ****************************************************************************/
  224. static void netxbig_v2_timer_init(void)
  225. {
  226. kirkwood_tclk = 166666667;
  227. orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
  228. }
  229. struct sys_timer netxbig_v2_timer = {
  230. .init = netxbig_v2_timer_init,
  231. };
  232. /*****************************************************************************
  233. * General Setup
  234. ****************************************************************************/
  235. static unsigned int net2big_v2_mpp_config[] __initdata = {
  236. MPP0_SPI_SCn,
  237. MPP1_SPI_MOSI,
  238. MPP2_SPI_SCK,
  239. MPP3_SPI_MISO,
  240. MPP6_SYSRST_OUTn,
  241. MPP7_GPO, /* Request power-off */
  242. MPP8_TW0_SDA,
  243. MPP9_TW0_SCK,
  244. MPP10_UART0_TXD,
  245. MPP11_UART0_RXD,
  246. MPP13_GPIO, /* Rear power switch (on|auto) */
  247. MPP14_GPIO, /* USB fuse alarm */
  248. MPP15_GPIO, /* Rear power switch (auto|off) */
  249. MPP16_GPIO, /* SATA HDD1 power */
  250. MPP17_GPIO, /* SATA HDD2 power */
  251. MPP20_SATA1_ACTn,
  252. MPP21_SATA0_ACTn,
  253. MPP24_GPIO, /* USB mode select */
  254. MPP26_GPIO, /* USB device vbus */
  255. MPP28_GPIO, /* USB enable host vbus */
  256. MPP29_GPIO, /* CPLD extension ALE */
  257. MPP34_GPIO, /* Rear Push button */
  258. MPP35_GPIO, /* Inhibit switch power-off */
  259. MPP36_GPIO, /* SATA HDD1 presence */
  260. MPP37_GPIO, /* SATA HDD2 presence */
  261. MPP40_GPIO, /* eSATA presence */
  262. MPP44_GPIO, /* CPLD extension (data 0) */
  263. MPP45_GPIO, /* CPLD extension (data 1) */
  264. MPP46_GPIO, /* CPLD extension (data 2) */
  265. MPP47_GPIO, /* CPLD extension (addr 0) */
  266. MPP48_GPIO, /* CPLD extension (addr 1) */
  267. MPP49_GPIO, /* CPLD extension (addr 2) */
  268. 0
  269. };
  270. static unsigned int net5big_v2_mpp_config[] __initdata = {
  271. MPP0_SPI_SCn,
  272. MPP1_SPI_MOSI,
  273. MPP2_SPI_SCK,
  274. MPP3_SPI_MISO,
  275. MPP6_SYSRST_OUTn,
  276. MPP7_GPO, /* Request power-off */
  277. MPP8_TW0_SDA,
  278. MPP9_TW0_SCK,
  279. MPP10_UART0_TXD,
  280. MPP11_UART0_RXD,
  281. MPP13_GPIO, /* Rear power switch (on|auto) */
  282. MPP14_GPIO, /* USB fuse alarm */
  283. MPP15_GPIO, /* Rear power switch (auto|off) */
  284. MPP16_GPIO, /* SATA HDD1 power */
  285. MPP17_GPIO, /* SATA HDD2 power */
  286. MPP20_GE1_TXD0,
  287. MPP21_GE1_TXD1,
  288. MPP22_GE1_TXD2,
  289. MPP23_GE1_TXD3,
  290. MPP24_GE1_RXD0,
  291. MPP25_GE1_RXD1,
  292. MPP26_GE1_RXD2,
  293. MPP27_GE1_RXD3,
  294. MPP28_GPIO, /* USB enable host vbus */
  295. MPP29_GPIO, /* CPLD extension ALE */
  296. MPP30_GE1_RXCTL,
  297. MPP31_GE1_RXCLK,
  298. MPP32_GE1_TCLKOUT,
  299. MPP33_GE1_TXCTL,
  300. MPP34_GPIO, /* Rear Push button */
  301. MPP35_GPIO, /* Inhibit switch power-off */
  302. MPP36_GPIO, /* SATA HDD1 presence */
  303. MPP37_GPIO, /* SATA HDD2 presence */
  304. MPP38_GPIO, /* SATA HDD3 presence */
  305. MPP39_GPIO, /* SATA HDD4 presence */
  306. MPP40_GPIO, /* SATA HDD5 presence */
  307. MPP41_GPIO, /* SATA HDD3 power */
  308. MPP42_GPIO, /* SATA HDD4 power */
  309. MPP43_GPIO, /* SATA HDD5 power */
  310. MPP44_GPIO, /* CPLD extension (data 0) */
  311. MPP45_GPIO, /* CPLD extension (data 1) */
  312. MPP46_GPIO, /* CPLD extension (data 2) */
  313. MPP47_GPIO, /* CPLD extension (addr 0) */
  314. MPP48_GPIO, /* CPLD extension (addr 1) */
  315. MPP49_GPIO, /* CPLD extension (addr 2) */
  316. 0
  317. };
  318. #define NETXBIG_V2_GPIO_POWER_OFF 7
  319. static void netxbig_v2_power_off(void)
  320. {
  321. gpio_set_value(NETXBIG_V2_GPIO_POWER_OFF, 1);
  322. }
  323. static void __init netxbig_v2_init(void)
  324. {
  325. /*
  326. * Basic setup. Needs to be called early.
  327. */
  328. kirkwood_init();
  329. if (machine_is_net2big_v2())
  330. kirkwood_mpp_conf(net2big_v2_mpp_config);
  331. else
  332. kirkwood_mpp_conf(net5big_v2_mpp_config);
  333. netxbig_v2_sata_power_init();
  334. kirkwood_ehci_init();
  335. kirkwood_ge00_init(&netxbig_v2_ge00_data);
  336. if (machine_is_net5big_v2())
  337. kirkwood_ge01_init(&netxbig_v2_ge01_data);
  338. kirkwood_sata_init(&netxbig_v2_sata_data);
  339. kirkwood_uart0_init();
  340. spi_register_board_info(netxbig_v2_spi_slave_info,
  341. ARRAY_SIZE(netxbig_v2_spi_slave_info));
  342. kirkwood_spi_init();
  343. kirkwood_i2c_init();
  344. i2c_register_board_info(0, netxbig_v2_i2c_info,
  345. ARRAY_SIZE(netxbig_v2_i2c_info));
  346. platform_device_register(&netxbig_v2_gpio_buttons);
  347. if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 &&
  348. gpio_direction_output(NETXBIG_V2_GPIO_POWER_OFF, 0) == 0)
  349. pm_power_off = netxbig_v2_power_off;
  350. else
  351. pr_err("netxbig_v2: failed to configure power-off GPIO\n");
  352. }
  353. #ifdef CONFIG_MACH_NET2BIG_V2
  354. MACHINE_START(NET2BIG_V2, "LaCie 2Big Network v2")
  355. .phys_io = KIRKWOOD_REGS_PHYS_BASE,
  356. .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
  357. .boot_params = 0x00000100,
  358. .init_machine = netxbig_v2_init,
  359. .map_io = kirkwood_map_io,
  360. .init_irq = kirkwood_init_irq,
  361. .timer = &netxbig_v2_timer,
  362. MACHINE_END
  363. #endif
  364. #ifdef CONFIG_MACH_NET5BIG_V2
  365. MACHINE_START(NET5BIG_V2, "LaCie 5Big Network v2")
  366. .phys_io = KIRKWOOD_REGS_PHYS_BASE,
  367. .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
  368. .boot_params = 0x00000100,
  369. .init_machine = netxbig_v2_init,
  370. .map_io = kirkwood_map_io,
  371. .init_irq = kirkwood_init_irq,
  372. .timer = &netxbig_v2_timer,
  373. MACHINE_END
  374. #endif