mss2-setup.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. /*
  2. * Maxtor Shared Storage II Board Setup
  3. *
  4. * Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/pci.h>
  15. #include <linux/irq.h>
  16. #include <linux/mtd/physmap.h>
  17. #include <linux/mv643xx_eth.h>
  18. #include <linux/leds.h>
  19. #include <linux/gpio_keys.h>
  20. #include <linux/input.h>
  21. #include <linux/i2c.h>
  22. #include <linux/ata_platform.h>
  23. #include <linux/gpio.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/pci.h>
  27. #include <mach/orion5x.h>
  28. #include <mach/bridge-regs.h>
  29. #include "common.h"
  30. #include "mpp.h"
  31. #define MSS2_NOR_BOOT_BASE 0xff800000
  32. #define MSS2_NOR_BOOT_SIZE SZ_256K
  33. /*****************************************************************************
  34. * Maxtor Shared Storage II Info
  35. ****************************************************************************/
  36. /*
  37. * Maxtor Shared Storage II hardware :
  38. * - Marvell 88F5182-A2 C500
  39. * - Marvell 88E1111 Gigabit Ethernet PHY
  40. * - RTC M41T81 (@0x68) on I2C bus
  41. * - 256KB NOR flash
  42. * - 64MB of RAM
  43. */
  44. /*****************************************************************************
  45. * 256KB NOR Flash on BOOT Device
  46. ****************************************************************************/
  47. static struct physmap_flash_data mss2_nor_flash_data = {
  48. .width = 1,
  49. };
  50. static struct resource mss2_nor_flash_resource = {
  51. .flags = IORESOURCE_MEM,
  52. .start = MSS2_NOR_BOOT_BASE,
  53. .end = MSS2_NOR_BOOT_BASE + MSS2_NOR_BOOT_SIZE - 1,
  54. };
  55. static struct platform_device mss2_nor_flash = {
  56. .name = "physmap-flash",
  57. .id = 0,
  58. .dev = {
  59. .platform_data = &mss2_nor_flash_data,
  60. },
  61. .resource = &mss2_nor_flash_resource,
  62. .num_resources = 1,
  63. };
  64. /****************************************************************************
  65. * PCI setup
  66. ****************************************************************************/
  67. static int __init mss2_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  68. {
  69. int irq;
  70. /*
  71. * Check for devices with hard-wired IRQs.
  72. */
  73. irq = orion5x_pci_map_irq(dev, slot, pin);
  74. if (irq != -1)
  75. return irq;
  76. return -1;
  77. }
  78. static struct hw_pci mss2_pci __initdata = {
  79. .nr_controllers = 2,
  80. .setup = orion5x_pci_sys_setup,
  81. .scan = orion5x_pci_sys_scan_bus,
  82. .map_irq = mss2_pci_map_irq,
  83. };
  84. static int __init mss2_pci_init(void)
  85. {
  86. if (machine_is_mss2())
  87. pci_common_init(&mss2_pci);
  88. return 0;
  89. }
  90. subsys_initcall(mss2_pci_init);
  91. /*****************************************************************************
  92. * Ethernet
  93. ****************************************************************************/
  94. static struct mv643xx_eth_platform_data mss2_eth_data = {
  95. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  96. };
  97. /*****************************************************************************
  98. * SATA
  99. ****************************************************************************/
  100. static struct mv_sata_platform_data mss2_sata_data = {
  101. .n_ports = 2,
  102. };
  103. /*****************************************************************************
  104. * GPIO buttons
  105. ****************************************************************************/
  106. #define MSS2_GPIO_KEY_RESET 12
  107. #define MSS2_GPIO_KEY_POWER 11
  108. static struct gpio_keys_button mss2_buttons[] = {
  109. {
  110. .code = KEY_POWER,
  111. .gpio = MSS2_GPIO_KEY_POWER,
  112. .desc = "Power",
  113. .active_low = 1,
  114. }, {
  115. .code = KEY_RESTART,
  116. .gpio = MSS2_GPIO_KEY_RESET,
  117. .desc = "Reset",
  118. .active_low = 1,
  119. },
  120. };
  121. static struct gpio_keys_platform_data mss2_button_data = {
  122. .buttons = mss2_buttons,
  123. .nbuttons = ARRAY_SIZE(mss2_buttons),
  124. };
  125. static struct platform_device mss2_button_device = {
  126. .name = "gpio-keys",
  127. .id = -1,
  128. .dev = {
  129. .platform_data = &mss2_button_data,
  130. },
  131. };
  132. /*****************************************************************************
  133. * RTC m41t81 on I2C bus
  134. ****************************************************************************/
  135. #define MSS2_GPIO_RTC_IRQ 3
  136. static struct i2c_board_info __initdata mss2_i2c_rtc = {
  137. I2C_BOARD_INFO("m41t81", 0x68),
  138. };
  139. /*****************************************************************************
  140. * MSS2 power off method
  141. ****************************************************************************/
  142. /*
  143. * On the Maxtor Shared Storage II, the shutdown process is the following :
  144. * - Userland modifies U-boot env to tell U-boot to go idle at next boot
  145. * - The board reboots
  146. * - U-boot starts and go into an idle mode until the user press "power"
  147. */
  148. static void mss2_power_off(void)
  149. {
  150. u32 reg;
  151. /*
  152. * Enable and issue soft reset
  153. */
  154. reg = readl(RSTOUTn_MASK);
  155. reg |= 1 << 2;
  156. writel(reg, RSTOUTn_MASK);
  157. reg = readl(CPU_SOFT_RESET);
  158. reg |= 1;
  159. writel(reg, CPU_SOFT_RESET);
  160. }
  161. /****************************************************************************
  162. * General Setup
  163. ****************************************************************************/
  164. static unsigned int mss2_mpp_modes[] __initdata = {
  165. MPP0_GPIO, /* Power LED */
  166. MPP1_GPIO, /* Error LED */
  167. MPP2_UNUSED,
  168. MPP3_GPIO, /* RTC interrupt */
  169. MPP4_GPIO, /* HDD ind. (Single/Dual)*/
  170. MPP5_GPIO, /* HD0 5V control */
  171. MPP6_GPIO, /* HD0 12V control */
  172. MPP7_GPIO, /* HD1 5V control */
  173. MPP8_GPIO, /* HD1 12V control */
  174. MPP9_UNUSED,
  175. MPP10_GPIO, /* Fan control */
  176. MPP11_GPIO, /* Power button */
  177. MPP12_GPIO, /* Reset button */
  178. MPP13_UNUSED,
  179. MPP14_SATA_LED, /* SATA 0 active */
  180. MPP15_SATA_LED, /* SATA 1 active */
  181. MPP16_UNUSED,
  182. MPP17_UNUSED,
  183. MPP18_UNUSED,
  184. MPP19_UNUSED,
  185. 0,
  186. };
  187. static void __init mss2_init(void)
  188. {
  189. /* Setup basic Orion functions. Need to be called early. */
  190. orion5x_init();
  191. orion5x_mpp_conf(mss2_mpp_modes);
  192. /*
  193. * MPP[20] Unused
  194. * MPP[21] PCI clock
  195. * MPP[22] USB 0 over current
  196. * MPP[23] USB 1 over current
  197. */
  198. /*
  199. * Configure peripherals.
  200. */
  201. orion5x_ehci0_init();
  202. orion5x_ehci1_init();
  203. orion5x_eth_init(&mss2_eth_data);
  204. orion5x_i2c_init();
  205. orion5x_sata_init(&mss2_sata_data);
  206. orion5x_uart0_init();
  207. orion5x_xor_init();
  208. orion5x_setup_dev_boot_win(MSS2_NOR_BOOT_BASE, MSS2_NOR_BOOT_SIZE);
  209. platform_device_register(&mss2_nor_flash);
  210. platform_device_register(&mss2_button_device);
  211. if (gpio_request(MSS2_GPIO_RTC_IRQ, "rtc") == 0) {
  212. if (gpio_direction_input(MSS2_GPIO_RTC_IRQ) == 0)
  213. mss2_i2c_rtc.irq = gpio_to_irq(MSS2_GPIO_RTC_IRQ);
  214. else
  215. gpio_free(MSS2_GPIO_RTC_IRQ);
  216. }
  217. i2c_register_board_info(0, &mss2_i2c_rtc, 1);
  218. /* register mss2 specific power-off method */
  219. pm_power_off = mss2_power_off;
  220. }
  221. MACHINE_START(MSS2, "Maxtor Shared Storage II")
  222. /* Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com> */
  223. .atag_offset = 0x100,
  224. .init_machine = mss2_init,
  225. .map_io = orion5x_map_io,
  226. .init_early = orion5x_init_early,
  227. .init_irq = orion5x_init_irq,
  228. .timer = &orion5x_timer,
  229. .fixup = tag_fixup_mem32,
  230. .restart = orion5x_restart,
  231. MACHINE_END