common.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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. };
  77. void __init loki_ge0_init(struct mv643xx_eth_platform_data *eth_data)
  78. {
  79. eth_data->shared = &loki_ge0_shared;
  80. loki_ge0.dev.platform_data = eth_data;
  81. writel(0x00079220, GE0_VIRT_BASE + 0x20b0);
  82. platform_device_register(&loki_ge0_shared);
  83. platform_device_register(&loki_ge0);
  84. }
  85. /*****************************************************************************
  86. * GE1
  87. ****************************************************************************/
  88. struct mv643xx_eth_shared_platform_data loki_ge1_shared_data = {
  89. .t_clk = LOKI_TCLK,
  90. .dram = &loki_mbus_dram_info,
  91. };
  92. static struct resource loki_ge1_shared_resources[] = {
  93. {
  94. .name = "ge1 base",
  95. .start = GE1_PHYS_BASE + 0x2000,
  96. .end = GE1_PHYS_BASE + 0x3fff,
  97. .flags = IORESOURCE_MEM,
  98. },
  99. };
  100. static struct platform_device loki_ge1_shared = {
  101. .name = MV643XX_ETH_SHARED_NAME,
  102. .id = 1,
  103. .dev = {
  104. .platform_data = &loki_ge1_shared_data,
  105. },
  106. .num_resources = 1,
  107. .resource = loki_ge1_shared_resources,
  108. };
  109. static struct resource loki_ge1_resources[] = {
  110. {
  111. .name = "ge1 irq",
  112. .start = IRQ_LOKI_GBE_B_INT,
  113. .end = IRQ_LOKI_GBE_B_INT,
  114. .flags = IORESOURCE_IRQ,
  115. },
  116. };
  117. static struct platform_device loki_ge1 = {
  118. .name = MV643XX_ETH_NAME,
  119. .id = 1,
  120. .num_resources = 1,
  121. .resource = loki_ge1_resources,
  122. };
  123. void __init loki_ge1_init(struct mv643xx_eth_platform_data *eth_data)
  124. {
  125. eth_data->shared = &loki_ge1_shared;
  126. loki_ge1.dev.platform_data = eth_data;
  127. writel(0x00079220, GE1_VIRT_BASE + 0x20b0);
  128. platform_device_register(&loki_ge1_shared);
  129. platform_device_register(&loki_ge1);
  130. }
  131. /*****************************************************************************
  132. * SAS/SATA
  133. ****************************************************************************/
  134. static struct resource loki_sas_resources[] = {
  135. {
  136. .name = "mvsas0 mem",
  137. .start = SAS0_PHYS_BASE,
  138. .end = SAS0_PHYS_BASE + 0x01ff,
  139. .flags = IORESOURCE_MEM,
  140. }, {
  141. .name = "mvsas0 irq",
  142. .start = IRQ_LOKI_SAS_A,
  143. .end = IRQ_LOKI_SAS_A,
  144. .flags = IORESOURCE_IRQ,
  145. }, {
  146. .name = "mvsas1 mem",
  147. .start = SAS1_PHYS_BASE,
  148. .end = SAS1_PHYS_BASE + 0x01ff,
  149. .flags = IORESOURCE_MEM,
  150. }, {
  151. .name = "mvsas1 irq",
  152. .start = IRQ_LOKI_SAS_B,
  153. .end = IRQ_LOKI_SAS_B,
  154. .flags = IORESOURCE_IRQ,
  155. },
  156. };
  157. static struct platform_device loki_sas = {
  158. .name = "mvsas",
  159. .id = 0,
  160. .dev = {
  161. .coherent_dma_mask = 0xffffffff,
  162. },
  163. .num_resources = ARRAY_SIZE(loki_sas_resources),
  164. .resource = loki_sas_resources,
  165. };
  166. void __init loki_sas_init(void)
  167. {
  168. writel(0x8300f707, DDR_REG(0x1424));
  169. platform_device_register(&loki_sas);
  170. }
  171. /*****************************************************************************
  172. * UART0
  173. ****************************************************************************/
  174. static struct plat_serial8250_port loki_uart0_data[] = {
  175. {
  176. .mapbase = UART0_PHYS_BASE,
  177. .membase = (char *)UART0_VIRT_BASE,
  178. .irq = IRQ_LOKI_UART0,
  179. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  180. .iotype = UPIO_MEM,
  181. .regshift = 2,
  182. .uartclk = LOKI_TCLK,
  183. }, {
  184. },
  185. };
  186. static struct resource loki_uart0_resources[] = {
  187. {
  188. .start = UART0_PHYS_BASE,
  189. .end = UART0_PHYS_BASE + 0xff,
  190. .flags = IORESOURCE_MEM,
  191. }, {
  192. .start = IRQ_LOKI_UART0,
  193. .end = IRQ_LOKI_UART0,
  194. .flags = IORESOURCE_IRQ,
  195. },
  196. };
  197. static struct platform_device loki_uart0 = {
  198. .name = "serial8250",
  199. .id = 0,
  200. .dev = {
  201. .platform_data = loki_uart0_data,
  202. },
  203. .resource = loki_uart0_resources,
  204. .num_resources = ARRAY_SIZE(loki_uart0_resources),
  205. };
  206. void __init loki_uart0_init(void)
  207. {
  208. platform_device_register(&loki_uart0);
  209. }
  210. /*****************************************************************************
  211. * UART1
  212. ****************************************************************************/
  213. static struct plat_serial8250_port loki_uart1_data[] = {
  214. {
  215. .mapbase = UART1_PHYS_BASE,
  216. .membase = (char *)UART1_VIRT_BASE,
  217. .irq = IRQ_LOKI_UART1,
  218. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  219. .iotype = UPIO_MEM,
  220. .regshift = 2,
  221. .uartclk = LOKI_TCLK,
  222. }, {
  223. },
  224. };
  225. static struct resource loki_uart1_resources[] = {
  226. {
  227. .start = UART1_PHYS_BASE,
  228. .end = UART1_PHYS_BASE + 0xff,
  229. .flags = IORESOURCE_MEM,
  230. }, {
  231. .start = IRQ_LOKI_UART1,
  232. .end = IRQ_LOKI_UART1,
  233. .flags = IORESOURCE_IRQ,
  234. },
  235. };
  236. static struct platform_device loki_uart1 = {
  237. .name = "serial8250",
  238. .id = 1,
  239. .dev = {
  240. .platform_data = loki_uart1_data,
  241. },
  242. .resource = loki_uart1_resources,
  243. .num_resources = ARRAY_SIZE(loki_uart1_resources),
  244. };
  245. void __init loki_uart1_init(void)
  246. {
  247. platform_device_register(&loki_uart1);
  248. }
  249. /*****************************************************************************
  250. * Time handling
  251. ****************************************************************************/
  252. static void loki_timer_init(void)
  253. {
  254. orion_time_init(IRQ_LOKI_BRIDGE, LOKI_TCLK);
  255. }
  256. struct sys_timer loki_timer = {
  257. .init = loki_timer_init,
  258. };
  259. /*****************************************************************************
  260. * General
  261. ****************************************************************************/
  262. void __init loki_init(void)
  263. {
  264. printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK);
  265. loki_setup_cpu_mbus();
  266. }