common.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. /*
  2. * arch/arm/mach-orion/common.c
  3. *
  4. * Core functions for Marvell Orion System On Chip
  5. *
  6. * Maintainer: Tzachi Perelstein <tzachi@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/serial_8250.h>
  16. #include <linux/mv643xx_eth.h>
  17. #include <asm/page.h>
  18. #include <asm/timex.h>
  19. #include <asm/mach/map.h>
  20. #include <asm/arch/orion.h>
  21. #include "common.h"
  22. /*****************************************************************************
  23. * I/O Address Mapping
  24. ****************************************************************************/
  25. static struct map_desc orion_io_desc[] __initdata = {
  26. {
  27. .virtual = ORION_REGS_BASE,
  28. .pfn = __phys_to_pfn(ORION_REGS_BASE),
  29. .length = ORION_REGS_SIZE,
  30. .type = MT_DEVICE
  31. },
  32. {
  33. .virtual = ORION_PCIE_IO_BASE,
  34. .pfn = __phys_to_pfn(ORION_PCIE_IO_BASE),
  35. .length = ORION_PCIE_IO_SIZE,
  36. .type = MT_DEVICE
  37. },
  38. {
  39. .virtual = ORION_PCI_IO_BASE,
  40. .pfn = __phys_to_pfn(ORION_PCI_IO_BASE),
  41. .length = ORION_PCI_IO_SIZE,
  42. .type = MT_DEVICE
  43. },
  44. {
  45. .virtual = ORION_PCIE_WA_BASE,
  46. .pfn = __phys_to_pfn(ORION_PCIE_WA_BASE),
  47. .length = ORION_PCIE_WA_SIZE,
  48. .type = MT_DEVICE
  49. },
  50. };
  51. void __init orion_map_io(void)
  52. {
  53. iotable_init(orion_io_desc, ARRAY_SIZE(orion_io_desc));
  54. }
  55. /*****************************************************************************
  56. * UART
  57. ****************************************************************************/
  58. static struct resource orion_uart_resources[] = {
  59. {
  60. .start = UART0_BASE,
  61. .end = UART0_BASE + 0xff,
  62. .flags = IORESOURCE_MEM,
  63. },
  64. {
  65. .start = IRQ_ORION_UART0,
  66. .end = IRQ_ORION_UART0,
  67. .flags = IORESOURCE_IRQ,
  68. },
  69. {
  70. .start = UART1_BASE,
  71. .end = UART1_BASE + 0xff,
  72. .flags = IORESOURCE_MEM,
  73. },
  74. {
  75. .start = IRQ_ORION_UART1,
  76. .end = IRQ_ORION_UART1,
  77. .flags = IORESOURCE_IRQ,
  78. },
  79. };
  80. static struct plat_serial8250_port orion_uart_data[] = {
  81. {
  82. .mapbase = UART0_BASE,
  83. .membase = (char *)UART0_BASE,
  84. .irq = IRQ_ORION_UART0,
  85. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  86. .iotype = UPIO_MEM,
  87. .regshift = 2,
  88. .uartclk = ORION_TCLK,
  89. },
  90. {
  91. .mapbase = UART1_BASE,
  92. .membase = (char *)UART1_BASE,
  93. .irq = IRQ_ORION_UART1,
  94. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  95. .iotype = UPIO_MEM,
  96. .regshift = 2,
  97. .uartclk = ORION_TCLK,
  98. },
  99. { },
  100. };
  101. static struct platform_device orion_uart = {
  102. .name = "serial8250",
  103. .id = PLAT8250_DEV_PLATFORM,
  104. .dev = {
  105. .platform_data = orion_uart_data,
  106. },
  107. .resource = orion_uart_resources,
  108. .num_resources = ARRAY_SIZE(orion_uart_resources),
  109. };
  110. /*******************************************************************************
  111. * USB Controller - 2 interfaces
  112. ******************************************************************************/
  113. static struct resource orion_ehci0_resources[] = {
  114. {
  115. .start = ORION_USB0_REG_BASE,
  116. .end = ORION_USB0_REG_BASE + SZ_4K,
  117. .flags = IORESOURCE_MEM,
  118. },
  119. {
  120. .start = IRQ_ORION_USB0_CTRL,
  121. .end = IRQ_ORION_USB0_CTRL,
  122. .flags = IORESOURCE_IRQ,
  123. },
  124. };
  125. static struct resource orion_ehci1_resources[] = {
  126. {
  127. .start = ORION_USB1_REG_BASE,
  128. .end = ORION_USB1_REG_BASE + SZ_4K,
  129. .flags = IORESOURCE_MEM,
  130. },
  131. {
  132. .start = IRQ_ORION_USB1_CTRL,
  133. .end = IRQ_ORION_USB1_CTRL,
  134. .flags = IORESOURCE_IRQ,
  135. },
  136. };
  137. static u64 ehci_dmamask = 0xffffffffUL;
  138. static struct platform_device orion_ehci0 = {
  139. .name = "orion-ehci",
  140. .id = 0,
  141. .dev = {
  142. .dma_mask = &ehci_dmamask,
  143. .coherent_dma_mask = 0xffffffff,
  144. },
  145. .resource = orion_ehci0_resources,
  146. .num_resources = ARRAY_SIZE(orion_ehci0_resources),
  147. };
  148. static struct platform_device orion_ehci1 = {
  149. .name = "orion-ehci",
  150. .id = 1,
  151. .dev = {
  152. .dma_mask = &ehci_dmamask,
  153. .coherent_dma_mask = 0xffffffff,
  154. },
  155. .resource = orion_ehci1_resources,
  156. .num_resources = ARRAY_SIZE(orion_ehci1_resources),
  157. };
  158. /*****************************************************************************
  159. * Gigabit Ethernet port
  160. * (The Orion and Discovery (MV643xx) families use the same Ethernet driver)
  161. ****************************************************************************/
  162. static struct resource orion_eth_shared_resources[] = {
  163. {
  164. .start = ORION_ETH_REG_BASE,
  165. .end = ORION_ETH_REG_BASE + 0xffff,
  166. .flags = IORESOURCE_MEM,
  167. },
  168. };
  169. static struct platform_device orion_eth_shared = {
  170. .name = MV643XX_ETH_SHARED_NAME,
  171. .id = 0,
  172. .num_resources = 1,
  173. .resource = orion_eth_shared_resources,
  174. };
  175. static struct resource orion_eth_resources[] = {
  176. {
  177. .name = "eth irq",
  178. .start = IRQ_ORION_ETH_SUM,
  179. .end = IRQ_ORION_ETH_SUM,
  180. .flags = IORESOURCE_IRQ,
  181. }
  182. };
  183. static struct platform_device orion_eth = {
  184. .name = MV643XX_ETH_NAME,
  185. .id = 0,
  186. .num_resources = 1,
  187. .resource = orion_eth_resources,
  188. };
  189. void __init orion_eth_init(struct mv643xx_eth_platform_data *eth_data)
  190. {
  191. orion_eth.dev.platform_data = eth_data;
  192. platform_device_register(&orion_eth_shared);
  193. platform_device_register(&orion_eth);
  194. }
  195. /*****************************************************************************
  196. * General
  197. ****************************************************************************/
  198. /*
  199. * Identify device ID and rev from PCIE configuration header space '0'.
  200. */
  201. static void orion_id(u32 *dev, u32 *rev, char **dev_name)
  202. {
  203. orion_pcie_id(dev, rev);
  204. if (*dev == MV88F5281_DEV_ID) {
  205. if (*rev == MV88F5281_REV_D2) {
  206. *dev_name = "MV88F5281-D2";
  207. } else if (*rev == MV88F5281_REV_D1) {
  208. *dev_name = "MV88F5281-D1";
  209. } else {
  210. *dev_name = "MV88F5281-Rev-Unsupported";
  211. }
  212. } else if (*dev == MV88F5182_DEV_ID) {
  213. if (*rev == MV88F5182_REV_A2) {
  214. *dev_name = "MV88F5182-A2";
  215. } else {
  216. *dev_name = "MV88F5182-Rev-Unsupported";
  217. }
  218. } else {
  219. *dev_name = "Device-Unknown";
  220. }
  221. }
  222. void __init orion_init(void)
  223. {
  224. char *dev_name;
  225. u32 dev, rev;
  226. orion_id(&dev, &rev, &dev_name);
  227. printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, ORION_TCLK);
  228. /*
  229. * Setup Orion address map
  230. */
  231. orion_setup_cpu_wins();
  232. orion_setup_usb_wins();
  233. orion_setup_eth_wins();
  234. orion_setup_pci_wins();
  235. orion_setup_pcie_wins();
  236. if (dev == MV88F5182_DEV_ID)
  237. orion_setup_sata_wins();
  238. /*
  239. * REgister devices
  240. */
  241. platform_device_register(&orion_uart);
  242. platform_device_register(&orion_ehci0);
  243. if (dev == MV88F5182_DEV_ID)
  244. platform_device_register(&orion_ehci1);
  245. }