790811957a7302f598226257d99d6ced24281286
[openwrt/staging/dedeckeh.git] /
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
5
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.
10
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>
16 ---
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(-)
23
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);
28 }
29
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)
32 {
33 const char *fmt;
34
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);
39 return buf;
40 }
41
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;
45
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,
51 ci->pub.chiprev);
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 {
55 u32 rambase;
56 u32 ramsize;
57 u32 srsize;
58 - char name[8];
59 + char name[12];
60 };
61
62 /**
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);
68
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
72 @@ -30,6 +30,7 @@
73 #include "common.h"
74 #include "of.h"
75 #include "firmware.h"
76 +#include "chip.h"
77
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)
82 {
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];
86 u8 *ptr;
87 size_t len;
88 s32 err;
89
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);
93 if (err) {
94 brcmf_err("get firmware name failed (%d)\n", err);
95 goto done;
96 @@ -238,6 +238,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
97 {
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;
103 char *clmver;
104 @@ -253,16 +254,18 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
105 }
106 memcpy(ifp->drvr->mac, ifp->mac_addr, sizeof(ifp->drvr->mac));
107
108 + bus = ifp->drvr->bus_if;
109 + ri = &ifp->drvr->revinfo;
110 +
111 err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_REVINFO,
112 &revinfo, sizeof(revinfo));
113 - ri = &ifp->drvr->revinfo;
114 if (err < 0) {
115 brcmf_err("retrieving revision info failed, %d\n", err);
116 + strlcpy(ri->chipname, "UNKNOWN", sizeof(ri->chipname));
117 } else {
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);
135 +
136 + if (!bus->chip) {
137 + bus->chip = le32_to_cpu(revinfo.chipnum);
138 + bus->chiprev = le32_to_cpu(revinfo.chiprev);
139 + }
140 }
141 ri->result = err;
142
143 + if (bus->chip)
144 + brcmf_chip_name(bus->chip, bus->chiprev,
145 + ri->chipname, sizeof(ri->chipname));
146 +
147 /* Do any CLM downloading */
148 err = brcmf_c_process_clm_blob(ifp);
149 if (err < 0) {
150 @@ -299,7 +310,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
151 strsep(&ptr, "\n");
152
153 /* Print fw version info */
154 - brcmf_info("Firmware version = %s\n", buf);
155 + brcmf_info("Firmware: %s %s\n", ri->chipname, buf);
156
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
172
173 brcmf_debugfs_add_entry(drvr, "revinfo", brcmf_revinfo_read);
174
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);
181 - }
182 brcmf_feat_attach(drvr);
183
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 {
188 u32 vendorid;
189 u32 deviceid;
190 u32 radiorev;
191 - u32 chiprev;
192 u32 corerev;
193 u32 boardid;
194 u32 boardvendor;
195 @@ -95,7 +94,7 @@ struct brcmf_rev_info {
196 u32 driverrev;
197 u32 ucoderev;
198 u32 bus;
199 - u32 chipnum;
200 + char chipname[12];
201 u32 phytype;
202 u32 phyrev;
203 u32 anarev;