blob: 45868bb43cbd2fbcbfcdfff638dc15f1cbd7d38b [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>
Kay Sieversedbaa602011-12-21 16:26:03 -080024#include <linux/device.h>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000025#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>
Marc Zyngierb8b87ae2011-05-18 10:51:49 +010034#include <linux/mtd/physmap.h>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000035
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>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000044#include <asm/mach/irq.h>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000045#include <asm/mach/map.h>
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000046
47#include <asm/hardware/gic.h>
48
Catalin Marinasee8c9572009-05-30 14:00:17 +010049#include <mach/platform.h>
50#include <mach/irqs.h>
Rob Herring8a9618f2010-10-06 16:18:08 +010051#include <asm/hardware/timer-sp.h>
Catalin Marinasee8c9572009-05-30 14:00:17 +010052
Russell King3cb5ee42011-01-18 20:13:20 +000053#include <plat/clcd.h>
Russell King1da0c892010-12-15 21:56:47 +000054#include <plat/sched_clock.h>
55
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000056#include "core.h"
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000057
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000058#define REALVIEW_FLASHCTRL (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)
59
Marc Zyngier667f3902011-05-18 10:51:55 +010060static void realview_flash_set_vpp(struct platform_device *pdev, int on)
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000061{
62 u32 val;
63
64 val = __raw_readl(REALVIEW_FLASHCTRL);
65 if (on)
66 val |= REALVIEW_FLASHPROG_FLVPPEN;
67 else
68 val &= ~REALVIEW_FLASHPROG_FLVPPEN;
69 __raw_writel(val, REALVIEW_FLASHCTRL);
70}
71
Marc Zyngierb8b87ae2011-05-18 10:51:49 +010072static struct physmap_flash_data realview_flash_data = {
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000073 .width = 4,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000074 .set_vpp = realview_flash_set_vpp,
75};
76
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000077struct platform_device realview_flash_device = {
Marc Zyngierb8b87ae2011-05-18 10:51:49 +010078 .name = "physmap-flash",
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000079 .id = 0,
80 .dev = {
81 .platform_data = &realview_flash_data,
82 },
Catalin Marinas8ad68bb2005-10-31 14:25:02 +000083};
84
Catalin Marinasa44ddfd2008-04-18 22:43:10 +010085int realview_flash_register(struct resource *res, u32 num)
86{
87 realview_flash_device.resource = res;
88 realview_flash_device.num_resources = num;
89 return platform_device_register(&realview_flash_device);
90}
91
Steve Glendinningc5142e82009-01-20 13:23:30 +000092static struct smsc911x_platform_config smsc911x_config = {
93 .flags = SMSC911X_USE_32BIT,
94 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
95 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
96 .phy_interface = PHY_INTERFACE_MODE_MII,
Catalin Marinas0a5b2f62008-12-01 14:54:59 +000097};
98
Catalin Marinas0a381332008-12-01 14:54:58 +000099static struct platform_device realview_eth_device = {
Steve Glendinningc5142e82009-01-20 13:23:30 +0000100 .name = "smsc911x",
Catalin Marinas0a381332008-12-01 14:54:58 +0000101 .id = 0,
102 .num_resources = 2,
103};
104
105int realview_eth_register(const char *name, struct resource *res)
106{
107 if (name)
108 realview_eth_device.name = name;
109 realview_eth_device.resource = res;
Steve Glendinningc5142e82009-01-20 13:23:30 +0000110 if (strcmp(realview_eth_device.name, "smsc911x") == 0)
111 realview_eth_device.dev.platform_data = &smsc911x_config;
Catalin Marinas0a381332008-12-01 14:54:58 +0000112
113 return platform_device_register(&realview_eth_device);
114}
115
Catalin Marinas7db21712009-02-12 16:00:21 +0100116struct platform_device realview_usb_device = {
117 .name = "isp1760",
118 .num_resources = 2,
119};
120
121int realview_usb_register(struct resource *res)
122{
123 realview_usb_device.resource = res;
124 return platform_device_register(&realview_usb_device);
125}
126
Catalin Marinas6be62ba2009-02-12 15:59:21 +0100127static struct pata_platform_info pata_platform_data = {
128 .ioport_shift = 1,
129};
130
131static struct resource pata_resources[] = {
132 [0] = {
133 .start = REALVIEW_CF_BASE,
134 .end = REALVIEW_CF_BASE + 0xff,
135 .flags = IORESOURCE_MEM,
136 },
137 [1] = {
138 .start = REALVIEW_CF_BASE + 0x100,
139 .end = REALVIEW_CF_BASE + SZ_4K - 1,
140 .flags = IORESOURCE_MEM,
141 },
142};
143
144struct platform_device realview_cf_device = {
145 .name = "pata_platform",
146 .id = -1,
147 .num_resources = ARRAY_SIZE(pata_resources),
148 .resource = pata_resources,
149 .dev = {
150 .platform_data = &pata_platform_data,
151 },
152};
153
Russell King6b65cd72006-12-10 21:21:32 +0100154static struct resource realview_i2c_resource = {
155 .start = REALVIEW_I2C_BASE,
156 .end = REALVIEW_I2C_BASE + SZ_4K - 1,
157 .flags = IORESOURCE_MEM,
158};
159
160struct platform_device realview_i2c_device = {
161 .name = "versatile-i2c",
Catalin Marinas533ad5e2009-02-12 15:58:20 +0100162 .id = 0,
Russell King6b65cd72006-12-10 21:21:32 +0100163 .num_resources = 1,
164 .resource = &realview_i2c_resource,
165};
166
Catalin Marinas533ad5e2009-02-12 15:58:20 +0100167static struct i2c_board_info realview_i2c_board_info[] = {
168 {
Russell King64e8be62009-07-18 15:51:55 +0100169 I2C_BOARD_INFO("ds1338", 0xd0 >> 1),
Catalin Marinas533ad5e2009-02-12 15:58:20 +0100170 },
171};
172
173static int __init realview_i2c_init(void)
174{
175 return i2c_register_board_info(0, realview_i2c_board_info,
176 ARRAY_SIZE(realview_i2c_board_info));
177}
178arch_initcall(realview_i2c_init);
179
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000180#define REALVIEW_SYSMCI (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_MCI_OFFSET)
181
Russell King98b09792009-07-09 15:17:41 +0100182/*
183 * This is only used if GPIOLIB support is disabled
184 */
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000185static unsigned int realview_mmc_status(struct device *dev)
186{
187 struct amba_device *adev = container_of(dev, struct amba_device, dev);
188 u32 mask;
189
Linus Walleij48f1d5a2010-07-02 10:24:03 +0100190 if (machine_is_realview_pb1176()) {
191 static bool inserted = false;
192
193 /*
194 * The PB1176 does not have the status register,
195 * assume it is inserted at startup, then invert
196 * for each call so card insertion/removal will
197 * be detected anyway. This will not be called if
198 * GPIO on PL061 is active, which is the proper
199 * way to do this on the PB1176.
200 */
201 inserted = !inserted;
202 return inserted ? 0 : 1;
203 }
204
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000205 if (adev->res.start == REALVIEW_MMCI0_BASE)
206 mask = 1;
207 else
208 mask = 2;
209
Russell King74bc8092010-07-29 15:58:59 +0100210 return readl(REALVIEW_SYSMCI) & mask;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000211}
212
Linus Walleij6ef297f2009-09-22 14:29:36 +0100213struct mmci_platform_data realview_mmc0_plat_data = {
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000214 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
215 .status = realview_mmc_status,
Russell King98b09792009-07-09 15:17:41 +0100216 .gpio_wp = 17,
217 .gpio_cd = 16,
Rabin Vincent29719442010-08-09 12:54:43 +0100218 .cd_invert = true,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000219};
220
Linus Walleij6ef297f2009-09-22 14:29:36 +0100221struct mmci_platform_data realview_mmc1_plat_data = {
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000222 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
223 .status = realview_mmc_status,
Russell King98b09792009-07-09 15:17:41 +0100224 .gpio_wp = 19,
225 .gpio_cd = 18,
Rabin Vincent29719442010-08-09 12:54:43 +0100226 .cd_invert = true,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000227};
228
229/*
230 * Clock handling
231 */
Russell King39c0cb02010-01-16 16:27:28 +0000232static const struct icst_params realview_oscvco_params = {
Russell King64fceb12010-01-16 17:28:44 +0000233 .ref = 24000000,
Russell King4de2edb2010-01-16 18:08:47 +0000234 .vco_max = ICST307_VCO_MAX,
Russell Kinge73a46a2010-01-16 19:49:39 +0000235 .vco_min = ICST307_VCO_MIN,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000236 .vd_min = 4 + 8,
237 .vd_max = 511 + 8,
238 .rd_min = 1 + 2,
239 .rd_max = 127 + 2,
Russell King232eaf72010-01-16 19:46:19 +0000240 .s2div = icst307_s2div,
241 .idx2s = icst307_idx2s,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000242};
243
Russell King39c0cb02010-01-16 16:27:28 +0000244static void realview_oscvco_set(struct clk *clk, struct icst_vco vco)
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000245{
246 void __iomem *sys_lock = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LOCK_OFFSET;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000247 u32 val;
248
Russell Kingd1914c72010-01-14 20:09:34 +0000249 val = readl(clk->vcoreg) & ~0x7ffff;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000250 val |= vco.v | (vco.r << 9) | (vco.s << 16);
251
252 writel(0xa05f, sys_lock);
Russell Kingd1914c72010-01-14 20:09:34 +0000253 writel(val, clk->vcoreg);
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000254 writel(0, sys_lock);
255}
256
Russell King9bf5b2e2010-03-01 16:18:39 +0000257static const struct clk_ops oscvco_clk_ops = {
258 .round = icst_clk_round,
259 .set = icst_clk_set,
260 .setvco = realview_oscvco_set,
261};
262
Russell Kingcf30fb42008-11-08 20:05:55 +0000263static struct clk oscvco_clk = {
Russell King9bf5b2e2010-03-01 16:18:39 +0000264 .ops = &oscvco_clk_ops,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000265 .params = &realview_oscvco_params,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000266};
267
268/*
Russell Kingcf30fb42008-11-08 20:05:55 +0000269 * These are fixed clocks.
270 */
271static struct clk ref24_clk = {
272 .rate = 24000000,
273};
274
Russell King7ff550d2011-05-12 13:31:48 +0100275static struct clk sp804_clk = {
276 .rate = 1000000,
277};
278
Russell King3126c7b2010-07-15 11:01:17 +0100279static struct clk dummy_apb_pclk;
280
Russell Kingcf30fb42008-11-08 20:05:55 +0000281static struct clk_lookup lookups[] = {
Russell King3126c7b2010-07-15 11:01:17 +0100282 { /* Bus clock */
283 .con_id = "apb_pclk",
284 .clk = &dummy_apb_pclk,
285 }, { /* UART0 */
Linus Walleij43215322009-09-21 12:30:32 +0100286 .dev_id = "dev:uart0",
Russell Kingcf30fb42008-11-08 20:05:55 +0000287 .clk = &ref24_clk,
288 }, { /* UART1 */
Linus Walleij43215322009-09-21 12:30:32 +0100289 .dev_id = "dev:uart1",
Russell Kingcf30fb42008-11-08 20:05:55 +0000290 .clk = &ref24_clk,
291 }, { /* UART2 */
Linus Walleij43215322009-09-21 12:30:32 +0100292 .dev_id = "dev:uart2",
Russell Kingcf30fb42008-11-08 20:05:55 +0000293 .clk = &ref24_clk,
294 }, { /* UART3 */
Linus Walleij43215322009-09-21 12:30:32 +0100295 .dev_id = "fpga:uart3",
Russell Kingcf30fb42008-11-08 20:05:55 +0000296 .clk = &ref24_clk,
Linus Walleij48f1d5a2010-07-02 10:24:03 +0100297 }, { /* UART3 is on the dev chip in PB1176 */
298 .dev_id = "dev:uart3",
299 .clk = &ref24_clk,
300 }, { /* UART4 only exists in PB1176 */
301 .dev_id = "fpga:uart4",
302 .clk = &ref24_clk,
Russell Kingcf30fb42008-11-08 20:05:55 +0000303 }, { /* KMI0 */
Linus Walleij43215322009-09-21 12:30:32 +0100304 .dev_id = "fpga:kmi0",
Russell Kingcf30fb42008-11-08 20:05:55 +0000305 .clk = &ref24_clk,
306 }, { /* KMI1 */
Linus Walleij43215322009-09-21 12:30:32 +0100307 .dev_id = "fpga:kmi1",
Russell Kingcf30fb42008-11-08 20:05:55 +0000308 .clk = &ref24_clk,
309 }, { /* MMC0 */
Linus Walleij43215322009-09-21 12:30:32 +0100310 .dev_id = "fpga:mmc0",
Russell Kingcf30fb42008-11-08 20:05:55 +0000311 .clk = &ref24_clk,
Linus Walleij48f1d5a2010-07-02 10:24:03 +0100312 }, { /* CLCD is in the PB1176 and EB DevChip */
Linus Walleij43215322009-09-21 12:30:32 +0100313 .dev_id = "dev:clcd",
Russell Kingcf30fb42008-11-08 20:05:55 +0000314 .clk = &oscvco_clk,
315 }, { /* PB:CLCD */
Linus Walleij43215322009-09-21 12:30:32 +0100316 .dev_id = "issp:clcd",
Russell Kingcf30fb42008-11-08 20:05:55 +0000317 .clk = &oscvco_clk,
Linus Walleijd6ada862010-07-14 23:58:38 +0100318 }, { /* SSP */
319 .dev_id = "dev:ssp0",
320 .clk = &ref24_clk,
Russell King7ff550d2011-05-12 13:31:48 +0100321 }, { /* SP804 timers */
322 .dev_id = "sp804",
323 .clk = &sp804_clk,
324 },
Russell Kingcf30fb42008-11-08 20:05:55 +0000325};
326
Russell King631e55f2011-01-11 13:05:01 +0000327void __init realview_init_early(void)
Russell Kingcf30fb42008-11-08 20:05:55 +0000328{
Russell King631e55f2011-01-11 13:05:01 +0000329 void __iomem *sys = __io_address(REALVIEW_SYS_BASE);
330
Russell Kingd1914c72010-01-14 20:09:34 +0000331 if (machine_is_realview_pb1176())
Russell King631e55f2011-01-11 13:05:01 +0000332 oscvco_clk.vcoreg = sys + REALVIEW_SYS_OSC0_OFFSET;
Russell Kingd1914c72010-01-14 20:09:34 +0000333 else
Russell King631e55f2011-01-11 13:05:01 +0000334 oscvco_clk.vcoreg = sys + REALVIEW_SYS_OSC4_OFFSET;
Russell Kingd1914c72010-01-14 20:09:34 +0000335
Russell King0a0300d2010-01-12 12:28:00 +0000336 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
Russell Kingd1914c72010-01-14 20:09:34 +0000337
Russell King631e55f2011-01-11 13:05:01 +0000338 versatile_sched_clock_init(sys + REALVIEW_SYS_24MHz_OFFSET, 24000000);
Russell Kingcf30fb42008-11-08 20:05:55 +0000339}
Russell Kingcf30fb42008-11-08 20:05:55 +0000340
341/*
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000342 * CLCD support.
343 */
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000344#define SYS_CLCD_NLCDIOON (1 << 2)
345#define SYS_CLCD_VDDPOSSWITCH (1 << 3)
346#define SYS_CLCD_PWR3V5SWITCH (1 << 4)
347#define SYS_CLCD_ID_MASK (0x1f << 8)
348#define SYS_CLCD_ID_SANYO_3_8 (0x00 << 8)
349#define SYS_CLCD_ID_UNKNOWN_8_4 (0x01 << 8)
350#define SYS_CLCD_ID_EPSON_2_2 (0x02 << 8)
351#define SYS_CLCD_ID_SANYO_2_5 (0x07 << 8)
352#define SYS_CLCD_ID_VGA (0x1f << 8)
353
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000354/*
355 * Disable all display connectors on the interface module.
356 */
357static void realview_clcd_disable(struct clcd_fb *fb)
358{
359 void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
360 u32 val;
361
362 val = readl(sys_clcd);
363 val &= ~SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
364 writel(val, sys_clcd);
365}
366
367/*
368 * Enable the relevant connector on the interface module.
369 */
370static void realview_clcd_enable(struct clcd_fb *fb)
371{
372 void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
373 u32 val;
374
Catalin Marinas9e7714d2006-03-16 14:10:20 +0000375 /*
376 * Enable the PSUs
377 */
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000378 val = readl(sys_clcd);
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000379 val |= SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
380 writel(val, sys_clcd);
381}
382
Russell King3cb5ee42011-01-18 20:13:20 +0000383/*
384 * Detect which LCD panel is connected, and return the appropriate
385 * clcd_panel structure. Note: we do not have any information on
386 * the required timings for the 8.4in panel, so we presently assume
387 * VGA timings.
388 */
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000389static int realview_clcd_setup(struct clcd_fb *fb)
390{
Russell King3cb5ee42011-01-18 20:13:20 +0000391 void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
392 const char *panel_name, *vga_panel_name;
Colin Tuckleyc34a1022008-11-10 14:10:12 +0000393 unsigned long framesize;
Russell King3cb5ee42011-01-18 20:13:20 +0000394 u32 val;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000395
Russell King3cb5ee42011-01-18 20:13:20 +0000396 if (machine_is_realview_eb()) {
Colin Tuckleyc34a1022008-11-10 14:10:12 +0000397 /* VGA, 16bpp */
398 framesize = 640 * 480 * 2;
Russell King3cb5ee42011-01-18 20:13:20 +0000399 vga_panel_name = "VGA";
400 } else {
Colin Tuckleyc34a1022008-11-10 14:10:12 +0000401 /* XVGA, 16bpp */
402 framesize = 1024 * 768 * 2;
Russell King3cb5ee42011-01-18 20:13:20 +0000403 vga_panel_name = "XVGA";
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000404 }
405
Russell King3cb5ee42011-01-18 20:13:20 +0000406 val = readl(sys_clcd) & SYS_CLCD_ID_MASK;
407 if (val == SYS_CLCD_ID_SANYO_3_8)
408 panel_name = "Sanyo TM38QV67A02A";
409 else if (val == SYS_CLCD_ID_SANYO_2_5)
410 panel_name = "Sanyo QVGA Portrait";
411 else if (val == SYS_CLCD_ID_EPSON_2_2)
412 panel_name = "Epson L2F50113T00";
413 else if (val == SYS_CLCD_ID_VGA)
414 panel_name = vga_panel_name;
415 else {
416 pr_err("CLCD: unknown LCD panel ID 0x%08x, using VGA\n", val);
417 panel_name = vga_panel_name;
418 }
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000419
Russell King3cb5ee42011-01-18 20:13:20 +0000420 fb->panel = versatile_clcd_get_panel(panel_name);
421 if (!fb->panel)
422 return -EINVAL;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000423
Russell King3cb5ee42011-01-18 20:13:20 +0000424 return versatile_clcd_setup_dma(fb, framesize);
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000425}
426
427struct clcd_board clcd_plat_data = {
428 .name = "RealView",
Russell King3cb5ee42011-01-18 20:13:20 +0000429 .caps = CLCD_CAP_ALL,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000430 .check = clcdfb_check,
431 .decode = clcdfb_decode,
432 .disable = realview_clcd_disable,
433 .enable = realview_clcd_enable,
434 .setup = realview_clcd_setup,
Russell King3cb5ee42011-01-18 20:13:20 +0000435 .mmap = versatile_clcd_mmap_dma,
436 .remove = versatile_clcd_remove_dma,
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000437};
438
439#ifdef CONFIG_LEDS
440#define VA_LEDS_BASE (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LED_OFFSET)
441
442void realview_leds_event(led_event_t ledevt)
443{
444 unsigned long flags;
445 u32 val;
Catalin Marinasda055eb2009-05-30 13:56:16 +0100446 u32 led = 1 << smp_processor_id();
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000447
448 local_irq_save(flags);
449 val = readl(VA_LEDS_BASE);
450
451 switch (ledevt) {
452 case led_idle_start:
Catalin Marinasda055eb2009-05-30 13:56:16 +0100453 val = val & ~led;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000454 break;
455
456 case led_idle_end:
Catalin Marinasda055eb2009-05-30 13:56:16 +0100457 val = val | led;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000458 break;
459
460 case led_timer:
Catalin Marinasda055eb2009-05-30 13:56:16 +0100461 val = val ^ REALVIEW_SYS_LED7;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000462 break;
463
464 case led_halted:
465 val = 0;
466 break;
467
468 default:
469 break;
470 }
471
472 writel(val, VA_LEDS_BASE);
473 local_irq_restore(flags);
474}
475#endif /* CONFIG_LEDS */
476
477/*
478 * Where is the timer (VA)?
479 */
Catalin Marinas80192732008-04-18 22:43:11 +0100480void __iomem *timer0_va_base;
481void __iomem *timer1_va_base;
482void __iomem *timer2_va_base;
483void __iomem *timer3_va_base;
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000484
485/*
Catalin Marinasa8655e82008-02-04 17:30:57 +0100486 * Set up the clock source and clock events devices
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000487 */
Catalin Marinas8cc4c542008-02-04 17:43:02 +0100488void __init realview_timer_init(unsigned int timer_irq)
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000489{
490 u32 val;
491
492 /*
493 * set clock frequency:
494 * REALVIEW_REFCLK is 32KHz
495 * REALVIEW_TIMCLK is 1MHz
496 */
497 val = readl(__io_address(REALVIEW_SCTL_BASE));
498 writel((REALVIEW_TIMCLK << REALVIEW_TIMER1_EnSel) |
499 (REALVIEW_TIMCLK << REALVIEW_TIMER2_EnSel) |
500 (REALVIEW_TIMCLK << REALVIEW_TIMER3_EnSel) |
501 (REALVIEW_TIMCLK << REALVIEW_TIMER4_EnSel) | val,
502 __io_address(REALVIEW_SCTL_BASE));
503
504 /*
505 * Initialise to a known state (all timers off)
506 */
Catalin Marinas80192732008-04-18 22:43:11 +0100507 writel(0, timer0_va_base + TIMER_CTRL);
508 writel(0, timer1_va_base + TIMER_CTRL);
509 writel(0, timer2_va_base + TIMER_CTRL);
510 writel(0, timer3_va_base + TIMER_CTRL);
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000511
Russell Kingfb593cf2011-05-12 12:08:23 +0100512 sp804_clocksource_init(timer3_va_base, "timer3");
Russell King57cc4f72011-05-12 15:31:13 +0100513 sp804_clockevents_init(timer0_va_base, timer_irq, "timer0");
Catalin Marinas8ad68bb2005-10-31 14:25:02 +0000514}
Catalin Marinas5b39d152009-11-04 12:19:04 +0000515
516/*
517 * Setup the memory banks.
518 */
Russell King0744a3e2010-12-20 10:37:50 +0000519void realview_fixup(struct tag *tags, char **from, struct meminfo *meminfo)
Catalin Marinas5b39d152009-11-04 12:19:04 +0000520{
521 /*
522 * Most RealView platforms have 512MB contiguous RAM at 0x70000000.
523 * Half of this is mirrored at 0.
524 */
525#ifdef CONFIG_REALVIEW_HIGH_PHYS_OFFSET
526 meminfo->bank[0].start = 0x70000000;
527 meminfo->bank[0].size = SZ_512M;
528 meminfo->nr_banks = 1;
529#else
530 meminfo->bank[0].start = 0;
531 meminfo->bank[0].size = SZ_256M;
532 meminfo->nr_banks = 1;
533#endif
534}