core.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  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. };
  222. struct mmci_platform_data realview_mmc1_plat_data = {
  223. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  224. .status = realview_mmc_status,
  225. .gpio_wp = 19,
  226. .gpio_cd = 18,
  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. * Where is the timer (VA)?
  573. */
  574. void __iomem *timer0_va_base;
  575. void __iomem *timer1_va_base;
  576. void __iomem *timer2_va_base;
  577. void __iomem *timer3_va_base;
  578. /*
  579. * Set up the clock source and clock events devices
  580. */
  581. void __init realview_timer_init(unsigned int timer_irq)
  582. {
  583. u32 val;
  584. /*
  585. * set clock frequency:
  586. * REALVIEW_REFCLK is 32KHz
  587. * REALVIEW_TIMCLK is 1MHz
  588. */
  589. val = readl(__io_address(REALVIEW_SCTL_BASE));
  590. writel((REALVIEW_TIMCLK << REALVIEW_TIMER1_EnSel) |
  591. (REALVIEW_TIMCLK << REALVIEW_TIMER2_EnSel) |
  592. (REALVIEW_TIMCLK << REALVIEW_TIMER3_EnSel) |
  593. (REALVIEW_TIMCLK << REALVIEW_TIMER4_EnSel) | val,
  594. __io_address(REALVIEW_SCTL_BASE));
  595. /*
  596. * Initialise to a known state (all timers off)
  597. */
  598. writel(0, timer0_va_base + TIMER_CTRL);
  599. writel(0, timer1_va_base + TIMER_CTRL);
  600. writel(0, timer2_va_base + TIMER_CTRL);
  601. writel(0, timer3_va_base + TIMER_CTRL);
  602. sp804_clocksource_init(timer3_va_base);
  603. sp804_clockevents_init(timer0_va_base, timer_irq);
  604. }
  605. /*
  606. * Setup the memory banks.
  607. */
  608. void realview_fixup(struct machine_desc *mdesc, struct tag *tags, char **from,
  609. struct meminfo *meminfo)
  610. {
  611. /*
  612. * Most RealView platforms have 512MB contiguous RAM at 0x70000000.
  613. * Half of this is mirrored at 0.
  614. */
  615. #ifdef CONFIG_REALVIEW_HIGH_PHYS_OFFSET
  616. meminfo->bank[0].start = 0x70000000;
  617. meminfo->bank[0].size = SZ_512M;
  618. meminfo->nr_banks = 1;
  619. #else
  620. meminfo->bank[0].start = 0;
  621. meminfo->bank[0].size = SZ_256M;
  622. meminfo->nr_banks = 1;
  623. #endif
  624. }