aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArend van Spriel <arend@broadcom.com>2011-12-08 18:06:55 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-12-13 15:33:03 -0500
commitad5db1317c04ece569d18c692f8e49453c552d1e (patch)
tree9deb6d111e3357a6edd86e8013cda87da9682fce
parent4b006b11ca18995677c5f1cd03cc9c42fbe80693 (diff)
brcm80211: smac: remove SI_FAST() macro usage
The use of SI_FAST() macro interferes with the BCMA integration as it causes BCMA and aiutils.c to get out of sync on what the current core is. When everything is using BCMA we will try to add SI_FAST functionality to BCMA to avoid unnecessary core switching. Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com> Reviewed-by: Alwin Beukers <alwin@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Franky Lin <frankyl@broadcom.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/aiutils.c157
1 files changed, 35 insertions, 122 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index ef1441a9a4e0..7aa47b3252c2 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -318,16 +318,6 @@
318 318
319#define BADIDX (SI_MAXCORES + 1) 319#define BADIDX (SI_MAXCORES + 1)
320 320
321/* Newer chips can access PCI/PCIE and CC core without requiring to change
322 * PCI BAR0 WIN
323 */
324#define SI_FAST(sih) ((ai_get_buscoretype(sih) == PCIE_CORE_ID) || \
325 ((ai_get_buscoretype(sih) == PCI_CORE_ID) && \
326 ai_get_buscorerev(sih) >= 13))
327
328#define CCREGS_FAST(si) (((char __iomem *)((si)->curmap) + \
329 PCI_16KB0_CCREGS_OFFSET))
330
331#define IS_SIM(chippkg) \ 321#define IS_SIM(chippkg) \
332 ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID)) 322 ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID))
333 323
@@ -360,9 +350,6 @@
360 (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \ 350 (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \
361 IS_ALIGNED((x), SI_CORE_SIZE)) 351 IS_ALIGNED((x), SI_CORE_SIZE))
362 352
363#define PCIEREGS(si) ((__iomem char *)((si)->curmap) + \
364 PCI_16KB0_PCIREGS_OFFSET)
365
366struct aidmp { 353struct aidmp {
367 u32 oobselina30; /* 0x000 */ 354 u32 oobselina30; /* 0x000 */
368 u32 oobselina74; /* 0x004 */ 355 u32 oobselina74; /* 0x004 */
@@ -777,13 +764,11 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx)
777 } 764 }
778 765
779 /* fixup necessary chip/core configurations */ 766 /* fixup necessary chip/core configurations */
780 if (SI_FAST(&sii->pub)) { 767 if (!sii->pch) {
781 if (!sii->pch) { 768 sii->pch = pcicore_init(&sii->pub, sii->pcibus,
782 sii->pch = pcicore_init(&sii->pub, sii->pcibus, 769 sii->curmap + PCI_16KB0_PCIREGS_OFFSET);
783 (__iomem void *)PCIEREGS(sii)); 770 if (sii->pch == NULL)
784 if (sii->pch == NULL) 771 return false;
785 return false;
786 }
787 } 772 }
788 if (ai_pci_fixcfg(&sii->pub)) { 773 if (ai_pci_fixcfg(&sii->pub)) {
789 /* si_doattach: si_pci_fixcfg failed */ 774 /* si_doattach: si_pci_fixcfg failed */
@@ -1084,17 +1069,6 @@ void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx,
1084 1069
1085 sii = (struct si_info *)sih; 1070 sii = (struct si_info *)sih;
1086 1071
1087 if (SI_FAST(sih)) {
1088 /* Overloading the origidx variable to remember the coreid,
1089 * this works because the core ids cannot be confused with
1090 * core indices.
1091 */
1092 *origidx = coreid;
1093 if (coreid == CC_CORE_ID)
1094 return CCREGS_FAST(sii);
1095 else if (coreid == ai_get_buscoretype(sih))
1096 return PCIEREGS(sii);
1097 }
1098 INTR_OFF(sii, *intr_val); 1072 INTR_OFF(sii, *intr_val);
1099 *origidx = sii->curidx; 1073 *origidx = sii->curidx;
1100 cc = ai_setcore(sih, coreid, 0); 1074 cc = ai_setcore(sih, coreid, 0);
@@ -1107,9 +1081,6 @@ void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val)
1107 struct si_info *sii; 1081 struct si_info *sii;
1108 1082
1109 sii = (struct si_info *)sih; 1083 sii = (struct si_info *)sih;
1110 if (SI_FAST(sih)
1111 && ((coreid == CC_CORE_ID) || (coreid == ai_get_buscoretype(sih))))
1112 return;
1113 1084
1114 ai_setcoreidx(sih, coreid); 1085 ai_setcoreidx(sih, coreid);
1115 INTR_RESTORE(sii, intr_val); 1086 INTR_RESTORE(sii, intr_val);
@@ -1140,7 +1111,6 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask,
1140 u32 __iomem *r = NULL; 1111 u32 __iomem *r = NULL;
1141 uint w; 1112 uint w;
1142 uint intr_val = 0; 1113 uint intr_val = 0;
1143 bool fast = false;
1144 struct si_info *sii; 1114 struct si_info *sii;
1145 1115
1146 sii = (struct si_info *)sih; 1116 sii = (struct si_info *)sih;
@@ -1148,41 +1118,14 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask,
1148 if (coreidx >= SI_MAXCORES) 1118 if (coreidx >= SI_MAXCORES)
1149 return 0; 1119 return 0;
1150 1120
1151 /* 1121 INTR_OFF(sii, intr_val);
1152 * If pci/pcie, we can get at pci/pcie regs
1153 * and on newer cores to chipc
1154 */
1155 if ((sii->coreid[coreidx] == CC_CORE_ID) && SI_FAST(sih)) {
1156 /* Chipc registers are mapped at 12KB */
1157 fast = true;
1158 r = (u32 __iomem *)((__iomem char *)sii->curmap +
1159 PCI_16KB0_CCREGS_OFFSET + regoff);
1160 } else if (sii->buscoreidx == coreidx) {
1161 /*
1162 * pci registers are at either in the last 2KB of
1163 * an 8KB window or, in pcie and pci rev 13 at 8KB
1164 */
1165 fast = true;
1166 if (SI_FAST(sih))
1167 r = (u32 __iomem *)((__iomem char *)sii->curmap +
1168 PCI_16KB0_PCIREGS_OFFSET + regoff);
1169 else
1170 r = (u32 __iomem *)((__iomem char *)sii->curmap +
1171 ((regoff >= SBCONFIGOFF) ?
1172 PCI_BAR0_PCISBR_OFFSET :
1173 PCI_BAR0_PCIREGS_OFFSET) + regoff);
1174 }
1175
1176 if (!fast) {
1177 INTR_OFF(sii, intr_val);
1178 1122
1179 /* save current core index */ 1123 /* save current core index */
1180 origidx = ai_coreidx(&sii->pub); 1124 origidx = ai_coreidx(&sii->pub);
1181 1125
1182 /* switch core */ 1126 /* switch core */
1183 r = (u32 __iomem *) ((unsigned char __iomem *) 1127 r = (u32 __iomem *) ((unsigned char __iomem *)
1184 ai_setcoreidx(&sii->pub, coreidx) + regoff); 1128 ai_setcoreidx(&sii->pub, coreidx) + regoff);
1185 }
1186 1129
1187 /* mask and set */ 1130 /* mask and set */
1188 if (mask || val) { 1131 if (mask || val) {
@@ -1193,13 +1136,11 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask,
1193 /* readback */ 1136 /* readback */
1194 w = R_REG(r); 1137 w = R_REG(r);
1195 1138
1196 if (!fast) { 1139 /* restore core index */
1197 /* restore core index */ 1140 if (origidx != coreidx)
1198 if (origidx != coreidx) 1141 ai_setcoreidx(&sii->pub, origidx);
1199 ai_setcoreidx(&sii->pub, origidx);
1200 1142
1201 INTR_RESTORE(sii, intr_val); 1143 INTR_RESTORE(sii, intr_val);
1202 }
1203 1144
1204 return w; 1145 return w;
1205} 1146}
@@ -1354,24 +1295,16 @@ void ai_clkctl_init(struct si_pub *sih)
1354 struct si_info *sii; 1295 struct si_info *sii;
1355 uint origidx = 0; 1296 uint origidx = 0;
1356 struct chipcregs __iomem *cc; 1297 struct chipcregs __iomem *cc;
1357 bool fast;
1358 1298
1359 if (!(ai_get_cccaps(sih) & CC_CAP_PWR_CTL)) 1299 if (!(ai_get_cccaps(sih) & CC_CAP_PWR_CTL))
1360 return; 1300 return;
1361 1301
1362 sii = (struct si_info *)sih; 1302 sii = (struct si_info *)sih;
1363 fast = SI_FAST(sih); 1303 origidx = sii->curidx;
1364 if (!fast) { 1304 cc = (struct chipcregs __iomem *)
1365 origidx = sii->curidx; 1305 ai_setcore(sih, CC_CORE_ID, 0);
1366 cc = (struct chipcregs __iomem *) 1306 if (cc == NULL)
1367 ai_setcore(sih, CC_CORE_ID, 0); 1307 return;
1368 if (cc == NULL)
1369 return;
1370 } else {
1371 cc = (struct chipcregs __iomem *) CCREGS_FAST(sii);
1372 if (cc == NULL)
1373 return;
1374 }
1375 1308
1376 /* set all Instaclk chip ILP to 1 MHz */ 1309 /* set all Instaclk chip ILP to 1 MHz */
1377 if (ai_get_ccrev(sih) >= 10) 1310 if (ai_get_ccrev(sih) >= 10)
@@ -1380,8 +1313,7 @@ void ai_clkctl_init(struct si_pub *sih)
1380 1313
1381 ai_clkctl_setdelay(sii, cc); 1314 ai_clkctl_setdelay(sii, cc);
1382 1315
1383 if (!fast) 1316 ai_setcoreidx(sih, origidx);
1384 ai_setcoreidx(sih, origidx);
1385} 1317}
1386 1318
1387/* 1319/*
@@ -1396,7 +1328,6 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih)
1396 uint slowminfreq; 1328 uint slowminfreq;
1397 u16 fpdelay; 1329 u16 fpdelay;
1398 uint intr_val = 0; 1330 uint intr_val = 0;
1399 bool fast;
1400 1331
1401 sii = (struct si_info *)sih; 1332 sii = (struct si_info *)sih;
1402 if (ai_get_cccaps(sih) & CC_CAP_PMU) { 1333 if (ai_get_cccaps(sih) & CC_CAP_PMU) {
@@ -1409,30 +1340,21 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih)
1409 if (!(ai_get_cccaps(sih) & CC_CAP_PWR_CTL)) 1340 if (!(ai_get_cccaps(sih) & CC_CAP_PWR_CTL))
1410 return 0; 1341 return 0;
1411 1342
1412 fast = SI_FAST(sih);
1413 fpdelay = 0; 1343 fpdelay = 0;
1414 if (!fast) { 1344 origidx = sii->curidx;
1415 origidx = sii->curidx; 1345 INTR_OFF(sii, intr_val);
1416 INTR_OFF(sii, intr_val); 1346 cc = (struct chipcregs __iomem *)
1417 cc = (struct chipcregs __iomem *) 1347 ai_setcore(sih, CC_CORE_ID, 0);
1418 ai_setcore(sih, CC_CORE_ID, 0); 1348 if (cc == NULL)
1419 if (cc == NULL) 1349 goto done;
1420 goto done;
1421 } else {
1422 cc = (struct chipcregs __iomem *) CCREGS_FAST(sii);
1423 if (cc == NULL)
1424 goto done;
1425 }
1426 1350
1427 slowminfreq = ai_slowclk_freq(sii, false, cc); 1351 slowminfreq = ai_slowclk_freq(sii, false, cc);
1428 fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + 1352 fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) +
1429 (slowminfreq - 1)) / slowminfreq; 1353 (slowminfreq - 1)) / slowminfreq;
1430 1354
1431 done: 1355 done:
1432 if (!fast) { 1356 ai_setcoreidx(sih, origidx);
1433 ai_setcoreidx(sih, origidx); 1357 INTR_RESTORE(sii, intr_val);
1434 INTR_RESTORE(sii, intr_val);
1435 }
1436 return fpdelay; 1358 return fpdelay;
1437} 1359}
1438 1360
@@ -1506,22 +1428,15 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode)
1506 struct chipcregs __iomem *cc; 1428 struct chipcregs __iomem *cc;
1507 u32 scc; 1429 u32 scc;
1508 uint intr_val = 0; 1430 uint intr_val = 0;
1509 bool fast = SI_FAST(&sii->pub);
1510 1431
1511 /* chipcommon cores prior to rev6 don't support dynamic clock control */ 1432 /* chipcommon cores prior to rev6 don't support dynamic clock control */
1512 if (ai_get_ccrev(&sii->pub) < 6) 1433 if (ai_get_ccrev(&sii->pub) < 6)
1513 return false; 1434 return false;
1514 1435
1515 if (!fast) { 1436 INTR_OFF(sii, intr_val);
1516 INTR_OFF(sii, intr_val); 1437 origidx = sii->curidx;
1517 origidx = sii->curidx; 1438 cc = (struct chipcregs __iomem *)
1518 cc = (struct chipcregs __iomem *) 1439 ai_setcore(&sii->pub, CC_CORE_ID, 0);
1519 ai_setcore(&sii->pub, CC_CORE_ID, 0);
1520 } else {
1521 cc = (struct chipcregs __iomem *) CCREGS_FAST(sii);
1522 if (cc == NULL)
1523 goto done;
1524 }
1525 1440
1526 if (!(ai_get_cccaps(&sii->pub) & CC_CAP_PWR_CTL) && 1441 if (!(ai_get_cccaps(&sii->pub) & CC_CAP_PWR_CTL) &&
1527 (ai_get_ccrev(&sii->pub) < 20)) 1442 (ai_get_ccrev(&sii->pub) < 20))
@@ -1580,10 +1495,8 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode)
1580 } 1495 }
1581 1496
1582 done: 1497 done:
1583 if (!fast) { 1498 ai_setcoreidx(&sii->pub, origidx);
1584 ai_setcoreidx(&sii->pub, origidx); 1499 INTR_RESTORE(sii, intr_val);
1585 INTR_RESTORE(sii, intr_val);
1586 }
1587 return mode == CLK_FAST; 1500 return mode == CLK_FAST;
1588} 1501}
1589 1502