v2m.c 16 KB

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