core.c 16 KB

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