core.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /*
  2. * linux/arch/arm/mach-realview/core.c
  3. *
  4. * Copyright (C) 1999 - 2003 ARM Limited
  5. * Copyright (C) 2000 Deep Blue Solutions Ltd
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/init.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/dma-mapping.h>
  24. #include <linux/sysdev.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/amba/bus.h>
  27. #include <linux/amba/clcd.h>
  28. #include <linux/clocksource.h>
  29. #include <linux/clockchips.h>
  30. #include <asm/system.h>
  31. #include <asm/hardware.h>
  32. #include <asm/io.h>
  33. #include <asm/irq.h>
  34. #include <asm/leds.h>
  35. #include <asm/hardware/arm_timer.h>
  36. #include <asm/hardware/icst307.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach/flash.h>
  39. #include <asm/mach/irq.h>
  40. #include <asm/mach/time.h>
  41. #include <asm/mach/map.h>
  42. #include <asm/mach/mmc.h>
  43. #include <asm/hardware/gic.h>
  44. #include "core.h"
  45. #include "clock.h"
  46. #define REALVIEW_REFCOUNTER (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_24MHz_OFFSET)
  47. /*
  48. * This is the RealView sched_clock implementation. This has
  49. * a resolution of 41.7ns, and a maximum value of about 179s.
  50. */
  51. unsigned long long sched_clock(void)
  52. {
  53. unsigned long long v;
  54. v = (unsigned long long)readl(REALVIEW_REFCOUNTER) * 125;
  55. do_div(v, 3);
  56. return v;
  57. }
  58. #define REALVIEW_FLASHCTRL (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)
  59. static int realview_flash_init(void)
  60. {
  61. u32 val;
  62. val = __raw_readl(REALVIEW_FLASHCTRL);
  63. val &= ~REALVIEW_FLASHPROG_FLVPPEN;
  64. __raw_writel(val, REALVIEW_FLASHCTRL);
  65. return 0;
  66. }
  67. static void realview_flash_exit(void)
  68. {
  69. u32 val;
  70. val = __raw_readl(REALVIEW_FLASHCTRL);
  71. val &= ~REALVIEW_FLASHPROG_FLVPPEN;
  72. __raw_writel(val, REALVIEW_FLASHCTRL);
  73. }
  74. static void realview_flash_set_vpp(int on)
  75. {
  76. u32 val;
  77. val = __raw_readl(REALVIEW_FLASHCTRL);
  78. if (on)
  79. val |= REALVIEW_FLASHPROG_FLVPPEN;
  80. else
  81. val &= ~REALVIEW_FLASHPROG_FLVPPEN;
  82. __raw_writel(val, REALVIEW_FLASHCTRL);
  83. }
  84. static struct flash_platform_data realview_flash_data = {
  85. .map_name = "cfi_probe",
  86. .width = 4,
  87. .init = realview_flash_init,
  88. .exit = realview_flash_exit,
  89. .set_vpp = realview_flash_set_vpp,
  90. };
  91. static struct resource realview_flash_resource = {
  92. .start = REALVIEW_FLASH_BASE,
  93. .end = REALVIEW_FLASH_BASE + REALVIEW_FLASH_SIZE,
  94. .flags = IORESOURCE_MEM,
  95. };
  96. struct platform_device realview_flash_device = {
  97. .name = "armflash",
  98. .id = 0,
  99. .dev = {
  100. .platform_data = &realview_flash_data,
  101. },
  102. .num_resources = 1,
  103. .resource = &realview_flash_resource,
  104. };
  105. static struct resource realview_smc91x_resources[] = {
  106. [0] = {
  107. .start = REALVIEW_ETH_BASE,
  108. .end = REALVIEW_ETH_BASE + SZ_64K - 1,
  109. .flags = IORESOURCE_MEM,
  110. },
  111. [1] = {
  112. .start = IRQ_ETH,
  113. .end = IRQ_ETH,
  114. .flags = IORESOURCE_IRQ,
  115. },
  116. };
  117. struct platform_device realview_smc91x_device = {
  118. .name = "smc91x",
  119. .id = 0,
  120. .num_resources = ARRAY_SIZE(realview_smc91x_resources),
  121. .resource = realview_smc91x_resources,
  122. };
  123. static struct resource realview_i2c_resource = {
  124. .start = REALVIEW_I2C_BASE,
  125. .end = REALVIEW_I2C_BASE + SZ_4K - 1,
  126. .flags = IORESOURCE_MEM,
  127. };
  128. struct platform_device realview_i2c_device = {
  129. .name = "versatile-i2c",
  130. .id = -1,
  131. .num_resources = 1,
  132. .resource = &realview_i2c_resource,
  133. };
  134. #define REALVIEW_SYSMCI (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_MCI_OFFSET)
  135. static unsigned int realview_mmc_status(struct device *dev)
  136. {
  137. struct amba_device *adev = container_of(dev, struct amba_device, dev);
  138. u32 mask;
  139. if (adev->res.start == REALVIEW_MMCI0_BASE)
  140. mask = 1;
  141. else
  142. mask = 2;
  143. return readl(REALVIEW_SYSMCI) & mask;
  144. }
  145. struct mmc_platform_data realview_mmc0_plat_data = {
  146. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  147. .status = realview_mmc_status,
  148. };
  149. struct mmc_platform_data realview_mmc1_plat_data = {
  150. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  151. .status = realview_mmc_status,
  152. };
  153. /*
  154. * Clock handling
  155. */
  156. static const struct icst307_params realview_oscvco_params = {
  157. .ref = 24000,
  158. .vco_max = 200000,
  159. .vd_min = 4 + 8,
  160. .vd_max = 511 + 8,
  161. .rd_min = 1 + 2,
  162. .rd_max = 127 + 2,
  163. };
  164. static void realview_oscvco_set(struct clk *clk, struct icst307_vco vco)
  165. {
  166. void __iomem *sys_lock = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LOCK_OFFSET;
  167. void __iomem *sys_osc = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC4_OFFSET;
  168. u32 val;
  169. val = readl(sys_osc) & ~0x7ffff;
  170. val |= vco.v | (vco.r << 9) | (vco.s << 16);
  171. writel(0xa05f, sys_lock);
  172. writel(val, sys_osc);
  173. writel(0, sys_lock);
  174. }
  175. struct clk realview_clcd_clk = {
  176. .name = "CLCDCLK",
  177. .params = &realview_oscvco_params,
  178. .setvco = realview_oscvco_set,
  179. };
  180. /*
  181. * CLCD support.
  182. */
  183. #define SYS_CLCD_NLCDIOON (1 << 2)
  184. #define SYS_CLCD_VDDPOSSWITCH (1 << 3)
  185. #define SYS_CLCD_PWR3V5SWITCH (1 << 4)
  186. #define SYS_CLCD_ID_MASK (0x1f << 8)
  187. #define SYS_CLCD_ID_SANYO_3_8 (0x00 << 8)
  188. #define SYS_CLCD_ID_UNKNOWN_8_4 (0x01 << 8)
  189. #define SYS_CLCD_ID_EPSON_2_2 (0x02 << 8)
  190. #define SYS_CLCD_ID_SANYO_2_5 (0x07 << 8)
  191. #define SYS_CLCD_ID_VGA (0x1f << 8)
  192. static struct clcd_panel vga = {
  193. .mode = {
  194. .name = "VGA",
  195. .refresh = 60,
  196. .xres = 640,
  197. .yres = 480,
  198. .pixclock = 39721,
  199. .left_margin = 40,
  200. .right_margin = 24,
  201. .upper_margin = 32,
  202. .lower_margin = 11,
  203. .hsync_len = 96,
  204. .vsync_len = 2,
  205. .sync = 0,
  206. .vmode = FB_VMODE_NONINTERLACED,
  207. },
  208. .width = -1,
  209. .height = -1,
  210. .tim2 = TIM2_BCD | TIM2_IPC,
  211. .cntl = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
  212. .bpp = 16,
  213. };
  214. static struct clcd_panel sanyo_3_8_in = {
  215. .mode = {
  216. .name = "Sanyo QVGA",
  217. .refresh = 116,
  218. .xres = 320,
  219. .yres = 240,
  220. .pixclock = 100000,
  221. .left_margin = 6,
  222. .right_margin = 6,
  223. .upper_margin = 5,
  224. .lower_margin = 5,
  225. .hsync_len = 6,
  226. .vsync_len = 6,
  227. .sync = 0,
  228. .vmode = FB_VMODE_NONINTERLACED,
  229. },
  230. .width = -1,
  231. .height = -1,
  232. .tim2 = TIM2_BCD,
  233. .cntl = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
  234. .bpp = 16,
  235. };
  236. static struct clcd_panel sanyo_2_5_in = {
  237. .mode = {
  238. .name = "Sanyo QVGA Portrait",
  239. .refresh = 116,
  240. .xres = 240,
  241. .yres = 320,
  242. .pixclock = 100000,
  243. .left_margin = 20,
  244. .right_margin = 10,
  245. .upper_margin = 2,
  246. .lower_margin = 2,
  247. .hsync_len = 10,
  248. .vsync_len = 2,
  249. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  250. .vmode = FB_VMODE_NONINTERLACED,
  251. },
  252. .width = -1,
  253. .height = -1,
  254. .tim2 = TIM2_IVS | TIM2_IHS | TIM2_IPC,
  255. .cntl = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
  256. .bpp = 16,
  257. };
  258. static struct clcd_panel epson_2_2_in = {
  259. .mode = {
  260. .name = "Epson QCIF",
  261. .refresh = 390,
  262. .xres = 176,
  263. .yres = 220,
  264. .pixclock = 62500,
  265. .left_margin = 3,
  266. .right_margin = 2,
  267. .upper_margin = 1,
  268. .lower_margin = 0,
  269. .hsync_len = 3,
  270. .vsync_len = 2,
  271. .sync = 0,
  272. .vmode = FB_VMODE_NONINTERLACED,
  273. },
  274. .width = -1,
  275. .height = -1,
  276. .tim2 = TIM2_BCD | TIM2_IPC,
  277. .cntl = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
  278. .bpp = 16,
  279. };
  280. /*
  281. * Detect which LCD panel is connected, and return the appropriate
  282. * clcd_panel structure. Note: we do not have any information on
  283. * the required timings for the 8.4in panel, so we presently assume
  284. * VGA timings.
  285. */
  286. static struct clcd_panel *realview_clcd_panel(void)
  287. {
  288. void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
  289. struct clcd_panel *panel = &vga;
  290. u32 val;
  291. val = readl(sys_clcd) & SYS_CLCD_ID_MASK;
  292. if (val == SYS_CLCD_ID_SANYO_3_8)
  293. panel = &sanyo_3_8_in;
  294. else if (val == SYS_CLCD_ID_SANYO_2_5)
  295. panel = &sanyo_2_5_in;
  296. else if (val == SYS_CLCD_ID_EPSON_2_2)
  297. panel = &epson_2_2_in;
  298. else if (val == SYS_CLCD_ID_VGA)
  299. panel = &vga;
  300. else {
  301. printk(KERN_ERR "CLCD: unknown LCD panel ID 0x%08x, using VGA\n",
  302. val);
  303. panel = &vga;
  304. }
  305. return panel;
  306. }
  307. /*
  308. * Disable all display connectors on the interface module.
  309. */
  310. static void realview_clcd_disable(struct clcd_fb *fb)
  311. {
  312. void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
  313. u32 val;
  314. val = readl(sys_clcd);
  315. val &= ~SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
  316. writel(val, sys_clcd);
  317. }
  318. /*
  319. * Enable the relevant connector on the interface module.
  320. */
  321. static void realview_clcd_enable(struct clcd_fb *fb)
  322. {
  323. void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
  324. u32 val;
  325. /*
  326. * Enable the PSUs
  327. */
  328. val = readl(sys_clcd);
  329. val |= SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
  330. writel(val, sys_clcd);
  331. }
  332. static unsigned long framesize = SZ_1M;
  333. static int realview_clcd_setup(struct clcd_fb *fb)
  334. {
  335. dma_addr_t dma;
  336. fb->panel = realview_clcd_panel();
  337. fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, framesize,
  338. &dma, GFP_KERNEL);
  339. if (!fb->fb.screen_base) {
  340. printk(KERN_ERR "CLCD: unable to map framebuffer\n");
  341. return -ENOMEM;
  342. }
  343. fb->fb.fix.smem_start = dma;
  344. fb->fb.fix.smem_len = framesize;
  345. return 0;
  346. }
  347. static int realview_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
  348. {
  349. return dma_mmap_writecombine(&fb->dev->dev, vma,
  350. fb->fb.screen_base,
  351. fb->fb.fix.smem_start,
  352. fb->fb.fix.smem_len);
  353. }
  354. static void realview_clcd_remove(struct clcd_fb *fb)
  355. {
  356. dma_free_writecombine(&fb->dev->dev, fb->fb.fix.smem_len,
  357. fb->fb.screen_base, fb->fb.fix.smem_start);
  358. }
  359. struct clcd_board clcd_plat_data = {
  360. .name = "RealView",
  361. .check = clcdfb_check,
  362. .decode = clcdfb_decode,
  363. .disable = realview_clcd_disable,
  364. .enable = realview_clcd_enable,
  365. .setup = realview_clcd_setup,
  366. .mmap = realview_clcd_mmap,
  367. .remove = realview_clcd_remove,
  368. };
  369. #ifdef CONFIG_LEDS
  370. #define VA_LEDS_BASE (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LED_OFFSET)
  371. void realview_leds_event(led_event_t ledevt)
  372. {
  373. unsigned long flags;
  374. u32 val;
  375. local_irq_save(flags);
  376. val = readl(VA_LEDS_BASE);
  377. switch (ledevt) {
  378. case led_idle_start:
  379. val = val & ~REALVIEW_SYS_LED0;
  380. break;
  381. case led_idle_end:
  382. val = val | REALVIEW_SYS_LED0;
  383. break;
  384. case led_timer:
  385. val = val ^ REALVIEW_SYS_LED1;
  386. break;
  387. case led_halted:
  388. val = 0;
  389. break;
  390. default:
  391. break;
  392. }
  393. writel(val, VA_LEDS_BASE);
  394. local_irq_restore(flags);
  395. }
  396. #endif /* CONFIG_LEDS */
  397. /*
  398. * Where is the timer (VA)?
  399. */
  400. #define TIMER0_VA_BASE __io_address(REALVIEW_TIMER0_1_BASE)
  401. #define TIMER1_VA_BASE (__io_address(REALVIEW_TIMER0_1_BASE) + 0x20)
  402. #define TIMER2_VA_BASE __io_address(REALVIEW_TIMER2_3_BASE)
  403. #define TIMER3_VA_BASE (__io_address(REALVIEW_TIMER2_3_BASE) + 0x20)
  404. /*
  405. * How long is the timer interval?
  406. */
  407. #define TIMER_INTERVAL (TICKS_PER_uSEC * mSEC_10)
  408. #if TIMER_INTERVAL >= 0x100000
  409. #define TIMER_RELOAD (TIMER_INTERVAL >> 8)
  410. #define TIMER_DIVISOR (TIMER_CTRL_DIV256)
  411. #define TICKS2USECS(x) (256 * (x) / TICKS_PER_uSEC)
  412. #elif TIMER_INTERVAL >= 0x10000
  413. #define TIMER_RELOAD (TIMER_INTERVAL >> 4) /* Divide by 16 */
  414. #define TIMER_DIVISOR (TIMER_CTRL_DIV16)
  415. #define TICKS2USECS(x) (16 * (x) / TICKS_PER_uSEC)
  416. #else
  417. #define TIMER_RELOAD (TIMER_INTERVAL)
  418. #define TIMER_DIVISOR (TIMER_CTRL_DIV1)
  419. #define TICKS2USECS(x) ((x) / TICKS_PER_uSEC)
  420. #endif
  421. static void timer_set_mode(enum clock_event_mode mode,
  422. struct clock_event_device *clk)
  423. {
  424. unsigned long ctrl;
  425. switch(mode) {
  426. case CLOCK_EVT_MODE_PERIODIC:
  427. writel(TIMER_RELOAD, TIMER0_VA_BASE + TIMER_LOAD);
  428. ctrl = TIMER_CTRL_PERIODIC;
  429. ctrl |= TIMER_CTRL_32BIT | TIMER_CTRL_IE | TIMER_CTRL_ENABLE;
  430. break;
  431. case CLOCK_EVT_MODE_ONESHOT:
  432. /* period set, and timer enabled in 'next_event' hook */
  433. ctrl = TIMER_CTRL_ONESHOT;
  434. ctrl |= TIMER_CTRL_32BIT | TIMER_CTRL_IE;
  435. break;
  436. case CLOCK_EVT_MODE_UNUSED:
  437. case CLOCK_EVT_MODE_SHUTDOWN:
  438. default:
  439. ctrl = 0;
  440. }
  441. writel(ctrl, TIMER0_VA_BASE + TIMER_CTRL);
  442. }
  443. static int timer_set_next_event(unsigned long evt,
  444. struct clock_event_device *unused)
  445. {
  446. unsigned long ctrl = readl(TIMER0_VA_BASE + TIMER_CTRL);
  447. writel(evt, TIMER0_VA_BASE + TIMER_LOAD);
  448. writel(ctrl | TIMER_CTRL_ENABLE, TIMER0_VA_BASE + TIMER_CTRL);
  449. return 0;
  450. }
  451. static struct clock_event_device timer0_clockevent = {
  452. .name = "timer0",
  453. .shift = 32,
  454. .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
  455. .set_mode = timer_set_mode,
  456. .set_next_event = timer_set_next_event,
  457. .rating = 300,
  458. .irq = IRQ_TIMERINT0_1,
  459. .cpumask = CPU_MASK_ALL,
  460. };
  461. static void __init realview_clockevents_init(void)
  462. {
  463. timer0_clockevent.mult =
  464. div_sc(1000000, NSEC_PER_SEC, timer0_clockevent.shift);
  465. timer0_clockevent.max_delta_ns =
  466. clockevent_delta2ns(0xffffffff, &timer0_clockevent);
  467. timer0_clockevent.min_delta_ns =
  468. clockevent_delta2ns(0xf, &timer0_clockevent);
  469. clockevents_register_device(&timer0_clockevent);
  470. }
  471. /*
  472. * IRQ handler for the timer
  473. */
  474. static irqreturn_t realview_timer_interrupt(int irq, void *dev_id)
  475. {
  476. struct clock_event_device *evt = &timer0_clockevent;
  477. /* clear the interrupt */
  478. writel(1, TIMER0_VA_BASE + TIMER_INTCLR);
  479. evt->event_handler(evt);
  480. return IRQ_HANDLED;
  481. }
  482. static struct irqaction realview_timer_irq = {
  483. .name = "RealView Timer Tick",
  484. .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
  485. .handler = realview_timer_interrupt,
  486. };
  487. static cycle_t realview_get_cycles(void)
  488. {
  489. return ~readl(TIMER3_VA_BASE + TIMER_VALUE);
  490. }
  491. static struct clocksource clocksource_realview = {
  492. .name = "timer3",
  493. .rating = 200,
  494. .read = realview_get_cycles,
  495. .mask = CLOCKSOURCE_MASK(32),
  496. .shift = 20,
  497. .flags = CLOCK_SOURCE_IS_CONTINUOUS,
  498. };
  499. static void __init realview_clocksource_init(void)
  500. {
  501. /* setup timer 0 as free-running clocksource */
  502. writel(0, TIMER3_VA_BASE + TIMER_CTRL);
  503. writel(0xffffffff, TIMER3_VA_BASE + TIMER_LOAD);
  504. writel(0xffffffff, TIMER3_VA_BASE + TIMER_VALUE);
  505. writel(TIMER_CTRL_32BIT | TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC,
  506. TIMER3_VA_BASE + TIMER_CTRL);
  507. clocksource_realview.mult =
  508. clocksource_khz2mult(1000, clocksource_realview.shift);
  509. clocksource_register(&clocksource_realview);
  510. }
  511. /*
  512. * Set up timer interrupt, and return the current time in seconds.
  513. */
  514. static void __init realview_timer_init(void)
  515. {
  516. u32 val;
  517. /*
  518. * set clock frequency:
  519. * REALVIEW_REFCLK is 32KHz
  520. * REALVIEW_TIMCLK is 1MHz
  521. */
  522. val = readl(__io_address(REALVIEW_SCTL_BASE));
  523. writel((REALVIEW_TIMCLK << REALVIEW_TIMER1_EnSel) |
  524. (REALVIEW_TIMCLK << REALVIEW_TIMER2_EnSel) |
  525. (REALVIEW_TIMCLK << REALVIEW_TIMER3_EnSel) |
  526. (REALVIEW_TIMCLK << REALVIEW_TIMER4_EnSel) | val,
  527. __io_address(REALVIEW_SCTL_BASE));
  528. /*
  529. * Initialise to a known state (all timers off)
  530. */
  531. writel(0, TIMER0_VA_BASE + TIMER_CTRL);
  532. writel(0, TIMER1_VA_BASE + TIMER_CTRL);
  533. writel(0, TIMER2_VA_BASE + TIMER_CTRL);
  534. writel(0, TIMER3_VA_BASE + TIMER_CTRL);
  535. /*
  536. * Make irqs happen for the system timer
  537. */
  538. setup_irq(IRQ_TIMERINT0_1, &realview_timer_irq);
  539. realview_clocksource_init();
  540. realview_clockevents_init();
  541. }
  542. struct sys_timer realview_timer = {
  543. .init = realview_timer_init,
  544. };