diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2012-01-02 02:41:24 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-01-24 14:06:04 -0500 |
commit | b35a9aca631ee0cf67cd23098ea9076ca33c3f7b (patch) | |
tree | 59d26efe1f362673e5894b3b7de65fc549c7e1b5 /drivers/bcma/sprom.c | |
parent | b0f70292053a0f68f406564a721a7a3f2d66b44f (diff) |
bcma: SPROM: add macro for easier extraction
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/bcma/sprom.c')
-rw-r--r-- | drivers/bcma/sprom.c | 139 |
1 files changed, 71 insertions, 68 deletions
diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c index 6f230fb087c5..27f62cc2c8af 100644 --- a/drivers/bcma/sprom.c +++ b/drivers/bcma/sprom.c | |||
@@ -14,8 +14,6 @@ | |||
14 | #include <linux/dma-mapping.h> | 14 | #include <linux/dma-mapping.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | 16 | ||
17 | #define SPOFF(offset) ((offset) / sizeof(u16)) | ||
18 | |||
19 | /************************************************** | 17 | /************************************************** |
20 | * R/W ops. | 18 | * R/W ops. |
21 | **************************************************/ | 19 | **************************************************/ |
@@ -124,6 +122,11 @@ static int bcma_sprom_valid(const u16 *sprom) | |||
124 | * SPROM extraction. | 122 | * SPROM extraction. |
125 | **************************************************/ | 123 | **************************************************/ |
126 | 124 | ||
125 | #define SPOFF(offset) ((offset) / sizeof(u16)) | ||
126 | |||
127 | #define SPEX(_field, _offset, _mask, _shift) \ | ||
128 | bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift)) | ||
129 | |||
127 | static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) | 130 | static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) |
128 | { | 131 | { |
129 | u16 v; | 132 | u16 v; |
@@ -137,72 +140,72 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) | |||
137 | *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v); | 140 | *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v); |
138 | } | 141 | } |
139 | 142 | ||
140 | bus->sprom.board_rev = sprom[SPOFF(SSB_SPROM8_BOARDREV)]; | 143 | SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0); |
141 | 144 | ||
142 | bus->sprom.txpid2g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] & | 145 | SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0, |
143 | SSB_SPROM4_TXPID2G0) >> SSB_SPROM4_TXPID2G0_SHIFT; | 146 | SSB_SPROM4_TXPID2G0_SHIFT); |
144 | bus->sprom.txpid2g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] & | 147 | SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G1, |
145 | SSB_SPROM4_TXPID2G1) >> SSB_SPROM4_TXPID2G1_SHIFT; | 148 | SSB_SPROM4_TXPID2G1_SHIFT); |
146 | bus->sprom.txpid2g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] & | 149 | SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G2, |
147 | SSB_SPROM4_TXPID2G2) >> SSB_SPROM4_TXPID2G2_SHIFT; | 150 | SSB_SPROM4_TXPID2G2_SHIFT); |
148 | bus->sprom.txpid2g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] & | 151 | SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G3, |
149 | SSB_SPROM4_TXPID2G3) >> SSB_SPROM4_TXPID2G3_SHIFT; | 152 | SSB_SPROM4_TXPID2G3_SHIFT); |
150 | 153 | ||
151 | bus->sprom.txpid5gl[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] & | 154 | SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL0, |
152 | SSB_SPROM4_TXPID5GL0) >> SSB_SPROM4_TXPID5GL0_SHIFT; | 155 | SSB_SPROM4_TXPID5GL0_SHIFT); |
153 | bus->sprom.txpid5gl[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] & | 156 | SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL1, |
154 | SSB_SPROM4_TXPID5GL1) >> SSB_SPROM4_TXPID5GL1_SHIFT; | 157 | SSB_SPROM4_TXPID5GL1_SHIFT); |
155 | bus->sprom.txpid5gl[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] & | 158 | SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL2, |
156 | SSB_SPROM4_TXPID5GL2) >> SSB_SPROM4_TXPID5GL2_SHIFT; | 159 | SSB_SPROM4_TXPID5GL2_SHIFT); |
157 | bus->sprom.txpid5gl[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] & | 160 | SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL3, |
158 | SSB_SPROM4_TXPID5GL3) >> SSB_SPROM4_TXPID5GL3_SHIFT; | 161 | SSB_SPROM4_TXPID5GL3_SHIFT); |
159 | 162 | ||
160 | bus->sprom.txpid5g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] & | 163 | SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G0, |
161 | SSB_SPROM4_TXPID5G0) >> SSB_SPROM4_TXPID5G0_SHIFT; | 164 | SSB_SPROM4_TXPID5G0_SHIFT); |
162 | bus->sprom.txpid5g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] & | 165 | SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G1, |
163 | SSB_SPROM4_TXPID5G1) >> SSB_SPROM4_TXPID5G1_SHIFT; | 166 | SSB_SPROM4_TXPID5G1_SHIFT); |
164 | bus->sprom.txpid5g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] & | 167 | SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G2, |
165 | SSB_SPROM4_TXPID5G2) >> SSB_SPROM4_TXPID5G2_SHIFT; | 168 | SSB_SPROM4_TXPID5G2_SHIFT); |
166 | bus->sprom.txpid5g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] & | 169 | SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G3, |
167 | SSB_SPROM4_TXPID5G3) >> SSB_SPROM4_TXPID5G3_SHIFT; | 170 | SSB_SPROM4_TXPID5G3_SHIFT); |
168 | 171 | ||
169 | bus->sprom.txpid5gh[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] & | 172 | SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH0, |
170 | SSB_SPROM4_TXPID5GH0) >> SSB_SPROM4_TXPID5GH0_SHIFT; | 173 | SSB_SPROM4_TXPID5GH0_SHIFT); |
171 | bus->sprom.txpid5gh[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] & | 174 | SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH1, |
172 | SSB_SPROM4_TXPID5GH1) >> SSB_SPROM4_TXPID5GH1_SHIFT; | 175 | SSB_SPROM4_TXPID5GH1_SHIFT); |
173 | bus->sprom.txpid5gh[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] & | 176 | SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH2, |
174 | SSB_SPROM4_TXPID5GH2) >> SSB_SPROM4_TXPID5GH2_SHIFT; | 177 | SSB_SPROM4_TXPID5GH2_SHIFT); |
175 | bus->sprom.txpid5gh[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] & | 178 | SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH3, |
176 | SSB_SPROM4_TXPID5GH3) >> SSB_SPROM4_TXPID5GH3_SHIFT; | 179 | SSB_SPROM4_TXPID5GH3_SHIFT); |
177 | 180 | ||
178 | bus->sprom.boardflags_lo = sprom[SPOFF(SSB_SPROM8_BFLLO)]; | 181 | SPEX(boardflags_lo, SSB_SPROM8_BFLLO, ~0, 0); |
179 | bus->sprom.boardflags_hi = sprom[SPOFF(SSB_SPROM8_BFLHI)]; | 182 | SPEX(boardflags_hi, SSB_SPROM8_BFLHI, ~0, 0); |
180 | bus->sprom.boardflags2_lo = sprom[SPOFF(SSB_SPROM8_BFL2LO)]; | 183 | SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, ~0, 0); |
181 | bus->sprom.boardflags2_hi = sprom[SPOFF(SSB_SPROM8_BFL2HI)]; | 184 | SPEX(boardflags2_hi, SSB_SPROM8_BFL2HI, ~0, 0); |
182 | 185 | ||
183 | bus->sprom.country_code = sprom[SPOFF(SSB_SPROM8_CCODE)]; | 186 | SPEX(country_code, SSB_SPROM8_CCODE, ~0, 0); |
184 | 187 | ||
185 | bus->sprom.fem.ghz2.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & | 188 | SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TSSIPOS, |
186 | SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT; | 189 | SSB_SROM8_FEM_TSSIPOS_SHIFT); |
187 | bus->sprom.fem.ghz2.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & | 190 | SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_EXTPA_GAIN, |
188 | SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT; | 191 | SSB_SROM8_FEM_EXTPA_GAIN_SHIFT); |
189 | bus->sprom.fem.ghz2.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & | 192 | SPEX(fem.ghz2.pdet_range, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_PDET_RANGE, |
190 | SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT; | 193 | SSB_SROM8_FEM_PDET_RANGE_SHIFT); |
191 | bus->sprom.fem.ghz2.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & | 194 | SPEX(fem.ghz2.tr_iso, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TR_ISO, |
192 | SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT; | 195 | SSB_SROM8_FEM_TR_ISO_SHIFT); |
193 | bus->sprom.fem.ghz2.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & | 196 | SPEX(fem.ghz2.antswlut, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_ANTSWLUT, |
194 | SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT; | 197 | SSB_SROM8_FEM_ANTSWLUT_SHIFT); |
195 | 198 | ||
196 | bus->sprom.fem.ghz5.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & | 199 | SPEX(fem.ghz5.tssipos, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TSSIPOS, |
197 | SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT; | 200 | SSB_SROM8_FEM_TSSIPOS_SHIFT); |
198 | bus->sprom.fem.ghz5.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & | 201 | SPEX(fem.ghz5.extpa_gain, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_EXTPA_GAIN, |
199 | SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT; | 202 | SSB_SROM8_FEM_EXTPA_GAIN_SHIFT); |
200 | bus->sprom.fem.ghz5.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & | 203 | SPEX(fem.ghz5.pdet_range, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_PDET_RANGE, |
201 | SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT; | 204 | SSB_SROM8_FEM_PDET_RANGE_SHIFT); |
202 | bus->sprom.fem.ghz5.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & | 205 | SPEX(fem.ghz5.tr_iso, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TR_ISO, |
203 | SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT; | 206 | SSB_SROM8_FEM_TR_ISO_SHIFT); |
204 | bus->sprom.fem.ghz5.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & | 207 | SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_ANTSWLUT, |
205 | SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT; | 208 | SSB_SROM8_FEM_ANTSWLUT_SHIFT); |
206 | } | 209 | } |
207 | 210 | ||
208 | int bcma_sprom_get(struct bcma_bus *bus) | 211 | int bcma_sprom_get(struct bcma_bus *bus) |