summaryrefslogtreecommitdiff
path: root/target/linux/ixp4xx/patches-3.3/185-mi424wr_support.patch
blob: 4d61cee7a1ce2185abd6983b98b8aaaaa2e1b71e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
--- /dev/null
+++ b/arch/arm/mach-ixp4xx/mi424wr-pci.c
@@ -0,0 +1,71 @@
+/*
+ * arch/arm/mach-ixp4xx/mi424wr-pci.c
+ *
+ * Actiontec MI424WR board-level PCI initialization
+ *
+ * Copyright (C) 2008 Jose Vasconcellos
+ *
+ * Maintainer: Jose Vasconcellos <jvasco@verizon.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+
+#include <asm/mach-types.h>
+#include <asm/mach/pci.h>
+
+/* PCI controller GPIO to IRQ pin mappings
+ * This information was obtained from Actiontec's GPL release.
+ *
+ *		INTA		INTB
+ * SLOT 13	8		6
+ * SLOT 14	7		8
+ * SLOT 15	6		7
+ */
+
+void __init mi424wr_pci_preinit(void)
+{
+	irq_set_irq_type(IRQ_IXP4XX_GPIO6, IRQ_TYPE_LEVEL_LOW);
+	irq_set_irq_type(IRQ_IXP4XX_GPIO7, IRQ_TYPE_LEVEL_LOW);
+	irq_set_irq_type(IRQ_IXP4XX_GPIO8, IRQ_TYPE_LEVEL_LOW);
+
+	ixp4xx_pci_preinit();
+}
+
+static int __init mi424wr_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+{
+	if (slot == 13)
+		return IRQ_IXP4XX_GPIO8;
+	if (slot == 14)
+		return IRQ_IXP4XX_GPIO7;
+	if (slot == 15)
+		return IRQ_IXP4XX_GPIO6;
+
+	return -1;
+}
+
+struct hw_pci mi424wr_pci __initdata = {
+	.nr_controllers = 1,
+	.preinit	= mi424wr_pci_preinit,
+	.swizzle	= pci_std_swizzle,
+	.setup		= ixp4xx_setup,
+	.scan		= ixp4xx_scan_bus,
+	.map_irq	= mi424wr_map_irq,
+};
+
+int __init mi424wr_pci_init(void)
+{
+	if (machine_is_mi424wr())
+		pci_common_init(&mi424wr_pci);
+	return 0;
+}
+
+subsys_initcall(mi424wr_pci_init);
+
--- /dev/null
+++ b/arch/arm/mach-ixp4xx/mi424wr-setup.c
@@ -0,0 +1,381 @@
+/*
+ * arch/arm/mach-ixp4xx/mi424wr-setup.c
+ *
+ * Actiontec MI424-WR board setup
+ * Copyright (c) 2008 Jose Vasconcellos
+ *
+ * Based on Gemtek GTWX5715 by
+ * Copyright (C) 2004 George T. Joseph
+ * Derived from Coyote
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/serial.h>
+#include <linux/serial_8250.h>
+#include <linux/types.h>
+#include <linux/memory.h>
+#include <linux/leds.h>
+#include <linux/spi/spi_gpio_old.h>
+
+#include <asm/setup.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
+
+/*
+ * GPIO 2,3,4 and 9 are hard wired to the Micrel/Kendin KS8995M Switch
+ * and operate as an SPI type interface.  The details of the interface
+ * are available on Kendin/Micrel's web site.
+ */
+
+#define MI424WR_KSSPI_SELECT		9
+#define MI424WR_KSSPI_TXD		4
+#define MI424WR_KSSPI_CLOCK		2
+#define MI424WR_KSSPI_RXD		3
+
+/*
+ * The "reset" button is wired to GPIO 10.
+ * The GPIO is brought "low" when the button is pushed.
+ */
+
+#define MI424WR_BUTTON_GPIO	10
+#define MI424WR_BUTTON_IRQ	IRQ_IXP4XX_GPIO10
+
+#define MI424WR_MOCA_WAN_LED	11
+
+/* Latch on CS1 - taken from Actiontec's 2.4 source code
+ * 
+ * default latch value
+ * 0  - power alarm led (red)           0 (off)
+ * 1  - power led (green)               0 (off)
+ * 2  - wireless led    (green)         1 (off)
+ * 3  - no internet led (red)           0 (off)
+ * 4  - internet ok led (green)         0 (off)
+ * 5  - moca LAN                        0 (off)
+ * 6  - WAN alarm led (red)		0 (off)
+ * 7  - PCI reset                       1 (not reset)
+ * 8  - IP phone 1 led (green)          1 (off)
+ * 9  - IP phone 2 led (green)          1 (off)
+ * 10 - VOIP ready led (green)          1 (off)
+ * 11 - PSTN relay 1 control            0 (PSTN)
+ * 12 - PSTN relay 1 control            0 (PSTN)
+ * 13 - N/A
+ * 14 - N/A
+ * 15 - N/A
+ */
+
+#define MI424WR_LATCH_MASK              0x04
+#define MI424WR_LATCH_DEFAULT           0x1f86
+
+#define MI424WR_LATCH_ALARM_LED         0x00
+#define MI424WR_LATCH_POWER_LED         0x01
+#define MI424WR_LATCH_WIRELESS_LED      0x02
+#define MI424WR_LATCH_INET_DOWN_LED     0x03
+#define MI424WR_LATCH_INET_OK_LED       0x04
+#define MI424WR_LATCH_MOCA_LAN_LED      0x05
+#define MI424WR_LATCH_WAN_ALARM_LED     0x06
+#define MI424WR_LATCH_PCI_RESET         0x07
+#define MI424WR_LATCH_PHONE1_LED        0x08
+#define MI424WR_LATCH_PHONE2_LED        0x09
+#define MI424WR_LATCH_VOIP_LED          0x10
+#define MI424WR_LATCH_PSTN_RELAY1       0x11
+#define MI424WR_LATCH_PSTN_RELAY2       0x12
+
+/* initialize CS1 to default timings, Intel style, 16-bit bus */
+#define MI424WR_CS1_CONFIG	0x80000002
+
+/* Define both UARTs but they are not easily accessible.
+ */
+
+static struct resource mi424wr_uart_resources[] = {
+	{
+		.start	= IXP4XX_UART1_BASE_PHYS,
+		.end	= IXP4XX_UART1_BASE_PHYS + 0x0fff,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IXP4XX_UART2_BASE_PHYS,
+		.end	= IXP4XX_UART2_BASE_PHYS + 0x0fff,
+		.flags	= IORESOURCE_MEM,
+	}
+};
+
+
+static struct plat_serial8250_port mi424wr_uart_platform_data[] = {
+	{
+		.mapbase	= IXP4XX_UART1_BASE_PHYS,
+		.membase	= (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
+		.irq		= IRQ_IXP4XX_UART1,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+		.iotype		= UPIO_MEM,
+		.regshift	= 2,
+		.uartclk	= IXP4XX_UART_XTAL,
+	},
+	{
+		.mapbase	= IXP4XX_UART2_BASE_PHYS,
+		.membase	= (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
+		.irq		= IRQ_IXP4XX_UART2,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+		.iotype		= UPIO_MEM,
+		.regshift	= 2,
+		.uartclk	= IXP4XX_UART_XTAL,
+	},
+	{ },
+};
+
+static struct platform_device mi424wr_uart_device = {
+	.name		= "serial8250",
+	.id		= PLAT8250_DEV_PLATFORM,
+	.dev.platform_data	= mi424wr_uart_platform_data,
+	.num_resources	= ARRAY_SIZE(mi424wr_uart_resources),
+	.resource	= mi424wr_uart_resources,
+};
+
+static struct flash_platform_data mi424wr_flash_data = {
+	.map_name	= "cfi_probe",
+	.width		= 2,
+};
+
+static struct resource mi424wr_flash_resource = {
+	.flags		= IORESOURCE_MEM,
+};
+
+static struct platform_device mi424wr_flash = {
+	.name		= "IXP4XX-Flash",
+	.id		= 0,
+	.dev.platform_data = &mi424wr_flash_data,
+	.num_resources	= 1,
+	.resource	= &mi424wr_flash_resource,
+};
+
+static int mi424wr_spi_boardinfo_setup(struct spi_board_info *bi,
+		struct spi_master *master, void *data)
+{
+
+	strlcpy(bi->modalias, "spi-ks8995", sizeof(bi->modalias));
+
+	bi->max_speed_hz = 5000000 /* Hz */;
+	bi->bus_num = master->bus_num;
+	bi->mode = SPI_MODE_0;
+
+	return 0;
+}
+
+static struct spi_gpio_platform_data mi424wr_spi_bus_data = {
+	.pin_cs			= MI424WR_KSSPI_SELECT,
+	.pin_clk		= MI424WR_KSSPI_CLOCK,
+	.pin_miso		= MI424WR_KSSPI_RXD,
+	.pin_mosi		= MI424WR_KSSPI_TXD,
+	.cs_activelow		= 1,
+	.no_spi_delay		= 1,
+	.boardinfo_setup	= mi424wr_spi_boardinfo_setup,
+};
+
+static struct gpio_led mi424wr_gpio_led[] = {
+	{
+		.name		= "moca-wan",	/* green led */
+		.gpio		= MI424WR_MOCA_WAN_LED,
+		.active_low	= 0,
+	}
+};
+
+static struct gpio_led_platform_data mi424wr_gpio_leds_data = {
+	.num_leds	= 1,
+	.leds		= mi424wr_gpio_led,
+};
+
+static struct platform_device mi424wr_gpio_leds = {
+	.name		= "leds-gpio",
+	.id		= -1,
+	.dev.platform_data = &mi424wr_gpio_leds_data,
+};
+
+static uint16_t latch_value = MI424WR_LATCH_DEFAULT;
+static uint16_t __iomem *iobase;
+
+static void mi424wr_latch_set_led(u8 bit, enum led_brightness value)
+{
+
+	if (((MI424WR_LATCH_MASK >> bit) & 1) ^ (value == LED_OFF))
+		latch_value &= ~(0x1 << bit);
+	else
+		latch_value |= (0x1 << bit);
+
+	__raw_writew(latch_value, iobase);
+
+}
+
+static struct latch_led mi424wr_latch_led[] = {
+	{
+		.name	= "power-alarm",
+		.bit	= MI424WR_LATCH_ALARM_LED,
+	},
+	{
+		.name	= "power-ok",
+		.bit	= MI424WR_LATCH_POWER_LED,
+	},
+	{
+		.name	= "wireless",	/* green led */
+		.bit	= MI424WR_LATCH_WIRELESS_LED,
+	},
+	{
+		.name	= "inet-down",	/* red led */
+		.bit	= MI424WR_LATCH_INET_DOWN_LED,
+	},
+	{
+		.name	= "inet-up",	/* green led */
+		.bit	= MI424WR_LATCH_INET_OK_LED,
+	},
+	{
+		.name	= "moca-lan",	/* green led */
+		.bit	= MI424WR_LATCH_MOCA_LAN_LED,
+	},
+	{
+		.name	= "wan-alarm",	/* red led */
+		.bit	= MI424WR_LATCH_WAN_ALARM_LED,
+	}
+};
+
+static struct latch_led_platform_data mi424wr_latch_leds_data = {
+	.num_leds	= ARRAY_SIZE(mi424wr_latch_led),
+	.mem		= 0x51000000,
+	.leds		= mi424wr_latch_led,
+	.set_led        = mi424wr_latch_set_led,
+};
+
+static struct platform_device mi424wr_latch_leds = {
+	.name		= "leds-latch",
+	.id		= -1,
+	.dev.platform_data = &mi424wr_latch_leds_data,
+};
+
+static struct platform_device mi424wr_spi_bus = {
+	.name		= "spi-gpio",
+	.id		= 0,
+	.dev.platform_data = &mi424wr_spi_bus_data,
+};
+
+static struct eth_plat_info mi424wr_wan_data = {
+	.phy		= 17,	/* KS8721 */
+	.rxq		= 3,
+	.txreadyq	= 20,
+};
+
+static struct eth_plat_info mi424wr_lan_data = {
+	.phy		= IXP4XX_ETH_PHY_MAX_ADDR,
+	.phy_mask	= 0x1e, /* ports 1-4 of the KS8995 switch */
+	.rxq		= 4,
+	.txreadyq	= 21,
+};
+
+static struct platform_device mi424wr_npe_devices[] = {
+	{
+		.name			= "ixp4xx_eth",
+		.id			= IXP4XX_ETH_NPEC,
+		.dev.platform_data	= &mi424wr_lan_data,
+	}, {
+		.name			= "ixp4xx_eth",
+		.id			= IXP4XX_ETH_NPEB,
+		.dev.platform_data	= &mi424wr_wan_data,
+	}
+};
+
+static struct eth_plat_info mi424wr_wanD_data = {
+	.phy		= 5,
+	.rxq		= 4,
+	.txreadyq	= 21,
+};
+
+static struct eth_plat_info mi424wr_lanD_data = {
+	.phy		= IXP4XX_ETH_PHY_MAX_ADDR,
+	.phy_mask	= 0x1e, /* ports 1-4 of the KS8995 switch */
+	.rxq		= 3,
+	.txreadyq	= 20,
+};
+
+static struct platform_device mi424wr_npeD_devices[] = {
+	{
+		.name                   = "ixp4xx_eth",
+		.id                     = IXP4XX_ETH_NPEB,
+		.dev.platform_data      = &mi424wr_lanD_data,
+	}, {
+		.name                   = "ixp4xx_eth",
+		.id                     = IXP4XX_ETH_NPEC,
+		.dev.platform_data      = &mi424wr_wanD_data,
+	}
+};
+
+static struct platform_device *mi424wr_devices[] __initdata = {
+	&mi424wr_uart_device,
+	&mi424wr_flash,
+	&mi424wr_gpio_leds,
+	&mi424wr_latch_leds,
+	&mi424wr_spi_bus,
+};
+
+static void __init mi424wr_init(void)
+{
+	ixp4xx_sys_init();
+
+	mi424wr_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
+	mi424wr_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_8M - 1;
+
+	*IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
+	*IXP4XX_EXP_CS1 = MI424WR_CS1_CONFIG;
+
+	/* configure button as input
+	 */
+	gpio_line_config(MI424WR_BUTTON_GPIO, IXP4XX_GPIO_IN);
+
+	/* Initialize LEDs and enables PCI bus.
+	 */
+	iobase = ioremap_nocache(IXP4XX_EXP_BUS_BASE(1), 0x1000);
+	__raw_writew(latch_value, iobase);
+
+	platform_add_devices(mi424wr_devices, ARRAY_SIZE(mi424wr_devices));
+
+	/* Need to figure out how to detect revD.
+	 * Look for a revision argument sent by redboot.
+	 */
+#define revD 4
+	if (system_rev == revD) {
+		platform_device_register(&mi424wr_npeD_devices[0]);
+		platform_device_register(&mi424wr_npeD_devices[1]);
+	} else {
+		platform_device_register(&mi424wr_npe_devices[0]);
+		platform_device_register(&mi424wr_npe_devices[1]);
+	}
+}
+
+
+MACHINE_START(MI424WR, "Actiontec MI424WR")
+	/* Maintainer: Jose Vasconcellos */
+	.map_io		= ixp4xx_map_io,
+	.init_irq	= ixp4xx_init_irq,
+	.timer		= &ixp4xx_timer,
+	.atag_offset	= 0x0100,
+	.init_machine	= mi424wr_init,
+#if defined(CONFIG_PCI)
+	.dma_zone_size	= SZ_64M,
+#endif
+	.restart	= ixp4xx_restart,
+MACHINE_END
+
--- a/arch/arm/mach-ixp4xx/Makefile
+++ b/arch/arm/mach-ixp4xx/Makefile
@@ -25,6 +25,7 @@ obj-pci-$(CONFIG_MACH_COMPEX)		+= ixdp42
 obj-pci-$(CONFIG_MACH_WRT300NV2)		+= wrt300nv2-pci.o
 obj-pci-$(CONFIG_MACH_AP1000)		+= ixdp425-pci.o
 obj-pci-$(CONFIG_MACH_TW5334)		+= tw5334-pci.o
+obj-pci-$(CONFIG_MACH_MI424WR)		+= mi424wr-pci.o
 
 obj-y	+= common.o
 
@@ -51,6 +52,7 @@ obj-$(CONFIG_MACH_COMPEX)	+= compex-setu
 obj-$(CONFIG_MACH_WRT300NV2)	+= wrt300nv2-setup.o
 obj-$(CONFIG_MACH_AP1000)	+= ap1000-setup.o
 obj-$(CONFIG_MACH_TW5334)	+= tw5334-setup.o
+obj-$(CONFIG_MACH_MI424WR)	+= mi424wr-setup.o
 
 obj-$(CONFIG_PCI)		+= $(obj-pci-$(CONFIG_PCI)) common-pci.o
 obj-$(CONFIG_IXP4XX_QMGR)	+= ixp4xx_qmgr.o
--- a/arch/arm/mach-ixp4xx/Kconfig
+++ b/arch/arm/mach-ixp4xx/Kconfig
@@ -262,6 +262,13 @@ config MACH_MIC256
 	  Say 'Y' here if you want your kernel to support the MIC256
 	  board from OMICRON electronics GmbH.
 
+config MACH_MI424WR
+	bool "Actiontec MI424WR"
+	depends on ARCH_IXP4XX
+	select PCI
+	help
+		Add support for the Actiontec MI424-WR.
+
 comment "IXP4xx Options"
 
 config IXP4XX_INDIRECT_PCI
--- a/arch/arm/configs/ixp4xx_defconfig
+++ b/arch/arm/configs/ixp4xx_defconfig
@@ -26,6 +26,7 @@ CONFIG_MACH_NAS100D=y
 CONFIG_MACH_DSMG600=y
 CONFIG_MACH_FSG=y
 CONFIG_MACH_GTWX5715=y
+CONFIG_MACH_MI424WR=y
 CONFIG_IXP4XX_QMGR=y
 CONFIG_IXP4XX_NPE=y
 # CONFIG_ARM_THUMB is not set