summaryrefslogtreecommitdiff
path: root/packages/linux
diff options
context:
space:
mode:
authorJohn Bowler <jbowler@nslu2-linux.org>2006-01-16 05:19:51 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2006-01-16 05:19:51 +0000
commitf99c03dff8ea114ab0bfe297a391a0fa90aa9922 (patch)
tree5df1eeec2907d1a9d8c61c2c83e0a5779b776882 /packages/linux
parent9ce5a95818e5574d3fb411614519a219b9aa5c69 (diff)
ixp4xx-kernel: add loft EEPROM MAC support in 2.6.15
Diffstat (limited to 'packages/linux')
-rw-r--r--packages/linux/ixp4xx-kernel/2.6.15/45-eeprom-notifier.patch184
-rw-r--r--packages/linux/ixp4xx-kernel/2.6.15/93-loft-maclist.patch96
-rw-r--r--packages/linux/ixp4xx-kernel_2.6.15.bb4
3 files changed, 283 insertions, 1 deletions
diff --git a/packages/linux/ixp4xx-kernel/2.6.15/45-eeprom-notifier.patch b/packages/linux/ixp4xx-kernel/2.6.15/45-eeprom-notifier.patch
new file mode 100644
index 0000000000..a3597a9c3f
--- /dev/null
+++ b/packages/linux/ixp4xx-kernel/2.6.15/45-eeprom-notifier.patch
@@ -0,0 +1,184 @@
+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>
+
+--- linux-2.6.15/drivers/i2c/chips/eeprom.c 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.15/drivers/i2c/chips/eeprom.c 1970-01-01 00:00:00.000000000 +0000
+@@ -25,7 +25,6 @@
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+-
+ #include <linux/kernel.h>
+ #include <linux/init.h>
+ #include <linux/module.h>
+@@ -33,6 +32,9 @@
+ #include <linux/sched.h>
+ #include <linux/jiffies.h>
+ #include <linux/i2c.h>
++#include <linux/notifier.h>
++
++#include <linux/eeprom.h>
+
+ /* Addresses to scan */
+ static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
+@@ -41,6 +43,9 @@ static unsigned short normal_i2c[] = { 0
+ /* Insmod parameters */
+ I2C_CLIENT_INSMOD_1(eeprom);
+
++/* Notifier list */
++static DECLARE_MUTEX(eeprom_notifier_mutex);
++static LIST_HEAD(eeprom_notifiers);
+
+ /* Size of EEPROM in bytes */
+ #define EEPROM_SIZE 256
+@@ -160,6 +165,7 @@ static int eeprom_detect(struct i2c_adap
+ struct i2c_client *new_client;
+ struct eeprom_data *data;
+ int err = 0;
++ struct list_head *this;
+
+ /* There are three ways we can read the EEPROM data:
+ (1) I2C block reads (faster, but unsupported by most adapters)
+@@ -196,7 +202,7 @@ static int eeprom_detect(struct i2c_adap
+
+ /* Detect the Vaio nature of EEPROMs.
+ We use the "PCG-" prefix as the signature. */
+- if (address == 0x57) {
++ if (list_empty(&eeprom_notifiers) && address == 0x57) {
+ if (i2c_smbus_read_byte_data(new_client, 0x80) == 'P'
+ && i2c_smbus_read_byte(new_client) == 'C'
+ && i2c_smbus_read_byte(new_client) == 'G'
+@@ -210,6 +216,14 @@ static int eeprom_detect(struct i2c_adap
+ /* create the sysfs eeprom file */
+ sysfs_create_bin_file(&new_client->dev.kobj, &eeprom_attr);
+
++ /* Call each notifier callback */
++ down(&eeprom_notifier_mutex);
++ list_for_each(this, &eeprom_notifiers) {
++ struct eeprom_notifier *not = list_entry(this, struct eeprom_notifier, list);
++ not->add(address, kind, &new_client->dev.kobj, &eeprom_attr);
++ }
++ up(&eeprom_notifier_mutex);
++
+ return 0;
+
+ exit_kfree:
+@@ -231,6 +245,51 @@ static int eeprom_detach_client(struct i
+ return 0;
+ }
+
++/**
++ * register_eeprom_user - register a 'user' of EEPROM devices.
++ * @new: 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!
++ */
++void register_eeprom_user (struct eeprom_notifier *new)
++{
++ down(&eeprom_notifier_mutex);
++
++ list_add(&new->list, &eeprom_notifiers);
++
++ up(&eeprom_notifier_mutex);
++}
++
++/**
++ * unregister_eeprom_user - 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.
++ */
++void unregister_eeprom_user (struct eeprom_notifier *old)
++{
++ down(&eeprom_notifier_mutex);
++
++ list_del(&old->list);
++
++ up(&eeprom_notifier_mutex);
++}
++
++
++EXPORT_SYMBOL(register_eeprom_user);
++EXPORT_SYMBOL(unregister_eeprom_user);
++
++
+ static int __init eeprom_init(void)
+ {
+ return i2c_add_driver(&eeprom_driver);
+--- linux-2.6.15/include/linux/eeprom.h 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.15/include/linux/eeprom.h 1970-01-01 00:00:00.000000000 +0000
+@@ -0,0 +1,56 @@
++#ifndef _LINUX_EEPROM_H
++#define _LINUX_EEPROM_H
++/*
++ * $Id$
++ *
++ * 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>
++
++/*
++ * This is very basic.
++ *
++ * If an EEPROM is detected on the I2C bus (this only works for
++ * I2C EEPROMs) the eeprom_notifier::add method 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).
++ */
++struct eeprom_notifier {
++ void (*add)(int address, int kind, struct kobject *kobj,
++ struct bin_attribute *eeprom_attr);
++ struct list_head list;
++};
++
++extern void register_eeprom_user (struct eeprom_notifier *new);
++extern void unregister_eeprom_user (struct eeprom_notifier *old);
++
++#endif /* _LINUX_EEPROM_H */
diff --git a/packages/linux/ixp4xx-kernel/2.6.15/93-loft-maclist.patch b/packages/linux/ixp4xx-kernel/2.6.15/93-loft-maclist.patch
new file mode 100644
index 0000000000..ffda1136ef
--- /dev/null
+++ b/packages/linux/ixp4xx-kernel/2.6.15/93-loft-maclist.patch
@@ -0,0 +1,96 @@
+add loft support for setting the maclist from EEPROM
+
+Signed-off-by: John Bowler <jbowler@acm.org>
+
+--- linux-2.6.15/arch/arm/mach-ixp4xx/ixdp425-setup.c 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.15/arch/arm/mach-ixp4xx/ixdp425-setup.c 1970-01-01 00:00:00.000000000 +0000
+@@ -14,6 +14,7 @@
+ #include <linux/serial.h>
+ #include <linux/tty.h>
+ #include <linux/serial_8250.h>
++#include <linux/eeprom.h>
+
+ #include <asm/types.h>
+ #include <asm/setup.h>
+@@ -24,6 +25,8 @@
+ #include <asm/mach/arch.h>
+ #include <asm/mach/flash.h>
+
++#include <net/maclist.h>
++
+ static struct flash_platform_data ixdp425_flash_data = {
+ .map_name = "cfi_probe",
+ .width = 2,
+@@ -188,9 +191,62 @@ 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.
++ * structure below is identical to Avila except for the and
++ * the use of a loft specific init.
++ *
++ * The loft init registers a notifier on the on-board EEPROM to
++ * detect the MAC addresses.
++ * NOTE: this probably works for all Gateworks Avila boards and
++ * maybe the ixdp425 too.
+ */
+ #ifdef CONFIG_MACH_LOFT
++/*
++ * When the EEPROM is added the MAC address are read from it.
++ */
++static void loft_eeprom_add(int address, int kind, struct kobject *kobj,
++ struct bin_attribute *eeprom_attr) {
++ /* The MACs are the first 12 bytes in the eeprom at address 0x51 */
++ if (address == 0x51) {
++ ssize_t retlen;
++ char data[12];
++
++ /* Two Macs, one at 0, the other at 6, maclist_add will
++ * complain if the ID is not a valid MAC.
++ */
++ retlen = eeprom_attr->read(kobj, data, 0, sizeof data);
++ if (retlen >= 6) {
++ u8 mac[6];
++ memcpy(mac, data+0, sizeof mac);
++ printk(KERN_INFO "LOFT MAC[0]: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
++ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
++ maclist_add(mac);
++ }
++ if (retlen >= 12) {
++ u8 mac[6];
++ memcpy(mac, data+6, sizeof mac);
++ printk(KERN_INFO "LOFT MAC[1]: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
++ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
++ maclist_add(mac);
++ }
++ }
++}
++
++static struct eeprom_notifier loft_eeprom_notifier = {
++ .add = loft_eeprom_add
++};
++
++static void __init loft_init(void)
++{
++ /* The EEPROM has two ethernet MACs embedded in it which we need,
++ * that is all this notifier does.
++ */
++ register_eeprom_user(&loft_eeprom_notifier);
++
++ ixp4xx_sys_init();
++
++ platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
++}
++
+ MACHINE_START(LOFT, "Giant Shoulder Inc Loft board")
+ /* Maintainer: Tom Billman <kernel@giantshoulderinc.com> */
+ .phys_ram = PHYS_OFFSET,
+@@ -200,7 +256,7 @@ MACHINE_START(LOFT, "Giant Shoulder Inc
+ .init_irq = ixp4xx_init_irq,
+ .timer = &ixp4xx_timer,
+ .boot_params = 0x0100,
+- .init_machine = ixdp425_init,
++ .init_machine = loft_init,
+ MACHINE_END
+ #endif
+
diff --git a/packages/linux/ixp4xx-kernel_2.6.15.bb b/packages/linux/ixp4xx-kernel_2.6.15.bb
index 745e04ee8d..ce501ff40f 100644
--- a/packages/linux/ixp4xx-kernel_2.6.15.bb
+++ b/packages/linux/ixp4xx-kernel_2.6.15.bb
@@ -8,7 +8,7 @@ PR_CONFIG = "1"
# Increment the number below (i.e. the digits after PR) when
# making changes within this file or for changes to the patches
# applied to the kernel.
-PR = "r6.${PR_CONFIG}"
+PR = "r7.${PR_CONFIG}"
include ixp4xx-kernel.inc
@@ -20,6 +20,7 @@ IXP4XX_PATCHES += "file://10-mtdpart-redboot-fis-byteswap.patch;patch=1"
IXP4XX_PATCHES += "file://11-mtdpart-redboot-config-byteswap.patch;patch=1"
IXP4XX_PATCHES += "file://15-jffs2-endian-config.patch;patch=1"
IXP4XX_PATCHES += "file://40-rtc-class.patch;patch=1"
+IXP4XX_PATCHES += "file://45-eeprom-notifier.patch;patch=1"
IXP4XX_PATCHES += "file://50-nas100d-arch.patch;patch=1"
IXP4XX_PATCHES += "file://55-rtc-pcf8563.patch;patch=1"
IXP4XX_PATCHES += "file://60-nas100d-i2c.patch;patch=1"
@@ -33,3 +34,4 @@ IXP4XX_PATCHES += "file://85-timer.patch;patch=1"
IXP4XX_PATCHES += "file://91-maclist.patch;patch=1"
IXP4XX_PATCHES += "file://92-nas100d-maclist.patch;patch=1"
IXP4XX_PATCHES += "file://92-nslu2-maclist.patch;patch=1"
+IXP4XX_PATCHES += "file://93-loft-maclist.patch;patch=1"