# NOTE: for now it's for only IXP4xx in big endian mode
# list of supported boards, in "boardname machtypeid" format
-for board in "avila 526" "gateway7001 731" "nslu2 597" "nas100d 865" "wg302v2 890" "pronghornmetro 1040" "compex 1273" "wrt300nv2 1077"
+for board in "avila 526" "gateway7001 731" "nslu2 597" "nas100d 865" "wg302v2 890" "pronghornmetro 1040" "compex 1273" "wrt300nv2 1077" "loft 849"
do
set -- $board
hexid=$(printf %x\\n $2)
# CONFIG_ARCH_AAEC2000 is not set
# CONFIG_ARCH_ADI_COYOTE is not set
# CONFIG_ARCH_AT91 is not set
-CONFIG_ARCH_AVILA=y
# CONFIG_ARCH_CLPS711X is not set
# CONFIG_ARCH_CLPS7500 is not set
# CONFIG_ARCH_CO285 is not set
CONFIG_LEGACY_PTY_COUNT=256
# CONFIG_LIBCRC32C is not set
# CONFIG_LLC2 is not set
+CONFIG_MACH_AVILA=y
CONFIG_MACH_COMPEX=y
CONFIG_MACH_GATEWAY7001=y
# CONFIG_MACH_GTWX5715 is not set
# CONFIG_MACH_IXDP465 is not set
# CONFIG_MACH_IXDPG425 is not set
+CONFIG_MACH_LOFT=y
CONFIG_MACH_NAS100D=y
CONFIG_MACH_NSLU2=y
CONFIG_MACH_PRONGHORNMETRO=y
# CONFIG_SENSORS_DS1337 is not set
# CONFIG_SENSORS_DS1374 is not set
# CONFIG_SENSORS_DS1621 is not set
-# CONFIG_SENSORS_EEPROM is not set
+CONFIG_SENSORS_EEPROM=y
# CONFIG_SENSORS_F71805F is not set
# CONFIG_SENSORS_FSCHER is not set
# CONFIG_SENSORS_FSCPOS is not set
--- /dev/null
+diff -Nur linux-2.6.19.2/arch/arm/mach-ixp4xx/ixdp425-pci.c linux-2.6.19.2-owrt/arch/arm/mach-ixp4xx/ixdp425-pci.c
+--- linux-2.6.19.2/arch/arm/mach-ixp4xx/ixdp425-pci.c 2007-04-15 14:26:04.000000000 +0200
++++ linux-2.6.19.2-owrt/arch/arm/mach-ixp4xx/ixdp425-pci.c 2007-05-10 11:10:40.000000000 +0200
+@@ -66,7 +66,7 @@
+ int __init ixdp425_pci_init(void)
+ {
+ if (machine_is_ixdp425() || machine_is_ixcdp1100() ||
+- machine_is_avila() || machine_is_ixdp465() || machine_is_compex())
++ machine_is_ixdp465() || machine_is_compex())
+ pci_common_init(&ixdp425_pci);
+ return 0;
+ }
+diff -Nur linux-2.6.19.2/arch/arm/mach-ixp4xx/ixdp425-setup.c linux-2.6.19.2-owrt/arch/arm/mach-ixp4xx/ixdp425-setup.c
+--- linux-2.6.19.2/arch/arm/mach-ixp4xx/ixdp425-setup.c 2007-04-15 14:26:49.000000000 +0200
++++ linux-2.6.19.2-owrt/arch/arm/mach-ixp4xx/ixdp425-setup.c 2007-05-10 11:10:01.000000000 +0200
+@@ -205,23 +205,3 @@
+ .init_machine = ixdp425_init,
+ MACHINE_END
+ #endif
+-
+-/*
+- * Avila is functionally equivalent to IXDP425 except that it adds
+- * a CF IDE slot hanging off the expansion bus. When we have a
+- * driver for IXP4xx CF IDE with driver model support we'll move
+- * Avila to it's own setup file.
+- */
+-#ifdef CONFIG_ARCH_AVILA
+-MACHINE_START(AVILA, "Gateworks Avila Network Platform")
+- /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */
+- .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
+- .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
+- .map_io = ixp4xx_map_io,
+- .init_irq = ixp4xx_init_irq,
+- .timer = &ixp4xx_timer,
+- .boot_params = 0x0100,
+- .init_machine = ixdp425_init,
+-MACHINE_END
+-#endif
+-
--- /dev/null
+This patch adds support for the Gateworks Avila Network Platform in
+a separate set of setup files to the IXDP425. This is necessary now
+that a driver for the Avila CF card slot is available. It also adds
+support for a minor variant on the Avila board known as the Loft,
+which has a different number of maximum PCI devices.
+
+Signed-off-by: Michael-Luke Jones <mlj28 <at> cam.ac.uk>
+
+Index: linux-2.6.19/arch/arm/mach-ixp4xx/Kconfig
+===================================================================
+--- linux-2.6.19.orig/arch/arm/mach-ixp4xx/Kconfig
++++ linux-2.6.19/arch/arm/mach-ixp4xx/Kconfig
+@@ -17,7 +17,7 @@ config MACH_NSLU2
+ NSLU2 NAS device. For more information on this platform,
+ see http://www.nslu2-linux.org
+
+-config ARCH_AVILA
++config MACH_AVILA
+ bool "Avila"
+ select PCI
+ help
+@@ -25,6 +25,14 @@ config ARCH_AVILA
+ Avila Network Platform. For more information on this platform,
+ see <file:Documentation/arm/IXP4xx>.
+
++config MACH_LOFT
++ bool "Loft"
++ depends on MACH_AVILA
++ help
++ Say 'Y' here if you want your kernel to support the Giant
++ Shoulder Inc Loft board (a minor variation on the standard
++ Gateworks Avila Network Platform).
++
+ config ARCH_ADI_COYOTE
+ bool "Coyote"
+ select PCI
+@@ -86,7 +94,7 @@ config MACH_NAS100D
+ #
+ config ARCH_IXDP4XX
+ bool
+- depends on ARCH_IXDP425 || ARCH_AVILA || MACH_IXDP465
++ depends on ARCH_IXDP425 || MACH_IXDP465
+ default y
+
+ #
+Index: linux-2.6.19/arch/arm/mach-ixp4xx/Makefile
+===================================================================
+--- linux-2.6.19.orig/arch/arm/mach-ixp4xx/Makefile
++++ linux-2.6.19/arch/arm/mach-ixp4xx/Makefile
+@@ -6,6 +6,7 @@ obj-pci-y :=
+ obj-pci-n :=
+
+ obj-pci-$(CONFIG_ARCH_IXDP4XX) += ixdp425-pci.o
++obj-pci-$(CONFIG_MACH_AVILA) += avila-pci.o
+ obj-pci-$(CONFIG_MACH_IXDPG425) += ixdpg425-pci.o
+ obj-pci-$(CONFIG_ARCH_ADI_COYOTE) += coyote-pci.o
+ obj-pci-$(CONFIG_MACH_GTWX5715) += gtwx5715-pci.o
+@@ -15,6 +16,7 @@ obj-pci-$(CONFIG_MACH_NAS100D) += nas10
+ obj-y += common.o
+
+ obj-$(CONFIG_ARCH_IXDP4XX) += ixdp425-setup.o
++obj-$(CONFIG_MACH_AVILA) += avila-setup.o
+ obj-$(CONFIG_MACH_IXDPG425) += coyote-setup.o
+ obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-setup.o
+ obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o
+Index: linux-2.6.19/arch/arm/mach-ixp4xx/avila-pci.c
+===================================================================
+--- /dev/null
++++ linux-2.6.19/arch/arm/mach-ixp4xx/avila-pci.c
+@@ -0,0 +1,78 @@
++/*
++ * arch/arm/mach-ixp4xx/avila-pci.c
++ *
++ * Gateworks Avila board-level PCI initialization
++ *
++ * Author: Michael-Luke Jones <mlj28@cam.ac.uk>
++ *
++ * Based on ixdp-pci.c
++ * Copyright (C) 2002 Intel Corporation.
++ * Copyright (C) 2003-2004 MontaVista Software, Inc.
++ *
++ * Maintainer: Deepak Saxena <dsaxena@plexity.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 <linux/delay.h>
++
++#include <asm/mach/pci.h>
++#include <asm/irq.h>
++#include <asm/hardware.h>
++#include <asm/mach-types.h>
++
++void __init avila_pci_preinit(void)
++{
++ set_irq_type(IRQ_AVILA_PCI_INTA, IRQT_LOW);
++ set_irq_type(IRQ_AVILA_PCI_INTB, IRQT_LOW);
++ set_irq_type(IRQ_AVILA_PCI_INTC, IRQT_LOW);
++ set_irq_type(IRQ_AVILA_PCI_INTD, IRQT_LOW);
++
++ ixp4xx_pci_preinit();
++}
++
++static int __init avila_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
++{
++ static int pci_irq_table[AVILA_PCI_IRQ_LINES] = {
++ IRQ_AVILA_PCI_INTA,
++ IRQ_AVILA_PCI_INTB,
++ IRQ_AVILA_PCI_INTC,
++ IRQ_AVILA_PCI_INTD
++ };
++
++ int irq = -1;
++
++ if (slot >= 1 &&
++ slot <= (machine_is_loft() ? LOFT_PCI_MAX_DEV : AVILA_PCI_MAX_DEV) &&
++ pin >= 1 && pin <= AVILA_PCI_IRQ_LINES) {
++ irq = pci_irq_table[(slot + pin - 2) % 4];
++ }
++
++ return irq;
++}
++
++struct hw_pci avila_pci __initdata = {
++ .nr_controllers = 1,
++ .preinit = avila_pci_preinit,
++ .swizzle = pci_std_swizzle,
++ .setup = ixp4xx_setup,
++ .scan = ixp4xx_scan_bus,
++ .map_irq = avila_map_irq,
++};
++
++int __init avila_pci_init(void)
++{
++ if (machine_is_avila() || machine_is_loft())
++ pci_common_init(&avila_pci);
++ return 0;
++}
++
++subsys_initcall(avila_pci_init);
++
+Index: linux-2.6.19/arch/arm/mach-ixp4xx/avila-setup.c
+===================================================================
+--- /dev/null
++++ linux-2.6.19/arch/arm/mach-ixp4xx/avila-setup.c
+@@ -0,0 +1,152 @@
++/*
++ * arch/arm/mach-ixp4xx/avila-setup.c
++ *
++ * Gateworks Avila board-setup
++ *
++ * Author: Michael-Luke Jones <mlj28@cam.ac.uk>
++ *
++ * Based on ixdp-setup.c
++ * Copyright (C) 2003-2005 MontaVista Software, Inc.
++ *
++ * Author: Deepak Saxena <dsaxena@plexity.net>
++ */
++
++#include <linux/kernel.h>
++#include <linux/init.h>
++#include <linux/device.h>
++#include <linux/serial.h>
++#include <linux/tty.h>
++#include <linux/serial_8250.h>
++#include <linux/slab.h>
++
++#include <asm/types.h>
++#include <asm/setup.h>
++#include <asm/memory.h>
++#include <asm/hardware.h>
++#include <asm/mach-types.h>
++#include <asm/irq.h>
++#include <asm/mach/arch.h>
++#include <asm/mach/flash.h>
++
++static struct flash_platform_data avila_flash_data = {
++ .map_name = "cfi_probe",
++ .width = 2,
++};
++
++static struct resource avila_flash_resource = {
++ .flags = IORESOURCE_MEM,
++};
++
++static struct platform_device avila_flash = {
++ .name = "IXP4XX-Flash",
++ .id = 0,
++ .dev = {
++ .platform_data = &avila_flash_data,
++ },
++ .num_resources = 1,
++ .resource = &avila_flash_resource,
++};
++
++static struct ixp4xx_i2c_pins avila_i2c_gpio_pins = {
++ .sda_pin = AVILA_SDA_PIN,
++ .scl_pin = AVILA_SCL_PIN,
++};
++
++static struct platform_device avila_i2c_controller = {
++ .name = "IXP4XX-I2C",
++ .id = 0,
++ .dev = {
++ .platform_data = &avila_i2c_gpio_pins,
++ },
++ .num_resources = 0
++};
++
++static struct resource avila_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 avila_uart_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 avila_uart = {
++ .name = "serial8250",
++ .id = PLAT8250_DEV_PLATFORM,
++ .dev.platform_data = avila_uart_data,
++ .num_resources = 2,
++ .resource = avila_uart_resources
++};
++
++static struct platform_device *avila_devices[] __initdata = {
++ &avila_i2c_controller,
++ &avila_flash,
++ &avila_uart
++};
++
++static void __init avila_init(void)
++{
++ ixp4xx_sys_init();
++
++ avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
++ avila_flash_resource.end =
++ IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
++
++ platform_add_devices(avila_devices, ARRAY_SIZE(avila_devices));
++}
++
++MACHINE_START(AVILA, "Gateworks Avila Network Platform")
++ /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */
++ .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
++ .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
++ .map_io = ixp4xx_map_io,
++ .init_irq = ixp4xx_init_irq,
++ .timer = &ixp4xx_timer,
++ .boot_params = 0x0100,
++ .init_machine = avila_init,
++MACHINE_END
++
++ /*
++ * Loft is functionally equivalent to Avila except that it has a
++ * different number for the maximum PCI devices. The MACHINE
++ * structure below is identical to Avila except for the comment.
++ */
++#ifdef CONFIG_MACH_LOFT
++MACHINE_START(LOFT, "Giant Shoulder Inc Loft board")
++ /* Maintainer: Tom Billman <kernel@giantshoulderinc.com> */
++ .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
++ .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
++ .map_io = ixp4xx_map_io,
++ .init_irq = ixp4xx_init_irq,
++ .timer = &ixp4xx_timer,
++ .boot_params = 0x0100,
++ .init_machine = avila_init,
++MACHINE_END
++#endif
++
+Index: linux-2.6.19/include/asm-arm/arch-ixp4xx/avila.h
+===================================================================
+--- /dev/null
++++ linux-2.6.19/include/asm-arm/arch-ixp4xx/avila.h
+@@ -0,0 +1,39 @@
++/*
++ * include/asm-arm/arch-ixp4xx/avila.h
++ *
++ * Gateworks Avila platform specific definitions
++ *
++ * Author: Michael-Luke Jones <mlj28@cam.ac.uk>
++ *
++ * Based on ixdp425.h
++ * Author: Deepak Saxena <dsaxena@plexity.net>
++ *
++ * Copyright 2004 (c) MontaVista, Software, Inc.
++ *
++ * This file is licensed under the terms of the GNU General Public
++ * License version 2. This program is licensed "as is" without any
++ * warranty of any kind, whether express or implied.
++ */
++
++#ifndef __ASM_ARCH_HARDWARE_H__
++#error "Do not include this directly, instead #include <asm/hardware.h>"
++#endif
++
++#define AVILA_SDA_PIN 7
++#define AVILA_SCL_PIN 6
++
++/*
++ * AVILA PCI IRQs
++ */
++#define AVILA_PCI_MAX_DEV 4
++#define LOFT_PCI_MAX_DEV 6
++#define AVILA_PCI_IRQ_LINES 4
++
++
++/* PCI controller GPIO to IRQ pin mappings */
++#define AVILA_PCI_INTA_PIN 11
++#define AVILA_PCI_INTB_PIN 10
++#define AVILA_PCI_INTC_PIN 9
++#define AVILA_PCI_INTD_PIN 8
++
++
+Index: linux-2.6.19/include/asm-arm/arch-ixp4xx/hardware.h
+===================================================================
+--- linux-2.6.19.orig/include/asm-arm/arch-ixp4xx/hardware.h
++++ linux-2.6.19/include/asm-arm/arch-ixp4xx/hardware.h
+@@ -42,6 +42,7 @@ extern unsigned int processor_id;
+
+ /* Platform specific details */
+ #include "ixdp425.h"
++#include "avila.h"
+ #include "coyote.h"
+ #include "prpmc1100.h"
+ #include "nslu2.h"
+Index: linux-2.6.19/include/asm-arm/arch-ixp4xx/irqs.h
+===================================================================
+--- linux-2.6.19.orig/include/asm-arm/arch-ixp4xx/irqs.h
++++ linux-2.6.19/include/asm-arm/arch-ixp4xx/irqs.h
+@@ -79,6 +79,15 @@
+ #define IRQ_IXDP425_PCI_INTD IRQ_IXP4XX_GPIO8
+
+ /*
++ * Gateworks Avila board IRQs
++ */
++#define IRQ_AVILA_PCI_INTA IRQ_IXP4XX_GPIO11
++#define IRQ_AVILA_PCI_INTB IRQ_IXP4XX_GPIO10
++#define IRQ_AVILA_PCI_INTC IRQ_IXP4XX_GPIO9
++#define IRQ_AVILA_PCI_INTD IRQ_IXP4XX_GPIO8
++
++
++/*
+ * PrPMC1100 Board IRQs
+ */
+ #define IRQ_PRPMC1100_PCI_INTA IRQ_IXP4XX_GPIO11
--- /dev/null
+---
+ arch/arm/mach-ixp4xx/avila-setup.c | 50 ++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 49 insertions(+), 1 deletion(-)
+
+Index: linux-2.6.19/arch/arm/mach-ixp4xx/avila-setup.c
+===================================================================
+--- linux-2.6.19.orig/arch/arm/mach-ixp4xx/avila-setup.c
++++ linux-2.6.19/arch/arm/mach-ixp4xx/avila-setup.c
+@@ -104,10 +104,60 @@ static struct platform_device avila_uart
+ .resource = avila_uart_resources
+ };
+
++/* MACs */
++static struct resource res_mac0 = {
++ .start = IXP4XX_EthB_BASE_PHYS,
++ .end = IXP4XX_EthB_BASE_PHYS + 0x1ff,
++ .flags = IORESOURCE_MEM,
++};
++
++static struct resource res_mac1 = {
++ .start = IXP4XX_EthC_BASE_PHYS,
++ .end = IXP4XX_EthC_BASE_PHYS + 0x1ff,
++ .flags = IORESOURCE_MEM,
++};
++
++static struct mac_plat_info plat_mac0 = {
++ .npe_id = 1,
++ .phy_id = 0,
++ .eth_id = 0,
++ .rxq_id = 27,
++ .txq_id = 24,
++ .rxdoneq_id = 4,
++};
++
++static struct mac_plat_info plat_mac1 = {
++ .npe_id = 2,
++ .phy_id = 1,
++ .eth_id = 1,
++ .rxq_id = 28,
++ .txq_id = 25,
++ .rxdoneq_id = 5,
++};
++
++static struct platform_device mac0 = {
++ .name = "ixp4xx_mac",
++ .id = 0,
++ .dev.platform_data = &plat_mac0,
++ .num_resources = 1,
++ .resource = &res_mac0,
++};
++
++static struct platform_device mac1 = {
++ .name = "ixp4xx_mac",
++ .id = 1,
++ .dev.platform_data = &plat_mac1,
++ .num_resources = 1,
++ .resource = &res_mac1,
++};
++
+ static struct platform_device *avila_devices[] __initdata = {
+ &avila_i2c_controller,
+ &avila_flash,
+- &avila_uart
++ &avila_uart,
++ &mac0,
++ &mac1,
++
+ };
+
+ static void __init avila_init(void)
--- /dev/null
+Index: linux-2.6.19/arch/arm/mach-ixp4xx/avila-setup.c
+===================================================================
+--- linux-2.6.19.orig/arch/arm/mach-ixp4xx/avila-setup.c 2007-01-23 03:12:36.000000000 -0800
++++ linux-2.6.19/arch/arm/mach-ixp4xx/avila-setup.c 2007-01-23 03:12:47.000000000 -0800
+@@ -18,6 +18,10 @@
+ #include <linux/tty.h>
+ #include <linux/serial_8250.h>
+ #include <linux/slab.h>
++#ifdef CONFIG_SENSORS_EEPROM
++#include <linux/i2c.h>
++#include <linux/eeprom.h>
++#endif
+
+ #include <asm/types.h>
+ #include <asm/setup.h>
+@@ -198,9 +202,34 @@
+ &avila_npe_ucode,
+ };
+
++#ifdef CONFIG_SENSORS_EEPROM
++static int loft_eeprom_do(struct notifier_block *self, unsigned long event, void *t)
++{
++ struct eeprom_data *data = t;
++
++ char macs[12];
++
++ /* The MACs are the first 12 bytes in the eeprom at address 0x51 */
++ if (event == EEPROM_REGISTER && data->client.addr == 0x51) {
++ data->attr->read(&data->client.dev.kobj, macs, 0, 12);
++ memcpy(&plat_mac0.hwaddr, macs, 6);
++ memcpy(&plat_mac1.hwaddr, macs + 6, 6);
++ }
++
++ return NOTIFY_DONE;
++}
++
++static struct notifier_block loft_eeprom_notifier = {
++ .notifier_call = loft_eeprom_do
++};
++#endif
++
+ static void __init avila_init(void)
+ {
+ ixp4xx_sys_init();
++#ifdef CONFIG_SENSORS_EEPROM
++ register_eeprom_notifier(&loft_eeprom_notifier);
++#endif
+
+ avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
+ avila_flash_resource.end =
--- /dev/null
+diff -Nur linux-2.6.19.2/arch/arm/mach-ixp4xx/avila-setup.c linux-2.6.19.2-owrt/arch/arm/mach-ixp4xx/avila-setup.c
+--- linux-2.6.19.2/arch/arm/mach-ixp4xx/avila-setup.c 2007-05-10 12:30:54.000000000 +0200
++++ linux-2.6.19.2-owrt/arch/arm/mach-ixp4xx/avila-setup.c 2007-05-10 12:33:08.000000000 +0200
+@@ -155,13 +155,23 @@
+ .resource = &res_mac1,
+ };
+
++struct npe_ucode_platform_data avila_npe_ucode_data = {
++ .mtd_partition = "RedBoot",
++};
++
++static struct platform_device avila_npe_ucode = {
++ .name = "ixp4xx_npe_ucode",
++ .id = 0,
++ .dev.platform_data = &avila_npe_ucode_data,
++};
++
+ static struct platform_device *avila_devices[] __initdata = {
+ &avila_i2c_controller,
+ &avila_flash,
+ &avila_uart,
+ &mac0,
+ &mac1,
+-
++ &avila_npe_ucode,
+ };
+
+ #ifdef CONFIG_SENSORS_EEPROM
--- /dev/null
+Add EEPROM notifiers
+
+These help board level code by allowing a callback when EEPROMs are
+loaded, this permits system level configuration to be loaded from the
+EEPROM. This is particularly useful when the ethernet MAC ids are
+stored in EEPROM and when the ethernet hardware is generic (so it
+has no board level knowledge), then the MACs can be loaded into
+the 'maclist' code and read out by the ethernet config.
+
+Signed-off-by: John Bowler <jbowler@acm.org>
+
+Index: linux-2.6.19/drivers/i2c/chips/eeprom.c
+===================================================================
+--- linux-2.6.19.orig/drivers/i2c/chips/eeprom.c
++++ linux-2.6.19/drivers/i2c/chips/eeprom.c
+@@ -34,6 +34,8 @@
+ #include <linux/jiffies.h>
+ #include <linux/i2c.h>
+ #include <linux/mutex.h>
++#include <linux/notifier.h>
++#include <linux/eeprom.h>
+
+ /* Addresses to scan */
+ static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
+@@ -42,26 +44,7 @@ static unsigned short normal_i2c[] = { 0
+ /* Insmod parameters */
+ I2C_CLIENT_INSMOD_1(eeprom);
+
+-
+-/* Size of EEPROM in bytes */
+-#define EEPROM_SIZE 256
+-
+-/* possible types of eeprom devices */
+-enum eeprom_nature {
+- UNKNOWN,
+- VAIO,
+-};
+-
+-/* Each client has this additional data */
+-struct eeprom_data {
+- struct i2c_client client;
+- struct mutex update_lock;
+- u8 valid; /* bitfield, bit!=0 if slice is valid */
+- unsigned long last_updated[8]; /* In jiffies, 8 slices */
+- u8 data[EEPROM_SIZE]; /* Register values */
+- enum eeprom_nature nature;
+-};
+-
++ATOMIC_NOTIFIER_HEAD(eeprom_chain);
+
+ static int eeprom_attach_adapter(struct i2c_adapter *adapter);
+ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind);
+@@ -190,6 +173,7 @@ static int eeprom_detect(struct i2c_adap
+ data->valid = 0;
+ mutex_init(&data->update_lock);
+ data->nature = UNKNOWN;
++ data->attr = &eeprom_attr;
+
+ /* Tell the I2C layer a new client has arrived */
+ if ((err = i2c_attach_client(new_client)))
+@@ -213,6 +197,9 @@ static int eeprom_detect(struct i2c_adap
+ if (err)
+ goto exit_detach;
+
++ /* call the notifier chain */
++ atomic_notifier_call_chain(&eeprom_chain, EEPROM_REGISTER, data);
++
+ return 0;
+
+ exit_detach:
+@@ -238,6 +225,41 @@ static int eeprom_detach_client(struct i
+ return 0;
+ }
+
++/**
++ * register_eeprom_notifier - register a 'user' of EEPROM devices.
++ * @nb: pointer to notifier info structure
++ *
++ * Registers a callback function to be called upon detection
++ * of an EEPROM device. Detection invokes the 'add' callback
++ * with the kobj of the mutex and a bin_attribute which allows
++ * read from the EEPROM. The intention is that the notifier
++ * will be able to read system configuration from the notifier.
++ *
++ * Only EEPROMs detected *after* the addition of the notifier
++ * are notified. I.e. EEPROMs already known to the system
++ * will not be notified - add the notifier from board level
++ * code!
++ */
++int register_eeprom_notifier(struct notifier_block *nb)
++{
++ return atomic_notifier_chain_register(&eeprom_chain, nb);
++}
++
++/**
++ * unregister_eeprom_notifier - unregister a 'user' of EEPROM devices.
++ * @old: pointer to notifier info structure
++ *
++ * Removes a callback function from the list of 'users' to be
++ * notified upon detection of EEPROM devices.
++ */
++int unregister_eeprom_notifier(struct notifier_block *nb)
++{
++ return atomic_notifier_chain_unregister(&eeprom_chain, nb);
++}
++
++EXPORT_SYMBOL_GPL(register_eeprom_notifier);
++EXPORT_SYMBOL_GPL(unregister_eeprom_notifier);
++
+ static int __init eeprom_init(void)
+ {
+ return i2c_add_driver(&eeprom_driver);
+Index: linux-2.6.19/include/linux/eeprom.h
+===================================================================
+--- /dev/null
++++ linux-2.6.19/include/linux/eeprom.h
+@@ -0,0 +1,71 @@
++#ifndef _LINUX_EEPROM_H
++#define _LINUX_EEPROM_H
++/*
++ * $Id: 45-eeprom-new-notifier.patch,v 1.2 2006/03/27 11:10:19 azummo Exp $
++ *
++ * Copyright (C) 2006 John Bowler
++ */
++
++/*
++ * 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
++ */
++
++#ifndef __KERNEL__
++#error This is a kernel header
++#endif
++
++#include <linux/list.h>
++#include <linux/kobject.h>
++#include <linux/sysfs.h>
++
++/* Size of EEPROM in bytes */
++#define EEPROM_SIZE 256
++
++/* possible types of eeprom devices */
++enum eeprom_nature {
++ UNKNOWN,
++ VAIO,
++};
++
++/* Each client has this additional data */
++struct eeprom_data {
++ struct i2c_client client;
++ struct mutex update_lock;
++ u8 valid; /* bitfield, bit!=0 if slice is valid */
++ unsigned long last_updated[8]; /* In jiffies, 8 slices */
++ u8 data[EEPROM_SIZE]; /* Register values */
++ enum eeprom_nature nature;
++ struct bin_attribute *attr;
++};
++
++/*
++ * This is very basic.
++ *
++ * If an EEPROM is detected on the I2C bus (this only works for
++ * I2C EEPROMs) the notifier chain is called with
++ * both the I2C information and the kobject for the sysfs
++ * device which has been registers. It is then possible to
++ * read from the device via the bin_attribute::read method
++ * to extract configuration information.
++ *
++ * Register the notifier in the board level code, there is no
++ * need to unregister it but you can if you want (it will save
++ * a little bit or kernel memory to do so).
++ */
++
++extern int register_eeprom_notifier(struct notifier_block *nb);
++extern int unregister_eeprom_notifier(struct notifier_block *nb);
++
++#endif /* _LINUX_EEPROM_H */
+Index: linux-2.6.19/include/linux/notifier.h
+===================================================================
+--- linux-2.6.19.orig/include/linux/notifier.h
++++ linux-2.6.19/include/linux/notifier.h
+@@ -187,5 +187,8 @@ extern int srcu_notifier_call_chain(stru
+ #define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */
+ #define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */
+
++/* eeprom notifier chain */
++#define EEPROM_REGISTER 0x0001
++
+ #endif /* __KERNEL__ */
+ #endif /* _LINUX_NOTIFIER_H */