lantiq: allow platforms with rt2x00 to override the mac address without overriding...
authorFelix Fietkau <nbd@openwrt.org>
Sun, 20 May 2012 21:58:03 +0000 (21:58 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 20 May 2012 21:58:03 +0000 (21:58 +0000)
SVN-Revision: 31835

package/mac80211/patches/608-add_platform_data_mac_addr.patch [new file with mode: 0644]
target/linux/generic/files/include/linux/rt2x00_platform.h
target/linux/lantiq/files-3.3/arch/mips/lantiq/xway/dev-wifi-rt2x00.c
target/linux/lantiq/files-3.3/arch/mips/lantiq/xway/dev-wifi-rt2x00.h
target/linux/lantiq/files-3.3/arch/mips/lantiq/xway/mach-arv.c

diff --git a/package/mac80211/patches/608-add_platform_data_mac_addr.patch b/package/mac80211/patches/608-add_platform_data_mac_addr.patch
new file mode 100644 (file)
index 0000000..5008180
--- /dev/null
@@ -0,0 +1,63 @@
+--- a/include/linux/rt2x00_platform.h
++++ b/include/linux/rt2x00_platform.h
+@@ -14,6 +14,7 @@
+ struct rt2x00_platform_data {
+       char *eeprom_file_name;
++      const u8 *mac_address;
+       int disable_2ghz;
+       int disable_5ghz;
+--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
+@@ -825,6 +825,18 @@ static void rt2x00lib_rate(struct ieee80
+               entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE;
+ }
++const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev)
++{
++      struct rt2x00_platform_data *pdata;
++
++      pdata = rt2x00dev->dev->platform_data;
++      if (!pdata)
++              return NULL;
++
++      return pdata->mac_address;
++}
++EXPORT_SYMBOL_GPL(rt2x00lib_get_mac_address);
++
+ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
+                                   struct hw_mode_spec *spec)
+ {
+--- a/drivers/net/wireless/rt2x00/rt2x00.h
++++ b/drivers/net/wireless/rt2x00/rt2x00.h
+@@ -1280,6 +1280,7 @@ static inline void rt2x00debug_dump_fram
+  */
+ u32 rt2x00lib_get_bssidx(struct rt2x00_dev *rt2x00dev,
+                        struct ieee80211_vif *vif);
++const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev);
+ /*
+  * Interrupt context handlers.
+--- a/drivers/net/wireless/rt2x00/rt61pci.c
++++ b/drivers/net/wireless/rt2x00/rt61pci.c
+@@ -2393,6 +2393,7 @@ static int rt61pci_validate_eeprom(struc
+       u32 reg;
+       u16 word;
+       u8 *mac;
++      const u8 *pdata_mac;
+       s8 value;
+       rt2x00pci_register_read(rt2x00dev, E2PROM_CSR, &reg);
+@@ -2413,7 +2414,11 @@ static int rt61pci_validate_eeprom(struc
+       /*
+        * Start validation of the data that has been read.
+        */
++      pdata_mac = rt2x00lib_get_mac_address(rt2x00dev);
+       mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
++      if (pdata_mac)
++              memcpy(mac, pdata_mac, 6);
++
+       if (!is_valid_ether_addr(mac)) {
+               random_ether_addr(mac);
+               EEPROM(rt2x00dev, "MAC: %pM\n", mac);
index b4c7768739db82bd3fee741a63255a2b392b4236..e10377e21b092e38c200c4e1e8d218f33b3c438a 100644 (file)
@@ -14,6 +14,7 @@
 
 struct rt2x00_platform_data {
        char *eeprom_file_name;
+       const u8 *mac_address;
 
        int disable_2ghz;
        int disable_5ghz;
index 8975f6be7d5b1b24f6d25457e4b874316cd1e48a..8e271f06ec5b990d7e12ef476ab9b9fcb2fabc4c 100644 (file)
@@ -24,8 +24,9 @@ rt2x00_pci_plat_dev_init(struct pci_dev *dev)
 }
 
 void __init
-ltq_register_rt2x00(const char *firmware)
+ltq_register_rt2x00(const char *firmware, const u8 *mac)
 {
        rt2x00_pdata.eeprom_file_name = kstrdup(firmware, GFP_KERNEL);
+       rt2x00_pdata.mac_address = mac;
        ltqpci_plat_dev_init = rt2x00_pci_plat_dev_init;
 }
index 060ca50270d79fee903a48fc2e59c11319c66a28..941c26535f8169510f6dfab949d449304252f788 100644 (file)
@@ -9,6 +9,6 @@
 #ifndef _DEV_WIFI_RT2X00_H__
 #define _DEV_WIFI_RT2X00_H__
 
-extern void ltq_register_rt2x00(const char *firmware);
+extern void ltq_register_rt2x00(const char *firmware, const u8 *mac);
 
 #endif
index c300b9d42f0a35c77324e5931909b0fe5dd47aea..4abb2d500e5570927df41e0422b6f9fd16b4d12f 100644 (file)
@@ -597,6 +597,7 @@ arv4520pw_init(void)
        ltq_register_pci(&ltq_pci_data);
        ltq_register_tapi();
        arv_register_ethernet(ARV4520PW_MAC_ADDR);
+       ltq_register_rt2x00(NULL, (const u8 *) ltq_eth_data.mac.sa_data);
        xway_register_dwc(ARV4520PW_USB);
 
        gpio_request(ARV4520PW_SWITCH_RESET, "switch");
@@ -686,7 +687,7 @@ arv7525pw_init(void)
        ltq_pci_data.irq[14] = (INT_NUM_IM3_IRL0 + 31);
        ltq_register_pci(&ltq_pci_data);
        ltq_eth_data.mii_mode = PHY_INTERFACE_MODE_MII;
-       ltq_register_rt2x00("RT2860.eeprom");
+       ltq_register_rt2x00("RT2860.eeprom", NULL);
        ltq_register_tapi();
        arv_register_ethernet(ARV7525P_MAC_ADDR);
 }
@@ -773,7 +774,7 @@ arv752dpw_init(void)
        ltq_pci_data.gpio |= PCI_EXIN1 | PCI_REQ2;
        ltq_register_pci(&ltq_pci_data);
        xway_register_dwc(ARV752DPW22_USB);
-       ltq_register_rt2x00("RT2860.eeprom");
+       ltq_register_rt2x00("RT2860.eeprom", NULL);
        arv_register_ethernet(ARV752DPW22_MAC_ADDR);
        gpio_request(ARV752DPW22_RELAY, "relay");
        gpio_set_value(ARV752DPW22_RELAY, 1);