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/uaccess.h>
15 #include <linux/termios.h>
16 #include <linux/mfd/syscon.h>
17 #include <linux/regmap.h>
19 #include <asm/mach/arch.h>
20 #include <asm/mach/map.h>
22 #include "integrator-hardware.h"
23 #include "integrator-cm.h"
24 #include "integrator.h"
26 /* Regmap to the AP system controller */
27 static struct regmap
*ap_syscon_map
;
30 * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
33 * Setup a VA for the Integrator interrupt controller (for header #0,
36 #define VA_IC_BASE __io_address(INTEGRATOR_IC_BASE)
40 * f1400000 14000000 Interrupt controller
41 * f1600000 16000000 UART 0
44 static struct map_desc ap_io_desc
[] __initdata __maybe_unused
= {
46 .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE
),
47 .pfn
= __phys_to_pfn(INTEGRATOR_IC_BASE
),
51 .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE
),
52 .pfn
= __phys_to_pfn(INTEGRATOR_UART0_BASE
),
58 static void __init
ap_map_io(void)
60 iotable_init(ap_io_desc
, ARRAY_SIZE(ap_io_desc
));
64 static unsigned long ic_irq_enable
;
66 static int irq_suspend(void)
68 ic_irq_enable
= readl(VA_IC_BASE
+ IRQ_ENABLE
);
72 static void irq_resume(void)
74 /* disable all irq sources */
76 writel(-1, VA_IC_BASE
+ IRQ_ENABLE_CLEAR
);
77 writel(-1, VA_IC_BASE
+ FIQ_ENABLE_CLEAR
);
79 writel(ic_irq_enable
, VA_IC_BASE
+ IRQ_ENABLE_SET
);
82 #define irq_suspend NULL
83 #define irq_resume NULL
86 static struct syscore_ops irq_syscore_ops
= {
87 .suspend
= irq_suspend
,
91 static int __init
irq_syscore_init(void)
93 register_syscore_ops(&irq_syscore_ops
);
98 device_initcall(irq_syscore_init
);
101 * For the PL010 found in the Integrator/AP some of the UART control is
102 * implemented in the system controller and accessed using a callback
105 static void integrator_uart_set_mctrl(struct amba_device
*dev
,
106 void __iomem
*base
, unsigned int mctrl
)
108 unsigned int ctrls
= 0, ctrlc
= 0, rts_mask
, dtr_mask
;
109 u32 phybase
= dev
->res
.start
;
112 if (phybase
== INTEGRATOR_UART0_BASE
) {
122 if (mctrl
& TIOCM_RTS
)
127 if (mctrl
& TIOCM_DTR
)
132 ret
= regmap_write(ap_syscon_map
,
133 INTEGRATOR_SC_CTRLS_OFFSET
,
136 pr_err("MODEM: unable to write PL010 UART CTRLS\n");
138 ret
= regmap_write(ap_syscon_map
,
139 INTEGRATOR_SC_CTRLC_OFFSET
,
142 pr_err("MODEM: unable to write PL010 UART CRTLC\n");
145 struct amba_pl010_data ap_uart_data
= {
146 .set_mctrl
= integrator_uart_set_mctrl
,
149 static void __init
ap_init_irq_of(void)
155 /* For the Device Tree, add in the UART callbacks as AUXDATA */
156 static struct of_dev_auxdata ap_auxdata_lookup
[] __initdata
= {
157 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE
,
158 "uart0", &ap_uart_data
),
159 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE
,
160 "uart1", &ap_uart_data
),
164 static const struct of_device_id ap_syscon_match
[] = {
165 { .compatible
= "arm,integrator-ap-syscon"},
169 static void __init
ap_init_of(void)
171 struct device_node
*syscon
;
173 of_platform_default_populate(NULL
, ap_auxdata_lookup
, NULL
);
175 syscon
= of_find_matching_node(NULL
, ap_syscon_match
);
178 ap_syscon_map
= syscon_node_to_regmap(syscon
);
179 if (IS_ERR(ap_syscon_map
)) {
180 pr_crit("could not find Integrator/AP system controller\n");
185 static const char * ap_dt_board_compat
[] = {
190 DT_MACHINE_START(INTEGRATOR_AP_DT
, "ARM Integrator/AP (Device Tree)")
191 .reserve
= integrator_reserve
,
193 .init_irq
= ap_init_irq_of
,
194 .init_machine
= ap_init_of
,
195 .dt_compat
= ap_dt_board_compat
,