core.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  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/io.h>
  29. #include <linux/smsc911x.h>
  30. #include <linux/ata_platform.h>
  31. #include <linux/amba/mmci.h>
  32. #include <asm/clkdev.h>
  33. #include <asm/system.h>
  34. #include <mach/hardware.h>
  35. #include <asm/irq.h>
  36. #include <asm/leds.h>
  37. #include <asm/mach-types.h>
  38. #include <asm/hardware/arm_timer.h>
  39. #include <asm/hardware/icst.h>
  40. #include <asm/mach/arch.h>
  41. #include <asm/mach/flash.h>
  42. #include <asm/mach/irq.h>
  43. #include <asm/mach/map.h>
  44. #include <asm/hardware/gic.h>
  45. #include <mach/clkdev.h>
  46. #include <mach/platform.h>
  47. #include <mach/irqs.h>
  48. #include <plat/timer-sp.h>
  49. #include "core.h"
  50. #define REALVIEW_REFCOUNTER (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_24MHz_OFFSET)
  51. /* used by entry-macro.S and platsmp.c */
  52. void __iomem *gic_cpu_base_addr;
  53. #ifdef CONFIG_ZONE_DMA
  54. /*
  55. * Adjust the zones if there are restrictions for DMA access.
  56. */
  57. void __init realview_adjust_zones(int node, unsigned long *size,
  58. unsigned long *hole)
  59. {
  60. unsigned long dma_size = SZ_256M >> PAGE_SHIFT;
  61. if (!machine_is_realview_pbx() || node || (size[0] <= dma_size))
  62. return;
  63. size[ZONE_NORMAL] = size[0] - dma_size;
  64. size[ZONE_DMA] = dma_size;
  65. hole[ZONE_NORMAL] = hole[0];
  66. hole[ZONE_DMA] = 0;
  67. }
  68. #endif
  69. /*
  70. * This is the RealView sched_clock implementation. This has
  71. * a resolution of 41.7ns, and a maximum value of about 179s.
  72. */
  73. unsigned long long sched_clock(void)
  74. {
  75. unsigned long long v;
  76. v = (unsigned long long)readl(REALVIEW_REFCOUNTER) * 125;
  77. do_div(v, 3);
  78. return v;
  79. }
  80. #define REALVIEW_FLASHCTRL (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)
  81. static int realview_flash_init(void)
  82. {
  83. u32 val;
  84. val = __raw_readl(REALVIEW_FLASHCTRL);
  85. val &= ~REALVIEW_FLASHPROG_FLVPPEN;
  86. __raw_writel(val, REALVIEW_FLASHCTRL);
  87. return 0;
  88. }
  89. static void realview_flash_exit(void)
  90. {
  91. u32 val;
  92. val = __raw_readl(REALVIEW_FLASHCTRL);
  93. val &= ~REALVIEW_FLASHPROG_FLVPPEN;
  94. __raw_writel(val, REALVIEW_FLASHCTRL);
  95. }
  96. static void realview_flash_set_vpp(int on)
  97. {
  98. u32 val;
  99. val = __raw_readl(REALVIEW_FLASHCTRL);
  100. if (on)
  101. val |= REALVIEW_FLASHPROG_FLVPPEN;
  102. else
  103. val &= ~REALVIEW_FLASHPROG_FLVPPEN;
  104. __raw_writel(val, REALVIEW_FLASHCTRL);
  105. }
  106. static struct flash_platform_data realview_flash_data = {
  107. .map_name = "cfi_probe",
  108. .width = 4,
  109. .init = realview_flash_init,
  110. .exit = realview_flash_exit,
  111. .set_vpp = realview_flash_set_vpp,
  112. };
  113. struct platform_device realview_flash_device = {
  114. .name = "armflash",
  115. .id = 0,
  116. .dev = {
  117. .platform_data = &realview_flash_data,
  118. },
  119. };
  120. int realview_flash_register(struct resource *res, u32 num)
  121. {
  122. realview_flash_device.resource = res;
  123. realview_flash_device.num_resources = num;
  124. return platform_device_register(&realview_flash_device);
  125. }
  126. static struct smsc911x_platform_config smsc911x_config = {
  127. .flags = SMSC911X_USE_32BIT,
  128. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
  129. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  130. .phy_interface = PHY_INTERFACE_MODE_MII,
  131. };
  132. static struct platform_device realview_eth_device = {
  133. .name = "smsc911x",
  134. .id = 0,
  135. .num_resources = 2,
  136. };
  137. int realview_eth_register(const char *name, struct resource *res)
  138. {
  139. if (name)
  140. realview_eth_device.name = name;
  141. realview_eth_device.resource = res;
  142. if (strcmp(realview_eth_device.name, "smsc911x") == 0)
  143. realview_eth_device.dev.platform_data = &smsc911x_config;
  144. return platform_device_register(&realview_eth_device);
  145. }
  146. struct platform_device realview_usb_device = {
  147. .name = "isp1760",
  148. .num_resources = 2,
  149. };
  150. int realview_usb_register(struct resource *res)
  151. {
  152. realview_usb_device.resource = res;
  153. return platform_device_register(&realview_usb_device);
  154. }
  155. static struct pata_platform_info pata_platform_data = {
  156. .ioport_shift = 1,
  157. };
  158. static struct resource pata_resources[] = {
  159. [0] = {
  160. .start = REALVIEW_CF_BASE,
  161. .end = REALVIEW_CF_BASE + 0xff,
  162. .flags = IORESOURCE_MEM,
  163. },
  164. [1] = {
  165. .start = REALVIEW_CF_BASE + 0x100,
  166. .end = REALVIEW_CF_BASE + SZ_4K - 1,
  167. .flags = IORESOURCE_MEM,
  168. },
  169. };
  170. struct platform_device realview_cf_device = {
  171. .name = "pata_platform",
  172. .id = -1,
  173. .num_resources = ARRAY_SIZE(pata_resources),
  174. .resource = pata_resources,
  175. .dev = {
  176. .platform_data = &pata_platform_data,
  177. },
  178. };
  179. static struct resource realview_i2c_resource = {
  180. .start = REALVIEW_I2C_BASE,
  181. .end = REALVIEW_I2C_BASE + SZ_4K - 1,
  182. .flags = IORESOURCE_MEM,
  183. };
  184. struct platform_device realview_i2c_device = {
  185. .name = "versatile-i2c",
  186. .id = 0,
  187. .num_resources = 1,
  188. .resource = &realview_i2c_resource,
  189. };
  190. static struct i2c_board_info realview_i2c_board_info[] = {
  191. {
  192. I2C_BOARD_INFO("ds1338", 0xd0 >> 1),
  193. },
  194. };
  195. static int __init realview_i2c_init(void)
  196. {
  197. return i2c_register_board_info(0, realview_i2c_board_info,
  198. ARRAY_SIZE(realview_i2c_board_info));
  199. }
  200. arch_initcall(realview_i2c_init);
  201. #define REALVIEW_SYSMCI (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_MCI_OFFSET)
  202. /*
  203. * This is only used if GPIOLIB support is disabled
  204. */
  205. static unsigned int realview_mmc_status(struct device *dev)
  206. {
  207. struct amba_device *adev = container_of(dev, struct amba_device, dev);
  208. u32 mask;
  209. if (adev->res.start == REALVIEW_MMCI0_BASE)
  210. mask = 1;
  211. else
  212. mask = 2;
  213. return readl(REALVIEW_SYSMCI) & mask;
  214. }
  215. struct mmci_platform_data realview_mmc0_plat_data = {
  216. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  217. .status = realview_mmc_status,
  218. .gpio_wp = 17,
  219. .gpio_cd = 16,
  220. };
  221. struct mmci_platform_data realview_mmc1_plat_data = {
  222. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  223. .status = realview_mmc_status,
  224. .gpio_wp = 19,
  225. .gpio_cd = 18,
  226. };
  227. /*
  228. * Clock handling
  229. */
  230. static const struct icst_params realview_oscvco_params = {
  231. .ref = 24000000,
  232. .vco_max = ICST307_VCO_MAX,
  233. .vco_min = ICST307_VCO_MIN,
  234. .vd_min = 4 + 8,
  235. .vd_max = 511 + 8,
  236. .rd_min = 1 + 2,
  237. .rd_max = 127 + 2,
  238. .s2div = icst307_s2div,
  239. .idx2s = icst307_idx2s,
  240. };
  241. static void realview_oscvco_set(struct clk *clk, struct icst_vco vco)
  242. {
  243. void __iomem *sys_lock = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LOCK_OFFSET;
  244. void __iomem *sys_osc;
  245. u32 val;
  246. if (machine_is_realview_pb1176())
  247. sys_osc = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC0_OFFSET;
  248. else
  249. sys_osc = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC4_OFFSET;
  250. val = readl(sys_osc) & ~0x7ffff;
  251. val |= vco.v | (vco.r << 9) | (vco.s << 16);
  252. writel(0xa05f, sys_lock);
  253. writel(val, sys_osc);
  254. writel(0, sys_lock);
  255. }
  256. static struct clk oscvco_clk = {
  257. .params = &realview_oscvco_params,
  258. .setvco = realview_oscvco_set,
  259. };
  260. /*
  261. * These are fixed clocks.
  262. */
  263. static struct clk ref24_clk = {
  264. .rate = 24000000,
  265. };
  266. static struct clk_lookup lookups[] = {
  267. { /* UART0 */
  268. .dev_id = "dev:uart0",
  269. .clk = &ref24_clk,
  270. }, { /* UART1 */
  271. .dev_id = "dev:uart1",
  272. .clk = &ref24_clk,
  273. }, { /* UART2 */
  274. .dev_id = "dev:uart2",
  275. .clk = &ref24_clk,
  276. }, { /* UART3 */
  277. .dev_id = "fpga:uart3",
  278. .clk = &ref24_clk,
  279. }, { /* KMI0 */
  280. .dev_id = "fpga:kmi0",
  281. .clk = &ref24_clk,
  282. }, { /* KMI1 */
  283. .dev_id = "fpga:kmi1",
  284. .clk = &ref24_clk,
  285. }, { /* MMC0 */
  286. .dev_id = "fpga:mmc0",
  287. .clk = &ref24_clk,
  288. }, { /* EB:CLCD */
  289. .dev_id = "dev:clcd",
  290. .clk = &oscvco_clk,
  291. }, { /* PB:CLCD */
  292. .dev_id = "issp:clcd",
  293. .clk = &oscvco_clk,
  294. }
  295. };
  296. static int __init clk_init(void)
  297. {
  298. clkdev_add_table(lookups, ARRAY_SIZE(lookups));
  299. return 0;
  300. }
  301. arch_initcall(clk_init);
  302. /*
  303. * CLCD support.
  304. */
  305. #define SYS_CLCD_NLCDIOON (1 << 2)
  306. #define SYS_CLCD_VDDPOSSWITCH (1 << 3)
  307. #define SYS_CLCD_PWR3V5SWITCH (1 << 4)
  308. #define SYS_CLCD_ID_MASK (0x1f << 8)
  309. #define SYS_CLCD_ID_SANYO_3_8 (0x00 << 8)
  310. #define SYS_CLCD_ID_UNKNOWN_8_4 (0x01 << 8)
  311. #define SYS_CLCD_ID_EPSON_2_2 (0x02 << 8)
  312. #define SYS_CLCD_ID_SANYO_2_5 (0x07 << 8)
  313. #define SYS_CLCD_ID_VGA (0x1f << 8)
  314. static struct clcd_panel vga = {
  315. .mode = {
  316. .name = "VGA",
  317. .refresh = 60,
  318. .xres = 640,
  319. .yres = 480,
  320. .pixclock = 39721,
  321. .left_margin = 40,
  322. .right_margin = 24,
  323. .upper_margin = 32,
  324. .lower_margin = 11,
  325. .hsync_len = 96,
  326. .vsync_len = 2,
  327. .sync = 0,
  328. .vmode = FB_VMODE_NONINTERLACED,
  329. },
  330. .width = -1,
  331. .height = -1,
  332. .tim2 = TIM2_BCD | TIM2_IPC,
  333. .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
  334. .bpp = 16,
  335. };
  336. static struct clcd_panel xvga = {
  337. .mode = {
  338. .name = "XVGA",
  339. .refresh = 60,
  340. .xres = 1024,
  341. .yres = 768,
  342. .pixclock = 15748,
  343. .left_margin = 152,
  344. .right_margin = 48,
  345. .upper_margin = 23,
  346. .lower_margin = 3,
  347. .hsync_len = 104,
  348. .vsync_len = 4,
  349. .sync = 0,
  350. .vmode = FB_VMODE_NONINTERLACED,
  351. },
  352. .width = -1,
  353. .height = -1,
  354. .tim2 = TIM2_BCD | TIM2_IPC,
  355. .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
  356. .bpp = 16,
  357. };
  358. static struct clcd_panel sanyo_3_8_in = {
  359. .mode = {
  360. .name = "Sanyo QVGA",
  361. .refresh = 116,
  362. .xres = 320,
  363. .yres = 240,
  364. .pixclock = 100000,
  365. .left_margin = 6,
  366. .right_margin = 6,
  367. .upper_margin = 5,
  368. .lower_margin = 5,
  369. .hsync_len = 6,
  370. .vsync_len = 6,
  371. .sync = 0,
  372. .vmode = FB_VMODE_NONINTERLACED,
  373. },
  374. .width = -1,
  375. .height = -1,
  376. .tim2 = TIM2_BCD,
  377. .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
  378. .bpp = 16,
  379. };
  380. static struct clcd_panel sanyo_2_5_in = {
  381. .mode = {
  382. .name = "Sanyo QVGA Portrait",
  383. .refresh = 116,
  384. .xres = 240,
  385. .yres = 320,
  386. .pixclock = 100000,
  387. .left_margin = 20,
  388. .right_margin = 10,
  389. .upper_margin = 2,
  390. .lower_margin = 2,
  391. .hsync_len = 10,
  392. .vsync_len = 2,
  393. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  394. .vmode = FB_VMODE_NONINTERLACED,
  395. },
  396. .width = -1,
  397. .height = -1,
  398. .tim2 = TIM2_IVS | TIM2_IHS | TIM2_IPC,
  399. .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
  400. .bpp = 16,
  401. };
  402. static struct clcd_panel epson_2_2_in = {
  403. .mode = {
  404. .name = "Epson QCIF",
  405. .refresh = 390,
  406. .xres = 176,
  407. .yres = 220,
  408. .pixclock = 62500,
  409. .left_margin = 3,
  410. .right_margin = 2,
  411. .upper_margin = 1,
  412. .lower_margin = 0,
  413. .hsync_len = 3,
  414. .vsync_len = 2,
  415. .sync = 0,
  416. .vmode = FB_VMODE_NONINTERLACED,
  417. },
  418. .width = -1,
  419. .height = -1,
  420. .tim2 = TIM2_BCD | TIM2_IPC,
  421. .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
  422. .bpp = 16,
  423. };
  424. /*
  425. * Detect which LCD panel is connected, and return the appropriate
  426. * clcd_panel structure. Note: we do not have any information on
  427. * the required timings for the 8.4in panel, so we presently assume
  428. * VGA timings.
  429. */
  430. static struct clcd_panel *realview_clcd_panel(void)
  431. {
  432. void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
  433. struct clcd_panel *vga_panel;
  434. struct clcd_panel *panel;
  435. u32 val;
  436. if (machine_is_realview_eb())
  437. vga_panel = &vga;
  438. else
  439. vga_panel = &xvga;
  440. val = readl(sys_clcd) & SYS_CLCD_ID_MASK;
  441. if (val == SYS_CLCD_ID_SANYO_3_8)
  442. panel = &sanyo_3_8_in;
  443. else if (val == SYS_CLCD_ID_SANYO_2_5)
  444. panel = &sanyo_2_5_in;
  445. else if (val == SYS_CLCD_ID_EPSON_2_2)
  446. panel = &epson_2_2_in;
  447. else if (val == SYS_CLCD_ID_VGA)
  448. panel = vga_panel;
  449. else {
  450. printk(KERN_ERR "CLCD: unknown LCD panel ID 0x%08x, using VGA\n",
  451. val);
  452. panel = vga_panel;
  453. }
  454. return panel;
  455. }
  456. /*
  457. * Disable all display connectors on the interface module.
  458. */
  459. static void realview_clcd_disable(struct clcd_fb *fb)
  460. {
  461. void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
  462. u32 val;
  463. val = readl(sys_clcd);
  464. val &= ~SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
  465. writel(val, sys_clcd);
  466. }
  467. /*
  468. * Enable the relevant connector on the interface module.
  469. */
  470. static void realview_clcd_enable(struct clcd_fb *fb)
  471. {
  472. void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
  473. u32 val;
  474. /*
  475. * Enable the PSUs
  476. */
  477. val = readl(sys_clcd);
  478. val |= SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
  479. writel(val, sys_clcd);
  480. }
  481. static int realview_clcd_setup(struct clcd_fb *fb)
  482. {
  483. unsigned long framesize;
  484. dma_addr_t dma;
  485. if (machine_is_realview_eb())
  486. /* VGA, 16bpp */
  487. framesize = 640 * 480 * 2;
  488. else
  489. /* XVGA, 16bpp */
  490. framesize = 1024 * 768 * 2;
  491. fb->panel = realview_clcd_panel();
  492. fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, framesize,
  493. &dma, GFP_KERNEL | GFP_DMA);
  494. if (!fb->fb.screen_base) {
  495. printk(KERN_ERR "CLCD: unable to map framebuffer\n");
  496. return -ENOMEM;
  497. }
  498. fb->fb.fix.smem_start = dma;
  499. fb->fb.fix.smem_len = framesize;
  500. return 0;
  501. }
  502. static int realview_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
  503. {
  504. return dma_mmap_writecombine(&fb->dev->dev, vma,
  505. fb->fb.screen_base,
  506. fb->fb.fix.smem_start,
  507. fb->fb.fix.smem_len);
  508. }
  509. static void realview_clcd_remove(struct clcd_fb *fb)
  510. {
  511. dma_free_writecombine(&fb->dev->dev, fb->fb.fix.smem_len,
  512. fb->fb.screen_base, fb->fb.fix.smem_start);
  513. }
  514. struct clcd_board clcd_plat_data = {
  515. .name = "RealView",
  516. .check = clcdfb_check,
  517. .decode = clcdfb_decode,
  518. .disable = realview_clcd_disable,
  519. .enable = realview_clcd_enable,
  520. .setup = realview_clcd_setup,
  521. .mmap = realview_clcd_mmap,
  522. .remove = realview_clcd_remove,
  523. };
  524. #ifdef CONFIG_LEDS
  525. #define VA_LEDS_BASE (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LED_OFFSET)
  526. void realview_leds_event(led_event_t ledevt)
  527. {
  528. unsigned long flags;
  529. u32 val;
  530. u32 led = 1 << smp_processor_id();
  531. local_irq_save(flags);
  532. val = readl(VA_LEDS_BASE);
  533. switch (ledevt) {
  534. case led_idle_start:
  535. val = val & ~led;
  536. break;
  537. case led_idle_end:
  538. val = val | led;
  539. break;
  540. case led_timer:
  541. val = val ^ REALVIEW_SYS_LED7;
  542. break;
  543. case led_halted:
  544. val = 0;
  545. break;
  546. default:
  547. break;
  548. }
  549. writel(val, VA_LEDS_BASE);
  550. local_irq_restore(flags);
  551. }
  552. #endif /* CONFIG_LEDS */
  553. /*
  554. * Where is the timer (VA)?
  555. */
  556. void __iomem *timer0_va_base;
  557. void __iomem *timer1_va_base;
  558. void __iomem *timer2_va_base;
  559. void __iomem *timer3_va_base;
  560. /*
  561. * Set up the clock source and clock events devices
  562. */
  563. void __init realview_timer_init(unsigned int timer_irq)
  564. {
  565. u32 val;
  566. /*
  567. * set clock frequency:
  568. * REALVIEW_REFCLK is 32KHz
  569. * REALVIEW_TIMCLK is 1MHz
  570. */
  571. val = readl(__io_address(REALVIEW_SCTL_BASE));
  572. writel((REALVIEW_TIMCLK << REALVIEW_TIMER1_EnSel) |
  573. (REALVIEW_TIMCLK << REALVIEW_TIMER2_EnSel) |
  574. (REALVIEW_TIMCLK << REALVIEW_TIMER3_EnSel) |
  575. (REALVIEW_TIMCLK << REALVIEW_TIMER4_EnSel) | val,
  576. __io_address(REALVIEW_SCTL_BASE));
  577. /*
  578. * Initialise to a known state (all timers off)
  579. */
  580. writel(0, timer0_va_base + TIMER_CTRL);
  581. writel(0, timer1_va_base + TIMER_CTRL);
  582. writel(0, timer2_va_base + TIMER_CTRL);
  583. writel(0, timer3_va_base + TIMER_CTRL);
  584. sp804_clocksource_init(timer3_va_base);
  585. sp804_clockevents_init(timer0_va_base, timer_irq);
  586. }
  587. /*
  588. * Setup the memory banks.
  589. */
  590. void realview_fixup(struct machine_desc *mdesc, struct tag *tags, char **from,
  591. struct meminfo *meminfo)
  592. {
  593. /*
  594. * Most RealView platforms have 512MB contiguous RAM at 0x70000000.
  595. * Half of this is mirrored at 0.
  596. */
  597. #ifdef CONFIG_REALVIEW_HIGH_PHYS_OFFSET
  598. meminfo->bank[0].start = 0x70000000;
  599. meminfo->bank[0].size = SZ_512M;
  600. meminfo->nr_banks = 1;
  601. #else
  602. meminfo->bank[0].start = 0;
  603. meminfo->bank[0].size = SZ_256M;
  604. meminfo->nr_banks = 1;
  605. #endif
  606. }