v2m.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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/clkdev.h>
  20. #include <linux/clk-provider.h>
  21. #include <linux/mtd/physmap.h>
  22. #include <linux/regulator/fixed.h>
  23. #include <linux/regulator/machine.h>
  24. #include <asm/arch_timer.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/sizes.h>
  27. #include <asm/smp_twd.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/gic.h>
  34. #include <asm/hardware/timer-sp.h>
  35. #include <asm/hardware/sp810.h>
  36. #include <mach/ct-ca9x4.h>
  37. #include <mach/motherboard.h>
  38. #include <plat/sched_clock.h>
  39. #include <plat/platsmp.h>
  40. #include "core.h"
  41. #define V2M_PA_CS0 0x40000000
  42. #define V2M_PA_CS1 0x44000000
  43. #define V2M_PA_CS2 0x48000000
  44. #define V2M_PA_CS3 0x4c000000
  45. #define V2M_PA_CS7 0x10000000
  46. static struct map_desc v2m_io_desc[] __initdata = {
  47. {
  48. .virtual = V2M_PERIPH,
  49. .pfn = __phys_to_pfn(V2M_PA_CS7),
  50. .length = SZ_128K,
  51. .type = MT_DEVICE,
  52. },
  53. };
  54. static void __iomem *v2m_sysreg_base;
  55. static void __init v2m_sysctl_init(void __iomem *base)
  56. {
  57. u32 scctrl;
  58. if (WARN_ON(!base))
  59. return;
  60. /* Select 1MHz TIMCLK as the reference clock for SP804 timers */
  61. scctrl = readl(base + SCCTRL);
  62. scctrl |= SCCTRL_TIMEREN0SEL_TIMCLK;
  63. scctrl |= SCCTRL_TIMEREN1SEL_TIMCLK;
  64. writel(scctrl, base + SCCTRL);
  65. }
  66. static void __init v2m_sp804_init(void __iomem *base, unsigned int irq)
  67. {
  68. if (WARN_ON(!base || irq == NO_IRQ))
  69. return;
  70. writel(0, base + TIMER_1_BASE + TIMER_CTRL);
  71. writel(0, base + TIMER_2_BASE + TIMER_CTRL);
  72. sp804_clocksource_init(base + TIMER_2_BASE, "v2m-timer1");
  73. sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0");
  74. }
  75. static DEFINE_SPINLOCK(v2m_cfg_lock);
  76. int v2m_cfg_write(u32 devfn, u32 data)
  77. {
  78. /* Configuration interface broken? */
  79. u32 val;
  80. printk("%s: writing %08x to %08x\n", __func__, data, devfn);
  81. devfn |= SYS_CFG_START | SYS_CFG_WRITE;
  82. spin_lock(&v2m_cfg_lock);
  83. val = readl(v2m_sysreg_base + V2M_SYS_CFGSTAT);
  84. writel(val & ~SYS_CFG_COMPLETE, v2m_sysreg_base + V2M_SYS_CFGSTAT);
  85. writel(data, v2m_sysreg_base + V2M_SYS_CFGDATA);
  86. writel(devfn, v2m_sysreg_base + V2M_SYS_CFGCTRL);
  87. do {
  88. val = readl(v2m_sysreg_base + V2M_SYS_CFGSTAT);
  89. } while (val == 0);
  90. spin_unlock(&v2m_cfg_lock);
  91. return !!(val & SYS_CFG_ERR);
  92. }
  93. int v2m_cfg_read(u32 devfn, u32 *data)
  94. {
  95. u32 val;
  96. devfn |= SYS_CFG_START;
  97. spin_lock(&v2m_cfg_lock);
  98. writel(0, v2m_sysreg_base + V2M_SYS_CFGSTAT);
  99. writel(devfn, v2m_sysreg_base + V2M_SYS_CFGCTRL);
  100. mb();
  101. do {
  102. cpu_relax();
  103. val = readl(v2m_sysreg_base + V2M_SYS_CFGSTAT);
  104. } while (val == 0);
  105. *data = readl(v2m_sysreg_base + V2M_SYS_CFGDATA);
  106. spin_unlock(&v2m_cfg_lock);
  107. return !!(val & SYS_CFG_ERR);
  108. }
  109. void __init v2m_flags_set(u32 data)
  110. {
  111. writel(~0, v2m_sysreg_base + V2M_SYS_FLAGSCLR);
  112. writel(data, v2m_sysreg_base + V2M_SYS_FLAGSSET);
  113. }
  114. int v2m_get_master_site(void)
  115. {
  116. u32 misc = readl(v2m_sysreg_base + V2M_SYS_MISC);
  117. return misc & SYS_MISC_MASTERSITE ? SYS_CFG_SITE_DB2 : SYS_CFG_SITE_DB1;
  118. }
  119. static struct resource v2m_pcie_i2c_resource = {
  120. .start = V2M_SERIAL_BUS_PCI,
  121. .end = V2M_SERIAL_BUS_PCI + SZ_4K - 1,
  122. .flags = IORESOURCE_MEM,
  123. };
  124. static struct platform_device v2m_pcie_i2c_device = {
  125. .name = "versatile-i2c",
  126. .id = 0,
  127. .num_resources = 1,
  128. .resource = &v2m_pcie_i2c_resource,
  129. };
  130. static struct resource v2m_ddc_i2c_resource = {
  131. .start = V2M_SERIAL_BUS_DVI,
  132. .end = V2M_SERIAL_BUS_DVI + SZ_4K - 1,
  133. .flags = IORESOURCE_MEM,
  134. };
  135. static struct platform_device v2m_ddc_i2c_device = {
  136. .name = "versatile-i2c",
  137. .id = 1,
  138. .num_resources = 1,
  139. .resource = &v2m_ddc_i2c_resource,
  140. };
  141. static struct resource v2m_eth_resources[] = {
  142. {
  143. .start = V2M_LAN9118,
  144. .end = V2M_LAN9118 + SZ_64K - 1,
  145. .flags = IORESOURCE_MEM,
  146. }, {
  147. .start = IRQ_V2M_LAN9118,
  148. .end = IRQ_V2M_LAN9118,
  149. .flags = IORESOURCE_IRQ,
  150. },
  151. };
  152. static struct smsc911x_platform_config v2m_eth_config = {
  153. .flags = SMSC911X_USE_32BIT,
  154. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
  155. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  156. .phy_interface = PHY_INTERFACE_MODE_MII,
  157. };
  158. static struct platform_device v2m_eth_device = {
  159. .name = "smsc911x",
  160. .id = -1,
  161. .resource = v2m_eth_resources,
  162. .num_resources = ARRAY_SIZE(v2m_eth_resources),
  163. .dev.platform_data = &v2m_eth_config,
  164. };
  165. static struct regulator_consumer_supply v2m_eth_supplies[] = {
  166. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  167. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  168. };
  169. static struct resource v2m_usb_resources[] = {
  170. {
  171. .start = V2M_ISP1761,
  172. .end = V2M_ISP1761 + SZ_128K - 1,
  173. .flags = IORESOURCE_MEM,
  174. }, {
  175. .start = IRQ_V2M_ISP1761,
  176. .end = IRQ_V2M_ISP1761,
  177. .flags = IORESOURCE_IRQ,
  178. },
  179. };
  180. static struct isp1760_platform_data v2m_usb_config = {
  181. .is_isp1761 = true,
  182. .bus_width_16 = false,
  183. .port1_otg = true,
  184. .analog_oc = false,
  185. .dack_polarity_high = false,
  186. .dreq_polarity_high = false,
  187. };
  188. static struct platform_device v2m_usb_device = {
  189. .name = "isp1760",
  190. .id = -1,
  191. .resource = v2m_usb_resources,
  192. .num_resources = ARRAY_SIZE(v2m_usb_resources),
  193. .dev.platform_data = &v2m_usb_config,
  194. };
  195. static void v2m_flash_set_vpp(struct platform_device *pdev, int on)
  196. {
  197. writel(on != 0, v2m_sysreg_base + V2M_SYS_FLASH);
  198. }
  199. static struct physmap_flash_data v2m_flash_data = {
  200. .width = 4,
  201. .set_vpp = v2m_flash_set_vpp,
  202. };
  203. static struct resource v2m_flash_resources[] = {
  204. {
  205. .start = V2M_NOR0,
  206. .end = V2M_NOR0 + SZ_64M - 1,
  207. .flags = IORESOURCE_MEM,
  208. }, {
  209. .start = V2M_NOR1,
  210. .end = V2M_NOR1 + SZ_64M - 1,
  211. .flags = IORESOURCE_MEM,
  212. },
  213. };
  214. static struct platform_device v2m_flash_device = {
  215. .name = "physmap-flash",
  216. .id = -1,
  217. .resource = v2m_flash_resources,
  218. .num_resources = ARRAY_SIZE(v2m_flash_resources),
  219. .dev.platform_data = &v2m_flash_data,
  220. };
  221. static struct pata_platform_info v2m_pata_data = {
  222. .ioport_shift = 2,
  223. };
  224. static struct resource v2m_pata_resources[] = {
  225. {
  226. .start = V2M_CF,
  227. .end = V2M_CF + 0xff,
  228. .flags = IORESOURCE_MEM,
  229. }, {
  230. .start = V2M_CF + 0x100,
  231. .end = V2M_CF + SZ_4K - 1,
  232. .flags = IORESOURCE_MEM,
  233. },
  234. };
  235. static struct platform_device v2m_cf_device = {
  236. .name = "pata_platform",
  237. .id = -1,
  238. .resource = v2m_pata_resources,
  239. .num_resources = ARRAY_SIZE(v2m_pata_resources),
  240. .dev.platform_data = &v2m_pata_data,
  241. };
  242. static unsigned int v2m_mmci_status(struct device *dev)
  243. {
  244. return readl(v2m_sysreg_base + V2M_SYS_MCI) & (1 << 0);
  245. }
  246. static struct mmci_platform_data v2m_mmci_data = {
  247. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  248. .status = v2m_mmci_status,
  249. };
  250. static AMBA_APB_DEVICE(aaci, "mb:aaci", 0, V2M_AACI, IRQ_V2M_AACI, NULL);
  251. static AMBA_APB_DEVICE(mmci, "mb:mmci", 0, V2M_MMCI, IRQ_V2M_MMCI, &v2m_mmci_data);
  252. static AMBA_APB_DEVICE(kmi0, "mb:kmi0", 0, V2M_KMI0, IRQ_V2M_KMI0, NULL);
  253. static AMBA_APB_DEVICE(kmi1, "mb:kmi1", 0, V2M_KMI1, IRQ_V2M_KMI1, NULL);
  254. static AMBA_APB_DEVICE(uart0, "mb:uart0", 0, V2M_UART0, IRQ_V2M_UART0, NULL);
  255. static AMBA_APB_DEVICE(uart1, "mb:uart1", 0, V2M_UART1, IRQ_V2M_UART1, NULL);
  256. static AMBA_APB_DEVICE(uart2, "mb:uart2", 0, V2M_UART2, IRQ_V2M_UART2, NULL);
  257. static AMBA_APB_DEVICE(uart3, "mb:uart3", 0, V2M_UART3, IRQ_V2M_UART3, NULL);
  258. static AMBA_APB_DEVICE(wdt, "mb:wdt", 0, V2M_WDT, IRQ_V2M_WDT, NULL);
  259. static AMBA_APB_DEVICE(rtc, "mb:rtc", 0, V2M_RTC, IRQ_V2M_RTC, NULL);
  260. static struct amba_device *v2m_amba_devs[] __initdata = {
  261. &aaci_device,
  262. &mmci_device,
  263. &kmi0_device,
  264. &kmi1_device,
  265. &uart0_device,
  266. &uart1_device,
  267. &uart2_device,
  268. &uart3_device,
  269. &wdt_device,
  270. &rtc_device,
  271. };
  272. static unsigned long v2m_osc_recalc_rate(struct clk_hw *hw,
  273. unsigned long parent_rate)
  274. {
  275. struct v2m_osc *osc = to_v2m_osc(hw);
  276. return !parent_rate ? osc->rate_default : parent_rate;
  277. }
  278. static long v2m_osc_round_rate(struct clk_hw *hw, unsigned long rate,
  279. unsigned long *parent_rate)
  280. {
  281. struct v2m_osc *osc = to_v2m_osc(hw);
  282. if (WARN_ON(rate < osc->rate_min))
  283. rate = osc->rate_min;
  284. if (WARN_ON(rate > osc->rate_max))
  285. rate = osc->rate_max;
  286. return rate;
  287. }
  288. static int v2m_osc_set_rate(struct clk_hw *hw, unsigned long rate,
  289. unsigned long parent_rate)
  290. {
  291. struct v2m_osc *osc = to_v2m_osc(hw);
  292. v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE(osc->site) |
  293. SYS_CFG_STACK(osc->stack) | osc->osc, rate);
  294. return 0;
  295. }
  296. static struct clk_ops v2m_osc_ops = {
  297. .recalc_rate = v2m_osc_recalc_rate,
  298. .round_rate = v2m_osc_round_rate,
  299. .set_rate = v2m_osc_set_rate,
  300. };
  301. struct clk * __init v2m_osc_register(const char *name, struct v2m_osc *osc)
  302. {
  303. struct clk_init_data init;
  304. WARN_ON(osc->site > 2);
  305. WARN_ON(osc->stack > 15);
  306. WARN_ON(osc->osc > 4095);
  307. init.name = name;
  308. init.ops = &v2m_osc_ops;
  309. init.flags = CLK_IS_ROOT;
  310. init.num_parents = 0;
  311. osc->hw.init = &init;
  312. return clk_register(NULL, &osc->hw);
  313. }
  314. static struct v2m_osc v2m_mb_osc1 = {
  315. .site = SYS_CFG_SITE_MB,
  316. .osc = 1,
  317. .rate_min = 23750000,
  318. .rate_max = 63500000,
  319. .rate_default = 23750000,
  320. };
  321. static const char *v2m_ref_clk_periphs[] __initconst = {
  322. "mb:wdt", "1000f000.wdt", "1c0f0000.wdt", /* SP805 WDT */
  323. };
  324. static const char *v2m_osc1_periphs[] __initconst = {
  325. "mb:clcd", "1001f000.clcd", "1c1f0000.clcd", /* PL111 CLCD */
  326. };
  327. static const char *v2m_osc2_periphs[] __initconst = {
  328. "mb:mmci", "10005000.mmci", "1c050000.mmci", /* PL180 MMCI */
  329. "mb:kmi0", "10006000.kmi", "1c060000.kmi", /* PL050 KMI0 */
  330. "mb:kmi1", "10007000.kmi", "1c070000.kmi", /* PL050 KMI1 */
  331. "mb:uart0", "10009000.uart", "1c090000.uart", /* PL011 UART0 */
  332. "mb:uart1", "1000a000.uart", "1c0a0000.uart", /* PL011 UART1 */
  333. "mb:uart2", "1000b000.uart", "1c0b0000.uart", /* PL011 UART2 */
  334. "mb:uart3", "1000c000.uart", "1c0c0000.uart", /* PL011 UART3 */
  335. };
  336. static void __init v2m_clk_init(void)
  337. {
  338. struct clk *clk;
  339. int i;
  340. clk = clk_register_fixed_rate(NULL, "dummy_apb_pclk", NULL,
  341. CLK_IS_ROOT, 0);
  342. WARN_ON(clk_register_clkdev(clk, "apb_pclk", NULL));
  343. clk = clk_register_fixed_rate(NULL, "mb:ref_clk", NULL,
  344. CLK_IS_ROOT, 32768);
  345. for (i = 0; i < ARRAY_SIZE(v2m_ref_clk_periphs); i++)
  346. WARN_ON(clk_register_clkdev(clk, NULL, v2m_ref_clk_periphs[i]));
  347. clk = clk_register_fixed_rate(NULL, "mb:sp804_clk", NULL,
  348. CLK_IS_ROOT, 1000000);
  349. WARN_ON(clk_register_clkdev(clk, "v2m-timer0", "sp804"));
  350. WARN_ON(clk_register_clkdev(clk, "v2m-timer1", "sp804"));
  351. clk = v2m_osc_register("mb:osc1", &v2m_mb_osc1);
  352. for (i = 0; i < ARRAY_SIZE(v2m_osc1_periphs); i++)
  353. WARN_ON(clk_register_clkdev(clk, NULL, v2m_osc1_periphs[i]));
  354. clk = clk_register_fixed_rate(NULL, "mb:osc2", NULL,
  355. CLK_IS_ROOT, 24000000);
  356. for (i = 0; i < ARRAY_SIZE(v2m_osc2_periphs); i++)
  357. WARN_ON(clk_register_clkdev(clk, NULL, v2m_osc2_periphs[i]));
  358. }
  359. static void __init v2m_timer_init(void)
  360. {
  361. v2m_sysctl_init(ioremap(V2M_SYSCTL, SZ_4K));
  362. v2m_clk_init();
  363. v2m_sp804_init(ioremap(V2M_TIMER01, SZ_4K), IRQ_V2M_TIMER0);
  364. }
  365. static struct sys_timer v2m_timer = {
  366. .init = v2m_timer_init,
  367. };
  368. static void __init v2m_init_early(void)
  369. {
  370. if (ct_desc->init_early)
  371. ct_desc->init_early();
  372. versatile_sched_clock_init(v2m_sysreg_base + V2M_SYS_24MHZ, 24000000);
  373. }
  374. static void v2m_power_off(void)
  375. {
  376. if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE(SYS_CFG_SITE_MB), 0))
  377. printk(KERN_EMERG "Unable to shutdown\n");
  378. }
  379. static void v2m_restart(char str, const char *cmd)
  380. {
  381. if (v2m_cfg_write(SYS_CFG_REBOOT | SYS_CFG_SITE(SYS_CFG_SITE_MB), 0))
  382. printk(KERN_EMERG "Unable to reboot\n");
  383. }
  384. struct ct_desc *ct_desc;
  385. static struct ct_desc *ct_descs[] __initdata = {
  386. #ifdef CONFIG_ARCH_VEXPRESS_CA9X4
  387. &ct_ca9x4_desc,
  388. #endif
  389. };
  390. static void __init v2m_populate_ct_desc(void)
  391. {
  392. int i;
  393. u32 current_tile_id;
  394. ct_desc = NULL;
  395. current_tile_id = readl(v2m_sysreg_base + V2M_SYS_PROCID0)
  396. & V2M_CT_ID_MASK;
  397. for (i = 0; i < ARRAY_SIZE(ct_descs) && !ct_desc; ++i)
  398. if (ct_descs[i]->id == current_tile_id)
  399. ct_desc = ct_descs[i];
  400. if (!ct_desc)
  401. panic("vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.\n"
  402. "You may need a device tree blob or a different kernel to boot on this board.\n",
  403. current_tile_id);
  404. }
  405. static void __init v2m_map_io(void)
  406. {
  407. iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
  408. v2m_sysreg_base = ioremap(V2M_SYSREGS, SZ_4K);
  409. v2m_populate_ct_desc();
  410. ct_desc->map_io();
  411. }
  412. static void __init v2m_init_irq(void)
  413. {
  414. ct_desc->init_irq();
  415. }
  416. static void __init v2m_init(void)
  417. {
  418. int i;
  419. regulator_register_fixed(0, v2m_eth_supplies,
  420. ARRAY_SIZE(v2m_eth_supplies));
  421. platform_device_register(&v2m_pcie_i2c_device);
  422. platform_device_register(&v2m_ddc_i2c_device);
  423. platform_device_register(&v2m_flash_device);
  424. platform_device_register(&v2m_cf_device);
  425. platform_device_register(&v2m_eth_device);
  426. platform_device_register(&v2m_usb_device);
  427. for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
  428. amba_device_register(v2m_amba_devs[i], &iomem_resource);
  429. pm_power_off = v2m_power_off;
  430. ct_desc->init_tile();
  431. }
  432. MACHINE_START(VEXPRESS, "ARM-Versatile Express")
  433. .atag_offset = 0x100,
  434. .smp = smp_ops(vexpress_smp_ops),
  435. .map_io = v2m_map_io,
  436. .init_early = v2m_init_early,
  437. .init_irq = v2m_init_irq,
  438. .timer = &v2m_timer,
  439. .handle_irq = gic_handle_irq,
  440. .init_machine = v2m_init,
  441. .restart = v2m_restart,
  442. MACHINE_END
  443. static struct map_desc v2m_rs1_io_desc __initdata = {
  444. .virtual = V2M_PERIPH,
  445. .pfn = __phys_to_pfn(0x1c000000),
  446. .length = SZ_2M,
  447. .type = MT_DEVICE,
  448. };
  449. static int __init v2m_dt_scan_memory_map(unsigned long node, const char *uname,
  450. int depth, void *data)
  451. {
  452. const char **map = data;
  453. if (strcmp(uname, "motherboard") != 0)
  454. return 0;
  455. *map = of_get_flat_dt_prop(node, "arm,v2m-memory-map", NULL);
  456. return 1;
  457. }
  458. void __init v2m_dt_map_io(void)
  459. {
  460. const char *map = NULL;
  461. of_scan_flat_dt(v2m_dt_scan_memory_map, &map);
  462. if (map && strcmp(map, "rs1") == 0)
  463. iotable_init(&v2m_rs1_io_desc, 1);
  464. else
  465. iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
  466. #if defined(CONFIG_SMP)
  467. vexpress_dt_smp_map_io();
  468. #endif
  469. }
  470. void __init v2m_dt_init_early(void)
  471. {
  472. struct device_node *node;
  473. u32 dt_hbi;
  474. node = of_find_compatible_node(NULL, NULL, "arm,vexpress-sysreg");
  475. v2m_sysreg_base = of_iomap(node, 0);
  476. if (WARN_ON(!v2m_sysreg_base))
  477. return;
  478. /* Confirm board type against DT property, if available */
  479. if (of_property_read_u32(allnodes, "arm,hbi", &dt_hbi) == 0) {
  480. int site = v2m_get_master_site();
  481. u32 id = readl(v2m_sysreg_base + (site == SYS_CFG_SITE_DB2 ?
  482. V2M_SYS_PROCID1 : V2M_SYS_PROCID0));
  483. u32 hbi = id & SYS_PROCIDx_HBI_MASK;
  484. if (WARN_ON(dt_hbi != hbi))
  485. pr_warning("vexpress: DT HBI (%x) is not matching "
  486. "hardware (%x)!\n", dt_hbi, hbi);
  487. }
  488. }
  489. static struct of_device_id vexpress_irq_match[] __initdata = {
  490. { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
  491. {}
  492. };
  493. static void __init v2m_dt_init_irq(void)
  494. {
  495. of_irq_init(vexpress_irq_match);
  496. }
  497. static void __init v2m_dt_timer_init(void)
  498. {
  499. struct device_node *node;
  500. const char *path;
  501. int err;
  502. node = of_find_compatible_node(NULL, NULL, "arm,sp810");
  503. v2m_sysctl_init(of_iomap(node, 0));
  504. v2m_clk_init();
  505. err = of_property_read_string(of_aliases, "arm,v2m_timer", &path);
  506. if (WARN_ON(err))
  507. return;
  508. node = of_find_node_by_path(path);
  509. v2m_sp804_init(of_iomap(node, 0), irq_of_parse_and_map(node, 0));
  510. if (arch_timer_of_register() != 0)
  511. twd_local_timer_of_register();
  512. if (arch_timer_sched_clock_init() != 0)
  513. versatile_sched_clock_init(v2m_sysreg_base + V2M_SYS_24MHZ, 24000000);
  514. }
  515. static struct sys_timer v2m_dt_timer = {
  516. .init = v2m_dt_timer_init,
  517. };
  518. static struct of_dev_auxdata v2m_dt_auxdata_lookup[] __initdata = {
  519. OF_DEV_AUXDATA("arm,vexpress-flash", V2M_NOR0, "physmap-flash",
  520. &v2m_flash_data),
  521. OF_DEV_AUXDATA("arm,primecell", V2M_MMCI, "mb:mmci", &v2m_mmci_data),
  522. /* RS1 memory map */
  523. OF_DEV_AUXDATA("arm,vexpress-flash", 0x08000000, "physmap-flash",
  524. &v2m_flash_data),
  525. OF_DEV_AUXDATA("arm,primecell", 0x1c050000, "mb:mmci", &v2m_mmci_data),
  526. {}
  527. };
  528. static void __init v2m_dt_init(void)
  529. {
  530. l2x0_of_init(0x00400000, 0xfe0fffff);
  531. of_platform_populate(NULL, of_default_bus_match_table,
  532. v2m_dt_auxdata_lookup, NULL);
  533. pm_power_off = v2m_power_off;
  534. }
  535. const static char *v2m_dt_match[] __initconst = {
  536. "arm,vexpress",
  537. "xen,xenvm",
  538. NULL,
  539. };
  540. DT_MACHINE_START(VEXPRESS_DT, "ARM-Versatile Express")
  541. .dt_compat = v2m_dt_match,
  542. .smp = smp_ops(vexpress_smp_ops),
  543. .map_io = v2m_dt_map_io,
  544. .init_early = v2m_dt_init_early,
  545. .init_irq = v2m_dt_init_irq,
  546. .timer = &v2m_dt_timer,
  547. .init_machine = v2m_dt_init,
  548. .handle_irq = gic_handle_irq,
  549. .restart = v2m_restart,
  550. MACHINE_END