v2m.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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. .status = vexpress_get_mci_cardin,
  178. .gpio_cd = -1,
  179. .gpio_wp = -1,
  180. };
  181. static struct resource v2m_sysreg_resources[] = {
  182. {
  183. .start = V2M_SYSREGS,
  184. .end = V2M_SYSREGS + 0xfff,
  185. .flags = IORESOURCE_MEM,
  186. },
  187. };
  188. static struct platform_device v2m_sysreg_device = {
  189. .name = "vexpress-sysreg",
  190. .id = -1,
  191. .resource = v2m_sysreg_resources,
  192. .num_resources = ARRAY_SIZE(v2m_sysreg_resources),
  193. };
  194. static struct platform_device v2m_muxfpga_device = {
  195. .name = "vexpress-muxfpga",
  196. .id = 0,
  197. .num_resources = 1,
  198. .resource = (struct resource []) {
  199. VEXPRESS_RES_FUNC(0, 7),
  200. }
  201. };
  202. static struct platform_device v2m_shutdown_device = {
  203. .name = "vexpress-shutdown",
  204. .id = 0,
  205. .num_resources = 1,
  206. .resource = (struct resource []) {
  207. VEXPRESS_RES_FUNC(0, 8),
  208. }
  209. };
  210. static struct platform_device v2m_reboot_device = {
  211. .name = "vexpress-reboot",
  212. .id = 0,
  213. .num_resources = 1,
  214. .resource = (struct resource []) {
  215. VEXPRESS_RES_FUNC(0, 9),
  216. }
  217. };
  218. static struct platform_device v2m_dvimode_device = {
  219. .name = "vexpress-dvimode",
  220. .id = 0,
  221. .num_resources = 1,
  222. .resource = (struct resource []) {
  223. VEXPRESS_RES_FUNC(0, 11),
  224. }
  225. };
  226. static AMBA_APB_DEVICE(aaci, "mb:aaci", 0, V2M_AACI, IRQ_V2M_AACI, NULL);
  227. static AMBA_APB_DEVICE(mmci, "mb:mmci", 0, V2M_MMCI, IRQ_V2M_MMCI, &v2m_mmci_data);
  228. static AMBA_APB_DEVICE(kmi0, "mb:kmi0", 0, V2M_KMI0, IRQ_V2M_KMI0, NULL);
  229. static AMBA_APB_DEVICE(kmi1, "mb:kmi1", 0, V2M_KMI1, IRQ_V2M_KMI1, NULL);
  230. static AMBA_APB_DEVICE(uart0, "mb:uart0", 0, V2M_UART0, IRQ_V2M_UART0, NULL);
  231. static AMBA_APB_DEVICE(uart1, "mb:uart1", 0, V2M_UART1, IRQ_V2M_UART1, NULL);
  232. static AMBA_APB_DEVICE(uart2, "mb:uart2", 0, V2M_UART2, IRQ_V2M_UART2, NULL);
  233. static AMBA_APB_DEVICE(uart3, "mb:uart3", 0, V2M_UART3, IRQ_V2M_UART3, NULL);
  234. static AMBA_APB_DEVICE(wdt, "mb:wdt", 0, V2M_WDT, IRQ_V2M_WDT, NULL);
  235. static AMBA_APB_DEVICE(rtc, "mb:rtc", 0, V2M_RTC, IRQ_V2M_RTC, NULL);
  236. static struct amba_device *v2m_amba_devs[] __initdata = {
  237. &aaci_device,
  238. &mmci_device,
  239. &kmi0_device,
  240. &kmi1_device,
  241. &uart0_device,
  242. &uart1_device,
  243. &uart2_device,
  244. &uart3_device,
  245. &wdt_device,
  246. &rtc_device,
  247. };
  248. static void __init v2m_timer_init(void)
  249. {
  250. vexpress_clk_init(ioremap(V2M_SYSCTL, SZ_4K));
  251. v2m_sp804_init(ioremap(V2M_TIMER01, SZ_4K), IRQ_V2M_TIMER0);
  252. }
  253. static void __init v2m_init_early(void)
  254. {
  255. if (ct_desc->init_early)
  256. ct_desc->init_early();
  257. versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
  258. }
  259. struct ct_desc *ct_desc;
  260. static struct ct_desc *ct_descs[] __initdata = {
  261. #ifdef CONFIG_ARCH_VEXPRESS_CA9X4
  262. &ct_ca9x4_desc,
  263. #endif
  264. };
  265. static void __init v2m_populate_ct_desc(void)
  266. {
  267. int i;
  268. u32 current_tile_id;
  269. ct_desc = NULL;
  270. current_tile_id = vexpress_get_procid(VEXPRESS_SITE_MASTER)
  271. & V2M_CT_ID_MASK;
  272. for (i = 0; i < ARRAY_SIZE(ct_descs) && !ct_desc; ++i)
  273. if (ct_descs[i]->id == current_tile_id)
  274. ct_desc = ct_descs[i];
  275. if (!ct_desc)
  276. panic("vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.\n"
  277. "You may need a device tree blob or a different kernel to boot on this board.\n",
  278. current_tile_id);
  279. }
  280. static void __init v2m_map_io(void)
  281. {
  282. iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
  283. vexpress_sysreg_early_init(ioremap(V2M_SYSREGS, SZ_4K));
  284. v2m_populate_ct_desc();
  285. ct_desc->map_io();
  286. }
  287. static void __init v2m_init_irq(void)
  288. {
  289. ct_desc->init_irq();
  290. }
  291. static void __init v2m_init(void)
  292. {
  293. int i;
  294. regulator_register_fixed(0, v2m_eth_supplies,
  295. ARRAY_SIZE(v2m_eth_supplies));
  296. platform_device_register(&v2m_sysreg_device);
  297. platform_device_register(&v2m_pcie_i2c_device);
  298. platform_device_register(&v2m_ddc_i2c_device);
  299. platform_device_register(&v2m_flash_device);
  300. platform_device_register(&v2m_cf_device);
  301. platform_device_register(&v2m_eth_device);
  302. platform_device_register(&v2m_usb_device);
  303. for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
  304. amba_device_register(v2m_amba_devs[i], &iomem_resource);
  305. vexpress_syscfg_device_register(&v2m_muxfpga_device);
  306. vexpress_syscfg_device_register(&v2m_shutdown_device);
  307. vexpress_syscfg_device_register(&v2m_reboot_device);
  308. vexpress_syscfg_device_register(&v2m_dvimode_device);
  309. ct_desc->init_tile();
  310. }
  311. MACHINE_START(VEXPRESS, "ARM-Versatile Express")
  312. .atag_offset = 0x100,
  313. .smp = smp_ops(vexpress_smp_ops),
  314. .map_io = v2m_map_io,
  315. .init_early = v2m_init_early,
  316. .init_irq = v2m_init_irq,
  317. .init_time = v2m_timer_init,
  318. .init_machine = v2m_init,
  319. MACHINE_END
  320. static void __init v2m_dt_init(void)
  321. {
  322. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  323. }
  324. static const char * const v2m_dt_match[] __initconst = {
  325. "arm,vexpress",
  326. NULL,
  327. };
  328. DT_MACHINE_START(VEXPRESS_DT, "ARM-Versatile Express")
  329. .dt_compat = v2m_dt_match,
  330. .l2c_aux_val = 0x00400000,
  331. .l2c_aux_mask = 0xfe0fffff,
  332. .smp = smp_ops(vexpress_smp_dt_ops),
  333. .smp_init = smp_init_ops(vexpress_smp_init_ops),
  334. .init_machine = v2m_dt_init,
  335. MACHINE_END