]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - wl12xx/ti-utils.git/commitdiff
plt: add support to read MAC address from the FUSE
authorLuciano Coelho <coelho@ti.com>
Fri, 13 Jan 2012 09:59:11 +0000 (11:59 +0200)
committerLuciano Coelho <coelho@ti.com>
Mon, 23 Jan 2012 07:21:15 +0000 (09:21 +0200)
In some newer PG versions, we can read the MAC address from the FUSE
ROM.  Add get_mac command to read and print out the MAC address.

Signed-off-by: Luciano Coelho <coelho@ti.com>
plt.c
plt.h

diff --git a/plt.c b/plt.c
index 4559700a44148d193be8176cc0f517ebd1281f62..0214b7664dcaf9079144123e6dcf9ab66a57fed1 100644 (file)
--- a/plt.c
+++ b/plt.c
@@ -1108,3 +1108,77 @@ out_removenvs:
 }
 COMMAND(plt, autocalibrate, "<dev> <module path> <ini file1> <nvs file> <mac addr> ", 0, 0, CIB_NONE,
        plt_autocalibrate, "Do automatic calibration\n");
+
+static int plt_get_mac_cb(struct nl_msg *msg, void *arg)
+{
+       struct nlattr *tb[NL80211_ATTR_MAX + 1];
+       struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+       struct nlattr *td[WL1271_TM_ATTR_MAX + 1];
+       char *addr;
+       int lower;
+
+       nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+                 genlmsg_attrlen(gnlh, 0), NULL);
+
+       if (!tb[NL80211_ATTR_TESTDATA]) {
+               fprintf(stderr, "no data!\n");
+               return NL_SKIP;
+       }
+
+       nla_parse(td, WL1271_TM_ATTR_MAX, nla_data(tb[NL80211_ATTR_TESTDATA]),
+                 nla_len(tb[NL80211_ATTR_TESTDATA]), NULL);
+
+       addr = (char *) nla_data(td[WL1271_TM_ATTR_DATA]);
+
+       printf("BD_ADDR from fuse:\t0x%0x:0x%0x:0x%0x:0x%0x:0x%0x:0x%0x\n",
+              addr[0], addr[1], addr[2],
+              addr[3], addr[4], addr[5]);
+
+       lower = (addr[3] << 16) + (addr[4] << 8) + addr[5];
+
+       lower++;
+       printf("First WLAN MAC:\t\t0x%0x:0x%0x:0x%0x:0x%0x:0x%0x:0x%0x\n",
+              addr[0], addr[1], addr[2],
+              (lower & 0xff0000) >> 16,
+              (lower & 0xff00) >> 8,
+              (lower & 0xff));
+
+       lower++;
+       printf("Second WLAN MAC:\t0x%0x:0x%0x:0x%0x:0x%0x:0x%0x:0x%0x\n",
+              addr[0], addr[1], addr[2],
+              (lower & 0xff0000) >> 16,
+              (lower & 0xff00) >> 8,
+              (lower & 0xff));
+
+       return NL_SKIP;
+}
+
+static int plt_get_mac(struct nl80211_state *state, struct nl_cb *cb,
+                      struct nl_msg *msg, int argc, char **argv)
+{
+       struct nlattr *key;
+
+       if (argc != 0)
+               return 1;
+
+       key = nla_nest_start(msg, NL80211_ATTR_TESTDATA);
+       if (!key) {
+               fprintf(stderr, "%s> fail to nla_nest_start()\n", __func__);
+               return 1;
+       }
+
+       NLA_PUT_U32(msg, WL1271_TM_ATTR_CMD_ID, WL1271_TM_CMD_GET_MAC);
+
+       nla_nest_end(msg, key);
+
+       nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, plt_get_mac_cb, NULL);
+
+       return 0;
+
+nla_put_failure:
+       fprintf(stderr, "%s> building message failed\n", __func__);
+       return 2;
+}
+COMMAND(plt, get_mac, "",
+       NL80211_CMD_TESTMODE, 0, CIB_NETDEV, plt_get_mac,
+       "Read MAC address from the Fuse ROM.\n");
diff --git a/plt.h b/plt.h
index 40846ff0420a479df517c546ead7c1c70e6871b4..d6ca9eb23536d8fd4d8f81cff7517fe6ed4daa5a 100644 (file)
--- a/plt.h
+++ b/plt.h
@@ -124,6 +124,9 @@ enum wl1271_tm_commands {
        WL1271_TM_CMD_CONFIGURE,
        WL1271_TM_CMD_NVS_PUSH,
        WL1271_TM_CMD_SET_PLT_MODE,
+       WL1271_TM_CMD_RECOVER,
+       WL1271_TM_CMD_GET_MAC,
+
        __WL1271_TM_CMD_AFTER_LAST
 };