2 * Freescale STMP37XX platform support
4 * Embedded Alley Solutions, Inc <source@embeddedalley.com>
6 * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
7 * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
11 * The code contained herein is licensed under the GNU General Public
12 * License. You may obtain a copy of the GNU General Public License
13 * Version 2 or later at the following locations:
15 * http://www.opensource.org/licenses/gpl-license.html
16 * http://www.gnu.org/copyleft/gpl.html
18 #include <linux/types.h>
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/device.h>
22 #include <linux/platform_device.h>
23 #include <linux/irq.h>
26 #include <asm/setup.h>
27 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/irq.h>
31 #include <asm/mach/map.h>
32 #include <asm/mach/time.h>
34 #include <mach/stmp3xxx.h>
37 #include <mach/platform.h>
38 #include <mach/regs-icoll.h>
39 #include <mach/regs-apbh.h>
40 #include <mach/regs-apbx.h>
46 static void stmp37xx_ack_irq(unsigned int irq
)
49 stmp3xxx_clearl(0x04 << ((irq
% 4) * 8),
50 REGS_ICOLL_BASE
+ HW_ICOLL_PRIORITYn
+ irq
/ 4 * 0x10);
52 /* ACK current interrupt */
53 __raw_writel(1, REGS_ICOLL_BASE
+ HW_ICOLL_LEVELACK
);
56 (void)__raw_readl(REGS_ICOLL_BASE
+ HW_ICOLL_STAT
);
59 static void stmp37xx_mask_irq(unsigned int irq
)
62 stmp3xxx_clearl(0x04 << ((irq
% 4) * 8),
63 REGS_ICOLL_BASE
+ HW_ICOLL_PRIORITYn
+ irq
/ 4 * 0x10);
66 static void stmp37xx_unmask_irq(unsigned int irq
)
69 stmp3xxx_setl(0x04 << ((irq
% 4) * 8),
70 REGS_ICOLL_BASE
+ HW_ICOLL_PRIORITYn
+ irq
/ 4 * 0x10);
73 static struct irq_chip stmp37xx_chip
= {
74 .ack
= stmp37xx_ack_irq
,
75 .mask
= stmp37xx_mask_irq
,
76 .unmask
= stmp37xx_unmask_irq
,
79 void __init
stmp37xx_init_irq(void)
81 stmp3xxx_init_irq(&stmp37xx_chip
);
85 * DMA interrupt handling
87 void stmp3xxx_arch_dma_enable_interrupt(int channel
)
89 switch (STMP3XXX_DMA_BUS(channel
)) {
90 case STMP3XXX_BUS_APBH
:
91 stmp3xxx_setl(1 << (8 + STMP3XXX_DMA_CHANNEL(channel
)),
92 REGS_APBH_BASE
+ HW_APBH_CTRL1
);
95 case STMP3XXX_BUS_APBX
:
96 stmp3xxx_setl(1 << (8 + STMP3XXX_DMA_CHANNEL(channel
)),
97 REGS_APBX_BASE
+ HW_APBX_CTRL1
);
101 EXPORT_SYMBOL(stmp3xxx_arch_dma_enable_interrupt
);
103 void stmp3xxx_arch_dma_clear_interrupt(int channel
)
105 switch (STMP3XXX_DMA_BUS(channel
)) {
106 case STMP3XXX_BUS_APBH
:
107 stmp3xxx_clearl(1 << STMP3XXX_DMA_CHANNEL(channel
),
108 REGS_APBH_BASE
+ HW_APBH_CTRL1
);
111 case STMP3XXX_BUS_APBX
:
112 stmp3xxx_clearl(1 << STMP3XXX_DMA_CHANNEL(channel
),
113 REGS_APBX_BASE
+ HW_APBX_CTRL1
);
117 EXPORT_SYMBOL(stmp3xxx_arch_dma_clear_interrupt
);
119 int stmp3xxx_arch_dma_is_interrupt(int channel
)
123 switch (STMP3XXX_DMA_BUS(channel
)) {
124 case STMP3XXX_BUS_APBH
:
125 r
= __raw_readl(REGS_APBH_BASE
+ HW_APBH_CTRL1
) &
126 (1 << STMP3XXX_DMA_CHANNEL(channel
));
129 case STMP3XXX_BUS_APBX
:
130 r
= __raw_readl(REGS_APBH_BASE
+ HW_APBH_CTRL1
) &
131 (1 << STMP3XXX_DMA_CHANNEL(channel
));
136 EXPORT_SYMBOL(stmp3xxx_arch_dma_is_interrupt
);
138 void stmp3xxx_arch_dma_reset_channel(int channel
)
140 unsigned chbit
= 1 << STMP3XXX_DMA_CHANNEL(channel
);
142 switch (STMP3XXX_DMA_BUS(channel
)) {
143 case STMP3XXX_BUS_APBH
:
144 /* Reset channel and wait for it to complete */
145 stmp3xxx_setl(chbit
<< BP_APBH_CTRL0_RESET_CHANNEL
,
146 REGS_APBH_BASE
+ HW_APBH_CTRL0
);
147 while (__raw_readl(REGS_APBH_BASE
+ HW_APBH_CTRL0
) &
148 (chbit
<< BP_APBH_CTRL0_RESET_CHANNEL
))
152 case STMP3XXX_BUS_APBX
:
153 stmp3xxx_setl(chbit
<< BP_APBX_CTRL0_RESET_CHANNEL
,
154 REGS_APBX_BASE
+ HW_APBX_CTRL0
);
155 while (__raw_readl(REGS_APBX_BASE
+ HW_APBX_CTRL0
) &
156 (chbit
<< BP_APBX_CTRL0_RESET_CHANNEL
))
161 EXPORT_SYMBOL(stmp3xxx_arch_dma_reset_channel
);
163 void stmp3xxx_arch_dma_freeze(int channel
)
165 unsigned chbit
= 1 << STMP3XXX_DMA_CHANNEL(channel
);
167 switch (STMP3XXX_DMA_BUS(channel
)) {
168 case STMP3XXX_BUS_APBH
:
169 stmp3xxx_setl(1 << chbit
, REGS_APBH_BASE
+ HW_APBH_CTRL0
);
171 case STMP3XXX_BUS_APBX
:
172 stmp3xxx_setl(1 << chbit
, REGS_APBH_BASE
+ HW_APBH_CTRL0
);
176 EXPORT_SYMBOL(stmp3xxx_arch_dma_freeze
);
178 void stmp3xxx_arch_dma_unfreeze(int channel
)
180 unsigned chbit
= 1 << STMP3XXX_DMA_CHANNEL(channel
);
182 switch (STMP3XXX_DMA_BUS(channel
)) {
183 case STMP3XXX_BUS_APBH
:
184 stmp3xxx_clearl(1 << chbit
, REGS_APBH_BASE
+ HW_APBH_CTRL0
);
186 case STMP3XXX_BUS_APBX
:
187 stmp3xxx_clearl(1 << chbit
, REGS_APBH_BASE
+ HW_APBH_CTRL0
);
191 EXPORT_SYMBOL(stmp3xxx_arch_dma_unfreeze
);
194 * The registers are all very closely mapped, so we might as well map them all
195 * with a single mapping
198 * f0000000 80000000 On-chip registers
199 * f1000000 00000000 32k on-chip SRAM
201 static struct map_desc stmp37xx_io_desc
[] __initdata
= {
203 .virtual = (u32
)STMP3XXX_REGS_BASE
,
204 .pfn
= __phys_to_pfn(STMP3XXX_REGS_PHBASE
),
209 .virtual = (u32
)STMP3XXX_OCRAM_BASE
,
210 .pfn
= __phys_to_pfn(STMP3XXX_OCRAM_PHBASE
),
211 .length
= STMP3XXX_OCRAM_SIZE
,
216 void __init
stmp37xx_map_io(void)
218 iotable_init(stmp37xx_io_desc
, ARRAY_SIZE(stmp37xx_io_desc
));