rd88f5182-setup.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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 <asm/arch/orion5x.h>
  27. #include "common.h"
  28. /*****************************************************************************
  29. * RD-88F5182 Info
  30. ****************************************************************************/
  31. /*
  32. * 512K NOR flash Device bus boot chip select
  33. */
  34. #define RD88F5182_NOR_BOOT_BASE 0xf4000000
  35. #define RD88F5182_NOR_BOOT_SIZE SZ_512K
  36. /*
  37. * 16M NOR flash on Device bus chip select 1
  38. */
  39. #define RD88F5182_NOR_BASE 0xfc000000
  40. #define RD88F5182_NOR_SIZE SZ_16M
  41. /*
  42. * PCI
  43. */
  44. #define RD88F5182_PCI_SLOT0_OFFS 7
  45. #define RD88F5182_PCI_SLOT0_IRQ_A_PIN 7
  46. #define RD88F5182_PCI_SLOT0_IRQ_B_PIN 6
  47. /*
  48. * GPIO Debug LED
  49. */
  50. #define RD88F5182_GPIO_DBG_LED 0
  51. /*****************************************************************************
  52. * 16M NOR Flash on Device bus CS1
  53. ****************************************************************************/
  54. static struct physmap_flash_data rd88f5182_nor_flash_data = {
  55. .width = 1,
  56. };
  57. static struct resource rd88f5182_nor_flash_resource = {
  58. .flags = IORESOURCE_MEM,
  59. .start = RD88F5182_NOR_BASE,
  60. .end = RD88F5182_NOR_BASE + RD88F5182_NOR_SIZE - 1,
  61. };
  62. static struct platform_device rd88f5182_nor_flash = {
  63. .name = "physmap-flash",
  64. .id = 0,
  65. .dev = {
  66. .platform_data = &rd88f5182_nor_flash_data,
  67. },
  68. .num_resources = 1,
  69. .resource = &rd88f5182_nor_flash_resource,
  70. };
  71. #ifdef CONFIG_LEDS
  72. /*****************************************************************************
  73. * Use GPIO debug led as CPU active indication
  74. ****************************************************************************/
  75. static void rd88f5182_dbgled_event(led_event_t evt)
  76. {
  77. int val;
  78. if (evt == led_idle_end)
  79. val = 1;
  80. else if (evt == led_idle_start)
  81. val = 0;
  82. else
  83. return;
  84. gpio_set_value(RD88F5182_GPIO_DBG_LED, val);
  85. }
  86. static int __init rd88f5182_dbgled_init(void)
  87. {
  88. int pin;
  89. if (machine_is_rd88f5182()) {
  90. pin = RD88F5182_GPIO_DBG_LED;
  91. if (gpio_request(pin, "DBGLED") == 0) {
  92. if (gpio_direction_output(pin, 0) != 0) {
  93. printk(KERN_ERR "rd88f5182_dbgled_init failed "
  94. "to set output pin %d\n", pin);
  95. gpio_free(pin);
  96. return 0;
  97. }
  98. } else {
  99. printk(KERN_ERR "rd88f5182_dbgled_init failed "
  100. "to request gpio %d\n", pin);
  101. return 0;
  102. }
  103. leds_event = rd88f5182_dbgled_event;
  104. }
  105. return 0;
  106. }
  107. __initcall(rd88f5182_dbgled_init);
  108. #endif
  109. /*****************************************************************************
  110. * PCI
  111. ****************************************************************************/
  112. void __init rd88f5182_pci_preinit(void)
  113. {
  114. int pin;
  115. /*
  116. * Configure PCI GPIO IRQ pins
  117. */
  118. pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN;
  119. if (gpio_request(pin, "PCI IntA") == 0) {
  120. if (gpio_direction_input(pin) == 0) {
  121. set_irq_type(gpio_to_irq(pin), IRQT_LOW);
  122. } else {
  123. printk(KERN_ERR "rd88f5182_pci_preinit faield to "
  124. "set_irq_type pin %d\n", pin);
  125. gpio_free(pin);
  126. }
  127. } else {
  128. printk(KERN_ERR "rd88f5182_pci_preinit failed to request gpio %d\n", pin);
  129. }
  130. pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN;
  131. if (gpio_request(pin, "PCI IntB") == 0) {
  132. if (gpio_direction_input(pin) == 0) {
  133. set_irq_type(gpio_to_irq(pin), IRQT_LOW);
  134. } else {
  135. printk(KERN_ERR "rd88f5182_pci_preinit faield to "
  136. "set_irq_type pin %d\n", pin);
  137. gpio_free(pin);
  138. }
  139. } else {
  140. printk(KERN_ERR "rd88f5182_pci_preinit failed to gpio_request %d\n", pin);
  141. }
  142. }
  143. static int __init rd88f5182_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  144. {
  145. int irq;
  146. /*
  147. * Check for devices with hard-wired IRQs.
  148. */
  149. irq = orion5x_pci_map_irq(dev, slot, pin);
  150. if (irq != -1)
  151. return irq;
  152. /*
  153. * PCI IRQs are connected via GPIOs
  154. */
  155. switch (slot - RD88F5182_PCI_SLOT0_OFFS) {
  156. case 0:
  157. if (pin == 1)
  158. return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN);
  159. else
  160. return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN);
  161. default:
  162. return -1;
  163. }
  164. }
  165. static struct hw_pci rd88f5182_pci __initdata = {
  166. .nr_controllers = 2,
  167. .preinit = rd88f5182_pci_preinit,
  168. .swizzle = pci_std_swizzle,
  169. .setup = orion5x_pci_sys_setup,
  170. .scan = orion5x_pci_sys_scan_bus,
  171. .map_irq = rd88f5182_pci_map_irq,
  172. };
  173. static int __init rd88f5182_pci_init(void)
  174. {
  175. if (machine_is_rd88f5182())
  176. pci_common_init(&rd88f5182_pci);
  177. return 0;
  178. }
  179. subsys_initcall(rd88f5182_pci_init);
  180. /*****************************************************************************
  181. * Ethernet
  182. ****************************************************************************/
  183. static struct mv643xx_eth_platform_data rd88f5182_eth_data = {
  184. .phy_addr = 8,
  185. .force_phy_addr = 1,
  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 void __init rd88f5182_init(void)
  203. {
  204. /*
  205. * Setup basic Orion functions. Need to be called early.
  206. */
  207. orion5x_init();
  208. /*
  209. * Setup Multiplexing Pins --
  210. * MPP[0] Debug Led (GPIO - Out)
  211. * MPP[1] Debug Led (GPIO - Out)
  212. * MPP[2] N/A
  213. * MPP[3] RTC_Int (GPIO - In)
  214. * MPP[4] GPIO
  215. * MPP[5] GPIO
  216. * MPP[6] PCI_intA (GPIO - In)
  217. * MPP[7] PCI_intB (GPIO - In)
  218. * MPP[8-11] N/A
  219. * MPP[12] SATA 0 presence Indication
  220. * MPP[13] SATA 1 presence Indication
  221. * MPP[14] SATA 0 active Indication
  222. * MPP[15] SATA 1 active indication
  223. * MPP[16-19] Not used
  224. * MPP[20] PCI Clock to MV88F5182
  225. * MPP[21] PCI Clock to mini PCI CON11
  226. * MPP[22] USB 0 over current indication
  227. * MPP[23] USB 1 over current indication
  228. * MPP[24] USB 1 over current enable
  229. * MPP[25] USB 0 over current enable
  230. */
  231. orion5x_write(MPP_0_7_CTRL, 0x00000003);
  232. orion5x_write(MPP_8_15_CTRL, 0x55550000);
  233. orion5x_write(MPP_16_19_CTRL, 0x5555);
  234. orion5x_gpio_set_valid_pins(0x000000fb);
  235. /*
  236. * Configure peripherals.
  237. */
  238. orion5x_ehci0_init();
  239. orion5x_ehci1_init();
  240. orion5x_eth_init(&rd88f5182_eth_data);
  241. orion5x_i2c_init();
  242. orion5x_sata_init(&rd88f5182_sata_data);
  243. orion5x_uart0_init();
  244. orion5x_setup_dev_boot_win(RD88F5182_NOR_BOOT_BASE,
  245. RD88F5182_NOR_BOOT_SIZE);
  246. orion5x_setup_dev1_win(RD88F5182_NOR_BASE, RD88F5182_NOR_SIZE);
  247. platform_device_register(&rd88f5182_nor_flash);
  248. i2c_register_board_info(0, &rd88f5182_i2c_rtc, 1);
  249. }
  250. MACHINE_START(RD88F5182, "Marvell Orion-NAS Reference Design")
  251. /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */
  252. .phys_io = ORION5X_REGS_PHYS_BASE,
  253. .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
  254. .boot_params = 0x00000100,
  255. .init_machine = rd88f5182_init,
  256. .map_io = orion5x_map_io,
  257. .init_irq = orion5x_init_irq,
  258. .timer = &orion5x_timer,
  259. MACHINE_END