rd88f5182-setup.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/pci.h>
  16. #include <linux/irq.h>
  17. #include <linux/mtd/physmap.h>
  18. #include <linux/mv643xx_eth.h>
  19. #include <linux/ata_platform.h>
  20. #include <linux/i2c.h>
  21. #include <asm/mach-types.h>
  22. #include <asm/gpio.h>
  23. #include <asm/leds.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/pci.h>
  26. #include <mach/orion5x.h>
  27. #include "common.h"
  28. #include "mpp.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. * GPIO Debug LED
  50. */
  51. #define RD88F5182_GPIO_DBG_LED 0
  52. /*****************************************************************************
  53. * 16M NOR Flash on Device bus CS1
  54. ****************************************************************************/
  55. static struct physmap_flash_data rd88f5182_nor_flash_data = {
  56. .width = 1,
  57. };
  58. static struct resource rd88f5182_nor_flash_resource = {
  59. .flags = IORESOURCE_MEM,
  60. .start = RD88F5182_NOR_BASE,
  61. .end = RD88F5182_NOR_BASE + RD88F5182_NOR_SIZE - 1,
  62. };
  63. static struct platform_device rd88f5182_nor_flash = {
  64. .name = "physmap-flash",
  65. .id = 0,
  66. .dev = {
  67. .platform_data = &rd88f5182_nor_flash_data,
  68. },
  69. .num_resources = 1,
  70. .resource = &rd88f5182_nor_flash_resource,
  71. };
  72. #ifdef CONFIG_LEDS
  73. /*****************************************************************************
  74. * Use GPIO debug led as CPU active indication
  75. ****************************************************************************/
  76. static void rd88f5182_dbgled_event(led_event_t evt)
  77. {
  78. int val;
  79. if (evt == led_idle_end)
  80. val = 1;
  81. else if (evt == led_idle_start)
  82. val = 0;
  83. else
  84. return;
  85. gpio_set_value(RD88F5182_GPIO_DBG_LED, val);
  86. }
  87. static int __init rd88f5182_dbgled_init(void)
  88. {
  89. int pin;
  90. if (machine_is_rd88f5182()) {
  91. pin = RD88F5182_GPIO_DBG_LED;
  92. if (gpio_request(pin, "DBGLED") == 0) {
  93. if (gpio_direction_output(pin, 0) != 0) {
  94. printk(KERN_ERR "rd88f5182_dbgled_init failed "
  95. "to set output pin %d\n", pin);
  96. gpio_free(pin);
  97. return 0;
  98. }
  99. } else {
  100. printk(KERN_ERR "rd88f5182_dbgled_init failed "
  101. "to request gpio %d\n", pin);
  102. return 0;
  103. }
  104. leds_event = rd88f5182_dbgled_event;
  105. }
  106. return 0;
  107. }
  108. __initcall(rd88f5182_dbgled_init);
  109. #endif
  110. /*****************************************************************************
  111. * PCI
  112. ****************************************************************************/
  113. void __init rd88f5182_pci_preinit(void)
  114. {
  115. int pin;
  116. /*
  117. * Configure PCI GPIO IRQ pins
  118. */
  119. pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN;
  120. if (gpio_request(pin, "PCI IntA") == 0) {
  121. if (gpio_direction_input(pin) == 0) {
  122. set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
  123. } else {
  124. printk(KERN_ERR "rd88f5182_pci_preinit faield to "
  125. "set_irq_type pin %d\n", pin);
  126. gpio_free(pin);
  127. }
  128. } else {
  129. printk(KERN_ERR "rd88f5182_pci_preinit failed to request gpio %d\n", pin);
  130. }
  131. pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN;
  132. if (gpio_request(pin, "PCI IntB") == 0) {
  133. if (gpio_direction_input(pin) == 0) {
  134. set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
  135. } else {
  136. printk(KERN_ERR "rd88f5182_pci_preinit faield to "
  137. "set_irq_type pin %d\n", pin);
  138. gpio_free(pin);
  139. }
  140. } else {
  141. printk(KERN_ERR "rd88f5182_pci_preinit failed to gpio_request %d\n", pin);
  142. }
  143. }
  144. static int __init rd88f5182_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  145. {
  146. int irq;
  147. /*
  148. * Check for devices with hard-wired IRQs.
  149. */
  150. irq = orion5x_pci_map_irq(dev, slot, pin);
  151. if (irq != -1)
  152. return irq;
  153. /*
  154. * PCI IRQs are connected via GPIOs
  155. */
  156. switch (slot - RD88F5182_PCI_SLOT0_OFFS) {
  157. case 0:
  158. if (pin == 1)
  159. return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN);
  160. else
  161. return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN);
  162. default:
  163. return -1;
  164. }
  165. }
  166. static struct hw_pci rd88f5182_pci __initdata = {
  167. .nr_controllers = 2,
  168. .preinit = rd88f5182_pci_preinit,
  169. .swizzle = pci_std_swizzle,
  170. .setup = orion5x_pci_sys_setup,
  171. .scan = orion5x_pci_sys_scan_bus,
  172. .map_irq = rd88f5182_pci_map_irq,
  173. };
  174. static int __init rd88f5182_pci_init(void)
  175. {
  176. if (machine_is_rd88f5182())
  177. pci_common_init(&rd88f5182_pci);
  178. return 0;
  179. }
  180. subsys_initcall(rd88f5182_pci_init);
  181. /*****************************************************************************
  182. * Ethernet
  183. ****************************************************************************/
  184. static struct mv643xx_eth_platform_data rd88f5182_eth_data = {
  185. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  186. };
  187. /*****************************************************************************
  188. * RTC DS1338 on I2C bus
  189. ****************************************************************************/
  190. static struct i2c_board_info __initdata rd88f5182_i2c_rtc = {
  191. I2C_BOARD_INFO("ds1338", 0x68),
  192. };
  193. /*****************************************************************************
  194. * Sata
  195. ****************************************************************************/
  196. static struct mv_sata_platform_data rd88f5182_sata_data = {
  197. .n_ports = 2,
  198. };
  199. /*****************************************************************************
  200. * General Setup
  201. ****************************************************************************/
  202. static struct orion5x_mpp_mode rd88f5182_mpp_modes[] __initdata = {
  203. { 0, MPP_GPIO }, /* Debug Led */
  204. { 1, MPP_GPIO }, /* Reset Switch */
  205. { 2, MPP_UNUSED },
  206. { 3, MPP_GPIO }, /* RTC Int */
  207. { 4, MPP_GPIO },
  208. { 5, MPP_GPIO },
  209. { 6, MPP_GPIO }, /* PCI_intA */
  210. { 7, MPP_GPIO }, /* PCI_intB */
  211. { 8, MPP_UNUSED },
  212. { 9, MPP_UNUSED },
  213. { 10, MPP_UNUSED },
  214. { 11, MPP_UNUSED },
  215. { 12, MPP_SATA_LED }, /* SATA 0 presence */
  216. { 13, MPP_SATA_LED }, /* SATA 1 presence */
  217. { 14, MPP_SATA_LED }, /* SATA 0 active */
  218. { 15, MPP_SATA_LED }, /* SATA 1 active */
  219. { 16, MPP_UNUSED },
  220. { 17, MPP_UNUSED },
  221. { 18, MPP_UNUSED },
  222. { 19, MPP_UNUSED },
  223. { -1 },
  224. };
  225. static void __init rd88f5182_init(void)
  226. {
  227. /*
  228. * Setup basic Orion functions. Need to be called early.
  229. */
  230. orion5x_init();
  231. orion5x_mpp_conf(rd88f5182_mpp_modes);
  232. /*
  233. * MPP[20] PCI Clock to MV88F5182
  234. * MPP[21] PCI Clock to mini PCI CON11
  235. * MPP[22] USB 0 over current indication
  236. * MPP[23] USB 1 over current indication
  237. * MPP[24] USB 1 over current enable
  238. * MPP[25] USB 0 over current enable
  239. */
  240. /*
  241. * Configure peripherals.
  242. */
  243. orion5x_ehci0_init();
  244. orion5x_ehci1_init();
  245. orion5x_eth_init(&rd88f5182_eth_data);
  246. orion5x_i2c_init();
  247. orion5x_sata_init(&rd88f5182_sata_data);
  248. orion5x_uart0_init();
  249. orion5x_xor_init();
  250. orion5x_setup_dev_boot_win(RD88F5182_NOR_BOOT_BASE,
  251. RD88F5182_NOR_BOOT_SIZE);
  252. orion5x_setup_dev1_win(RD88F5182_NOR_BASE, RD88F5182_NOR_SIZE);
  253. platform_device_register(&rd88f5182_nor_flash);
  254. i2c_register_board_info(0, &rd88f5182_i2c_rtc, 1);
  255. }
  256. MACHINE_START(RD88F5182, "Marvell Orion-NAS Reference Design")
  257. /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */
  258. .phys_io = ORION5X_REGS_PHYS_BASE,
  259. .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
  260. .boot_params = 0x00000100,
  261. .init_machine = rd88f5182_init,
  262. .map_io = orion5x_map_io,
  263. .init_irq = orion5x_init_irq,
  264. .timer = &orion5x_timer,
  265. MACHINE_END