2 * linux/arch/arm/mach-integrator/core.c
4 * Copyright (C) 2000-2003 Deep Blue Solutions Ltd
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/device.h>
14 #include <linux/spinlock.h>
15 #include <linux/interrupt.h>
16 #include <linux/irq.h>
17 #include <linux/memblock.h>
18 #include <linux/sched.h>
19 #include <linux/smp.h>
20 #include <linux/termios.h>
21 #include <linux/amba/bus.h>
22 #include <linux/amba/serial.h>
25 #include <asm/clkdev.h>
26 #include <mach/clkdev.h>
27 #include <mach/hardware.h>
28 #include <mach/platform.h>
31 #include <asm/system.h>
33 #include <asm/mach/time.h>
34 #include <asm/pgtable.h>
36 static struct amba_pl010_data integrator_uart_data;
38 static struct amba_device rtc_device = {
43 .start = INTEGRATOR_RTC_BASE,
44 .end = INTEGRATOR_RTC_BASE + SZ_4K - 1,
45 .flags = IORESOURCE_MEM,
47 .irq = { IRQ_RTCINT, NO_IRQ },
48 .periphid = 0x00041030,
51 static struct amba_device uart0_device = {
54 .platform_data = &integrator_uart_data,
57 .start = INTEGRATOR_UART0_BASE,
58 .end = INTEGRATOR_UART0_BASE + SZ_4K - 1,
59 .flags = IORESOURCE_MEM,
61 .irq = { IRQ_UARTINT0, NO_IRQ },
62 .periphid = 0x0041010,
65 static struct amba_device uart1_device = {
68 .platform_data = &integrator_uart_data,
71 .start = INTEGRATOR_UART1_BASE,
72 .end = INTEGRATOR_UART1_BASE + SZ_4K - 1,
73 .flags = IORESOURCE_MEM,
75 .irq = { IRQ_UARTINT1, NO_IRQ },
76 .periphid = 0x0041010,
79 static struct amba_device kmi0_device = {
85 .end = KMI0_BASE + SZ_4K - 1,
86 .flags = IORESOURCE_MEM,
88 .irq = { IRQ_KMIINT0, NO_IRQ },
89 .periphid = 0x00041050,
92 static struct amba_device kmi1_device = {
98 .end = KMI1_BASE + SZ_4K - 1,
99 .flags = IORESOURCE_MEM,
101 .irq = { IRQ_KMIINT1, NO_IRQ },
102 .periphid = 0x00041050,
105 static struct amba_device *amba_devs[] __initdata = {
114 * These are fixed clocks.
116 static struct clk clk24mhz = {
120 static struct clk uartclk = {
124 static struct clk dummy_apb_pclk;
126 static struct clk_lookup lookups[] = {
128 .con_id = "apb_pclk",
129 .clk = &dummy_apb_pclk,
142 }, { /* MMCI - IntegratorCP */
148 static int __init integrator_init(void)
152 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
154 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
155 struct amba_device *d = amba_devs[i];
156 amba_device_register(d, &iomem_resource);
162 arch_initcall(integrator_init);
165 * On the Integrator platform, the port RTS and DTR are provided by
166 * bits in the following SC_CTRLS register bits:
171 #define SC_CTRLC IO_ADDRESS(INTEGRATOR_SC_CTRLC)
172 #define SC_CTRLS IO_ADDRESS(INTEGRATOR_SC_CTRLS)
174 static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *base, unsigned int mctrl)
176 unsigned int ctrls = 0, ctrlc = 0, rts_mask, dtr_mask;
178 if (dev == &uart0_device) {
186 if (mctrl & TIOCM_RTS)
191 if (mctrl & TIOCM_DTR)
196 __raw_writel(ctrls, SC_CTRLS);
197 __raw_writel(ctrlc, SC_CTRLC);
200 static struct amba_pl010_data integrator_uart_data = {
201 .set_mctrl = integrator_uart_set_mctrl,
204 #define CM_CTRL IO_ADDRESS(INTEGRATOR_HDR_CTRL)
206 static DEFINE_SPINLOCK(cm_lock);
209 * cm_control - update the CM_CTRL register.
210 * @mask: bits to change
213 void cm_control(u32 mask, u32 set)
218 spin_lock_irqsave(&cm_lock, flags);
219 val = readl(CM_CTRL) & ~mask;
220 writel(val | set, CM_CTRL);
221 spin_unlock_irqrestore(&cm_lock, flags);
224 EXPORT_SYMBOL(cm_control);
227 * We need to stop things allocating the low memory; ideally we need a
228 * better implementation of GFP_DMA which does not assume that DMA-able
229 * memory starts at zero.
231 void __init integrator_reserve(void)
233 memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);