diff options
Diffstat (limited to 'arch/arm/mach-netx')
-rw-r--r-- | arch/arm/mach-netx/Kconfig | 24 | ||||
-rw-r--r-- | arch/arm/mach-netx/Makefile | 15 | ||||
-rw-r--r-- | arch/arm/mach-netx/Makefile.boot | 2 | ||||
-rw-r--r-- | arch/arm/mach-netx/fb.c | 114 | ||||
-rw-r--r-- | arch/arm/mach-netx/fb.h | 24 | ||||
-rw-r--r-- | arch/arm/mach-netx/generic.c | 193 | ||||
-rw-r--r-- | arch/arm/mach-netx/generic.h | 24 | ||||
-rw-r--r-- | arch/arm/mach-netx/nxdb500.c | 210 | ||||
-rw-r--r-- | arch/arm/mach-netx/nxdkn.c | 103 | ||||
-rw-r--r-- | arch/arm/mach-netx/nxeb500hmi.c | 187 | ||||
-rw-r--r-- | arch/arm/mach-netx/pfifo.c | 68 | ||||
-rw-r--r-- | arch/arm/mach-netx/time.c | 88 | ||||
-rw-r--r-- | arch/arm/mach-netx/xc.c | 255 |
13 files changed, 1307 insertions, 0 deletions
diff --git a/arch/arm/mach-netx/Kconfig b/arch/arm/mach-netx/Kconfig new file mode 100644 index 000000000000..3d90ef19be2b --- /dev/null +++ b/arch/arm/mach-netx/Kconfig | |||
@@ -0,0 +1,24 @@ | |||
1 | menu "NetX Implementations" | ||
2 | depends on ARCH_NETX | ||
3 | |||
4 | config MACH_NXDKN | ||
5 | bool "Enable Hilscher nxdkn Eval Board support" | ||
6 | depends on ARCH_NETX | ||
7 | help | ||
8 | Board support for the Hilscher NetX Eval Board | ||
9 | |||
10 | config MACH_NXDB500 | ||
11 | bool "Enable Hilscher nxdb500 Eval Board support" | ||
12 | depends on ARCH_NETX | ||
13 | select ARM_AMBA | ||
14 | help | ||
15 | Board support for the Hilscher nxdb500 Eval Board | ||
16 | |||
17 | config MACH_NXEB500HMI | ||
18 | bool "Enable Hilscher nxeb500hmi Eval Board support" | ||
19 | depends on ARCH_NETX | ||
20 | select ARM_AMBA | ||
21 | help | ||
22 | Board support for the Hilscher nxeb500hmi Eval Board | ||
23 | |||
24 | endmenu | ||
diff --git a/arch/arm/mach-netx/Makefile b/arch/arm/mach-netx/Makefile new file mode 100644 index 000000000000..18785ff37657 --- /dev/null +++ b/arch/arm/mach-netx/Makefile | |||
@@ -0,0 +1,15 @@ | |||
1 | # | ||
2 | # Makefile for the linux kernel. | ||
3 | # | ||
4 | # Note! Dependencies are done automagically by 'make dep', which also | ||
5 | # removes any old dependencies. DON'T put your own dependencies here | ||
6 | # unless it's something special (ie not a .c file). | ||
7 | |||
8 | # Object file lists. | ||
9 | |||
10 | obj-y += time.o generic.o pfifo.o xc.o | ||
11 | |||
12 | # Specific board support | ||
13 | obj-$(CONFIG_MACH_NXDKN) += nxdkn.o | ||
14 | obj-$(CONFIG_MACH_NXDB500) += nxdb500.o fb.o | ||
15 | obj-$(CONFIG_MACH_NXEB500HMI) += nxeb500hmi.o fb.o | ||
diff --git a/arch/arm/mach-netx/Makefile.boot b/arch/arm/mach-netx/Makefile.boot new file mode 100644 index 000000000000..b81cf6aff0ac --- /dev/null +++ b/arch/arm/mach-netx/Makefile.boot | |||
@@ -0,0 +1,2 @@ | |||
1 | zreladdr-y := 0x80008000 | ||
2 | |||
diff --git a/arch/arm/mach-netx/fb.c b/arch/arm/mach-netx/fb.c new file mode 100644 index 000000000000..ef0ab6115c0b --- /dev/null +++ b/arch/arm/mach-netx/fb.c | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-netx/fb.c | ||
3 | * | ||
4 | * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/device.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/dma-mapping.h> | ||
23 | #include <linux/amba/bus.h> | ||
24 | #include <linux/amba/clcd.h> | ||
25 | |||
26 | #include <asm/arch/netx-regs.h> | ||
27 | #include <asm/hardware.h> | ||
28 | |||
29 | struct clk {}; | ||
30 | |||
31 | static struct clk fb_clk; | ||
32 | |||
33 | static struct clcd_panel *netx_panel; | ||
34 | |||
35 | void netx_clcd_enable(struct clcd_fb *fb) | ||
36 | { | ||
37 | } | ||
38 | |||
39 | int netx_clcd_setup(struct clcd_fb *fb) | ||
40 | { | ||
41 | dma_addr_t dma; | ||
42 | |||
43 | fb->panel = netx_panel; | ||
44 | |||
45 | fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, 1024*1024, | ||
46 | &dma, GFP_KERNEL); | ||
47 | if (!fb->fb.screen_base) { | ||
48 | printk(KERN_ERR "CLCD: unable to map framebuffer\n"); | ||
49 | return -ENOMEM; | ||
50 | } | ||
51 | |||
52 | fb->fb.fix.smem_start = dma; | ||
53 | fb->fb.fix.smem_len = 1024*1024; | ||
54 | |||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | int netx_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma) | ||
59 | { | ||
60 | return dma_mmap_writecombine(&fb->dev->dev, vma, | ||
61 | fb->fb.screen_base, | ||
62 | fb->fb.fix.smem_start, | ||
63 | fb->fb.fix.smem_len); | ||
64 | } | ||
65 | |||
66 | void netx_clcd_remove(struct clcd_fb *fb) | ||
67 | { | ||
68 | dma_free_writecombine(&fb->dev->dev, fb->fb.fix.smem_len, | ||
69 | fb->fb.screen_base, fb->fb.fix.smem_start); | ||
70 | } | ||
71 | |||
72 | void clk_disable(struct clk *clk) | ||
73 | { | ||
74 | } | ||
75 | |||
76 | int clk_set_rate(struct clk *clk, unsigned long rate) | ||
77 | { | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | int clk_enable(struct clk *clk) | ||
82 | { | ||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | struct clk *clk_get(struct device *dev, const char *id) | ||
87 | { | ||
88 | return &fb_clk; | ||
89 | } | ||
90 | |||
91 | void clk_put(struct clk *clk) | ||
92 | { | ||
93 | } | ||
94 | |||
95 | static struct amba_device fb_device = { | ||
96 | .dev = { | ||
97 | .bus_id = "fb", | ||
98 | .coherent_dma_mask = ~0, | ||
99 | }, | ||
100 | .res = { | ||
101 | .start = 0x00104000, | ||
102 | .end = 0x00104fff, | ||
103 | .flags = IORESOURCE_MEM, | ||
104 | }, | ||
105 | .irq = { NETX_IRQ_LCD, NO_IRQ }, | ||
106 | .periphid = 0x10112400, | ||
107 | }; | ||
108 | |||
109 | int netx_fb_init(struct clcd_board *board, struct clcd_panel *panel) | ||
110 | { | ||
111 | netx_panel = panel; | ||
112 | fb_device.dev.platform_data = board; | ||
113 | return amba_device_register(&fb_device, &iomem_resource); | ||
114 | } | ||
diff --git a/arch/arm/mach-netx/fb.h b/arch/arm/mach-netx/fb.h new file mode 100644 index 000000000000..4919cf33a5f3 --- /dev/null +++ b/arch/arm/mach-netx/fb.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-netx/fb.h | ||
3 | * | ||
4 | * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | void netx_clcd_enable(struct clcd_fb *fb); | ||
21 | int netx_clcd_setup(struct clcd_fb *fb); | ||
22 | int netx_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma); | ||
23 | void netx_clcd_remove(struct clcd_fb *fb); | ||
24 | int netx_fb_init(struct clcd_board *board, struct clcd_panel *panel); | ||
diff --git a/arch/arm/mach-netx/generic.c b/arch/arm/mach-netx/generic.c new file mode 100644 index 000000000000..af0b13534cfd --- /dev/null +++ b/arch/arm/mach-netx/generic.c | |||
@@ -0,0 +1,193 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-netx/generic.c | ||
3 | * | ||
4 | * Copyright (C) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/device.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <asm/hardware.h> | ||
26 | #include <asm/mach/map.h> | ||
27 | #include <asm/hardware/vic.h> | ||
28 | #include <asm/io.h> | ||
29 | #include <asm/arch/netx-regs.h> | ||
30 | #include <asm/mach/irq.h> | ||
31 | |||
32 | static struct map_desc netx_io_desc[] __initdata = { | ||
33 | { | ||
34 | .virtual = NETX_IO_VIRT, | ||
35 | .pfn = __phys_to_pfn(NETX_IO_PHYS), | ||
36 | .length = NETX_IO_SIZE, | ||
37 | .type = MT_DEVICE | ||
38 | } | ||
39 | }; | ||
40 | |||
41 | void __init netx_map_io(void) | ||
42 | { | ||
43 | iotable_init(netx_io_desc, ARRAY_SIZE(netx_io_desc)); | ||
44 | } | ||
45 | |||
46 | static struct resource netx_rtc_resources[] = { | ||
47 | [0] = { | ||
48 | .start = 0x00101200, | ||
49 | .end = 0x00101220, | ||
50 | .flags = IORESOURCE_MEM, | ||
51 | }, | ||
52 | }; | ||
53 | |||
54 | static struct platform_device netx_rtc_device = { | ||
55 | .name = "netx-rtc", | ||
56 | .id = 0, | ||
57 | .num_resources = ARRAY_SIZE(netx_rtc_resources), | ||
58 | .resource = netx_rtc_resources, | ||
59 | }; | ||
60 | |||
61 | static struct platform_device *devices[] __initdata = { | ||
62 | &netx_rtc_device, | ||
63 | }; | ||
64 | |||
65 | #if 0 | ||
66 | #define DEBUG_IRQ(fmt...) printk(fmt) | ||
67 | #else | ||
68 | #define DEBUG_IRQ(fmt...) while (0) {} | ||
69 | #endif | ||
70 | |||
71 | static void | ||
72 | netx_hif_demux_handler(unsigned int irq_unused, struct irqdesc *desc, | ||
73 | struct pt_regs *regs) | ||
74 | { | ||
75 | unsigned int irq = NETX_IRQ_HIF_CHAINED(0); | ||
76 | unsigned int stat; | ||
77 | |||
78 | stat = ((readl(NETX_DPMAS_INT_EN) & | ||
79 | readl(NETX_DPMAS_INT_STAT)) >> 24) & 0x1f; | ||
80 | |||
81 | desc = irq_desc + NETX_IRQ_HIF_CHAINED(0); | ||
82 | |||
83 | while (stat) { | ||
84 | if (stat & 1) { | ||
85 | DEBUG_IRQ("handling irq %d\n", irq); | ||
86 | desc_handle_irq(irq, desc, regs); | ||
87 | } | ||
88 | irq++; | ||
89 | desc++; | ||
90 | stat >>= 1; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | static int | ||
95 | netx_hif_irq_type(unsigned int _irq, unsigned int type) | ||
96 | { | ||
97 | unsigned int val, irq; | ||
98 | |||
99 | val = readl(NETX_DPMAS_IF_CONF1); | ||
100 | |||
101 | irq = _irq - NETX_IRQ_HIF_CHAINED(0); | ||
102 | |||
103 | if (type & __IRQT_RISEDGE) { | ||
104 | DEBUG_IRQ("rising edges\n"); | ||
105 | val |= (1 << 26) << irq; | ||
106 | } | ||
107 | if (type & __IRQT_FALEDGE) { | ||
108 | DEBUG_IRQ("falling edges\n"); | ||
109 | val &= ~((1 << 26) << irq); | ||
110 | } | ||
111 | if (type & __IRQT_LOWLVL) { | ||
112 | DEBUG_IRQ("low level\n"); | ||
113 | val &= ~((1 << 26) << irq); | ||
114 | } | ||
115 | if (type & __IRQT_HIGHLVL) { | ||
116 | DEBUG_IRQ("high level\n"); | ||
117 | val |= (1 << 26) << irq; | ||
118 | } | ||
119 | |||
120 | writel(val, NETX_DPMAS_IF_CONF1); | ||
121 | |||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | static void | ||
126 | netx_hif_ack_irq(unsigned int _irq) | ||
127 | { | ||
128 | unsigned int val, irq; | ||
129 | |||
130 | irq = _irq - NETX_IRQ_HIF_CHAINED(0); | ||
131 | writel((1 << 24) << irq, NETX_DPMAS_INT_STAT); | ||
132 | |||
133 | val = readl(NETX_DPMAS_INT_EN); | ||
134 | val &= ~((1 << 24) << irq); | ||
135 | writel(val, NETX_DPMAS_INT_EN); | ||
136 | |||
137 | DEBUG_IRQ("%s: irq %d\n", __FUNCTION__, _irq); | ||
138 | } | ||
139 | |||
140 | static void | ||
141 | netx_hif_mask_irq(unsigned int _irq) | ||
142 | { | ||
143 | unsigned int val, irq; | ||
144 | |||
145 | irq = _irq - NETX_IRQ_HIF_CHAINED(0); | ||
146 | val = readl(NETX_DPMAS_INT_EN); | ||
147 | val &= ~((1 << 24) << irq); | ||
148 | writel(val, NETX_DPMAS_INT_EN); | ||
149 | DEBUG_IRQ("%s: irq %d\n", __FUNCTION__, _irq); | ||
150 | } | ||
151 | |||
152 | static void | ||
153 | netx_hif_unmask_irq(unsigned int _irq) | ||
154 | { | ||
155 | unsigned int val, irq; | ||
156 | |||
157 | irq = _irq - NETX_IRQ_HIF_CHAINED(0); | ||
158 | val = readl(NETX_DPMAS_INT_EN); | ||
159 | val |= (1 << 24) << irq; | ||
160 | writel(val, NETX_DPMAS_INT_EN); | ||
161 | DEBUG_IRQ("%s: irq %d\n", __FUNCTION__, _irq); | ||
162 | } | ||
163 | |||
164 | static struct irqchip netx_hif_chip = { | ||
165 | .ack = netx_hif_ack_irq, | ||
166 | .mask = netx_hif_mask_irq, | ||
167 | .unmask = netx_hif_unmask_irq, | ||
168 | .set_type = netx_hif_irq_type, | ||
169 | }; | ||
170 | |||
171 | void __init netx_init_irq(void) | ||
172 | { | ||
173 | int irq; | ||
174 | |||
175 | vic_init(__io(io_p2v(NETX_PA_VIC)), 0, ~0); | ||
176 | |||
177 | for (irq = NETX_IRQ_HIF_CHAINED(0); irq <= NETX_IRQ_HIF_LAST; irq++) { | ||
178 | set_irq_chip(irq, &netx_hif_chip); | ||
179 | set_irq_handler(irq, do_level_IRQ); | ||
180 | set_irq_flags(irq, IRQF_VALID); | ||
181 | } | ||
182 | |||
183 | writel(NETX_DPMAS_INT_EN_GLB_EN, NETX_DPMAS_INT_EN); | ||
184 | set_irq_chained_handler(NETX_IRQ_HIF, netx_hif_demux_handler); | ||
185 | } | ||
186 | |||
187 | static int __init netx_init(void) | ||
188 | { | ||
189 | return platform_add_devices(devices, ARRAY_SIZE(devices)); | ||
190 | } | ||
191 | |||
192 | subsys_initcall(netx_init); | ||
193 | |||
diff --git a/arch/arm/mach-netx/generic.h b/arch/arm/mach-netx/generic.h new file mode 100644 index 000000000000..ede2d35341c3 --- /dev/null +++ b/arch/arm/mach-netx/generic.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-netx/generic.h | ||
3 | * | ||
4 | * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | extern void __init netx_map_io(void); | ||
21 | extern void __init netx_init_irq(void); | ||
22 | |||
23 | struct sys_timer; | ||
24 | extern struct sys_timer netx_timer; | ||
diff --git a/arch/arm/mach-netx/nxdb500.c b/arch/arm/mach-netx/nxdb500.c new file mode 100644 index 000000000000..e4a133d62846 --- /dev/null +++ b/arch/arm/mach-netx/nxdb500.c | |||
@@ -0,0 +1,210 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-netx/nxdb500.c | ||
3 | * | ||
4 | * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/dma-mapping.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/mtd/plat-ram.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/amba/bus.h> | ||
26 | #include <linux/amba/clcd.h> | ||
27 | |||
28 | #include <asm/hardware.h> | ||
29 | #include <asm/mach-types.h> | ||
30 | #include <asm/mach/arch.h> | ||
31 | #include <asm/arch/netx-regs.h> | ||
32 | #include <asm/arch/eth.h> | ||
33 | |||
34 | #include "generic.h" | ||
35 | #include "fb.h" | ||
36 | |||
37 | static struct clcd_panel qvga = { | ||
38 | .mode = { | ||
39 | .name = "QVGA", | ||
40 | .refresh = 60, | ||
41 | .xres = 240, | ||
42 | .yres = 320, | ||
43 | .pixclock = 187617, | ||
44 | .left_margin = 6, | ||
45 | .right_margin = 26, | ||
46 | .upper_margin = 0, | ||
47 | .lower_margin = 6, | ||
48 | .hsync_len = 6, | ||
49 | .vsync_len = 1, | ||
50 | .sync = 0, | ||
51 | .vmode = FB_VMODE_NONINTERLACED, | ||
52 | }, | ||
53 | .width = -1, | ||
54 | .height = -1, | ||
55 | .tim2 = 16, | ||
56 | .cntl = CNTL_LCDTFT | CNTL_BGR, | ||
57 | .bpp = 16, | ||
58 | .grayscale = 0, | ||
59 | }; | ||
60 | |||
61 | static inline int nxdb500_check(struct clcd_fb *fb, struct fb_var_screeninfo *var) | ||
62 | { | ||
63 | var->green.length = 5; | ||
64 | var->green.msb_right = 0; | ||
65 | |||
66 | return clcdfb_check(fb, var); | ||
67 | } | ||
68 | |||
69 | static int nxdb500_clcd_setup(struct clcd_fb *fb) | ||
70 | { | ||
71 | unsigned int val; | ||
72 | |||
73 | fb->fb.var.green.length = 5; | ||
74 | fb->fb.var.green.msb_right = 0; | ||
75 | |||
76 | /* enable asic control */ | ||
77 | val = readl(NETX_SYSTEM_IOC_ACCESS_KEY); | ||
78 | writel(val, NETX_SYSTEM_IOC_ACCESS_KEY); | ||
79 | |||
80 | writel(3, NETX_SYSTEM_IOC_CR); | ||
81 | |||
82 | val = readl(NETX_PIO_OUTPIO); | ||
83 | writel(val | 1, NETX_PIO_OUTPIO); | ||
84 | |||
85 | val = readl(NETX_PIO_OEPIO); | ||
86 | writel(val | 1, NETX_PIO_OEPIO); | ||
87 | return netx_clcd_setup(fb); | ||
88 | } | ||
89 | |||
90 | static struct clcd_board clcd_data = { | ||
91 | .name = "netX", | ||
92 | .check = nxdb500_check, | ||
93 | .decode = clcdfb_decode, | ||
94 | .enable = netx_clcd_enable, | ||
95 | .setup = nxdb500_clcd_setup, | ||
96 | .mmap = netx_clcd_mmap, | ||
97 | .remove = netx_clcd_remove, | ||
98 | }; | ||
99 | |||
100 | static struct netxeth_platform_data eth0_platform_data = { | ||
101 | .xcno = 0, | ||
102 | }; | ||
103 | |||
104 | static struct platform_device netx_eth0_device = { | ||
105 | .name = "netx-eth", | ||
106 | .id = 0, | ||
107 | .num_resources = 0, | ||
108 | .resource = NULL, | ||
109 | .dev = { | ||
110 | .platform_data = ð0_platform_data, | ||
111 | } | ||
112 | }; | ||
113 | |||
114 | static struct netxeth_platform_data eth1_platform_data = { | ||
115 | .xcno = 1, | ||
116 | }; | ||
117 | |||
118 | static struct platform_device netx_eth1_device = { | ||
119 | .name = "netx-eth", | ||
120 | .id = 1, | ||
121 | .num_resources = 0, | ||
122 | .resource = NULL, | ||
123 | .dev = { | ||
124 | .platform_data = ð1_platform_data, | ||
125 | } | ||
126 | }; | ||
127 | |||
128 | static struct resource netx_uart0_resources[] = { | ||
129 | [0] = { | ||
130 | .start = 0x00100A00, | ||
131 | .end = 0x00100A3F, | ||
132 | .flags = IORESOURCE_MEM, | ||
133 | }, | ||
134 | [1] = { | ||
135 | .start = (NETX_IRQ_UART0), | ||
136 | .end = (NETX_IRQ_UART0), | ||
137 | .flags = IORESOURCE_IRQ, | ||
138 | }, | ||
139 | }; | ||
140 | |||
141 | static struct platform_device netx_uart0_device = { | ||
142 | .name = "netx-uart", | ||
143 | .id = 0, | ||
144 | .num_resources = ARRAY_SIZE(netx_uart0_resources), | ||
145 | .resource = netx_uart0_resources, | ||
146 | }; | ||
147 | |||
148 | static struct resource netx_uart1_resources[] = { | ||
149 | [0] = { | ||
150 | .start = 0x00100A40, | ||
151 | .end = 0x00100A7F, | ||
152 | .flags = IORESOURCE_MEM, | ||
153 | }, | ||
154 | [1] = { | ||
155 | .start = (NETX_IRQ_UART1), | ||
156 | .end = (NETX_IRQ_UART1), | ||
157 | .flags = IORESOURCE_IRQ, | ||
158 | }, | ||
159 | }; | ||
160 | |||
161 | static struct platform_device netx_uart1_device = { | ||
162 | .name = "netx-uart", | ||
163 | .id = 1, | ||
164 | .num_resources = ARRAY_SIZE(netx_uart1_resources), | ||
165 | .resource = netx_uart1_resources, | ||
166 | }; | ||
167 | |||
168 | static struct resource netx_uart2_resources[] = { | ||
169 | [0] = { | ||
170 | .start = 0x00100A80, | ||
171 | .end = 0x00100ABF, | ||
172 | .flags = IORESOURCE_MEM, | ||
173 | }, | ||
174 | [1] = { | ||
175 | .start = (NETX_IRQ_UART2), | ||
176 | .end = (NETX_IRQ_UART2), | ||
177 | .flags = IORESOURCE_IRQ, | ||
178 | }, | ||
179 | }; | ||
180 | |||
181 | static struct platform_device netx_uart2_device = { | ||
182 | .name = "netx-uart", | ||
183 | .id = 2, | ||
184 | .num_resources = ARRAY_SIZE(netx_uart2_resources), | ||
185 | .resource = netx_uart2_resources, | ||
186 | }; | ||
187 | |||
188 | static struct platform_device *devices[] __initdata = { | ||
189 | &netx_eth0_device, | ||
190 | &netx_eth1_device, | ||
191 | &netx_uart0_device, | ||
192 | &netx_uart1_device, | ||
193 | &netx_uart2_device, | ||
194 | }; | ||
195 | |||
196 | static void __init nxdb500_init(void) | ||
197 | { | ||
198 | netx_fb_init(&clcd_data, &qvga); | ||
199 | platform_add_devices(devices, ARRAY_SIZE(devices)); | ||
200 | } | ||
201 | |||
202 | MACHINE_START(NXDB500, "Hilscher nxdb500") | ||
203 | .phys_io = 0x00100000, | ||
204 | .io_pg_offst = (io_p2v(0x00100000) >> 18) & 0xfffc, | ||
205 | .boot_params = 0x80000100, | ||
206 | .map_io = netx_map_io, | ||
207 | .init_irq = netx_init_irq, | ||
208 | .timer = &netx_timer, | ||
209 | .init_machine = nxdb500_init, | ||
210 | MACHINE_END | ||
diff --git a/arch/arm/mach-netx/nxdkn.c b/arch/arm/mach-netx/nxdkn.c new file mode 100644 index 000000000000..7e26c42d1ac7 --- /dev/null +++ b/arch/arm/mach-netx/nxdkn.c | |||
@@ -0,0 +1,103 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-netx/nxdkn.c | ||
3 | * | ||
4 | * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/dma-mapping.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/mtd/plat-ram.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/amba/bus.h> | ||
26 | #include <linux/amba/clcd.h> | ||
27 | |||
28 | #include <asm/hardware.h> | ||
29 | #include <asm/mach-types.h> | ||
30 | #include <asm/mach/arch.h> | ||
31 | #include <asm/arch/netx-regs.h> | ||
32 | #include <asm/arch/eth.h> | ||
33 | |||
34 | #include "generic.h" | ||
35 | |||
36 | static struct netxeth_platform_data eth0_platform_data = { | ||
37 | .xcno = 0, | ||
38 | }; | ||
39 | |||
40 | static struct platform_device nxdkn_eth0_device = { | ||
41 | .name = "netx-eth", | ||
42 | .id = 0, | ||
43 | .num_resources = 0, | ||
44 | .resource = NULL, | ||
45 | .dev = { | ||
46 | .platform_data = ð0_platform_data, | ||
47 | } | ||
48 | }; | ||
49 | |||
50 | static struct netxeth_platform_data eth1_platform_data = { | ||
51 | .xcno = 1, | ||
52 | }; | ||
53 | |||
54 | static struct platform_device nxdkn_eth1_device = { | ||
55 | .name = "netx-eth", | ||
56 | .id = 1, | ||
57 | .num_resources = 0, | ||
58 | .resource = NULL, | ||
59 | .dev = { | ||
60 | .platform_data = ð1_platform_data, | ||
61 | } | ||
62 | }; | ||
63 | |||
64 | static struct resource netx_uart0_resources[] = { | ||
65 | [0] = { | ||
66 | .start = 0x00100A00, | ||
67 | .end = 0x00100A3F, | ||
68 | .flags = IORESOURCE_MEM, | ||
69 | }, | ||
70 | [1] = { | ||
71 | .start = (NETX_IRQ_UART0), | ||
72 | .end = (NETX_IRQ_UART0), | ||
73 | .flags = IORESOURCE_IRQ, | ||
74 | }, | ||
75 | }; | ||
76 | |||
77 | static struct platform_device netx_uart0_device = { | ||
78 | .name = "netx-uart", | ||
79 | .id = 0, | ||
80 | .num_resources = ARRAY_SIZE(netx_uart0_resources), | ||
81 | .resource = netx_uart0_resources, | ||
82 | }; | ||
83 | |||
84 | static struct platform_device *devices[] __initdata = { | ||
85 | &nxdkn_eth0_device, | ||
86 | &nxdkn_eth1_device, | ||
87 | &netx_uart0_device, | ||
88 | }; | ||
89 | |||
90 | static void __init nxdkn_init(void) | ||
91 | { | ||
92 | platform_add_devices(devices, ARRAY_SIZE(devices)); | ||
93 | } | ||
94 | |||
95 | MACHINE_START(NXDKN, "Hilscher nxdkn") | ||
96 | .phys_io = 0x00100000, | ||
97 | .io_pg_offst = (io_p2v(0x00100000) >> 18) & 0xfffc, | ||
98 | .boot_params = 0x80000100, | ||
99 | .map_io = netx_map_io, | ||
100 | .init_irq = netx_init_irq, | ||
101 | .timer = &netx_timer, | ||
102 | .init_machine = nxdkn_init, | ||
103 | MACHINE_END | ||
diff --git a/arch/arm/mach-netx/nxeb500hmi.c b/arch/arm/mach-netx/nxeb500hmi.c new file mode 100644 index 000000000000..53e10a9849f9 --- /dev/null +++ b/arch/arm/mach-netx/nxeb500hmi.c | |||
@@ -0,0 +1,187 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-netx/nxeb500hmi.c | ||
3 | * | ||
4 | * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/dma-mapping.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/mtd/plat-ram.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/amba/bus.h> | ||
26 | #include <linux/amba/clcd.h> | ||
27 | |||
28 | #include <asm/hardware.h> | ||
29 | #include <asm/mach-types.h> | ||
30 | #include <asm/mach/arch.h> | ||
31 | #include <asm/arch/netx-regs.h> | ||
32 | #include <asm/arch/eth.h> | ||
33 | |||
34 | #include "generic.h" | ||
35 | #include "fb.h" | ||
36 | |||
37 | static struct clcd_panel qvga = { | ||
38 | .mode = { | ||
39 | .name = "QVGA", | ||
40 | .refresh = 60, | ||
41 | .xres = 240, | ||
42 | .yres = 320, | ||
43 | .pixclock = 187617, | ||
44 | .left_margin = 6, | ||
45 | .right_margin = 26, | ||
46 | .upper_margin = 0, | ||
47 | .lower_margin = 6, | ||
48 | .hsync_len = 6, | ||
49 | .vsync_len = 1, | ||
50 | .sync = 0, | ||
51 | .vmode = FB_VMODE_NONINTERLACED, | ||
52 | }, | ||
53 | .width = -1, | ||
54 | .height = -1, | ||
55 | .tim2 = 16, | ||
56 | .cntl = CNTL_LCDTFT | CNTL_BGR, | ||
57 | .bpp = 16, | ||
58 | .grayscale = 0, | ||
59 | }; | ||
60 | |||
61 | static inline int nxeb500hmi_check(struct clcd_fb *fb, struct fb_var_screeninfo *var) | ||
62 | { | ||
63 | var->green.length = 5; | ||
64 | var->green.msb_right = 0; | ||
65 | |||
66 | return clcdfb_check(fb, var); | ||
67 | } | ||
68 | |||
69 | static int nxeb500hmi_clcd_setup(struct clcd_fb *fb) | ||
70 | { | ||
71 | unsigned int val; | ||
72 | |||
73 | fb->fb.var.green.length = 5; | ||
74 | fb->fb.var.green.msb_right = 0; | ||
75 | |||
76 | /* enable asic control */ | ||
77 | val = readl(NETX_SYSTEM_IOC_ACCESS_KEY); | ||
78 | writel(val, NETX_SYSTEM_IOC_ACCESS_KEY); | ||
79 | |||
80 | writel(3, NETX_SYSTEM_IOC_CR); | ||
81 | |||
82 | /* GPIO 14 is used for display enable on newer boards */ | ||
83 | writel(9, NETX_GPIO_CFG(14)); | ||
84 | |||
85 | val = readl(NETX_PIO_OUTPIO); | ||
86 | writel(val | 1, NETX_PIO_OUTPIO); | ||
87 | |||
88 | val = readl(NETX_PIO_OEPIO); | ||
89 | writel(val | 1, NETX_PIO_OEPIO); | ||
90 | return netx_clcd_setup(fb); | ||
91 | } | ||
92 | |||
93 | static struct clcd_board clcd_data = { | ||
94 | .name = "netX", | ||
95 | .check = nxeb500hmi_check, | ||
96 | .decode = clcdfb_decode, | ||
97 | .enable = netx_clcd_enable, | ||
98 | .setup = nxeb500hmi_clcd_setup, | ||
99 | .mmap = netx_clcd_mmap, | ||
100 | .remove = netx_clcd_remove, | ||
101 | }; | ||
102 | |||
103 | static struct netxeth_platform_data eth0_platform_data = { | ||
104 | .xcno = 0, | ||
105 | }; | ||
106 | |||
107 | static struct platform_device netx_eth0_device = { | ||
108 | .name = "netx-eth", | ||
109 | .id = 0, | ||
110 | .num_resources = 0, | ||
111 | .resource = NULL, | ||
112 | .dev = { | ||
113 | .platform_data = ð0_platform_data, | ||
114 | } | ||
115 | }; | ||
116 | |||
117 | static struct netxeth_platform_data eth1_platform_data = { | ||
118 | .xcno = 1, | ||
119 | }; | ||
120 | |||
121 | static struct platform_device netx_eth1_device = { | ||
122 | .name = "netx-eth", | ||
123 | .id = 1, | ||
124 | .num_resources = 0, | ||
125 | .resource = NULL, | ||
126 | .dev = { | ||
127 | .platform_data = ð1_platform_data, | ||
128 | } | ||
129 | }; | ||
130 | |||
131 | static struct resource netx_cf_resources[] = { | ||
132 | [0] = { | ||
133 | .start = 0x20000000, | ||
134 | .end = 0x25ffffff, | ||
135 | .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT, | ||
136 | }, | ||
137 | }; | ||
138 | |||
139 | static struct platform_device netx_cf_device = { | ||
140 | .name = "netx-cf", | ||
141 | .id = 0, | ||
142 | .resource = netx_cf_resources, | ||
143 | .num_resources = ARRAY_SIZE(netx_cf_resources), | ||
144 | }; | ||
145 | |||
146 | static struct resource netx_uart0_resources[] = { | ||
147 | [0] = { | ||
148 | .start = 0x00100A00, | ||
149 | .end = 0x00100A3F, | ||
150 | .flags = IORESOURCE_MEM, | ||
151 | }, | ||
152 | [1] = { | ||
153 | .start = (NETX_IRQ_UART0), | ||
154 | .end = (NETX_IRQ_UART0), | ||
155 | .flags = IORESOURCE_IRQ, | ||
156 | }, | ||
157 | }; | ||
158 | |||
159 | static struct platform_device netx_uart0_device = { | ||
160 | .name = "netx-uart", | ||
161 | .id = 0, | ||
162 | .num_resources = ARRAY_SIZE(netx_uart0_resources), | ||
163 | .resource = netx_uart0_resources, | ||
164 | }; | ||
165 | |||
166 | static struct platform_device *devices[] __initdata = { | ||
167 | &netx_eth0_device, | ||
168 | &netx_eth1_device, | ||
169 | &netx_cf_device, | ||
170 | &netx_uart0_device, | ||
171 | }; | ||
172 | |||
173 | static void __init nxeb500hmi_init(void) | ||
174 | { | ||
175 | netx_fb_init(&clcd_data, &qvga); | ||
176 | platform_add_devices(devices, ARRAY_SIZE(devices)); | ||
177 | } | ||
178 | |||
179 | MACHINE_START(NXEB500HMI, "Hilscher nxeb500hmi") | ||
180 | .phys_io = 0x00100000, | ||
181 | .io_pg_offst = (io_p2v(0x00100000) >> 18) & 0xfffc, | ||
182 | .boot_params = 0x80000100, | ||
183 | .map_io = netx_map_io, | ||
184 | .init_irq = netx_init_irq, | ||
185 | .timer = &netx_timer, | ||
186 | .init_machine = nxeb500hmi_init, | ||
187 | MACHINE_END | ||
diff --git a/arch/arm/mach-netx/pfifo.c b/arch/arm/mach-netx/pfifo.c new file mode 100644 index 000000000000..44dea61a9de4 --- /dev/null +++ b/arch/arm/mach-netx/pfifo.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-netx/pfifo.c | ||
3 | * | ||
4 | * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/init.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/mutex.h> | ||
23 | |||
24 | #include <asm/io.h> | ||
25 | #include <asm/hardware.h> | ||
26 | #include <asm/arch/netx-regs.h> | ||
27 | #include <asm/arch/pfifo.h> | ||
28 | |||
29 | static DEFINE_MUTEX(pfifo_lock); | ||
30 | |||
31 | static unsigned int pfifo_used = 0; | ||
32 | |||
33 | int pfifo_request(unsigned int pfifo_mask) | ||
34 | { | ||
35 | int err = 0; | ||
36 | unsigned int val; | ||
37 | |||
38 | mutex_lock(&pfifo_lock); | ||
39 | |||
40 | if (pfifo_mask & pfifo_used) { | ||
41 | err = -EBUSY; | ||
42 | goto out; | ||
43 | } | ||
44 | |||
45 | pfifo_used |= pfifo_mask; | ||
46 | |||
47 | val = readl(NETX_PFIFO_RESET); | ||
48 | writel(val | pfifo_mask, NETX_PFIFO_RESET); | ||
49 | writel(val, NETX_PFIFO_RESET); | ||
50 | |||
51 | out: | ||
52 | mutex_unlock(&pfifo_lock); | ||
53 | return err; | ||
54 | } | ||
55 | |||
56 | void pfifo_free(unsigned int pfifo_mask) | ||
57 | { | ||
58 | mutex_lock(&pfifo_lock); | ||
59 | pfifo_used &= ~pfifo_mask; | ||
60 | mutex_unlock(&pfifo_lock); | ||
61 | } | ||
62 | |||
63 | EXPORT_SYMBOL(pfifo_push); | ||
64 | EXPORT_SYMBOL(pfifo_pop); | ||
65 | EXPORT_SYMBOL(pfifo_fill_level); | ||
66 | EXPORT_SYMBOL(pfifo_empty); | ||
67 | EXPORT_SYMBOL(pfifo_request); | ||
68 | EXPORT_SYMBOL(pfifo_free); | ||
diff --git a/arch/arm/mach-netx/time.c b/arch/arm/mach-netx/time.c new file mode 100644 index 000000000000..edfbdf40c600 --- /dev/null +++ b/arch/arm/mach-netx/time.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-netx/time.c | ||
3 | * | ||
4 | * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/init.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | |||
23 | #include <asm/hardware.h> | ||
24 | #include <asm/io.h> | ||
25 | #include <asm/mach/time.h> | ||
26 | #include <asm/arch/netx-regs.h> | ||
27 | |||
28 | /* | ||
29 | * Returns number of us since last clock interrupt. Note that interrupts | ||
30 | * will have been disabled by do_gettimeoffset() | ||
31 | */ | ||
32 | static unsigned long netx_gettimeoffset(void) | ||
33 | { | ||
34 | return readl(NETX_GPIO_COUNTER_CURRENT(0)) / 100; | ||
35 | } | ||
36 | |||
37 | /* | ||
38 | * IRQ handler for the timer | ||
39 | */ | ||
40 | static irqreturn_t | ||
41 | netx_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) | ||
42 | { | ||
43 | write_seqlock(&xtime_lock); | ||
44 | |||
45 | timer_tick(regs); | ||
46 | write_sequnlock(&xtime_lock); | ||
47 | |||
48 | /* acknowledge interrupt */ | ||
49 | writel(COUNTER_BIT(0), NETX_GPIO_IRQ); | ||
50 | |||
51 | return IRQ_HANDLED; | ||
52 | } | ||
53 | |||
54 | |||
55 | static struct irqaction netx_timer_irq = { | ||
56 | .name = "NetX Timer Tick", | ||
57 | .flags = SA_INTERRUPT | SA_TIMER, | ||
58 | .handler = netx_timer_interrupt, | ||
59 | }; | ||
60 | |||
61 | /* | ||
62 | * Set up timer interrupt | ||
63 | */ | ||
64 | static void __init netx_timer_init(void) | ||
65 | { | ||
66 | /* disable timer initially */ | ||
67 | writel(0, NETX_GPIO_COUNTER_CTRL(0)); | ||
68 | |||
69 | /* Reset the timer value to zero */ | ||
70 | writel(0, NETX_GPIO_COUNTER_CURRENT(0)); | ||
71 | |||
72 | writel(LATCH, NETX_GPIO_COUNTER_MAX(0)); | ||
73 | |||
74 | /* acknowledge interrupt */ | ||
75 | writel(COUNTER_BIT(0), NETX_GPIO_IRQ); | ||
76 | |||
77 | /* Enable the interrupt in the specific timer register and start timer */ | ||
78 | writel(COUNTER_BIT(0), NETX_GPIO_IRQ_ENABLE); | ||
79 | writel(NETX_GPIO_COUNTER_CTRL_IRQ_EN | NETX_GPIO_COUNTER_CTRL_RUN, | ||
80 | NETX_GPIO_COUNTER_CTRL(0)); | ||
81 | |||
82 | setup_irq(NETX_IRQ_TIMER0, &netx_timer_irq); | ||
83 | } | ||
84 | |||
85 | struct sys_timer netx_timer = { | ||
86 | .init = netx_timer_init, | ||
87 | .offset = netx_gettimeoffset, | ||
88 | }; | ||
diff --git a/arch/arm/mach-netx/xc.c b/arch/arm/mach-netx/xc.c new file mode 100644 index 000000000000..172a058ddd66 --- /dev/null +++ b/arch/arm/mach-netx/xc.c | |||
@@ -0,0 +1,255 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-netx/xc.c | ||
3 | * | ||
4 | * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/init.h> | ||
21 | #include <linux/device.h> | ||
22 | #include <linux/firmware.h> | ||
23 | #include <linux/mutex.h> | ||
24 | |||
25 | #include <asm/io.h> | ||
26 | #include <asm/hardware.h> | ||
27 | #include <asm/arch/netx-regs.h> | ||
28 | |||
29 | #include <asm/arch/xc.h> | ||
30 | |||
31 | static DEFINE_MUTEX(xc_lock); | ||
32 | |||
33 | static int xc_in_use = 0; | ||
34 | |||
35 | struct fw_desc { | ||
36 | unsigned int ofs; | ||
37 | unsigned int size; | ||
38 | unsigned int patch_ofs; | ||
39 | unsigned int patch_entries; | ||
40 | }; | ||
41 | |||
42 | struct fw_header { | ||
43 | unsigned int magic; | ||
44 | unsigned int type; | ||
45 | unsigned int version; | ||
46 | unsigned int reserved[5]; | ||
47 | struct fw_desc fw_desc[3]; | ||
48 | } __attribute__ ((packed)); | ||
49 | |||
50 | int xc_stop(struct xc *x) | ||
51 | { | ||
52 | writel(RPU_HOLD_PC, x->xmac_base + NETX_XMAC_RPU_HOLD_PC_OFS); | ||
53 | writel(TPU_HOLD_PC, x->xmac_base + NETX_XMAC_TPU_HOLD_PC_OFS); | ||
54 | writel(XPU_HOLD_PC, x->xpec_base + NETX_XPEC_XPU_HOLD_PC_OFS); | ||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | int xc_start(struct xc *x) | ||
59 | { | ||
60 | writel(0, x->xmac_base + NETX_XMAC_RPU_HOLD_PC_OFS); | ||
61 | writel(0, x->xmac_base + NETX_XMAC_TPU_HOLD_PC_OFS); | ||
62 | writel(0, x->xpec_base + NETX_XPEC_XPU_HOLD_PC_OFS); | ||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | int xc_running(struct xc *x) | ||
67 | { | ||
68 | return (readl(x->xmac_base + NETX_XMAC_RPU_HOLD_PC_OFS) & RPU_HOLD_PC) | ||
69 | || (readl(x->xmac_base + NETX_XMAC_TPU_HOLD_PC_OFS) & TPU_HOLD_PC) | ||
70 | || (readl(x->xpec_base + NETX_XPEC_XPU_HOLD_PC_OFS) & XPU_HOLD_PC) ? | ||
71 | 0 : 1; | ||
72 | } | ||
73 | |||
74 | int xc_reset(struct xc *x) | ||
75 | { | ||
76 | writel(0, x->xpec_base + NETX_XPEC_PC_OFS); | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static int xc_check_ptr(struct xc *x, unsigned long adr, unsigned int size) | ||
81 | { | ||
82 | if (adr >= NETX_PA_XMAC(x->no) && | ||
83 | adr + size < NETX_PA_XMAC(x->no) + XMAC_MEM_SIZE) | ||
84 | return 0; | ||
85 | |||
86 | if (adr >= NETX_PA_XPEC(x->no) && | ||
87 | adr + size < NETX_PA_XPEC(x->no) + XPEC_MEM_SIZE) | ||
88 | return 0; | ||
89 | |||
90 | dev_err(x->dev, "Illegal pointer in firmware found. aborting\n"); | ||
91 | |||
92 | return -1; | ||
93 | } | ||
94 | |||
95 | static int xc_patch(struct xc *x, void *patch, int count) | ||
96 | { | ||
97 | unsigned int val, adr; | ||
98 | unsigned int *data = patch; | ||
99 | |||
100 | int i; | ||
101 | for (i = 0; i < count; i++) { | ||
102 | adr = *data++; | ||
103 | val = *data++; | ||
104 | if (xc_check_ptr(x, adr, 4) < 0) | ||
105 | return -EINVAL; | ||
106 | |||
107 | writel(val, (void __iomem *)io_p2v(adr)); | ||
108 | } | ||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | int xc_request_firmware(struct xc *x) | ||
113 | { | ||
114 | int ret; | ||
115 | char name[16]; | ||
116 | const struct firmware *fw; | ||
117 | struct fw_header *head; | ||
118 | unsigned int size; | ||
119 | int i; | ||
120 | void *src; | ||
121 | unsigned long dst; | ||
122 | |||
123 | sprintf(name, "xc%d.bin", x->no); | ||
124 | |||
125 | ret = request_firmware(&fw, name, x->dev); | ||
126 | |||
127 | if (ret < 0) { | ||
128 | dev_err(x->dev, "request_firmware failed\n"); | ||
129 | return ret; | ||
130 | } | ||
131 | |||
132 | head = (struct fw_header *)fw->data; | ||
133 | if (head->magic != 0x4e657458) { | ||
134 | if (head->magic == 0x5874654e) { | ||
135 | dev_err(x->dev, | ||
136 | "firmware magic is 'XteN'. Endianess problems?\n"); | ||
137 | ret = -ENODEV; | ||
138 | goto exit_release_firmware; | ||
139 | } | ||
140 | dev_err(x->dev, "unrecognized firmware magic 0x%08x\n", | ||
141 | head->magic); | ||
142 | ret = -ENODEV; | ||
143 | goto exit_release_firmware; | ||
144 | } | ||
145 | |||
146 | x->type = head->type; | ||
147 | x->version = head->version; | ||
148 | |||
149 | ret = -EINVAL; | ||
150 | |||
151 | for (i = 0; i < 3; i++) { | ||
152 | src = fw->data + head->fw_desc[i].ofs; | ||
153 | dst = *(unsigned int *)src; | ||
154 | src += sizeof (unsigned int); | ||
155 | size = head->fw_desc[i].size - sizeof (unsigned int); | ||
156 | |||
157 | if (xc_check_ptr(x, dst, size)) | ||
158 | goto exit_release_firmware; | ||
159 | |||
160 | memcpy((void *)io_p2v(dst), src, size); | ||
161 | |||
162 | src = fw->data + head->fw_desc[i].patch_ofs; | ||
163 | size = head->fw_desc[i].patch_entries; | ||
164 | ret = xc_patch(x, src, size); | ||
165 | if (ret < 0) | ||
166 | goto exit_release_firmware; | ||
167 | } | ||
168 | |||
169 | ret = 0; | ||
170 | |||
171 | exit_release_firmware: | ||
172 | release_firmware(fw); | ||
173 | |||
174 | return ret; | ||
175 | } | ||
176 | |||
177 | struct xc *request_xc(int xcno, struct device *dev) | ||
178 | { | ||
179 | struct xc *x = NULL; | ||
180 | |||
181 | mutex_lock(&xc_lock); | ||
182 | |||
183 | if (xcno > 3) | ||
184 | goto exit; | ||
185 | if (xc_in_use & (1 << xcno)) | ||
186 | goto exit; | ||
187 | |||
188 | x = kmalloc(sizeof (struct xc), GFP_KERNEL); | ||
189 | if (!x) | ||
190 | goto exit; | ||
191 | |||
192 | if (!request_mem_region | ||
193 | (NETX_PA_XPEC(xcno), XPEC_MEM_SIZE, dev->kobj.name)) | ||
194 | goto exit_free; | ||
195 | |||
196 | if (!request_mem_region | ||
197 | (NETX_PA_XMAC(xcno), XMAC_MEM_SIZE, dev->kobj.name)) | ||
198 | goto exit_release_1; | ||
199 | |||
200 | if (!request_mem_region | ||
201 | (SRAM_INTERNAL_PHYS(xcno), SRAM_MEM_SIZE, dev->kobj.name)) | ||
202 | goto exit_release_2; | ||
203 | |||
204 | x->xpec_base = (void * __iomem)io_p2v(NETX_PA_XPEC(xcno)); | ||
205 | x->xmac_base = (void * __iomem)io_p2v(NETX_PA_XMAC(xcno)); | ||
206 | x->sram_base = ioremap(SRAM_INTERNAL_PHYS(xcno), SRAM_MEM_SIZE); | ||
207 | if (!x->sram_base) | ||
208 | goto exit_release_3; | ||
209 | |||
210 | x->irq = NETX_IRQ_XPEC(xcno); | ||
211 | |||
212 | x->no = xcno; | ||
213 | x->dev = dev; | ||
214 | |||
215 | xc_in_use |= (1 << xcno); | ||
216 | |||
217 | goto exit; | ||
218 | |||
219 | exit_release_3: | ||
220 | release_mem_region(SRAM_INTERNAL_PHYS(xcno), SRAM_MEM_SIZE); | ||
221 | exit_release_2: | ||
222 | release_mem_region(NETX_PA_XMAC(xcno), XMAC_MEM_SIZE); | ||
223 | exit_release_1: | ||
224 | release_mem_region(NETX_PA_XPEC(xcno), XPEC_MEM_SIZE); | ||
225 | exit_free: | ||
226 | kfree(x); | ||
227 | x = NULL; | ||
228 | exit: | ||
229 | mutex_unlock(&xc_lock); | ||
230 | return x; | ||
231 | } | ||
232 | |||
233 | void free_xc(struct xc *x) | ||
234 | { | ||
235 | int xcno = x->no; | ||
236 | |||
237 | mutex_lock(&xc_lock); | ||
238 | |||
239 | iounmap(x->sram_base); | ||
240 | release_mem_region(SRAM_INTERNAL_PHYS(xcno), SRAM_MEM_SIZE); | ||
241 | release_mem_region(NETX_PA_XMAC(xcno), XMAC_MEM_SIZE); | ||
242 | release_mem_region(NETX_PA_XPEC(xcno), XPEC_MEM_SIZE); | ||
243 | xc_in_use &= ~(1 << x->no); | ||
244 | kfree(x); | ||
245 | |||
246 | mutex_unlock(&xc_lock); | ||
247 | } | ||
248 | |||
249 | EXPORT_SYMBOL(free_xc); | ||
250 | EXPORT_SYMBOL(request_xc); | ||
251 | EXPORT_SYMBOL(xc_request_firmware); | ||
252 | EXPORT_SYMBOL(xc_reset); | ||
253 | EXPORT_SYMBOL(xc_running); | ||
254 | EXPORT_SYMBOL(xc_start); | ||
255 | EXPORT_SYMBOL(xc_stop); | ||