1 From 756a2b390874d274f2f615921318ef0856ff9313 Mon Sep 17 00:00:00 2001
2 From: Arend Van Spriel <arend.vanspriel@broadcom.com>
3 Date: Thu, 22 Mar 2018 21:28:21 +0100
4 Subject: [PATCH] brcmfmac: use brcmf_chip_name() to store name in revinfo
6 The chip id can either be four or five digits. For the chip name either
7 the hexadecimal value needs to be taken (four digits) or the decimal
8 value (five digits). The function brcmf_chip_name() does this conversion
9 so use it to store the name in driver revision info.
11 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
12 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
13 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
14 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
15 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
17 .../wireless/broadcom/brcm80211/brcmfmac/chip.c | 9 +++++----
18 .../wireless/broadcom/brcm80211/brcmfmac/chip.h | 3 ++-
19 .../wireless/broadcom/brcm80211/brcmfmac/common.c | 23 ++++++++++++++++------
20 .../wireless/broadcom/brcm80211/brcmfmac/core.c | 10 +---------
21 .../wireless/broadcom/brcm80211/brcmfmac/core.h | 3 +--
22 5 files changed, 26 insertions(+), 22 deletions(-)
24 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
25 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
26 @@ -464,12 +464,12 @@ static void brcmf_chip_ai_resetcore(stru
27 ci->ops->read32(ci->ctx, core->wrapbase + BCMA_IOCTL);
30 -static char *brcmf_chip_name(uint chipid, char *buf, uint len)
31 +char *brcmf_chip_name(u32 id, u32 rev, char *buf, uint len)
35 - fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x";
36 - snprintf(buf, len, fmt, chipid);
37 + fmt = ((id > 0xa000) || (id < 0x4000)) ? "BCM%d/%u" : "BCM%x/%u";
38 + snprintf(buf, len, fmt, id, rev);
42 @@ -924,7 +924,8 @@ static int brcmf_chip_recognition(struct
43 ci->pub.chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT;
44 socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
46 - brcmf_chip_name(ci->pub.chip, ci->pub.name, sizeof(ci->pub.name));
47 + brcmf_chip_name(ci->pub.chip, ci->pub.chiprev,
48 + ci->pub.name, sizeof(ci->pub.name));
49 brcmf_dbg(INFO, "found %s chip: BCM%s, rev=%d\n",
50 socitype == SOCI_SB ? "SB" : "AXI", ci->pub.name,
52 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
53 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
54 @@ -45,7 +45,7 @@ struct brcmf_chip {
63 @@ -93,5 +93,6 @@ void brcmf_chip_resetcore(struct brcmf_c
64 void brcmf_chip_set_passive(struct brcmf_chip *ci);
65 bool brcmf_chip_set_active(struct brcmf_chip *ci, u32 rstvec);
66 bool brcmf_chip_sr_capable(struct brcmf_chip *pub);
67 +char *brcmf_chip_name(u32 chipid, u32 chiprev, char *buf, uint len);
69 #endif /* BRCMF_AXIDMP_H */
70 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
71 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
78 MODULE_AUTHOR("Broadcom Corporation");
79 MODULE_DESCRIPTION("Broadcom 802.11 wireless LAN fullmac driver.");
80 @@ -131,14 +132,13 @@ static int brcmf_c_download(struct brcmf
81 static int brcmf_c_get_clm_name(struct brcmf_if *ifp, u8 *clm_name)
83 struct brcmf_bus *bus = ifp->drvr->bus_if;
84 - struct brcmf_rev_info *ri = &ifp->drvr->revinfo;
85 u8 fw_name[BRCMF_FW_NAME_LEN];
90 memset(fw_name, 0, BRCMF_FW_NAME_LEN);
91 - err = brcmf_bus_get_fwname(bus, ri->chipnum, ri->chiprev, fw_name);
92 + err = brcmf_bus_get_fwname(bus, bus->chip, bus->chiprev, fw_name);
94 brcmf_err("get firmware name failed (%d)\n", err);
96 @@ -238,6 +238,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
98 s8 eventmask[BRCMF_EVENTING_MASK_LEN];
99 u8 buf[BRCMF_DCMD_SMLEN];
100 + struct brcmf_bus *bus;
101 struct brcmf_rev_info_le revinfo;
102 struct brcmf_rev_info *ri;
104 @@ -253,16 +254,18 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
106 memcpy(ifp->drvr->mac, ifp->mac_addr, sizeof(ifp->drvr->mac));
108 + bus = ifp->drvr->bus_if;
109 + ri = &ifp->drvr->revinfo;
111 err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_REVINFO,
112 &revinfo, sizeof(revinfo));
113 - ri = &ifp->drvr->revinfo;
115 brcmf_err("retrieving revision info failed, %d\n", err);
116 + strlcpy(ri->chipname, "UNKNOWN", sizeof(ri->chipname));
118 ri->vendorid = le32_to_cpu(revinfo.vendorid);
119 ri->deviceid = le32_to_cpu(revinfo.deviceid);
120 ri->radiorev = le32_to_cpu(revinfo.radiorev);
121 - ri->chiprev = le32_to_cpu(revinfo.chiprev);
122 ri->corerev = le32_to_cpu(revinfo.corerev);
123 ri->boardid = le32_to_cpu(revinfo.boardid);
124 ri->boardvendor = le32_to_cpu(revinfo.boardvendor);
125 @@ -270,15 +273,23 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
126 ri->driverrev = le32_to_cpu(revinfo.driverrev);
127 ri->ucoderev = le32_to_cpu(revinfo.ucoderev);
128 ri->bus = le32_to_cpu(revinfo.bus);
129 - ri->chipnum = le32_to_cpu(revinfo.chipnum);
130 ri->phytype = le32_to_cpu(revinfo.phytype);
131 ri->phyrev = le32_to_cpu(revinfo.phyrev);
132 ri->anarev = le32_to_cpu(revinfo.anarev);
133 ri->chippkg = le32_to_cpu(revinfo.chippkg);
134 ri->nvramrev = le32_to_cpu(revinfo.nvramrev);
137 + bus->chip = le32_to_cpu(revinfo.chipnum);
138 + bus->chiprev = le32_to_cpu(revinfo.chiprev);
144 + brcmf_chip_name(bus->chip, bus->chiprev,
145 + ri->chipname, sizeof(ri->chipname));
147 /* Do any CLM downloading */
148 err = brcmf_c_process_clm_blob(ifp);
150 @@ -299,7 +310,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
153 /* Print fw version info */
154 - brcmf_info("Firmware version = %s\n", buf);
155 + brcmf_info("Firmware: %s %s\n", ri->chipname, buf);
157 /* locate firmware version number for ethtool */
158 ptr = strrchr(buf, ' ') + 1;
159 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
160 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
161 @@ -1002,8 +1002,7 @@ static int brcmf_revinfo_read(struct seq
162 seq_printf(s, "vendorid: 0x%04x\n", ri->vendorid);
163 seq_printf(s, "deviceid: 0x%04x\n", ri->deviceid);
164 seq_printf(s, "radiorev: %s\n", brcmu_dotrev_str(ri->radiorev, drev));
165 - seq_printf(s, "chipnum: %u (%x)\n", ri->chipnum, ri->chipnum);
166 - seq_printf(s, "chiprev: %u\n", ri->chiprev);
167 + seq_printf(s, "chip: %s\n", ri->chipname);
168 seq_printf(s, "chippkg: %u\n", ri->chippkg);
169 seq_printf(s, "corerev: %u\n", ri->corerev);
170 seq_printf(s, "boardid: 0x%04x\n", ri->boardid);
171 @@ -1053,13 +1052,6 @@ static int brcmf_bus_started(struct brcm
173 brcmf_debugfs_add_entry(drvr, "revinfo", brcmf_revinfo_read);
175 - /* assure we have chipid before feature attach */
176 - if (!bus_if->chip) {
177 - bus_if->chip = drvr->revinfo.chipnum;
178 - bus_if->chiprev = drvr->revinfo.chiprev;
179 - brcmf_dbg(INFO, "firmware revinfo: chip %x (%d) rev %d\n",
180 - bus_if->chip, bus_if->chip, bus_if->chiprev);
182 brcmf_feat_attach(drvr);
184 ret = brcmf_proto_init_done(drvr);
185 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
186 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
187 @@ -87,7 +87,6 @@ struct brcmf_rev_info {
195 @@ -95,7 +94,7 @@ struct brcmf_rev_info {