Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

brcm80211: smac: use bcma core access functions in aiutils.c

The code in aiutils.c now uses the BCMA function for control the
registers in the device cores.

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>

authored by

Arend van Spriel and committed by
John W. Linville
c8086745 8d30b708

+70 -120
+70 -120
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
··· 558 558 } 559 559 560 560 static bool 561 - ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) 561 + ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) 562 562 { 563 563 bool pci, pcie; 564 564 uint i; 565 565 uint pciidx, pcieidx, pcirev, pcierev; 566 - struct chipcregs __iomem *cc; 567 - 568 - cc = ai_setcoreidx(&sii->pub, SI_CC_IDX); 569 566 570 567 /* get chipcommon rev */ 571 - sii->pub.ccrev = (int)ai_corerev(&sii->pub); 568 + sii->pub.ccrev = cc->id.rev; 572 569 573 570 /* get chipcommon chipstatus */ 574 571 if (ai_get_ccrev(&sii->pub) >= 11) 575 - sii->chipst = R_REG(&cc->chipstatus); 572 + sii->chipst = bcma_read32(cc, CHIPCREGOFFS(chipstatus)); 576 573 577 574 /* get chipcommon capabilites */ 578 - sii->pub.cccaps = R_REG(&cc->capabilities); 575 + sii->pub.cccaps = bcma_read32(cc, CHIPCREGOFFS(capabilities)); 579 576 580 577 /* get pmu rev and caps */ 581 578 if (ai_get_cccaps(&sii->pub) & CC_CAP_PMU) { 582 - sii->pub.pmucaps = R_REG(&cc->pmucapabilities); 579 + sii->pub.pmucaps = bcma_read32(cc, 580 + CHIPCREGOFFS(pmucapabilities)); 583 581 sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK; 584 582 } 585 583 ··· 606 608 pcierev = crev; 607 609 pcie = true; 608 610 } 609 - 610 - /* find the core idx before entering this func. */ 611 - if ((savewin && (savewin == sii->coresba[i])) || 612 - (cc == sii->regs[i])) 613 - *origidx = i; 614 611 } 615 612 616 613 if (pci && pcie) { ··· 635 642 return false; 636 643 } 637 644 638 - /* return to the original core */ 639 - ai_setcoreidx(&sii->pub, *origidx); 640 - 641 645 return true; 642 646 } 643 647 ··· 658 668 void __iomem *regs = pbus->mmio; 659 669 struct si_pub *sih = &sii->pub; 660 670 u32 w, savewin; 661 - struct chipcregs __iomem *cc; 671 + struct bcma_device *cc; 662 672 uint socitype; 663 - uint origidx; 664 673 665 674 memset((unsigned char *) sii, 0, sizeof(struct si_info)); 666 675 ··· 672 683 sii->curwrap = sii->curmap + SI_CORE_SIZE; 673 684 674 685 /* switch to Chipcommon core */ 675 - bcma_read32(pbus->drv_cc.core, 0); 676 - savewin = SI_ENUM_BASE; 677 - 678 - cc = (struct chipcregs __iomem *) regs; 686 + cc = pbus->drv_cc.core; 679 687 680 688 /* bus/core/clk setup for register access */ 681 689 if (!ai_buscore_prep(sii)) ··· 685 699 * hosts w/o chipcommon), some way of recognizing them needs to 686 700 * be added here. 687 701 */ 688 - w = R_REG(&cc->chipid); 702 + w = bcma_read32(cc, CHIPCREGOFFS(chipid)); 689 703 socitype = (w & CID_TYPE_MASK) >> CID_TYPE_SHIFT; 690 704 /* Might as wll fill in chip id rev & pkg */ 691 705 sih->chip = w & CID_ID_MASK; ··· 706 720 return NULL; 707 721 708 722 /* bus/core/clk setup */ 709 - origidx = SI_CC_IDX; 710 - if (!ai_buscore_setup(sii, savewin, &origidx)) 723 + if (!ai_buscore_setup(sii, cc)) 711 724 goto exit; 712 725 713 726 /* Init nvram from sprom/otp if they exist */ ··· 716 731 ai_nvram_process(sii); 717 732 718 733 /* === NVRAM, clock is ready === */ 719 - cc = (struct chipcregs __iomem *) ai_setcore(sih, CC_CORE_ID, 0); 720 - W_REG(&cc->gpiopullup, 0); 721 - W_REG(&cc->gpiopulldown, 0); 722 - ai_setcoreidx(sih, origidx); 734 + bcma_write32(cc, CHIPCREGOFFS(gpiopullup), 0); 735 + bcma_write32(cc, CHIPCREGOFFS(gpiopulldown), 0); 723 736 724 737 /* PMU specific initializations */ 725 738 if (ai_get_cccaps(sih) & CC_CAP_PMU) { ··· 973 990 } 974 991 975 992 /* return the slow clock source - LPO, XTAL, or PCI */ 976 - static uint ai_slowclk_src(struct si_info *sii) 993 + static uint ai_slowclk_src(struct si_pub *sih, struct bcma_device *cc) 977 994 { 978 - struct chipcregs __iomem *cc; 995 + struct si_info *sii; 979 996 u32 val; 980 997 998 + sii = (struct si_info *)sih; 981 999 if (ai_get_ccrev(&sii->pub) < 6) { 982 1000 pci_read_config_dword(sii->pcibus, PCI_GPIO_OUT, 983 1001 &val); ··· 986 1002 return SCC_SS_PCI; 987 1003 return SCC_SS_XTAL; 988 1004 } else if (ai_get_ccrev(&sii->pub) < 10) { 989 - cc = (struct chipcregs __iomem *) 990 - ai_setcoreidx(&sii->pub, sii->curidx); 991 - return R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK; 1005 + return bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl)) & 1006 + SCC_SS_MASK; 992 1007 } else /* Insta-clock */ 993 1008 return SCC_SS_XTAL; 994 1009 } ··· 996 1013 * return the ILP (slowclock) min or max frequency 997 1014 * precondition: we've established the chip has dynamic clk control 998 1015 */ 999 - static uint ai_slowclk_freq(struct si_info *sii, bool max_freq, 1000 - struct chipcregs __iomem *cc) 1016 + static uint ai_slowclk_freq(struct si_pub *sih, bool max_freq, 1017 + struct bcma_device *cc) 1001 1018 { 1002 1019 u32 slowclk; 1003 1020 uint div; 1004 1021 1005 - slowclk = ai_slowclk_src(sii); 1006 - if (ai_get_ccrev(&sii->pub) < 6) { 1022 + slowclk = ai_slowclk_src(sih, cc); 1023 + if (ai_get_ccrev(sih) < 6) { 1007 1024 if (slowclk == SCC_SS_PCI) 1008 1025 return max_freq ? (PCIMAXFREQ / 64) 1009 1026 : (PCIMINFREQ / 64); 1010 1027 else 1011 1028 return max_freq ? (XTALMAXFREQ / 32) 1012 1029 : (XTALMINFREQ / 32); 1013 - } else if (ai_get_ccrev(&sii->pub) < 10) { 1030 + } else if (ai_get_ccrev(sih) < 10) { 1014 1031 div = 4 * 1015 - (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> 1016 - SCC_CD_SHIFT) + 1); 1032 + (((bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl)) & 1033 + SCC_CD_MASK) >> SCC_CD_SHIFT) + 1); 1017 1034 if (slowclk == SCC_SS_LPO) 1018 1035 return max_freq ? LPOMAXFREQ : LPOMINFREQ; 1019 1036 else if (slowclk == SCC_SS_XTAL) ··· 1024 1041 : (PCIMINFREQ / div); 1025 1042 } else { 1026 1043 /* Chipc rev 10 is InstaClock */ 1027 - div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT; 1028 - div = 4 * (div + 1); 1044 + div = bcma_read32(cc, CHIPCREGOFFS(system_clk_ctl)); 1045 + div = 4 * ((div >> SYCC_CD_SHIFT) + 1); 1029 1046 return max_freq ? XTALMAXFREQ : (XTALMINFREQ / div); 1030 1047 } 1031 1048 return 0; 1032 1049 } 1033 1050 1034 1051 static void 1035 - ai_clkctl_setdelay(struct si_info *sii, struct chipcregs __iomem *cc) 1052 + ai_clkctl_setdelay(struct si_pub *sih, struct bcma_device *cc) 1036 1053 { 1037 1054 uint slowmaxfreq, pll_delay, slowclk; 1038 1055 uint pll_on_delay, fref_sel_delay; ··· 1045 1062 * powered down by dynamic clk control logic. 1046 1063 */ 1047 1064 1048 - slowclk = ai_slowclk_src(sii); 1065 + slowclk = ai_slowclk_src(sih, cc); 1049 1066 if (slowclk != SCC_SS_XTAL) 1050 1067 pll_delay += XTAL_ON_DELAY; 1051 1068 1052 1069 /* Starting with 4318 it is ILP that is used for the delays */ 1053 1070 slowmaxfreq = 1054 - ai_slowclk_freq(sii, 1055 - (ai_get_ccrev(&sii->pub) >= 10) ? false : true, cc); 1071 + ai_slowclk_freq(sih, 1072 + (ai_get_ccrev(sih) >= 10) ? false : true, cc); 1056 1073 1057 1074 pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000; 1058 1075 fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000; 1059 1076 1060 - W_REG(&cc->pll_on_delay, pll_on_delay); 1061 - W_REG(&cc->fref_sel_delay, fref_sel_delay); 1077 + bcma_write32(cc, CHIPCREGOFFS(pll_on_delay), pll_on_delay); 1078 + bcma_write32(cc, CHIPCREGOFFS(fref_sel_delay), fref_sel_delay); 1062 1079 } 1063 1080 1064 1081 /* initialize power control delay registers */ 1065 1082 void ai_clkctl_init(struct si_pub *sih) 1066 1083 { 1067 - struct si_info *sii; 1068 - uint origidx = 0; 1069 - struct chipcregs __iomem *cc; 1084 + struct bcma_device *cc; 1070 1085 1071 1086 if (!(ai_get_cccaps(sih) & CC_CAP_PWR_CTL)) 1072 1087 return; 1073 1088 1074 - sii = (struct si_info *)sih; 1075 - origidx = sii->curidx; 1076 - cc = (struct chipcregs __iomem *) 1077 - ai_setcore(sih, CC_CORE_ID, 0); 1089 + cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); 1078 1090 if (cc == NULL) 1079 1091 return; 1080 1092 1081 1093 /* set all Instaclk chip ILP to 1 MHz */ 1082 1094 if (ai_get_ccrev(sih) >= 10) 1083 - SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, 1084 - (ILP_DIV_1MHZ << SYCC_CD_SHIFT)); 1095 + bcma_maskset32(cc, CHIPCREGOFFS(system_clk_ctl), SYCC_CD_MASK, 1096 + (ILP_DIV_1MHZ << SYCC_CD_SHIFT)); 1085 1097 1086 - ai_clkctl_setdelay(sii, cc); 1087 - 1088 - ai_setcoreidx(sih, origidx); 1098 + ai_clkctl_setdelay(sih, cc); 1089 1099 } 1090 1100 1091 1101 /* ··· 1088 1112 u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) 1089 1113 { 1090 1114 struct si_info *sii; 1091 - uint origidx = 0; 1092 - struct chipcregs __iomem *cc; 1115 + struct bcma_device *cc; 1093 1116 uint slowminfreq; 1094 1117 u16 fpdelay; 1095 1118 uint intr_val = 0; ··· 1105 1130 return 0; 1106 1131 1107 1132 fpdelay = 0; 1108 - origidx = sii->curidx; 1109 1133 INTR_OFF(sii, intr_val); 1110 - cc = (struct chipcregs __iomem *) 1111 - ai_setcore(sih, CC_CORE_ID, 0); 1134 + cc = ai_findcore(sih, CC_CORE_ID, 0); 1112 1135 if (cc == NULL) 1113 1136 goto done; 1114 1137 1115 - slowminfreq = ai_slowclk_freq(sii, false, cc); 1116 - fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + 1117 - (slowminfreq - 1)) / slowminfreq; 1138 + 1139 + slowminfreq = ai_slowclk_freq(sih, false, cc); 1140 + fpdelay = (((bcma_read32(cc, CHIPCREGOFFS(pll_on_delay)) + 2) * 1000000) 1141 + + (slowminfreq - 1)) / slowminfreq; 1118 1142 1119 1143 done: 1120 - ai_setcoreidx(sih, origidx); 1121 1144 INTR_RESTORE(sii, intr_val); 1122 1145 return fpdelay; 1123 1146 } ··· 1186 1213 /* clk control mechanism through chipcommon, no policy checking */ 1187 1214 static bool _ai_clkctl_cc(struct si_info *sii, uint mode) 1188 1215 { 1189 - uint origidx = 0; 1190 - struct chipcregs __iomem *cc; 1216 + struct bcma_device *cc; 1191 1217 u32 scc; 1192 1218 uint intr_val = 0; 1193 1219 ··· 1195 1223 return false; 1196 1224 1197 1225 INTR_OFF(sii, intr_val); 1198 - origidx = sii->curidx; 1199 - cc = (struct chipcregs __iomem *) 1200 - ai_setcore(&sii->pub, CC_CORE_ID, 0); 1226 + cc = ai_findcore(&sii->pub, BCMA_CORE_CHIPCOMMON, 0); 1201 1227 1202 1228 if (!(ai_get_cccaps(&sii->pub) & CC_CAP_PWR_CTL) && 1203 1229 (ai_get_ccrev(&sii->pub) < 20)) ··· 1209 1239 * on before we clear SCC_DYN_XTAL.. 1210 1240 */ 1211 1241 ai_clkctl_xtal(&sii->pub, XTAL, ON); 1212 - SET_REG(&cc->slow_clk_ctl, 1213 - (SCC_XC | SCC_FS | SCC_IP), SCC_IP); 1242 + bcma_maskset32(cc, CHIPCREGOFFS(slow_clk_ctl), 1243 + (SCC_XC | SCC_FS | SCC_IP), SCC_IP); 1214 1244 } else if (ai_get_ccrev(&sii->pub) < 20) { 1215 - OR_REG(&cc->system_clk_ctl, SYCC_HR); 1245 + bcma_set32(cc, CHIPCREGOFFS(system_clk_ctl), SYCC_HR); 1216 1246 } else { 1217 - OR_REG(&cc->clk_ctl_st, CCS_FORCEHT); 1247 + bcma_set32(cc, CHIPCREGOFFS(clk_ctl_st), CCS_FORCEHT); 1218 1248 } 1219 1249 1220 1250 /* wait for the PLL */ 1221 1251 if (ai_get_cccaps(&sii->pub) & CC_CAP_PMU) { 1222 1252 u32 htavail = CCS_HTAVAIL; 1223 - SPINWAIT(((R_REG(&cc->clk_ctl_st) & htavail) 1224 - == 0), PMU_MAX_TRANSITION_DLY); 1253 + SPINWAIT(((bcma_read32(cc, CHIPCREGOFFS(clk_ctl_st)) & 1254 + htavail) == 0), PMU_MAX_TRANSITION_DLY); 1225 1255 } else { 1226 1256 udelay(PLL_DELAY); 1227 1257 } ··· 1229 1259 1230 1260 case CLK_DYNAMIC: /* enable dynamic clock control */ 1231 1261 if (ai_get_ccrev(&sii->pub) < 10) { 1232 - scc = R_REG(&cc->slow_clk_ctl); 1262 + scc = bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl)); 1233 1263 scc &= ~(SCC_FS | SCC_IP | SCC_XC); 1234 1264 if ((scc & SCC_SS_MASK) != SCC_SS_XTAL) 1235 1265 scc |= SCC_XC; 1236 - W_REG(&cc->slow_clk_ctl, scc); 1266 + bcma_write32(cc, CHIPCREGOFFS(slow_clk_ctl), scc); 1237 1267 1238 1268 /* 1239 1269 * for dynamic control, we have to ··· 1243 1273 ai_clkctl_xtal(&sii->pub, XTAL, OFF); 1244 1274 } else if (ai_get_ccrev(&sii->pub) < 20) { 1245 1275 /* Instaclock */ 1246 - AND_REG(&cc->system_clk_ctl, ~SYCC_HR); 1276 + bcma_mask32(cc, CHIPCREGOFFS(system_clk_ctl), ~SYCC_HR); 1247 1277 } else { 1248 - AND_REG(&cc->clk_ctl_st, ~CCS_FORCEHT); 1278 + bcma_mask32(cc, CHIPCREGOFFS(clk_ctl_st), ~CCS_FORCEHT); 1249 1279 } 1250 1280 break; 1251 1281 ··· 1254 1284 } 1255 1285 1256 1286 done: 1257 - ai_setcoreidx(&sii->pub, origidx); 1258 1287 INTR_RESTORE(sii, intr_val); 1259 1288 return mode == CLK_FAST; 1260 1289 } ··· 1396 1427 1397 1428 void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) 1398 1429 { 1399 - struct si_info *sii; 1400 - struct chipcregs __iomem *cc; 1401 - uint origidx; 1430 + struct bcma_device *cc; 1402 1431 u32 val; 1403 1432 1404 - sii = (struct si_info *)sih; 1405 - origidx = ai_coreidx(sih); 1406 - 1407 - cc = (struct chipcregs __iomem *) ai_setcore(sih, CC_CORE_ID, 0); 1408 - 1409 - val = R_REG(&cc->chipcontrol); 1433 + cc = ai_findcore(sih, CC_CORE_ID, 0); 1410 1434 1411 1435 if (on) { 1412 1436 if (ai_get_chippkg(sih) == 9 || ai_get_chippkg(sih) == 0xb) 1413 1437 /* Ext PA Controls for 4331 12x9 Package */ 1414 - W_REG(&cc->chipcontrol, val | 1415 - CCTRL4331_EXTPA_EN | 1416 - CCTRL4331_EXTPA_ON_GPIO2_5); 1438 + bcma_set32(cc, CHIPCREGOFFS(chipcontrol), 1439 + CCTRL4331_EXTPA_EN | 1440 + CCTRL4331_EXTPA_ON_GPIO2_5); 1417 1441 else 1418 1442 /* Ext PA Controls for 4331 12x12 Package */ 1419 - W_REG(&cc->chipcontrol, 1420 - val | CCTRL4331_EXTPA_EN); 1443 + bcma_set32(cc, CHIPCREGOFFS(chipcontrol), 1444 + CCTRL4331_EXTPA_EN); 1421 1445 } else { 1422 1446 val &= ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5); 1423 - W_REG(&cc->chipcontrol, val); 1447 + bcma_mask32(cc, CHIPCREGOFFS(chipcontrol), 1448 + ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5)); 1424 1449 } 1425 - 1426 - ai_setcoreidx(sih, origidx); 1427 1450 } 1428 1451 1429 1452 /* Enable BT-COEX & Ex-PA for 4313 */ 1430 1453 void ai_epa_4313war(struct si_pub *sih) 1431 1454 { 1432 - struct si_info *sii; 1433 - struct chipcregs __iomem *cc; 1434 - uint origidx; 1455 + struct bcma_device *cc; 1435 1456 1436 - sii = (struct si_info *)sih; 1437 - origidx = ai_coreidx(sih); 1438 - 1439 - cc = ai_setcore(sih, CC_CORE_ID, 0); 1457 + cc = ai_findcore(sih, CC_CORE_ID, 0); 1440 1458 1441 1459 /* EPA Fix */ 1442 - W_REG(&cc->gpiocontrol, 1443 - R_REG(&cc->gpiocontrol) | GPIO_CTRL_EPA_EN_MASK); 1444 - 1445 - ai_setcoreidx(sih, origidx); 1460 + bcma_set32(cc, CHIPCREGOFFS(gpiocontrol), GPIO_CTRL_EPA_EN_MASK); 1446 1461 } 1447 1462 1448 1463 /* check if the device is removed */ ··· 1449 1496 struct si_info *sii = (struct si_info *)sih; 1450 1497 1451 1498 if (ai_get_ccrev(sih) >= 31) { 1452 - uint origidx; 1453 - struct chipcregs __iomem *cc; 1499 + struct bcma_device *cc; 1454 1500 u32 sromctrl; 1455 1501 1456 1502 if ((ai_get_cccaps(sih) & CC_CAP_SROM) == 0) 1457 1503 return false; 1458 1504 1459 - origidx = sii->curidx; 1460 - cc = ai_setcoreidx(sih, SI_CC_IDX); 1461 - sromctrl = R_REG(&cc->sromcontrol); 1462 - ai_setcoreidx(sih, origidx); 1505 + cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); 1506 + sromctrl = bcma_read32(cc, CHIPCREGOFFS(sromcontrol)); 1463 1507 return sromctrl & SRC_PRESENT; 1464 1508 } 1465 1509