integrator_ap.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. /*
  2. * linux/arch/arm/mach-integrator/integrator_ap.c
  3. *
  4. * Copyright (C) 2000-2003 Deep Blue Solutions Ltd
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/types.h>
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/list.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/slab.h>
  26. #include <linux/string.h>
  27. #include <linux/syscore_ops.h>
  28. #include <linux/amba/bus.h>
  29. #include <linux/amba/kmi.h>
  30. #include <linux/clocksource.h>
  31. #include <linux/clockchips.h>
  32. #include <linux/interrupt.h>
  33. #include <linux/io.h>
  34. #include <linux/irqchip/versatile-fpga.h>
  35. #include <linux/mtd/physmap.h>
  36. #include <linux/clk.h>
  37. #include <linux/platform_data/clk-integrator.h>
  38. #include <linux/of_irq.h>
  39. #include <linux/of_address.h>
  40. #include <linux/of_platform.h>
  41. #include <linux/stat.h>
  42. #include <linux/sys_soc.h>
  43. #include <linux/termios.h>
  44. #include <video/vga.h>
  45. #include <mach/hardware.h>
  46. #include <mach/platform.h>
  47. #include <asm/hardware/arm_timer.h>
  48. #include <asm/setup.h>
  49. #include <asm/param.h> /* HZ */
  50. #include <asm/mach-types.h>
  51. #include <asm/sched_clock.h>
  52. #include <mach/lm.h>
  53. #include <mach/irqs.h>
  54. #include <asm/mach/arch.h>
  55. #include <asm/mach/irq.h>
  56. #include <asm/mach/map.h>
  57. #include <asm/mach/pci.h>
  58. #include <asm/mach/time.h>
  59. #include "common.h"
  60. /* Base address to the AP system controller */
  61. void __iomem *ap_syscon_base;
  62. /*
  63. * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
  64. * is the (PA >> 12).
  65. *
  66. * Setup a VA for the Integrator interrupt controller (for header #0,
  67. * just for now).
  68. */
  69. #define VA_IC_BASE __io_address(INTEGRATOR_IC_BASE)
  70. #define VA_EBI_BASE __io_address(INTEGRATOR_EBI_BASE)
  71. #define VA_CMIC_BASE __io_address(INTEGRATOR_HDR_IC)
  72. /*
  73. * Logical Physical
  74. * e8000000 40000000 PCI memory PHYS_PCI_MEM_BASE (max 512M)
  75. * ec000000 61000000 PCI config space PHYS_PCI_CONFIG_BASE (max 16M)
  76. * fee00000 60000000 PCI IO PHYS_PCI_IO_BASE (max 16M)
  77. * ef000000 Cache flush
  78. * f1000000 10000000 Core module registers
  79. * f1100000 11000000 System controller registers
  80. * f1200000 12000000 EBI registers
  81. * f1300000 13000000 Counter/Timer
  82. * f1400000 14000000 Interrupt controller
  83. * f1600000 16000000 UART 0
  84. * f1700000 17000000 UART 1
  85. * f1a00000 1a000000 Debug LEDs
  86. * f1b00000 1b000000 GPIO
  87. */
  88. static struct map_desc ap_io_desc[] __initdata __maybe_unused = {
  89. {
  90. .virtual = IO_ADDRESS(INTEGRATOR_HDR_BASE),
  91. .pfn = __phys_to_pfn(INTEGRATOR_HDR_BASE),
  92. .length = SZ_4K,
  93. .type = MT_DEVICE
  94. }, {
  95. .virtual = IO_ADDRESS(INTEGRATOR_EBI_BASE),
  96. .pfn = __phys_to_pfn(INTEGRATOR_EBI_BASE),
  97. .length = SZ_4K,
  98. .type = MT_DEVICE
  99. }, {
  100. .virtual = IO_ADDRESS(INTEGRATOR_CT_BASE),
  101. .pfn = __phys_to_pfn(INTEGRATOR_CT_BASE),
  102. .length = SZ_4K,
  103. .type = MT_DEVICE
  104. }, {
  105. .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE),
  106. .pfn = __phys_to_pfn(INTEGRATOR_IC_BASE),
  107. .length = SZ_4K,
  108. .type = MT_DEVICE
  109. }, {
  110. .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE),
  111. .pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE),
  112. .length = SZ_4K,
  113. .type = MT_DEVICE
  114. }, {
  115. .virtual = IO_ADDRESS(INTEGRATOR_DBG_BASE),
  116. .pfn = __phys_to_pfn(INTEGRATOR_DBG_BASE),
  117. .length = SZ_4K,
  118. .type = MT_DEVICE
  119. }, {
  120. .virtual = IO_ADDRESS(INTEGRATOR_AP_GPIO_BASE),
  121. .pfn = __phys_to_pfn(INTEGRATOR_AP_GPIO_BASE),
  122. .length = SZ_4K,
  123. .type = MT_DEVICE
  124. }, {
  125. .virtual = (unsigned long)PCI_MEMORY_VADDR,
  126. .pfn = __phys_to_pfn(PHYS_PCI_MEM_BASE),
  127. .length = SZ_16M,
  128. .type = MT_DEVICE
  129. }, {
  130. .virtual = (unsigned long)PCI_CONFIG_VADDR,
  131. .pfn = __phys_to_pfn(PHYS_PCI_CONFIG_BASE),
  132. .length = SZ_16M,
  133. .type = MT_DEVICE
  134. }
  135. };
  136. static void __init ap_map_io(void)
  137. {
  138. iotable_init(ap_io_desc, ARRAY_SIZE(ap_io_desc));
  139. vga_base = (unsigned long)PCI_MEMORY_VADDR;
  140. pci_map_io_early(__phys_to_pfn(PHYS_PCI_IO_BASE));
  141. }
  142. #ifdef CONFIG_PM
  143. static unsigned long ic_irq_enable;
  144. static int irq_suspend(void)
  145. {
  146. ic_irq_enable = readl(VA_IC_BASE + IRQ_ENABLE);
  147. return 0;
  148. }
  149. static void irq_resume(void)
  150. {
  151. /* disable all irq sources */
  152. writel(-1, VA_CMIC_BASE + IRQ_ENABLE_CLEAR);
  153. writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR);
  154. writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR);
  155. writel(ic_irq_enable, VA_IC_BASE + IRQ_ENABLE_SET);
  156. }
  157. #else
  158. #define irq_suspend NULL
  159. #define irq_resume NULL
  160. #endif
  161. static struct syscore_ops irq_syscore_ops = {
  162. .suspend = irq_suspend,
  163. .resume = irq_resume,
  164. };
  165. static int __init irq_syscore_init(void)
  166. {
  167. register_syscore_ops(&irq_syscore_ops);
  168. return 0;
  169. }
  170. device_initcall(irq_syscore_init);
  171. /*
  172. * Flash handling.
  173. */
  174. #define EBI_CSR1 (VA_EBI_BASE + INTEGRATOR_EBI_CSR1_OFFSET)
  175. #define EBI_LOCK (VA_EBI_BASE + INTEGRATOR_EBI_LOCK_OFFSET)
  176. static int ap_flash_init(struct platform_device *dev)
  177. {
  178. u32 tmp;
  179. writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP,
  180. ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET);
  181. tmp = readl(EBI_CSR1) | INTEGRATOR_EBI_WRITE_ENABLE;
  182. writel(tmp, EBI_CSR1);
  183. if (!(readl(EBI_CSR1) & INTEGRATOR_EBI_WRITE_ENABLE)) {
  184. writel(0xa05f, EBI_LOCK);
  185. writel(tmp, EBI_CSR1);
  186. writel(0, EBI_LOCK);
  187. }
  188. return 0;
  189. }
  190. static void ap_flash_exit(struct platform_device *dev)
  191. {
  192. u32 tmp;
  193. writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP,
  194. ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET);
  195. tmp = readl(EBI_CSR1) & ~INTEGRATOR_EBI_WRITE_ENABLE;
  196. writel(tmp, EBI_CSR1);
  197. if (readl(EBI_CSR1) & INTEGRATOR_EBI_WRITE_ENABLE) {
  198. writel(0xa05f, EBI_LOCK);
  199. writel(tmp, EBI_CSR1);
  200. writel(0, EBI_LOCK);
  201. }
  202. }
  203. static void ap_flash_set_vpp(struct platform_device *pdev, int on)
  204. {
  205. if (on)
  206. writel(INTEGRATOR_SC_CTRL_nFLVPPEN,
  207. ap_syscon_base + INTEGRATOR_SC_CTRLS_OFFSET);
  208. else
  209. writel(INTEGRATOR_SC_CTRL_nFLVPPEN,
  210. ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET);
  211. }
  212. static struct physmap_flash_data ap_flash_data = {
  213. .width = 4,
  214. .init = ap_flash_init,
  215. .exit = ap_flash_exit,
  216. .set_vpp = ap_flash_set_vpp,
  217. };
  218. /*
  219. * For the PL010 found in the Integrator/AP some of the UART control is
  220. * implemented in the system controller and accessed using a callback
  221. * from the driver.
  222. */
  223. static void integrator_uart_set_mctrl(struct amba_device *dev,
  224. void __iomem *base, unsigned int mctrl)
  225. {
  226. unsigned int ctrls = 0, ctrlc = 0, rts_mask, dtr_mask;
  227. u32 phybase = dev->res.start;
  228. if (phybase == INTEGRATOR_UART0_BASE) {
  229. /* UART0 */
  230. rts_mask = 1 << 4;
  231. dtr_mask = 1 << 5;
  232. } else {
  233. /* UART1 */
  234. rts_mask = 1 << 6;
  235. dtr_mask = 1 << 7;
  236. }
  237. if (mctrl & TIOCM_RTS)
  238. ctrlc |= rts_mask;
  239. else
  240. ctrls |= rts_mask;
  241. if (mctrl & TIOCM_DTR)
  242. ctrlc |= dtr_mask;
  243. else
  244. ctrls |= dtr_mask;
  245. __raw_writel(ctrls, ap_syscon_base + INTEGRATOR_SC_CTRLS_OFFSET);
  246. __raw_writel(ctrlc, ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET);
  247. }
  248. struct amba_pl010_data ap_uart_data = {
  249. .set_mctrl = integrator_uart_set_mctrl,
  250. };
  251. /*
  252. * Where is the timer (VA)?
  253. */
  254. #define TIMER0_VA_BASE __io_address(INTEGRATOR_TIMER0_BASE)
  255. #define TIMER1_VA_BASE __io_address(INTEGRATOR_TIMER1_BASE)
  256. #define TIMER2_VA_BASE __io_address(INTEGRATOR_TIMER2_BASE)
  257. static unsigned long timer_reload;
  258. static u32 notrace integrator_read_sched_clock(void)
  259. {
  260. return -readl((void __iomem *) TIMER2_VA_BASE + TIMER_VALUE);
  261. }
  262. static void integrator_clocksource_init(unsigned long inrate,
  263. void __iomem *base)
  264. {
  265. u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC;
  266. unsigned long rate = inrate;
  267. if (rate >= 1500000) {
  268. rate /= 16;
  269. ctrl |= TIMER_CTRL_DIV16;
  270. }
  271. writel(0xffff, base + TIMER_LOAD);
  272. writel(ctrl, base + TIMER_CTRL);
  273. clocksource_mmio_init(base + TIMER_VALUE, "timer2",
  274. rate, 200, 16, clocksource_mmio_readl_down);
  275. setup_sched_clock(integrator_read_sched_clock, 16, rate);
  276. }
  277. static void __iomem * clkevt_base;
  278. /*
  279. * IRQ handler for the timer
  280. */
  281. static irqreturn_t integrator_timer_interrupt(int irq, void *dev_id)
  282. {
  283. struct clock_event_device *evt = dev_id;
  284. /* clear the interrupt */
  285. writel(1, clkevt_base + TIMER_INTCLR);
  286. evt->event_handler(evt);
  287. return IRQ_HANDLED;
  288. }
  289. static void clkevt_set_mode(enum clock_event_mode mode, struct clock_event_device *evt)
  290. {
  291. u32 ctrl = readl(clkevt_base + TIMER_CTRL) & ~TIMER_CTRL_ENABLE;
  292. /* Disable timer */
  293. writel(ctrl, clkevt_base + TIMER_CTRL);
  294. switch (mode) {
  295. case CLOCK_EVT_MODE_PERIODIC:
  296. /* Enable the timer and start the periodic tick */
  297. writel(timer_reload, clkevt_base + TIMER_LOAD);
  298. ctrl |= TIMER_CTRL_PERIODIC | TIMER_CTRL_ENABLE;
  299. writel(ctrl, clkevt_base + TIMER_CTRL);
  300. break;
  301. case CLOCK_EVT_MODE_ONESHOT:
  302. /* Leave the timer disabled, .set_next_event will enable it */
  303. ctrl &= ~TIMER_CTRL_PERIODIC;
  304. writel(ctrl, clkevt_base + TIMER_CTRL);
  305. break;
  306. case CLOCK_EVT_MODE_UNUSED:
  307. case CLOCK_EVT_MODE_SHUTDOWN:
  308. case CLOCK_EVT_MODE_RESUME:
  309. default:
  310. /* Just leave in disabled state */
  311. break;
  312. }
  313. }
  314. static int clkevt_set_next_event(unsigned long next, struct clock_event_device *evt)
  315. {
  316. unsigned long ctrl = readl(clkevt_base + TIMER_CTRL);
  317. writel(ctrl & ~TIMER_CTRL_ENABLE, clkevt_base + TIMER_CTRL);
  318. writel(next, clkevt_base + TIMER_LOAD);
  319. writel(ctrl | TIMER_CTRL_ENABLE, clkevt_base + TIMER_CTRL);
  320. return 0;
  321. }
  322. static struct clock_event_device integrator_clockevent = {
  323. .name = "timer1",
  324. .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
  325. .set_mode = clkevt_set_mode,
  326. .set_next_event = clkevt_set_next_event,
  327. .rating = 300,
  328. };
  329. static struct irqaction integrator_timer_irq = {
  330. .name = "timer",
  331. .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
  332. .handler = integrator_timer_interrupt,
  333. .dev_id = &integrator_clockevent,
  334. };
  335. static void integrator_clockevent_init(unsigned long inrate,
  336. void __iomem *base, int irq)
  337. {
  338. unsigned long rate = inrate;
  339. unsigned int ctrl = 0;
  340. clkevt_base = base;
  341. /* Calculate and program a divisor */
  342. if (rate > 0x100000 * HZ) {
  343. rate /= 256;
  344. ctrl |= TIMER_CTRL_DIV256;
  345. } else if (rate > 0x10000 * HZ) {
  346. rate /= 16;
  347. ctrl |= TIMER_CTRL_DIV16;
  348. }
  349. timer_reload = rate / HZ;
  350. writel(ctrl, clkevt_base + TIMER_CTRL);
  351. setup_irq(irq, &integrator_timer_irq);
  352. clockevents_config_and_register(&integrator_clockevent,
  353. rate,
  354. 1,
  355. 0xffffU);
  356. }
  357. void __init ap_init_early(void)
  358. {
  359. }
  360. #ifdef CONFIG_OF
  361. static void __init ap_of_timer_init(void)
  362. {
  363. struct device_node *node;
  364. const char *path;
  365. void __iomem *base;
  366. int err;
  367. int irq;
  368. struct clk *clk;
  369. unsigned long rate;
  370. clk = clk_get_sys("ap_timer", NULL);
  371. BUG_ON(IS_ERR(clk));
  372. clk_prepare_enable(clk);
  373. rate = clk_get_rate(clk);
  374. err = of_property_read_string(of_aliases,
  375. "arm,timer-primary", &path);
  376. if (WARN_ON(err))
  377. return;
  378. node = of_find_node_by_path(path);
  379. base = of_iomap(node, 0);
  380. if (WARN_ON(!base))
  381. return;
  382. writel(0, base + TIMER_CTRL);
  383. integrator_clocksource_init(rate, base);
  384. err = of_property_read_string(of_aliases,
  385. "arm,timer-secondary", &path);
  386. if (WARN_ON(err))
  387. return;
  388. node = of_find_node_by_path(path);
  389. base = of_iomap(node, 0);
  390. if (WARN_ON(!base))
  391. return;
  392. irq = irq_of_parse_and_map(node, 0);
  393. writel(0, base + TIMER_CTRL);
  394. integrator_clockevent_init(rate, base, irq);
  395. }
  396. static const struct of_device_id fpga_irq_of_match[] __initconst = {
  397. { .compatible = "arm,versatile-fpga-irq", .data = fpga_irq_of_init, },
  398. { /* Sentinel */ }
  399. };
  400. static void __init ap_init_irq_of(void)
  401. {
  402. /* disable core module IRQs */
  403. writel(0xffffffffU, VA_CMIC_BASE + IRQ_ENABLE_CLEAR);
  404. of_irq_init(fpga_irq_of_match);
  405. integrator_clk_init(false);
  406. }
  407. /* For the Device Tree, add in the UART callbacks as AUXDATA */
  408. static struct of_dev_auxdata ap_auxdata_lookup[] __initdata = {
  409. OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_RTC_BASE,
  410. "rtc", NULL),
  411. OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE,
  412. "uart0", &ap_uart_data),
  413. OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE,
  414. "uart1", &ap_uart_data),
  415. OF_DEV_AUXDATA("arm,primecell", KMI0_BASE,
  416. "kmi0", NULL),
  417. OF_DEV_AUXDATA("arm,primecell", KMI1_BASE,
  418. "kmi1", NULL),
  419. OF_DEV_AUXDATA("cfi-flash", INTEGRATOR_FLASH_BASE,
  420. "physmap-flash", &ap_flash_data),
  421. { /* sentinel */ },
  422. };
  423. /*
  424. * This is a placeholder that will get deleted when we move the PCI
  425. * device over to the device tree.
  426. */
  427. static struct platform_device pci_v3_device_of = {
  428. .name = "pci-v3",
  429. .id = 0,
  430. };
  431. static void __init ap_init_of(void)
  432. {
  433. unsigned long sc_dec;
  434. struct device_node *root;
  435. struct device_node *syscon;
  436. struct device *parent;
  437. struct soc_device *soc_dev;
  438. struct soc_device_attribute *soc_dev_attr;
  439. u32 ap_sc_id;
  440. int err;
  441. int i;
  442. /* Here we create an SoC device for the root node */
  443. root = of_find_node_by_path("/");
  444. if (!root)
  445. return;
  446. syscon = of_find_node_by_path("/syscon");
  447. if (!syscon)
  448. return;
  449. ap_syscon_base = of_iomap(syscon, 0);
  450. if (!ap_syscon_base)
  451. return;
  452. ap_sc_id = readl(ap_syscon_base);
  453. soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
  454. if (!soc_dev_attr)
  455. return;
  456. err = of_property_read_string(root, "compatible",
  457. &soc_dev_attr->soc_id);
  458. if (err)
  459. return;
  460. err = of_property_read_string(root, "model", &soc_dev_attr->machine);
  461. if (err)
  462. return;
  463. soc_dev_attr->family = "Integrator";
  464. soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%c",
  465. 'A' + (ap_sc_id & 0x0f));
  466. soc_dev = soc_device_register(soc_dev_attr);
  467. if (IS_ERR(soc_dev)) {
  468. kfree(soc_dev_attr->revision);
  469. kfree(soc_dev_attr);
  470. return;
  471. }
  472. parent = soc_device_to_device(soc_dev);
  473. integrator_init_sysfs(parent, ap_sc_id);
  474. of_platform_populate(root, of_default_bus_match_table,
  475. ap_auxdata_lookup, parent);
  476. platform_device_register(&pci_v3_device_of);
  477. sc_dec = readl(ap_syscon_base + INTEGRATOR_SC_DEC_OFFSET);
  478. for (i = 0; i < 4; i++) {
  479. struct lm_device *lmdev;
  480. if ((sc_dec & (16 << i)) == 0)
  481. continue;
  482. lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL);
  483. if (!lmdev)
  484. continue;
  485. lmdev->resource.start = 0xc0000000 + 0x10000000 * i;
  486. lmdev->resource.end = lmdev->resource.start + 0x0fffffff;
  487. lmdev->resource.flags = IORESOURCE_MEM;
  488. lmdev->irq = IRQ_AP_EXPINT0 + i;
  489. lmdev->id = i;
  490. lm_device_register(lmdev);
  491. }
  492. }
  493. static const char * ap_dt_board_compat[] = {
  494. "arm,integrator-ap",
  495. NULL,
  496. };
  497. DT_MACHINE_START(INTEGRATOR_AP_DT, "ARM Integrator/AP (Device Tree)")
  498. .reserve = integrator_reserve,
  499. .map_io = ap_map_io,
  500. .init_early = ap_init_early,
  501. .init_irq = ap_init_irq_of,
  502. .handle_irq = fpga_handle_irq,
  503. .init_time = ap_of_timer_init,
  504. .init_machine = ap_init_of,
  505. .restart = integrator_restart,
  506. .dt_compat = ap_dt_board_compat,
  507. MACHINE_END
  508. #endif
  509. #ifdef CONFIG_ATAGS
  510. /*
  511. * For the ATAG boot some static mappings are needed. This will
  512. * go away with the ATAG support down the road.
  513. */
  514. static struct map_desc ap_io_desc_atag[] __initdata = {
  515. {
  516. .virtual = IO_ADDRESS(INTEGRATOR_SC_BASE),
  517. .pfn = __phys_to_pfn(INTEGRATOR_SC_BASE),
  518. .length = SZ_4K,
  519. .type = MT_DEVICE
  520. },
  521. };
  522. static void __init ap_map_io_atag(void)
  523. {
  524. iotable_init(ap_io_desc_atag, ARRAY_SIZE(ap_io_desc_atag));
  525. ap_map_io();
  526. }
  527. /*
  528. * This is where non-devicetree initialization code is collected and stashed
  529. * for eventual deletion.
  530. */
  531. static struct platform_device pci_v3_device = {
  532. .name = "pci-v3",
  533. .id = 0,
  534. };
  535. static struct resource cfi_flash_resource = {
  536. .start = INTEGRATOR_FLASH_BASE,
  537. .end = INTEGRATOR_FLASH_BASE + INTEGRATOR_FLASH_SIZE - 1,
  538. .flags = IORESOURCE_MEM,
  539. };
  540. static struct platform_device cfi_flash_device = {
  541. .name = "physmap-flash",
  542. .id = 0,
  543. .dev = {
  544. .platform_data = &ap_flash_data,
  545. },
  546. .num_resources = 1,
  547. .resource = &cfi_flash_resource,
  548. };
  549. static void __init ap_timer_init(void)
  550. {
  551. struct clk *clk;
  552. unsigned long rate;
  553. clk = clk_get_sys("ap_timer", NULL);
  554. BUG_ON(IS_ERR(clk));
  555. clk_prepare_enable(clk);
  556. rate = clk_get_rate(clk);
  557. writel(0, TIMER0_VA_BASE + TIMER_CTRL);
  558. writel(0, TIMER1_VA_BASE + TIMER_CTRL);
  559. writel(0, TIMER2_VA_BASE + TIMER_CTRL);
  560. integrator_clocksource_init(rate, (void __iomem *)TIMER2_VA_BASE);
  561. integrator_clockevent_init(rate, (void __iomem *)TIMER1_VA_BASE,
  562. IRQ_TIMERINT1);
  563. }
  564. #define INTEGRATOR_SC_VALID_INT 0x003fffff
  565. static void __init ap_init_irq(void)
  566. {
  567. /* Disable all interrupts initially. */
  568. /* Do the core module ones */
  569. writel(-1, VA_CMIC_BASE + IRQ_ENABLE_CLEAR);
  570. /* do the header card stuff next */
  571. writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR);
  572. writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR);
  573. fpga_irq_init(VA_IC_BASE, "SC", IRQ_PIC_START,
  574. -1, INTEGRATOR_SC_VALID_INT, NULL);
  575. integrator_clk_init(false);
  576. }
  577. static void __init ap_init(void)
  578. {
  579. unsigned long sc_dec;
  580. int i;
  581. platform_device_register(&pci_v3_device);
  582. platform_device_register(&cfi_flash_device);
  583. ap_syscon_base = __io_address(INTEGRATOR_SC_BASE);
  584. sc_dec = readl(ap_syscon_base + INTEGRATOR_SC_DEC_OFFSET);
  585. for (i = 0; i < 4; i++) {
  586. struct lm_device *lmdev;
  587. if ((sc_dec & (16 << i)) == 0)
  588. continue;
  589. lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL);
  590. if (!lmdev)
  591. continue;
  592. lmdev->resource.start = 0xc0000000 + 0x10000000 * i;
  593. lmdev->resource.end = lmdev->resource.start + 0x0fffffff;
  594. lmdev->resource.flags = IORESOURCE_MEM;
  595. lmdev->irq = IRQ_AP_EXPINT0 + i;
  596. lmdev->id = i;
  597. lm_device_register(lmdev);
  598. }
  599. integrator_init(false);
  600. }
  601. MACHINE_START(INTEGRATOR, "ARM-Integrator")
  602. /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
  603. .atag_offset = 0x100,
  604. .reserve = integrator_reserve,
  605. .map_io = ap_map_io_atag,
  606. .init_early = ap_init_early,
  607. .init_irq = ap_init_irq,
  608. .handle_irq = fpga_handle_irq,
  609. .init_time = ap_timer_init,
  610. .init_machine = ap_init,
  611. .restart = integrator_restart,
  612. MACHINE_END
  613. #endif