common.c 7.3 KB

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