2005-10-31 15:25:02 +01:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/mach-realview/core.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 - 2003 ARM Limited
|
|
|
|
* Copyright (C) 2000 Deep Blue Solutions Ltd
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
2005-10-31 17:57:06 +01:00
|
|
|
#include <linux/platform_device.h>
|
2005-10-31 15:25:02 +01:00
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/sysdev.h>
|
|
|
|
#include <linux/interrupt.h>
|
2006-01-07 14:52:45 +01:00
|
|
|
#include <linux/amba/bus.h>
|
|
|
|
#include <linux/amba/clcd.h>
|
2008-09-06 13:10:45 +02:00
|
|
|
#include <linux/io.h>
|
2009-01-20 14:23:30 +01:00
|
|
|
#include <linux/smsc911x.h>
|
2009-02-12 15:59:21 +01:00
|
|
|
#include <linux/ata_platform.h>
|
2009-09-22 15:29:36 +02:00
|
|
|
#include <linux/amba/mmci.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 09:04:11 +01:00
|
|
|
#include <linux/gfp.h>
|
2010-11-17 10:04:33 +01:00
|
|
|
#include <linux/clkdev.h>
|
2005-10-31 15:25:02 +01:00
|
|
|
|
|
|
|
#include <asm/system.h>
|
2008-08-05 17:14:15 +02:00
|
|
|
#include <mach/hardware.h>
|
2005-10-31 15:25:02 +01:00
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/leds.h>
|
2008-11-10 15:10:11 +01:00
|
|
|
#include <asm/mach-types.h>
|
2005-10-31 15:25:02 +01:00
|
|
|
#include <asm/hardware/arm_timer.h>
|
2010-01-16 21:16:10 +01:00
|
|
|
#include <asm/hardware/icst.h>
|
2005-10-31 15:25:02 +01:00
|
|
|
|
|
|
|
#include <asm/mach/arch.h>
|
|
|
|
#include <asm/mach/flash.h>
|
|
|
|
#include <asm/mach/irq.h>
|
|
|
|
#include <asm/mach/map.h>
|
|
|
|
|
|
|
|
#include <asm/hardware/gic.h>
|
|
|
|
|
2009-05-30 15:00:17 +02:00
|
|
|
#include <mach/platform.h>
|
|
|
|
#include <mach/irqs.h>
|
2010-10-06 17:18:08 +02:00
|
|
|
#include <asm/hardware/timer-sp.h>
|
2009-05-30 15:00:17 +02:00
|
|
|
|
2011-01-18 21:13:20 +01:00
|
|
|
#include <plat/clcd.h>
|
2010-12-15 22:56:47 +01:00
|
|
|
#include <plat/sched_clock.h>
|
|
|
|
|
2005-10-31 15:25:02 +01:00
|
|
|
#include "core.h"
|
|
|
|
|
2009-11-04 13:19:05 +01:00
|
|
|
#ifdef CONFIG_ZONE_DMA
|
|
|
|
/*
|
|
|
|
* Adjust the zones if there are restrictions for DMA access.
|
|
|
|
*/
|
2010-05-22 21:58:51 +02:00
|
|
|
void __init realview_adjust_zones(unsigned long *size, unsigned long *hole)
|
2009-11-04 13:19:05 +01:00
|
|
|
{
|
|
|
|
unsigned long dma_size = SZ_256M >> PAGE_SHIFT;
|
|
|
|
|
2010-05-22 21:58:51 +02:00
|
|
|
if (!machine_is_realview_pbx() || size[0] <= dma_size)
|
2009-11-04 13:19:05 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
size[ZONE_NORMAL] = size[0] - dma_size;
|
|
|
|
size[ZONE_DMA] = dma_size;
|
|
|
|
hole[ZONE_NORMAL] = hole[0];
|
|
|
|
hole[ZONE_DMA] = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-10-31 15:25:02 +01:00
|
|
|
|
|
|
|
#define REALVIEW_FLASHCTRL (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)
|
|
|
|
|
|
|
|
static int realview_flash_init(void)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
val = __raw_readl(REALVIEW_FLASHCTRL);
|
|
|
|
val &= ~REALVIEW_FLASHPROG_FLVPPEN;
|
|
|
|
__raw_writel(val, REALVIEW_FLASHCTRL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void realview_flash_exit(void)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
val = __raw_readl(REALVIEW_FLASHCTRL);
|
|
|
|
val &= ~REALVIEW_FLASHPROG_FLVPPEN;
|
|
|
|
__raw_writel(val, REALVIEW_FLASHCTRL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void realview_flash_set_vpp(int on)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
val = __raw_readl(REALVIEW_FLASHCTRL);
|
|
|
|
if (on)
|
|
|
|
val |= REALVIEW_FLASHPROG_FLVPPEN;
|
|
|
|
else
|
|
|
|
val &= ~REALVIEW_FLASHPROG_FLVPPEN;
|
|
|
|
__raw_writel(val, REALVIEW_FLASHCTRL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct flash_platform_data realview_flash_data = {
|
|
|
|
.map_name = "cfi_probe",
|
|
|
|
.width = 4,
|
|
|
|
.init = realview_flash_init,
|
|
|
|
.exit = realview_flash_exit,
|
|
|
|
.set_vpp = realview_flash_set_vpp,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct platform_device realview_flash_device = {
|
|
|
|
.name = "armflash",
|
|
|
|
.id = 0,
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &realview_flash_data,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2008-04-18 23:43:10 +02:00
|
|
|
int realview_flash_register(struct resource *res, u32 num)
|
|
|
|
{
|
|
|
|
realview_flash_device.resource = res;
|
|
|
|
realview_flash_device.num_resources = num;
|
|
|
|
return platform_device_register(&realview_flash_device);
|
|
|
|
}
|
|
|
|
|
2009-01-20 14:23:30 +01:00
|
|
|
static struct smsc911x_platform_config smsc911x_config = {
|
|
|
|
.flags = SMSC911X_USE_32BIT,
|
|
|
|
.irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
|
|
|
|
.irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
|
|
|
|
.phy_interface = PHY_INTERFACE_MODE_MII,
|
2008-12-01 15:54:59 +01:00
|
|
|
};
|
|
|
|
|
2008-12-01 15:54:58 +01:00
|
|
|
static struct platform_device realview_eth_device = {
|
2009-01-20 14:23:30 +01:00
|
|
|
.name = "smsc911x",
|
2008-12-01 15:54:58 +01:00
|
|
|
.id = 0,
|
|
|
|
.num_resources = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
int realview_eth_register(const char *name, struct resource *res)
|
|
|
|
{
|
|
|
|
if (name)
|
|
|
|
realview_eth_device.name = name;
|
|
|
|
realview_eth_device.resource = res;
|
2009-01-20 14:23:30 +01:00
|
|
|
if (strcmp(realview_eth_device.name, "smsc911x") == 0)
|
|
|
|
realview_eth_device.dev.platform_data = &smsc911x_config;
|
2008-12-01 15:54:58 +01:00
|
|
|
|
|
|
|
return platform_device_register(&realview_eth_device);
|
2009-02-12 16:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct platform_device realview_usb_device = {
|
|
|
|
.name = "isp1760",
|
|
|
|
.num_resources = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
int realview_usb_register(struct resource *res)
|
|
|
|
{
|
|
|
|
realview_usb_device.resource = res;
|
|
|
|
return platform_device_register(&realview_usb_device);
|
2008-12-01 15:54:58 +01:00
|
|
|
}
|
|
|
|
|
2009-02-12 15:59:21 +01:00
|
|
|
static struct pata_platform_info pata_platform_data = {
|
|
|
|
.ioport_shift = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource pata_resources[] = {
|
|
|
|
[0] = {
|
|
|
|
.start = REALVIEW_CF_BASE,
|
|
|
|
.end = REALVIEW_CF_BASE + 0xff,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
},
|
|
|
|
[1] = {
|
|
|
|
.start = REALVIEW_CF_BASE + 0x100,
|
|
|
|
.end = REALVIEW_CF_BASE + SZ_4K - 1,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
struct platform_device realview_cf_device = {
|
|
|
|
.name = "pata_platform",
|
|
|
|
.id = -1,
|
|
|
|
.num_resources = ARRAY_SIZE(pata_resources),
|
|
|
|
.resource = pata_resources,
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &pata_platform_data,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2006-12-10 21:21:32 +01:00
|
|
|
static struct resource realview_i2c_resource = {
|
|
|
|
.start = REALVIEW_I2C_BASE,
|
|
|
|
.end = REALVIEW_I2C_BASE + SZ_4K - 1,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct platform_device realview_i2c_device = {
|
|
|
|
.name = "versatile-i2c",
|
2009-02-12 15:58:20 +01:00
|
|
|
.id = 0,
|
2006-12-10 21:21:32 +01:00
|
|
|
.num_resources = 1,
|
|
|
|
.resource = &realview_i2c_resource,
|
|
|
|
};
|
|
|
|
|
2009-02-12 15:58:20 +01:00
|
|
|
static struct i2c_board_info realview_i2c_board_info[] = {
|
|
|
|
{
|
2009-07-18 16:51:55 +02:00
|
|
|
I2C_BOARD_INFO("ds1338", 0xd0 >> 1),
|
2009-02-12 15:58:20 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init realview_i2c_init(void)
|
|
|
|
{
|
|
|
|
return i2c_register_board_info(0, realview_i2c_board_info,
|
|
|
|
ARRAY_SIZE(realview_i2c_board_info));
|
|
|
|
}
|
|
|
|
arch_initcall(realview_i2c_init);
|
|
|
|
|
2005-10-31 15:25:02 +01:00
|
|
|
#define REALVIEW_SYSMCI (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_MCI_OFFSET)
|
|
|
|
|
2009-07-09 16:17:41 +02:00
|
|
|
/*
|
|
|
|
* This is only used if GPIOLIB support is disabled
|
|
|
|
*/
|
2005-10-31 15:25:02 +01:00
|
|
|
static unsigned int realview_mmc_status(struct device *dev)
|
|
|
|
{
|
|
|
|
struct amba_device *adev = container_of(dev, struct amba_device, dev);
|
|
|
|
u32 mask;
|
|
|
|
|
2010-07-02 11:24:03 +02:00
|
|
|
if (machine_is_realview_pb1176()) {
|
|
|
|
static bool inserted = false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The PB1176 does not have the status register,
|
|
|
|
* assume it is inserted at startup, then invert
|
|
|
|
* for each call so card insertion/removal will
|
|
|
|
* be detected anyway. This will not be called if
|
|
|
|
* GPIO on PL061 is active, which is the proper
|
|
|
|
* way to do this on the PB1176.
|
|
|
|
*/
|
|
|
|
inserted = !inserted;
|
|
|
|
return inserted ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
2005-10-31 15:25:02 +01:00
|
|
|
if (adev->res.start == REALVIEW_MMCI0_BASE)
|
|
|
|
mask = 1;
|
|
|
|
else
|
|
|
|
mask = 2;
|
|
|
|
|
2010-07-29 16:58:59 +02:00
|
|
|
return readl(REALVIEW_SYSMCI) & mask;
|
2005-10-31 15:25:02 +01:00
|
|
|
}
|
|
|
|
|
2009-09-22 15:29:36 +02:00
|
|
|
struct mmci_platform_data realview_mmc0_plat_data = {
|
2005-10-31 15:25:02 +01:00
|
|
|
.ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
|
|
|
|
.status = realview_mmc_status,
|
2009-07-09 16:17:41 +02:00
|
|
|
.gpio_wp = 17,
|
|
|
|
.gpio_cd = 16,
|
2010-08-09 13:54:43 +02:00
|
|
|
.cd_invert = true,
|
2005-10-31 15:25:02 +01:00
|
|
|
};
|
|
|
|
|
2009-09-22 15:29:36 +02:00
|
|
|
struct mmci_platform_data realview_mmc1_plat_data = {
|
2005-10-31 15:25:02 +01:00
|
|
|
.ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
|
|
|
|
.status = realview_mmc_status,
|
2009-07-09 16:17:41 +02:00
|
|
|
.gpio_wp = 19,
|
|
|
|
.gpio_cd = 18,
|
2010-08-09 13:54:43 +02:00
|
|
|
.cd_invert = true,
|
2005-10-31 15:25:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clock handling
|
|
|
|
*/
|
2010-01-16 17:27:28 +01:00
|
|
|
static const struct icst_params realview_oscvco_params = {
|
2010-01-16 18:28:44 +01:00
|
|
|
.ref = 24000000,
|
2010-01-16 19:08:47 +01:00
|
|
|
.vco_max = ICST307_VCO_MAX,
|
2010-01-16 20:49:39 +01:00
|
|
|
.vco_min = ICST307_VCO_MIN,
|
2005-10-31 15:25:02 +01:00
|
|
|
.vd_min = 4 + 8,
|
|
|
|
.vd_max = 511 + 8,
|
|
|
|
.rd_min = 1 + 2,
|
|
|
|
.rd_max = 127 + 2,
|
2010-01-16 20:46:19 +01:00
|
|
|
.s2div = icst307_s2div,
|
|
|
|
.idx2s = icst307_idx2s,
|
2005-10-31 15:25:02 +01:00
|
|
|
};
|
|
|
|
|
2010-01-16 17:27:28 +01:00
|
|
|
static void realview_oscvco_set(struct clk *clk, struct icst_vco vco)
|
2005-10-31 15:25:02 +01:00
|
|
|
{
|
|
|
|
void __iomem *sys_lock = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LOCK_OFFSET;
|
|
|
|
u32 val;
|
|
|
|
|
2010-01-14 21:09:34 +01:00
|
|
|
val = readl(clk->vcoreg) & ~0x7ffff;
|
2005-10-31 15:25:02 +01:00
|
|
|
val |= vco.v | (vco.r << 9) | (vco.s << 16);
|
|
|
|
|
|
|
|
writel(0xa05f, sys_lock);
|
2010-01-14 21:09:34 +01:00
|
|
|
writel(val, clk->vcoreg);
|
2005-10-31 15:25:02 +01:00
|
|
|
writel(0, sys_lock);
|
|
|
|
}
|
|
|
|
|
2010-03-01 17:18:39 +01:00
|
|
|
static const struct clk_ops oscvco_clk_ops = {
|
|
|
|
.round = icst_clk_round,
|
|
|
|
.set = icst_clk_set,
|
|
|
|
.setvco = realview_oscvco_set,
|
|
|
|
};
|
|
|
|
|
2008-11-08 21:05:55 +01:00
|
|
|
static struct clk oscvco_clk = {
|
2010-03-01 17:18:39 +01:00
|
|
|
.ops = &oscvco_clk_ops,
|
2005-10-31 15:25:02 +01:00
|
|
|
.params = &realview_oscvco_params,
|
|
|
|
};
|
|
|
|
|
2008-11-08 21:05:55 +01:00
|
|
|
/*
|
|
|
|
* These are fixed clocks.
|
|
|
|
*/
|
|
|
|
static struct clk ref24_clk = {
|
|
|
|
.rate = 24000000,
|
|
|
|
};
|
|
|
|
|
2011-05-12 14:31:48 +02:00
|
|
|
static struct clk sp804_clk = {
|
|
|
|
.rate = 1000000,
|
|
|
|
};
|
|
|
|
|
2010-07-15 12:01:17 +02:00
|
|
|
static struct clk dummy_apb_pclk;
|
|
|
|
|
2008-11-08 21:05:55 +01:00
|
|
|
static struct clk_lookup lookups[] = {
|
2010-07-15 12:01:17 +02:00
|
|
|
{ /* Bus clock */
|
|
|
|
.con_id = "apb_pclk",
|
|
|
|
.clk = &dummy_apb_pclk,
|
|
|
|
}, { /* UART0 */
|
2009-09-21 13:30:32 +02:00
|
|
|
.dev_id = "dev:uart0",
|
2008-11-08 21:05:55 +01:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* UART1 */
|
2009-09-21 13:30:32 +02:00
|
|
|
.dev_id = "dev:uart1",
|
2008-11-08 21:05:55 +01:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* UART2 */
|
2009-09-21 13:30:32 +02:00
|
|
|
.dev_id = "dev:uart2",
|
2008-11-08 21:05:55 +01:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* UART3 */
|
2009-09-21 13:30:32 +02:00
|
|
|
.dev_id = "fpga:uart3",
|
2008-11-08 21:05:55 +01:00
|
|
|
.clk = &ref24_clk,
|
2010-07-02 11:24:03 +02:00
|
|
|
}, { /* UART3 is on the dev chip in PB1176 */
|
|
|
|
.dev_id = "dev:uart3",
|
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* UART4 only exists in PB1176 */
|
|
|
|
.dev_id = "fpga:uart4",
|
|
|
|
.clk = &ref24_clk,
|
2008-11-08 21:05:55 +01:00
|
|
|
}, { /* KMI0 */
|
2009-09-21 13:30:32 +02:00
|
|
|
.dev_id = "fpga:kmi0",
|
2008-11-08 21:05:55 +01:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* KMI1 */
|
2009-09-21 13:30:32 +02:00
|
|
|
.dev_id = "fpga:kmi1",
|
2008-11-08 21:05:55 +01:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* MMC0 */
|
2009-09-21 13:30:32 +02:00
|
|
|
.dev_id = "fpga:mmc0",
|
2008-11-08 21:05:55 +01:00
|
|
|
.clk = &ref24_clk,
|
2010-07-02 11:24:03 +02:00
|
|
|
}, { /* CLCD is in the PB1176 and EB DevChip */
|
2009-09-21 13:30:32 +02:00
|
|
|
.dev_id = "dev:clcd",
|
2008-11-08 21:05:55 +01:00
|
|
|
.clk = &oscvco_clk,
|
|
|
|
}, { /* PB:CLCD */
|
2009-09-21 13:30:32 +02:00
|
|
|
.dev_id = "issp:clcd",
|
2008-11-08 21:05:55 +01:00
|
|
|
.clk = &oscvco_clk,
|
2010-07-15 00:58:38 +02:00
|
|
|
}, { /* SSP */
|
|
|
|
.dev_id = "dev:ssp0",
|
|
|
|
.clk = &ref24_clk,
|
2011-05-12 14:31:48 +02:00
|
|
|
}, { /* SP804 timers */
|
|
|
|
.dev_id = "sp804",
|
|
|
|
.clk = &sp804_clk,
|
|
|
|
},
|
2008-11-08 21:05:55 +01:00
|
|
|
};
|
|
|
|
|
2011-01-11 14:05:01 +01:00
|
|
|
void __init realview_init_early(void)
|
2008-11-08 21:05:55 +01:00
|
|
|
{
|
2011-01-11 14:05:01 +01:00
|
|
|
void __iomem *sys = __io_address(REALVIEW_SYS_BASE);
|
|
|
|
|
2010-01-14 21:09:34 +01:00
|
|
|
if (machine_is_realview_pb1176())
|
2011-01-11 14:05:01 +01:00
|
|
|
oscvco_clk.vcoreg = sys + REALVIEW_SYS_OSC0_OFFSET;
|
2010-01-14 21:09:34 +01:00
|
|
|
else
|
2011-01-11 14:05:01 +01:00
|
|
|
oscvco_clk.vcoreg = sys + REALVIEW_SYS_OSC4_OFFSET;
|
2010-01-14 21:09:34 +01:00
|
|
|
|
2010-01-12 13:28:00 +01:00
|
|
|
clkdev_add_table(lookups, ARRAY_SIZE(lookups));
|
2010-01-14 21:09:34 +01:00
|
|
|
|
2011-01-11 14:05:01 +01:00
|
|
|
versatile_sched_clock_init(sys + REALVIEW_SYS_24MHz_OFFSET, 24000000);
|
2008-11-08 21:05:55 +01:00
|
|
|
}
|
|
|
|
|
2005-10-31 15:25:02 +01:00
|
|
|
/*
|
|
|
|
* CLCD support.
|
|
|
|
*/
|
|
|
|
#define SYS_CLCD_NLCDIOON (1 << 2)
|
|
|
|
#define SYS_CLCD_VDDPOSSWITCH (1 << 3)
|
|
|
|
#define SYS_CLCD_PWR3V5SWITCH (1 << 4)
|
|
|
|
#define SYS_CLCD_ID_MASK (0x1f << 8)
|
|
|
|
#define SYS_CLCD_ID_SANYO_3_8 (0x00 << 8)
|
|
|
|
#define SYS_CLCD_ID_UNKNOWN_8_4 (0x01 << 8)
|
|
|
|
#define SYS_CLCD_ID_EPSON_2_2 (0x02 << 8)
|
|
|
|
#define SYS_CLCD_ID_SANYO_2_5 (0x07 << 8)
|
|
|
|
#define SYS_CLCD_ID_VGA (0x1f << 8)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable all display connectors on the interface module.
|
|
|
|
*/
|
|
|
|
static void realview_clcd_disable(struct clcd_fb *fb)
|
|
|
|
{
|
|
|
|
void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
val = readl(sys_clcd);
|
|
|
|
val &= ~SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
|
|
|
|
writel(val, sys_clcd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable the relevant connector on the interface module.
|
|
|
|
*/
|
|
|
|
static void realview_clcd_enable(struct clcd_fb *fb)
|
|
|
|
{
|
|
|
|
void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
/*
|
2006-03-16 15:10:20 +01:00
|
|
|
* Enable the PSUs
|
2005-10-31 15:25:02 +01:00
|
|
|
*/
|
2006-03-16 15:10:20 +01:00
|
|
|
val = readl(sys_clcd);
|
2005-10-31 15:25:02 +01:00
|
|
|
val |= SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
|
|
|
|
writel(val, sys_clcd);
|
|
|
|
}
|
|
|
|
|
2011-01-18 21:13:20 +01:00
|
|
|
/*
|
|
|
|
* Detect which LCD panel is connected, and return the appropriate
|
|
|
|
* clcd_panel structure. Note: we do not have any information on
|
|
|
|
* the required timings for the 8.4in panel, so we presently assume
|
|
|
|
* VGA timings.
|
|
|
|
*/
|
2005-10-31 15:25:02 +01:00
|
|
|
static int realview_clcd_setup(struct clcd_fb *fb)
|
|
|
|
{
|
2011-01-18 21:13:20 +01:00
|
|
|
void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
|
|
|
|
const char *panel_name, *vga_panel_name;
|
2008-11-10 15:10:12 +01:00
|
|
|
unsigned long framesize;
|
2011-01-18 21:13:20 +01:00
|
|
|
u32 val;
|
2005-10-31 15:25:02 +01:00
|
|
|
|
2011-01-18 21:13:20 +01:00
|
|
|
if (machine_is_realview_eb()) {
|
2008-11-10 15:10:12 +01:00
|
|
|
/* VGA, 16bpp */
|
|
|
|
framesize = 640 * 480 * 2;
|
2011-01-18 21:13:20 +01:00
|
|
|
vga_panel_name = "VGA";
|
|
|
|
} else {
|
2008-11-10 15:10:12 +01:00
|
|
|
/* XVGA, 16bpp */
|
|
|
|
framesize = 1024 * 768 * 2;
|
2011-01-18 21:13:20 +01:00
|
|
|
vga_panel_name = "XVGA";
|
2005-10-31 15:25:02 +01:00
|
|
|
}
|
|
|
|
|
2011-01-18 21:13:20 +01:00
|
|
|
val = readl(sys_clcd) & SYS_CLCD_ID_MASK;
|
|
|
|
if (val == SYS_CLCD_ID_SANYO_3_8)
|
|
|
|
panel_name = "Sanyo TM38QV67A02A";
|
|
|
|
else if (val == SYS_CLCD_ID_SANYO_2_5)
|
|
|
|
panel_name = "Sanyo QVGA Portrait";
|
|
|
|
else if (val == SYS_CLCD_ID_EPSON_2_2)
|
|
|
|
panel_name = "Epson L2F50113T00";
|
|
|
|
else if (val == SYS_CLCD_ID_VGA)
|
|
|
|
panel_name = vga_panel_name;
|
|
|
|
else {
|
|
|
|
pr_err("CLCD: unknown LCD panel ID 0x%08x, using VGA\n", val);
|
|
|
|
panel_name = vga_panel_name;
|
|
|
|
}
|
2005-10-31 15:25:02 +01:00
|
|
|
|
2011-01-18 21:13:20 +01:00
|
|
|
fb->panel = versatile_clcd_get_panel(panel_name);
|
|
|
|
if (!fb->panel)
|
|
|
|
return -EINVAL;
|
2005-10-31 15:25:02 +01:00
|
|
|
|
2011-01-18 21:13:20 +01:00
|
|
|
return versatile_clcd_setup_dma(fb, framesize);
|
2005-10-31 15:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct clcd_board clcd_plat_data = {
|
|
|
|
.name = "RealView",
|
2011-01-18 21:13:20 +01:00
|
|
|
.caps = CLCD_CAP_ALL,
|
2005-10-31 15:25:02 +01:00
|
|
|
.check = clcdfb_check,
|
|
|
|
.decode = clcdfb_decode,
|
|
|
|
.disable = realview_clcd_disable,
|
|
|
|
.enable = realview_clcd_enable,
|
|
|
|
.setup = realview_clcd_setup,
|
2011-01-18 21:13:20 +01:00
|
|
|
.mmap = versatile_clcd_mmap_dma,
|
|
|
|
.remove = versatile_clcd_remove_dma,
|
2005-10-31 15:25:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_LEDS
|
|
|
|
#define VA_LEDS_BASE (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LED_OFFSET)
|
|
|
|
|
|
|
|
void realview_leds_event(led_event_t ledevt)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
u32 val;
|
2009-05-30 14:56:16 +02:00
|
|
|
u32 led = 1 << smp_processor_id();
|
2005-10-31 15:25:02 +01:00
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
val = readl(VA_LEDS_BASE);
|
|
|
|
|
|
|
|
switch (ledevt) {
|
|
|
|
case led_idle_start:
|
2009-05-30 14:56:16 +02:00
|
|
|
val = val & ~led;
|
2005-10-31 15:25:02 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case led_idle_end:
|
2009-05-30 14:56:16 +02:00
|
|
|
val = val | led;
|
2005-10-31 15:25:02 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case led_timer:
|
2009-05-30 14:56:16 +02:00
|
|
|
val = val ^ REALVIEW_SYS_LED7;
|
2005-10-31 15:25:02 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case led_halted:
|
|
|
|
val = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
writel(val, VA_LEDS_BASE);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_LEDS */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Where is the timer (VA)?
|
|
|
|
*/
|
2008-04-18 23:43:11 +02:00
|
|
|
void __iomem *timer0_va_base;
|
|
|
|
void __iomem *timer1_va_base;
|
|
|
|
void __iomem *timer2_va_base;
|
|
|
|
void __iomem *timer3_va_base;
|
2005-10-31 15:25:02 +01:00
|
|
|
|
|
|
|
/*
|
2008-02-04 17:30:57 +01:00
|
|
|
* Set up the clock source and clock events devices
|
2005-10-31 15:25:02 +01:00
|
|
|
*/
|
2008-02-04 17:43:02 +01:00
|
|
|
void __init realview_timer_init(unsigned int timer_irq)
|
2005-10-31 15:25:02 +01:00
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set clock frequency:
|
|
|
|
* REALVIEW_REFCLK is 32KHz
|
|
|
|
* REALVIEW_TIMCLK is 1MHz
|
|
|
|
*/
|
|
|
|
val = readl(__io_address(REALVIEW_SCTL_BASE));
|
|
|
|
writel((REALVIEW_TIMCLK << REALVIEW_TIMER1_EnSel) |
|
|
|
|
(REALVIEW_TIMCLK << REALVIEW_TIMER2_EnSel) |
|
|
|
|
(REALVIEW_TIMCLK << REALVIEW_TIMER3_EnSel) |
|
|
|
|
(REALVIEW_TIMCLK << REALVIEW_TIMER4_EnSel) | val,
|
|
|
|
__io_address(REALVIEW_SCTL_BASE));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialise to a known state (all timers off)
|
|
|
|
*/
|
2008-04-18 23:43:11 +02:00
|
|
|
writel(0, timer0_va_base + TIMER_CTRL);
|
|
|
|
writel(0, timer1_va_base + TIMER_CTRL);
|
|
|
|
writel(0, timer2_va_base + TIMER_CTRL);
|
|
|
|
writel(0, timer3_va_base + TIMER_CTRL);
|
2005-10-31 15:25:02 +01:00
|
|
|
|
2011-05-12 13:08:23 +02:00
|
|
|
sp804_clocksource_init(timer3_va_base, "timer3");
|
2010-01-14 14:30:16 +01:00
|
|
|
sp804_clockevents_init(timer0_va_base, timer_irq);
|
2005-10-31 15:25:02 +01:00
|
|
|
}
|
2009-11-04 13:19:04 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup the memory banks.
|
|
|
|
*/
|
|
|
|
void realview_fixup(struct machine_desc *mdesc, struct tag *tags, char **from,
|
|
|
|
struct meminfo *meminfo)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Most RealView platforms have 512MB contiguous RAM at 0x70000000.
|
|
|
|
* Half of this is mirrored at 0.
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_REALVIEW_HIGH_PHYS_OFFSET
|
|
|
|
meminfo->bank[0].start = 0x70000000;
|
|
|
|
meminfo->bank[0].size = SZ_512M;
|
|
|
|
meminfo->nr_banks = 1;
|
|
|
|
#else
|
|
|
|
meminfo->bank[0].start = 0;
|
|
|
|
meminfo->bank[0].size = SZ_256M;
|
|
|
|
meminfo->nr_banks = 1;
|
|
|
|
#endif
|
|
|
|
}
|