2 * linux/arch/arm/mach-h720x/cpu-h7202.c
4 * Copyright (C) 2003 Thomas Gleixner <tglx@linutronix.de>
5 * 2003 Robert Schwebel <r.schwebel@pengutronix.de>
6 * 2004 Sascha Hauer <s.hauer@pengutronix.de>
8 * processor specific stuff for the Hynix h7202
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
16 #include <linux/init.h>
17 #include <linux/interrupt.h>
18 #include <linux/module.h>
19 #include <asm/types.h>
20 #include <asm/hardware.h>
22 #include <asm/arch/irqs.h>
23 #include <asm/mach/irq.h>
24 #include <asm/mach/time.h>
25 #include <linux/device.h>
26 #include <linux/serial_8250.h>
29 static struct resource h7202ps2_resources
[] = {
33 .flags
= IORESOURCE_MEM
,
38 .flags
= IORESOURCE_IRQ
,
42 static struct platform_device h7202ps2_device
= {
45 .num_resources
= ARRAY_SIZE(h7202ps2_resources
),
46 .resource
= h7202ps2_resources
,
49 static struct plat_serial8250_port serial_platform_data
[] = {
51 .membase
= (void*)SERIAL0_VIRT
,
52 .mapbase
= SERIAL0_BASE
,
57 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
,
60 .membase
= (void*)SERIAL1_VIRT
,
61 .mapbase
= SERIAL1_BASE
,
66 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
,
68 #ifdef CONFIG_H7202_SERIAL23
70 .membase
= (void*)SERIAL2_VIRT
,
71 .mapbase
= SERIAL2_BASE
,
76 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
,
79 .membase
= (void*)SERIAL3_VIRT
,
80 .mapbase
= SERIAL3_BASE
,
85 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
,
91 static struct platform_device serial_device
= {
93 .id
= PLAT8250_DEV_PLATFORM
,
95 .platform_data
= serial_platform_data
,
99 static struct platform_device
*devices
[] __initdata
= {
104 /* Although we have two interrupt lines for the timers, we only have one
105 * status register which clears all pending timer interrupts on reading. So
106 * we have to handle all timer interrupts in one place.
109 h7202_timerx_demux_handler(unsigned int irq_unused
, struct irq_desc
*desc
)
111 unsigned int mask
, irq
;
113 mask
= CPU_REG (TIMER_VIRT
, TIMER_TOPSTAT
);
115 if ( mask
& TSTAT_T0INT
) {
117 if( mask
== TSTAT_T0INT
)
123 desc
= irq_desc
+ irq
;
126 desc_handle_irq(irq
, desc
);
134 * Timer interrupt handler
137 h7202_timer_interrupt(int irq
, void *dev_id
)
139 h7202_timerx_demux_handler(0, NULL
);
144 * mask multiplexed timer IRQs
146 static void inline mask_timerx_irq (u32 irq
)
149 bit
= 2 << ((irq
== IRQ_TIMER64B
) ? 4 : (irq
- IRQ_TIMER1
));
150 CPU_REG (TIMER_VIRT
, TIMER_TOPCTRL
) &= ~bit
;
154 * unmask multiplexed timer IRQs
156 static void inline unmask_timerx_irq (u32 irq
)
159 bit
= 2 << ((irq
== IRQ_TIMER64B
) ? 4 : (irq
- IRQ_TIMER1
));
160 CPU_REG (TIMER_VIRT
, TIMER_TOPCTRL
) |= bit
;
163 static struct irq_chip h7202_timerx_chip
= {
164 .ack
= mask_timerx_irq
,
165 .mask
= mask_timerx_irq
,
166 .unmask
= unmask_timerx_irq
,
169 static struct irqaction h7202_timer_irq
= {
170 .name
= "h7202 Timer Tick",
171 .flags
= IRQF_DISABLED
| IRQF_TIMER
| IRQF_IRQPOLL
,
172 .handler
= h7202_timer_interrupt
,
176 * Setup TIMER0 as system timer
178 void __init
h7202_init_time(void)
180 CPU_REG (TIMER_VIRT
, TM0_PERIOD
) = LATCH
;
181 CPU_REG (TIMER_VIRT
, TM0_CTRL
) = TM_RESET
;
182 CPU_REG (TIMER_VIRT
, TM0_CTRL
) = TM_REPEAT
| TM_START
;
183 CPU_REG (TIMER_VIRT
, TIMER_TOPCTRL
) = ENABLE_TM0_INTR
| TIMER_ENABLE_BIT
;
185 setup_irq(IRQ_TIMER0
, &h7202_timer_irq
);
188 struct sys_timer h7202_timer
= {
189 .init
= h7202_init_time
,
190 .offset
= h720x_gettimeoffset
,
193 void __init
h7202_init_irq (void)
197 CPU_REG (GPIO_E_VIRT
, GPIO_MASK
) = 0x0;
199 for (irq
= IRQ_TIMER1
;
200 irq
< IRQ_CHAINED_TIMERX(NR_TIMERX_IRQS
); irq
++) {
201 mask_timerx_irq(irq
);
202 set_irq_chip(irq
, &h7202_timerx_chip
);
203 set_irq_handler(irq
, handle_edge_irq
);
204 set_irq_flags(irq
, IRQF_VALID
);
206 set_irq_chained_handler(IRQ_TIMERX
, h7202_timerx_demux_handler
);
211 void __init
init_hw_h7202(void)
214 CPU_REG (PMU_BASE
, PMU_PLL_CTRL
) |= PLL_2_EN
| PLL_1_EN
| PLL_3_MUTE
;
216 CPU_REG (SERIAL0_VIRT
, SERIAL_ENABLE
) = SERIAL_ENABLE_EN
;
217 CPU_REG (SERIAL1_VIRT
, SERIAL_ENABLE
) = SERIAL_ENABLE_EN
;
218 #ifdef CONFIG_H7202_SERIAL23
219 CPU_REG (SERIAL2_VIRT
, SERIAL_ENABLE
) = SERIAL_ENABLE_EN
;
220 CPU_REG (SERIAL3_VIRT
, SERIAL_ENABLE
) = SERIAL_ENABLE_EN
;
221 CPU_IO (GPIO_AMULSEL
) = AMULSEL_USIN2
| AMULSEL_USOUT2
|
222 AMULSEL_USIN3
| AMULSEL_USOUT3
;
224 (void) platform_add_devices(devices
, ARRAY_SIZE(devices
));