2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/mach-integrator/integrator_ap.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000-2003 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/kernel.h>
|
|
|
|
#include <linux/init.h>
|
2011-04-23 04:02:55 +08:00
|
|
|
#include <linux/syscore_ops.h>
|
2006-01-07 21:52:45 +08:00
|
|
|
#include <linux/amba/bus.h>
|
2008-09-06 19:10:45 +08:00
|
|
|
#include <linux/io.h>
|
2014-05-30 05:44:27 +08:00
|
|
|
#include <linux/irqchip.h>
|
2012-09-06 16:08:24 +08:00
|
|
|
#include <linux/of_irq.h>
|
|
|
|
#include <linux/of_address.h>
|
2012-09-06 16:08:47 +08:00
|
|
|
#include <linux/of_platform.h>
|
2012-11-18 02:24:23 +08:00
|
|
|
#include <linux/termios.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <asm/mach/arch.h>
|
|
|
|
#include <asm/mach/map.h>
|
|
|
|
|
2014-02-14 04:26:24 +08:00
|
|
|
#include "hardware.h"
|
2013-06-16 08:44:27 +08:00
|
|
|
#include "cm.h"
|
2010-05-23 01:18:57 +08:00
|
|
|
#include "common.h"
|
2013-03-20 02:58:49 +08:00
|
|
|
#include "pci_v3.h"
|
2014-02-14 03:01:41 +08:00
|
|
|
#include "lm.h"
|
2010-05-23 01:18:57 +08:00
|
|
|
|
2012-11-05 03:49:15 +08:00
|
|
|
/* Base address to the AP system controller */
|
2012-11-18 02:24:23 +08:00
|
|
|
void __iomem *ap_syscon_base;
|
2013-06-18 05:58:25 +08:00
|
|
|
/* Base address to the external bus interface */
|
|
|
|
static void __iomem *ebi_base;
|
2012-11-05 03:49:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-04-17 06:20:36 +08:00
|
|
|
* All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
|
|
|
|
* is the (PA >> 12).
|
|
|
|
*
|
|
|
|
* Setup a VA for the Integrator interrupt controller (for header #0,
|
|
|
|
* just for now).
|
|
|
|
*/
|
2011-01-19 23:32:15 +08:00
|
|
|
#define VA_IC_BASE __io_address(INTEGRATOR_IC_BASE)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Logical Physical
|
|
|
|
* f1400000 14000000 Interrupt controller
|
|
|
|
* f1600000 16000000 UART 0
|
|
|
|
*/
|
|
|
|
|
2013-02-14 20:50:57 +08:00
|
|
|
static struct map_desc ap_io_desc[] __initdata __maybe_unused = {
|
2005-10-28 22:19:10 +08:00
|
|
|
{
|
|
|
|
.virtual = IO_ADDRESS(INTEGRATOR_IC_BASE),
|
|
|
|
.pfn = __phys_to_pfn(INTEGRATOR_IC_BASE),
|
|
|
|
.length = SZ_4K,
|
|
|
|
.type = MT_DEVICE
|
|
|
|
}, {
|
|
|
|
.virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE),
|
|
|
|
.pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE),
|
|
|
|
.length = SZ_4K,
|
|
|
|
.type = MT_DEVICE
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static void __init ap_map_io(void)
|
|
|
|
{
|
|
|
|
iotable_init(ap_io_desc, ARRAY_SIZE(ap_io_desc));
|
2013-03-20 02:58:49 +08:00
|
|
|
pci_v3_early_init();
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
static unsigned long ic_irq_enable;
|
|
|
|
|
2011-04-23 04:02:55 +08:00
|
|
|
static int irq_suspend(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
ic_irq_enable = readl(VA_IC_BASE + IRQ_ENABLE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-23 04:02:55 +08:00
|
|
|
static void irq_resume(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
/* disable all irq sources */
|
2013-06-16 08:44:27 +08:00
|
|
|
cm_clear_irqs();
|
2005-04-17 06:20:36 +08:00
|
|
|
writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR);
|
|
|
|
writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR);
|
|
|
|
|
|
|
|
writel(ic_irq_enable, VA_IC_BASE + IRQ_ENABLE_SET);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define irq_suspend NULL
|
|
|
|
#define irq_resume NULL
|
|
|
|
#endif
|
|
|
|
|
2011-04-23 04:02:55 +08:00
|
|
|
static struct syscore_ops irq_syscore_ops = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.suspend = irq_suspend,
|
|
|
|
.resume = irq_resume,
|
|
|
|
};
|
|
|
|
|
2011-04-23 04:02:55 +08:00
|
|
|
static int __init irq_syscore_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2011-04-23 04:02:55 +08:00
|
|
|
register_syscore_ops(&irq_syscore_ops);
|
|
|
|
|
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2011-04-23 04:02:55 +08:00
|
|
|
device_initcall(irq_syscore_init);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-11-18 02:24:23 +08:00
|
|
|
/*
|
|
|
|
* For the PL010 found in the Integrator/AP some of the UART control is
|
|
|
|
* implemented in the system controller and accessed using a callback
|
|
|
|
* from the driver.
|
|
|
|
*/
|
|
|
|
static void integrator_uart_set_mctrl(struct amba_device *dev,
|
|
|
|
void __iomem *base, unsigned int mctrl)
|
|
|
|
{
|
|
|
|
unsigned int ctrls = 0, ctrlc = 0, rts_mask, dtr_mask;
|
|
|
|
u32 phybase = dev->res.start;
|
|
|
|
|
|
|
|
if (phybase == INTEGRATOR_UART0_BASE) {
|
|
|
|
/* UART0 */
|
|
|
|
rts_mask = 1 << 4;
|
|
|
|
dtr_mask = 1 << 5;
|
|
|
|
} else {
|
|
|
|
/* UART1 */
|
|
|
|
rts_mask = 1 << 6;
|
|
|
|
dtr_mask = 1 << 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mctrl & TIOCM_RTS)
|
|
|
|
ctrlc |= rts_mask;
|
|
|
|
else
|
|
|
|
ctrls |= rts_mask;
|
|
|
|
|
|
|
|
if (mctrl & TIOCM_DTR)
|
|
|
|
ctrlc |= dtr_mask;
|
|
|
|
else
|
|
|
|
ctrls |= dtr_mask;
|
|
|
|
|
|
|
|
__raw_writel(ctrls, ap_syscon_base + INTEGRATOR_SC_CTRLS_OFFSET);
|
|
|
|
__raw_writel(ctrlc, ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct amba_pl010_data ap_uart_data = {
|
|
|
|
.set_mctrl = integrator_uart_set_mctrl,
|
|
|
|
};
|
|
|
|
|
2012-06-11 23:33:12 +08:00
|
|
|
void __init ap_init_early(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-06 16:08:24 +08:00
|
|
|
static void __init ap_init_irq_of(void)
|
|
|
|
{
|
2013-06-16 08:44:27 +08:00
|
|
|
cm_init();
|
2014-05-30 05:44:27 +08:00
|
|
|
irqchip_init();
|
2012-09-06 16:08:24 +08:00
|
|
|
}
|
|
|
|
|
2012-09-06 16:08:47 +08:00
|
|
|
/* For the Device Tree, add in the UART callbacks as AUXDATA */
|
|
|
|
static struct of_dev_auxdata ap_auxdata_lookup[] __initdata = {
|
|
|
|
OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE,
|
2012-11-18 02:24:23 +08:00
|
|
|
"uart0", &ap_uart_data),
|
2012-09-06 16:08:47 +08:00
|
|
|
OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE,
|
2012-11-18 02:24:23 +08:00
|
|
|
"uart1", &ap_uart_data),
|
2012-09-06 16:08:47 +08:00
|
|
|
{ /* sentinel */ },
|
|
|
|
};
|
|
|
|
|
2013-10-11 00:24:58 +08:00
|
|
|
static const struct of_device_id ap_syscon_match[] = {
|
|
|
|
{ .compatible = "arm,integrator-ap-syscon"},
|
|
|
|
{ },
|
|
|
|
};
|
|
|
|
|
2013-06-18 05:58:25 +08:00
|
|
|
static const struct of_device_id ebi_match[] = {
|
|
|
|
{ .compatible = "arm,external-bus-interface"},
|
|
|
|
{ },
|
|
|
|
};
|
|
|
|
|
2012-09-06 16:08:47 +08:00
|
|
|
static void __init ap_init_of(void)
|
|
|
|
{
|
|
|
|
unsigned long sc_dec;
|
2012-11-02 08:31:10 +08:00
|
|
|
struct device_node *syscon;
|
2013-06-18 05:58:25 +08:00
|
|
|
struct device_node *ebi;
|
2012-09-06 16:08:47 +08:00
|
|
|
int i;
|
|
|
|
|
2014-06-24 20:08:07 +08:00
|
|
|
syscon = of_find_matching_node(NULL, ap_syscon_match);
|
2012-11-02 08:31:10 +08:00
|
|
|
if (!syscon)
|
|
|
|
return;
|
2014-06-24 20:08:07 +08:00
|
|
|
ebi = of_find_matching_node(NULL, ebi_match);
|
2013-06-18 05:58:25 +08:00
|
|
|
if (!ebi)
|
|
|
|
return;
|
2012-11-02 08:31:10 +08:00
|
|
|
|
|
|
|
ap_syscon_base = of_iomap(syscon, 0);
|
|
|
|
if (!ap_syscon_base)
|
|
|
|
return;
|
2013-06-18 05:58:25 +08:00
|
|
|
ebi_base = of_iomap(ebi, 0);
|
|
|
|
if (!ebi_base)
|
|
|
|
return;
|
2012-11-02 08:31:10 +08:00
|
|
|
|
2016-06-01 14:53:05 +08:00
|
|
|
of_platform_default_populate(NULL, ap_auxdata_lookup, NULL);
|
2014-06-24 20:08:07 +08:00
|
|
|
|
2012-11-05 03:49:15 +08:00
|
|
|
sc_dec = readl(ap_syscon_base + INTEGRATOR_SC_DEC_OFFSET);
|
2012-09-06 16:08:47 +08:00
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
struct lm_device *lmdev;
|
|
|
|
|
|
|
|
if ((sc_dec & (16 << i)) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL);
|
|
|
|
if (!lmdev)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
lmdev->resource.start = 0xc0000000 + 0x10000000 * i;
|
|
|
|
lmdev->resource.end = lmdev->resource.start + 0x0fffffff;
|
|
|
|
lmdev->resource.flags = IORESOURCE_MEM;
|
2013-06-16 05:56:32 +08:00
|
|
|
lmdev->irq = irq_of_parse_and_map(syscon, i);
|
2012-09-06 16:08:47 +08:00
|
|
|
lmdev->id = i;
|
|
|
|
|
|
|
|
lm_device_register(lmdev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-06 16:08:24 +08:00
|
|
|
static const char * ap_dt_board_compat[] = {
|
|
|
|
"arm,integrator-ap",
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
DT_MACHINE_START(INTEGRATOR_AP_DT, "ARM Integrator/AP (Device Tree)")
|
|
|
|
.reserve = integrator_reserve,
|
|
|
|
.map_io = ap_map_io,
|
|
|
|
.init_early = ap_init_early,
|
|
|
|
.init_irq = ap_init_irq_of,
|
2012-09-06 16:08:47 +08:00
|
|
|
.init_machine = ap_init_of,
|
2012-09-06 16:08:24 +08:00
|
|
|
.dt_compat = ap_dt_board_compat,
|
|
|
|
MACHINE_END
|