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-types.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
},
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
},
63 static struct amba_device uart1_device
= {
66 .platform_data
= &integrator_uart_data
,
69 .start
= INTEGRATOR_UART1_BASE
,
70 .end
= INTEGRATOR_UART1_BASE
+ SZ_4K
- 1,
71 .flags
= IORESOURCE_MEM
,
73 .irq
= { IRQ_UARTINT1
, NO_IRQ
},
76 static struct amba_device kmi0_device
= {
82 .end
= KMI0_BASE
+ SZ_4K
- 1,
83 .flags
= IORESOURCE_MEM
,
85 .irq
= { IRQ_KMIINT0
, NO_IRQ
},
88 static struct amba_device kmi1_device
= {
94 .end
= KMI1_BASE
+ SZ_4K
- 1,
95 .flags
= IORESOURCE_MEM
,
97 .irq
= { IRQ_KMIINT1
, NO_IRQ
},
100 static struct amba_device
*amba_devs
[] __initdata
= {
109 * These are fixed clocks.
111 static struct clk clk24mhz
= {
115 static struct clk uartclk
= {
119 static struct clk dummy_apb_pclk
;
121 static struct clk_lookup lookups
[] = {
123 .con_id
= "apb_pclk",
124 .clk
= &dummy_apb_pclk
,
126 /* Integrator/AP timer frequency */
127 .dev_id
= "ap_timer",
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)
157 * The Integrator/AP lacks necessary AMBA PrimeCell IDs, so we need to
158 * hard-code them. The Integator/CP and forward have proper cell IDs.
159 * Else we leave them undefined to the bus driver can autoprobe them.
161 if (machine_is_integrator()) {
162 rtc_device
.periphid
= 0x00041030;
163 uart0_device
.periphid
= 0x00041010;
164 uart1_device
.periphid
= 0x00041010;
165 kmi0_device
.periphid
= 0x00041050;
166 kmi1_device
.periphid
= 0x00041050;
169 for (i
= 0; i
< ARRAY_SIZE(amba_devs
); i
++) {
170 struct amba_device
*d
= amba_devs
[i
];
171 amba_device_register(d
, &iomem_resource
);
177 arch_initcall(integrator_init
);
180 * On the Integrator platform, the port RTS and DTR are provided by
181 * bits in the following SC_CTRLS register bits:
186 #define SC_CTRLC IO_ADDRESS(INTEGRATOR_SC_CTRLC)
187 #define SC_CTRLS IO_ADDRESS(INTEGRATOR_SC_CTRLS)
189 static void integrator_uart_set_mctrl(struct amba_device
*dev
, void __iomem
*base
, unsigned int mctrl
)
191 unsigned int ctrls
= 0, ctrlc
= 0, rts_mask
, dtr_mask
;
193 if (dev
== &uart0_device
) {
201 if (mctrl
& TIOCM_RTS
)
206 if (mctrl
& TIOCM_DTR
)
211 __raw_writel(ctrls
, SC_CTRLS
);
212 __raw_writel(ctrlc
, SC_CTRLC
);
215 static struct amba_pl010_data integrator_uart_data
= {
216 .set_mctrl
= integrator_uart_set_mctrl
,
219 #define CM_CTRL IO_ADDRESS(INTEGRATOR_HDR_CTRL)
221 static DEFINE_RAW_SPINLOCK(cm_lock
);
224 * cm_control - update the CM_CTRL register.
225 * @mask: bits to change
228 void cm_control(u32 mask
, u32 set
)
233 raw_spin_lock_irqsave(&cm_lock
, flags
);
234 val
= readl(CM_CTRL
) & ~mask
;
235 writel(val
| set
, CM_CTRL
);
236 raw_spin_unlock_irqrestore(&cm_lock
, flags
);
239 EXPORT_SYMBOL(cm_control
);
242 * We need to stop things allocating the low memory; ideally we need a
243 * better implementation of GFP_DMA which does not assume that DMA-able
244 * memory starts at zero.
246 void __init
integrator_reserve(void)
248 memblock_reserve(PHYS_OFFSET
, __pa(swapper_pg_dir
) - PHYS_OFFSET
);
252 * To reset, we hit the on-board reset register in the system FPGA
254 void integrator_restart(char mode
, const char *cmd
)
256 cm_control(CM_CTRL_RESET
, CM_CTRL_RESET
);