mss2-setup.c 7.1 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 "common.h"
  29. #include "mpp.h"
  30. #define MSS2_NOR_BOOT_BASE 0xff800000
  31. #define MSS2_NOR_BOOT_SIZE SZ_256K
  32. /*****************************************************************************
  33. * Maxtor Shared Storage II Info
  34. ****************************************************************************/
  35. /*
  36. * Maxtor Shared Storage II hardware :
  37. * - Marvell 88F5182-A2 C500
  38. * - Marvell 88E1111 Gigabit Ethernet PHY
  39. * - RTC M41T81 (@0x68) on I2C bus
  40. * - 256KB NOR flash
  41. * - 64MB of RAM
  42. */
  43. /*****************************************************************************
  44. * 256KB NOR Flash on BOOT Device
  45. ****************************************************************************/
  46. static struct physmap_flash_data mss2_nor_flash_data = {
  47. .width = 1,
  48. };
  49. static struct resource mss2_nor_flash_resource = {
  50. .flags = IORESOURCE_MEM,
  51. .start = MSS2_NOR_BOOT_BASE,
  52. .end = MSS2_NOR_BOOT_BASE + MSS2_NOR_BOOT_SIZE - 1,
  53. };
  54. static struct platform_device mss2_nor_flash = {
  55. .name = "physmap-flash",
  56. .id = 0,
  57. .dev = {
  58. .platform_data = &mss2_nor_flash_data,
  59. },
  60. .resource = &mss2_nor_flash_resource,
  61. .num_resources = 1,
  62. };
  63. /****************************************************************************
  64. * PCI setup
  65. ****************************************************************************/
  66. static int __init mss2_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  67. {
  68. int irq;
  69. /*
  70. * Check for devices with hard-wired IRQs.
  71. */
  72. irq = orion5x_pci_map_irq(dev, slot, pin);
  73. if (irq != -1)
  74. return irq;
  75. return -1;
  76. }
  77. static struct hw_pci mss2_pci __initdata = {
  78. .nr_controllers = 2,
  79. .swizzle = pci_std_swizzle,
  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(CPU_RESET_MASK);
  155. reg |= 1 << 2;
  156. writel(reg, CPU_RESET_MASK);
  157. reg = readl(CPU_SOFT_RESET);
  158. reg |= 1;
  159. writel(reg, CPU_SOFT_RESET);
  160. }
  161. /****************************************************************************
  162. * General Setup
  163. ****************************************************************************/
  164. static struct orion5x_mpp_mode mss2_mpp_modes[] __initdata = {
  165. { 0, MPP_GPIO }, /* Power LED */
  166. { 1, MPP_GPIO }, /* Error LED */
  167. { 2, MPP_UNUSED },
  168. { 3, MPP_GPIO }, /* RTC interrupt */
  169. { 4, MPP_GPIO }, /* HDD ind. (Single/Dual)*/
  170. { 5, MPP_GPIO }, /* HD0 5V control */
  171. { 6, MPP_GPIO }, /* HD0 12V control */
  172. { 7, MPP_GPIO }, /* HD1 5V control */
  173. { 8, MPP_GPIO }, /* HD1 12V control */
  174. { 9, MPP_UNUSED },
  175. { 10, MPP_GPIO }, /* Fan control */
  176. { 11, MPP_GPIO }, /* Power button */
  177. { 12, MPP_GPIO }, /* Reset button */
  178. { 13, MPP_UNUSED },
  179. { 14, MPP_SATA_LED }, /* SATA 0 active */
  180. { 15, MPP_SATA_LED }, /* SATA 1 active */
  181. { 16, MPP_UNUSED },
  182. { 17, MPP_UNUSED },
  183. { 18, MPP_UNUSED },
  184. { 19, MPP_UNUSED },
  185. { -1 },
  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. .phys_io = ORION5X_REGS_PHYS_BASE,
  224. .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
  225. .boot_params = 0x00000100,
  226. .init_machine = mss2_init,
  227. .map_io = orion5x_map_io,
  228. .init_irq = orion5x_init_irq,
  229. .timer = &orion5x_timer,
  230. .fixup = tag_fixup_mem32
  231. MACHINE_END