v2m.c 11 KB

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