summaryrefslogtreecommitdiffstats
path: root/target/linux/ixp4xx/patches-2.6.24/300-avila_fetch_mac.patch
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/ixp4xx/patches-2.6.24/300-avila_fetch_mac.patch')
-rw-r--r--target/linux/ixp4xx/patches-2.6.24/300-avila_fetch_mac.patch160
1 files changed, 121 insertions, 39 deletions
diff --git a/target/linux/ixp4xx/patches-2.6.24/300-avila_fetch_mac.patch b/target/linux/ixp4xx/patches-2.6.24/300-avila_fetch_mac.patch
index 2a987588b..ce0d73042 100644
--- a/target/linux/ixp4xx/patches-2.6.24/300-avila_fetch_mac.patch
+++ b/target/linux/ixp4xx/patches-2.6.24/300-avila_fetch_mac.patch
@@ -1,6 +1,7 @@
-diff -r -u linux-2.6.23.12/arch/arm/mach-ixp4xx/avila-setup.c ../../../../trunk/build_dir/linux-ixp4xx_generic/linux-2.6.23.12/arch/arm/mach-ixp4xx/avila-setup.c
---- linux-2.6.23.12/arch/arm/mach-ixp4xx/avila-setup.c 2008-01-04 01:28:24.134925761 +0100
-+++ ../../../../trunk/build_dir/linux-ixp4xx_generic/linux-2.6.23.12/arch/arm/mach-ixp4xx/avila-setup.c 2008-01-04 01:23:27.874042817 +0100
+Index: linux-2.6.24.2/arch/arm/mach-ixp4xx/avila-setup.c
+===================================================================
+--- linux-2.6.24.2.orig/arch/arm/mach-ixp4xx/avila-setup.c
++++ linux-2.6.24.2/arch/arm/mach-ixp4xx/avila-setup.c
@@ -14,10 +14,18 @@
#include <linux/kernel.h>
#include <linux/init.h>
@@ -20,53 +21,134 @@ diff -r -u linux-2.6.23.12/arch/arm/mach-ixp4xx/avila-setup.c ../../../../trunk/
#include <linux/i2c-gpio.h>
#include <asm/types.h>
-@@ -194,9 +202,48 @@
- t->hdr.size = 0;
- }
+@@ -177,6 +185,118 @@ static struct platform_device *avila_eth
+ &avila_eth[1]
+ };
+#ifdef CONFIG_SENSORS_EEPROM
-+static int loft_eeprom_do(struct notifier_block *self, unsigned long event, void *t)
++struct avila_board_info {
++ unsigned char *model;
++ int npes_used;
++ int npeb_phy;
++ int npec_phy;
++};
++
++static struct avila_board_info avila_boards[] = {
++ {
++ .model = "GW2342",
++ .npes_used = 2,
++ .npeb_phy = 0,
++ .npec_phy = 1,
++ }, {
++ .model = "GW2345",
++ .npes_used = 2,
++ .npeb_phy = 0,
++ .npec_phy = 1,
++ }, {
++ .model = "GW2347",
++ .npes_used = 1,
++ .npeb_phy = 1,
++ }, {
++ .model = "GW2348-2",
++ .npes_used = 2,
++ .npeb_phy = 0,
++ .npec_phy = 1,
++ }, {
++ .model = "GW2348-4",
++ .npes_used = 2,
++ .npeb_phy = 0,
++ .npec_phy = 1,
++ }, {
++ .model = "GW2353",
++ .npes_used = 1,
++ .npeb_phy = 1,
++ }, {
++ .model = "GW2357",
++ .npes_used = 1,
++ .npeb_phy = 1,
++ }
++};
++
++static struct avila_board_info *avila_find_board_info(char *model)
+{
-+ struct eeprom_data *data = t;
-+ struct sockaddr address;
-+ struct net_device * netdev ;
-+
-+ 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, data->attr, macs, 0, 12);
-+ /*eth0*/
-+ /* using dev_get_by_name here is really ugly and can cause
-+ * confusion if other ethernet devices are present. FIXME */
-+
-+ memcpy(address.sa_data, macs, ETH_ALEN);
-+ memcpy(&avila_plat_eth[0].hwaddr, macs, ETH_ALEN);
-+ if ( (netdev = dev_get_by_name(&init_net, "eth0")) )
-+ netdev->set_mac_address(netdev, &address);
-+
-+ /*same for eth1*/
-+ memcpy(address.sa_data, macs + ETH_ALEN, ETH_ALEN);
-+ memcpy(&avila_plat_eth[1].hwaddr, macs + ETH_ALEN, ETH_ALEN);
-+ if ( (netdev = dev_get_by_name(&init_net, "eth1")) )
-+ netdev->set_mac_address(netdev, &address);
-+ }
-+
-+ return NOTIFY_DONE;
++ int i;
++
++ for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
++ struct avila_board_info *info = &avila_boards[i];
++ if (strncmp(info->model, model, strlen(info->model)) == 0)
++ return info;
++ }
++
++ return NULL;
+}
+
-+static struct notifier_block loft_eeprom_notifier = {
-+ .notifier_call = loft_eeprom_do
++struct avila_eeprom_header {
++ unsigned char mac0[ETH_ALEN];
++ unsigned char mac1[ETH_ALEN];
++ unsigned char res0[4];
++ unsigned char magic[2];
++ unsigned char config[14];
++ unsigned char model[16];
++};
++
++static int avila_eeprom_notify(struct notifier_block *self,
++ unsigned long event, void *t)
++{
++ struct eeprom_data *ee = t;
++ struct avila_board_info *info = NULL;
++ struct avila_eeprom_header hdr;
++
++ /* The eeprom is at address 0x51 */
++ if (event != EEPROM_REGISTER || ee->client.addr != 0x51)
++ return NOTIFY_DONE;
++
++ ee->attr->read(&ee->client.dev.kobj, ee->attr, (char *)&hdr,
++ 0, sizeof(hdr));
++
++ if (hdr.magic[0] != 'G' || hdr.magic[1] != 'W')
++ return NOTIFY_DONE;
++
++ memcpy(&avila_plat_eth[0].hwaddr, hdr.mac0, ETH_ALEN);
++ memcpy(&avila_plat_eth[1].hwaddr, hdr.mac1, ETH_ALEN);
++
++ info = avila_find_board_info(hdr.model);
++
++ if (info) {
++ printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
++ info->model);
++ avila_plat_eth[0].phy = info->npeb_phy;
++ avila_plat_eth[1].phy = info->npec_phy;
++ platform_add_devices(avila_eth_devices,
++ info->npes_used);
++ } else {
++ printk(KERN_INFO "Unknown/missing Avila model number"
++ " -- defaults will be used\n");
++ platform_add_devices(avila_eth_devices,
++ ARRAY_SIZE(avila_eth_devices));
++ }
++
++ unregister_eeprom_notifier(self);
++
++ return NOTIFY_OK;
++}
++
++static struct notifier_block avila_eeprom_notifier = {
++ .notifier_call = avila_eeprom_notify
+};
+#endif
+
static void __init avila_init(void)
{
ixp4xx_sys_init();
+@@ -201,7 +321,11 @@ static void __init avila_init(void)
+
+ platform_device_register(&avila_pata);
+
+#ifdef CONFIG_SENSORS_EEPROM
-+ register_eeprom_notifier(&loft_eeprom_notifier);
++ register_eeprom_notifier(&avila_eeprom_notifier);
++#else
+ platform_add_devices(avila_eth_devices, ARRAY_SIZE(avila_eth_devices));
+#endif
+ }
- avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
- avila_flash_resource.end =
-
+ MACHINE_START(AVILA, "Gateworks Avila Network Platform")