summaryrefslogtreecommitdiff
path: root/package/mac80211
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-04-10 21:12:05 +0000
committerFelix Fietkau <nbd@openwrt.org>2011-04-10 21:12:05 +0000
commit718f5aa78e12c2a40182e264cd17b64f09d4b6ee (patch)
tree72679aeb9e63857983b720d8b1e599b0001ba847 /package/mac80211
parent8ab360f9b300eab5c31a38de43d216f6f50d2eb9 (diff)
downloadmtk-20170518-718f5aa78e12c2a40182e264cd17b64f09d4b6ee.zip
mtk-20170518-718f5aa78e12c2a40182e264cd17b64f09d4b6ee.tar.gz
mtk-20170518-718f5aa78e12c2a40182e264cd17b64f09d4b6ee.tar.bz2
ath5k: fix mac address detection on dual-radio ar5312
SVN-Revision: 26583
Diffstat (limited to 'package/mac80211')
-rw-r--r--package/mac80211/patches/472-ath_unshare_bus_ops.patch50
-rw-r--r--package/mac80211/patches/473-ath5k_read_mac_addr.patch179
2 files changed, 229 insertions, 0 deletions
diff --git a/package/mac80211/patches/472-ath_unshare_bus_ops.patch b/package/mac80211/patches/472-ath_unshare_bus_ops.patch
new file mode 100644
index 0000000..b3b0eab
--- /dev/null
+++ b/package/mac80211/patches/472-ath_unshare_bus_ops.patch
@@ -0,0 +1,50 @@
+--- a/drivers/net/wireless/ath/ath.h
++++ b/drivers/net/wireless/ath/ath.h
+@@ -123,14 +123,7 @@ struct ath_ops {
+ };
+
+ struct ath_common;
+-
+-struct ath_bus_ops {
+- enum ath_bus_type ath_bus_type;
+- void (*read_cachesize)(struct ath_common *common, int *csz);
+- bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
+- void (*bt_coex_prep)(struct ath_common *common);
+- void (*extn_synch_en)(struct ath_common *common);
+-};
++struct ath_bus_ops;
+
+ struct ath_common {
+ void *ah;
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -847,6 +847,14 @@ struct ath_hw {
+ u32 ent_mode;
+ };
+
++struct ath_bus_ops {
++ enum ath_bus_type ath_bus_type;
++ void (*read_cachesize)(struct ath_common *common, int *csz);
++ bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
++ void (*bt_coex_prep)(struct ath_common *common);
++ void (*extn_synch_en)(struct ath_common *common);
++};
++
+ static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah)
+ {
+ return &ah->common;
+--- a/drivers/net/wireless/ath/ath5k/ath5k.h
++++ b/drivers/net/wireless/ath/ath5k/ath5k.h
+@@ -1155,6 +1155,12 @@ struct ath5k_hw {
+ struct ath5k_rx_status *);
+ };
+
++struct ath_bus_ops {
++ enum ath_bus_type ath_bus_type;
++ void (*read_cachesize)(struct ath_common *common, int *csz);
++ bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
++};
++
+ /*
+ * Prototypes
+ */
diff --git a/package/mac80211/patches/473-ath5k_read_mac_addr.patch b/package/mac80211/patches/473-ath5k_read_mac_addr.patch
new file mode 100644
index 0000000..83c951f
--- /dev/null
+++ b/package/mac80211/patches/473-ath5k_read_mac_addr.patch
@@ -0,0 +1,179 @@
+--- a/drivers/net/wireless/ath/ath5k/ath5k.h
++++ b/drivers/net/wireless/ath/ath5k/ath5k.h
+@@ -1159,6 +1159,7 @@ struct ath_bus_ops {
+ enum ath_bus_type ath_bus_type;
+ void (*read_cachesize)(struct ath_common *common, int *csz);
+ bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
++ int (*eeprom_read_mac)(struct ath5k_hw *ah, u8 *mac);
+ };
+
+ /*
+@@ -1244,7 +1245,6 @@ int ath5k_hw_dma_stop(struct ath5k_hw *a
+ /* EEPROM access functions */
+ int ath5k_eeprom_init(struct ath5k_hw *ah);
+ void ath5k_eeprom_detach(struct ath5k_hw *ah);
+-int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac);
+
+
+ /* Protocol Control Unit Functions */
+--- a/drivers/net/wireless/ath/ath5k/eeprom.c
++++ b/drivers/net/wireless/ath/ath5k/eeprom.c
+@@ -1723,46 +1723,6 @@ ath5k_eeprom_read_spur_chans(struct ath5
+ return ret;
+ }
+
+-/*
+- * 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;
+- 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;
+- }
+-
+- AR5K_EEPROM_READ(0x20, data);
+-
+- for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) {
+- AR5K_EEPROM_READ(offset, data);
+-
+- 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 *
+ \***********************/
+--- a/drivers/net/wireless/ath/ath5k/pci.c
++++ b/drivers/net/wireless/ath/ath5k/pci.c
+@@ -18,6 +18,7 @@
+ #include <linux/pci.h>
+ #include <linux/pci-aspm.h>
+ #include <linux/ath5k_platform.h>
++#include <linux/etherdevice.h>
+ #include "../ath.h"
+ #include "ath5k.h"
+ #include "debug.h"
+@@ -122,11 +123,52 @@ int ath5k_hw_read_srev(struct ath5k_hw *
+ return 0;
+ }
+
++/*
++ * Read the MAC address from eeprom or platform_data
++ */
++static int ath5k_pci_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
++{
++ u8 mac_d[ETH_ALEN] = {};
++ u32 total, offset;
++ u16 data;
++ int octet;
++ 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;
++ }
++
++ AR5K_EEPROM_READ(0x20, data);
++
++ for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) {
++ AR5K_EEPROM_READ(offset, data);
++
++ 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,
+ .read_cachesize = ath5k_pci_read_cachesize,
+ .eeprom_read = ath5k_pci_eeprom_read,
++ .eeprom_read_mac = ath5k_pci_eeprom_read_mac,
+ };
+
+ /********************\
+--- a/drivers/net/wireless/ath/ath5k/ahb.c
++++ b/drivers/net/wireless/ath/ath5k/ahb.c
+@@ -18,6 +18,7 @@
+
+ #include <linux/nl80211.h>
+ #include <linux/platform_device.h>
++#include <linux/etherdevice.h>
+ #include <ar231x_platform.h>
+ #include "ath5k.h"
+ #include "debug.h"
+@@ -62,10 +63,27 @@ int ath5k_hw_read_srev(struct ath5k_hw *
+ return 0;
+ }
+
++static int ath5k_ahb_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;
++ u8 *cfg_mac;
++
++ if (to_platform_device(sc->dev)->id == 0)
++ cfg_mac = bcfg->config->wlan0_mac;
++ else
++ cfg_mac = bcfg->config->wlan1_mac;
++
++ memcpy(mac, cfg_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,
+ .eeprom_read = ath5k_ahb_eeprom_read,
++ .eeprom_read_mac = ath5k_ahb_eeprom_read_mac,
+ };
+
+ /*Initialization*/
+--- a/drivers/net/wireless/ath/ath5k/base.c
++++ b/drivers/net/wireless/ath/ath5k/base.c
+@@ -2880,7 +2880,7 @@ ath5k_init(struct ieee80211_hw *hw)
+ INIT_WORK(&sc->reset_work, ath5k_reset_work);
+ INIT_DELAYED_WORK(&sc->tx_complete_work, ath5k_tx_complete_poll_work);
+
+- ret = ath5k_eeprom_read_mac(ah, mac);
++ ret = ath5k_hw_common(ah)->bus_ops->eeprom_read_mac(ah, mac);
+ if (ret) {
+ ATH5K_ERR(sc, "unable to read address from EEPROM\n");
+ goto err_queues;