aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authordmitry pervushin <dpervushin@embeddedalley.com>2009-04-22 18:57:28 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-04-27 05:28:09 -0400
commitbc19d892a14cbb31d838813b2225e262a6c01341 (patch)
tree833c884534ce314d16b55ef0c3c60cecacc544f8 /arch/arm
parent45d9108011b9dfb4fccd6c258290d2185145709b (diff)
[ARM] 5464/1: Freescale STMP platform support [7/10]
Sources: support for 378x boards Signed-off-by: dmitry pervushin <dpervushin@embeddedalley.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-stmp378x/Makefile2
-rw-r--r--arch/arm/mach-stmp378x/Makefile.boot3
-rw-r--r--arch/arm/mach-stmp378x/stmp378x.c225
-rw-r--r--arch/arm/mach-stmp378x/stmp378x.h24
-rw-r--r--arch/arm/mach-stmp378x/stmp378x_devb.c80
5 files changed, 334 insertions, 0 deletions
diff --git a/arch/arm/mach-stmp378x/Makefile b/arch/arm/mach-stmp378x/Makefile
new file mode 100644
index 000000000000..d156f76b379f
--- /dev/null
+++ b/arch/arm/mach-stmp378x/Makefile
@@ -0,0 +1,2 @@
1obj-$(CONFIG_ARCH_STMP378X) += stmp378x.o
2obj-$(CONFIG_MACH_STMP378X) += stmp378x_devb.o
diff --git a/arch/arm/mach-stmp378x/Makefile.boot b/arch/arm/mach-stmp378x/Makefile.boot
new file mode 100644
index 000000000000..1568ad404d59
--- /dev/null
+++ b/arch/arm/mach-stmp378x/Makefile.boot
@@ -0,0 +1,3 @@
1 zreladdr-y := 0x40008000
2params_phys-y := 0x40000100
3initrd_phys-y := 0x40800000
diff --git a/arch/arm/mach-stmp378x/stmp378x.c b/arch/arm/mach-stmp378x/stmp378x.c
new file mode 100644
index 000000000000..f156ec7306c0
--- /dev/null
+++ b/arch/arm/mach-stmp378x/stmp378x.c
@@ -0,0 +1,225 @@
1/*
2 * Freescale STMP378X platform support
3 *
4 * Embedded Alley Solutions, Inc <source@embeddedalley.com>
5 *
6 * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
7 * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
8 */
9
10/*
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:
14 *
15 * http://www.opensource.org/licenses/gpl-license.html
16 * http://www.gnu.org/copyleft/gpl.html
17 */
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/platform_device.h>
21#include <linux/irq.h>
22
23#include <asm/dma.h>
24#include <asm/setup.h>
25#include <asm/mach-types.h>
26
27#include <asm/mach/arch.h>
28#include <asm/mach/irq.h>
29#include <asm/mach/map.h>
30#include <asm/mach/time.h>
31
32#include <mach/pins.h>
33#include <mach/pinmux.h>
34#include <mach/dma.h>
35#include <mach/hardware.h>
36#include <mach/system.h>
37#include <mach/platform.h>
38#include <mach/stmp3xxx.h>
39#include <mach/regs-icoll.h>
40#include <mach/regs-apbh.h>
41#include <mach/regs-apbx.h>
42
43#include "stmp378x.h"
44/*
45 * IRQ handling
46 */
47static void stmp378x_ack_irq(unsigned int irq)
48{
49 /* Tell ICOLL to release IRQ line */
50 HW_ICOLL_VECTOR_WR(0x0);
51
52 /* ACK current interrupt */
53 HW_ICOLL_LEVELACK_WR(BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0);
54
55 /* Barrier */
56 (void) HW_ICOLL_STAT_RD();
57}
58
59static void stmp378x_mask_irq(unsigned int irq)
60{
61 /* IRQ disable */
62 HW_ICOLL_INTERRUPTn_CLR(irq, BM_ICOLL_INTERRUPTn_ENABLE);
63}
64
65static void stmp378x_unmask_irq(unsigned int irq)
66{
67 /* IRQ enable */
68 HW_ICOLL_INTERRUPTn_SET(irq, BM_ICOLL_INTERRUPTn_ENABLE);
69}
70
71static struct irq_chip stmp378x_chip = {
72 .ack = stmp378x_ack_irq,
73 .mask = stmp378x_mask_irq,
74 .unmask = stmp378x_unmask_irq,
75};
76
77void __init stmp378x_init_irq(void)
78{
79 stmp3xxx_init_irq(&stmp378x_chip);
80}
81
82/*
83 * DMA interrupt handling
84 */
85void stmp3xxx_arch_dma_enable_interrupt(int channel)
86{
87 int dmabus = channel / 16;
88
89 switch (dmabus) {
90 case STMP3XXX_BUS_APBH:
91 HW_APBH_CTRL1_SET(1 << (16 + (channel % 16)));
92 HW_APBH_CTRL2_SET(1 << (16 + (channel % 16)));
93 break;
94
95 case STMP3XXX_BUS_APBX:
96 HW_APBX_CTRL1_SET(1 << (16 + (channel % 16)));
97 HW_APBX_CTRL2_SET(1 << (16 + (channel % 16)));
98 break;
99 }
100}
101EXPORT_SYMBOL(stmp3xxx_arch_dma_enable_interrupt);
102
103void stmp3xxx_arch_dma_clear_interrupt(int channel)
104{
105 int dmabus = channel / 16;
106
107 switch (dmabus) {
108 case STMP3XXX_BUS_APBH:
109 HW_APBH_CTRL1_CLR(1 << (channel % 16));
110 HW_APBH_CTRL2_CLR(1 << (channel % 16));
111 break;
112
113 case STMP3XXX_BUS_APBX:
114 HW_APBX_CTRL1_CLR(1 << (channel % 16));
115 HW_APBX_CTRL2_CLR(1 << (channel % 16));
116 break;
117 }
118}
119EXPORT_SYMBOL(stmp3xxx_arch_dma_clear_interrupt);
120
121int stmp3xxx_arch_dma_is_interrupt(int channel)
122{
123 int dmabus = channel / 16;
124 int r = 0;
125
126 switch (dmabus) {
127 case STMP3XXX_BUS_APBH:
128 r = HW_APBH_CTRL1_RD() & (1 << (channel % 16));
129 break;
130
131 case STMP3XXX_BUS_APBX:
132 r = HW_APBX_CTRL1_RD() & (1 << (channel % 16));
133 break;
134 }
135 return r;
136}
137EXPORT_SYMBOL(stmp3xxx_arch_dma_is_interrupt);
138
139void stmp3xxx_arch_dma_reset_channel(int channel)
140{
141 int dmabus = channel / 16;
142 unsigned chbit = 1 << (channel % 16);
143
144 switch (dmabus) {
145 case STMP3XXX_BUS_APBH:
146 /* Reset channel and wait for it to complete */
147 HW_APBH_CTRL0_SET(chbit <<
148 BP_APBH_CTRL0_RESET_CHANNEL);
149 while (HW_APBH_CTRL0_RD() &
150 (chbit << BP_APBH_CTRL0_RESET_CHANNEL))
151 continue;
152 break;
153
154 case STMP3XXX_BUS_APBX:
155 /* Reset channel and wait for it to complete */
156 HW_APBX_CHANNEL_CTRL_SET(
157 BF_APBX_CHANNEL_CTRL_RESET_CHANNEL(chbit));
158 while (HW_APBX_CHANNEL_CTRL_RD() &
159 BF_APBX_CHANNEL_CTRL_RESET_CHANNEL(chbit))
160 continue;
161 break;
162 }
163}
164EXPORT_SYMBOL(stmp3xxx_arch_dma_reset_channel);
165
166void stmp3xxx_arch_dma_freeze(int channel)
167{
168 int dmabus = channel / 16;
169 unsigned chbit = 1 << (channel % 16);
170
171 switch (dmabus) {
172 case STMP3XXX_BUS_APBH:
173 HW_APBH_CTRL0_SET(1<<chbit);
174 break;
175 case STMP3XXX_BUS_APBX:
176 HW_APBX_CHANNEL_CTRL_SET(1<<chbit);
177 break;
178 }
179}
180EXPORT_SYMBOL(stmp3xxx_arch_dma_freeze);
181
182void stmp3xxx_arch_dma_unfreeze(int channel)
183{
184 int dmabus = channel / 16;
185 unsigned chbit = 1 << (channel % 16);
186
187 switch (dmabus) {
188 case STMP3XXX_BUS_APBH:
189 HW_APBH_CTRL0_CLR(1<<chbit);
190 break;
191 case STMP3XXX_BUS_APBX:
192 HW_APBX_CHANNEL_CTRL_CLR(1<<chbit);
193 break;
194 }
195}
196EXPORT_SYMBOL(stmp3xxx_arch_dma_unfreeze);
197
198/*
199 * The registers are all very closely mapped, so we might as well map them all
200 * with a single mapping
201 *
202 * Logical Physical
203 * f0000000 80000000 On-chip registers
204 * f1000000 00000000 256k on-chip SRAM
205 */
206
207static struct map_desc stmp378x_io_desc[] __initdata = {
208 {
209 .virtual = (u32)STMP3XXX_REGS_BASE,
210 .pfn = __phys_to_pfn(STMP3XXX_REGS_PHBASE),
211 .length = STMP3XXX_REGS_SIZE,
212 .type = MT_DEVICE,
213 },
214 {
215 .virtual = (u32)STMP3XXX_OCRAM_BASE,
216 .pfn = __phys_to_pfn(STMP3XXX_OCRAM_PHBASE),
217 .length = STMP3XXX_OCRAM_SIZE,
218 .type = MT_DEVICE,
219 },
220};
221
222void __init stmp378x_map_io(void)
223{
224 iotable_init(stmp378x_io_desc, ARRAY_SIZE(stmp378x_io_desc));
225}
diff --git a/arch/arm/mach-stmp378x/stmp378x.h b/arch/arm/mach-stmp378x/stmp378x.h
new file mode 100644
index 000000000000..473de64cf8f7
--- /dev/null
+++ b/arch/arm/mach-stmp378x/stmp378x.h
@@ -0,0 +1,24 @@
1/*
2 * Freescale STMP37XX/STMP378X internal functions and data declarations
3 *
4 * Embedded Alley Solutions, Inc <source@embeddedalley.com>
5 *
6 * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
7 * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
8 */
9
10/*
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:
14 *
15 * http://www.opensource.org/licenses/gpl-license.html
16 * http://www.gnu.org/copyleft/gpl.html
17 */
18#ifndef __MACH_STMP378X_H
19#define __MACH_STMP378X_H
20
21void stmp378x_map_io(void);
22void stmp378x_init_irq(void);
23
24#endif /* __MACH_STMP378X_COMMON_H */
diff --git a/arch/arm/mach-stmp378x/stmp378x_devb.c b/arch/arm/mach-stmp378x/stmp378x_devb.c
new file mode 100644
index 000000000000..bc643f686b11
--- /dev/null
+++ b/arch/arm/mach-stmp378x/stmp378x_devb.c
@@ -0,0 +1,80 @@
1/*
2 * Freescale STMP378X development board support
3 *
4 * Embedded Alley Solutions, Inc <source@embeddedalley.com>
5 *
6 * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
7 * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
8 */
9
10/*
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:
14 *
15 * http://www.opensource.org/licenses/gpl-license.html
16 * http://www.gnu.org/copyleft/gpl.html
17 */
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/platform_device.h>
21
22#include <asm/setup.h>
23#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
25
26#include <mach/pins.h>
27#include <mach/pinmux.h>
28#include <mach/stmp3xxx.h>
29
30#include "stmp378x.h"
31
32static struct platform_device *devices[] = {
33 &stmp3xxx_dbguart,
34};
35
36static struct pin_desc dbguart_pins_0[] = {
37 { PINID_PWM0, PIN_FUN3, },
38 { PINID_PWM1, PIN_FUN3, },
39};
40
41static struct pin_group dbguart_pins[] = {
42 [0] = {
43 .pins = dbguart_pins_0,
44 .nr_pins = ARRAY_SIZE(dbguart_pins_0),
45 },
46};
47
48static int dbguart_pins_control(int id, int request)
49{
50 int r = 0;
51
52 if (request)
53 r = stmp3xxx_request_pin_group(&dbguart_pins[id], "debug uart");
54 else
55 stmp3xxx_release_pin_group(&dbguart_pins[id], "debug uart");
56 return r;
57}
58
59static void __init stmp378x_devb_init(void)
60{
61 stmp3xxx_pinmux_init(NR_REAL_IRQS);
62
63 /* init stmp3xxx platform */
64 stmp3xxx_init();
65
66 stmp3xxx_dbguart.dev.platform_data = dbguart_pins_control;
67
68 /* add board's devices */
69 platform_add_devices(devices, ARRAY_SIZE(devices));
70}
71
72MACHINE_START(STMP378X, "STMP378X")
73 .phys_io = 0x80000000,
74 .io_pg_offst = ((0xf0000000) >> 18) & 0xfffc,
75 .boot_params = 0x40000100,
76 .map_io = stmp378x_map_io,
77 .init_irq = stmp378x_init_irq,
78 .timer = &stmp3xxx_timer,
79 .init_machine = stmp378x_devb_init,
80MACHINE_END