[lantiq] fixes zyxel p2601hnfx
[openwrt.git] / target / linux / lantiq / patches-3.3 / 206-machtypes.patch
1 --- a/arch/mips/lantiq/machtypes.h
2 +++ b/arch/mips/lantiq/machtypes.h
3 @@ -20,6 +20,42 @@ enum lantiq_mach_type {
4         LANTIQ_MACH_EASY98000,          /* Falcon Eval Board, NOR Flash */
5         LANTIQ_MACH_EASY98000SF,        /* Falcon Eval Board, Serial Flash */
6         LANTIQ_MACH_EASY98000NAND,      /* Falcon Eval Board, NAND Flash */
7 +       LANTIQ_MACH_EASY98020,          /* EASY98020 Eval Board */
8 +       LANTIQ_MACH_EASY98020_1LAN,     /* EASY98020 Eval Board (1 LAN port) */
9 +       LANTIQ_MACH_EASY98020_2LAN,     /* EASY98020 Eval Board (2 LAN port) */
10 +       LANTIQ_MACH_95C3AM1,            /* 95C3AM1 Eval Board */
11 +
12 +       /* Arcadyan */
13 +       LANTIQ_MACH_ARV3527P,           /* Arcor easybox a401 */
14 +       LANTIQ_MACH_ARV4510PW,          /* Wippies Homebox */
15 +       LANTIQ_MACH_ARV4518PW,          /* Airties WAV-221, SMC-7908A-ISP */
16 +       LANTIQ_MACH_ARV4519PW,          /* Vodafone, Pirelli */
17 +       LANTIQ_MACH_ARV4520PW,          /* Airties WAV-281, Arcor EasyboxA800 */
18 +       LANTIQ_MACH_ARV452CPW,          /* Arcor EasyboxA801 */
19 +       LANTIQ_MACH_ARV4525PW,          /* Speedport W502V */
20 +       LANTIQ_MACH_ARV7525PW,          /* Speedport W303V */
21 +       LANTIQ_MACH_ARV752DPW,          /* Arcor easybox a802 */
22 +       LANTIQ_MACH_ARV752DPW22,        /* Arcor easybox a803 */
23 +       LANTIQ_MACH_ARV7518PW,          /* ASTORIA */
24 +
25 +       /* Netgear */
26 +       LANTIQ_MACH_DGN3500B,           /* Netgear DGN3500 */
27 +
28 +       /* FRITZ!BOX */
29 +       LANTIQ_MACH_FRITZ3370,          /* FRITZ!BOX 3370 vdsl cpe */
30 +       LANTIQ_MACH_FRITZ7320,          /* FRITZ!BOX 7320 1&1 homeserver */
31 +
32 +       /* Gigaset */
33 +       LANTIQ_MACH_GIGASX76X,          /* Gigaset SX76x */
34 +
35 +       /* Buffalo */
36 +       LANTIQ_MACH_WBMR,               /* WBMR-HP-G300H */
37 +
38 +       /* ZyXEL */
39 +       LANTIQ_MACH_P2601HNFX,          /* ZyXEL P-2601HN-Fx */
40 +
41 +       /* ZTE */
42 +       LANTIQ_MACH_H201L,              /* ZTE ZXV10 H201L */
43  };
44  
45  #endif
46 --- a/arch/mips/lantiq/xway/Kconfig
47 +++ b/arch/mips/lantiq/xway/Kconfig
48 @@ -6,6 +6,38 @@ config LANTIQ_MACH_EASY50712
49         bool "Easy50712 - Danube"
50         default y
51  
52 +config LANTIQ_MACH_ARV
53 +       bool "ARV"
54 +       default y
55 +
56 +config LANTIQ_MACH_NETGEAR
57 +       bool "Netgear"
58 +       default y
59 +
60 +config LANTIQ_MACH_GIGASX76X
61 +       bool "GIGASX76X"
62 +       default y
63 +
64 +config LANTIQ_MACH_WBMR
65 +       bool "WBMR-HP-G300H"
66 +       default y
67 +
68 +config LANTIQ_MACH_P2601HNFX
69 +       bool "P2601HNFX"
70 +       default y
71 +
72 +config LANTIQ_MACH_H201L
73 +       bool "H201L"
74 +       default y
75 +
76 +config LANTIQ_MACH_FRITZ_VR9
77 +       bool "FRITZ3370"
78 +       default y
79 +
80 +config LANTIQ_MACH_FRITZ_AR9
81 +       bool "FRITZ7320"
82 +       default y
83 +
84  endmenu
85  
86  choice
87 --- a/arch/mips/lantiq/xway/Makefile
88 +++ b/arch/mips/lantiq/xway/Makefile
89 @@ -2,3 +2,11 @@ obj-y := sysctrl.o reset.o gpio.o gpio_s
90  
91  obj-$(CONFIG_LANTIQ_MACH_EASY50712) += mach-easy50712.o
92  obj-$(CONFIG_LANTIQ_MACH_EASY50601) += mach-easy50601.o
93 +obj-$(CONFIG_LANTIQ_MACH_ARV) += mach-arv.o
94 +obj-$(CONFIG_LANTIQ_MACH_FRITZ_AR9) += mach-fritz_ar9.o
95 +obj-$(CONFIG_LANTIQ_MACH_FRITZ_VR9) += mach-fritz_vr9.o
96 +obj-$(CONFIG_LANTIQ_MACH_GIGASX76X) += mach-gigasx76x.o
97 +obj-$(CONFIG_LANTIQ_MACH_NETGEAR) += mach-netgear.o
98 +obj-$(CONFIG_LANTIQ_MACH_WBMR) += mach-wbmr.o
99 +obj-$(CONFIG_LANTIQ_MACH_P2601HNFX) += mach-p2601hnfx.o
100 +obj-$(CONFIG_LANTIQ_MACH_H201L) += mach-h201l.o
101 --- a/arch/mips/lantiq/falcon/Kconfig
102 +++ b/arch/mips/lantiq/falcon/Kconfig
103 @@ -6,6 +6,14 @@ config LANTIQ_MACH_EASY98000
104         bool "Easy98000"
105         default y
106  
107 +config LANTIQ_MACH_EASY98020
108 +       bool "Easy98020"
109 +       default y
110 +
111 +config LANTIQ_MACH_95C3AM1
112 +       bool "95C3AM1"
113 +       default y
114 +
115  endmenu
116  
117  endif
118 --- a/arch/mips/lantiq/falcon/Makefile
119 +++ b/arch/mips/lantiq/falcon/Makefile
120 @@ -1,2 +1,6 @@
121  obj-y := prom.o reset.o sysctrl.o devices.o gpio.o
122 +obj-$(CONFIG_LANTIQ_MACH_EASY98000) += addon-easy98000.o
123 +obj-$(CONFIG_LANTIQ_MACH_EASY98000) += dev-leds-easy98000-cpld.o
124  obj-$(CONFIG_LANTIQ_MACH_EASY98000) += mach-easy98000.o
125 +obj-$(CONFIG_LANTIQ_MACH_EASY98020) += mach-easy98020.o
126 +obj-$(CONFIG_LANTIQ_MACH_95C3AM1)   += mach-95C3AM1.o
127 --- a/arch/mips/lantiq/falcon/mach-easy98000.c
128 +++ b/arch/mips/lantiq/falcon/mach-easy98000.c
129 @@ -1,23 +1,38 @@
130 -/*
131 - *  This program is free software; you can redistribute it and/or modify it
132 - *  under the terms of the GNU General Public License version 2 as published
133 - *  by the Free Software Foundation.
134 - *
135 - *  Copyright (C) 2011 Thomas Langer <thomas.langer@lantiq.com>
136 - *  Copyright (C) 2011 John Crispin <blogic@openwrt.org>
137 - */
138 -
139 +#include <linux/init.h>
140  #include <linux/platform_device.h>
141 +#include <linux/leds.h>
142 +#include <linux/gpio.h>
143 +#include <linux/gpio_buttons.h>
144 +#include <linux/etherdevice.h>
145 +#include <linux/mtd/mtd.h>
146  #include <linux/mtd/partitions.h>
147 +#include <linux/mtd/physmap.h>
148 +#include <linux/input.h>
149 +#include <linux/interrupt.h>
150 +#include <linux/dm9000.h>
151 +#include <linux/i2c.h>
152 +#include <linux/i2c-gpio.h>
153  #include <linux/spi/spi.h>
154  #include <linux/spi/spi_gpio.h>
155  #include <linux/spi/eeprom.h>
156 +#include <falcon/lantiq_soc.h>
157  
158  #include "../machtypes.h"
159  
160  #include "devices.h"
161 +#include "dev-leds-gpio.h"
162 +
163 +#define EASY98000_GPIO_LED_0 9
164 +#define EASY98000_GPIO_LED_1 10
165 +#define EASY98000_GPIO_LED_2 11
166 +#define EASY98000_GPIO_LED_3 12
167 +#define EASY98000_GPIO_LED_4 13
168 +#define EASY98000_GPIO_LED_5 14
169  
170 -static struct mtd_partition easy98000_nor_partitions[] = {
171 +extern unsigned char ltq_ethaddr[6];
172 +
173 +static struct mtd_partition easy98000_nor_partitions[] =
174 +{
175         {
176                 .name   = "uboot",
177                 .offset = 0x0,
178 @@ -35,7 +50,7 @@ static struct mtd_partition easy98000_no
179         },
180  };
181  
182 -struct physmap_flash_data easy98000_nor_flash_data = {
183 +static struct physmap_flash_data easy98000_nor_flash_data = {
184         .nr_parts       = ARRAY_SIZE(easy98000_nor_partitions),
185         .parts          = easy98000_nor_partitions,
186  };
187 @@ -55,12 +70,105 @@ static struct spi_board_info easy98000_s
188         .platform_data          = &easy98000_spi_flash_platform_data
189  };
190  
191 +static struct gpio_led easy98000_leds_gpio[] __initdata = {
192 +       {
193 +               .name           = "easy98000:green:0",
194 +               .gpio           = EASY98000_GPIO_LED_0,
195 +               .active_low     = 0,
196 +       }, {
197 +               .name           = "easy98000:green:1",
198 +               .gpio           = EASY98000_GPIO_LED_1,
199 +               .active_low     = 0,
200 +       }, {
201 +               .name           = "easy98000:green:2",
202 +               .gpio           = EASY98000_GPIO_LED_2,
203 +               .active_low     = 0,
204 +       }, {
205 +               .name           = "easy98000:green:3",
206 +               .gpio           = EASY98000_GPIO_LED_3,
207 +               .active_low     = 0,
208 +       }, {
209 +               .name           = "easy98000:green:4",
210 +               .gpio           = EASY98000_GPIO_LED_4,
211 +               .active_low     = 0,
212 +       }, {
213 +               .name           = "easy98000:green:5",
214 +               .gpio           = EASY98000_GPIO_LED_5,
215 +               .active_low     = 0,
216 +       }
217 +};
218 +
219 +#define CONFIG_DM9000_BASE             0x14000000
220 +#define DM9000_IO                      (CONFIG_DM9000_BASE + 3)
221 +#define DM9000_DATA                    (CONFIG_DM9000_BASE + 1)
222 +
223 +static struct dm9000_plat_data dm9000_plat_data = {
224 +       .flags = DM9000_PLATF_8BITONLY,
225 +       //.dev_addr = { }, /* possibility to provide an ethernet address for the chip */
226 +};
227 +
228 +static struct resource dm9000_resources[] = {
229 +       MEM_RES("dm9000_io", DM9000_IO, DM9000_IO),
230 +       MEM_RES("dm9000_data", DM9000_DATA, DM9000_DATA),
231 +       [2] = {
232 +               /* with irq (210 -> gpio 110) the driver is very unreliable */
233 +               .start  = -1,           /* use polling */
234 +               .end    = -1,
235 +               .flags  = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
236 +       },
237 +};
238 +
239 +static struct platform_device dm9000_platform = {
240 +       .name = "dm9000",
241 +       .id = 0,
242 +       .num_resources  = ARRAY_SIZE(dm9000_resources),
243 +       .resource       = dm9000_resources,
244 +       .dev = {
245 +               .platform_data = (void *) &dm9000_plat_data,
246 +       }
247 +};
248 +
249 +extern int easy98000_addon_has_dm9000(void);
250 +static void __init register_davicom(void)
251 +{
252 +       if (!easy98000_addon_has_dm9000())
253 +               return;
254 +
255 +       if (!is_valid_ether_addr(ltq_ethaddr))
256 +               random_ether_addr(dm9000_plat_data.dev_addr);
257 +       else {
258 +               memcpy(dm9000_plat_data.dev_addr, ltq_ethaddr, 6);
259 +               /* change to "Locally Administered Address" */
260 +               dm9000_plat_data.dev_addr[0] |= 0x2;
261 +       }
262 +       platform_device_register(&dm9000_platform);
263 +}
264 +
265 +static struct i2c_gpio_platform_data easy98000_i2c_gpio_data = {
266 +       .sda_pin        = 107,
267 +       .scl_pin        = 108,
268 +};
269 +
270 +static struct platform_device easy98000_i2c_gpio_device = {
271 +       .name           = "i2c-gpio",
272 +       .id             = 0,
273 +       .dev = {
274 +               .platform_data  = &easy98000_i2c_gpio_data,
275 +       }
276 +};
277 +
278 +void __init register_easy98000_cpld(void)
279 +{
280 +       platform_device_register_simple("easy98000_cpld_led", 0, NULL, 0);
281 +       platform_device_register_simple("easy98000_addon", 0, NULL, 0);
282 +}
283 +
284  /* setup gpio based spi bus/device for access to the eeprom on the board */
285 -#define SPI_GPIO_MRST          102
286 -#define SPI_GPIO_MTSR          103
287 -#define SPI_GPIO_CLK           104
288 -#define SPI_GPIO_CS0           105
289 -#define SPI_GPIO_CS1           106
290 +#define SPI_GPIO_MRST  102
291 +#define SPI_GPIO_MTSR  103
292 +#define SPI_GPIO_CLK   104
293 +#define SPI_GPIO_CS0   105
294 +#define SPI_GPIO_CS1   106
295  #define SPI_GPIO_BUS_NUM       1
296  
297  static struct spi_gpio_platform_data easy98000_spi_gpio_data = {
298 @@ -94,11 +202,22 @@ static struct spi_board_info easy98000_s
299  };
300  
301  static void __init
302 -easy98000_init_common(void)
303 +easy98000_spi_gpio_init(void)
304  {
305         spi_register_board_info(&easy98000_spi_gpio_devices, 1);
306         platform_device_register(&easy98000_spi_gpio_device);
307 +}
308 +
309 +static void __init
310 +easy98000_init_common(void)
311 +{
312         falcon_register_i2c();
313 +       platform_device_register(&easy98000_i2c_gpio_device);
314 +       register_davicom();
315 +       ltq_add_device_leds_gpio(-1, ARRAY_SIZE(easy98000_leds_gpio),
316 +               easy98000_leds_gpio);
317 +       register_easy98000_cpld();
318 +       easy98000_spi_gpio_init();
319  }
320  
321  static void __init