core.c 16 KB

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