Add image generation for edimax routers
[openwrt.git] / target / linux / magicbox-2.6 / patches / 001-magicbox_support.patch
1 diff -urN linux.old/arch/ppc/platforms/4xx/Kconfig linux.dev/arch/ppc/platforms/4xx/Kconfig
2 --- linux.old/arch/ppc/platforms/4xx/Kconfig 2006-11-29 22:57:37.000000000 +0100
3 +++ linux.dev/arch/ppc/platforms/4xx/Kconfig 2006-12-14 08:49:18.000000000 +0100
4 @@ -52,6 +52,12 @@
5 help
6 This option enables support for the IBM PPC405GP evaluation board.
7
8 +config MAGICBOX
9 + bool "MagicBox"
10 + select WANT_EARLY_SERIAL
11 + help
12 + This option enables support for the IBM PPC405EP evaluation board.
13 +
14 config XILINX_ML300
15 bool "Xilinx-ML300"
16 help
17 @@ -173,7 +179,7 @@
18
19 config IBM_OCP
20 bool
21 - depends on ASH || BAMBOO || BUBINGA || CPCI405 || EBONY || EP405 || LUAN || YUCCA || OCOTEA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT
22 + depends on ASH || BAMBOO || BUBINGA || CPCI405 || EBONY || EP405 || LUAN || YUCCA || OCOTEA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT || MAGICBOX
23 default y
24
25 config IBM_EMAC4
26 @@ -183,7 +189,7 @@
27
28 config BIOS_FIXUP
29 bool
30 - depends on BUBINGA || EP405 || SYCAMORE || WALNUT || CPCI405
31 + depends on BUBINGA || EP405 || SYCAMORE || WALNUT || CPCI405 || MAGICBOX
32 default y
33
34 # OAK doesn't exist but wanted to keep this around for any future 403GCX boards
35 @@ -194,7 +200,7 @@
36
37 config 405EP
38 bool
39 - depends on BUBINGA
40 + depends on BUBINGA || MAGICBOX
41 default y
42
43 config 405GP
44 diff -urN linux.old/arch/ppc/platforms/4xx/magicbox.c linux.dev/arch/ppc/platforms/4xx/magicbox.c
45 --- linux.old/arch/ppc/platforms/4xx/magicbox.c 1970-01-01 01:00:00.000000000 +0100
46 +++ linux.dev/arch/ppc/platforms/4xx/magicbox.c 2006-12-14 08:48:56.000000000 +0100
47 @@ -0,0 +1,249 @@
48 +/*
49 + * Support for IBM PPC 405EP-based MagicBox board
50 + * Copyright (C) 2006 Karol Lewandowski
51 + *
52 + * Heavily based on bubinga.c
53 + *
54 + * Author: SAW (IBM), derived from walnut.c.
55 + * Maintained by MontaVista Software <source@mvista.com>
56 + *
57 + * 2003 (c) MontaVista Softare Inc. This file is licensed under the
58 + * terms of the GNU General Public License version 2. This program is
59 + * licensed "as is" without any warranty of any kind, whether express
60 + * or implied.
61 + */
62 +
63 +#include <linux/autoconf.h>
64 +#include <linux/init.h>
65 +#include <linux/smp.h>
66 +#include <linux/threads.h>
67 +#include <linux/param.h>
68 +#include <linux/string.h>
69 +#include <linux/blkdev.h>
70 +#include <linux/pci.h>
71 +#include <linux/tty.h>
72 +#include <linux/serial.h>
73 +#include <linux/serial_core.h>
74 +
75 +#include <asm/system.h>
76 +#include <asm/pci-bridge.h>
77 +#include <asm/processor.h>
78 +#include <asm/machdep.h>
79 +#include <asm/page.h>
80 +#include <asm/time.h>
81 +#include <asm/io.h>
82 +#include <asm/kgdb.h>
83 +#include <asm/ocp.h>
84 +#include <asm/ibm_ocp_pci.h>
85 +
86 +#include <platforms/4xx/ibm405ep.h>
87 +
88 +#undef DEBUG
89 +
90 +#ifdef DEBUG
91 +#define DBG(x...) printk(x)
92 +#else
93 +#define DBG(x...)
94 +#endif
95 +
96 +extern bd_t __res;
97 +
98 +/* Some IRQs unique to board
99 + * Used by the generic 405 PCI setup functions in ppc4xx_pci.c
100 + */
101 +int __init
102 +ppc405_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
103 +{
104 + static char pci_irq_table[][4] =
105 + /*
106 + * PCI IDSEL/INTPIN->INTLINE
107 + * A B C D
108 + */
109 + {
110 + {28, 28, 28, 28}, /* IDSEL 1 - PCI slot 1 */
111 + {29, 29, 29, 29}, /* IDSEL 2 - PCI slot 2 */
112 + {30, 30, 30, 30}, /* IDSEL 3 - PCI slot 3 */
113 + {31, 31, 31, 31}, /* IDSEL 4 - PCI slot 4 */
114 + };
115 +
116 + const long min_idsel = 1, max_idsel = 4, irqs_per_slot = 4;
117 + return PCI_IRQ_TABLE_LOOKUP;
118 +};
119 +
120 +
121 +/* The serial clock for the chip is an internal clock determined by
122 + * different clock speeds/dividers.
123 + * Calculate the proper input baud rate and setup the serial driver.
124 + */
125 +static void __init
126 +magicbox_early_serial_map(void)
127 +{
128 + u32 uart_div;
129 + int uart_clock;
130 + struct uart_port port;
131 +
132 + /* Calculate the serial clock input frequency
133 + *
134 + * The base baud is the PLL OUTA (provided in the board info
135 + * structure) divided by the external UART Divisor, divided
136 + * by 16.
137 + */
138 + uart_div = (mfdcr(DCRN_CPC0_UCR_BASE) & DCRN_CPC0_UCR_U0DIV);
139 + uart_clock = __res.bi_procfreq / uart_div;
140 +
141 + /* Setup serial port access */
142 + memset(&port, 0, sizeof(port));
143 + port.membase = (void*)ACTING_UART0_IO_BASE;
144 + port.irq = ACTING_UART0_INT;
145 + port.uartclk = uart_clock;
146 + port.regshift = 0;
147 + port.iotype = SERIAL_IO_MEM;
148 + port.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
149 + port.line = 0;
150 +
151 + if (early_serial_setup(&port) != 0) {
152 + printk("Early serial init of port 0 failed\n");
153 + }
154 +
155 + port.membase = (void*)ACTING_UART1_IO_BASE;
156 + port.irq = ACTING_UART1_INT;
157 + port.line = 1;
158 +
159 + if (early_serial_setup(&port) != 0) {
160 + printk("Early serial init of port 1 failed\n");
161 + }
162 +}
163 +
164 +void __init
165 +bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
166 +{
167 + unsigned int bar_response, bar;
168 + /*
169 + * Expected PCI mapping:
170 + *
171 + * PLB addr PCI memory addr
172 + * --------------------- ---------------------
173 + * 0000'0000 - 7fff'ffff <--- 0000'0000 - 7fff'ffff
174 + * 8000'0000 - Bfff'ffff ---> 8000'0000 - Bfff'ffff
175 + *
176 + * PLB addr PCI io addr
177 + * --------------------- ---------------------
178 + * e800'0000 - e800'ffff ---> 0000'0000 - 0001'0000
179 + *
180 + * The following code is simplified by assuming that the bootrom
181 + * has been well behaved in following this mapping.
182 + */
183 +
184 +#ifdef DEBUG
185 + int i;
186 +
187 + printk("ioremap PCLIO_BASE = 0x%x\n", pcip);
188 + printk("PCI bridge regs before fixup \n");
189 + for (i = 0; i <= 3; i++) {
190 + printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].ma)));
191 + printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].la)));
192 + printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pcila)));
193 + printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pciha)));
194 + }
195 + printk(" ptm1ms\t0x%x\n", in_le32(&(pcip->ptm1ms)));
196 + printk(" ptm1la\t0x%x\n", in_le32(&(pcip->ptm1la)));
197 + printk(" ptm2ms\t0x%x\n", in_le32(&(pcip->ptm2ms)));
198 + printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la)));
199 +
200 +#endif
201 +
202 + /* added for IBM boot rom version 1.15 bios bar changes -AK */
203 +
204 + /* Disable region first */
205 + out_le32((void *) &(pcip->pmm[0].ma), 0x00000000);
206 + /* PLB starting addr, PCI: 0x80000000 */
207 + out_le32((void *) &(pcip->pmm[0].la), 0x80000000);
208 + /* PCI start addr, 0x80000000 */
209 + out_le32((void *) &(pcip->pmm[0].pcila), PPC405_PCI_MEM_BASE);
210 + /* 512MB range of PLB to PCI */
211 + out_le32((void *) &(pcip->pmm[0].pciha), 0x00000000);
212 + /* Enable no pre-fetch, enable region */
213 + out_le32((void *) &(pcip->pmm[0].ma), ((0xffffffff -
214 + (PPC405_PCI_UPPER_MEM -
215 + PPC405_PCI_MEM_BASE)) | 0x01));
216 +
217 + /* Disable region one */
218 + out_le32((void *) &(pcip->pmm[1].ma), 0x00000000);
219 + out_le32((void *) &(pcip->pmm[1].la), 0x00000000);
220 + out_le32((void *) &(pcip->pmm[1].pcila), 0x00000000);
221 + out_le32((void *) &(pcip->pmm[1].pciha), 0x00000000);
222 + out_le32((void *) &(pcip->pmm[1].ma), 0x00000000);
223 + out_le32((void *) &(pcip->ptm1ms), 0x00000001);
224 +
225 + /* Disable region two */
226 + out_le32((void *) &(pcip->pmm[2].ma), 0x00000000);
227 + out_le32((void *) &(pcip->pmm[2].la), 0x00000000);
228 + out_le32((void *) &(pcip->pmm[2].pcila), 0x00000000);
229 + out_le32((void *) &(pcip->pmm[2].pciha), 0x00000000);
230 + out_le32((void *) &(pcip->pmm[2].ma), 0x00000000);
231 + out_le32((void *) &(pcip->ptm2ms), 0x00000000);
232 + out_le32((void *) &(pcip->ptm2la), 0x00000000);
233 +
234 + /* Zero config bars */
235 + for (bar = PCI_BASE_ADDRESS_1; bar <= PCI_BASE_ADDRESS_2; bar += 4) {
236 + early_write_config_dword(hose, hose->first_busno,
237 + PCI_FUNC(hose->first_busno), bar,
238 + 0x00000000);
239 + early_read_config_dword(hose, hose->first_busno,
240 + PCI_FUNC(hose->first_busno), bar,
241 + &bar_response);
242 + DBG("BUS %d, device %d, Function %d bar 0x%8.8x is 0x%8.8x\n",
243 + hose->first_busno, PCI_SLOT(hose->first_busno),
244 + PCI_FUNC(hose->first_busno), bar, bar_response);
245 + }
246 + /* end work arround */
247 +
248 +#ifdef DEBUG
249 + printk("PCI bridge regs after fixup \n");
250 + for (i = 0; i <= 3; i++) {
251 + printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].ma)));
252 + printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].la)));
253 + printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pcila)));
254 + printk(" pmm%dma\t0x%x\n", i, in_le32(&(pcip->pmm[i].pciha)));
255 + }
256 + printk(" ptm1ms\t0x%x\n", in_le32(&(pcip->ptm1ms)));
257 + printk(" ptm1la\t0x%x\n", in_le32(&(pcip->ptm1la)));
258 + printk(" ptm2ms\t0x%x\n", in_le32(&(pcip->ptm2ms)));
259 + printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la)));
260 +
261 +#endif /* DEBUG */
262 +}
263 +
264 +void __init
265 +magicbox_setup_arch(void)
266 +{
267 + ppc4xx_setup_arch();
268 +
269 + ibm_ocp_set_emac(0, 1);
270 +
271 + magicbox_early_serial_map();
272 +
273 + /* Identify the system */
274 + printk("MagicBox port (C) 2005 Karol Lewandowski <kl@jasmine.eu.org>\n");
275 +}
276 +
277 +void __init
278 +magicbox_map_io(void)
279 +{
280 + ppc4xx_map_io();
281 +}
282 +
283 +void __init
284 +platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
285 + unsigned long r6, unsigned long r7)
286 +{
287 + ppc4xx_init(r3, r4, r5, r6, r7);
288 +
289 + ppc_md.setup_arch = magicbox_setup_arch;
290 + ppc_md.setup_io_mappings = magicbox_map_io;
291 +
292 +#ifdef CONFIG_KGDB
293 + ppc_md.early_serial_map = bubinga_early_serial_map;
294 +#endif
295 +
296 +}
297 diff -urN linux.old/arch/ppc/platforms/4xx/magicbox.h linux.dev/arch/ppc/platforms/4xx/magicbox.h
298 --- linux.old/arch/ppc/platforms/4xx/magicbox.h 1970-01-01 01:00:00.000000000 +0100
299 +++ linux.dev/arch/ppc/platforms/4xx/magicbox.h 2006-12-14 08:48:56.000000000 +0100
300 @@ -0,0 +1,47 @@
301 +/*
302 + * Support for IBM PPC 405EP-based MagicBox board
303 + *
304 + * Heavily based on bubinga.h
305 + *
306 + *
307 + * Author: SAW (IBM), derived from walnut.h.
308 + * Maintained by MontaVista Software <source@mvista.com>
309 + *
310 + * 2003 (c) MontaVista Softare Inc. This file is licensed under the
311 + * terms of the GNU General Public License version 2. This program is
312 + * licensed "as is" without any warranty of any kind, whether express
313 + * or implied.
314 + */
315 +
316 +#ifdef __KERNEL__
317 +#ifndef __MAGICBOX_H__
318 +#define __MAGICBOX_H__
319 +
320 +#include <linux/autoconf.h>
321 +#include <platforms/4xx/ibm405ep.h>
322 +#include <asm/ppcboot.h>
323 +
324 +/* Memory map for the "MagicBox" 405EP evaluation board -- generic 4xx. */
325 +
326 +/* The UART clock is based off an internal clock -
327 + * define BASE_BAUD based on the internal clock and divider(s).
328 + * Since BASE_BAUD must be a constant, we will initialize it
329 + * using clock/divider values which OpenBIOS initializes
330 + * for typical configurations at various CPU speeds.
331 + * The base baud is calculated as (FWDA / EXT UART DIV / 16)
332 + */
333 +#define BASE_BAUD 0
334 +
335 +/* Flash */
336 +#define PPC40x_FPGA_BASE 0xF0300000
337 +#define PPC40x_FPGA_REG_OFFS 1 /* offset to flash map reg */
338 +#define PPC40x_FLASH_ONBD_N(x) (x & 0x02)
339 +#define PPC40x_FLASH_SRAM_SEL(x) (x & 0x01)
340 +#define PPC40x_FLASH_LOW 0xFFF00000
341 +#define PPC40x_FLASH_HIGH 0xFFF80000
342 +#define PPC40x_FLASH_SIZE 0x80000
343 +
344 +#define PPC4xx_MACHINE_NAME "MagicBox"
345 +
346 +#endif /* __MAGICBOX_H__ */
347 +#endif /* __KERNEL__ */
348 diff -urN linux.old/arch/ppc/platforms/4xx/Makefile linux.dev/arch/ppc/platforms/4xx/Makefile
349 --- linux.old/arch/ppc/platforms/4xx/Makefile 2006-11-29 22:57:37.000000000 +0100
350 +++ linux.dev/arch/ppc/platforms/4xx/Makefile 2006-12-14 08:48:56.000000000 +0100
351 @@ -13,6 +13,7 @@
352 obj-$(CONFIG_REDWOOD_6) += redwood6.o
353 obj-$(CONFIG_SYCAMORE) += sycamore.o
354 obj-$(CONFIG_WALNUT) += walnut.o
355 +obj-$(CONFIG_MAGICBOX) += magicbox.o
356 obj-$(CONFIG_XILINX_ML300) += xilinx_ml300.o
357 obj-$(CONFIG_XILINX_ML403) += xilinx_ml403.o
358
359 diff -urN linux.old/include/asm-ppc/ibm4xx.h linux.dev/include/asm-ppc/ibm4xx.h
360 --- linux.old/include/asm-ppc/ibm4xx.h 2006-11-29 22:57:37.000000000 +0100
361 +++ linux.dev/include/asm-ppc/ibm4xx.h 2006-12-14 08:48:56.000000000 +0100
362 @@ -18,6 +18,10 @@
363
364 #ifdef CONFIG_40x
365
366 +#if defined(CONFIG_MAGICBOX)
367 +#include <platforms/4xx/magicbox.h>
368 +#endif
369 +
370 #if defined(CONFIG_BUBINGA)
371 #include <platforms/4xx/bubinga.h>
372 #endif
This page took 0.054282 seconds and 5 git commands to generate.