mss2-setup.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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(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. .swizzle = pci_std_swizzle,
  81. .setup = orion5x_pci_sys_setup,
  82. .scan = orion5x_pci_sys_scan_bus,
  83. .map_irq = mss2_pci_map_irq,
  84. };
  85. static int __init mss2_pci_init(void)
  86. {
  87. if (machine_is_mss2())
  88. pci_common_init(&mss2_pci);
  89. return 0;
  90. }
  91. subsys_initcall(mss2_pci_init);
  92. /*****************************************************************************
  93. * Ethernet
  94. ****************************************************************************/
  95. static struct mv643xx_eth_platform_data mss2_eth_data = {
  96. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  97. };
  98. /*****************************************************************************
  99. * SATA
  100. ****************************************************************************/
  101. static struct mv_sata_platform_data mss2_sata_data = {
  102. .n_ports = 2,
  103. };
  104. /*****************************************************************************
  105. * GPIO buttons
  106. ****************************************************************************/
  107. #define MSS2_GPIO_KEY_RESET 12
  108. #define MSS2_GPIO_KEY_POWER 11
  109. static struct gpio_keys_button mss2_buttons[] = {
  110. {
  111. .code = KEY_POWER,
  112. .gpio = MSS2_GPIO_KEY_POWER,
  113. .desc = "Power",
  114. .active_low = 1,
  115. }, {
  116. .code = KEY_RESTART,
  117. .gpio = MSS2_GPIO_KEY_RESET,
  118. .desc = "Reset",
  119. .active_low = 1,
  120. },
  121. };
  122. static struct gpio_keys_platform_data mss2_button_data = {
  123. .buttons = mss2_buttons,
  124. .nbuttons = ARRAY_SIZE(mss2_buttons),
  125. };
  126. static struct platform_device mss2_button_device = {
  127. .name = "gpio-keys",
  128. .id = -1,
  129. .dev = {
  130. .platform_data = &mss2_button_data,
  131. },
  132. };
  133. /*****************************************************************************
  134. * RTC m41t81 on I2C bus
  135. ****************************************************************************/
  136. #define MSS2_GPIO_RTC_IRQ 3
  137. static struct i2c_board_info __initdata mss2_i2c_rtc = {
  138. I2C_BOARD_INFO("m41t81", 0x68),
  139. };
  140. /*****************************************************************************
  141. * MSS2 power off method
  142. ****************************************************************************/
  143. /*
  144. * On the Maxtor Shared Storage II, the shutdown process is the following :
  145. * - Userland modifies U-boot env to tell U-boot to go idle at next boot
  146. * - The board reboots
  147. * - U-boot starts and go into an idle mode until the user press "power"
  148. */
  149. static void mss2_power_off(void)
  150. {
  151. u32 reg;
  152. /*
  153. * Enable and issue soft reset
  154. */
  155. reg = readl(RSTOUTn_MASK);
  156. reg |= 1 << 2;
  157. writel(reg, RSTOUTn_MASK);
  158. reg = readl(CPU_SOFT_RESET);
  159. reg |= 1;
  160. writel(reg, CPU_SOFT_RESET);
  161. }
  162. /****************************************************************************
  163. * General Setup
  164. ****************************************************************************/
  165. static struct orion5x_mpp_mode mss2_mpp_modes[] __initdata = {
  166. { 0, MPP_GPIO }, /* Power LED */
  167. { 1, MPP_GPIO }, /* Error LED */
  168. { 2, MPP_UNUSED },
  169. { 3, MPP_GPIO }, /* RTC interrupt */
  170. { 4, MPP_GPIO }, /* HDD ind. (Single/Dual)*/
  171. { 5, MPP_GPIO }, /* HD0 5V control */
  172. { 6, MPP_GPIO }, /* HD0 12V control */
  173. { 7, MPP_GPIO }, /* HD1 5V control */
  174. { 8, MPP_GPIO }, /* HD1 12V control */
  175. { 9, MPP_UNUSED },
  176. { 10, MPP_GPIO }, /* Fan control */
  177. { 11, MPP_GPIO }, /* Power button */
  178. { 12, MPP_GPIO }, /* Reset button */
  179. { 13, MPP_UNUSED },
  180. { 14, MPP_SATA_LED }, /* SATA 0 active */
  181. { 15, MPP_SATA_LED }, /* SATA 1 active */
  182. { 16, MPP_UNUSED },
  183. { 17, MPP_UNUSED },
  184. { 18, MPP_UNUSED },
  185. { 19, MPP_UNUSED },
  186. { -1 },
  187. };
  188. static void __init mss2_init(void)
  189. {
  190. /* Setup basic Orion functions. Need to be called early. */
  191. orion5x_init();
  192. orion5x_mpp_conf(mss2_mpp_modes);
  193. /*
  194. * MPP[20] Unused
  195. * MPP[21] PCI clock
  196. * MPP[22] USB 0 over current
  197. * MPP[23] USB 1 over current
  198. */
  199. /*
  200. * Configure peripherals.
  201. */
  202. orion5x_ehci0_init();
  203. orion5x_ehci1_init();
  204. orion5x_eth_init(&mss2_eth_data);
  205. orion5x_i2c_init();
  206. orion5x_sata_init(&mss2_sata_data);
  207. orion5x_uart0_init();
  208. orion5x_xor_init();
  209. orion5x_setup_dev_boot_win(MSS2_NOR_BOOT_BASE, MSS2_NOR_BOOT_SIZE);
  210. platform_device_register(&mss2_nor_flash);
  211. platform_device_register(&mss2_button_device);
  212. if (gpio_request(MSS2_GPIO_RTC_IRQ, "rtc") == 0) {
  213. if (gpio_direction_input(MSS2_GPIO_RTC_IRQ) == 0)
  214. mss2_i2c_rtc.irq = gpio_to_irq(MSS2_GPIO_RTC_IRQ);
  215. else
  216. gpio_free(MSS2_GPIO_RTC_IRQ);
  217. }
  218. i2c_register_board_info(0, &mss2_i2c_rtc, 1);
  219. /* register mss2 specific power-off method */
  220. pm_power_off = mss2_power_off;
  221. }
  222. MACHINE_START(MSS2, "Maxtor Shared Storage II")
  223. /* Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com> */
  224. .phys_io = ORION5X_REGS_PHYS_BASE,
  225. .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
  226. .boot_params = 0x00000100,
  227. .init_machine = mss2_init,
  228. .map_io = orion5x_map_io,
  229. .init_irq = orion5x_init_irq,
  230. .timer = &orion5x_timer,
  231. .fixup = tag_fixup_mem32
  232. MACHINE_END