mac80211: For ath5k AHB take mac addresses from board configuration
 and not from calibration data. Otherwise each radio instance will
 have same MAC.

Signed-off-by: Wojciech Dubowik <wojciech.dubo...@neratec.com>
---
 .../451-add-platform-eeprom-support-to-ath5k.patch |  181 +++++++++++++++-----
 1 files changed, 136 insertions(+), 45 deletions(-)

diff --git 
a/package/mac80211/patches/451-add-platform-eeprom-support-to-ath5k.patch 
b/package/mac80211/patches/451-add-platform-eeprom-support-to-ath5k.patch
index ff96b78..c016920 100644
--- a/package/mac80211/patches/451-add-platform-eeprom-support-to-ath5k.patch
+++ b/package/mac80211/patches/451-add-platform-eeprom-support-to-ath5k.patch
@@ -1,51 +1,16 @@
---- a/drivers/net/wireless/ath/ath5k/eeprom.c
-+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
-@@ -22,6 +22,8 @@
- \*************************************/
- 
- #include <linux/slab.h>
-+#include <linux/ath5k_platform.h>
-+#include <linux/pci.h>
- 
- #include "ath5k.h"
- #include "reg.h"
-@@ -1726,7 +1728,7 @@ ath5k_eeprom_read_spur_chans(struct ath5
- }
- 
- /*
-- * Read the MAC address from eeprom
-+ * Read the MAC address from eeprom or platform_data
+Index: compat-wireless-2010-12-16/drivers/net/wireless/ath/ath5k/pci.c
+===================================================================
+--- compat-wireless-2010-12-16.orig/drivers/net/wireless/ath/ath5k/pci.c       
2010-12-17 22:22:02.000000000 +0100
++++ compat-wireless-2010-12-16/drivers/net/wireless/ath/ath5k/pci.c    
2011-01-06 12:52:58.934762991 +0100
+@@ -15,6 +15,7 @@
   */
- int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
- {
-@@ -1734,6 +1736,16 @@ int ath5k_eeprom_read_mac(struct ath5k_h
-       u32 total, offset;
-       u16 data;
-       int octet, ret;
-+      struct ath5k_platform_data *pdata = NULL;
-+
-+      if (ah->ah_sc->pdev)
-+              pdata = ah->ah_sc->pdev->dev.platform_data;
-+
-+      if (pdata && pdata->macaddr)
-+      {
-+              memcpy(mac, pdata->macaddr, ETH_ALEN);
-+              return 0;
-+      }
  
-       ret = ath5k_hw_nvram_read(ah, 0x20, &data);
-       if (ret)
---- a/drivers/net/wireless/ath/ath5k/pci.c
-+++ b/drivers/net/wireless/ath/ath5k/pci.c
-@@ -17,6 +17,7 @@
  #include <linux/nl80211.h>
++#include <linux/ath5k_platform.h>
  #include <linux/pci.h>
  #include <linux/pci-aspm.h>
-+#include <linux/ath5k_platform.h>
  #include "../ath.h"
- #include "ath5k.h"
- #include "debug.h"
-@@ -73,6 +74,19 @@ bool ath5k_pci_eeprom_read(struct ath_co
+@@ -73,6 +74,18 @@
  {
        struct ath5k_hw *ah = (struct ath5k_hw *) common->ah;
        u32 status, timeout;
@@ -56,12 +21,138 @@
 +
 +      if (pdata && pdata->eeprom_data && pdata->eeprom_data[0] == 
AR5K_EEPROM_MAGIC_VALUE)
 +      {
-+              if (offset >= ATH5K_PLAT_EEP_MAX_WORDS)
-+                      return -EIO;
-+
++              ATH5K_INFO(ah->ah_sc, "using eeprom-content from 
platform_data\n");
++              if (offset >= ATH5K_PLAT_EEP_MAX_WORDS) return -EIO;
 +              *data = pdata->eeprom_data[offset];
 +              return 0;
 +      }
  
        /*
         * Initialize EEPROM access
+@@ -107,6 +120,49 @@
+       return 0;
+ }
+ 
++/*
++ * Read the MAC address from eeprom or platform_data
++ */
++int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
++{
++      u8 mac_d[ETH_ALEN] = {};
++      u32 total, offset;
++      u16 data;
++      int octet, ret;
++      struct ath5k_platform_data *pdata = NULL;
++
++      if (ah->ah_sc->pdev)
++              pdata = ah->ah_sc->pdev->dev.platform_data;
++
++      if (pdata && pdata->macaddr)
++      {
++              memcpy(mac, pdata->macaddr, ETH_ALEN);
++              return 0;
++      }
++
++      ret = ath5k_hw_nvram_read(ah, 0x20, &data);
++      if (ret)
++              return ret;
++
++      for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) {
++              ret = ath5k_hw_nvram_read(ah, offset, &data);
++              if (ret)
++                      return ret;
++
++              total += data;
++              mac_d[octet + 1] = data & 0xff;
++              mac_d[octet] = data >> 8;
++              octet += 2;
++      }
++
++      if (!total || total == 3 * 0xffff)
++              return -EINVAL;
++
++      memcpy(mac, mac_d, ETH_ALEN);
++
++      return 0;
++}
++
+ /* Common ath_bus_opts structure */
+ static const struct ath_bus_ops ath_pci_bus_ops = {
+       .ath_bus_type = ATH_PCI,
+Index: compat-wireless-2010-12-16/drivers/net/wireless/ath/ath5k/eeprom.c
+===================================================================
+--- compat-wireless-2010-12-16.orig/drivers/net/wireless/ath/ath5k/eeprom.c    
2010-12-17 22:22:01.000000000 +0100
++++ compat-wireless-2010-12-16/drivers/net/wireless/ath/ath5k/eeprom.c 
2011-01-06 12:55:48.004762993 +0100
+@@ -1725,40 +1725,6 @@
+       return ret;
+ }
+ 
+-/*
+- * Read the MAC address from eeprom
+- */
+-int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
+-{
+-      u8 mac_d[ETH_ALEN] = {};
+-      u32 total, offset;
+-      u16 data;
+-      int octet, ret;
+-
+-      ret = ath5k_hw_nvram_read(ah, 0x20, &data);
+-      if (ret)
+-              return ret;
+-
+-      for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) {
+-              ret = ath5k_hw_nvram_read(ah, offset, &data);
+-              if (ret)
+-                      return ret;
+-
+-              total += data;
+-              mac_d[octet + 1] = data & 0xff;
+-              mac_d[octet] = data >> 8;
+-              octet += 2;
+-      }
+-
+-      if (!total || total == 3 * 0xffff)
+-              return -EINVAL;
+-
+-      memcpy(mac, mac_d, ETH_ALEN);
+-
+-      return 0;
+-}
+-
+-
+ /***********************\
+ * Init/Detach functions *
+ \***********************/
+Index: compat-wireless-2010-12-16/drivers/net/wireless/ath/ath5k/ahb.c
+===================================================================
+--- compat-wireless-2010-12-16.orig/drivers/net/wireless/ath/ath5k/ahb.c       
2010-12-17 22:22:01.000000000 +0100
++++ compat-wireless-2010-12-16/drivers/net/wireless/ath/ath5k/ahb.c    
2011-01-06 12:52:58.934762991 +0100
+@@ -61,6 +61,27 @@
+       return 0;
+ }
+ 
++/*
++ * Read the MAC address from eeprom or platform_data
++ */
++int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
++{
++      struct ath5k_softc *sc = ah->ah_sc;
++      struct platform_device *pdev = to_platform_device(sc->dev);
++      struct ar231x_board_config *bcfg = pdev->dev.platform_data;
++
++
++      if (bcfg->config == NULL)
++              return -EINVAL;
++              
++      if (to_platform_device(sc->dev)->id == 0)
++              memcpy(mac, bcfg->config->wlan0_mac, ETH_ALEN);
++      else
++              memcpy(mac, bcfg->config->wlan1_mac, ETH_ALEN);
++
++      return 0;
++}
++
+ static const struct ath_bus_ops ath_ahb_bus_ops = {
+       .ath_bus_type = ATH_AHB,
+       .read_cachesize = ath5k_ahb_read_cachesize,
-- 
1.7.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to