1 --- a/arch/arm/configs/ixp4xx_defconfig
2 +++ b/arch/arm/configs/ixp4xx_defconfig
3 @@ -26,6 +26,7 @@ CONFIG_MACH_NAS100D=y
10 # CONFIG_ARM_THUMB is not set
11 --- a/arch/arm/mach-ixp4xx/Kconfig
12 +++ b/arch/arm/mach-ixp4xx/Kconfig
13 @@ -258,6 +258,13 @@ config MACH_MIC256
14 Say 'Y' here if you want your kernel to support the MIC256
15 board from OMICRON electronics GmbH.
18 + bool "Actiontec MI424WR"
19 + depends on ARCH_IXP4XX
22 + Add support for the Actiontec MI424-WR.
24 comment "IXP4xx Options"
26 config IXP4XX_INDIRECT_PCI
27 --- a/arch/arm/mach-ixp4xx/Makefile
28 +++ b/arch/arm/mach-ixp4xx/Makefile
29 @@ -25,6 +25,7 @@ obj-pci-$(CONFIG_MACH_COMPEXWP18) += ixd
30 obj-pci-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-pci.o
31 obj-pci-$(CONFIG_MACH_AP1000) += ixdp425-pci.o
32 obj-pci-$(CONFIG_MACH_TW5334) += tw5334-pci.o
33 +obj-pci-$(CONFIG_MACH_MI424WR) += mi424wr-pci.o
37 @@ -51,6 +52,7 @@ obj-$(CONFIG_MACH_COMPEXWP18) += compex4
38 obj-$(CONFIG_MACH_WRT300NV2) += wrt300nv2-setup.o
39 obj-$(CONFIG_MACH_AP1000) += ap1000-setup.o
40 obj-$(CONFIG_MACH_TW5334) += tw5334-setup.o
41 +obj-$(CONFIG_MACH_MI424WR) += mi424wr-setup.o
43 obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
44 obj-$(CONFIG_IXP4XX_QMGR) += ixp4xx_qmgr.o
46 +++ b/arch/arm/mach-ixp4xx/mi424wr-pci.c
49 + * arch/arm/mach-ixp4xx/mi424wr-pci.c
51 + * Actiontec MI424WR board-level PCI initialization
53 + * Copyright (C) 2008 Jose Vasconcellos
55 + * Maintainer: Jose Vasconcellos <jvasco@verizon.net>
57 + * This program is free software; you can redistribute it and/or modify
58 + * it under the terms of the GNU General Public License version 2 as
59 + * published by the Free Software Foundation.
63 +#include <linux/kernel.h>
64 +#include <linux/pci.h>
65 +#include <linux/init.h>
66 +#include <linux/irq.h>
68 +#include <asm/mach-types.h>
69 +#include <asm/mach/pci.h>
71 +/* PCI controller GPIO to IRQ pin mappings
72 + * This information was obtained from Actiontec's GPL release.
80 +void __init mi424wr_pci_preinit(void)
82 + irq_set_irq_type(IRQ_IXP4XX_GPIO6, IRQ_TYPE_LEVEL_LOW);
83 + irq_set_irq_type(IRQ_IXP4XX_GPIO7, IRQ_TYPE_LEVEL_LOW);
84 + irq_set_irq_type(IRQ_IXP4XX_GPIO8, IRQ_TYPE_LEVEL_LOW);
86 + ixp4xx_pci_preinit();
89 +static int __init mi424wr_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
92 + return IRQ_IXP4XX_GPIO8;
94 + return IRQ_IXP4XX_GPIO7;
96 + return IRQ_IXP4XX_GPIO6;
101 +struct hw_pci mi424wr_pci __initdata = {
102 + .nr_controllers = 1,
103 + .preinit = mi424wr_pci_preinit,
104 + .ops = &ixp4xx_ops,
105 + .setup = ixp4xx_setup,
106 + .map_irq = mi424wr_map_irq,
109 +int __init mi424wr_pci_init(void)
111 + if (machine_is_mi424wr())
112 + pci_common_init(&mi424wr_pci);
116 +subsys_initcall(mi424wr_pci_init);
119 +++ b/arch/arm/mach-ixp4xx/mi424wr-setup.c
122 + * arch/arm/mach-ixp4xx/mi424wr-setup.c
124 + * Actiontec MI424-WR board setup
125 + * Copyright (c) 2008 Jose Vasconcellos
127 + * Based on Gemtek GTWX5715 by
128 + * Copyright (C) 2004 George T. Joseph
129 + * Derived from Coyote
131 + * This program is free software; you can redistribute it and/or
132 + * modify it under the terms of the GNU General Public License
133 + * as published by the Free Software Foundation; either version 2
134 + * of the License, or (at your option) any later version.
136 + * This program is distributed in the hope that it will be useful,
137 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
138 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
139 + * GNU General Public License for more details.
141 + * You should have received a copy of the GNU General Public License
142 + * along with this program; if not, write to the Free Software
143 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
147 +#include <linux/init.h>
148 +#include <linux/device.h>
149 +#include <linux/serial.h>
150 +#include <linux/serial_8250.h>
151 +#include <linux/types.h>
152 +#include <linux/memory.h>
153 +#include <linux/leds.h>
154 +#include <linux/spi/spi_gpio_old.h>
155 +#include <linux/dma-mapping.h>
157 +#include <asm/setup.h>
158 +#include <asm/system_info.h>
159 +#include <asm/irq.h>
161 +#include <asm/mach-types.h>
162 +#include <asm/mach/arch.h>
163 +#include <asm/mach/flash.h>
166 + * GPIO 2,3,4 and 9 are hard wired to the Micrel/Kendin KS8995M Switch
167 + * and operate as an SPI type interface. The details of the interface
168 + * are available on Kendin/Micrel's web site.
171 +#define MI424WR_KSSPI_SELECT 9
172 +#define MI424WR_KSSPI_TXD 4
173 +#define MI424WR_KSSPI_CLOCK 2
174 +#define MI424WR_KSSPI_RXD 3
177 + * The "reset" button is wired to GPIO 10.
178 + * The GPIO is brought "low" when the button is pushed.
181 +#define MI424WR_BUTTON_GPIO 10
182 +#define MI424WR_BUTTON_IRQ IRQ_IXP4XX_GPIO10
184 +#define MI424WR_MOCA_WAN_LED 11
186 +/* Latch on CS1 - taken from Actiontec's 2.4 source code
188 + * default latch value
189 + * 0 - power alarm led (red) 0 (off)
190 + * 1 - power led (green) 0 (off)
191 + * 2 - wireless led (green) 1 (off)
192 + * 3 - no internet led (red) 0 (off)
193 + * 4 - internet ok led (green) 0 (off)
194 + * 5 - moca LAN 0 (off)
195 + * 6 - WAN alarm led (red) 0 (off)
196 + * 7 - PCI reset 1 (not reset)
197 + * 8 - IP phone 1 led (green) 1 (off)
198 + * 9 - IP phone 2 led (green) 1 (off)
199 + * 10 - VOIP ready led (green) 1 (off)
200 + * 11 - PSTN relay 1 control 0 (PSTN)
201 + * 12 - PSTN relay 1 control 0 (PSTN)
207 +#define MI424WR_LATCH_MASK 0x04
208 +#define MI424WR_LATCH_DEFAULT 0x1f86
210 +#define MI424WR_LATCH_ALARM_LED 0x00
211 +#define MI424WR_LATCH_POWER_LED 0x01
212 +#define MI424WR_LATCH_WIRELESS_LED 0x02
213 +#define MI424WR_LATCH_INET_DOWN_LED 0x03
214 +#define MI424WR_LATCH_INET_OK_LED 0x04
215 +#define MI424WR_LATCH_MOCA_LAN_LED 0x05
216 +#define MI424WR_LATCH_WAN_ALARM_LED 0x06
217 +#define MI424WR_LATCH_PCI_RESET 0x07
218 +#define MI424WR_LATCH_PHONE1_LED 0x08
219 +#define MI424WR_LATCH_PHONE2_LED 0x09
220 +#define MI424WR_LATCH_VOIP_LED 0x10
221 +#define MI424WR_LATCH_PSTN_RELAY1 0x11
222 +#define MI424WR_LATCH_PSTN_RELAY2 0x12
224 +/* initialize CS1 to default timings, Intel style, 16-bit bus */
225 +#define MI424WR_CS1_CONFIG 0x80000002
227 +/* Define both UARTs but they are not easily accessible.
230 +static struct resource mi424wr_uart_resources[] = {
232 + .start = IXP4XX_UART1_BASE_PHYS,
233 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
234 + .flags = IORESOURCE_MEM,
237 + .start = IXP4XX_UART2_BASE_PHYS,
238 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
239 + .flags = IORESOURCE_MEM,
244 +static struct plat_serial8250_port mi424wr_uart_platform_data[] = {
246 + .mapbase = IXP4XX_UART1_BASE_PHYS,
247 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
248 + .irq = IRQ_IXP4XX_UART1,
249 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
250 + .iotype = UPIO_MEM,
252 + .uartclk = IXP4XX_UART_XTAL,
255 + .mapbase = IXP4XX_UART2_BASE_PHYS,
256 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
257 + .irq = IRQ_IXP4XX_UART2,
258 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
259 + .iotype = UPIO_MEM,
261 + .uartclk = IXP4XX_UART_XTAL,
266 +static struct platform_device mi424wr_uart_device = {
267 + .name = "serial8250",
268 + .id = PLAT8250_DEV_PLATFORM,
269 + .dev.platform_data = mi424wr_uart_platform_data,
270 + .num_resources = ARRAY_SIZE(mi424wr_uart_resources),
271 + .resource = mi424wr_uart_resources,
274 +static struct flash_platform_data mi424wr_flash_data = {
275 + .map_name = "cfi_probe",
279 +static struct resource mi424wr_flash_resource = {
280 + .flags = IORESOURCE_MEM,
283 +static struct platform_device mi424wr_flash = {
284 + .name = "IXP4XX-Flash",
286 + .dev.platform_data = &mi424wr_flash_data,
287 + .num_resources = 1,
288 + .resource = &mi424wr_flash_resource,
291 +static int mi424wr_spi_boardinfo_setup(struct spi_board_info *bi,
292 + struct spi_master *master, void *data)
295 + strlcpy(bi->modalias, "spi-ks8995", sizeof(bi->modalias));
297 + bi->max_speed_hz = 5000000 /* Hz */;
298 + bi->bus_num = master->bus_num;
299 + bi->mode = SPI_MODE_0;
304 +static struct spi_gpio_platform_data mi424wr_spi_bus_data = {
305 + .pin_cs = MI424WR_KSSPI_SELECT,
306 + .pin_clk = MI424WR_KSSPI_CLOCK,
307 + .pin_miso = MI424WR_KSSPI_RXD,
308 + .pin_mosi = MI424WR_KSSPI_TXD,
311 + .boardinfo_setup = mi424wr_spi_boardinfo_setup,
314 +static struct gpio_led mi424wr_gpio_led[] = {
316 + .name = "moca-wan", /* green led */
317 + .gpio = MI424WR_MOCA_WAN_LED,
322 +static struct gpio_led_platform_data mi424wr_gpio_leds_data = {
324 + .leds = mi424wr_gpio_led,
327 +static struct platform_device mi424wr_gpio_leds = {
328 + .name = "leds-gpio",
330 + .dev.platform_data = &mi424wr_gpio_leds_data,
333 +static uint16_t latch_value = MI424WR_LATCH_DEFAULT;
334 +static uint16_t __iomem *iobase;
336 +static void mi424wr_latch_set_led(u8 bit, enum led_brightness value)
339 + if (((MI424WR_LATCH_MASK >> bit) & 1) ^ (value == LED_OFF))
340 + latch_value &= ~(0x1 << bit);
342 + latch_value |= (0x1 << bit);
344 + __raw_writew(latch_value, iobase);
348 +static struct latch_led mi424wr_latch_led[] = {
350 + .name = "power-alarm",
351 + .bit = MI424WR_LATCH_ALARM_LED,
354 + .name = "power-ok",
355 + .bit = MI424WR_LATCH_POWER_LED,
358 + .name = "wireless", /* green led */
359 + .bit = MI424WR_LATCH_WIRELESS_LED,
362 + .name = "inet-down", /* red led */
363 + .bit = MI424WR_LATCH_INET_DOWN_LED,
366 + .name = "inet-up", /* green led */
367 + .bit = MI424WR_LATCH_INET_OK_LED,
370 + .name = "moca-lan", /* green led */
371 + .bit = MI424WR_LATCH_MOCA_LAN_LED,
374 + .name = "wan-alarm", /* red led */
375 + .bit = MI424WR_LATCH_WAN_ALARM_LED,
379 +static struct latch_led_platform_data mi424wr_latch_leds_data = {
380 + .num_leds = ARRAY_SIZE(mi424wr_latch_led),
382 + .leds = mi424wr_latch_led,
383 + .set_led = mi424wr_latch_set_led,
386 +static struct platform_device mi424wr_latch_leds = {
387 + .name = "leds-latch",
389 + .dev.platform_data = &mi424wr_latch_leds_data,
392 +static struct platform_device mi424wr_spi_bus = {
393 + .name = "spi-gpio",
395 + .dev.platform_data = &mi424wr_spi_bus_data,
398 +static struct eth_plat_info mi424wr_wan_data = {
399 + .phy = 17, /* KS8721 */
404 +static struct eth_plat_info mi424wr_lan_data = {
405 + .phy = IXP4XX_ETH_PHY_MAX_ADDR,
406 + .phy_mask = 0x1e, /* ports 1-4 of the KS8995 switch */
411 +static struct platform_device mi424wr_npe_devices[] = {
413 + .name = "ixp4xx_eth",
414 + .id = IXP4XX_ETH_NPEC,
415 + .dev.platform_data = &mi424wr_lan_data,
416 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
418 + .name = "ixp4xx_eth",
419 + .id = IXP4XX_ETH_NPEB,
420 + .dev.platform_data = &mi424wr_wan_data,
421 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
425 +static struct eth_plat_info mi424wr_wanD_data = {
431 +static struct eth_plat_info mi424wr_lanD_data = {
432 + .phy = IXP4XX_ETH_PHY_MAX_ADDR,
433 + .phy_mask = 0x1e, /* ports 1-4 of the KS8995 switch */
438 +static struct platform_device mi424wr_npeD_devices[] = {
440 + .name = "ixp4xx_eth",
441 + .id = IXP4XX_ETH_NPEB,
442 + .dev.platform_data = &mi424wr_lanD_data,
443 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
445 + .name = "ixp4xx_eth",
446 + .id = IXP4XX_ETH_NPEC,
447 + .dev.platform_data = &mi424wr_wanD_data,
448 + .dev.coherent_dma_mask = DMA_BIT_MASK(32),
452 +static struct platform_device *mi424wr_devices[] __initdata = {
453 + &mi424wr_uart_device,
455 + &mi424wr_gpio_leds,
456 + &mi424wr_latch_leds,
460 +static void __init mi424wr_init(void)
464 + mi424wr_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
465 + mi424wr_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_8M - 1;
467 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
468 + *IXP4XX_EXP_CS1 = MI424WR_CS1_CONFIG;
470 + /* configure button as input
472 + gpio_line_config(MI424WR_BUTTON_GPIO, IXP4XX_GPIO_IN);
474 + /* Initialize LEDs and enables PCI bus.
476 + iobase = ioremap_nocache(IXP4XX_EXP_BUS_BASE(1), 0x1000);
477 + __raw_writew(latch_value, iobase);
479 + platform_add_devices(mi424wr_devices, ARRAY_SIZE(mi424wr_devices));
481 + /* Need to figure out how to detect revD.
482 + * Look for a revision argument sent by redboot.
485 + if (system_rev == revD) {
486 + platform_device_register(&mi424wr_npeD_devices[0]);
487 + platform_device_register(&mi424wr_npeD_devices[1]);
489 + platform_device_register(&mi424wr_npe_devices[0]);
490 + platform_device_register(&mi424wr_npe_devices[1]);
495 +MACHINE_START(MI424WR, "Actiontec MI424WR")
496 + /* Maintainer: Jose Vasconcellos */
497 + .map_io = ixp4xx_map_io,
498 + .init_irq = ixp4xx_init_irq,
499 + .init_time = ixp4xx_timer_init,
500 + .atag_offset = 0x0100,
501 + .init_machine = mi424wr_init,
502 +#if defined(CONFIG_PCI)
503 + .dma_zone_size = SZ_64M,
505 + .restart = ixp4xx_restart,