Fixes the MAC address handling on avila NPE on startup
[openwrt.git] / target / linux / ixp4xx / patches-2.6.23 / 150-lanready_ap1000_support.patch
1 diff -Nur linux-2.6.23.1/arch/arm/mach-ixp4xx/ap1000-setup.c linux-2.6.23.1-owrt/arch/arm/mach-ixp4xx/ap1000-setup.c
2 --- linux-2.6.23.1/arch/arm/mach-ixp4xx/ap1000-setup.c  1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.23.1-owrt/arch/arm/mach-ixp4xx/ap1000-setup.c     2007-11-14 13:58:58.000000000 +0100
4 @@ -0,0 +1,151 @@
5 +/*
6 + * arch/arm/mach-ixp4xx/ap1000-setup.c
7 + *
8 + * Lanready AP-1000
9 + *
10 + * Copyright (C) 2007 Imre Kaloz <Kaloz@openwrt.org>
11 + *
12 + * based on ixdp425-setup.c:
13 + *     Copyright (C) 2003-2005 MontaVista Software, Inc.
14 + *
15 + * Author: Imre Kaloz <Kaloz@openwrt.org>
16 + */
17 +
18 +#include <linux/kernel.h>
19 +#include <linux/init.h>
20 +#include <linux/device.h>
21 +#include <linux/serial.h>
22 +#include <linux/tty.h>
23 +#include <linux/serial_8250.h>
24 +#include <linux/slab.h>
25 +
26 +#include <asm/types.h>
27 +#include <asm/setup.h>
28 +#include <asm/memory.h>
29 +#include <asm/hardware.h>
30 +#include <asm/mach-types.h>
31 +#include <asm/irq.h>
32 +#include <asm/mach/arch.h>
33 +#include <asm/mach/flash.h>
34 +
35 +static struct flash_platform_data ap1000_flash_data = {
36 +       .map_name       = "cfi_probe",
37 +       .width          = 2,
38 +};
39 +
40 +static struct resource ap1000_flash_resource = {
41 +       .flags          = IORESOURCE_MEM,
42 +};
43 +
44 +static struct platform_device ap1000_flash = {
45 +       .name           = "IXP4XX-Flash",
46 +       .id             = 0,
47 +       .dev            = {
48 +               .platform_data = &ap1000_flash_data,
49 +       },
50 +       .num_resources  = 1,
51 +       .resource       = &ap1000_flash_resource,
52 +};
53 +
54 +static struct resource ap1000_uart_resources[] = {
55 +       {
56 +               .start          = IXP4XX_UART1_BASE_PHYS,
57 +               .end            = IXP4XX_UART1_BASE_PHYS + 0x0fff,
58 +               .flags          = IORESOURCE_MEM
59 +       },
60 +       {
61 +               .start          = IXP4XX_UART2_BASE_PHYS,
62 +               .end            = IXP4XX_UART2_BASE_PHYS + 0x0fff,
63 +               .flags          = IORESOURCE_MEM
64 +       }
65 +};
66 +
67 +static struct plat_serial8250_port ap1000_uart_data[] = {
68 +       {
69 +               .mapbase        = IXP4XX_UART1_BASE_PHYS,
70 +               .membase        = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
71 +               .irq            = IRQ_IXP4XX_UART1,
72 +               .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
73 +               .iotype         = UPIO_MEM,
74 +               .regshift       = 2,
75 +               .uartclk        = IXP4XX_UART_XTAL,
76 +       },
77 +       {
78 +               .mapbase        = IXP4XX_UART2_BASE_PHYS,
79 +               .membase        = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
80 +               .irq            = IRQ_IXP4XX_UART2,
81 +               .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
82 +               .iotype         = UPIO_MEM,
83 +               .regshift       = 2,
84 +               .uartclk        = IXP4XX_UART_XTAL,
85 +       },
86 +       { },
87 +};
88 +
89 +static struct platform_device ap1000_uart = {
90 +       .name                   = "serial8250",
91 +       .id                     = PLAT8250_DEV_PLATFORM,
92 +       .dev.platform_data      = ap1000_uart_data,
93 +       .num_resources          = 2,
94 +       .resource               = ap1000_uart_resources
95 +};
96 +
97 +static struct platform_device *ap1000_devices[] __initdata = {
98 +       &ap1000_flash,
99 +       &ap1000_uart
100 +};
101 +
102 +static char ap1000_mem_fixup[] __initdata = "mem=64M ";
103 +
104 +static void __init ap1000_fixup(struct machine_desc *desc,
105 +               struct tag *tags, char **cmdline, struct meminfo *mi)
106 +
107 +{
108 +       struct tag *t = tags;
109 +       char *p = *cmdline;
110 +
111 +       /* Find the end of the tags table, taking note of any cmdline tag. */
112 +       for (; t->hdr.size; t = tag_next(t)) {
113 +               if (t->hdr.tag == ATAG_CMDLINE) {
114 +                       p = t->u.cmdline.cmdline;
115 +               }
116 +       }
117 +
118 +       /* Overwrite the end of the table with a new cmdline tag. */
119 +       t->hdr.tag = ATAG_CMDLINE;
120 +       t->hdr.size = (sizeof (struct tag_header) +
121 +               strlen(ap1000_mem_fixup) + strlen(p) + 1 + 4) >> 2;
122 +       strlcpy(t->u.cmdline.cmdline, ap1000_mem_fixup, COMMAND_LINE_SIZE);
123 +       strlcpy(t->u.cmdline.cmdline + strlen(ap1000_mem_fixup), p,
124 +               COMMAND_LINE_SIZE - strlen(ap1000_mem_fixup));
125 +
126 +       /* Terminate the table. */
127 +       t = tag_next(t);
128 +       t->hdr.tag = ATAG_NONE;
129 +       t->hdr.size = 0;
130 +}
131 +
132 +static void __init ap1000_init(void)
133 +{
134 +       ixp4xx_sys_init();
135 +
136 +       ap1000_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
137 +       ap1000_flash_resource.end =
138 +               IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
139 +
140 +       platform_add_devices(ap1000_devices, ARRAY_SIZE(ap1000_devices));
141 +}
142 +
143 +#ifdef CONFIG_MACH_AP1000
144 +MACHINE_START(AP1000, "Lanready AP-1000")
145 +       /* Maintainer: Imre Kaloz <Kaloz@openwrt.org> */
146 +       .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
147 +       .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
148 +       .fixup          = ap1000_fixup,
149 +       .map_io         = ixp4xx_map_io,
150 +       .init_irq       = ixp4xx_init_irq,
151 +       .timer          = &ixp4xx_timer,
152 +       .boot_params    = 0x0100,
153 +       .init_machine   = ap1000_init,
154 +MACHINE_END
155 +#endif
156 diff -Nur linux-2.6.23.1/arch/arm/mach-ixp4xx/ixdp425-pci.c linux-2.6.23.1-owrt/arch/arm/mach-ixp4xx/ixdp425-pci.c
157 --- linux-2.6.23.1/arch/arm/mach-ixp4xx/ixdp425-pci.c   2007-11-14 13:15:50.000000000 +0100
158 +++ linux-2.6.23.1-owrt/arch/arm/mach-ixp4xx/ixdp425-pci.c      2007-11-14 13:27:16.000000000 +0100
159 @@ -66,7 +66,8 @@
160  int __init ixdp425_pci_init(void)
161  {
162         if (machine_is_ixdp425() || machine_is_ixcdp1100() ||
163 -                       machine_is_ixdp465() || machine_is_kixrp435() || machine_is_compex())
164 +                       machine_is_ixdp465() || machine_is_kixrp435() ||
165 +                       machine_is_compex() || machine_is_ap1000())
166                 pci_common_init(&ixdp425_pci);
167         return 0;
168  }
169 diff -Nur linux-2.6.23.1/arch/arm/mach-ixp4xx/Kconfig linux-2.6.23.1-owrt/arch/arm/mach-ixp4xx/Kconfig
170 --- linux-2.6.23.1/arch/arm/mach-ixp4xx/Kconfig 2007-11-14 13:15:50.000000000 +0100
171 +++ linux-2.6.23.1-owrt/arch/arm/mach-ixp4xx/Kconfig    2007-11-14 13:25:07.000000000 +0100
172 @@ -89,6 +89,14 @@
173           WRT300N v2 router. For more information on this
174           platform, see http://openwrt.org
175  
176 +config MACH_AP1000
177 +       bool "Lanready AP-1000"
178 +       select PCI
179 +       help
180 +         Say 'Y' here if you want your kernel to support Lanready's
181 +         AP1000 board. For more information on this
182 +         platform, see http://openwrt.org
183 +
184  config ARCH_IXDP425
185         bool "IXDP425"
186         help
187 diff -Nur linux-2.6.23.1/arch/arm/mach-ixp4xx/Makefile linux-2.6.23.1-owrt/arch/arm/mach-ixp4xx/Makefile
188 --- linux-2.6.23.1/arch/arm/mach-ixp4xx/Makefile        2007-11-14 13:15:50.000000000 +0100
189 +++ linux-2.6.23.1-owrt/arch/arm/mach-ixp4xx/Makefile   2007-11-14 13:31:29.000000000 +0100
190 @@ -20,6 +20,7 @@
191  obj-pci-$(CONFIG_MACH_COMPEX)          += ixdp425-pci.o
192  obj-pci-$(CONFIG_MACH_WRT300NV2)               += wrt300nv2-pci.o
193  obj-pci-$(CONFIG_MACH_SIDEWINDER)              += sidewinder-pci.o
194 +obj-pci-$(CONFIG_MACH_AP1000)          += ixdp425-pci.o
195  
196  obj-y  += common.o
197  
198 @@ -38,5 +39,6 @@
199  obj-$(CONFIG_MACH_COMPEX)      += compex-setup.o
200  obj-$(CONFIG_MACH_WRT300NV2)   += wrt300nv2-setup.o
201  obj-$(CONFIG_MACH_SIDEWINDER)  += sidewinder-setup.o
202 +obj-$(CONFIG_MACH_AP1000)      += ap1000-setup.o
203  
204  obj-$(CONFIG_PCI)              += $(obj-pci-$(CONFIG_PCI)) common-pci.o
205 diff -Nur linux-2.6.23.1/arch/arm/tools/mach-types linux-2.6.23.1-owrt/arch/arm/tools/mach-types
206 --- linux-2.6.23.1/arch/arm/tools/mach-types    2007-11-14 13:15:50.000000000 +0100
207 +++ linux-2.6.23.1-owrt/arch/arm/tools/mach-types       2007-11-14 13:26:06.000000000 +0100
208 @@ -1367,3 +1367,4 @@
209  csb726                 MACH_CSB726             CSB726                  1359
210  tik27                  MACH_TIK27              TIK27                   1360
211  mx_uc7420              MACH_MX_UC7420          MX_UC7420               1361
212 +ap1000                 MACH_AP1000             AP1000                  1543