core.c 16 KB

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