v2m.c 16 KB

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