integrator_ap.c 17 KB

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