1 From f1c9b41720476cd660a852134b0e8a8acd601441 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Fri, 3 Aug 2012 10:23:08 +0200
4 Subject: [PATCH 13/25] machtype support
7 arch/mips/lantiq/Makefile | 2 +-
8 arch/mips/lantiq/devices.c | 18 ++++
9 arch/mips/lantiq/devices.h | 1 +
10 arch/mips/lantiq/falcon/Kconfig | 8 ++
11 arch/mips/lantiq/falcon/Makefile | 4 +
12 arch/mips/lantiq/falcon/mach-easy98000.c | 162 ++++++++++++++++++++++++++---
13 arch/mips/lantiq/machtypes.h | 42 ++++++++
14 arch/mips/lantiq/xway/Kconfig | 32 ++++++
15 arch/mips/lantiq/xway/Makefile | 11 ++
16 arch/mips/lantiq/xway/devices.c | 95 +++++++++++++++++
17 arch/mips/lantiq/xway/devices.h | 6 +
18 11 files changed, 363 insertions(+), 18 deletions(-)
20 diff --git a/arch/mips/lantiq/Makefile b/arch/mips/lantiq/Makefile
21 index db1ce50..4f245d8 100644
22 --- a/arch/mips/lantiq/Makefile
23 +++ b/arch/mips/lantiq/Makefile
25 # under the terms of the GNU General Public License version 2 as published
26 # by the Free Software Foundation.
28 -obj-y := irq.o setup.o clk.o prom.o devices.o
29 +obj-y := irq.o setup.o clk.o prom.o devices.o dev-gpio-leds.o dev-gpio-buttons.o
31 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
33 diff --git a/arch/mips/lantiq/devices.c b/arch/mips/lantiq/devices.c
34 index 7193d78..2d7c46a 100644
35 --- a/arch/mips/lantiq/devices.c
36 +++ b/arch/mips/lantiq/devices.c
38 #include <linux/time.h>
40 #include <linux/gpio.h>
41 +#include <linux/dma-mapping.h>
43 #include <asm/bootinfo.h>
45 @@ -100,3 +101,20 @@ void __init ltq_register_pci(struct ltq_pci_data *data)
46 pr_err("kernel is compiled without PCI support\n");
50 +static unsigned int *cp1_base = 0;
52 +ltq_get_cp1_base(void)
56 +EXPORT_SYMBOL(ltq_get_cp1_base);
59 +ltq_register_tapi(void)
61 +#define CP1_SIZE (1 << 20)
64 + (void*)CPHYSADDR(dma_alloc_coherent(NULL, CP1_SIZE, &dma, GFP_ATOMIC));
66 diff --git a/arch/mips/lantiq/devices.h b/arch/mips/lantiq/devices.h
67 index a03c23f..59d904c 100644
68 --- a/arch/mips/lantiq/devices.h
69 +++ b/arch/mips/lantiq/devices.h
70 @@ -23,5 +23,6 @@ extern void ltq_register_nor(struct physmap_flash_data *data);
71 extern void ltq_register_wdt(void);
72 extern void ltq_register_asc(int port);
73 extern void ltq_register_pci(struct ltq_pci_data *data);
74 +extern void ltq_register_tapi(void);
77 diff --git a/arch/mips/lantiq/falcon/Kconfig b/arch/mips/lantiq/falcon/Kconfig
78 index 03e999d..2e3e59c 100644
79 --- a/arch/mips/lantiq/falcon/Kconfig
80 +++ b/arch/mips/lantiq/falcon/Kconfig
81 @@ -6,6 +6,14 @@ config LANTIQ_MACH_EASY98000
85 +config LANTIQ_MACH_EASY98020
89 +config LANTIQ_MACH_95C3AM1
96 diff --git a/arch/mips/lantiq/falcon/Makefile b/arch/mips/lantiq/falcon/Makefile
97 index 3634154..aa1fc69 100644
98 --- a/arch/mips/lantiq/falcon/Makefile
99 +++ b/arch/mips/lantiq/falcon/Makefile
101 obj-y := prom.o reset.o sysctrl.o devices.o gpio.o
102 +obj-$(CONFIG_LANTIQ_MACH_EASY98000) += addon-easy98000.o
103 +obj-$(CONFIG_LANTIQ_MACH_EASY98000) += dev-leds-easy98000-cpld.o
104 obj-$(CONFIG_LANTIQ_MACH_EASY98000) += mach-easy98000.o
105 +obj-$(CONFIG_LANTIQ_MACH_EASY98020) += mach-easy98020.o
106 +obj-$(CONFIG_LANTIQ_MACH_95C3AM1) += mach-95C3AM1.o
107 diff --git a/arch/mips/lantiq/falcon/mach-easy98000.c b/arch/mips/lantiq/falcon/mach-easy98000.c
108 index fc5720d..adf6b5d 100644
109 --- a/arch/mips/lantiq/falcon/mach-easy98000.c
110 +++ b/arch/mips/lantiq/falcon/mach-easy98000.c
113 - * This program is free software; you can redistribute it and/or modify it
114 - * under the terms of the GNU General Public License version 2 as published
115 - * by the Free Software Foundation.
117 - * Copyright (C) 2011 Thomas Langer <thomas.langer@lantiq.com>
118 - * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
121 +#include <linux/init.h>
122 #include <linux/platform_device.h>
123 +#include <linux/leds.h>
124 +#include <linux/gpio.h>
125 +#include <linux/gpio_buttons.h>
126 +#include <linux/etherdevice.h>
127 +#include <linux/mtd/mtd.h>
128 #include <linux/mtd/partitions.h>
129 +#include <linux/mtd/physmap.h>
130 +#include <linux/input.h>
131 +#include <linux/interrupt.h>
132 +#include <linux/dm9000.h>
133 +#include <linux/i2c.h>
134 +#include <linux/i2c-gpio.h>
135 #include <linux/spi/spi.h>
136 #include <linux/spi/spi_gpio.h>
137 #include <linux/spi/eeprom.h>
138 +#include <falcon/lantiq_soc.h>
140 +#include <dev-gpio-leds.h>
142 #include "../machtypes.h"
146 -static struct mtd_partition easy98000_nor_partitions[] = {
147 +#define EASY98000_GPIO_LED_0 9
148 +#define EASY98000_GPIO_LED_1 10
149 +#define EASY98000_GPIO_LED_2 11
150 +#define EASY98000_GPIO_LED_3 12
151 +#define EASY98000_GPIO_LED_4 13
152 +#define EASY98000_GPIO_LED_5 14
154 +static unsigned char ltq_ethaddr[6] = {0};
156 +static int __init falcon_set_ethaddr(char *str)
158 + sscanf(str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
159 + <q_ethaddr[0], <q_ethaddr[1], <q_ethaddr[2],
160 + <q_ethaddr[3], <q_ethaddr[4], <q_ethaddr[5]);
163 +__setup("ethaddr=", falcon_set_ethaddr);
165 +static struct mtd_partition easy98000_nor_partitions[] =
170 @@ -35,7 +60,7 @@ static struct mtd_partition easy98000_nor_partitions[] = {
174 -struct physmap_flash_data easy98000_nor_flash_data = {
175 +static struct physmap_flash_data easy98000_nor_flash_data = {
176 .nr_parts = ARRAY_SIZE(easy98000_nor_partitions),
177 .parts = easy98000_nor_partitions,
179 @@ -55,12 +80,104 @@ static struct spi_board_info easy98000_spi_flash_data __initdata = {
180 .platform_data = &easy98000_spi_flash_platform_data
183 +static struct gpio_led easy98000_gpio_leds[] __initdata = {
185 + .name = "easy98000:green:0",
186 + .gpio = EASY98000_GPIO_LED_0,
189 + .name = "easy98000:green:1",
190 + .gpio = EASY98000_GPIO_LED_1,
193 + .name = "easy98000:green:2",
194 + .gpio = EASY98000_GPIO_LED_2,
197 + .name = "easy98000:green:3",
198 + .gpio = EASY98000_GPIO_LED_3,
201 + .name = "easy98000:green:4",
202 + .gpio = EASY98000_GPIO_LED_4,
205 + .name = "easy98000:green:5",
206 + .gpio = EASY98000_GPIO_LED_5,
211 +#define CONFIG_DM9000_BASE 0x14000000
212 +#define DM9000_IO (CONFIG_DM9000_BASE + 3)
213 +#define DM9000_DATA (CONFIG_DM9000_BASE + 1)
215 +static struct dm9000_plat_data dm9000_plat_data = {
216 + .flags = DM9000_PLATF_8BITONLY,
219 +static struct resource dm9000_resources[] = {
220 + MEM_RES("dm9000_io", DM9000_IO, 1),
221 + MEM_RES("dm9000_data", DM9000_DATA, 1),
223 + /* with irq (210 -> gpio 110) the driver is very unreliable */
224 + .start = -1, /* use polling */
226 + .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
230 +static struct platform_device dm9000_platform = {
233 + .num_resources = ARRAY_SIZE(dm9000_resources),
234 + .resource = dm9000_resources,
236 + .platform_data = (void *) &dm9000_plat_data,
240 +extern int easy98000_addon_has_dm9000(void);
241 +static void __init register_davicom(void)
243 + if (!easy98000_addon_has_dm9000())
246 + if (!is_valid_ether_addr(ltq_ethaddr))
247 + random_ether_addr(dm9000_plat_data.dev_addr);
249 + memcpy(dm9000_plat_data.dev_addr, ltq_ethaddr, 6);
250 + /* change to "Locally Administered Address" */
251 + dm9000_plat_data.dev_addr[0] |= 0x2;
253 + platform_device_register(&dm9000_platform);
256 +static struct i2c_gpio_platform_data easy98000_i2c_gpio_data = {
261 +static struct platform_device easy98000_i2c_gpio_device = {
262 + .name = "i2c-gpio",
265 + .platform_data = &easy98000_i2c_gpio_data,
269 +void __init register_easy98000_cpld(void)
271 + platform_device_register_simple("easy98000_cpld_led", 0, NULL, 0);
272 + platform_device_register_simple("easy98000_addon", 0, NULL, 0);
275 /* setup gpio based spi bus/device for access to the eeprom on the board */
276 -#define SPI_GPIO_MRST 102
277 -#define SPI_GPIO_MTSR 103
278 -#define SPI_GPIO_CLK 104
279 -#define SPI_GPIO_CS0 105
280 -#define SPI_GPIO_CS1 106
281 +#define SPI_GPIO_MRST 102
282 +#define SPI_GPIO_MTSR 103
283 +#define SPI_GPIO_CLK 104
284 +#define SPI_GPIO_CS0 105
285 +#define SPI_GPIO_CS1 106
286 #define SPI_GPIO_BUS_NUM 1
288 static struct spi_gpio_platform_data easy98000_spi_gpio_data = {
289 @@ -94,11 +211,22 @@ static struct spi_board_info easy98000_spi_gpio_devices __initdata = {
293 -easy98000_init_common(void)
294 +easy98000_spi_gpio_init(void)
296 spi_register_board_info(&easy98000_spi_gpio_devices, 1);
297 platform_device_register(&easy98000_spi_gpio_device);
301 +easy98000_init_common(void)
303 falcon_register_i2c();
304 + platform_device_register(&easy98000_i2c_gpio_device);
305 + register_davicom();
306 + ltq_add_device_gpio_leds(-1, ARRAY_SIZE(easy98000_gpio_leds),
307 + easy98000_gpio_leds);
308 + register_easy98000_cpld();
309 + easy98000_spi_gpio_init();
313 diff --git a/arch/mips/lantiq/machtypes.h b/arch/mips/lantiq/machtypes.h
314 index dfc6af7..7690f6a 100644
315 --- a/arch/mips/lantiq/machtypes.h
316 +++ b/arch/mips/lantiq/machtypes.h
317 @@ -16,10 +16,52 @@ enum lantiq_mach_type {
318 LTQ_MACH_EASY50712, /* Danube evaluation board */
319 LTQ_MACH_EASY50601, /* Amazon SE evaluation board */
322 + LANTIQ_MACH_EASY33016, /* SVIP Easy33016 */
323 + LANTIQ_MACH_EASY336, /* SVIP Easy336, NOR Flash */
324 + LANTIQ_MACH_EASY336SF, /* SVIP Easy336, Serial Flash */
325 + LANTIQ_MACH_EASY336NAND, /* SVIP Easy336, NAND Flash */
328 LANTIQ_MACH_EASY98000, /* Falcon Eval Board, NOR Flash */
329 LANTIQ_MACH_EASY98000SF, /* Falcon Eval Board, Serial Flash */
330 LANTIQ_MACH_EASY98000NAND, /* Falcon Eval Board, NAND Flash */
331 + LANTIQ_MACH_EASY98020, /* EASY98020 Eval Board */
332 + LANTIQ_MACH_EASY98020_1LAN, /* EASY98020 Eval Board (1 LAN port) */
333 + LANTIQ_MACH_EASY98020_2LAN, /* EASY98020 Eval Board (2 LAN port) */
334 + LANTIQ_MACH_95C3AM1, /* 95C3AM1 Eval Board */
337 + LANTIQ_MACH_ARV3527P, /* Arcor easybox a401 */
338 + LANTIQ_MACH_ARV4510PW, /* Wippies Homebox */
339 + LANTIQ_MACH_ARV4518PW, /* Airties WAV-221, SMC-7908A-ISP */
340 + LANTIQ_MACH_ARV4519PW, /* Vodafone, Pirelli */
341 + LANTIQ_MACH_ARV4520PW, /* Airties WAV-281, Arcor EasyboxA800 */
342 + LANTIQ_MACH_ARV452CPW, /* Arcor EasyboxA801 */
343 + LANTIQ_MACH_ARV4525PW, /* Speedport W502V */
344 + LANTIQ_MACH_ARV7525PW, /* Speedport W303V */
345 + LANTIQ_MACH_ARV752DPW, /* Arcor easybox a802 */
346 + LANTIQ_MACH_ARV752DPW22, /* Arcor easybox a803 */
347 + LANTIQ_MACH_ARV7518PW, /* ASTORIA */
350 + LANTIQ_MACH_DGN3500B, /* Netgear DGN3500 */
353 + LANTIQ_MACH_FRITZ3370, /* FRITZ!BOX 3370 vdsl cpe */
354 + LANTIQ_MACH_FRITZ7320, /* FRITZ!BOX 7320 1&1 homeserver */
357 + LANTIQ_MACH_GIGASX76X, /* Gigaset SX76x */
360 + LANTIQ_MACH_WBMR, /* WBMR-HP-G300H */
363 + LANTIQ_MACH_P2601HNFX, /* ZyXEL P-2601HN-Fx */
366 + LANTIQ_MACH_H201L, /* ZTE ZXV10 H201L */
370 diff --git a/arch/mips/lantiq/xway/Kconfig b/arch/mips/lantiq/xway/Kconfig
371 index 54a51ff..8ad481c 100644
372 --- a/arch/mips/lantiq/xway/Kconfig
373 +++ b/arch/mips/lantiq/xway/Kconfig
374 @@ -6,6 +6,38 @@ config LANTIQ_MACH_EASY50712
375 bool "Easy50712 - Danube"
378 +config LANTIQ_MACH_ARV
382 +config LANTIQ_MACH_NETGEAR
386 +config LANTIQ_MACH_GIGASX76X
390 +config LANTIQ_MACH_WBMR
391 + bool "WBMR-HP-G300H"
394 +config LANTIQ_MACH_P2601HNFX
398 +config LANTIQ_MACH_H201L
402 +config LANTIQ_MACH_FRITZ_VR9
406 +config LANTIQ_MACH_FRITZ_AR9
413 diff --git a/arch/mips/lantiq/xway/Makefile b/arch/mips/lantiq/xway/Makefile
414 index c9baf91..d9f3685 100644
415 --- a/arch/mips/lantiq/xway/Makefile
416 +++ b/arch/mips/lantiq/xway/Makefile
418 obj-y := sysctrl.o reset.o gpio.o gpio_stp.o gpio_ebu.o devices.o dma.o clk.o prom.o nand.o timer.o dev-ifxhcd.o
420 +obj-y += dev-dwc_otg.o
421 +obj-$(CONFIG_PCI) += dev-wifi-rt2x00.o dev-wifi-athxk.o pci-ath-fixup.o
423 obj-$(CONFIG_LANTIQ_MACH_EASY50712) += mach-easy50712.o
424 obj-$(CONFIG_LANTIQ_MACH_EASY50601) += mach-easy50601.o
425 +obj-$(CONFIG_LANTIQ_MACH_ARV) += mach-arv.o
426 +obj-$(CONFIG_LANTIQ_MACH_FRITZ_AR9) += mach-fritz_ar9.o
427 +obj-$(CONFIG_LANTIQ_MACH_FRITZ_VR9) += mach-fritz_vr9.o
428 +obj-$(CONFIG_LANTIQ_MACH_GIGASX76X) += mach-gigasx76x.o
429 +obj-$(CONFIG_LANTIQ_MACH_NETGEAR) += mach-netgear.o
430 +obj-$(CONFIG_LANTIQ_MACH_WBMR) += mach-wbmr.o
431 +obj-$(CONFIG_LANTIQ_MACH_P2601HNFX) += mach-p2601hnfx.o
432 +obj-$(CONFIG_LANTIQ_MACH_H201L) += mach-h201l.o
433 diff --git a/arch/mips/lantiq/xway/devices.c b/arch/mips/lantiq/xway/devices.c
434 index 5d4650d..64fe713 100644
435 --- a/arch/mips/lantiq/xway/devices.c
436 +++ b/arch/mips/lantiq/xway/devices.c
438 #include <linux/time.h>
439 #include <linux/io.h>
440 #include <linux/gpio.h>
441 +#include <linux/spi/spi.h>
443 #include <asm/bootinfo.h>
445 @@ -119,3 +120,97 @@ ltq_register_vrx200(struct ltq_eth_data *eth)
446 ltq_vrx200.dev.platform_data = eth;
447 platform_device_register(<q_vrx200);
451 +static struct resource ltq_ebu_resource =
453 + .name = "gpio_ebu",
454 + .start = LTQ_EBU_GPIO_START,
455 + .end = LTQ_EBU_GPIO_START + LTQ_EBU_GPIO_SIZE - 1,
456 + .flags = IORESOURCE_MEM,
459 +static struct platform_device ltq_ebu =
462 + .resource = <q_ebu_resource,
463 + .num_resources = 1,
467 +ltq_register_gpio_ebu(unsigned int value)
469 + ltq_ebu.dev.platform_data = (void*) value;
470 + platform_device_register(<q_ebu);
474 +static struct gpio_buttons_platform_data ltq_gpio_buttons_platform_data;
476 +static struct platform_device ltq_gpio_buttons_platform_device =
478 + .name = "gpio-buttons",
481 + .platform_data = (void *) <q_gpio_buttons_platform_data,
486 +ltq_register_gpio_buttons(struct gpio_button *buttons, int cnt)
488 + ltq_gpio_buttons_platform_data.buttons = buttons;
489 + ltq_gpio_buttons_platform_data.nbuttons = cnt;
490 + platform_device_register(<q_gpio_buttons_platform_device);
493 +static struct resource ltq_spi_resources[] = {
495 + .start = LTQ_SSC_BASE_ADDR,
496 + .end = LTQ_SSC_BASE_ADDR + LTQ_SSC_SIZE - 1,
497 + .flags = IORESOURCE_MEM,
499 + IRQ_RES(spi_tx, LTQ_SSC_TIR),
500 + IRQ_RES(spi_rx, LTQ_SSC_RIR),
501 + IRQ_RES(spi_err, LTQ_SSC_EIR),
504 +static struct resource ltq_spi_resources_ar9[] = {
506 + .start = LTQ_SSC_BASE_ADDR,
507 + .end = LTQ_SSC_BASE_ADDR + LTQ_SSC_SIZE - 1,
508 + .flags = IORESOURCE_MEM,
510 + IRQ_RES(spi_tx, LTQ_SSC_TIR_AR9),
511 + IRQ_RES(spi_rx, LTQ_SSC_RIR_AR9),
512 + IRQ_RES(spi_err, LTQ_SSC_EIR),
515 +static struct resource ltq_spi_resources_ase[] = {
517 + .start = LTQ_SSC_BASE_ADDR,
518 + .end = LTQ_SSC_BASE_ADDR + LTQ_SSC_SIZE - 1,
519 + .flags = IORESOURCE_MEM,
521 + IRQ_RES(spi_tx, LTQ_SSC_TIR_ASE),
522 + IRQ_RES(spi_rx, LTQ_SSC_RIR_ASE),
523 + IRQ_RES(spi_err, LTQ_SSC_EIR_ASE),
526 +static struct platform_device ltq_spi = {
528 + .resource = ltq_spi_resources,
529 + .num_resources = ARRAY_SIZE(ltq_spi_resources),
532 +void __init ltq_register_spi(struct ltq_spi_platform_data *pdata,
533 + struct spi_board_info const *info, unsigned n)
536 + ltq_spi.resource = ltq_spi_resources_ar9;
537 + else if (ltq_is_ase())
538 + ltq_spi.resource = ltq_spi_resources_ase;
539 + spi_register_board_info(info, n);
540 + ltq_spi.dev.platform_data = pdata;
541 + platform_device_register(<q_spi);
543 diff --git a/arch/mips/lantiq/xway/devices.h b/arch/mips/lantiq/xway/devices.h
544 index 08befd9..dcf2a14 100644
545 --- a/arch/mips/lantiq/xway/devices.h
546 +++ b/arch/mips/lantiq/xway/devices.h
549 #include "../devices.h"
550 #include <linux/phy.h>
551 +#include <linux/spi/spi.h>
552 +#include <linux/gpio_buttons.h>
554 extern void ltq_register_gpio(void);
555 extern void ltq_register_gpio_stp(void);
556 @@ -18,5 +20,9 @@ extern void ltq_register_ase_asc(void);
557 extern void ltq_register_etop(struct ltq_eth_data *eth);
558 extern void xway_register_nand(struct mtd_partition *parts, int count);
559 extern void ltq_register_vrx200(struct ltq_eth_data *eth);
560 +extern void ltq_register_gpio_ebu(unsigned int value);
561 +extern void ltq_register_spi(struct ltq_spi_platform_data *pdata,
562 + struct spi_board_info const *info, unsigned n);
563 +extern void ltq_register_gpio_buttons(struct gpio_button *buttons, int cnt);