common.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /*
  2. * arch/arm/mach-kirkwood/common.c
  3. *
  4. * Core functions for Marvell Kirkwood 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 <linux/ata_platform.h>
  17. #include <asm/page.h>
  18. #include <asm/timex.h>
  19. #include <asm/mach/map.h>
  20. #include <asm/mach/time.h>
  21. #include <asm/arch/kirkwood.h>
  22. #include <asm/plat-orion/cache-feroceon-l2.h>
  23. #include <asm/plat-orion/ehci-orion.h>
  24. #include <asm/plat-orion/orion_nand.h>
  25. #include <asm/plat-orion/time.h>
  26. #include "common.h"
  27. /*****************************************************************************
  28. * I/O Address Mapping
  29. ****************************************************************************/
  30. static struct map_desc kirkwood_io_desc[] __initdata = {
  31. {
  32. .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE,
  33. .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE),
  34. .length = KIRKWOOD_PCIE_IO_SIZE,
  35. .type = MT_DEVICE,
  36. }, {
  37. .virtual = KIRKWOOD_REGS_VIRT_BASE,
  38. .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
  39. .length = KIRKWOOD_REGS_SIZE,
  40. .type = MT_DEVICE,
  41. },
  42. };
  43. void __init kirkwood_map_io(void)
  44. {
  45. iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
  46. }
  47. /*****************************************************************************
  48. * EHCI
  49. ****************************************************************************/
  50. static struct orion_ehci_data kirkwood_ehci_data = {
  51. .dram = &kirkwood_mbus_dram_info,
  52. };
  53. static u64 ehci_dmamask = 0xffffffffUL;
  54. /*****************************************************************************
  55. * EHCI0
  56. ****************************************************************************/
  57. static struct resource kirkwood_ehci_resources[] = {
  58. {
  59. .start = USB_PHYS_BASE,
  60. .end = USB_PHYS_BASE + 0x0fff,
  61. .flags = IORESOURCE_MEM,
  62. }, {
  63. .start = IRQ_KIRKWOOD_USB,
  64. .end = IRQ_KIRKWOOD_USB,
  65. .flags = IORESOURCE_IRQ,
  66. },
  67. };
  68. static struct platform_device kirkwood_ehci = {
  69. .name = "orion-ehci",
  70. .id = 0,
  71. .dev = {
  72. .dma_mask = &ehci_dmamask,
  73. .coherent_dma_mask = 0xffffffff,
  74. .platform_data = &kirkwood_ehci_data,
  75. },
  76. .resource = kirkwood_ehci_resources,
  77. .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
  78. };
  79. void __init kirkwood_ehci_init(void)
  80. {
  81. platform_device_register(&kirkwood_ehci);
  82. }
  83. /*****************************************************************************
  84. * GE00
  85. ****************************************************************************/
  86. struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
  87. .t_clk = KIRKWOOD_TCLK,
  88. .dram = &kirkwood_mbus_dram_info,
  89. };
  90. static struct resource kirkwood_ge00_shared_resources[] = {
  91. {
  92. .name = "ge00 base",
  93. .start = GE00_PHYS_BASE + 0x2000,
  94. .end = GE00_PHYS_BASE + 0x3fff,
  95. .flags = IORESOURCE_MEM,
  96. },
  97. };
  98. static struct platform_device kirkwood_ge00_shared = {
  99. .name = MV643XX_ETH_SHARED_NAME,
  100. .id = 0,
  101. .dev = {
  102. .platform_data = &kirkwood_ge00_shared_data,
  103. },
  104. .num_resources = 1,
  105. .resource = kirkwood_ge00_shared_resources,
  106. };
  107. static struct resource kirkwood_ge00_resources[] = {
  108. {
  109. .name = "ge00 irq",
  110. .start = IRQ_KIRKWOOD_GE00_SUM,
  111. .end = IRQ_KIRKWOOD_GE00_SUM,
  112. .flags = IORESOURCE_IRQ,
  113. },
  114. };
  115. static struct platform_device kirkwood_ge00 = {
  116. .name = MV643XX_ETH_NAME,
  117. .id = 0,
  118. .num_resources = 1,
  119. .resource = kirkwood_ge00_resources,
  120. };
  121. void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  122. {
  123. eth_data->shared = &kirkwood_ge00_shared;
  124. kirkwood_ge00.dev.platform_data = eth_data;
  125. platform_device_register(&kirkwood_ge00_shared);
  126. platform_device_register(&kirkwood_ge00);
  127. }
  128. /*****************************************************************************
  129. * SoC RTC
  130. ****************************************************************************/
  131. static struct resource kirkwood_rtc_resource = {
  132. .start = RTC_PHYS_BASE,
  133. .end = RTC_PHYS_BASE + SZ_16 - 1,
  134. .flags = IORESOURCE_MEM,
  135. };
  136. void __init kirkwood_rtc_init(void)
  137. {
  138. platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
  139. }
  140. /*****************************************************************************
  141. * SATA
  142. ****************************************************************************/
  143. static struct resource kirkwood_sata_resources[] = {
  144. {
  145. .name = "sata base",
  146. .start = SATA_PHYS_BASE,
  147. .end = SATA_PHYS_BASE + 0x5000 - 1,
  148. .flags = IORESOURCE_MEM,
  149. }, {
  150. .name = "sata irq",
  151. .start = IRQ_KIRKWOOD_SATA,
  152. .end = IRQ_KIRKWOOD_SATA,
  153. .flags = IORESOURCE_IRQ,
  154. },
  155. };
  156. static struct platform_device kirkwood_sata = {
  157. .name = "sata_mv",
  158. .id = 0,
  159. .dev = {
  160. .coherent_dma_mask = 0xffffffff,
  161. },
  162. .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
  163. .resource = kirkwood_sata_resources,
  164. };
  165. void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
  166. {
  167. sata_data->dram = &kirkwood_mbus_dram_info;
  168. kirkwood_sata.dev.platform_data = sata_data;
  169. platform_device_register(&kirkwood_sata);
  170. }
  171. /*****************************************************************************
  172. * UART0
  173. ****************************************************************************/
  174. static struct plat_serial8250_port kirkwood_uart0_data[] = {
  175. {
  176. .mapbase = UART0_PHYS_BASE,
  177. .membase = (char *)UART0_VIRT_BASE,
  178. .irq = IRQ_KIRKWOOD_UART_0,
  179. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  180. .iotype = UPIO_MEM,
  181. .regshift = 2,
  182. .uartclk = KIRKWOOD_TCLK,
  183. }, {
  184. },
  185. };
  186. static struct resource kirkwood_uart0_resources[] = {
  187. {
  188. .start = UART0_PHYS_BASE,
  189. .end = UART0_PHYS_BASE + 0xff,
  190. .flags = IORESOURCE_MEM,
  191. }, {
  192. .start = IRQ_KIRKWOOD_UART_0,
  193. .end = IRQ_KIRKWOOD_UART_0,
  194. .flags = IORESOURCE_IRQ,
  195. },
  196. };
  197. static struct platform_device kirkwood_uart0 = {
  198. .name = "serial8250",
  199. .id = 0,
  200. .dev = {
  201. .platform_data = kirkwood_uart0_data,
  202. },
  203. .resource = kirkwood_uart0_resources,
  204. .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
  205. };
  206. void __init kirkwood_uart0_init(void)
  207. {
  208. platform_device_register(&kirkwood_uart0);
  209. }
  210. /*****************************************************************************
  211. * UART1
  212. ****************************************************************************/
  213. static struct plat_serial8250_port kirkwood_uart1_data[] = {
  214. {
  215. .mapbase = UART1_PHYS_BASE,
  216. .membase = (char *)UART1_VIRT_BASE,
  217. .irq = IRQ_KIRKWOOD_UART_1,
  218. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  219. .iotype = UPIO_MEM,
  220. .regshift = 2,
  221. .uartclk = KIRKWOOD_TCLK,
  222. }, {
  223. },
  224. };
  225. static struct resource kirkwood_uart1_resources[] = {
  226. {
  227. .start = UART1_PHYS_BASE,
  228. .end = UART1_PHYS_BASE + 0xff,
  229. .flags = IORESOURCE_MEM,
  230. }, {
  231. .start = IRQ_KIRKWOOD_UART_1,
  232. .end = IRQ_KIRKWOOD_UART_1,
  233. .flags = IORESOURCE_IRQ,
  234. },
  235. };
  236. static struct platform_device kirkwood_uart1 = {
  237. .name = "serial8250",
  238. .id = 1,
  239. .dev = {
  240. .platform_data = kirkwood_uart1_data,
  241. },
  242. .resource = kirkwood_uart1_resources,
  243. .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
  244. };
  245. void __init kirkwood_uart1_init(void)
  246. {
  247. platform_device_register(&kirkwood_uart1);
  248. }
  249. /*****************************************************************************
  250. * Time handling
  251. ****************************************************************************/
  252. static void kirkwood_timer_init(void)
  253. {
  254. orion_time_init(IRQ_KIRKWOOD_BRIDGE, KIRKWOOD_TCLK);
  255. }
  256. struct sys_timer kirkwood_timer = {
  257. .init = kirkwood_timer_init,
  258. };
  259. /*****************************************************************************
  260. * General
  261. ****************************************************************************/
  262. static char * __init kirkwood_id(void)
  263. {
  264. switch (readl(DEVICE_ID) & 0x3) {
  265. case 0:
  266. return "88F6180";
  267. case 1:
  268. return "88F6192";
  269. case 2:
  270. return "88F6281";
  271. }
  272. return "unknown 88F6000 variant";
  273. }
  274. static int __init is_l2_writethrough(void)
  275. {
  276. return !!(readl(L2_CONFIG_REG) & L2_WRITETHROUGH);
  277. }
  278. void __init kirkwood_init(void)
  279. {
  280. printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
  281. kirkwood_id(), KIRKWOOD_TCLK);
  282. kirkwood_setup_cpu_mbus();
  283. #ifdef CONFIG_CACHE_FEROCEON_L2
  284. feroceon_l2_init(is_l2_writethrough());
  285. #endif
  286. }