aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuciano Coelho <coelho@ti.com>2012-04-11 04:07:28 -0400
committerLuciano Coelho <coelho@ti.com>2012-04-12 01:43:57 -0400
commit30d9b4a58bc168620eed0fc6d90b2f05cd02a462 (patch)
tree8e12315f08cfa4909e4e736014d57370ee00c4e8
parentdd5512eb6b8317069e80d70a624b6d350afebc9e (diff)
wlcore/wl12xx: move MAC address reading operation to lower driver
Different chip families have the factory MAC address written in different places. Add a new hardware operation to read the MAC address, if available. Signed-off-by: Luciano Coelho <coelho@ti.com>
-rw-r--r--drivers/net/wireless/ti/wl12xx/main.c52
-rw-r--r--drivers/net/wireless/ti/wlcore/main.c52
-rw-r--r--drivers/net/wireless/ti/wlcore/wlcore.h1
3 files changed, 55 insertions, 50 deletions
diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
index d235da244a21..cef2884b37c8 100644
--- a/drivers/net/wireless/ti/wl12xx/main.c
+++ b/drivers/net/wireless/ti/wl12xx/main.c
@@ -571,6 +571,51 @@ out:
571 return ret; 571 return ret;
572} 572}
573 573
574static bool wl12xx_mac_in_fuse(struct wl1271 *wl)
575{
576 bool supported = false;
577 u8 major, minor;
578
579 if (wl->chip.id == CHIP_ID_1283_PG20) {
580 major = WL128X_PG_GET_MAJOR(wl->hw_pg_ver);
581 minor = WL128X_PG_GET_MINOR(wl->hw_pg_ver);
582
583 /* in wl128x we have the MAC address if the PG is >= (2, 1) */
584 if (major > 2 || (major == 2 && minor >= 1))
585 supported = true;
586 } else {
587 major = WL127X_PG_GET_MAJOR(wl->hw_pg_ver);
588 minor = WL127X_PG_GET_MINOR(wl->hw_pg_ver);
589
590 /* in wl127x we have the MAC address if the PG is >= (3, 1) */
591 if (major == 3 && minor >= 1)
592 supported = true;
593 }
594
595 wl1271_debug(DEBUG_PROBE,
596 "PG Ver major = %d minor = %d, MAC %s present",
597 major, minor, supported ? "is" : "is not");
598
599 return supported;
600}
601
602static void wl12xx_get_fuse_mac(struct wl1271 *wl)
603{
604 u32 mac1, mac2;
605
606 wlcore_set_partition(wl, &wl->ptable[PART_DRPW]);
607
608 mac1 = wl1271_read32(wl, WL12XX_REG_FUSE_BD_ADDR_1);
609 mac2 = wl1271_read32(wl, WL12XX_REG_FUSE_BD_ADDR_2);
610
611 /* these are the two parts of the BD_ADDR */
612 wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) +
613 ((mac1 & 0xff000000) >> 24);
614 wl->fuse_nic_addr = mac1 & 0xffffff;
615
616 wlcore_set_partition(wl, &wl->ptable[PART_DOWN]);
617}
618
574static s8 wl12xx_get_pg_ver(struct wl1271 *wl) 619static s8 wl12xx_get_pg_ver(struct wl1271 *wl)
575{ 620{
576 u32 die_info; 621 u32 die_info;
@@ -583,10 +628,17 @@ static s8 wl12xx_get_pg_ver(struct wl1271 *wl)
583 return (s8) (die_info & PG_VER_MASK) >> PG_VER_OFFSET; 628 return (s8) (die_info & PG_VER_MASK) >> PG_VER_OFFSET;
584} 629}
585 630
631static void wl12xx_get_mac(struct wl1271 *wl)
632{
633 if (wl12xx_mac_in_fuse(wl))
634 wl12xx_get_fuse_mac(wl);
635}
636
586static struct wlcore_ops wl12xx_ops = { 637static struct wlcore_ops wl12xx_ops = {
587 .identify_chip = wl12xx_identify_chip, 638 .identify_chip = wl12xx_identify_chip,
588 .boot = wl12xx_boot, 639 .boot = wl12xx_boot,
589 .get_pg_ver = wl12xx_get_pg_ver, 640 .get_pg_ver = wl12xx_get_pg_ver,
641 .get_mac = wl12xx_get_mac,
590}; 642};
591 643
592static int __devinit wl12xx_probe(struct platform_device *pdev) 644static int __devinit wl12xx_probe(struct platform_device *pdev)
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
index f761a6123a97..5a202924c7b1 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -50,9 +50,6 @@
50#include "testmode.h" 50#include "testmode.h"
51#include "scan.h" 51#include "scan.h"
52 52
53/* TODO: remove this once the FUSE definitions are separated */
54#include "../wl12xx/reg.h"
55
56#define WL1271_BOOT_RETRIES 3 53#define WL1271_BOOT_RETRIES 3
57 54
58static struct conf_drv_settings default_conf = { 55static struct conf_drv_settings default_conf = {
@@ -4993,34 +4990,6 @@ static struct bin_attribute fwlog_attr = {
4993 .read = wl1271_sysfs_read_fwlog, 4990 .read = wl1271_sysfs_read_fwlog,
4994}; 4991};
4995 4992
4996static bool wl12xx_mac_in_fuse(struct wl1271 *wl)
4997{
4998 bool supported = false;
4999 u8 major, minor;
5000
5001 if (wl->chip.id == CHIP_ID_1283_PG20) {
5002 major = WL128X_PG_GET_MAJOR(wl->hw_pg_ver);
5003 minor = WL128X_PG_GET_MINOR(wl->hw_pg_ver);
5004
5005 /* in wl128x we have the MAC address if the PG is >= (2, 1) */
5006 if (major > 2 || (major == 2 && minor >= 1))
5007 supported = true;
5008 } else {
5009 major = WL127X_PG_GET_MAJOR(wl->hw_pg_ver);
5010 minor = WL127X_PG_GET_MINOR(wl->hw_pg_ver);
5011
5012 /* in wl127x we have the MAC address if the PG is >= (3, 1) */
5013 if (major == 3 && minor >= 1)
5014 supported = true;
5015 }
5016
5017 wl1271_debug(DEBUG_PROBE,
5018 "PG Ver major = %d minor = %d, MAC %s present",
5019 major, minor, supported ? "is" : "is not");
5020
5021 return supported;
5022}
5023
5024static void wl12xx_derive_mac_addresses(struct wl1271 *wl, 4993static void wl12xx_derive_mac_addresses(struct wl1271 *wl,
5025 u32 oui, u32 nic, int n) 4994 u32 oui, u32 nic, int n)
5026{ 4995{
@@ -5046,23 +5015,6 @@ static void wl12xx_derive_mac_addresses(struct wl1271 *wl,
5046 wl->hw->wiphy->addresses = wl->addresses; 5015 wl->hw->wiphy->addresses = wl->addresses;
5047} 5016}
5048 5017
5049static void wl12xx_get_fuse_mac(struct wl1271 *wl)
5050{
5051 u32 mac1, mac2;
5052
5053 wlcore_set_partition(wl, &wl->ptable[PART_DRPW]);
5054
5055 mac1 = wl1271_read32(wl, WL12XX_REG_FUSE_BD_ADDR_1);
5056 mac2 = wl1271_read32(wl, WL12XX_REG_FUSE_BD_ADDR_2);
5057
5058 /* these are the two parts of the BD_ADDR */
5059 wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) +
5060 ((mac1 & 0xff000000) >> 24);
5061 wl->fuse_nic_addr = mac1 & 0xffffff;
5062
5063 wlcore_set_partition(wl, &wl->ptable[PART_DOWN]);
5064}
5065
5066static int wl12xx_get_hw_info(struct wl1271 *wl) 5018static int wl12xx_get_hw_info(struct wl1271 *wl)
5067{ 5019{
5068 int ret; 5020 int ret;
@@ -5078,8 +5030,8 @@ static int wl12xx_get_hw_info(struct wl1271 *wl)
5078 5030
5079 wl->hw_pg_ver = wl->ops->get_pg_ver(wl); 5031 wl->hw_pg_ver = wl->ops->get_pg_ver(wl);
5080 5032
5081 if (wl12xx_mac_in_fuse(wl)) 5033 if (wl->ops->get_mac)
5082 wl12xx_get_fuse_mac(wl); 5034 wl->ops->get_mac(wl);
5083 5035
5084 wl1271_power_off(wl); 5036 wl1271_power_off(wl);
5085out: 5037out:
diff --git a/drivers/net/wireless/ti/wlcore/wlcore.h b/drivers/net/wireless/ti/wlcore/wlcore.h
index f2b18bec8f54..38d1ed2967c8 100644
--- a/drivers/net/wireless/ti/wlcore/wlcore.h
+++ b/drivers/net/wireless/ti/wlcore/wlcore.h
@@ -31,6 +31,7 @@ struct wlcore_ops {
31 int (*identify_chip)(struct wl1271 *wl); 31 int (*identify_chip)(struct wl1271 *wl);
32 int (*boot)(struct wl1271 *wl); 32 int (*boot)(struct wl1271 *wl);
33 s8 (*get_pg_ver)(struct wl1271 *wl); 33 s8 (*get_pg_ver)(struct wl1271 *wl);
34 void (*get_mac)(struct wl1271 *wl);
34}; 35};
35 36
36enum wlcore_partitions { 37enum wlcore_partitions {