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 pmu.c

The code in pmu.c now uses the functions provided by BCMA to
access the core registers.

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
8d30b708 b14f1674

+73 -80
+73 -80
drivers/net/wireless/brcm80211/brcmsmac/pmu.c
··· 140 140 } 141 141 142 142 static void 143 - si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct chipcregs __iomem *cc, 143 + si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct bcma_device *core, 144 144 u8 spuravoid) 145 145 { 146 146 u32 tmp = 0; ··· 149 149 case BCM43224_CHIP_ID: 150 150 case BCM43225_CHIP_ID: 151 151 if (spuravoid == 1) { 152 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); 153 - W_REG(&cc->pllcontrol_data, 0x11500010); 154 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); 155 - W_REG(&cc->pllcontrol_data, 0x000C0C06); 156 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); 157 - W_REG(&cc->pllcontrol_data, 0x0F600a08); 158 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); 159 - W_REG(&cc->pllcontrol_data, 0x00000000); 160 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); 161 - W_REG(&cc->pllcontrol_data, 0x2001E920); 162 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); 163 - W_REG(&cc->pllcontrol_data, 0x88888815); 152 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 153 + PMU1_PLL0_PLLCTL0); 154 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 155 + 0x11500010); 156 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 157 + PMU1_PLL0_PLLCTL1); 158 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 159 + 0x000C0C06); 160 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 161 + PMU1_PLL0_PLLCTL2); 162 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 163 + 0x0F600a08); 164 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 165 + PMU1_PLL0_PLLCTL3); 166 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 167 + 0x00000000); 168 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 169 + PMU1_PLL0_PLLCTL4); 170 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 171 + 0x2001E920); 172 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 173 + PMU1_PLL0_PLLCTL5); 174 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 175 + 0x88888815); 164 176 } else { 165 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); 166 - W_REG(&cc->pllcontrol_data, 0x11100010); 167 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); 168 - W_REG(&cc->pllcontrol_data, 0x000c0c06); 169 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); 170 - W_REG(&cc->pllcontrol_data, 0x03000a08); 171 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); 172 - W_REG(&cc->pllcontrol_data, 0x00000000); 173 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); 174 - W_REG(&cc->pllcontrol_data, 0x200005c0); 175 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); 176 - W_REG(&cc->pllcontrol_data, 0x88888815); 177 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 178 + PMU1_PLL0_PLLCTL0); 179 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 180 + 0x11100010); 181 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 182 + PMU1_PLL0_PLLCTL1); 183 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 184 + 0x000c0c06); 185 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 186 + PMU1_PLL0_PLLCTL2); 187 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 188 + 0x03000a08); 189 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 190 + PMU1_PLL0_PLLCTL3); 191 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 192 + 0x00000000); 193 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 194 + PMU1_PLL0_PLLCTL4); 195 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 196 + 0x200005c0); 197 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), 198 + PMU1_PLL0_PLLCTL5); 199 + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), 200 + 0x88888815); 177 201 } 178 - tmp = 1 << 10; 179 - break; 180 - 181 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); 182 - W_REG(&cc->pllcontrol_data, 0x11100008); 183 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); 184 - W_REG(&cc->pllcontrol_data, 0x0c000c06); 185 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); 186 - W_REG(&cc->pllcontrol_data, 0x03000a08); 187 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); 188 - W_REG(&cc->pllcontrol_data, 0x00000000); 189 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); 190 - W_REG(&cc->pllcontrol_data, 0x200005c0); 191 - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); 192 - W_REG(&cc->pllcontrol_data, 0x88888855); 193 - 194 202 tmp = 1 << 10; 195 203 break; 196 204 ··· 207 199 return; 208 200 } 209 201 210 - tmp |= R_REG(&cc->pmucontrol); 211 - W_REG(&cc->pmucontrol, tmp); 202 + bcma_set32(core, CHIPCREGOFFS(pmucontrol), tmp); 212 203 } 213 204 214 205 u16 si_pmu_fast_pwrup_delay(struct si_pub *sih) ··· 296 289 297 290 void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid) 298 291 { 299 - struct chipcregs __iomem *cc; 292 + struct bcma_device *cc; 300 293 uint origidx, intr_val; 301 294 302 - /* Remember original core before switch to chipc */ 303 - cc = (struct chipcregs __iomem *) 304 - ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val); 295 + /* switch to chipc */ 296 + cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); 297 + ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val); 305 298 306 299 /* update the pll changes */ 307 300 si_pmu_spuravoid_pllupdate(sih, cc, spuravoid); ··· 313 306 /* initialize PMU */ 314 307 void si_pmu_init(struct si_pub *sih) 315 308 { 316 - struct chipcregs __iomem *cc; 317 - uint origidx; 309 + struct bcma_device *core; 318 310 319 - /* Remember original core before switch to chipc */ 320 - origidx = ai_coreidx(sih); 321 - cc = ai_setcoreidx(sih, SI_CC_IDX); 311 + /* select chipc */ 312 + core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); 322 313 323 314 if (ai_get_pmurev(sih) == 1) 324 - AND_REG(&cc->pmucontrol, ~PCTL_NOILP_ON_WAIT); 315 + bcma_mask32(core, CHIPCREGOFFS(pmucontrol), 316 + ~PCTL_NOILP_ON_WAIT); 325 317 else if (ai_get_pmurev(sih) >= 2) 326 - OR_REG(&cc->pmucontrol, PCTL_NOILP_ON_WAIT); 327 - 328 - /* Return to original core */ 329 - ai_setcoreidx(sih, origidx); 318 + bcma_set32(core, CHIPCREGOFFS(pmucontrol), PCTL_NOILP_ON_WAIT); 330 319 } 331 320 332 321 /* initialize PMU chip controls and other chip level stuff */ ··· 372 369 /* initialize PMU resources */ 373 370 void si_pmu_res_init(struct si_pub *sih) 374 371 { 375 - struct chipcregs __iomem *cc; 376 - uint origidx; 372 + struct bcma_device *core; 377 373 u32 min_mask = 0, max_mask = 0; 378 374 379 - /* Remember original core before switch to chipc */ 380 - origidx = ai_coreidx(sih); 381 - cc = ai_setcoreidx(sih, SI_CC_IDX); 375 + /* select to chipc */ 376 + core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); 382 377 383 378 /* Determine min/max rsrc masks */ 384 379 si_pmu_res_masks(sih, &min_mask, &max_mask); ··· 386 385 /* Program max resource mask */ 387 386 388 387 if (max_mask) 389 - W_REG(&cc->max_res_mask, max_mask); 388 + bcma_write32(core, CHIPCREGOFFS(max_res_mask), max_mask); 390 389 391 390 /* Program min resource mask */ 392 391 393 392 if (min_mask) 394 - W_REG(&cc->min_res_mask, min_mask); 393 + bcma_write32(core, CHIPCREGOFFS(min_res_mask), min_mask); 395 394 396 395 /* Add some delay; allow resources to come up and settle. */ 397 396 mdelay(2); 398 - 399 - /* Return to original core */ 400 - ai_setcoreidx(sih, origidx); 401 397 } 402 398 403 399 u32 si_pmu_measure_alpclk(struct si_pub *sih) 404 400 { 405 - struct chipcregs __iomem *cc; 406 - uint origidx; 401 + struct bcma_device *core; 407 402 u32 alp_khz; 408 403 409 404 if (ai_get_pmurev(sih) < 10) 410 405 return 0; 411 406 412 407 /* Remember original core before switch to chipc */ 413 - origidx = ai_coreidx(sih); 414 - cc = ai_setcoreidx(sih, SI_CC_IDX); 408 + core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); 415 409 416 - if (R_REG(&cc->pmustatus) & PST_EXTLPOAVAIL) { 410 + if (bcma_read32(core, CHIPCREGOFFS(pmustatus)) & PST_EXTLPOAVAIL) { 417 411 u32 ilp_ctr, alp_hz; 418 412 419 413 /* 420 414 * Enable the reg to measure the freq, 421 415 * in case it was disabled before 422 416 */ 423 - W_REG(&cc->pmu_xtalfreq, 424 - 1U << PMU_XTALFREQ_REG_MEASURE_SHIFT); 417 + bcma_write32(core, CHIPCREGOFFS(pmu_xtalfreq), 418 + 1U << PMU_XTALFREQ_REG_MEASURE_SHIFT); 425 419 426 420 /* Delay for well over 4 ILP clocks */ 427 421 udelay(1000); 428 422 429 423 /* Read the latched number of ALP ticks per 4 ILP ticks */ 430 - ilp_ctr = 431 - R_REG(&cc->pmu_xtalfreq) & PMU_XTALFREQ_REG_ILPCTR_MASK; 424 + ilp_ctr = bcma_read32(core, CHIPCREGOFFS(pmu_xtalfreq)) & 425 + PMU_XTALFREQ_REG_ILPCTR_MASK; 432 426 433 427 /* 434 428 * Turn off the PMU_XTALFREQ_REG_MEASURE_SHIFT 435 429 * bit to save power 436 430 */ 437 - W_REG(&cc->pmu_xtalfreq, 0); 431 + bcma_write32(core, CHIPCREGOFFS(pmu_xtalfreq), 0); 438 432 439 433 /* Calculate ALP frequency */ 440 434 alp_hz = (ilp_ctr * EXT_ILP_HZ) / 4; ··· 441 445 alp_khz = (alp_hz + 50000) / 100000 * 100; 442 446 } else 443 447 alp_khz = 0; 444 - 445 - /* Return to original core */ 446 - ai_setcoreidx(sih, origidx); 447 448 448 449 return alp_khz; 449 450 }