v2m.c 16 KB

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