2 +++ b/arch/arm/mach-ixp4xx/cambria-pci.c
5 + * arch/arch/mach-ixp4xx/cambria-pci.c
7 + * PCI setup routines for Gateworks Cambria series
9 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
11 + * based on coyote-pci.c:
12 + * Copyright (C) 2002 Jungo Software Technologies.
13 + * Copyright (C) 2003 MontaVista Softwrae, Inc.
15 + * Maintainer: Imre Kaloz <kaloz@openwrt.org>
17 + * This program is free software; you can redistribute it and/or modify
18 + * it under the terms of the GNU General Public License version 2 as
19 + * published by the Free Software Foundation.
23 +#include <linux/kernel.h>
24 +#include <linux/pci.h>
25 +#include <linux/init.h>
26 +#include <linux/irq.h>
28 +#include <asm/mach-types.h>
29 +#include <mach/hardware.h>
32 +#include <asm/mach/pci.h>
34 +extern void ixp4xx_pci_preinit(void);
35 +extern int ixp4xx_setup(int nr, struct pci_sys_data *sys);
36 +extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
38 +void __init cambria_pci_preinit(void)
40 + set_irq_type(IRQ_IXP4XX_GPIO11, IRQ_TYPE_LEVEL_LOW);
41 + set_irq_type(IRQ_IXP4XX_GPIO10, IRQ_TYPE_LEVEL_LOW);
42 + set_irq_type(IRQ_IXP4XX_GPIO9, IRQ_TYPE_LEVEL_LOW);
43 + set_irq_type(IRQ_IXP4XX_GPIO8, IRQ_TYPE_LEVEL_LOW);
45 + ixp4xx_pci_preinit();
48 +static int __init cambria_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
51 + return IRQ_IXP4XX_GPIO11;
53 + return IRQ_IXP4XX_GPIO10;
55 + return IRQ_IXP4XX_GPIO9;
57 + return IRQ_IXP4XX_GPIO8;
61 +struct hw_pci cambria_pci __initdata = {
62 + .nr_controllers = 1,
63 + .preinit = cambria_pci_preinit,
64 + .swizzle = pci_std_swizzle,
65 + .setup = ixp4xx_setup,
66 + .scan = ixp4xx_scan_bus,
67 + .map_irq = cambria_map_irq,
70 +int __init cambria_pci_init(void)
72 + if (machine_is_cambria())
73 + pci_common_init(&cambria_pci);
77 +subsys_initcall(cambria_pci_init);
79 +++ b/arch/arm/mach-ixp4xx/cambria-setup.c
82 + * arch/arm/mach-ixp4xx/cambria-setup.c
84 + * Board setup for the Gateworks Cambria series
86 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
88 + * based on coyote-setup.c:
89 + * Copyright (C) 2003-2005 MontaVista Software, Inc.
91 + * Author: Imre Kaloz <kaloz@openwrt.org>
94 +#include <linux/device.h>
95 +#include <linux/i2c.h>
96 +#include <linux/i2c-gpio.h>
97 +#include <linux/i2c/at24.h>
98 +#include <linux/if_ether.h>
99 +#include <linux/init.h>
100 +#include <linux/kernel.h>
101 +#include <linux/leds.h>
102 +#include <linux/memory.h>
103 +#include <linux/netdevice.h>
104 +#include <linux/serial.h>
105 +#include <linux/serial_8250.h>
106 +#include <linux/slab.h>
107 +#include <linux/socket.h>
108 +#include <linux/types.h>
109 +#include <linux/tty.h>
111 +#include <mach/hardware.h>
112 +#include <asm/irq.h>
113 +#include <asm/mach-types.h>
114 +#include <asm/mach/arch.h>
115 +#include <asm/mach/flash.h>
116 +#include <asm/setup.h>
118 +struct cambria_board_info {
119 + unsigned char *model;
120 + void (*setup)(void);
123 +static struct cambria_board_info *cambria_info __initdata;
125 +static struct flash_platform_data cambria_flash_data = {
126 + .map_name = "cfi_probe",
130 +static struct resource cambria_flash_resource = {
131 + .flags = IORESOURCE_MEM,
134 +static struct platform_device cambria_flash = {
135 + .name = "IXP4XX-Flash",
138 + .platform_data = &cambria_flash_data,
140 + .num_resources = 1,
141 + .resource = &cambria_flash_resource,
144 +static struct i2c_gpio_platform_data cambria_i2c_gpio_data = {
149 +static struct platform_device cambria_i2c_gpio = {
150 + .name = "i2c-gpio",
153 + .platform_data = &cambria_i2c_gpio_data,
157 +static struct eth_plat_info cambria_npec_data = {
163 +static struct eth_plat_info cambria_npea_data = {
169 +static struct platform_device cambria_npec_device = {
170 + .name = "ixp4xx_eth",
171 + .id = IXP4XX_ETH_NPEC,
172 + .dev.platform_data = &cambria_npec_data,
175 +static struct platform_device cambria_npea_device = {
176 + .name = "ixp4xx_eth",
177 + .id = IXP4XX_ETH_NPEA,
178 + .dev.platform_data = &cambria_npea_data,
181 +static struct resource cambria_uart_resource = {
182 + .start = IXP4XX_UART1_BASE_PHYS,
183 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
184 + .flags = IORESOURCE_MEM,
187 +static struct plat_serial8250_port cambria_uart_data[] = {
189 + .mapbase = IXP4XX_UART1_BASE_PHYS,
190 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
191 + .irq = IRQ_IXP4XX_UART1,
192 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
193 + .iotype = UPIO_MEM,
195 + .uartclk = IXP4XX_UART_XTAL,
200 +static struct platform_device cambria_uart = {
201 + .name = "serial8250",
202 + .id = PLAT8250_DEV_PLATFORM,
204 + .platform_data = cambria_uart_data,
206 + .num_resources = 1,
207 + .resource = &cambria_uart_resource,
210 +static struct resource cambria_pata_resources[] = {
212 + .flags = IORESOURCE_MEM
215 + .flags = IORESOURCE_MEM,
219 + .start = IRQ_IXP4XX_GPIO12,
220 + .end = IRQ_IXP4XX_GPIO12,
221 + .flags = IORESOURCE_IRQ,
225 +static struct ixp4xx_pata_data cambria_pata_data = {
226 + .cs0_bits = 0xbfff3c03,
227 + .cs1_bits = 0xbfff3c03,
230 +static struct platform_device cambria_pata = {
231 + .name = "pata_ixp4xx_cf",
233 + .dev.platform_data = &cambria_pata_data,
234 + .num_resources = ARRAY_SIZE(cambria_pata_resources),
235 + .resource = cambria_pata_resources,
238 +static struct gpio_led cambria_gpio_leds[] = {
240 + .name = "user", /* green led */
246 +static struct gpio_led_platform_data cambria_gpio_leds_data = {
248 + .leds = cambria_gpio_leds,
251 +static struct platform_device cambria_gpio_leds_device = {
252 + .name = "leds-gpio",
254 + .dev.platform_data = &cambria_gpio_leds_data,
257 +static struct latch_led cambria_latch_leds[] = {
259 + .name = "ledA", /* green led */
263 + .name = "ledB", /* green led */
267 + .name = "ledC", /* green led */
271 + .name = "ledD", /* green led */
275 + .name = "ledE", /* green led */
279 + .name = "ledF", /* green led */
283 + .name = "ledG", /* green led */
287 + .name = "ledH", /* green led */
292 +static struct latch_led_platform_data cambria_latch_leds_data = {
294 + .leds = cambria_latch_leds,
298 +static struct platform_device cambria_latch_leds_device = {
299 + .name = "leds-latch",
301 + .dev.platform_data = &cambria_latch_leds_data,
304 +static struct resource cambria_usb0_resources[] = {
306 + .start = 0xCD000000,
308 + .flags = IORESOURCE_MEM,
312 + .flags = IORESOURCE_IRQ,
316 +static struct resource cambria_usb1_resources[] = {
318 + .start = 0xCE000000,
320 + .flags = IORESOURCE_MEM,
324 + .flags = IORESOURCE_IRQ,
328 +static u64 ehci_dma_mask = ~(u32)0;
330 +static struct platform_device cambria_usb0_device = {
331 + .name = "ixp4xx-ehci",
333 + .resource = cambria_usb0_resources,
334 + .num_resources = ARRAY_SIZE(cambria_usb0_resources),
336 + .dma_mask = &ehci_dma_mask,
337 + .coherent_dma_mask = 0xffffffff,
341 +static struct platform_device cambria_usb1_device = {
342 + .name = "ixp4xx-ehci",
344 + .resource = cambria_usb1_resources,
345 + .num_resources = ARRAY_SIZE(cambria_usb1_resources),
347 + .dma_mask = &ehci_dma_mask,
348 + .coherent_dma_mask = 0xffffffff,
352 +static struct platform_device *cambria_devices[] __initdata = {
358 +static void __init cambria_gw23xx_setup(void)
360 + platform_device_register(&cambria_npec_device);
361 + platform_device_register(&cambria_npea_device);
364 +static void __init cambria_gw2350_setup(void)
366 + platform_device_register(&cambria_npec_device);
367 + platform_device_register(&cambria_npea_device);
369 + platform_device_register(&cambria_usb0_device);
370 + platform_device_register(&cambria_usb1_device);
372 + platform_device_register(&cambria_gpio_leds_device);
375 +static void __init cambria_gw2358_setup(void)
377 + platform_device_register(&cambria_npec_device);
378 + platform_device_register(&cambria_npea_device);
380 + platform_device_register(&cambria_usb0_device);
381 + platform_device_register(&cambria_usb1_device);
383 + platform_device_register(&cambria_pata);
385 + platform_device_register(&cambria_latch_leds_device);
388 +static struct cambria_board_info cambria_boards[] __initdata = {
391 + .setup = cambria_gw2350_setup,
394 + .setup = cambria_gw2358_setup,
398 +static struct cambria_board_info * __init cambria_find_board_info(char *model)
403 + for (i = 0; i < ARRAY_SIZE(cambria_boards); i++) {
404 + struct cambria_board_info *info = &cambria_boards[i];
405 + if (strcmp(info->model, model) == 0)
412 +static struct memory_accessor *at24_mem_acc;
414 +static void at24_setup(struct memory_accessor *mem_acc, void *context)
416 + char mac_addr[ETH_ALEN];
419 + at24_mem_acc = mem_acc;
421 + /* Read MAC addresses */
422 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x0, 6) == 6) {
423 + memcpy(&cambria_npec_data.hwaddr, mac_addr, ETH_ALEN);
425 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x6, 6) == 6) {
426 + memcpy(&cambria_npea_data.hwaddr, mac_addr, ETH_ALEN);
429 + /* Read the first 6 bytes of the model number */
430 + if (at24_mem_acc->read(at24_mem_acc, model, 0x20, 6) == 6) {
431 + cambria_info = cambria_find_board_info(model);
436 +static struct at24_platform_data cambria_eeprom_info = {
439 + .flags = AT24_FLAG_READONLY,
440 + .setup = at24_setup,
443 +static struct i2c_board_info __initdata cambria_i2c_board_info[] = {
445 + I2C_BOARD_INFO("ds1672", 0x68),
448 + I2C_BOARD_INFO("ad7418", 0x28),
451 + I2C_BOARD_INFO("24c08", 0x51),
452 + .platform_data = &cambria_eeprom_info
456 +static void __init cambria_init(void)
460 + cambria_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
461 + cambria_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
463 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
464 + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
466 + platform_add_devices(cambria_devices, ARRAY_SIZE(cambria_devices));
468 + cambria_pata_resources[0].start = 0x53e00000;
469 + cambria_pata_resources[0].end = 0x53e3ffff;
471 + cambria_pata_resources[1].start = 0x53e40000;
472 + cambria_pata_resources[1].end = 0x53e7ffff;
474 + cambria_pata_data.cs0_cfg = IXP4XX_EXP_CS3;
475 + cambria_pata_data.cs1_cfg = IXP4XX_EXP_CS3;
477 + i2c_register_board_info(0, cambria_i2c_board_info,
478 + ARRAY_SIZE(cambria_i2c_board_info));
481 +static int __init cambria_model_setup(void)
483 + if (!machine_is_cambria())
486 + if (cambria_info) {
487 + printk(KERN_DEBUG "Running on Gateworks Cambria %s\n",
488 + cambria_info->model);
489 + cambria_info->setup();
491 + printk(KERN_INFO "Unknown/missing Cambria model number"
492 + " -- defaults will be used\n");
493 + cambria_gw23xx_setup();
498 +late_initcall(cambria_model_setup);
500 +MACHINE_START(CAMBRIA, "Gateworks Cambria series")
501 + /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
502 + .map_io = ixp4xx_map_io,
503 + .init_irq = ixp4xx_init_irq,
504 + .timer = &ixp4xx_timer,
505 + .boot_params = 0x0100,
506 + .init_machine = cambria_init,
508 --- a/arch/arm/mach-ixp4xx/Kconfig
509 +++ b/arch/arm/mach-ixp4xx/Kconfig
510 @@ -25,6 +25,14 @@ config MACH_AVILA
511 Avila Network Platform. For more information on this platform,
512 see <file:Documentation/arm/IXP4xx>.
518 + Say 'Y' here if you want your kernel to support the Gateworks
519 + Cambria series. For more information on this platform,
520 + see <file:Documentation/arm/IXP4xx>.
524 depends on MACH_AVILA
525 @@ -222,7 +230,7 @@ config CPU_IXP46X
529 - depends on MACH_KIXRP435
530 + depends on MACH_KIXRP435 || MACH_CAMBRIA
534 --- a/arch/arm/mach-ixp4xx/Makefile
535 +++ b/arch/arm/mach-ixp4xx/Makefile
536 @@ -7,6 +7,7 @@ obj-pci-n :=
538 obj-pci-$(CONFIG_ARCH_IXDP4XX) += ixdp425-pci.o
539 obj-pci-$(CONFIG_MACH_AVILA) += avila-pci.o
540 +obj-pci-$(CONFIG_MACH_CAMBRIA) += cambria-pci.o
541 obj-pci-$(CONFIG_MACH_IXDPG425) += ixdpg425-pci.o
542 obj-pci-$(CONFIG_ARCH_ADI_COYOTE) += coyote-pci.o
543 obj-pci-$(CONFIG_MACH_GTWX5715) += gtwx5715-pci.o
544 @@ -30,6 +31,7 @@ obj-y += common.o
546 obj-$(CONFIG_ARCH_IXDP4XX) += ixdp425-setup.o
547 obj-$(CONFIG_MACH_AVILA) += avila-setup.o
548 +obj-$(CONFIG_MACH_CAMBRIA) += cambria-setup.o
549 obj-$(CONFIG_MACH_IXDPG425) += coyote-setup.o
550 obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-setup.o
551 obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o