rename patch
[openwrt.git] / target / linux / ixp4xx / patches-2.6.23 / 300-avila_fetch_mac.patch
1 Index: linux-2.6.23.17/arch/arm/mach-ixp4xx/avila-setup.c
2 ===================================================================
3 --- linux-2.6.23.17.orig/arch/arm/mach-ixp4xx/avila-setup.c
4 +++ linux-2.6.23.17/arch/arm/mach-ixp4xx/avila-setup.c
5 @@ -14,10 +14,18 @@
6  #include <linux/kernel.h>
7  #include <linux/init.h>
8  #include <linux/device.h>
9 +#include <linux/if_ether.h>
10 +#include <linux/socket.h>
11 +#include <linux/netdevice.h>
12  #include <linux/serial.h>
13  #include <linux/tty.h>
14  #include <linux/serial_8250.h>
15  #include <linux/slab.h>
16 +#ifdef CONFIG_SENSORS_EEPROM
17 +# include <linux/i2c.h>
18 +# include <linux/eeprom.h>
19 +#endif
20 +
21  #include <linux/i2c-gpio.h>
22  
23  #include <asm/types.h>
24 @@ -194,9 +202,48 @@ static void __init avila_fixup(struct ma
25      t->hdr.size = 0;
26  }
27  
28 +#ifdef CONFIG_SENSORS_EEPROM
29 +static int loft_eeprom_do(struct notifier_block *self, unsigned long event, void *t)
30 +{
31 +       struct eeprom_data *data = t;
32 +       struct sockaddr address;
33 +       struct net_device * netdev ;
34 +
35 +       char macs[12];
36 +
37 +       /* The MACs are the first 12 bytes in the eeprom at address 0x51 */
38 +       if (event == EEPROM_REGISTER && data->client.addr == 0x51) {
39 +               data->attr->read(&data->client.dev.kobj, data->attr, macs, 0, 12);
40 +               /*eth0*/
41 +               /* using dev_get_by_name here is really ugly and can cause
42 +               * confusion if other ethernet devices are present. FIXME */
43 +               
44 +               memcpy(address.sa_data, macs, ETH_ALEN);
45 +                       memcpy(&avila_plat_eth[0].hwaddr, macs, ETH_ALEN);
46 +               if ( (netdev = dev_get_by_name("eth0")) )
47 +                       netdev->set_mac_address(netdev, &address);
48 +
49 +                /*same for eth1*/
50 +               memcpy(address.sa_data, macs + ETH_ALEN, ETH_ALEN);
51 +              memcpy(&avila_plat_eth[1].hwaddr, macs + ETH_ALEN, ETH_ALEN);
52 +               if ( (netdev = dev_get_by_name("eth1")) )
53 +                       netdev->set_mac_address(netdev, &address);
54 +       }
55 +
56 +       return NOTIFY_DONE;
57 +}
58 +
59 +static struct notifier_block loft_eeprom_notifier = {
60 +       .notifier_call = loft_eeprom_do
61 +};
62 +#endif
63 +
64  static void __init avila_init(void)
65  {
66         ixp4xx_sys_init();
67 +#ifdef CONFIG_SENSORS_EEPROM
68 +       register_eeprom_notifier(&loft_eeprom_notifier);
69 +#endif
70  
71         avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
72         avila_flash_resource.end =