2019-05-27 14:55:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/mach-integrator/integrator_ap.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000-2003 Deep Blue Solutions Ltd
|
|
|
|
*/
|
|
|
|
#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>
|
2016-11-09 16:12:06 +08:00
|
|
|
#include <linux/mfd/syscon.h>
|
|
|
|
#include <linux/regmap.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"
|
2014-02-14 03:01:41 +08:00
|
|
|
#include "lm.h"
|
2010-05-23 01:18:57 +08:00
|
|
|
|
2016-11-09 16:12:06 +08:00
|
|
|
/* Regmap to the AP system controller */
|
|
|
|
static struct regmap *ap_syscon_map;
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
#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;
|
2016-11-09 16:12:06 +08:00
|
|
|
int ret;
|
2012-11-18 02:24:23 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2016-11-09 16:12:06 +08:00
|
|
|
ret = regmap_write(ap_syscon_map,
|
|
|
|
INTEGRATOR_SC_CTRLS_OFFSET,
|
|
|
|
ctrls);
|
|
|
|
if (ret)
|
|
|
|
pr_err("MODEM: unable to write PL010 UART CTRLS\n");
|
|
|
|
|
|
|
|
ret = regmap_write(ap_syscon_map,
|
|
|
|
INTEGRATOR_SC_CTRLC_OFFSET,
|
|
|
|
ctrlc);
|
|
|
|
if (ret)
|
|
|
|
pr_err("MODEM: unable to write PL010 UART CRTLC\n");
|
2012-11-18 02:24:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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"},
|
|
|
|
{ },
|
|
|
|
};
|
|
|
|
|
2012-09-06 16:08:47 +08:00
|
|
|
static void __init ap_init_of(void)
|
|
|
|
{
|
2016-11-09 16:12:06 +08:00
|
|
|
u32 sc_dec;
|
2012-11-02 08:31:10 +08:00
|
|
|
struct device_node *syscon;
|
2016-11-09 16:12:06 +08:00
|
|
|
int ret;
|
2012-09-06 16:08:47 +08:00
|
|
|
int i;
|
|
|
|
|
2016-11-09 16:12:06 +08:00
|
|
|
of_platform_default_populate(NULL, ap_auxdata_lookup, NULL);
|
|
|
|
|
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;
|
2016-11-09 16:12:06 +08:00
|
|
|
ap_syscon_map = syscon_node_to_regmap(syscon);
|
|
|
|
if (IS_ERR(ap_syscon_map)) {
|
|
|
|
pr_crit("could not find Integrator/AP system controller\n");
|
2013-06-18 05:58:25 +08:00
|
|
|
return;
|
2016-11-09 16:12:06 +08:00
|
|
|
}
|
2012-11-02 08:31:10 +08:00
|
|
|
|
2016-11-09 16:12:06 +08:00
|
|
|
ret = regmap_read(ap_syscon_map,
|
|
|
|
INTEGRATOR_SC_DEC_OFFSET,
|
|
|
|
&sc_dec);
|
|
|
|
if (ret) {
|
|
|
|
pr_crit("could not read from Integrator/AP syscon\n");
|
2013-06-18 05:58:25 +08:00
|
|
|
return;
|
2016-11-09 16:12:06 +08:00
|
|
|
}
|
2012-11-02 08:31:10 +08:00
|
|
|
|
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
|