rd88f5182-setup.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /*
  2. * arch/arm/mach-orion5x/rd88f5182-setup.c
  3. *
  4. * Marvell Orion-NAS Reference Design Setup
  5. *
  6. * Maintainer: Ronen Shitrit <rshitrit@marvell.com>
  7. *
  8. * This file is licensed under the terms of the GNU General Public
  9. * License version 2. This program is licensed "as is" without any
  10. * warranty of any kind, whether express or implied.
  11. */
  12. #include <linux/gpio.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/pci.h>
  17. #include <linux/irq.h>
  18. #include <linux/mtd/physmap.h>
  19. #include <linux/mv643xx_eth.h>
  20. #include <linux/ata_platform.h>
  21. #include <linux/i2c.h>
  22. #include <linux/leds.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/pci.h>
  26. #include "common.h"
  27. #include "mpp.h"
  28. #include "orion5x.h"
  29. /*****************************************************************************
  30. * RD-88F5182 Info
  31. ****************************************************************************/
  32. /*
  33. * 512K NOR flash Device bus boot chip select
  34. */
  35. #define RD88F5182_NOR_BOOT_BASE 0xf4000000
  36. #define RD88F5182_NOR_BOOT_SIZE SZ_512K
  37. /*
  38. * 16M NOR flash on Device bus chip select 1
  39. */
  40. #define RD88F5182_NOR_BASE 0xfc000000
  41. #define RD88F5182_NOR_SIZE SZ_16M
  42. /*
  43. * PCI
  44. */
  45. #define RD88F5182_PCI_SLOT0_OFFS 7
  46. #define RD88F5182_PCI_SLOT0_IRQ_A_PIN 7
  47. #define RD88F5182_PCI_SLOT0_IRQ_B_PIN 6
  48. /*****************************************************************************
  49. * 16M NOR Flash on Device bus CS1
  50. ****************************************************************************/
  51. static struct physmap_flash_data rd88f5182_nor_flash_data = {
  52. .width = 1,
  53. };
  54. static struct resource rd88f5182_nor_flash_resource = {
  55. .flags = IORESOURCE_MEM,
  56. .start = RD88F5182_NOR_BASE,
  57. .end = RD88F5182_NOR_BASE + RD88F5182_NOR_SIZE - 1,
  58. };
  59. static struct platform_device rd88f5182_nor_flash = {
  60. .name = "physmap-flash",
  61. .id = 0,
  62. .dev = {
  63. .platform_data = &rd88f5182_nor_flash_data,
  64. },
  65. .num_resources = 1,
  66. .resource = &rd88f5182_nor_flash_resource,
  67. };
  68. /*****************************************************************************
  69. * Use GPIO LED as CPU active indication
  70. ****************************************************************************/
  71. #define RD88F5182_GPIO_LED 0
  72. static struct gpio_led rd88f5182_gpio_led_pins[] = {
  73. {
  74. .name = "rd88f5182:cpu",
  75. .default_trigger = "cpu0",
  76. .gpio = RD88F5182_GPIO_LED,
  77. },
  78. };
  79. static struct gpio_led_platform_data rd88f5182_gpio_led_data = {
  80. .leds = rd88f5182_gpio_led_pins,
  81. .num_leds = ARRAY_SIZE(rd88f5182_gpio_led_pins),
  82. };
  83. static struct platform_device rd88f5182_gpio_leds = {
  84. .name = "leds-gpio",
  85. .id = -1,
  86. .dev = {
  87. .platform_data = &rd88f5182_gpio_led_data,
  88. },
  89. };
  90. /*****************************************************************************
  91. * PCI
  92. ****************************************************************************/
  93. static void __init rd88f5182_pci_preinit(void)
  94. {
  95. int pin;
  96. /*
  97. * Configure PCI GPIO IRQ pins
  98. */
  99. pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN;
  100. if (gpio_request(pin, "PCI IntA") == 0) {
  101. if (gpio_direction_input(pin) == 0) {
  102. irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
  103. } else {
  104. printk(KERN_ERR "rd88f5182_pci_preinit failed to "
  105. "set_irq_type pin %d\n", pin);
  106. gpio_free(pin);
  107. }
  108. } else {
  109. printk(KERN_ERR "rd88f5182_pci_preinit failed to request gpio %d\n", pin);
  110. }
  111. pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN;
  112. if (gpio_request(pin, "PCI IntB") == 0) {
  113. if (gpio_direction_input(pin) == 0) {
  114. irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
  115. } else {
  116. printk(KERN_ERR "rd88f5182_pci_preinit failed to "
  117. "set_irq_type pin %d\n", pin);
  118. gpio_free(pin);
  119. }
  120. } else {
  121. printk(KERN_ERR "rd88f5182_pci_preinit failed to gpio_request %d\n", pin);
  122. }
  123. }
  124. static int __init rd88f5182_pci_map_irq(const struct pci_dev *dev, u8 slot,
  125. u8 pin)
  126. {
  127. int irq;
  128. /*
  129. * Check for devices with hard-wired IRQs.
  130. */
  131. irq = orion5x_pci_map_irq(dev, slot, pin);
  132. if (irq != -1)
  133. return irq;
  134. /*
  135. * PCI IRQs are connected via GPIOs
  136. */
  137. switch (slot - RD88F5182_PCI_SLOT0_OFFS) {
  138. case 0:
  139. if (pin == 1)
  140. return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN);
  141. else
  142. return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN);
  143. default:
  144. return -1;
  145. }
  146. }
  147. static struct hw_pci rd88f5182_pci __initdata = {
  148. .nr_controllers = 2,
  149. .preinit = rd88f5182_pci_preinit,
  150. .setup = orion5x_pci_sys_setup,
  151. .scan = orion5x_pci_sys_scan_bus,
  152. .map_irq = rd88f5182_pci_map_irq,
  153. };
  154. static int __init rd88f5182_pci_init(void)
  155. {
  156. if (machine_is_rd88f5182())
  157. pci_common_init(&rd88f5182_pci);
  158. return 0;
  159. }
  160. subsys_initcall(rd88f5182_pci_init);
  161. /*****************************************************************************
  162. * Ethernet
  163. ****************************************************************************/
  164. static struct mv643xx_eth_platform_data rd88f5182_eth_data = {
  165. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  166. };
  167. /*****************************************************************************
  168. * RTC DS1338 on I2C bus
  169. ****************************************************************************/
  170. static struct i2c_board_info __initdata rd88f5182_i2c_rtc = {
  171. I2C_BOARD_INFO("ds1338", 0x68),
  172. };
  173. /*****************************************************************************
  174. * Sata
  175. ****************************************************************************/
  176. static struct mv_sata_platform_data rd88f5182_sata_data = {
  177. .n_ports = 2,
  178. };
  179. /*****************************************************************************
  180. * General Setup
  181. ****************************************************************************/
  182. static unsigned int rd88f5182_mpp_modes[] __initdata = {
  183. MPP0_GPIO, /* Debug Led */
  184. MPP1_GPIO, /* Reset Switch */
  185. MPP2_UNUSED,
  186. MPP3_GPIO, /* RTC Int */
  187. MPP4_GPIO,
  188. MPP5_GPIO,
  189. MPP6_GPIO, /* PCI_intA */
  190. MPP7_GPIO, /* PCI_intB */
  191. MPP8_UNUSED,
  192. MPP9_UNUSED,
  193. MPP10_UNUSED,
  194. MPP11_UNUSED,
  195. MPP12_SATA_LED, /* SATA 0 presence */
  196. MPP13_SATA_LED, /* SATA 1 presence */
  197. MPP14_SATA_LED, /* SATA 0 active */
  198. MPP15_SATA_LED, /* SATA 1 active */
  199. MPP16_UNUSED,
  200. MPP17_UNUSED,
  201. MPP18_UNUSED,
  202. MPP19_UNUSED,
  203. 0,
  204. };
  205. static void __init rd88f5182_init(void)
  206. {
  207. /*
  208. * Setup basic Orion functions. Need to be called early.
  209. */
  210. orion5x_init();
  211. orion5x_mpp_conf(rd88f5182_mpp_modes);
  212. /*
  213. * MPP[20] PCI Clock to MV88F5182
  214. * MPP[21] PCI Clock to mini PCI CON11
  215. * MPP[22] USB 0 over current indication
  216. * MPP[23] USB 1 over current indication
  217. * MPP[24] USB 1 over current enable
  218. * MPP[25] USB 0 over current enable
  219. */
  220. /*
  221. * Configure peripherals.
  222. */
  223. orion5x_ehci0_init();
  224. orion5x_ehci1_init();
  225. orion5x_eth_init(&rd88f5182_eth_data);
  226. orion5x_i2c_init();
  227. orion5x_sata_init(&rd88f5182_sata_data);
  228. orion5x_uart0_init();
  229. orion5x_xor_init();
  230. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
  231. ORION_MBUS_DEVBUS_BOOT_ATTR,
  232. RD88F5182_NOR_BOOT_BASE,
  233. RD88F5182_NOR_BOOT_SIZE);
  234. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_TARGET(1),
  235. ORION_MBUS_DEVBUS_ATTR(1),
  236. RD88F5182_NOR_BASE,
  237. RD88F5182_NOR_SIZE);
  238. platform_device_register(&rd88f5182_nor_flash);
  239. platform_device_register(&rd88f5182_gpio_leds);
  240. i2c_register_board_info(0, &rd88f5182_i2c_rtc, 1);
  241. }
  242. MACHINE_START(RD88F5182, "Marvell Orion-NAS Reference Design")
  243. /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */
  244. .atag_offset = 0x100,
  245. .nr_irqs = ORION5X_NR_IRQS,
  246. .init_machine = rd88f5182_init,
  247. .map_io = orion5x_map_io,
  248. .init_early = orion5x_init_early,
  249. .init_irq = orion5x_init_irq,
  250. .init_time = orion5x_timer_init,
  251. .restart = orion5x_restart,
  252. MACHINE_END