2005-10-31 14:25:02 +00: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 16:57:06 +00:00
|
|
|
#include <linux/platform_device.h>
|
2005-10-31 14:25:02 +00:00
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/sysdev.h>
|
|
|
|
#include <linux/interrupt.h>
|
2006-01-07 13:52:45 +00:00
|
|
|
#include <linux/amba/bus.h>
|
|
|
|
#include <linux/amba/clcd.h>
|
2008-09-06 11:10:45 +00:00
|
|
|
#include <linux/io.h>
|
2009-01-20 13:23:30 +00:00
|
|
|
#include <linux/smsc911x.h>
|
2009-02-12 14:59:21 +00:00
|
|
|
#include <linux/ata_platform.h>
|
2009-09-22 13:29:36 +00: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 08:04:11 +00:00
|
|
|
#include <linux/gfp.h>
|
2005-10-31 14:25:02 +00:00
|
|
|
|
2008-11-08 20:05:55 +00:00
|
|
|
#include <asm/clkdev.h>
|
2005-10-31 14:25:02 +00:00
|
|
|
#include <asm/system.h>
|
2008-08-05 15:14:15 +00:00
|
|
|
#include <mach/hardware.h>
|
2005-10-31 14:25:02 +00:00
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/leds.h>
|
2008-11-10 14:10:11 +00:00
|
|
|
#include <asm/mach-types.h>
|
2005-10-31 14:25:02 +00:00
|
|
|
#include <asm/hardware/arm_timer.h>
|
2010-01-16 20:16:10 +00:00
|
|
|
#include <asm/hardware/icst.h>
|
2005-10-31 14:25:02 +00: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>
|
|
|
|
|
2010-01-14 12:48:06 +00:00
|
|
|
#include <mach/clkdev.h>
|
2009-05-30 13:00:17 +00:00
|
|
|
#include <mach/platform.h>
|
|
|
|
#include <mach/irqs.h>
|
2010-01-14 13:30:16 +00:00
|
|
|
#include <plat/timer-sp.h>
|
2009-05-30 13:00:17 +00:00
|
|
|
|
2005-10-31 14:25:02 +00:00
|
|
|
#include "core.h"
|
|
|
|
|
2008-12-01 14:54:58 +00:00
|
|
|
/* used by entry-macro.S and platsmp.c */
|
2008-02-04 16:41:01 +00:00
|
|
|
void __iomem *gic_cpu_base_addr;
|
|
|
|
|
2009-11-04 12:19:05 +00:00
|
|
|
#ifdef CONFIG_ZONE_DMA
|
|
|
|
/*
|
|
|
|
* Adjust the zones if there are restrictions for DMA access.
|
|
|
|
*/
|
|
|
|
void __init realview_adjust_zones(int node, unsigned long *size,
|
|
|
|
unsigned long *hole)
|
|
|
|
{
|
|
|
|
unsigned long dma_size = SZ_256M >> PAGE_SHIFT;
|
|
|
|
|
|
|
|
if (!machine_is_realview_pbx() || node || (size[0] <= dma_size))
|
|
|
|
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 14:25:02 +00: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 21:43:10 +00: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 13:23:30 +00: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 14:54:59 +00:00
|
|
|
};
|
|
|
|
|
2008-12-01 14:54:58 +00:00
|
|
|
static struct platform_device realview_eth_device = {
|
2009-01-20 13:23:30 +00:00
|
|
|
.name = "smsc911x",
|
2008-12-01 14:54:58 +00: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 13:23:30 +00:00
|
|
|
if (strcmp(realview_eth_device.name, "smsc911x") == 0)
|
|
|
|
realview_eth_device.dev.platform_data = &smsc911x_config;
|
2008-12-01 14:54:58 +00:00
|
|
|
|
|
|
|
return platform_device_register(&realview_eth_device);
|
2009-02-12 15:00:21 +00: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 14:54:58 +00:00
|
|
|
}
|
|
|
|
|
2009-02-12 14:59:21 +00: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 20:21:32 +00: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 14:58:20 +00:00
|
|
|
.id = 0,
|
2006-12-10 20:21:32 +00:00
|
|
|
.num_resources = 1,
|
|
|
|
.resource = &realview_i2c_resource,
|
|
|
|
};
|
|
|
|
|
2009-02-12 14:58:20 +00:00
|
|
|
static struct i2c_board_info realview_i2c_board_info[] = {
|
|
|
|
{
|
2009-07-18 14:51:55 +00:00
|
|
|
I2C_BOARD_INFO("ds1338", 0xd0 >> 1),
|
2009-02-12 14:58:20 +00: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 14:25:02 +00:00
|
|
|
#define REALVIEW_SYSMCI (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_MCI_OFFSET)
|
|
|
|
|
2009-07-09 14:17:41 +00:00
|
|
|
/*
|
|
|
|
* This is only used if GPIOLIB support is disabled
|
|
|
|
*/
|
2005-10-31 14:25:02 +00:00
|
|
|
static unsigned int realview_mmc_status(struct device *dev)
|
|
|
|
{
|
|
|
|
struct amba_device *adev = container_of(dev, struct amba_device, dev);
|
|
|
|
u32 mask;
|
|
|
|
|
|
|
|
if (adev->res.start == REALVIEW_MMCI0_BASE)
|
|
|
|
mask = 1;
|
|
|
|
else
|
|
|
|
mask = 2;
|
|
|
|
|
2010-02-24 14:23:10 +00:00
|
|
|
return !(readl(REALVIEW_SYSMCI) & mask);
|
2005-10-31 14:25:02 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 13:29:36 +00:00
|
|
|
struct mmci_platform_data realview_mmc0_plat_data = {
|
2005-10-31 14:25:02 +00:00
|
|
|
.ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
|
|
|
|
.status = realview_mmc_status,
|
2009-07-09 14:17:41 +00:00
|
|
|
.gpio_wp = 17,
|
|
|
|
.gpio_cd = 16,
|
2005-10-31 14:25:02 +00:00
|
|
|
};
|
|
|
|
|
2009-09-22 13:29:36 +00:00
|
|
|
struct mmci_platform_data realview_mmc1_plat_data = {
|
2005-10-31 14:25:02 +00:00
|
|
|
.ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
|
|
|
|
.status = realview_mmc_status,
|
2009-07-09 14:17:41 +00:00
|
|
|
.gpio_wp = 19,
|
|
|
|
.gpio_cd = 18,
|
2005-10-31 14:25:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clock handling
|
|
|
|
*/
|
2010-01-16 16:27:28 +00:00
|
|
|
static const struct icst_params realview_oscvco_params = {
|
2010-01-16 17:28:44 +00:00
|
|
|
.ref = 24000000,
|
2010-01-16 18:08:47 +00:00
|
|
|
.vco_max = ICST307_VCO_MAX,
|
2010-01-16 19:49:39 +00:00
|
|
|
.vco_min = ICST307_VCO_MIN,
|
2005-10-31 14:25:02 +00:00
|
|
|
.vd_min = 4 + 8,
|
|
|
|
.vd_max = 511 + 8,
|
|
|
|
.rd_min = 1 + 2,
|
|
|
|
.rd_max = 127 + 2,
|
2010-01-16 19:46:19 +00:00
|
|
|
.s2div = icst307_s2div,
|
|
|
|
.idx2s = icst307_idx2s,
|
2005-10-31 14:25:02 +00:00
|
|
|
};
|
|
|
|
|
2010-01-16 16:27:28 +00:00
|
|
|
static void realview_oscvco_set(struct clk *clk, struct icst_vco vco)
|
2005-10-31 14:25:02 +00:00
|
|
|
{
|
|
|
|
void __iomem *sys_lock = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LOCK_OFFSET;
|
|
|
|
u32 val;
|
|
|
|
|
2010-01-14 20:09:34 +00:00
|
|
|
val = readl(clk->vcoreg) & ~0x7ffff;
|
2005-10-31 14:25:02 +00:00
|
|
|
val |= vco.v | (vco.r << 9) | (vco.s << 16);
|
|
|
|
|
|
|
|
writel(0xa05f, sys_lock);
|
2010-01-14 20:09:34 +00:00
|
|
|
writel(val, clk->vcoreg);
|
2005-10-31 14:25:02 +00:00
|
|
|
writel(0, sys_lock);
|
|
|
|
}
|
|
|
|
|
2010-03-01 16:18:39 +00:00
|
|
|
static const struct clk_ops oscvco_clk_ops = {
|
|
|
|
.round = icst_clk_round,
|
|
|
|
.set = icst_clk_set,
|
|
|
|
.setvco = realview_oscvco_set,
|
|
|
|
};
|
|
|
|
|
2008-11-08 20:05:55 +00:00
|
|
|
static struct clk oscvco_clk = {
|
2010-03-01 16:18:39 +00:00
|
|
|
.ops = &oscvco_clk_ops,
|
2005-10-31 14:25:02 +00:00
|
|
|
.params = &realview_oscvco_params,
|
|
|
|
};
|
|
|
|
|
2008-11-08 20:05:55 +00:00
|
|
|
/*
|
|
|
|
* These are fixed clocks.
|
|
|
|
*/
|
|
|
|
static struct clk ref24_clk = {
|
|
|
|
.rate = 24000000,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct clk_lookup lookups[] = {
|
|
|
|
{ /* UART0 */
|
2009-09-21 11:30:32 +00:00
|
|
|
.dev_id = "dev:uart0",
|
2008-11-08 20:05:55 +00:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* UART1 */
|
2009-09-21 11:30:32 +00:00
|
|
|
.dev_id = "dev:uart1",
|
2008-11-08 20:05:55 +00:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* UART2 */
|
2009-09-21 11:30:32 +00:00
|
|
|
.dev_id = "dev:uart2",
|
2008-11-08 20:05:55 +00:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* UART3 */
|
2009-09-21 11:30:32 +00:00
|
|
|
.dev_id = "fpga:uart3",
|
2008-11-08 20:05:55 +00:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* KMI0 */
|
2009-09-21 11:30:32 +00:00
|
|
|
.dev_id = "fpga:kmi0",
|
2008-11-08 20:05:55 +00:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* KMI1 */
|
2009-09-21 11:30:32 +00:00
|
|
|
.dev_id = "fpga:kmi1",
|
2008-11-08 20:05:55 +00:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* MMC0 */
|
2009-09-21 11:30:32 +00:00
|
|
|
.dev_id = "fpga:mmc0",
|
2008-11-08 20:05:55 +00:00
|
|
|
.clk = &ref24_clk,
|
|
|
|
}, { /* EB:CLCD */
|
2009-09-21 11:30:32 +00:00
|
|
|
.dev_id = "dev:clcd",
|
2008-11-08 20:05:55 +00:00
|
|
|
.clk = &oscvco_clk,
|
|
|
|
}, { /* PB:CLCD */
|
2009-09-21 11:30:32 +00:00
|
|
|
.dev_id = "issp:clcd",
|
2008-11-08 20:05:55 +00:00
|
|
|
.clk = &oscvco_clk,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init clk_init(void)
|
|
|
|
{
|
2010-01-14 20:09:34 +00:00
|
|
|
if (machine_is_realview_pb1176())
|
|
|
|
oscvco_clk.vcoreg = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC0_OFFSET;
|
|
|
|
else
|
|
|
|
oscvco_clk.vcoreg = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC4_OFFSET;
|
|
|
|
|
2010-01-12 12:28:00 +00:00
|
|
|
clkdev_add_table(lookups, ARRAY_SIZE(lookups));
|
2010-01-14 20:09:34 +00:00
|
|
|
|
2008-11-08 20:05:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
arch_initcall(clk_init);
|
|
|
|
|
2005-10-31 14:25:02 +00: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)
|
|
|
|
|
|
|
|
static struct clcd_panel vga = {
|
|
|
|
.mode = {
|
|
|
|
.name = "VGA",
|
|
|
|
.refresh = 60,
|
|
|
|
.xres = 640,
|
|
|
|
.yres = 480,
|
|
|
|
.pixclock = 39721,
|
|
|
|
.left_margin = 40,
|
|
|
|
.right_margin = 24,
|
|
|
|
.upper_margin = 32,
|
|
|
|
.lower_margin = 11,
|
|
|
|
.hsync_len = 96,
|
|
|
|
.vsync_len = 2,
|
|
|
|
.sync = 0,
|
|
|
|
.vmode = FB_VMODE_NONINTERLACED,
|
|
|
|
},
|
|
|
|
.width = -1,
|
|
|
|
.height = -1,
|
|
|
|
.tim2 = TIM2_BCD | TIM2_IPC,
|
2008-11-10 14:10:13 +00:00
|
|
|
.cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
|
2005-10-31 14:25:02 +00:00
|
|
|
.bpp = 16,
|
|
|
|
};
|
|
|
|
|
2008-11-10 14:10:12 +00:00
|
|
|
static struct clcd_panel xvga = {
|
|
|
|
.mode = {
|
|
|
|
.name = "XVGA",
|
|
|
|
.refresh = 60,
|
|
|
|
.xres = 1024,
|
|
|
|
.yres = 768,
|
|
|
|
.pixclock = 15748,
|
|
|
|
.left_margin = 152,
|
|
|
|
.right_margin = 48,
|
|
|
|
.upper_margin = 23,
|
|
|
|
.lower_margin = 3,
|
|
|
|
.hsync_len = 104,
|
|
|
|
.vsync_len = 4,
|
|
|
|
.sync = 0,
|
|
|
|
.vmode = FB_VMODE_NONINTERLACED,
|
|
|
|
},
|
|
|
|
.width = -1,
|
|
|
|
.height = -1,
|
|
|
|
.tim2 = TIM2_BCD | TIM2_IPC,
|
2008-11-10 14:10:13 +00:00
|
|
|
.cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
|
2005-10-31 14:25:02 +00:00
|
|
|
.bpp = 16,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct clcd_panel sanyo_3_8_in = {
|
|
|
|
.mode = {
|
|
|
|
.name = "Sanyo QVGA",
|
|
|
|
.refresh = 116,
|
|
|
|
.xres = 320,
|
|
|
|
.yres = 240,
|
|
|
|
.pixclock = 100000,
|
|
|
|
.left_margin = 6,
|
|
|
|
.right_margin = 6,
|
|
|
|
.upper_margin = 5,
|
|
|
|
.lower_margin = 5,
|
|
|
|
.hsync_len = 6,
|
|
|
|
.vsync_len = 6,
|
|
|
|
.sync = 0,
|
|
|
|
.vmode = FB_VMODE_NONINTERLACED,
|
|
|
|
},
|
|
|
|
.width = -1,
|
|
|
|
.height = -1,
|
|
|
|
.tim2 = TIM2_BCD,
|
2008-11-10 14:10:13 +00:00
|
|
|
.cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
|
2005-10-31 14:25:02 +00:00
|
|
|
.bpp = 16,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct clcd_panel sanyo_2_5_in = {
|
|
|
|
.mode = {
|
|
|
|
.name = "Sanyo QVGA Portrait",
|
|
|
|
.refresh = 116,
|
|
|
|
.xres = 240,
|
|
|
|
.yres = 320,
|
|
|
|
.pixclock = 100000,
|
|
|
|
.left_margin = 20,
|
|
|
|
.right_margin = 10,
|
|
|
|
.upper_margin = 2,
|
|
|
|
.lower_margin = 2,
|
|
|
|
.hsync_len = 10,
|
|
|
|
.vsync_len = 2,
|
|
|
|
.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
|
|
|
|
.vmode = FB_VMODE_NONINTERLACED,
|
|
|
|
},
|
|
|
|
.width = -1,
|
|
|
|
.height = -1,
|
|
|
|
.tim2 = TIM2_IVS | TIM2_IHS | TIM2_IPC,
|
2008-11-10 14:10:13 +00:00
|
|
|
.cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
|
2005-10-31 14:25:02 +00:00
|
|
|
.bpp = 16,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct clcd_panel epson_2_2_in = {
|
|
|
|
.mode = {
|
|
|
|
.name = "Epson QCIF",
|
|
|
|
.refresh = 390,
|
|
|
|
.xres = 176,
|
|
|
|
.yres = 220,
|
|
|
|
.pixclock = 62500,
|
|
|
|
.left_margin = 3,
|
|
|
|
.right_margin = 2,
|
|
|
|
.upper_margin = 1,
|
|
|
|
.lower_margin = 0,
|
|
|
|
.hsync_len = 3,
|
|
|
|
.vsync_len = 2,
|
|
|
|
.sync = 0,
|
|
|
|
.vmode = FB_VMODE_NONINTERLACED,
|
|
|
|
},
|
|
|
|
.width = -1,
|
|
|
|
.height = -1,
|
|
|
|
.tim2 = TIM2_BCD | TIM2_IPC,
|
2008-11-10 14:10:13 +00:00
|
|
|
.cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
|
2005-10-31 14:25:02 +00:00
|
|
|
.bpp = 16,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
static struct clcd_panel *realview_clcd_panel(void)
|
|
|
|
{
|
|
|
|
void __iomem *sys_clcd = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_CLCD_OFFSET;
|
2008-11-10 14:10:12 +00:00
|
|
|
struct clcd_panel *vga_panel;
|
|
|
|
struct clcd_panel *panel;
|
2005-10-31 14:25:02 +00:00
|
|
|
u32 val;
|
|
|
|
|
2008-11-10 14:10:12 +00:00
|
|
|
if (machine_is_realview_eb())
|
|
|
|
vga_panel = &vga;
|
|
|
|
else
|
|
|
|
vga_panel = &xvga;
|
|
|
|
|
2005-10-31 14:25:02 +00:00
|
|
|
val = readl(sys_clcd) & SYS_CLCD_ID_MASK;
|
|
|
|
if (val == SYS_CLCD_ID_SANYO_3_8)
|
|
|
|
panel = &sanyo_3_8_in;
|
|
|
|
else if (val == SYS_CLCD_ID_SANYO_2_5)
|
|
|
|
panel = &sanyo_2_5_in;
|
|
|
|
else if (val == SYS_CLCD_ID_EPSON_2_2)
|
|
|
|
panel = &epson_2_2_in;
|
|
|
|
else if (val == SYS_CLCD_ID_VGA)
|
2008-11-10 14:10:12 +00:00
|
|
|
panel = vga_panel;
|
2005-10-31 14:25:02 +00:00
|
|
|
else {
|
|
|
|
printk(KERN_ERR "CLCD: unknown LCD panel ID 0x%08x, using VGA\n",
|
|
|
|
val);
|
2008-11-10 14:10:12 +00:00
|
|
|
panel = vga_panel;
|
2005-10-31 14:25:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 14:10:20 +00:00
|
|
|
* Enable the PSUs
|
2005-10-31 14:25:02 +00:00
|
|
|
*/
|
2006-03-16 14:10:20 +00:00
|
|
|
val = readl(sys_clcd);
|
2005-10-31 14:25:02 +00:00
|
|
|
val |= SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH;
|
|
|
|
writel(val, sys_clcd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int realview_clcd_setup(struct clcd_fb *fb)
|
|
|
|
{
|
2008-11-10 14:10:12 +00:00
|
|
|
unsigned long framesize;
|
2005-10-31 14:25:02 +00:00
|
|
|
dma_addr_t dma;
|
|
|
|
|
2008-11-10 14:10:12 +00:00
|
|
|
if (machine_is_realview_eb())
|
|
|
|
/* VGA, 16bpp */
|
|
|
|
framesize = 640 * 480 * 2;
|
|
|
|
else
|
|
|
|
/* XVGA, 16bpp */
|
|
|
|
framesize = 1024 * 768 * 2;
|
|
|
|
|
2005-10-31 14:25:02 +00:00
|
|
|
fb->panel = realview_clcd_panel();
|
|
|
|
|
|
|
|
fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, framesize,
|
2009-11-04 12:19:05 +00:00
|
|
|
&dma, GFP_KERNEL | GFP_DMA);
|
2005-10-31 14:25:02 +00:00
|
|
|
if (!fb->fb.screen_base) {
|
|
|
|
printk(KERN_ERR "CLCD: unable to map framebuffer\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
fb->fb.fix.smem_start = dma;
|
|
|
|
fb->fb.fix.smem_len = framesize;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int realview_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
|
|
|
|
{
|
|
|
|
return dma_mmap_writecombine(&fb->dev->dev, vma,
|
|
|
|
fb->fb.screen_base,
|
|
|
|
fb->fb.fix.smem_start,
|
|
|
|
fb->fb.fix.smem_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void realview_clcd_remove(struct clcd_fb *fb)
|
|
|
|
{
|
|
|
|
dma_free_writecombine(&fb->dev->dev, fb->fb.fix.smem_len,
|
|
|
|
fb->fb.screen_base, fb->fb.fix.smem_start);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct clcd_board clcd_plat_data = {
|
|
|
|
.name = "RealView",
|
|
|
|
.check = clcdfb_check,
|
|
|
|
.decode = clcdfb_decode,
|
|
|
|
.disable = realview_clcd_disable,
|
|
|
|
.enable = realview_clcd_enable,
|
|
|
|
.setup = realview_clcd_setup,
|
|
|
|
.mmap = realview_clcd_mmap,
|
|
|
|
.remove = realview_clcd_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
#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 12:56:16 +00:00
|
|
|
u32 led = 1 << smp_processor_id();
|
2005-10-31 14:25:02 +00:00
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
val = readl(VA_LEDS_BASE);
|
|
|
|
|
|
|
|
switch (ledevt) {
|
|
|
|
case led_idle_start:
|
2009-05-30 12:56:16 +00:00
|
|
|
val = val & ~led;
|
2005-10-31 14:25:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case led_idle_end:
|
2009-05-30 12:56:16 +00:00
|
|
|
val = val | led;
|
2005-10-31 14:25:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case led_timer:
|
2009-05-30 12:56:16 +00:00
|
|
|
val = val ^ REALVIEW_SYS_LED7;
|
2005-10-31 14:25:02 +00: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 21:43:11 +00:00
|
|
|
void __iomem *timer0_va_base;
|
|
|
|
void __iomem *timer1_va_base;
|
|
|
|
void __iomem *timer2_va_base;
|
|
|
|
void __iomem *timer3_va_base;
|
2005-10-31 14:25:02 +00:00
|
|
|
|
|
|
|
/*
|
2008-02-04 16:30:57 +00:00
|
|
|
* Set up the clock source and clock events devices
|
2005-10-31 14:25:02 +00:00
|
|
|
*/
|
2008-02-04 16:43:02 +00:00
|
|
|
void __init realview_timer_init(unsigned int timer_irq)
|
2005-10-31 14:25:02 +00: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 21:43:11 +00: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 14:25:02 +00:00
|
|
|
|
2010-01-14 13:30:16 +00:00
|
|
|
sp804_clocksource_init(timer3_va_base);
|
|
|
|
sp804_clockevents_init(timer0_va_base, timer_irq);
|
2005-10-31 14:25:02 +00:00
|
|
|
}
|
2009-11-04 12:19:04 +00: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
|
|
|
|
}
|