v2m.c 16 KB

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