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>
24 #include <linux/clkdev.h>
26 #include <mach/hardware.h>
27 #include <mach/platform.h>
30 #include <asm/system.h>
32 #include <asm/mach/time.h>
33 #include <asm/pgtable.h>
35 static struct amba_pl010_data integrator_uart_data
;
37 static struct amba_device rtc_device
= {
42 .start
= INTEGRATOR_RTC_BASE
,
43 .end
= INTEGRATOR_RTC_BASE
+ SZ_4K
- 1,
44 .flags
= IORESOURCE_MEM
,
46 .irq
= { IRQ_RTCINT
, NO_IRQ
},
47 .periphid
= 0x00041030,
50 static struct amba_device uart0_device
= {
53 .platform_data
= &integrator_uart_data
,
56 .start
= INTEGRATOR_UART0_BASE
,
57 .end
= INTEGRATOR_UART0_BASE
+ SZ_4K
- 1,
58 .flags
= IORESOURCE_MEM
,
60 .irq
= { IRQ_UARTINT0
, NO_IRQ
},
61 .periphid
= 0x0041010,
64 static struct amba_device uart1_device
= {
67 .platform_data
= &integrator_uart_data
,
70 .start
= INTEGRATOR_UART1_BASE
,
71 .end
= INTEGRATOR_UART1_BASE
+ SZ_4K
- 1,
72 .flags
= IORESOURCE_MEM
,
74 .irq
= { IRQ_UARTINT1
, NO_IRQ
},
75 .periphid
= 0x0041010,
78 static struct amba_device kmi0_device
= {
84 .end
= KMI0_BASE
+ SZ_4K
- 1,
85 .flags
= IORESOURCE_MEM
,
87 .irq
= { IRQ_KMIINT0
, NO_IRQ
},
88 .periphid
= 0x00041050,
91 static struct amba_device kmi1_device
= {
97 .end
= KMI1_BASE
+ SZ_4K
- 1,
98 .flags
= IORESOURCE_MEM
,
100 .irq
= { IRQ_KMIINT1
, NO_IRQ
},
101 .periphid
= 0x00041050,
104 static struct amba_device
*amba_devs
[] __initdata
= {
113 * These are fixed clocks.
115 static struct clk clk24mhz
= {
119 static struct clk uartclk
= {
123 static struct clk dummy_apb_pclk
;
125 static struct clk_lookup lookups
[] = {
127 .con_id
= "apb_pclk",
128 .clk
= &dummy_apb_pclk
,
141 }, { /* MMCI - IntegratorCP */
147 void __init
integrator_init_early(void)
149 clkdev_add_table(lookups
, ARRAY_SIZE(lookups
));
152 static int __init
integrator_init(void)
156 for (i
= 0; i
< ARRAY_SIZE(amba_devs
); i
++) {
157 struct amba_device
*d
= amba_devs
[i
];
158 amba_device_register(d
, &iomem_resource
);
164 arch_initcall(integrator_init
);
167 * On the Integrator platform, the port RTS and DTR are provided by
168 * bits in the following SC_CTRLS register bits:
173 #define SC_CTRLC IO_ADDRESS(INTEGRATOR_SC_CTRLC)
174 #define SC_CTRLS IO_ADDRESS(INTEGRATOR_SC_CTRLS)
176 static void integrator_uart_set_mctrl(struct amba_device
*dev
, void __iomem
*base
, unsigned int mctrl
)
178 unsigned int ctrls
= 0, ctrlc
= 0, rts_mask
, dtr_mask
;
180 if (dev
== &uart0_device
) {
188 if (mctrl
& TIOCM_RTS
)
193 if (mctrl
& TIOCM_DTR
)
198 __raw_writel(ctrls
, SC_CTRLS
);
199 __raw_writel(ctrlc
, SC_CTRLC
);
202 static struct amba_pl010_data integrator_uart_data
= {
203 .set_mctrl
= integrator_uart_set_mctrl
,
206 #define CM_CTRL IO_ADDRESS(INTEGRATOR_HDR_CTRL)
208 static DEFINE_SPINLOCK(cm_lock
);
211 * cm_control - update the CM_CTRL register.
212 * @mask: bits to change
215 void cm_control(u32 mask
, u32 set
)
220 spin_lock_irqsave(&cm_lock
, flags
);
221 val
= readl(CM_CTRL
) & ~mask
;
222 writel(val
| set
, CM_CTRL
);
223 spin_unlock_irqrestore(&cm_lock
, flags
);
226 EXPORT_SYMBOL(cm_control
);
229 * We need to stop things allocating the low memory; ideally we need a
230 * better implementation of GFP_DMA which does not assume that DMA-able
231 * memory starts at zero.
233 void __init
integrator_reserve(void)
235 memblock_reserve(PHYS_OFFSET
, __pa(swapper_pg_dir
) - PHYS_OFFSET
);