v2m.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. /*
  2. * Versatile Express V2M Motherboard Support
  3. */
  4. #include <linux/clocksource.h>
  5. #include <linux/device.h>
  6. #include <linux/amba/bus.h>
  7. #include <linux/amba/mmci.h>
  8. #include <linux/io.h>
  9. #include <linux/clocksource.h>
  10. #include <linux/smp.h>
  11. #include <linux/init.h>
  12. #include <linux/irqchip.h>
  13. #include <linux/of_address.h>
  14. #include <linux/of_fdt.h>
  15. #include <linux/of_irq.h>
  16. #include <linux/of_platform.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/ata_platform.h>
  19. #include <linux/smsc911x.h>
  20. #include <linux/spinlock.h>
  21. #include <linux/usb/isp1760.h>
  22. #include <linux/mtd/physmap.h>
  23. #include <linux/regulator/fixed.h>
  24. #include <linux/regulator/machine.h>
  25. #include <linux/vexpress.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/sizes.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <asm/mach/time.h>
  31. #include <asm/hardware/arm_timer.h>
  32. #include <asm/hardware/cache-l2x0.h>
  33. #include <asm/hardware/timer-sp.h>
  34. #include <mach/ct-ca9x4.h>
  35. #include <mach/motherboard.h>
  36. #include <plat/sched_clock.h>
  37. #include <plat/platsmp.h>
  38. #include "core.h"
  39. #define V2M_PA_CS0 0x40000000
  40. #define V2M_PA_CS1 0x44000000
  41. #define V2M_PA_CS2 0x48000000
  42. #define V2M_PA_CS3 0x4c000000
  43. #define V2M_PA_CS7 0x10000000
  44. static struct map_desc v2m_io_desc[] __initdata = {
  45. {
  46. .virtual = V2M_PERIPH,
  47. .pfn = __phys_to_pfn(V2M_PA_CS7),
  48. .length = SZ_128K,
  49. .type = MT_DEVICE,
  50. },
  51. };
  52. static void __init v2m_sp804_init(void __iomem *base, unsigned int irq)
  53. {
  54. if (WARN_ON(!base || irq == NO_IRQ))
  55. return;
  56. sp804_clocksource_init(base + TIMER_2_BASE, "v2m-timer1");
  57. sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0");
  58. }
  59. static struct resource v2m_pcie_i2c_resource = {
  60. .start = V2M_SERIAL_BUS_PCI,
  61. .end = V2M_SERIAL_BUS_PCI + SZ_4K - 1,
  62. .flags = IORESOURCE_MEM,
  63. };
  64. static struct platform_device v2m_pcie_i2c_device = {
  65. .name = "versatile-i2c",
  66. .id = 0,
  67. .num_resources = 1,
  68. .resource = &v2m_pcie_i2c_resource,
  69. };
  70. static struct resource v2m_ddc_i2c_resource = {
  71. .start = V2M_SERIAL_BUS_DVI,
  72. .end = V2M_SERIAL_BUS_DVI + SZ_4K - 1,
  73. .flags = IORESOURCE_MEM,
  74. };
  75. static struct platform_device v2m_ddc_i2c_device = {
  76. .name = "versatile-i2c",
  77. .id = 1,
  78. .num_resources = 1,
  79. .resource = &v2m_ddc_i2c_resource,
  80. };
  81. static struct resource v2m_eth_resources[] = {
  82. {
  83. .start = V2M_LAN9118,
  84. .end = V2M_LAN9118 + SZ_64K - 1,
  85. .flags = IORESOURCE_MEM,
  86. }, {
  87. .start = IRQ_V2M_LAN9118,
  88. .end = IRQ_V2M_LAN9118,
  89. .flags = IORESOURCE_IRQ,
  90. },
  91. };
  92. static struct smsc911x_platform_config v2m_eth_config = {
  93. .flags = SMSC911X_USE_32BIT,
  94. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
  95. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  96. .phy_interface = PHY_INTERFACE_MODE_MII,
  97. };
  98. static struct platform_device v2m_eth_device = {
  99. .name = "smsc911x",
  100. .id = -1,
  101. .resource = v2m_eth_resources,
  102. .num_resources = ARRAY_SIZE(v2m_eth_resources),
  103. .dev.platform_data = &v2m_eth_config,
  104. };
  105. static struct regulator_consumer_supply v2m_eth_supplies[] = {
  106. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  107. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  108. };
  109. static struct resource v2m_usb_resources[] = {
  110. {
  111. .start = V2M_ISP1761,
  112. .end = V2M_ISP1761 + SZ_128K - 1,
  113. .flags = IORESOURCE_MEM,
  114. }, {
  115. .start = IRQ_V2M_ISP1761,
  116. .end = IRQ_V2M_ISP1761,
  117. .flags = IORESOURCE_IRQ,
  118. },
  119. };
  120. static struct isp1760_platform_data v2m_usb_config = {
  121. .is_isp1761 = true,
  122. .bus_width_16 = false,
  123. .port1_otg = true,
  124. .analog_oc = false,
  125. .dack_polarity_high = false,
  126. .dreq_polarity_high = false,
  127. };
  128. static struct platform_device v2m_usb_device = {
  129. .name = "isp1760",
  130. .id = -1,
  131. .resource = v2m_usb_resources,
  132. .num_resources = ARRAY_SIZE(v2m_usb_resources),
  133. .dev.platform_data = &v2m_usb_config,
  134. };
  135. static struct physmap_flash_data v2m_flash_data = {
  136. .width = 4,
  137. };
  138. static struct resource v2m_flash_resources[] = {
  139. {
  140. .start = V2M_NOR0,
  141. .end = V2M_NOR0 + SZ_64M - 1,
  142. .flags = IORESOURCE_MEM,
  143. }, {
  144. .start = V2M_NOR1,
  145. .end = V2M_NOR1 + SZ_64M - 1,
  146. .flags = IORESOURCE_MEM,
  147. },
  148. };
  149. static struct platform_device v2m_flash_device = {
  150. .name = "physmap-flash",
  151. .id = -1,
  152. .resource = v2m_flash_resources,
  153. .num_resources = ARRAY_SIZE(v2m_flash_resources),
  154. .dev.platform_data = &v2m_flash_data,
  155. };
  156. static struct pata_platform_info v2m_pata_data = {
  157. .ioport_shift = 2,
  158. };
  159. static struct resource v2m_pata_resources[] = {
  160. {
  161. .start = V2M_CF,
  162. .end = V2M_CF + 0xff,
  163. .flags = IORESOURCE_MEM,
  164. }, {
  165. .start = V2M_CF + 0x100,
  166. .end = V2M_CF + SZ_4K - 1,
  167. .flags = IORESOURCE_MEM,
  168. },
  169. };
  170. static struct platform_device v2m_cf_device = {
  171. .name = "pata_platform",
  172. .id = -1,
  173. .resource = v2m_pata_resources,
  174. .num_resources = ARRAY_SIZE(v2m_pata_resources),
  175. .dev.platform_data = &v2m_pata_data,
  176. };
  177. static struct mmci_platform_data v2m_mmci_data = {
  178. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  179. .gpio_wp = VEXPRESS_GPIO_MMC_WPROT,
  180. .gpio_cd = VEXPRESS_GPIO_MMC_CARDIN,
  181. };
  182. static struct resource v2m_sysreg_resources[] = {
  183. {
  184. .start = V2M_SYSREGS,
  185. .end = V2M_SYSREGS + 0xfff,
  186. .flags = IORESOURCE_MEM,
  187. },
  188. };
  189. static struct platform_device v2m_sysreg_device = {
  190. .name = "vexpress-sysreg",
  191. .id = -1,
  192. .resource = v2m_sysreg_resources,
  193. .num_resources = ARRAY_SIZE(v2m_sysreg_resources),
  194. };
  195. static struct platform_device v2m_muxfpga_device = {
  196. .name = "vexpress-muxfpga",
  197. .id = 0,
  198. .num_resources = 1,
  199. .resource = (struct resource []) {
  200. VEXPRESS_RES_FUNC(0, 7),
  201. }
  202. };
  203. static struct platform_device v2m_shutdown_device = {
  204. .name = "vexpress-shutdown",
  205. .id = 0,
  206. .num_resources = 1,
  207. .resource = (struct resource []) {
  208. VEXPRESS_RES_FUNC(0, 8),
  209. }
  210. };
  211. static struct platform_device v2m_reboot_device = {
  212. .name = "vexpress-reboot",
  213. .id = 0,
  214. .num_resources = 1,
  215. .resource = (struct resource []) {
  216. VEXPRESS_RES_FUNC(0, 9),
  217. }
  218. };
  219. static struct platform_device v2m_dvimode_device = {
  220. .name = "vexpress-dvimode",
  221. .id = 0,
  222. .num_resources = 1,
  223. .resource = (struct resource []) {
  224. VEXPRESS_RES_FUNC(0, 11),
  225. }
  226. };
  227. static AMBA_APB_DEVICE(aaci, "mb:aaci", 0, V2M_AACI, IRQ_V2M_AACI, NULL);
  228. static AMBA_APB_DEVICE(mmci, "mb:mmci", 0, V2M_MMCI, IRQ_V2M_MMCI, &v2m_mmci_data);
  229. static AMBA_APB_DEVICE(kmi0, "mb:kmi0", 0, V2M_KMI0, IRQ_V2M_KMI0, NULL);
  230. static AMBA_APB_DEVICE(kmi1, "mb:kmi1", 0, V2M_KMI1, IRQ_V2M_KMI1, NULL);
  231. static AMBA_APB_DEVICE(uart0, "mb:uart0", 0, V2M_UART0, IRQ_V2M_UART0, NULL);
  232. static AMBA_APB_DEVICE(uart1, "mb:uart1", 0, V2M_UART1, IRQ_V2M_UART1, NULL);
  233. static AMBA_APB_DEVICE(uart2, "mb:uart2", 0, V2M_UART2, IRQ_V2M_UART2, NULL);
  234. static AMBA_APB_DEVICE(uart3, "mb:uart3", 0, V2M_UART3, IRQ_V2M_UART3, NULL);
  235. static AMBA_APB_DEVICE(wdt, "mb:wdt", 0, V2M_WDT, IRQ_V2M_WDT, NULL);
  236. static AMBA_APB_DEVICE(rtc, "mb:rtc", 0, V2M_RTC, IRQ_V2M_RTC, NULL);
  237. static struct amba_device *v2m_amba_devs[] __initdata = {
  238. &aaci_device,
  239. &mmci_device,
  240. &kmi0_device,
  241. &kmi1_device,
  242. &uart0_device,
  243. &uart1_device,
  244. &uart2_device,
  245. &uart3_device,
  246. &wdt_device,
  247. &rtc_device,
  248. };
  249. static void __init v2m_timer_init(void)
  250. {
  251. vexpress_clk_init(ioremap(V2M_SYSCTL, SZ_4K));
  252. v2m_sp804_init(ioremap(V2M_TIMER01, SZ_4K), IRQ_V2M_TIMER0);
  253. }
  254. static void __init v2m_init_early(void)
  255. {
  256. if (ct_desc->init_early)
  257. ct_desc->init_early();
  258. versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
  259. }
  260. struct ct_desc *ct_desc;
  261. static struct ct_desc *ct_descs[] __initdata = {
  262. #ifdef CONFIG_ARCH_VEXPRESS_CA9X4
  263. &ct_ca9x4_desc,
  264. #endif
  265. };
  266. static void __init v2m_populate_ct_desc(void)
  267. {
  268. int i;
  269. u32 current_tile_id;
  270. ct_desc = NULL;
  271. current_tile_id = vexpress_get_procid(VEXPRESS_SITE_MASTER)
  272. & V2M_CT_ID_MASK;
  273. for (i = 0; i < ARRAY_SIZE(ct_descs) && !ct_desc; ++i)
  274. if (ct_descs[i]->id == current_tile_id)
  275. ct_desc = ct_descs[i];
  276. if (!ct_desc)
  277. panic("vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.\n"
  278. "You may need a device tree blob or a different kernel to boot on this board.\n",
  279. current_tile_id);
  280. }
  281. static void __init v2m_map_io(void)
  282. {
  283. iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
  284. vexpress_sysreg_early_init(ioremap(V2M_SYSREGS, SZ_4K));
  285. v2m_populate_ct_desc();
  286. ct_desc->map_io();
  287. }
  288. static void __init v2m_init_irq(void)
  289. {
  290. ct_desc->init_irq();
  291. }
  292. static void __init v2m_init(void)
  293. {
  294. int i;
  295. regulator_register_fixed(0, v2m_eth_supplies,
  296. ARRAY_SIZE(v2m_eth_supplies));
  297. platform_device_register(&v2m_muxfpga_device);
  298. platform_device_register(&v2m_shutdown_device);
  299. platform_device_register(&v2m_reboot_device);
  300. platform_device_register(&v2m_dvimode_device);
  301. platform_device_register(&v2m_sysreg_device);
  302. platform_device_register(&v2m_pcie_i2c_device);
  303. platform_device_register(&v2m_ddc_i2c_device);
  304. platform_device_register(&v2m_flash_device);
  305. platform_device_register(&v2m_cf_device);
  306. platform_device_register(&v2m_eth_device);
  307. platform_device_register(&v2m_usb_device);
  308. for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
  309. amba_device_register(v2m_amba_devs[i], &iomem_resource);
  310. pm_power_off = vexpress_power_off;
  311. ct_desc->init_tile();
  312. }
  313. MACHINE_START(VEXPRESS, "ARM-Versatile Express")
  314. .atag_offset = 0x100,
  315. .smp = smp_ops(vexpress_smp_ops),
  316. .map_io = v2m_map_io,
  317. .init_early = v2m_init_early,
  318. .init_irq = v2m_init_irq,
  319. .init_time = v2m_timer_init,
  320. .init_machine = v2m_init,
  321. .restart = vexpress_restart,
  322. MACHINE_END
  323. static struct map_desc v2m_rs1_io_desc __initdata = {
  324. .virtual = V2M_PERIPH,
  325. .pfn = __phys_to_pfn(0x1c000000),
  326. .length = SZ_2M,
  327. .type = MT_DEVICE,
  328. };
  329. static int __init v2m_dt_scan_memory_map(unsigned long node, const char *uname,
  330. int depth, void *data)
  331. {
  332. const char **map = data;
  333. if (strcmp(uname, "motherboard") != 0)
  334. return 0;
  335. *map = of_get_flat_dt_prop(node, "arm,v2m-memory-map", NULL);
  336. return 1;
  337. }
  338. void __init v2m_dt_map_io(void)
  339. {
  340. const char *map = NULL;
  341. of_scan_flat_dt(v2m_dt_scan_memory_map, &map);
  342. if (map && strcmp(map, "rs1") == 0)
  343. iotable_init(&v2m_rs1_io_desc, 1);
  344. else
  345. iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
  346. #if defined(CONFIG_SMP)
  347. vexpress_dt_smp_map_io();
  348. #endif
  349. }
  350. void __init v2m_dt_init_early(void)
  351. {
  352. u32 dt_hbi;
  353. vexpress_sysreg_of_early_init();
  354. /* Confirm board type against DT property, if available */
  355. if (of_property_read_u32(of_allnodes, "arm,hbi", &dt_hbi) == 0) {
  356. u32 hbi = vexpress_get_hbi(VEXPRESS_SITE_MASTER);
  357. if (WARN_ON(dt_hbi != hbi))
  358. pr_warning("vexpress: DT HBI (%x) is not matching "
  359. "hardware (%x)!\n", dt_hbi, hbi);
  360. }
  361. }
  362. static void __init v2m_dt_timer_init(void)
  363. {
  364. vexpress_clk_of_init();
  365. clocksource_of_init();
  366. versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
  367. 24000000);
  368. }
  369. static const struct of_device_id v2m_dt_bus_match[] __initconst = {
  370. { .compatible = "simple-bus", },
  371. { .compatible = "arm,amba-bus", },
  372. { .compatible = "arm,vexpress,config-bus", },
  373. {}
  374. };
  375. static void __init v2m_dt_init(void)
  376. {
  377. l2x0_of_init(0x00400000, 0xfe0fffff);
  378. of_platform_populate(NULL, v2m_dt_bus_match, NULL, NULL);
  379. pm_power_off = vexpress_power_off;
  380. }
  381. static const char * const v2m_dt_match[] __initconst = {
  382. "arm,vexpress",
  383. "xen,xenvm",
  384. NULL,
  385. };
  386. DT_MACHINE_START(VEXPRESS_DT, "ARM-Versatile Express")
  387. .dt_compat = v2m_dt_match,
  388. .smp = smp_ops(vexpress_smp_ops),
  389. .map_io = v2m_dt_map_io,
  390. .init_early = v2m_dt_init_early,
  391. .init_irq = irqchip_init,
  392. .init_time = v2m_dt_timer_init,
  393. .init_machine = v2m_dt_init,
  394. .restart = vexpress_restart,
  395. MACHINE_END