blob: a18a5a66c4c3995bb6123f7d4689c4a8ab37828e [file] [log] [blame]
Catalin Marinas8ad68bb2005-10-31 14:25:02 +00001/*
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 */
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000021#include <linux/init.h>
Russell King1be72282005-10-31 16:57:06 +000022#include <linux/platform_device.h>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000023#include <linux/dma-mapping.h>
24#include <linux/sysdev.h>
25#include <linux/interrupt.h>
Russell Kinga62c80e2006-01-07 13:52:45 +000026#include <linux/amba/bus.h>
27#include <linux/amba/clcd.h>
Russell Kingfced80c2008-09-06 12:10:45 +010028#include <linux/io.h>
Steve Glendinningc5142e82009-01-20 13:23:30 +000029#include <linux/smsc911x.h>
Catalin Marinas6be62ba2009-02-12 15:59:21 +010030#include <linux/ata_platform.h>
Linus Walleij6ef297f2009-09-22 14:29:36 +010031#include <linux/amba/mmci.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090032#include <linux/gfp.h>
Jean-Christop PLAGNIOL-VILLARD6d803ba2010-11-17 10:04:33 +010033#include <linux/clkdev.h>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000034
35#include <asm/system.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010036#include <mach/hardware.h>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000037#include <asm/irq.h>
38#include <asm/leds.h>
Colin Tuckley68c3d932008-11-10 14:10:11 +000039#include <asm/mach-types.h>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000040#include <asm/hardware/arm_timer.h>
Russell Kingc5a0adb2010-01-16 20:16:10 +000041#include <asm/hardware/icst.h>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000042
43#include <asm/mach/arch.h>
44#include <asm/mach/flash.h>
45#include <asm/mach/irq.h>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000046#include <asm/mach/map.h>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000047
48#include <asm/hardware/gic.h>
49
Catalin Marinasee8c9572009-05-30 14:00:17 +010050#include <mach/platform.h>
51#include <mach/irqs.h>
Rob Herring8a9618f2010-10-06 16:18:08 +010052#include <asm/hardware/timer-sp.h>
Catalin Marinasee8c9572009-05-30 14:00:17 +010053
Russell King3cb5ee42011-01-18 20:13:20 +000054#include <plat/clcd.h>
Russell King1da0c892010-12-15 21:56:47 +000055#include <plat/sched_clock.h>
56
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000057#include "core.h"
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000058
Catalin Marinasc97c5aa2009-11-04 12:19:05 +000059#ifdef CONFIG_ZONE_DMA
60/*
61 * Adjust the zones if there are restrictions for DMA access.
62 */
Russell Kingb65b4782010-05-22 20:58:51 +010063void __init realview_adjust_zones(unsigned long *size, unsigned long *hole)
Catalin Marinasc97c5aa2009-11-04 12:19:05 +000064{
65 unsigned long dma_size = SZ_256M >> PAGE_SHIFT;
66
Russell Kingb65b4782010-05-22 20:58:51 +010067 if (!machine_is_realview_pbx() || size[0] <= dma_size)
Catalin Marinasc97c5aa2009-11-04 12:19:05 +000068 return;
69
70 size[ZONE_NORMAL] = size[0] - dma_size;
71 size[ZONE_DMA] = dma_size;
72 hole[ZONE_NORMAL] = hole[0];
73 hole[ZONE_DMA] = 0;
74}
75#endif
76
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000077
78#define REALVIEW_FLASHCTRL (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)
79
80static int realview_flash_init(void)
81{
82 u32 val;
83
84 val = __raw_readl(REALVIEW_FLASHCTRL);
85 val &= ~REALVIEW_FLASHPROG_FLVPPEN;
86 __raw_writel(val, REALVIEW_FLASHCTRL);
87
88 return 0;
89}
90
91static void realview_flash_exit(void)
92{
93 u32 val;
94
95 val = __raw_readl(REALVIEW_FLASHCTRL);
96 val &= ~REALVIEW_FLASHPROG_FLVPPEN;
97 __raw_writel(val, REALVIEW_FLASHCTRL);
98}
99
100static void realview_flash_set_vpp(int on)
101{
102 u32 val;
103
104 val = __raw_readl(REALVIEW_FLASHCTRL);
105 if (on)
106 val |= REALVIEW_FLASHPROG_FLVPPEN;
107 else
108 val &= ~REALVIEW_FLASHPROG_FLVPPEN;
109 __raw_writel(val, REALVIEW_FLASHCTRL);
110}
111
112static struct flash_platform_data realview_flash_data = {
113 .map_name = "cfi_probe",
114 .width = 4,
115 .init = realview_flash_init,
116 .exit = realview_flash_exit,
117 .set_vpp = realview_flash_set_vpp,
118};
119
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000120struct platform_device realview_flash_device = {
121 .name = "armflash",
122 .id = 0,
123 .dev = {
124 .platform_data = &realview_flash_data,
125 },
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000126};
127
Catalin Marinasa44ddfd2008-04-18 22:43:10 +0100128int realview_flash_register(struct resource *res, u32 num)
129{
130 realview_flash_device.resource = res;
131 realview_flash_device.num_resources = num;
132 return platform_device_register(&realview_flash_device);
133}
134
Steve Glendinningc5142e82009-01-20 13:23:30 +0000135static struct smsc911x_platform_config smsc911x_config = {
136 .flags = SMSC911X_USE_32BIT,
137 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
138 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
139 .phy_interface = PHY_INTERFACE_MODE_MII,
Catalin Marinas0a5b2f62008-12-01 14:54:59 +0000140};
141
Catalin Marinas0a381332008-12-01 14:54:58 +0000142static struct platform_device realview_eth_device = {
Steve Glendinningc5142e82009-01-20 13:23:30 +0000143 .name = "smsc911x",
Catalin Marinas0a381332008-12-01 14:54:58 +0000144 .id = 0,
145 .num_resources = 2,
146};
147
148int realview_eth_register(const char *name, struct resource *res)
149{
150 if (name)
151 realview_eth_device.name = name;
152 realview_eth_device.resource = res;
Steve Glendinningc5142e82009-01-20 13:23:30 +0000153 if (strcmp(realview_eth_device.name, "smsc911x") == 0)
154 realview_eth_device.dev.platform_data = &smsc911x_config;
Catalin Marinas0a381332008-12-01 14:54:58 +0000155
156 return platform_device_register(&realview_eth_device);
157}
158
Catalin Marinas7db21712009-02-12 16:00:21 +0100159struct platform_device realview_usb_device = {
160 .name = "isp1760",
161 .num_resources = 2,
162};
163
164int realview_usb_register(struct resource *res)
165{
166 realview_usb_device.resource = res;
167 return platform_device_register(&realview_usb_device);
168}
169
Catalin Marinas6be62ba2009-02-12 15:59:21 +0100170static struct pata_platform_info pata_platform_data = {
171 .ioport_shift = 1,
172};
173
174static struct resource pata_resources[] = {
175 [0] = {
176 .start = REALVIEW_CF_BASE,
177 .end = REALVIEW_CF_BASE + 0xff,
178 .flags = IORESOURCE_MEM,
179 },
180 [1] = {
181 .start = REALVIEW_CF_BASE + 0x100,
182 .end = REALVIEW_CF_BASE + SZ_4K - 1,
183 .flags = IORESOURCE_MEM,
184 },
185};
186
187struct platform_device realview_cf_device = {
188 .name = "pata_platform",
189 .id = -1,
190 .num_resources = ARRAY_SIZE(pata_resources),
191 .resource = pata_resources,
192 .dev = {
193 .platform_data = &pata_platform_data,
194 },
195};
196
Russell King6b65cd72006-12-10 21:21:32 +0100197static struct resource realview_i2c_resource = {
198 .start = REALVIEW_I2C_BASE,
199 .end = REALVIEW_I2C_BASE + SZ_4K - 1,
200 .flags = IORESOURCE_MEM,
201};
202
203struct platform_device realview_i2c_device = {
204 .name = "versatile-i2c",
Catalin Marinas533ad5e2009-02-12 15:58:20 +0100205 .id = 0,
Russell King6b65cd72006-12-10 21:21:32 +0100206 .num_resources = 1,
207 .resource = &realview_i2c_resource,
208};
209
Catalin Marinas533ad5e2009-02-12 15:58:20 +0100210static struct i2c_board_info realview_i2c_board_info[] = {
211 {
Russell King64e8be62009-07-18 15:51:55 +0100212 I2C_BOARD_INFO("ds1338", 0xd0 >> 1),
Catalin Marinas533ad5e2009-02-12 15:58:20 +0100213 },
214};
215
216static int __init realview_i2c_init(void)
217{
218 return i2c_register_board_info(0, realview_i2c_board_info,
219 ARRAY_SIZE(realview_i2c_board_info));
220}
221arch_initcall(realview_i2c_init);
222
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000223#define REALVIEW_SYSMCI (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_MCI_OFFSET)
224
Russell King98b09792009-07-09 15:17:41 +0100225/*
226 * This is only used if GPIOLIB support is disabled
227 */
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000228static unsigned int realview_mmc_status(struct device *dev)
229{
230 struct amba_device *adev = container_of(dev, struct amba_device, dev);
231 u32 mask;
232
Linus Walleij48f1d5a2010-07-02 10:24:03 +0100233 if (machine_is_realview_pb1176()) {
234 static bool inserted = false;
235
236 /*
237 * The PB1176 does not have the status register,
238 * assume it is inserted at startup, then invert
239 * for each call so card insertion/removal will
240 * be detected anyway. This will not be called if
241 * GPIO on PL061 is active, which is the proper
242 * way to do this on the PB1176.
243 */
244 inserted = !inserted;
245 return inserted ? 0 : 1;
246 }
247
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000248 if (adev->res.start == REALVIEW_MMCI0_BASE)
249 mask = 1;
250 else
251 mask = 2;
252
Russell King74bc8092010-07-29 15:58:59 +0100253 return readl(REALVIEW_SYSMCI) & mask;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000254}
255
Linus Walleij6ef297f2009-09-22 14:29:36 +0100256struct mmci_platform_data realview_mmc0_plat_data = {
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000257 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
258 .status = realview_mmc_status,
Russell King98b09792009-07-09 15:17:41 +0100259 .gpio_wp = 17,
260 .gpio_cd = 16,
Rabin Vincent29719442010-08-09 12:54:43 +0100261 .cd_invert = true,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000262};
263
Linus Walleij6ef297f2009-09-22 14:29:36 +0100264struct mmci_platform_data realview_mmc1_plat_data = {
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000265 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
266 .status = realview_mmc_status,
Russell King98b09792009-07-09 15:17:41 +0100267 .gpio_wp = 19,
268 .gpio_cd = 18,
Rabin Vincent29719442010-08-09 12:54:43 +0100269 .cd_invert = true,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000270};
271
272/*
273 * Clock handling
274 */
Russell King39c0cb02010-01-16 16:27:28 +0000275static const struct icst_params realview_oscvco_params = {
Russell King64fceb12010-01-16 17:28:44 +0000276 .ref = 24000000,
Russell King4de2edb2010-01-16 18:08:47 +0000277 .vco_max = ICST307_VCO_MAX,
Russell Kinge73a46a2010-01-16 19:49:39 +0000278 .vco_min = ICST307_VCO_MIN,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000279 .vd_min = 4 + 8,
280 .vd_max = 511 + 8,
281 .rd_min = 1 + 2,
282 .rd_max = 127 + 2,
Russell King232eaf72010-01-16 19:46:19 +0000283 .s2div = icst307_s2div,
284 .idx2s = icst307_idx2s,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000285};
286
Russell King39c0cb02010-01-16 16:27:28 +0000287static void realview_oscvco_set(struct clk *clk, struct icst_vco vco)
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000288{
289 void __iomem *sys_lock = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LOCK_OFFSET;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000290 u32 val;
291
Russell Kingd1914c72010-01-14 20:09:34 +0000292 val = readl(clk->vcoreg) & ~0x7ffff;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000293 val |= vco.v | (vco.r << 9) | (vco.s << 16);
294
295 writel(0xa05f, sys_lock);
Russell Kingd1914c72010-01-14 20:09:34 +0000296 writel(val, clk->vcoreg);
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000297 writel(0, sys_lock);
298}
299
Russell King9bf5b2e2010-03-01 16:18:39 +0000300static const struct clk_ops oscvco_clk_ops = {
301 .round = icst_clk_round,
302 .set = icst_clk_set,
303 .setvco = realview_oscvco_set,
304};
305
Russell Kingcf30fb42008-11-08 20:05:55 +0000306static struct clk oscvco_clk = {
Russell King9bf5b2e2010-03-01 16:18:39 +0000307 .ops = &oscvco_clk_ops,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000308 .params = &realview_oscvco_params,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000309};
310
311/*
Russell Kingcf30fb42008-11-08 20:05:55 +0000312 * These are fixed clocks.
313 */
314static struct clk ref24_clk = {
315 .rate = 24000000,
316};
317
Russell King3126c7b2010-07-15 11:01:17 +0100318static struct clk dummy_apb_pclk;
319
Russell Kingcf30fb42008-11-08 20:05:55 +0000320static struct clk_lookup lookups[] = {
Russell King3126c7b2010-07-15 11:01:17 +0100321 { /* Bus clock */
322 .con_id = "apb_pclk",
323 .clk = &dummy_apb_pclk,
324 }, { /* UART0 */
Linus Walleij43215322009-09-21 12:30:32 +0100325 .dev_id = "dev:uart0",
Russell Kingcf30fb42008-11-08 20:05:55 +0000326 .clk = &ref24_clk,
327 }, { /* UART1 */
Linus Walleij43215322009-09-21 12:30:32 +0100328 .dev_id = "dev:uart1",
Russell Kingcf30fb42008-11-08 20:05:55 +0000329 .clk = &ref24_clk,
330 }, { /* UART2 */
Linus Walleij43215322009-09-21 12:30:32 +0100331 .dev_id = "dev:uart2",
Russell Kingcf30fb42008-11-08 20:05:55 +0000332 .clk = &ref24_clk,
333 }, { /* UART3 */
Linus Walleij43215322009-09-21 12:30:32 +0100334 .dev_id = "fpga:uart3",
Russell Kingcf30fb42008-11-08 20:05:55 +0000335 .clk = &ref24_clk,
Linus Walleij48f1d5a2010-07-02 10:24:03 +0100336 }, { /* UART3 is on the dev chip in PB1176 */
337 .dev_id = "dev:uart3",
338 .clk = &ref24_clk,
339 }, { /* UART4 only exists in PB1176 */
340 .dev_id = "fpga:uart4",
341 .clk = &ref24_clk,
Russell Kingcf30fb42008-11-08 20:05:55 +0000342 }, { /* KMI0 */
Linus Walleij43215322009-09-21 12:30:32 +0100343 .dev_id = "fpga:kmi0",
Russell Kingcf30fb42008-11-08 20:05:55 +0000344 .clk = &ref24_clk,
345 }, { /* KMI1 */
Linus Walleij43215322009-09-21 12:30:32 +0100346 .dev_id = "fpga:kmi1",
Russell Kingcf30fb42008-11-08 20:05:55 +0000347 .clk = &ref24_clk,
348 }, { /* MMC0 */
Linus Walleij43215322009-09-21 12:30:32 +0100349 .dev_id = "fpga:mmc0",
Russell Kingcf30fb42008-11-08 20:05:55 +0000350 .clk = &ref24_clk,
Linus Walleij48f1d5a2010-07-02 10:24:03 +0100351 }, { /* CLCD is in the PB1176 and EB DevChip */
Linus Walleij43215322009-09-21 12:30:32 +0100352 .dev_id = "dev:clcd",
Russell Kingcf30fb42008-11-08 20:05:55 +0000353 .clk = &oscvco_clk,
354 }, { /* PB:CLCD */
Linus Walleij43215322009-09-21 12:30:32 +0100355 .dev_id = "issp:clcd",
Russell Kingcf30fb42008-11-08 20:05:55 +0000356 .clk = &oscvco_clk,
Linus Walleijd6ada862010-07-14 23:58:38 +0100357 }, { /* SSP */
358 .dev_id = "dev:ssp0",
359 .clk = &ref24_clk,
Russell Kingcf30fb42008-11-08 20:05:55 +0000360 }
361};
362
363static int __init clk_init(void)
364{
Russell Kingd1914c72010-01-14 20:09:34 +0000365 if (machine_is_realview_pb1176())
366 oscvco_clk.vcoreg = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC0_OFFSET;
367 else
368 oscvco_clk.vcoreg = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC4_OFFSET;
369
Russell King0a0300d2010-01-12 12:28:00 +0000370 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
Russell Kingd1914c72010-01-14 20:09:34 +0000371
Russell Kingcf30fb42008-11-08 20:05:55 +0000372 return 0;
373}
Linus Walleij06385e42010-07-30 16:36:25 +0100374core_initcall(clk_init);
Russell Kingcf30fb42008-11-08 20:05:55 +0000375
376/*
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000377 * CLCD support.
378 */
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000379#define SYS_CLCD_NLCDIOON (1 << 2)
380#define SYS_CLCD_VDDPOSSWITCH (1 << 3)
381#define SYS_CLCD_PWR3V5SWITCH (1 << 4)
382#define SYS_CLCD_ID_MASK (0x1f << 8)
383#define SYS_CLCD_ID_SANYO_3_8 (0x00 << 8)
384#define SYS_CLCD_ID_UNKNOWN_8_4 (0x01 << 8)
385#define SYS_CLCD_ID_EPSON_2_2 (0x02 << 8)
386#define SYS_CLCD_ID_SANYO_2_5 (0x07 << 8)
387#define SYS_CLCD_ID_VGA (0x1f << 8)
388
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000389/*
390 * Disable all display connectors on the interface module.
391 */
392static void realview_clcd_disable(struct clcd_fb *fb)
393{
394 void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
395 u32 val;
396
397 val = readl(sys_clcd);
398 val &= ~SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
399 writel(val, sys_clcd);
400}
401
402/*
403 * Enable the relevant connector on the interface module.
404 */
405static void realview_clcd_enable(struct clcd_fb *fb)
406{
407 void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
408 u32 val;
409
Catalin Marinas9e7714d2006-03-16 14:10:20 +0000410 /*
411 * Enable the PSUs
412 */
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000413 val = readl(sys_clcd);
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000414 val |= SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
415 writel(val, sys_clcd);
416}
417
Russell King3cb5ee42011-01-18 20:13:20 +0000418/*
419 * Detect which LCD panel is connected, and return the appropriate
420 * clcd_panel structure. Note: we do not have any information on
421 * the required timings for the 8.4in panel, so we presently assume
422 * VGA timings.
423 */
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000424static int realview_clcd_setup(struct clcd_fb *fb)
425{
Russell King3cb5ee42011-01-18 20:13:20 +0000426 void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
427 const char *panel_name, *vga_panel_name;
Colin Tuckleyc34a1022008-11-10 14:10:12 +0000428 unsigned long framesize;
Russell King3cb5ee42011-01-18 20:13:20 +0000429 u32 val;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000430
Russell King3cb5ee42011-01-18 20:13:20 +0000431 if (machine_is_realview_eb()) {
Colin Tuckleyc34a1022008-11-10 14:10:12 +0000432 /* VGA, 16bpp */
433 framesize = 640 * 480 * 2;
Russell King3cb5ee42011-01-18 20:13:20 +0000434 vga_panel_name = "VGA";
435 } else {
Colin Tuckleyc34a1022008-11-10 14:10:12 +0000436 /* XVGA, 16bpp */
437 framesize = 1024 * 768 * 2;
Russell King3cb5ee42011-01-18 20:13:20 +0000438 vga_panel_name = "XVGA";
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000439 }
440
Russell King3cb5ee42011-01-18 20:13:20 +0000441 val = readl(sys_clcd) & SYS_CLCD_ID_MASK;
442 if (val == SYS_CLCD_ID_SANYO_3_8)
443 panel_name = "Sanyo TM38QV67A02A";
444 else if (val == SYS_CLCD_ID_SANYO_2_5)
445 panel_name = "Sanyo QVGA Portrait";
446 else if (val == SYS_CLCD_ID_EPSON_2_2)
447 panel_name = "Epson L2F50113T00";
448 else if (val == SYS_CLCD_ID_VGA)
449 panel_name = vga_panel_name;
450 else {
451 pr_err("CLCD: unknown LCD panel ID 0x%08x, using VGA\n", val);
452 panel_name = vga_panel_name;
453 }
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000454
Russell King3cb5ee42011-01-18 20:13:20 +0000455 fb->panel = versatile_clcd_get_panel(panel_name);
456 if (!fb->panel)
457 return -EINVAL;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000458
Russell King3cb5ee42011-01-18 20:13:20 +0000459 return versatile_clcd_setup_dma(fb, framesize);
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000460}
461
462struct clcd_board clcd_plat_data = {
463 .name = "RealView",
Russell King3cb5ee42011-01-18 20:13:20 +0000464 .caps = CLCD_CAP_ALL,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000465 .check = clcdfb_check,
466 .decode = clcdfb_decode,
467 .disable = realview_clcd_disable,
468 .enable = realview_clcd_enable,
469 .setup = realview_clcd_setup,
Russell King3cb5ee42011-01-18 20:13:20 +0000470 .mmap = versatile_clcd_mmap_dma,
471 .remove = versatile_clcd_remove_dma,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000472};
473
474#ifdef CONFIG_LEDS
475#define VA_LEDS_BASE (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LED_OFFSET)
476
477void realview_leds_event(led_event_t ledevt)
478{
479 unsigned long flags;
480 u32 val;
Catalin Marinasda055eb2009-05-30 13:56:16 +0100481 u32 led = 1 << smp_processor_id();
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000482
483 local_irq_save(flags);
484 val = readl(VA_LEDS_BASE);
485
486 switch (ledevt) {
487 case led_idle_start:
Catalin Marinasda055eb2009-05-30 13:56:16 +0100488 val = val & ~led;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000489 break;
490
491 case led_idle_end:
Catalin Marinasda055eb2009-05-30 13:56:16 +0100492 val = val | led;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000493 break;
494
495 case led_timer:
Catalin Marinasda055eb2009-05-30 13:56:16 +0100496 val = val ^ REALVIEW_SYS_LED7;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000497 break;
498
499 case led_halted:
500 val = 0;
501 break;
502
503 default:
504 break;
505 }
506
507 writel(val, VA_LEDS_BASE);
508 local_irq_restore(flags);
509}
510#endif /* CONFIG_LEDS */
511
512/*
Russell King1da0c892010-12-15 21:56:47 +0000513 * The sched_clock counter
514 */
515#define REFCOUNTER (__io_address(REALVIEW_SYS_BASE) + \
516 REALVIEW_SYS_24MHz_OFFSET)
517
518/*
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000519 * Where is the timer (VA)?
520 */
Catalin Marinas80192732008-04-18 22:43:11 +0100521void __iomem *timer0_va_base;
522void __iomem *timer1_va_base;
523void __iomem *timer2_va_base;
524void __iomem *timer3_va_base;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000525
526/*
Catalin Marinasa8655e82008-02-04 17:30:57 +0100527 * Set up the clock source and clock events devices
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000528 */
Catalin Marinas8cc4c542008-02-04 17:43:02 +0100529void __init realview_timer_init(unsigned int timer_irq)
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000530{
531 u32 val;
532
Russell King1da0c892010-12-15 21:56:47 +0000533 versatile_sched_clock_init(REFCOUNTER, 24000000);
534
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000535 /*
536 * set clock frequency:
537 * REALVIEW_REFCLK is 32KHz
538 * REALVIEW_TIMCLK is 1MHz
539 */
540 val = readl(__io_address(REALVIEW_SCTL_BASE));
541 writel((REALVIEW_TIMCLK << REALVIEW_TIMER1_EnSel) |
542 (REALVIEW_TIMCLK << REALVIEW_TIMER2_EnSel) |
543 (REALVIEW_TIMCLK << REALVIEW_TIMER3_EnSel) |
544 (REALVIEW_TIMCLK << REALVIEW_TIMER4_EnSel) | val,
545 __io_address(REALVIEW_SCTL_BASE));
546
547 /*
548 * Initialise to a known state (all timers off)
549 */
Catalin Marinas80192732008-04-18 22:43:11 +0100550 writel(0, timer0_va_base + TIMER_CTRL);
551 writel(0, timer1_va_base + TIMER_CTRL);
552 writel(0, timer2_va_base + TIMER_CTRL);
553 writel(0, timer3_va_base + TIMER_CTRL);
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000554
Russell Kinge3887712010-01-14 13:30:16 +0000555 sp804_clocksource_init(timer3_va_base);
556 sp804_clockevents_init(timer0_va_base, timer_irq);
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000557}
Catalin Marinas5b39d152009-11-04 12:19:04 +0000558
559/*
560 * Setup the memory banks.
561 */
562void realview_fixup(struct machine_desc *mdesc, struct tag *tags, char **from,
563 struct meminfo *meminfo)
564{
565 /*
566 * Most RealView platforms have 512MB contiguous RAM at 0x70000000.
567 * Half of this is mirrored at 0.
568 */
569#ifdef CONFIG_REALVIEW_HIGH_PHYS_OFFSET
570 meminfo->bank[0].start = 0x70000000;
571 meminfo->bank[0].size = SZ_512M;
572 meminfo->nr_banks = 1;
573#else
574 meminfo->bank[0].start = 0;
575 meminfo->bank[0].size = SZ_256M;
576 meminfo->nr_banks = 1;
577#endif
578}