1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2000-2003 Deep Blue Solutions Ltd
5 #include <linux/kernel.h>
6 #include <linux/init.h>
7 #include <linux/syscore_ops.h>
8 #include <linux/amba/bus.h>
10 #include <linux/irqchip.h>
11 #include <linux/of_irq.h>
12 #include <linux/of_address.h>
13 #include <linux/of_platform.h>
14 #include <linux/termios.h>
15 #include <linux/mfd/syscon.h>
16 #include <linux/regmap.h>
18 #include <asm/mach/arch.h>
19 #include <asm/mach/map.h>
21 #include "integrator-hardware.h"
22 #include "integrator-cm.h"
23 #include "integrator.h"
25 /* Regmap to the AP system controller */
26 static struct regmap *ap_syscon_map;
29 * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
32 * Setup a VA for the Integrator interrupt controller (for header #0,
35 #define VA_IC_BASE __io_address(INTEGRATOR_IC_BASE)
39 * f1400000 14000000 Interrupt controller
40 * f1600000 16000000 UART 0
43 static struct map_desc ap_io_desc[] __initdata __maybe_unused = {
45 .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE),
46 .pfn = __phys_to_pfn(INTEGRATOR_IC_BASE),
50 .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE),
51 .pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE),
57 static void __init ap_map_io(void)
59 iotable_init(ap_io_desc, ARRAY_SIZE(ap_io_desc));
63 static unsigned long ic_irq_enable;
65 static int irq_suspend(void)
67 ic_irq_enable = readl(VA_IC_BASE + IRQ_ENABLE);
71 static void irq_resume(void)
73 /* disable all irq sources */
75 writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR);
76 writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR);
78 writel(ic_irq_enable, VA_IC_BASE + IRQ_ENABLE_SET);
81 #define irq_suspend NULL
82 #define irq_resume NULL
85 static struct syscore_ops irq_syscore_ops = {
86 .suspend = irq_suspend,
90 static int __init irq_syscore_init(void)
92 register_syscore_ops(&irq_syscore_ops);
97 device_initcall(irq_syscore_init);
100 * For the PL010 found in the Integrator/AP some of the UART control is
101 * implemented in the system controller and accessed using a callback
104 static void integrator_uart_set_mctrl(struct amba_device *dev,
105 void __iomem *base, unsigned int mctrl)
107 unsigned int ctrls = 0, ctrlc = 0, rts_mask, dtr_mask;
108 u32 phybase = dev->res.start;
111 if (phybase == INTEGRATOR_UART0_BASE) {
121 if (mctrl & TIOCM_RTS)
126 if (mctrl & TIOCM_DTR)
131 ret = regmap_write(ap_syscon_map,
132 INTEGRATOR_SC_CTRLS_OFFSET,
135 pr_err("MODEM: unable to write PL010 UART CTRLS\n");
137 ret = regmap_write(ap_syscon_map,
138 INTEGRATOR_SC_CTRLC_OFFSET,
141 pr_err("MODEM: unable to write PL010 UART CRTLC\n");
144 struct amba_pl010_data ap_uart_data = {
145 .set_mctrl = integrator_uart_set_mctrl,
148 static void __init ap_init_irq_of(void)
154 /* For the Device Tree, add in the UART callbacks as AUXDATA */
155 static struct of_dev_auxdata ap_auxdata_lookup[] __initdata = {
156 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE,
157 "uart0", &ap_uart_data),
158 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE,
159 "uart1", &ap_uart_data),
163 static const struct of_device_id ap_syscon_match[] = {
164 { .compatible = "arm,integrator-ap-syscon"},
168 static void __init ap_init_of(void)
170 struct device_node *syscon;
172 of_platform_default_populate(NULL, ap_auxdata_lookup, NULL);
174 syscon = of_find_matching_node(NULL, ap_syscon_match);
177 ap_syscon_map = syscon_node_to_regmap(syscon);
178 if (IS_ERR(ap_syscon_map)) {
179 pr_crit("could not find Integrator/AP system controller\n");
184 static const char * ap_dt_board_compat[] = {
189 DT_MACHINE_START(INTEGRATOR_AP_DT, "ARM Integrator/AP (Device Tree)")
190 .reserve = integrator_reserve,
192 .init_irq = ap_init_irq_of,
193 .init_machine = ap_init_of,
194 .dt_compat = ap_dt_board_compat,