common.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. /*
  2. * arch/arm/mach-loki/common.c
  3. *
  4. * Core functions for Marvell Loki (88RC8480) SoCs
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/serial_8250.h>
  14. #include <linux/mbus.h>
  15. #include <linux/mv643xx_eth.h>
  16. #include <asm/page.h>
  17. #include <asm/timex.h>
  18. #include <asm/mach/map.h>
  19. #include <asm/mach/time.h>
  20. #include <mach/loki.h>
  21. #include <plat/orion_nand.h>
  22. #include <plat/time.h>
  23. #include "common.h"
  24. /*****************************************************************************
  25. * I/O Address Mapping
  26. ****************************************************************************/
  27. static struct map_desc loki_io_desc[] __initdata = {
  28. {
  29. .virtual = LOKI_REGS_VIRT_BASE,
  30. .pfn = __phys_to_pfn(LOKI_REGS_PHYS_BASE),
  31. .length = LOKI_REGS_SIZE,
  32. .type = MT_DEVICE,
  33. },
  34. };
  35. void __init loki_map_io(void)
  36. {
  37. iotable_init(loki_io_desc, ARRAY_SIZE(loki_io_desc));
  38. }
  39. /*****************************************************************************
  40. * GE0
  41. ****************************************************************************/
  42. struct mv643xx_eth_shared_platform_data loki_ge0_shared_data = {
  43. .t_clk = LOKI_TCLK,
  44. .dram = &loki_mbus_dram_info,
  45. };
  46. static struct resource loki_ge0_shared_resources[] = {
  47. {
  48. .name = "ge0 base",
  49. .start = GE0_PHYS_BASE + 0x2000,
  50. .end = GE0_PHYS_BASE + 0x3fff,
  51. .flags = IORESOURCE_MEM,
  52. },
  53. };
  54. static struct platform_device loki_ge0_shared = {
  55. .name = MV643XX_ETH_SHARED_NAME,
  56. .id = 0,
  57. .dev = {
  58. .platform_data = &loki_ge0_shared_data,
  59. },
  60. .num_resources = 1,
  61. .resource = loki_ge0_shared_resources,
  62. };
  63. static struct resource loki_ge0_resources[] = {
  64. {
  65. .name = "ge0 irq",
  66. .start = IRQ_LOKI_GBE_A_INT,
  67. .end = IRQ_LOKI_GBE_A_INT,
  68. .flags = IORESOURCE_IRQ,
  69. },
  70. };
  71. static struct platform_device loki_ge0 = {
  72. .name = MV643XX_ETH_NAME,
  73. .id = 0,
  74. .num_resources = 1,
  75. .resource = loki_ge0_resources,
  76. .dev = {
  77. .coherent_dma_mask = 0xffffffff,
  78. },
  79. };
  80. void __init loki_ge0_init(struct mv643xx_eth_platform_data *eth_data)
  81. {
  82. eth_data->shared = &loki_ge0_shared;
  83. loki_ge0.dev.platform_data = eth_data;
  84. writel(0x00079220, GE0_VIRT_BASE + 0x20b0);
  85. platform_device_register(&loki_ge0_shared);
  86. platform_device_register(&loki_ge0);
  87. }
  88. /*****************************************************************************
  89. * GE1
  90. ****************************************************************************/
  91. struct mv643xx_eth_shared_platform_data loki_ge1_shared_data = {
  92. .t_clk = LOKI_TCLK,
  93. .dram = &loki_mbus_dram_info,
  94. };
  95. static struct resource loki_ge1_shared_resources[] = {
  96. {
  97. .name = "ge1 base",
  98. .start = GE1_PHYS_BASE + 0x2000,
  99. .end = GE1_PHYS_BASE + 0x3fff,
  100. .flags = IORESOURCE_MEM,
  101. },
  102. };
  103. static struct platform_device loki_ge1_shared = {
  104. .name = MV643XX_ETH_SHARED_NAME,
  105. .id = 1,
  106. .dev = {
  107. .platform_data = &loki_ge1_shared_data,
  108. },
  109. .num_resources = 1,
  110. .resource = loki_ge1_shared_resources,
  111. };
  112. static struct resource loki_ge1_resources[] = {
  113. {
  114. .name = "ge1 irq",
  115. .start = IRQ_LOKI_GBE_B_INT,
  116. .end = IRQ_LOKI_GBE_B_INT,
  117. .flags = IORESOURCE_IRQ,
  118. },
  119. };
  120. static struct platform_device loki_ge1 = {
  121. .name = MV643XX_ETH_NAME,
  122. .id = 1,
  123. .num_resources = 1,
  124. .resource = loki_ge1_resources,
  125. .dev = {
  126. .coherent_dma_mask = 0xffffffff,
  127. },
  128. };
  129. void __init loki_ge1_init(struct mv643xx_eth_platform_data *eth_data)
  130. {
  131. eth_data->shared = &loki_ge1_shared;
  132. loki_ge1.dev.platform_data = eth_data;
  133. writel(0x00079220, GE1_VIRT_BASE + 0x20b0);
  134. platform_device_register(&loki_ge1_shared);
  135. platform_device_register(&loki_ge1);
  136. }
  137. /*****************************************************************************
  138. * SAS/SATA
  139. ****************************************************************************/
  140. static struct resource loki_sas_resources[] = {
  141. {
  142. .name = "mvsas0 mem",
  143. .start = SAS0_PHYS_BASE,
  144. .end = SAS0_PHYS_BASE + 0x01ff,
  145. .flags = IORESOURCE_MEM,
  146. }, {
  147. .name = "mvsas0 irq",
  148. .start = IRQ_LOKI_SAS_A,
  149. .end = IRQ_LOKI_SAS_A,
  150. .flags = IORESOURCE_IRQ,
  151. }, {
  152. .name = "mvsas1 mem",
  153. .start = SAS1_PHYS_BASE,
  154. .end = SAS1_PHYS_BASE + 0x01ff,
  155. .flags = IORESOURCE_MEM,
  156. }, {
  157. .name = "mvsas1 irq",
  158. .start = IRQ_LOKI_SAS_B,
  159. .end = IRQ_LOKI_SAS_B,
  160. .flags = IORESOURCE_IRQ,
  161. },
  162. };
  163. static struct platform_device loki_sas = {
  164. .name = "mvsas",
  165. .id = 0,
  166. .dev = {
  167. .coherent_dma_mask = 0xffffffff,
  168. },
  169. .num_resources = ARRAY_SIZE(loki_sas_resources),
  170. .resource = loki_sas_resources,
  171. };
  172. void __init loki_sas_init(void)
  173. {
  174. writel(0x8300f707, DDR_REG(0x1424));
  175. platform_device_register(&loki_sas);
  176. }
  177. /*****************************************************************************
  178. * UART0
  179. ****************************************************************************/
  180. static struct plat_serial8250_port loki_uart0_data[] = {
  181. {
  182. .mapbase = UART0_PHYS_BASE,
  183. .membase = (char *)UART0_VIRT_BASE,
  184. .irq = IRQ_LOKI_UART0,
  185. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  186. .iotype = UPIO_MEM,
  187. .regshift = 2,
  188. .uartclk = LOKI_TCLK,
  189. }, {
  190. },
  191. };
  192. static struct resource loki_uart0_resources[] = {
  193. {
  194. .start = UART0_PHYS_BASE,
  195. .end = UART0_PHYS_BASE + 0xff,
  196. .flags = IORESOURCE_MEM,
  197. }, {
  198. .start = IRQ_LOKI_UART0,
  199. .end = IRQ_LOKI_UART0,
  200. .flags = IORESOURCE_IRQ,
  201. },
  202. };
  203. static struct platform_device loki_uart0 = {
  204. .name = "serial8250",
  205. .id = 0,
  206. .dev = {
  207. .platform_data = loki_uart0_data,
  208. },
  209. .resource = loki_uart0_resources,
  210. .num_resources = ARRAY_SIZE(loki_uart0_resources),
  211. };
  212. void __init loki_uart0_init(void)
  213. {
  214. platform_device_register(&loki_uart0);
  215. }
  216. /*****************************************************************************
  217. * UART1
  218. ****************************************************************************/
  219. static struct plat_serial8250_port loki_uart1_data[] = {
  220. {
  221. .mapbase = UART1_PHYS_BASE,
  222. .membase = (char *)UART1_VIRT_BASE,
  223. .irq = IRQ_LOKI_UART1,
  224. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  225. .iotype = UPIO_MEM,
  226. .regshift = 2,
  227. .uartclk = LOKI_TCLK,
  228. }, {
  229. },
  230. };
  231. static struct resource loki_uart1_resources[] = {
  232. {
  233. .start = UART1_PHYS_BASE,
  234. .end = UART1_PHYS_BASE + 0xff,
  235. .flags = IORESOURCE_MEM,
  236. }, {
  237. .start = IRQ_LOKI_UART1,
  238. .end = IRQ_LOKI_UART1,
  239. .flags = IORESOURCE_IRQ,
  240. },
  241. };
  242. static struct platform_device loki_uart1 = {
  243. .name = "serial8250",
  244. .id = 1,
  245. .dev = {
  246. .platform_data = loki_uart1_data,
  247. },
  248. .resource = loki_uart1_resources,
  249. .num_resources = ARRAY_SIZE(loki_uart1_resources),
  250. };
  251. void __init loki_uart1_init(void)
  252. {
  253. platform_device_register(&loki_uart1);
  254. }
  255. /*****************************************************************************
  256. * Time handling
  257. ****************************************************************************/
  258. static void loki_timer_init(void)
  259. {
  260. orion_time_init(IRQ_LOKI_BRIDGE, LOKI_TCLK);
  261. }
  262. struct sys_timer loki_timer = {
  263. .init = loki_timer_init,
  264. };
  265. /*****************************************************************************
  266. * General
  267. ****************************************************************************/
  268. void __init loki_init(void)
  269. {
  270. printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK);
  271. loki_setup_cpu_mbus();
  272. }