Lines Matching refs:pi
26 #define VALID_RADIO(pi, radioid) ( \ argument
27 (ISNPHY(pi) ? VALID_N_RADIO(radioid) : false) || \
28 (ISLCNPHY(pi) ? VALID_LCN_RADIO(radioid) : false))
120 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phyreg_enter() local
121 wlapi_bmac_ucode_wake_override_phyreg_set(pi->sh->physhim); in wlc_phyreg_enter()
126 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phyreg_exit() local
127 wlapi_bmac_ucode_wake_override_phyreg_clear(pi->sh->physhim); in wlc_phyreg_exit()
132 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_radioreg_enter() local
133 wlapi_bmac_mctrl(pi->sh->physhim, MCTL_LOCK_RADIO, MCTL_LOCK_RADIO); in wlc_radioreg_enter()
140 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_radioreg_exit() local
142 (void)bcma_read16(pi->d11core, D11REGOFFS(phyversion)); in wlc_radioreg_exit()
143 pi->phy_wreg = 0; in wlc_radioreg_exit()
144 wlapi_bmac_mctrl(pi->sh->physhim, MCTL_LOCK_RADIO, 0); in wlc_radioreg_exit()
147 u16 read_radio_reg(struct brcms_phy *pi, u16 addr) in read_radio_reg() argument
154 switch (pi->pubpi.phy_type) { in read_radio_reg()
158 if (NREV_GE(pi->pubpi.phy_rev, 7)) in read_radio_reg()
174 if ((D11REV_GE(pi->sh->corerev, 24)) || in read_radio_reg()
175 (D11REV_IS(pi->sh->corerev, 22) in read_radio_reg()
176 && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { in read_radio_reg()
177 bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), addr); in read_radio_reg()
178 data = bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); in read_radio_reg()
180 bcma_wflush16(pi->d11core, D11REGOFFS(phy4waddr), addr); in read_radio_reg()
181 data = bcma_read16(pi->d11core, D11REGOFFS(phy4wdatalo)); in read_radio_reg()
183 pi->phy_wreg = 0; in read_radio_reg()
188 void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) in write_radio_reg() argument
190 if ((D11REV_GE(pi->sh->corerev, 24)) || in write_radio_reg()
191 (D11REV_IS(pi->sh->corerev, 22) in write_radio_reg()
192 && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { in write_radio_reg()
194 bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), addr); in write_radio_reg()
195 bcma_write16(pi->d11core, D11REGOFFS(radioregdata), val); in write_radio_reg()
197 bcma_wflush16(pi->d11core, D11REGOFFS(phy4waddr), addr); in write_radio_reg()
198 bcma_write16(pi->d11core, D11REGOFFS(phy4wdatalo), val); in write_radio_reg()
201 if ((pi->d11core->bus->hosttype == BCMA_HOSTTYPE_PCI) && in write_radio_reg()
202 (++pi->phy_wreg >= pi->phy_wreg_limit)) { in write_radio_reg()
203 (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); in write_radio_reg()
204 pi->phy_wreg = 0; in write_radio_reg()
208 static u32 read_radio_id(struct brcms_phy *pi) in read_radio_id() argument
212 if (D11REV_GE(pi->sh->corerev, 24)) { in read_radio_id()
215 bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 0); in read_radio_id()
216 b0 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); in read_radio_id()
217 bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 1); in read_radio_id()
218 b1 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); in read_radio_id()
219 bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 2); in read_radio_id()
220 b2 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); in read_radio_id()
225 bcma_wflush16(pi->d11core, D11REGOFFS(phy4waddr), RADIO_IDCODE); in read_radio_id()
226 id = (u32) bcma_read16(pi->d11core, D11REGOFFS(phy4wdatalo)); in read_radio_id()
227 id |= (u32) bcma_read16(pi->d11core, in read_radio_id()
230 pi->phy_wreg = 0; in read_radio_id()
234 void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) in and_radio_reg() argument
238 rval = read_radio_reg(pi, addr); in and_radio_reg()
239 write_radio_reg(pi, addr, (rval & val)); in and_radio_reg()
242 void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) in or_radio_reg() argument
246 rval = read_radio_reg(pi, addr); in or_radio_reg()
247 write_radio_reg(pi, addr, (rval | val)); in or_radio_reg()
250 void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask) in xor_radio_reg() argument
254 rval = read_radio_reg(pi, addr); in xor_radio_reg()
255 write_radio_reg(pi, addr, (rval ^ mask)); in xor_radio_reg()
258 void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val) in mod_radio_reg() argument
262 rval = read_radio_reg(pi, addr); in mod_radio_reg()
263 write_radio_reg(pi, addr, (rval & ~mask) | (val & mask)); in mod_radio_reg()
266 void write_phy_channel_reg(struct brcms_phy *pi, uint val) in write_phy_channel_reg() argument
268 bcma_write16(pi->d11core, D11REGOFFS(phychannel), val); in write_phy_channel_reg()
271 u16 read_phy_reg(struct brcms_phy *pi, u16 addr) in read_phy_reg() argument
273 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); in read_phy_reg()
275 pi->phy_wreg = 0; in read_phy_reg()
276 return bcma_read16(pi->d11core, D11REGOFFS(phyregdata)); in read_phy_reg()
279 void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) in write_phy_reg() argument
282 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); in write_phy_reg()
283 bcma_write16(pi->d11core, D11REGOFFS(phyregdata), val); in write_phy_reg()
285 (void)bcma_read16(pi->d11core, D11REGOFFS(phyregdata)); in write_phy_reg()
287 bcma_write32(pi->d11core, D11REGOFFS(phyregaddr), addr | (val << 16)); in write_phy_reg()
288 if ((pi->d11core->bus->hosttype == BCMA_HOSTTYPE_PCI) && in write_phy_reg()
289 (++pi->phy_wreg >= pi->phy_wreg_limit)) { in write_phy_reg()
290 pi->phy_wreg = 0; in write_phy_reg()
291 (void)bcma_read16(pi->d11core, D11REGOFFS(phyversion)); in write_phy_reg()
296 void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) in and_phy_reg() argument
298 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); in and_phy_reg()
299 bcma_mask16(pi->d11core, D11REGOFFS(phyregdata), val); in and_phy_reg()
300 pi->phy_wreg = 0; in and_phy_reg()
303 void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) in or_phy_reg() argument
305 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); in or_phy_reg()
306 bcma_set16(pi->d11core, D11REGOFFS(phyregdata), val); in or_phy_reg()
307 pi->phy_wreg = 0; in or_phy_reg()
310 void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val) in mod_phy_reg() argument
313 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); in mod_phy_reg()
314 bcma_maskset16(pi->d11core, D11REGOFFS(phyregdata), ~mask, val); in mod_phy_reg()
315 pi->phy_wreg = 0; in mod_phy_reg()
318 static void wlc_set_phy_uninitted(struct brcms_phy *pi) in wlc_set_phy_uninitted() argument
322 pi->initialized = false; in wlc_set_phy_uninitted()
324 pi->tx_vos = 0xffff; in wlc_set_phy_uninitted()
325 pi->nrssi_table_delta = 0x7fffffff; in wlc_set_phy_uninitted()
326 pi->rc_cal = 0xffff; in wlc_set_phy_uninitted()
327 pi->mintxbias = 0xffff; in wlc_set_phy_uninitted()
328 pi->txpwridx = -1; in wlc_set_phy_uninitted()
329 if (ISNPHY(pi)) { in wlc_set_phy_uninitted()
330 pi->phy_spuravoid = SPURAVOID_DISABLE; in wlc_set_phy_uninitted()
332 if (NREV_GE(pi->pubpi.phy_rev, 3) in wlc_set_phy_uninitted()
333 && NREV_LT(pi->pubpi.phy_rev, 7)) in wlc_set_phy_uninitted()
334 pi->phy_spuravoid = SPURAVOID_AUTO; in wlc_set_phy_uninitted()
336 pi->nphy_papd_skip = 0; in wlc_set_phy_uninitted()
337 pi->nphy_papd_epsilon_offset[0] = 0xf588; in wlc_set_phy_uninitted()
338 pi->nphy_papd_epsilon_offset[1] = 0xf588; in wlc_set_phy_uninitted()
339 pi->nphy_txpwr_idx[0] = 128; in wlc_set_phy_uninitted()
340 pi->nphy_txpwr_idx[1] = 128; in wlc_set_phy_uninitted()
341 pi->nphy_txpwrindex[0].index_internal = 40; in wlc_set_phy_uninitted()
342 pi->nphy_txpwrindex[1].index_internal = 40; in wlc_set_phy_uninitted()
343 pi->phy_pabias = 0; in wlc_set_phy_uninitted()
345 pi->phy_spuravoid = SPURAVOID_AUTO; in wlc_set_phy_uninitted()
347 pi->radiopwr = 0xffff; in wlc_set_phy_uninitted()
350 pi->stats_11b_txpower[i][j] = -1; in wlc_set_phy_uninitted()
386 static void wlc_phy_timercb_phycal(struct brcms_phy *pi) in wlc_phy_timercb_phycal() argument
390 if (PHY_PERICAL_MPHASE_PENDING(pi)) { in wlc_phy_timercb_phycal()
391 if (!pi->sh->up) { in wlc_phy_timercb_phycal()
392 wlc_phy_cal_perical_mphase_reset(pi); in wlc_phy_timercb_phycal()
396 if (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi)) { in wlc_phy_timercb_phycal()
399 wlc_phy_cal_perical_mphase_restart(pi); in wlc_phy_timercb_phycal()
401 wlc_phy_cal_perical_nphy_run(pi, PHY_PERICAL_AUTO); in wlc_phy_timercb_phycal()
402 wlapi_add_timer(pi->phycal_timer, delay, 0); in wlc_phy_timercb_phycal()
408 static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi) in wlc_phy_get_radio_ver() argument
412 ver = read_radio_id(pi); in wlc_phy_get_radio_ver()
421 struct brcms_phy *pi; in wlc_phy_attach() local
437 pi = sh->phy_head; in wlc_phy_attach()
438 if ((sflags & SISF_DB_PHY) && pi) { in wlc_phy_attach()
439 wlapi_bmac_corereset(pi->sh->physhim, pi->pubpi.coreflags); in wlc_phy_attach()
440 pi->refcnt++; in wlc_phy_attach()
441 return &pi->pubpi_ro; in wlc_phy_attach()
444 pi = kzalloc(sizeof(struct brcms_phy), GFP_ATOMIC); in wlc_phy_attach()
445 if (pi == NULL) in wlc_phy_attach()
447 pi->wiphy = wiphy; in wlc_phy_attach()
448 pi->d11core = d11core; in wlc_phy_attach()
449 pi->sh = sh; in wlc_phy_attach()
450 pi->phy_init_por = true; in wlc_phy_attach()
451 pi->phy_wreg_limit = PHY_WREG_LIMIT; in wlc_phy_attach()
453 pi->txpwr_percent = 100; in wlc_phy_attach()
455 pi->do_initcal = true; in wlc_phy_attach()
457 pi->phycal_tempdelta = 0; in wlc_phy_attach()
460 pi->pubpi.coreflags = SICF_GMODE; in wlc_phy_attach()
462 wlapi_bmac_corereset(pi->sh->physhim, pi->pubpi.coreflags); in wlc_phy_attach()
463 phyversion = bcma_read16(pi->d11core, D11REGOFFS(phyversion)); in wlc_phy_attach()
465 pi->pubpi.phy_type = PHY_TYPE(phyversion); in wlc_phy_attach()
466 pi->pubpi.phy_rev = phyversion & PV_PV_MASK; in wlc_phy_attach()
468 if (pi->pubpi.phy_type == PHY_TYPE_LCNXN) { in wlc_phy_attach()
469 pi->pubpi.phy_type = PHY_TYPE_N; in wlc_phy_attach()
470 pi->pubpi.phy_rev += LCNXN_BASEREV; in wlc_phy_attach()
472 pi->pubpi.phy_corenum = PHY_CORE_NUM_2; in wlc_phy_attach()
473 pi->pubpi.ana_rev = (phyversion & PV_AV_MASK) >> PV_AV_SHIFT; in wlc_phy_attach()
475 if (pi->pubpi.phy_type != PHY_TYPE_N && in wlc_phy_attach()
476 pi->pubpi.phy_type != PHY_TYPE_LCN) in wlc_phy_attach()
480 if (!ISNPHY(pi)) in wlc_phy_attach()
482 } else if (!ISNPHY(pi) && !ISLCNPHY(pi)) { in wlc_phy_attach()
486 wlc_phy_anacore((struct brcms_phy_pub *) pi, ON); in wlc_phy_attach()
488 idcode = wlc_phy_get_radio_ver(pi); in wlc_phy_attach()
489 pi->pubpi.radioid = in wlc_phy_attach()
491 pi->pubpi.radiorev = in wlc_phy_attach()
493 pi->pubpi.radiover = in wlc_phy_attach()
495 if (!VALID_RADIO(pi, pi->pubpi.radioid)) in wlc_phy_attach()
498 wlc_phy_switch_radio((struct brcms_phy_pub *) pi, OFF); in wlc_phy_attach()
500 wlc_set_phy_uninitted(pi); in wlc_phy_attach()
502 pi->bw = WL_CHANSPEC_BW_20; in wlc_phy_attach()
503 pi->radio_chanspec = (bandtype == BRCM_BAND_2G) ? in wlc_phy_attach()
506 pi->rxiq_samps = PHY_NOISE_SAMPLE_LOG_NUM_NPHY; in wlc_phy_attach()
507 pi->rxiq_antsel = ANT_RX_DIV_DEF; in wlc_phy_attach()
509 pi->watchdog_override = true; in wlc_phy_attach()
511 pi->cal_type_override = PHY_PERICAL_AUTO; in wlc_phy_attach()
513 pi->nphy_saved_noisevars.bufcount = 0; in wlc_phy_attach()
515 if (ISNPHY(pi)) in wlc_phy_attach()
516 pi->min_txpower = PHY_TXPWR_MIN_NPHY; in wlc_phy_attach()
518 pi->min_txpower = PHY_TXPWR_MIN; in wlc_phy_attach()
520 pi->sh->phyrxchain = 0x3; in wlc_phy_attach()
522 pi->rx2tx_biasentry = -1; in wlc_phy_attach()
524 pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP; in wlc_phy_attach()
525 pi->phy_txcore_enable_temp = in wlc_phy_attach()
527 pi->phy_tempsense_offset = 0; in wlc_phy_attach()
528 pi->phy_txcore_heatedup = false; in wlc_phy_attach()
530 pi->nphy_lastcal_temp = -50; in wlc_phy_attach()
532 pi->phynoise_polling = true; in wlc_phy_attach()
533 if (ISNPHY(pi) || ISLCNPHY(pi)) in wlc_phy_attach()
534 pi->phynoise_polling = false; in wlc_phy_attach()
537 pi->txpwr_limit[i] = BRCMS_TXPWR_MAX; in wlc_phy_attach()
538 pi->txpwr_env_limit[i] = BRCMS_TXPWR_MAX; in wlc_phy_attach()
539 pi->tx_user_target[i] = BRCMS_TXPWR_MAX; in wlc_phy_attach()
542 pi->radiopwr_override = RADIOPWR_OVERRIDE_DEF; in wlc_phy_attach()
544 pi->user_txpwr_at_rfport = false; in wlc_phy_attach()
546 if (ISNPHY(pi)) { in wlc_phy_attach()
548 pi->phycal_timer = wlapi_init_timer(pi->sh->physhim, in wlc_phy_attach()
550 pi, "phycal"); in wlc_phy_attach()
551 if (!pi->phycal_timer) in wlc_phy_attach()
554 if (!wlc_phy_attach_nphy(pi)) in wlc_phy_attach()
557 } else if (ISLCNPHY(pi)) { in wlc_phy_attach()
558 if (!wlc_phy_attach_lcnphy(pi)) in wlc_phy_attach()
563 pi->refcnt++; in wlc_phy_attach()
564 pi->next = pi->sh->phy_head; in wlc_phy_attach()
565 sh->phy_head = pi; in wlc_phy_attach()
567 memcpy(&pi->pubpi_ro, &pi->pubpi, sizeof(struct brcms_phy_pub)); in wlc_phy_attach()
569 return &pi->pubpi_ro; in wlc_phy_attach()
572 kfree(pi); in wlc_phy_attach()
578 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_detach() local
581 if (--pi->refcnt) in wlc_phy_detach()
584 if (pi->phycal_timer) { in wlc_phy_detach()
585 wlapi_free_timer(pi->phycal_timer); in wlc_phy_detach()
586 pi->phycal_timer = NULL; in wlc_phy_detach()
589 if (pi->sh->phy_head == pi) in wlc_phy_detach()
590 pi->sh->phy_head = pi->next; in wlc_phy_detach()
591 else if (pi->sh->phy_head->next == pi) in wlc_phy_detach()
592 pi->sh->phy_head->next = NULL; in wlc_phy_detach()
594 if (pi->pi_fptr.detach) in wlc_phy_detach()
595 (pi->pi_fptr.detach)(pi); in wlc_phy_detach()
597 kfree(pi); in wlc_phy_detach()
605 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_get_phyversion() local
606 *phytype = (u16) pi->pubpi.phy_type; in wlc_phy_get_phyversion()
607 *phyrev = (u16) pi->pubpi.phy_rev; in wlc_phy_get_phyversion()
608 *radioid = pi->pubpi.radioid; in wlc_phy_get_phyversion()
609 *radiover = pi->pubpi.radiorev; in wlc_phy_get_phyversion()
616 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_get_encore() local
617 return pi->pubpi.abgphy_encore; in wlc_phy_get_encore()
622 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_get_coreflags() local
623 return pi->pubpi.coreflags; in wlc_phy_get_coreflags()
628 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_anacore() local
630 if (ISNPHY(pi)) { in wlc_phy_anacore()
632 if (NREV_GE(pi->pubpi.phy_rev, 3)) { in wlc_phy_anacore()
633 write_phy_reg(pi, 0xa6, 0x0d); in wlc_phy_anacore()
634 write_phy_reg(pi, 0x8f, 0x0); in wlc_phy_anacore()
635 write_phy_reg(pi, 0xa7, 0x0d); in wlc_phy_anacore()
636 write_phy_reg(pi, 0xa5, 0x0); in wlc_phy_anacore()
638 write_phy_reg(pi, 0xa5, 0x0); in wlc_phy_anacore()
641 if (NREV_GE(pi->pubpi.phy_rev, 3)) { in wlc_phy_anacore()
642 write_phy_reg(pi, 0x8f, 0x07ff); in wlc_phy_anacore()
643 write_phy_reg(pi, 0xa6, 0x0fd); in wlc_phy_anacore()
644 write_phy_reg(pi, 0xa5, 0x07ff); in wlc_phy_anacore()
645 write_phy_reg(pi, 0xa7, 0x0fd); in wlc_phy_anacore()
647 write_phy_reg(pi, 0xa5, 0x7fff); in wlc_phy_anacore()
650 } else if (ISLCNPHY(pi)) { in wlc_phy_anacore()
652 and_phy_reg(pi, 0x43b, in wlc_phy_anacore()
655 or_phy_reg(pi, 0x43c, in wlc_phy_anacore()
657 or_phy_reg(pi, 0x43b, in wlc_phy_anacore()
665 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_clk_bwbits() local
669 if (pi && (ISNPHY(pi) || ISLCNPHY(pi))) { in wlc_phy_clk_bwbits()
670 switch (pi->bw) { in wlc_phy_clk_bwbits()
690 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_por_inform() local
692 pi->phy_init_por = true; in wlc_phy_por_inform()
697 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_edcrs_lock() local
699 pi->edcrs_threshold_lock = lock; in wlc_phy_edcrs_lock()
701 write_phy_reg(pi, 0x22c, 0x46b); in wlc_phy_edcrs_lock()
702 write_phy_reg(pi, 0x22d, 0x46b); in wlc_phy_edcrs_lock()
703 write_phy_reg(pi, 0x22e, 0x3c0); in wlc_phy_edcrs_lock()
704 write_phy_reg(pi, 0x22f, 0x3c0); in wlc_phy_edcrs_lock()
709 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_initcal_enable() local
711 pi->do_initcal = initcal; in wlc_phy_initcal_enable()
716 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_hw_clk_state_upd() local
718 if (!pi || !pi->sh) in wlc_phy_hw_clk_state_upd()
721 pi->sh->clk = newstate; in wlc_phy_hw_clk_state_upd()
726 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_hw_state_upd() local
728 if (!pi || !pi->sh) in wlc_phy_hw_state_upd()
731 pi->sh->up = newstate; in wlc_phy_hw_state_upd()
738 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_init() local
740 if (pi->init_in_progress) in wlc_phy_init()
743 pi->init_in_progress = true; in wlc_phy_init()
745 pi->radio_chanspec = chanspec; in wlc_phy_init()
747 mc = bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); in wlc_phy_init()
751 if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) in wlc_phy_init()
752 pi->measure_hold |= PHY_HOLD_FOR_NOT_ASSOC; in wlc_phy_init()
754 if (WARN(!(bcma_aread32(pi->d11core, BCMA_IOST) & SISF_FCLKA), in wlc_phy_init()
758 phy_init = pi->pi_fptr.init; in wlc_phy_init()
765 if (CHSPEC_BW(pi->radio_chanspec) != pi->bw) in wlc_phy_init()
766 wlapi_bmac_bw_set(pi->sh->physhim, in wlc_phy_init()
767 CHSPEC_BW(pi->radio_chanspec)); in wlc_phy_init()
769 pi->nphy_gain_boost = true; in wlc_phy_init()
771 wlc_phy_switch_radio((struct brcms_phy_pub *) pi, ON); in wlc_phy_init()
773 (*phy_init)(pi); in wlc_phy_init()
775 pi->phy_init_por = false; in wlc_phy_init()
777 if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) in wlc_phy_init()
778 wlc_phy_do_dummy_tx(pi, true, OFF); in wlc_phy_init()
780 if (!(ISNPHY(pi))) in wlc_phy_init()
781 wlc_phy_txpower_update_shm(pi); in wlc_phy_init()
783 wlc_phy_ant_rxdiv_set((struct brcms_phy_pub *) pi, pi->sh->rx_antdiv); in wlc_phy_init()
785 pi->init_in_progress = false; in wlc_phy_init()
790 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_cal_init() local
793 if (WARN((bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & in wlc_phy_cal_init()
797 if (!pi->initialized) { in wlc_phy_cal_init()
798 cal_init = pi->pi_fptr.calinit; in wlc_phy_cal_init()
800 (*cal_init)(pi); in wlc_phy_cal_init()
802 pi->initialized = true; in wlc_phy_cal_init()
808 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_down() local
811 if (pi->phycal_timer in wlc_phy_down()
812 && !wlapi_del_timer(pi->phycal_timer)) in wlc_phy_down()
815 pi->nphy_iqcal_chanspec_2G = 0; in wlc_phy_down()
816 pi->nphy_iqcal_chanspec_5G = 0; in wlc_phy_down()
822 wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id, uint tbl_offset, in wlc_phy_table_addr() argument
825 write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset); in wlc_phy_table_addr()
827 pi->tbl_data_hi = tblDataHi; in wlc_phy_table_addr()
828 pi->tbl_data_lo = tblDataLo; in wlc_phy_table_addr()
830 if (pi->sh->chip == BCMA_CHIP_ID_BCM43224 && in wlc_phy_table_addr()
831 pi->sh->chiprev == 1) { in wlc_phy_table_addr()
832 pi->tbl_addr = tblAddr; in wlc_phy_table_addr()
833 pi->tbl_save_id = tbl_id; in wlc_phy_table_addr()
834 pi->tbl_save_offset = tbl_offset; in wlc_phy_table_addr()
838 void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val) in wlc_phy_table_data_write() argument
840 if ((pi->sh->chip == BCMA_CHIP_ID_BCM43224) && in wlc_phy_table_data_write()
841 (pi->sh->chiprev == 1) && in wlc_phy_table_data_write()
842 (pi->tbl_save_id == NPHY_TBL_ID_ANTSWCTRLLUT)) { in wlc_phy_table_data_write()
843 read_phy_reg(pi, pi->tbl_data_lo); in wlc_phy_table_data_write()
845 write_phy_reg(pi, pi->tbl_addr, in wlc_phy_table_data_write()
846 (pi->tbl_save_id << 10) | pi->tbl_save_offset); in wlc_phy_table_data_write()
847 pi->tbl_save_offset++; in wlc_phy_table_data_write()
851 write_phy_reg(pi, pi->tbl_data_hi, (u16) (val >> 16)); in wlc_phy_table_data_write()
852 write_phy_reg(pi, pi->tbl_data_lo, (u16) val); in wlc_phy_table_data_write()
854 write_phy_reg(pi, pi->tbl_data_lo, (u16) val); in wlc_phy_table_data_write()
859 wlc_phy_write_table(struct brcms_phy *pi, const struct phytbl_info *ptbl_info, in wlc_phy_write_table() argument
870 write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset); in wlc_phy_write_table()
874 if ((pi->sh->chip == BCMA_CHIP_ID_BCM43224) && in wlc_phy_write_table()
875 (pi->sh->chiprev == 1) && in wlc_phy_write_table()
877 read_phy_reg(pi, tblDataLo); in wlc_phy_write_table()
879 write_phy_reg(pi, tblAddr, in wlc_phy_write_table()
884 write_phy_reg(pi, tblDataHi, in wlc_phy_write_table()
886 write_phy_reg(pi, tblDataLo, (u16) ptbl_32b[idx]); in wlc_phy_write_table()
888 write_phy_reg(pi, tblDataLo, ptbl_16b[idx]); in wlc_phy_write_table()
890 write_phy_reg(pi, tblDataLo, ptbl_8b[idx]); in wlc_phy_write_table()
896 wlc_phy_read_table(struct brcms_phy *pi, const struct phytbl_info *ptbl_info, in wlc_phy_read_table() argument
907 write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset); in wlc_phy_read_table()
911 if ((pi->sh->chip == BCMA_CHIP_ID_BCM43224) && in wlc_phy_read_table()
912 (pi->sh->chiprev == 1)) { in wlc_phy_read_table()
913 (void)read_phy_reg(pi, tblDataLo); in wlc_phy_read_table()
915 write_phy_reg(pi, tblAddr, in wlc_phy_read_table()
920 ptbl_32b[idx] = read_phy_reg(pi, tblDataLo); in wlc_phy_read_table()
921 ptbl_32b[idx] |= (read_phy_reg(pi, tblDataHi) << 16); in wlc_phy_read_table()
923 ptbl_16b[idx] = read_phy_reg(pi, tblDataLo); in wlc_phy_read_table()
925 ptbl_8b[idx] = (u8) read_phy_reg(pi, tblDataLo); in wlc_phy_read_table()
931 wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi, in wlc_phy_init_radio_regs_allbands() argument
938 write_radio_reg(pi, radioregs[i].address, in wlc_phy_init_radio_regs_allbands()
948 wlc_phy_init_radio_regs(struct brcms_phy *pi, in wlc_phy_init_radio_regs() argument
956 if (CHSPEC_IS5G(pi->radio_chanspec)) { in wlc_phy_init_radio_regs()
958 write_radio_reg(pi, in wlc_phy_init_radio_regs()
962 if (ISNPHY(pi) && (++count % 4 == 0)) in wlc_phy_init_radio_regs()
963 BRCMS_PHY_WAR_PR51571(pi); in wlc_phy_init_radio_regs()
967 write_radio_reg(pi, in wlc_phy_init_radio_regs()
971 if (ISNPHY(pi) && (++count % 4 == 0)) in wlc_phy_init_radio_regs()
972 BRCMS_PHY_WAR_PR51571(pi); in wlc_phy_init_radio_regs()
982 void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) in wlc_phy_do_dummy_tx() argument
985 struct bcma_device *core = pi->d11core; in wlc_phy_do_dummy_tx()
998 wlapi_bmac_write_template_ram(pi->sh->physhim, 0, DUMMY_PKT_LEN, in wlc_phy_do_dummy_tx()
1003 if (D11REV_GE(pi->sh->corerev, 11)) in wlc_phy_do_dummy_tx()
1010 if (ISNPHY(pi) || ISLCNPHY(pi)) in wlc_phy_do_dummy_tx()
1025 if (ISNPHY(pi)) in wlc_phy_do_dummy_tx()
1026 wlc_phy_pa_override_nphy(pi, OFF); in wlc_phy_do_dummy_tx()
1029 if (ISNPHY(pi) || ISLCNPHY(pi)) in wlc_phy_do_dummy_tx()
1055 if (ISNPHY(pi)) in wlc_phy_do_dummy_tx()
1056 wlc_phy_pa_override_nphy(pi, ON); in wlc_phy_do_dummy_tx()
1062 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_hold_upd() local
1065 mboolset(pi->measure_hold, id); in wlc_phy_hold_upd()
1067 mboolclr(pi->measure_hold, id); in wlc_phy_hold_upd()
1074 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_mute_upd() local
1077 mboolset(pi->measure_hold, PHY_HOLD_FOR_MUTE); in wlc_phy_mute_upd()
1079 mboolclr(pi->measure_hold, PHY_HOLD_FOR_MUTE); in wlc_phy_mute_upd()
1082 pi->nphy_perical_last = pi->sh->now - pi->sh->glacial_timer; in wlc_phy_mute_upd()
1088 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_clear_tssi() local
1090 if (ISNPHY(pi)) { in wlc_phy_clear_tssi()
1093 wlapi_bmac_write_shm(pi->sh->physhim, M_B_TSSI_0, NULL_TSSI_W); in wlc_phy_clear_tssi()
1094 wlapi_bmac_write_shm(pi->sh->physhim, M_B_TSSI_1, NULL_TSSI_W); in wlc_phy_clear_tssi()
1095 wlapi_bmac_write_shm(pi->sh->physhim, M_G_TSSI_0, NULL_TSSI_W); in wlc_phy_clear_tssi()
1096 wlapi_bmac_write_shm(pi->sh->physhim, M_G_TSSI_1, NULL_TSSI_W); in wlc_phy_clear_tssi()
1100 static bool wlc_phy_cal_txpower_recalc_sw(struct brcms_phy *pi) in wlc_phy_cal_txpower_recalc_sw() argument
1107 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_switch_radio() local
1108 (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); in wlc_phy_switch_radio()
1110 if (ISNPHY(pi)) { in wlc_phy_switch_radio()
1111 wlc_phy_switch_radio_nphy(pi, on); in wlc_phy_switch_radio()
1112 } else if (ISLCNPHY(pi)) { in wlc_phy_switch_radio()
1114 and_phy_reg(pi, 0x44c, in wlc_phy_switch_radio()
1118 and_phy_reg(pi, 0x4b0, ~((0x1 << 3) | (0x1 << 11))); in wlc_phy_switch_radio()
1119 and_phy_reg(pi, 0x4f9, ~(0x1 << 3)); in wlc_phy_switch_radio()
1121 and_phy_reg(pi, 0x44d, in wlc_phy_switch_radio()
1125 or_phy_reg(pi, 0x44c, in wlc_phy_switch_radio()
1130 and_phy_reg(pi, 0x4b7, ~((0x7f << 8))); in wlc_phy_switch_radio()
1131 and_phy_reg(pi, 0x4b1, ~((0x1 << 13))); in wlc_phy_switch_radio()
1132 or_phy_reg(pi, 0x4b0, (0x1 << 3) | (0x1 << 11)); in wlc_phy_switch_radio()
1133 and_phy_reg(pi, 0x4fa, ~((0x1 << 3))); in wlc_phy_switch_radio()
1134 or_phy_reg(pi, 0x4f9, (0x1 << 3)); in wlc_phy_switch_radio()
1141 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_bw_state_get() local
1143 return pi->bw; in wlc_phy_bw_state_get()
1148 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_bw_state_set() local
1150 pi->bw = bw; in wlc_phy_bw_state_set()
1155 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_radio_set() local
1156 pi->radio_chanspec = newch; in wlc_phy_chanspec_radio_set()
1162 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_get() local
1164 return pi->radio_chanspec; in wlc_phy_chanspec_get()
1169 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_set() local
1177 wlapi_bmac_write_shm(pi->sh->physhim, M_CURCHANNEL, m_cur_channel); in wlc_phy_chanspec_set()
1179 chanspec_set = pi->pi_fptr.chanset; in wlc_phy_chanspec_set()
1181 (*chanspec_set)(pi, chanspec); in wlc_phy_chanspec_set()
1201 int wlc_phy_chanspec_bandrange_get(struct brcms_phy *pi, u16 chanspec) in wlc_phy_chanspec_bandrange_get() argument
1207 if (ISNPHY(pi)) in wlc_phy_chanspec_bandrange_get()
1208 range = wlc_phy_get_chan_freq_range_nphy(pi, channel); in wlc_phy_chanspec_bandrange_get()
1209 else if (ISLCNPHY(pi)) in wlc_phy_chanspec_bandrange_get()
1218 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_ch14_widefilter_set() local
1220 pi->channel_14_wide_filter = wide_filter; in wlc_phy_chanspec_ch14_widefilter_set()
1238 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_band_validch() local
1247 if ((pi->a_band_high_disable) && (channel >= FIRST_REF5_CHANNUM) in wlc_phy_chanspec_band_validch()
1259 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_band_firstch() local
1267 if (ISNPHY(pi) && pi->bw == WL_CHANSPEC_BW_40) { in wlc_phy_chanspec_band_firstch()
1289 if ((pi->a_band_high_disable) && (channel >= FIRST_REF5_CHANNUM) in wlc_phy_chanspec_band_firstch()
1303 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_get() local
1305 *qdbm = pi->tx_user_target[0]; in wlc_phy_txpower_get()
1307 *override = pi->txpwroverride; in wlc_phy_txpower_get()
1315 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_target_set() local
1317 memcpy(&pi->tx_user_target[TXP_FIRST_CCK], in wlc_phy_txpower_target_set()
1320 memcpy(&pi->tx_user_target[TXP_FIRST_OFDM], in wlc_phy_txpower_target_set()
1322 memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_20_CDD], in wlc_phy_txpower_target_set()
1325 memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_40_SISO], in wlc_phy_txpower_target_set()
1327 memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_40_CDD], in wlc_phy_txpower_target_set()
1330 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_SISO], in wlc_phy_txpower_target_set()
1332 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_CDD], in wlc_phy_txpower_target_set()
1334 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_STBC], in wlc_phy_txpower_target_set()
1336 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_SDM], in wlc_phy_txpower_target_set()
1339 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_SISO], in wlc_phy_txpower_target_set()
1341 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_CDD], in wlc_phy_txpower_target_set()
1343 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_STBC], in wlc_phy_txpower_target_set()
1345 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_SDM], in wlc_phy_txpower_target_set()
1348 if (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & MCTL_EN_MAC) in wlc_phy_txpower_target_set()
1352 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_txpower_target_set()
1354 wlc_phy_txpower_recalc_target(pi); in wlc_phy_txpower_target_set()
1355 wlc_phy_cal_txpower_recalc_sw(pi); in wlc_phy_txpower_target_set()
1358 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_txpower_target_set()
1363 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_set() local
1370 pi->tx_user_target[i] = (u8) qdbm; in wlc_phy_txpower_set()
1372 pi->txpwroverride = false; in wlc_phy_txpower_set()
1374 if (pi->sh->up) { in wlc_phy_txpower_set()
1375 if (!SCAN_INPROG_PHY(pi)) { in wlc_phy_txpower_set()
1378 suspend = (0 == (bcma_read32(pi->d11core, in wlc_phy_txpower_set()
1383 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_txpower_set()
1385 wlc_phy_txpower_recalc_target(pi); in wlc_phy_txpower_set()
1386 wlc_phy_cal_txpower_recalc_sw(pi); in wlc_phy_txpower_set()
1389 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_txpower_set()
1399 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_sromlimit() local
1402 *min_pwr = pi->min_txpower * BRCMS_TXPWR_DB_FACTOR; in wlc_phy_txpower_sromlimit()
1404 if (ISNPHY(pi)) { in wlc_phy_txpower_sromlimit()
1407 wlc_phy_txpower_sromlimit_get_nphy(pi, channel, max_pwr, in wlc_phy_txpower_sromlimit()
1413 *max_pwr = pi->tx_srom_max_rate_2g[txp_rate_idx]; in wlc_phy_txpower_sromlimit()
1426 if (pi->hwtxpwr) { in wlc_phy_txpower_sromlimit()
1427 *max_pwr = pi->hwtxpwr[i]; in wlc_phy_txpower_sromlimit()
1432 pi->tx_srom_max_rate_5g_mid[txp_rate_idx]; in wlc_phy_txpower_sromlimit()
1436 pi->tx_srom_max_rate_5g_hi[txp_rate_idx]; in wlc_phy_txpower_sromlimit()
1439 pi->tx_srom_max_rate_5g_low[txp_rate_idx]; in wlc_phy_txpower_sromlimit()
1448 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_sromlimit_max_get() local
1456 max_num_rate = ISNPHY(pi) ? TXP_NUM_RATES : in wlc_phy_txpower_sromlimit_max_get()
1457 ISLCNPHY(pi) ? (TXP_LAST_SISO_MCS_20 + in wlc_phy_txpower_sromlimit_max_get()
1485 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_get_target_min() local
1487 return pi->tx_power_min; in wlc_phy_txpower_get_target_min()
1492 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_get_target_max() local
1494 return pi->tx_power_max; in wlc_phy_txpower_get_target_max()
1497 static s8 wlc_phy_env_measure_vbat(struct brcms_phy *pi) in wlc_phy_env_measure_vbat() argument
1499 if (ISLCNPHY(pi)) in wlc_phy_env_measure_vbat()
1500 return wlc_lcnphy_vbatsense(pi, 0); in wlc_phy_env_measure_vbat()
1505 static s8 wlc_phy_env_measure_temperature(struct brcms_phy *pi) in wlc_phy_env_measure_temperature() argument
1507 if (ISLCNPHY(pi)) in wlc_phy_env_measure_temperature()
1508 return wlc_lcnphy_tempsense_degree(pi, 0); in wlc_phy_env_measure_temperature()
1513 static void wlc_phy_upd_env_txpwr_rate_limits(struct brcms_phy *pi, u32 band) in wlc_phy_upd_env_txpwr_rate_limits() argument
1518 pi->txpwr_env_limit[i] = BRCMS_TXPWR_MAX; in wlc_phy_upd_env_txpwr_rate_limits()
1520 wlc_phy_env_measure_vbat(pi); in wlc_phy_upd_env_txpwr_rate_limits()
1521 wlc_phy_env_measure_temperature(pi); in wlc_phy_upd_env_txpwr_rate_limits()
1525 wlc_user_txpwr_antport_to_rfport(struct brcms_phy *pi, uint chan, u32 band, in wlc_user_txpwr_antport_to_rfport() argument
1531 void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) in wlc_phy_txpower_recalc_target() argument
1542 u32 band = CHSPEC2BAND(pi->radio_chanspec); in wlc_phy_txpower_recalc_target()
1545 chspec = pi->radio_chanspec; in wlc_phy_txpower_recalc_target()
1554 if (ISLCNPHY(pi)) { in wlc_phy_txpower_recalc_target()
1557 if (CHSPEC_IS40(pi->radio_chanspec)) { in wlc_phy_txpower_recalc_target()
1558 offset_mcs = pi->mcs40_po; in wlc_phy_txpower_recalc_target()
1561 pi->tx_srom_max_rate_2g[i - 8] = in wlc_phy_txpower_recalc_target()
1562 pi->tx_srom_max_2g - in wlc_phy_txpower_recalc_target()
1567 offset_mcs = pi->mcs20_po; in wlc_phy_txpower_recalc_target()
1570 pi->tx_srom_max_rate_2g[i - 8] = in wlc_phy_txpower_recalc_target()
1571 pi->tx_srom_max_2g - in wlc_phy_txpower_recalc_target()
1578 max_num_rate = ((ISNPHY(pi)) ? (TXP_NUM_RATES) : in wlc_phy_txpower_recalc_target()
1579 ((ISLCNPHY(pi)) ? in wlc_phy_txpower_recalc_target()
1582 wlc_phy_upd_env_txpwr_rate_limits(pi, band); in wlc_phy_txpower_recalc_target()
1586 tx_pwr_target[rate] = pi->tx_user_target[rate]; in wlc_phy_txpower_recalc_target()
1588 if (pi->user_txpwr_at_rfport) in wlc_phy_txpower_recalc_target()
1590 wlc_user_txpwr_antport_to_rfport(pi, in wlc_phy_txpower_recalc_target()
1595 wlc_phy_txpower_sromlimit((struct brcms_phy_pub *) pi, in wlc_phy_txpower_recalc_target()
1599 maxtxpwr = min(maxtxpwr, pi->txpwr_limit[rate]); in wlc_phy_txpower_recalc_target()
1607 if (pi->txpwr_percent <= 100) in wlc_phy_txpower_recalc_target()
1608 maxtxpwr = (maxtxpwr * pi->txpwr_percent) / 100; in wlc_phy_txpower_recalc_target()
1613 min(tx_pwr_target[rate], pi->txpwr_env_limit[rate]); in wlc_phy_txpower_recalc_target()
1622 memset(pi->tx_power_offset, 0, sizeof(pi->tx_power_offset)); in wlc_phy_txpower_recalc_target()
1623 pi->tx_power_max = tx_pwr_max; in wlc_phy_txpower_recalc_target()
1624 pi->tx_power_min = tx_pwr_min; in wlc_phy_txpower_recalc_target()
1625 pi->tx_power_max_rate_ind = tx_pwr_max_rate_ind; in wlc_phy_txpower_recalc_target()
1628 pi->tx_power_target[rate] = tx_pwr_target[rate]; in wlc_phy_txpower_recalc_target()
1630 if (!pi->hwpwrctrl || ISNPHY(pi)) in wlc_phy_txpower_recalc_target()
1631 pi->tx_power_offset[rate] = in wlc_phy_txpower_recalc_target()
1632 pi->tx_power_max - pi->tx_power_target[rate]; in wlc_phy_txpower_recalc_target()
1634 pi->tx_power_offset[rate] = in wlc_phy_txpower_recalc_target()
1635 pi->tx_power_target[rate] - pi->tx_power_min; in wlc_phy_txpower_recalc_target()
1638 txpwr_recalc_fn = pi->pi_fptr.txpwrrecalc; in wlc_phy_txpower_recalc_target()
1640 (*txpwr_recalc_fn)(pi); in wlc_phy_txpower_recalc_target()
1644 wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr, in wlc_phy_txpower_reg_limit_calc() argument
1653 pi->txpwr_limit[rate1] = txpwr->cck[rate2]; in wlc_phy_txpower_reg_limit_calc()
1657 pi->txpwr_limit[rate1] = txpwr->ofdm[rate2]; in wlc_phy_txpower_reg_limit_calc()
1659 if (ISNPHY(pi)) { in wlc_phy_txpower_reg_limit_calc()
1702 pi->txpwr_limit[rate1] = in wlc_phy_txpower_reg_limit_calc()
1747 pi->txpwr_limit[rate1] = in wlc_phy_txpower_reg_limit_calc()
1768 pi->txpwr_limit[rate1] = txpwr_ptr1[rate2]; in wlc_phy_txpower_reg_limit_calc()
1787 pi->txpwr_limit[rate1] = txpwr_ptr1[rate2]; in wlc_phy_txpower_reg_limit_calc()
1790 pi->txpwr_limit[WL_TX_POWER_MCS_32] = txpwr->mcs32; in wlc_phy_txpower_reg_limit_calc()
1792 pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST] = in wlc_phy_txpower_reg_limit_calc()
1793 min(pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST], in wlc_phy_txpower_reg_limit_calc()
1794 pi->txpwr_limit[WL_TX_POWER_MCS_32]); in wlc_phy_txpower_reg_limit_calc()
1795 pi->txpwr_limit[WL_TX_POWER_MCS_32] = in wlc_phy_txpower_reg_limit_calc()
1796 pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST]; in wlc_phy_txpower_reg_limit_calc()
1802 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpwr_percent_set() local
1804 pi->txpwr_percent = txpwr_percent; in wlc_phy_txpwr_percent_set()
1809 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_machwcap_set() local
1811 pi->sh->machwcap = machwcap; in wlc_phy_machwcap_set()
1816 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_runbist_config() local
1821 if (!ISNPHY(pi)) in wlc_phy_runbist_config()
1824 if (NREV_IS(pi->pubpi.phy_rev, 3) in wlc_phy_runbist_config()
1825 || NREV_IS(pi->pubpi.phy_rev, 4)) { in wlc_phy_runbist_config()
1826 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), in wlc_phy_runbist_config()
1828 bcma_set16(pi->d11core, D11REGOFFS(phyregdata), in wlc_phy_runbist_config()
1832 if (NREV_IS(pi->pubpi.phy_rev, 3) in wlc_phy_runbist_config()
1833 || NREV_IS(pi->pubpi.phy_rev, 4)) { in wlc_phy_runbist_config()
1834 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), in wlc_phy_runbist_config()
1836 bcma_write16(pi->d11core, D11REGOFFS(phyregdata), rxc); in wlc_phy_runbist_config()
1847 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_limit_set() local
1849 wlc_phy_txpower_reg_limit_calc(pi, txpwr, chanspec); in wlc_phy_txpower_limit_set()
1851 if (ISLCNPHY(pi)) { in wlc_phy_txpower_limit_set()
1856 pi->txpwr_limit[i] = txpwr->mcs_20_siso[j]; in wlc_phy_txpower_limit_set()
1858 pi->txpwr_limit[i] = txpwr->ofdm[j]; in wlc_phy_txpower_limit_set()
1862 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_txpower_limit_set()
1864 wlc_phy_txpower_recalc_target(pi); in wlc_phy_txpower_limit_set()
1865 wlc_phy_cal_txpower_recalc_sw(pi); in wlc_phy_txpower_limit_set()
1866 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_txpower_limit_set()
1871 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_ofdm_rateset_war() local
1873 pi->ofdm_rateset_war = war; in wlc_phy_ofdm_rateset_war()
1878 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_bf_preempt_enable() local
1880 pi->bf_preempt_4306 = bf_preempt; in wlc_phy_bf_preempt_enable()
1883 void wlc_phy_txpower_update_shm(struct brcms_phy *pi) in wlc_phy_txpower_update_shm() argument
1886 if (ISNPHY(pi)) in wlc_phy_txpower_update_shm()
1889 if (!pi->sh->clk) in wlc_phy_txpower_update_shm()
1892 if (pi->hwpwrctrl) { in wlc_phy_txpower_update_shm()
1895 wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_MAX, 63); in wlc_phy_txpower_update_shm()
1896 wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_N, in wlc_phy_txpower_update_shm()
1899 wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_TARGET, in wlc_phy_txpower_update_shm()
1900 pi->tx_power_min << NUM_TSSI_FRAMES); in wlc_phy_txpower_update_shm()
1902 wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_CUR, in wlc_phy_txpower_update_shm()
1903 pi->hwpwr_txcur); in wlc_phy_txpower_update_shm()
1910 pi->sh->physhim, in wlc_phy_txpower_update_shm()
1912 wlapi_bmac_write_shm(pi->sh->physhim, offset + 6, in wlc_phy_txpower_update_shm()
1913 pi->tx_power_offset[j]); in wlc_phy_txpower_update_shm()
1914 wlapi_bmac_write_shm(pi->sh->physhim, offset + 14, in wlc_phy_txpower_update_shm()
1915 -(pi->tx_power_offset[j] / 2)); in wlc_phy_txpower_update_shm()
1918 wlapi_bmac_mhf(pi->sh->physhim, MHF2, MHF2_HWPWRCTL, in wlc_phy_txpower_update_shm()
1924 pi->tx_power_offset[i] = in wlc_phy_txpower_update_shm()
1925 (u8) roundup(pi->tx_power_offset[i], 8); in wlc_phy_txpower_update_shm()
1926 wlapi_bmac_write_shm(pi->sh->physhim, M_OFDM_OFFSET, in wlc_phy_txpower_update_shm()
1928 ((pi->tx_power_offset[TXP_FIRST_OFDM] in wlc_phy_txpower_update_shm()
1935 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_hw_ctrl_get() local
1937 if (ISNPHY(pi)) in wlc_phy_txpower_hw_ctrl_get()
1938 return pi->nphy_txpwrctrl; in wlc_phy_txpower_hw_ctrl_get()
1940 return pi->hwpwrctrl; in wlc_phy_txpower_hw_ctrl_get()
1945 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_hw_ctrl_set() local
1948 if (!pi->hwpwrctrl_capable) in wlc_phy_txpower_hw_ctrl_set()
1951 pi->hwpwrctrl = hwpwrctrl; in wlc_phy_txpower_hw_ctrl_set()
1952 pi->nphy_txpwrctrl = hwpwrctrl; in wlc_phy_txpower_hw_ctrl_set()
1953 pi->txpwrctrl = hwpwrctrl; in wlc_phy_txpower_hw_ctrl_set()
1955 if (ISNPHY(pi)) { in wlc_phy_txpower_hw_ctrl_set()
1956 suspend = (0 == (bcma_read32(pi->d11core, in wlc_phy_txpower_hw_ctrl_set()
1960 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_txpower_hw_ctrl_set()
1962 wlc_phy_txpwrctrl_enable_nphy(pi, pi->nphy_txpwrctrl); in wlc_phy_txpower_hw_ctrl_set()
1963 if (pi->nphy_txpwrctrl == PHY_TPC_HW_OFF) in wlc_phy_txpower_hw_ctrl_set()
1964 wlc_phy_txpwr_fixpower_nphy(pi); in wlc_phy_txpower_hw_ctrl_set()
1966 mod_phy_reg(pi, 0x1e7, (0x7f << 0), in wlc_phy_txpower_hw_ctrl_set()
1967 pi->saved_txpwr_idx); in wlc_phy_txpower_hw_ctrl_set()
1970 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_txpower_hw_ctrl_set()
1974 void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi) in wlc_phy_txpower_ipa_upd() argument
1977 if (NREV_GE(pi->pubpi.phy_rev, 3)) { in wlc_phy_txpower_ipa_upd()
1978 pi->ipa2g_on = (pi->srom_fem2g.extpagain == 2); in wlc_phy_txpower_ipa_upd()
1979 pi->ipa5g_on = (pi->srom_fem5g.extpagain == 2); in wlc_phy_txpower_ipa_upd()
1981 pi->ipa2g_on = false; in wlc_phy_txpower_ipa_upd()
1982 pi->ipa5g_on = false; in wlc_phy_txpower_ipa_upd()
1986 static u32 wlc_phy_txpower_est_power_nphy(struct brcms_phy *pi) in wlc_phy_txpower_est_power_nphy() argument
1993 estPower1 = read_phy_reg(pi, 0x118); in wlc_phy_txpower_est_power_nphy()
1994 estPower2 = read_phy_reg(pi, 0x119); in wlc_phy_txpower_est_power_nphy()
2006 tx0_status = read_phy_reg(pi, 0x1ed); in wlc_phy_txpower_est_power_nphy()
2007 tx1_status = read_phy_reg(pi, 0x1ee); in wlc_phy_txpower_est_power_nphy()
2028 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_get_current() local
2036 if (ISNPHY(pi)) { in wlc_phy_txpower_get_current()
2039 if (pi->nphy_txpwrctrl == PHY_TPC_HW_ON) in wlc_phy_txpower_get_current()
2042 } else if (ISLCNPHY(pi)) { in wlc_phy_txpower_get_current()
2045 if (pi->radiopwr_override == RADIOPWR_OVERRIDE_DEF) in wlc_phy_txpower_get_current()
2047 if (pi->hwpwrctrl) in wlc_phy_txpower_get_current()
2051 num_rates = ((ISNPHY(pi)) ? (TXP_NUM_RATES) : in wlc_phy_txpower_get_current()
2052 ((ISLCNPHY(pi)) ? in wlc_phy_txpower_get_current()
2056 power->user_limit[rate] = pi->tx_user_target[rate]; in wlc_phy_txpower_get_current()
2060 power->target[rate] = pi->tx_power_target[rate]; in wlc_phy_txpower_get_current()
2063 if (ISNPHY(pi)) { in wlc_phy_txpower_get_current()
2066 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_txpower_get_current()
2067 wlc_phyreg_enter((struct brcms_phy_pub *) pi); in wlc_phy_txpower_get_current()
2068 est_pout = wlc_phy_txpower_est_power_nphy(pi); in wlc_phy_txpower_get_current()
2069 wlc_phyreg_exit((struct brcms_phy_pub *) pi); in wlc_phy_txpower_get_current()
2070 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_txpower_get_current()
2090 power->tx_power_max[0] = pi->tx_power_max; in wlc_phy_txpower_get_current()
2091 power->tx_power_max[1] = pi->tx_power_max; in wlc_phy_txpower_get_current()
2093 power->tx_power_max_rate_ind[0] = pi->tx_power_max_rate_ind; in wlc_phy_txpower_get_current()
2094 power->tx_power_max_rate_ind[1] = pi->tx_power_max_rate_ind; in wlc_phy_txpower_get_current()
2095 } else if (pi->hwpwrctrl && pi->sh->up) { in wlc_phy_txpower_get_current()
2098 if (ISLCNPHY(pi)) { in wlc_phy_txpower_get_current()
2100 power->tx_power_max[0] = pi->tx_power_max; in wlc_phy_txpower_get_current()
2101 power->tx_power_max[1] = pi->tx_power_max; in wlc_phy_txpower_get_current()
2104 pi->tx_power_max_rate_ind; in wlc_phy_txpower_get_current()
2106 pi->tx_power_max_rate_ind; in wlc_phy_txpower_get_current()
2108 if (wlc_phy_tpc_isenabled_lcnphy(pi)) in wlc_phy_txpower_get_current()
2117 wlc_lcnphy_get_tssi(pi, (s8 *) &power->est_Pout[0], in wlc_phy_txpower_get_current()
2126 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_antsel_type_set() local
2128 pi->antsel_type = antsel_type; in wlc_phy_antsel_type_set()
2133 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_test_ison() local
2135 return pi->phytest_on; in wlc_phy_test_ison()
2140 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_ant_rxdiv_set() local
2143 pi->sh->rx_antdiv = val; in wlc_phy_ant_rxdiv_set()
2145 if (!(ISNPHY(pi) && D11REV_IS(pi->sh->corerev, 16))) { in wlc_phy_ant_rxdiv_set()
2147 wlapi_bmac_mhf(pi->sh->physhim, MHF1, MHF1_ANTDIV, in wlc_phy_ant_rxdiv_set()
2150 wlapi_bmac_mhf(pi->sh->physhim, MHF1, MHF1_ANTDIV, 0, in wlc_phy_ant_rxdiv_set()
2154 if (ISNPHY(pi)) in wlc_phy_ant_rxdiv_set()
2157 if (!pi->sh->clk) in wlc_phy_ant_rxdiv_set()
2160 suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & in wlc_phy_ant_rxdiv_set()
2163 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_ant_rxdiv_set()
2165 if (ISLCNPHY(pi)) { in wlc_phy_ant_rxdiv_set()
2167 mod_phy_reg(pi, 0x410, (0x1 << 1), 0x01 << 1); in wlc_phy_ant_rxdiv_set()
2168 mod_phy_reg(pi, 0x410, in wlc_phy_ant_rxdiv_set()
2172 mod_phy_reg(pi, 0x410, (0x1 << 1), 0x00 << 1); in wlc_phy_ant_rxdiv_set()
2173 mod_phy_reg(pi, 0x410, (0x1 << 0), (u16) val << 0); in wlc_phy_ant_rxdiv_set()
2178 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_ant_rxdiv_set()
2184 wlc_phy_noise_calc_phy(struct brcms_phy *pi, u32 *cmplx_pwr, s8 *pwr_ant) in wlc_phy_noise_calc_phy() argument
2190 wlc_phy_compute_dB(cmplx_pwr, cmplx_pwr_dbm, pi->pubpi.phy_corenum); in wlc_phy_noise_calc_phy()
2192 for (i = 0; i < pi->pubpi.phy_corenum; i++) { in wlc_phy_noise_calc_phy()
2193 if (NREV_GE(pi->pubpi.phy_rev, 3)) in wlc_phy_noise_calc_phy()
2200 for (i = 0; i < pi->pubpi.phy_corenum; i++) { in wlc_phy_noise_calc_phy()
2201 pi->nphy_noise_win[i][pi->nphy_noise_index] = cmplx_pwr_dbm[i]; in wlc_phy_noise_calc_phy()
2204 pi->nphy_noise_index = in wlc_phy_noise_calc_phy()
2205 MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); in wlc_phy_noise_calc_phy()
2209 static void wlc_phy_noise_cb(struct brcms_phy *pi, u8 channel, s8 noise_dbm) in wlc_phy_noise_cb() argument
2211 if (!pi->phynoise_state) in wlc_phy_noise_cb()
2214 if (pi->phynoise_state & PHY_NOISE_STATE_MON) { in wlc_phy_noise_cb()
2215 if (pi->phynoise_chan_watchdog == channel) { in wlc_phy_noise_cb()
2216 pi->sh->phy_noise_window[pi->sh->phy_noise_index] = in wlc_phy_noise_cb()
2218 pi->sh->phy_noise_index = in wlc_phy_noise_cb()
2219 MODINC(pi->sh->phy_noise_index, MA_WINDOW_SZ); in wlc_phy_noise_cb()
2221 pi->phynoise_state &= ~PHY_NOISE_STATE_MON; in wlc_phy_noise_cb()
2224 if (pi->phynoise_state & PHY_NOISE_STATE_EXTERNAL) in wlc_phy_noise_cb()
2225 pi->phynoise_state &= ~PHY_NOISE_STATE_EXTERNAL; in wlc_phy_noise_cb()
2229 static s8 wlc_phy_noise_read_shmem(struct brcms_phy *pi) in wlc_phy_noise_read_shmem() argument
2241 for (idx = 0, core = 0; core < pi->pubpi.phy_corenum; idx += 2, in wlc_phy_noise_read_shmem()
2243 lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP(idx)); in wlc_phy_noise_read_shmem()
2244 hi = wlapi_bmac_read_shm(pi->sh->physhim, in wlc_phy_noise_read_shmem()
2255 wlc_phy_noise_calc_phy(pi, cmplx_pwr, noise_dbm_ant); in wlc_phy_noise_read_shmem()
2257 for (core = 0; core < pi->pubpi.phy_corenum; core++) { in wlc_phy_noise_read_shmem()
2258 pi->nphy_noise_win[core][pi->nphy_noise_index] = in wlc_phy_noise_read_shmem()
2264 pi->nphy_noise_index = in wlc_phy_noise_read_shmem()
2265 MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); in wlc_phy_noise_read_shmem()
2273 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_noise_sample_intr() local
2278 if (ISLCNPHY(pi)) { in wlc_phy_noise_sample_intr()
2284 jssi_aux = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_AUX); in wlc_phy_noise_sample_intr()
2287 lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP0); in wlc_phy_noise_sample_intr()
2288 hi = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP1); in wlc_phy_noise_sample_intr()
2291 lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP2); in wlc_phy_noise_sample_intr()
2292 hi = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP3); in wlc_phy_noise_sample_intr()
2297 status_1 = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_0); in wlc_phy_noise_sample_intr()
2302 pi->pubpi.phy_corenum); in wlc_phy_noise_sample_intr()
2303 pwr_offset_dB = (read_phy_reg(pi, 0x434) & 0xFF); in wlc_phy_noise_sample_intr()
2314 } else if (ISNPHY(pi)) { in wlc_phy_noise_sample_intr()
2316 jssi_aux = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_AUX); in wlc_phy_noise_sample_intr()
2319 noise_dbm = wlc_phy_noise_read_shmem(pi); in wlc_phy_noise_sample_intr()
2322 wlc_phy_noise_cb(pi, channel, noise_dbm); in wlc_phy_noise_sample_intr()
2329 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_noise_sample_request() local
2331 bool sampling_in_progress = (pi->phynoise_state != 0); in wlc_phy_noise_sample_request()
2336 pi->phynoise_chan_watchdog = ch; in wlc_phy_noise_sample_request()
2337 pi->phynoise_state |= PHY_NOISE_STATE_MON; in wlc_phy_noise_sample_request()
2341 pi->phynoise_state |= PHY_NOISE_STATE_EXTERNAL; in wlc_phy_noise_sample_request()
2351 pi->phynoise_now = pi->sh->now; in wlc_phy_noise_sample_request()
2353 if (pi->phy_fixed_noise) { in wlc_phy_noise_sample_request()
2354 if (ISNPHY(pi)) { in wlc_phy_noise_sample_request()
2355 pi->nphy_noise_win[WL_ANT_IDX_1][pi->nphy_noise_index] = in wlc_phy_noise_sample_request()
2357 pi->nphy_noise_win[WL_ANT_IDX_2][pi->nphy_noise_index] = in wlc_phy_noise_sample_request()
2359 pi->nphy_noise_index = MODINC_POW2(pi->nphy_noise_index, in wlc_phy_noise_sample_request()
2370 if (ISLCNPHY(pi)) { in wlc_phy_noise_sample_request()
2371 if (!pi->phynoise_polling in wlc_phy_noise_sample_request()
2373 wlapi_bmac_write_shm(pi->sh->physhim, M_JSSI_0, 0); in wlc_phy_noise_sample_request()
2374 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP0, 0); in wlc_phy_noise_sample_request()
2375 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP1, 0); in wlc_phy_noise_sample_request()
2376 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP2, 0); in wlc_phy_noise_sample_request()
2377 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP3, 0); in wlc_phy_noise_sample_request()
2379 bcma_set32(pi->d11core, D11REGOFFS(maccommand), in wlc_phy_noise_sample_request()
2382 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_noise_sample_request()
2383 wlc_lcnphy_deaf_mode(pi, (bool) 0); in wlc_phy_noise_sample_request()
2384 noise_dbm = (s8) wlc_lcnphy_rx_signal_power(pi, 20); in wlc_phy_noise_sample_request()
2385 wlc_lcnphy_deaf_mode(pi, (bool) 1); in wlc_phy_noise_sample_request()
2386 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_noise_sample_request()
2389 } else if (ISNPHY(pi)) { in wlc_phy_noise_sample_request()
2390 if (!pi->phynoise_polling in wlc_phy_noise_sample_request()
2393 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP0, 0); in wlc_phy_noise_sample_request()
2394 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP1, 0); in wlc_phy_noise_sample_request()
2395 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP2, 0); in wlc_phy_noise_sample_request()
2396 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP3, 0); in wlc_phy_noise_sample_request()
2398 bcma_set32(pi->d11core, D11REGOFFS(maccommand), in wlc_phy_noise_sample_request()
2416 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_noise_sample_request()
2417 classif_state = wlc_phy_classifier_nphy(pi, 0, 0); in wlc_phy_noise_sample_request()
2418 wlc_phy_classifier_nphy(pi, 3, 0); in wlc_phy_noise_sample_request()
2419 wlc_phy_rx_iq_est_nphy(pi, est, num_samps, wait_time, in wlc_phy_noise_sample_request()
2421 wlc_phy_classifier_nphy(pi, (0x7 << 0), classif_state); in wlc_phy_noise_sample_request()
2422 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_noise_sample_request()
2424 for (i = 0; i < pi->pubpi.phy_corenum; i++) in wlc_phy_noise_sample_request()
2428 wlc_phy_noise_calc_phy(pi, cmplx_pwr, noise_dbm_ant); in wlc_phy_noise_sample_request()
2430 for (i = 0; i < pi->pubpi.phy_corenum; i++) { in wlc_phy_noise_sample_request()
2431 pi->nphy_noise_win[i][pi->nphy_noise_index] = in wlc_phy_noise_sample_request()
2437 pi->nphy_noise_index = MODINC_POW2(pi->nphy_noise_index, in wlc_phy_noise_sample_request()
2447 wlc_phy_noise_cb(pi, ch, noise_dbm); in wlc_phy_noise_sample_request()
2521 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_rssi_compute() local
2523 if ((pi->sh->corerev >= 11) in wlc_phy_rssi_compute()
2529 if (ISLCNPHY(pi)) { in wlc_phy_rssi_compute()
2531 struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; in wlc_phy_rssi_compute()
2546 if (ISLCNPHY(pi)) { in wlc_phy_rssi_compute()
2551 rssi = wlc_phy_rssi_compute_nphy(pi, rxh); in wlc_phy_rssi_compute()
2570 struct brcms_phy *pi; in wlc_phy_set_deaf() local
2571 pi = (struct brcms_phy *) ppi; in wlc_phy_set_deaf()
2573 if (ISLCNPHY(pi)) in wlc_phy_set_deaf()
2574 wlc_lcnphy_deaf_mode(pi, true); in wlc_phy_set_deaf()
2575 else if (ISNPHY(pi)) in wlc_phy_set_deaf()
2576 wlc_nphy_deaf_mode(pi, true); in wlc_phy_set_deaf()
2581 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_watchdog() local
2583 pi->sh->now++; in wlc_phy_watchdog()
2585 if (!pi->watchdog_override) in wlc_phy_watchdog()
2588 if (!(SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi))) in wlc_phy_watchdog()
2589 wlc_phy_noise_sample_request((struct brcms_phy_pub *) pi, in wlc_phy_watchdog()
2591 CHSPEC_CHANNEL(pi-> in wlc_phy_watchdog()
2594 if (pi->phynoise_state && (pi->sh->now - pi->phynoise_now) > 5) in wlc_phy_watchdog()
2595 pi->phynoise_state = 0; in wlc_phy_watchdog()
2597 if ((!pi->phycal_txpower) || in wlc_phy_watchdog()
2598 ((pi->sh->now - pi->phycal_txpower) >= pi->sh->fast_timer)) { in wlc_phy_watchdog()
2600 if (!SCAN_INPROG_PHY(pi) && wlc_phy_cal_txpower_recalc_sw(pi)) in wlc_phy_watchdog()
2601 pi->phycal_txpower = pi->sh->now; in wlc_phy_watchdog()
2604 if ((SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi) in wlc_phy_watchdog()
2605 || ASSOC_INPROG_PHY(pi))) in wlc_phy_watchdog()
2608 if (ISNPHY(pi) && !pi->disable_percal && !delay_phy_cal) { in wlc_phy_watchdog()
2610 if ((pi->nphy_perical != PHY_PERICAL_DISABLE) && in wlc_phy_watchdog()
2611 (pi->nphy_perical != PHY_PERICAL_MANUAL) && in wlc_phy_watchdog()
2612 ((pi->sh->now - pi->nphy_perical_last) >= in wlc_phy_watchdog()
2613 pi->sh->glacial_timer)) in wlc_phy_watchdog()
2614 wlc_phy_cal_perical((struct brcms_phy_pub *) pi, in wlc_phy_watchdog()
2617 wlc_phy_txpwr_papd_cal_nphy(pi); in wlc_phy_watchdog()
2620 if (ISLCNPHY(pi)) { in wlc_phy_watchdog()
2621 if (pi->phy_forcecal || in wlc_phy_watchdog()
2622 ((pi->sh->now - pi->phy_lastcal) >= in wlc_phy_watchdog()
2623 pi->sh->glacial_timer)) { in wlc_phy_watchdog()
2624 if (!(SCAN_RM_IN_PROGRESS(pi) || ASSOC_INPROG_PHY(pi))) in wlc_phy_watchdog()
2626 pi, in wlc_phy_watchdog()
2629 (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi) in wlc_phy_watchdog()
2630 || ASSOC_INPROG_PHY(pi) in wlc_phy_watchdog()
2631 || pi->carrier_suppr_disable in wlc_phy_watchdog()
2632 || pi->disable_percal)) in wlc_phy_watchdog()
2633 wlc_lcnphy_calib_modes(pi, in wlc_phy_watchdog()
2641 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_BSSinit() local
2646 pi->sh->phy_noise_window[i] = (s8) (rssi & 0xff); in wlc_phy_BSSinit()
2647 if (ISLCNPHY(pi)) { in wlc_phy_BSSinit()
2649 pi->sh->phy_noise_window[i] = in wlc_phy_BSSinit()
2652 pi->sh->phy_noise_index = 0; in wlc_phy_BSSinit()
2656 pi->nphy_noise_win[k][i] = PHY_NOISE_FIXED_VAL_NPHY; in wlc_phy_BSSinit()
2658 pi->nphy_noise_index = 0; in wlc_phy_BSSinit()
2673 void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi) in wlc_phy_cal_perical_mphase_reset() argument
2675 wlapi_del_timer(pi->phycal_timer); in wlc_phy_cal_perical_mphase_reset()
2677 pi->cal_type_override = PHY_PERICAL_AUTO; in wlc_phy_cal_perical_mphase_reset()
2678 pi->mphase_cal_phase_id = MPHASE_CAL_STATE_IDLE; in wlc_phy_cal_perical_mphase_reset()
2679 pi->mphase_txcal_cmdidx = 0; in wlc_phy_cal_perical_mphase_reset()
2683 wlc_phy_cal_perical_mphase_schedule(struct brcms_phy *pi, uint delay) in wlc_phy_cal_perical_mphase_schedule() argument
2686 if ((pi->nphy_perical != PHY_PERICAL_MPHASE) && in wlc_phy_cal_perical_mphase_schedule()
2687 (pi->nphy_perical != PHY_PERICAL_MANUAL)) in wlc_phy_cal_perical_mphase_schedule()
2690 wlapi_del_timer(pi->phycal_timer); in wlc_phy_cal_perical_mphase_schedule()
2692 pi->mphase_cal_phase_id = MPHASE_CAL_STATE_INIT; in wlc_phy_cal_perical_mphase_schedule()
2693 wlapi_add_timer(pi->phycal_timer, delay, 0); in wlc_phy_cal_perical_mphase_schedule()
2701 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_cal_perical() local
2703 if (!ISNPHY(pi)) in wlc_phy_cal_perical()
2706 if ((pi->nphy_perical == PHY_PERICAL_DISABLE) || in wlc_phy_cal_perical()
2707 (pi->nphy_perical == PHY_PERICAL_MANUAL)) in wlc_phy_cal_perical()
2715 if (pi->nphy_perical == PHY_PERICAL_MPHASE) { in wlc_phy_cal_perical()
2716 if (PHY_PERICAL_MPHASE_PENDING(pi)) in wlc_phy_cal_perical()
2717 wlc_phy_cal_perical_mphase_reset(pi); in wlc_phy_cal_perical()
2720 pi, in wlc_phy_cal_perical()
2728 if ((pi->nphy_perical == PHY_PERICAL_MPHASE) && in wlc_phy_cal_perical()
2729 PHY_PERICAL_MPHASE_PENDING(pi)) in wlc_phy_cal_perical()
2730 wlc_phy_cal_perical_mphase_reset(pi); in wlc_phy_cal_perical()
2732 pi->first_cal_after_assoc = true; in wlc_phy_cal_perical()
2734 pi->cal_type_override = PHY_PERICAL_FULL; in wlc_phy_cal_perical()
2736 if (pi->phycal_tempdelta) in wlc_phy_cal_perical()
2737 pi->nphy_lastcal_temp = wlc_phy_tempsense_nphy(pi); in wlc_phy_cal_perical()
2739 wlc_phy_cal_perical_nphy_run(pi, PHY_PERICAL_FULL); in wlc_phy_cal_perical()
2743 if (pi->phycal_tempdelta) { in wlc_phy_cal_perical()
2744 nphy_currtemp = wlc_phy_tempsense_nphy(pi); in wlc_phy_cal_perical()
2746 (nphy_currtemp > pi->nphy_lastcal_temp) ? in wlc_phy_cal_perical()
2747 nphy_currtemp - pi->nphy_lastcal_temp : in wlc_phy_cal_perical()
2748 pi->nphy_lastcal_temp - nphy_currtemp; in wlc_phy_cal_perical()
2750 if ((delta_temp < (s16) pi->phycal_tempdelta) && in wlc_phy_cal_perical()
2751 (pi->nphy_txiqlocal_chanspec == in wlc_phy_cal_perical()
2752 pi->radio_chanspec)) in wlc_phy_cal_perical()
2755 pi->nphy_lastcal_temp = nphy_currtemp; in wlc_phy_cal_perical()
2759 if (pi->nphy_perical == PHY_PERICAL_MPHASE) { in wlc_phy_cal_perical()
2760 if (!PHY_PERICAL_MPHASE_PENDING(pi)) in wlc_phy_cal_perical()
2762 pi, in wlc_phy_cal_perical()
2764 } else if (pi->nphy_perical == PHY_PERICAL_SPHASE) in wlc_phy_cal_perical()
2765 wlc_phy_cal_perical_nphy_run(pi, in wlc_phy_cal_perical()
2774 void wlc_phy_cal_perical_mphase_restart(struct brcms_phy *pi) in wlc_phy_cal_perical_mphase_restart() argument
2776 pi->mphase_cal_phase_id = MPHASE_CAL_STATE_INIT; in wlc_phy_cal_perical_mphase_restart()
2777 pi->mphase_txcal_cmdidx = 0; in wlc_phy_cal_perical_mphase_restart()
2794 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_stf_chain_init() local
2796 pi->sh->hw_phytxchain = txchain; in wlc_phy_stf_chain_init()
2797 pi->sh->hw_phyrxchain = rxchain; in wlc_phy_stf_chain_init()
2798 pi->sh->phytxchain = txchain; in wlc_phy_stf_chain_init()
2799 pi->sh->phyrxchain = rxchain; in wlc_phy_stf_chain_init()
2800 pi->pubpi.phy_corenum = (u8)hweight8(pi->sh->phyrxchain); in wlc_phy_stf_chain_init()
2805 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_stf_chain_set() local
2807 pi->sh->phytxchain = txchain; in wlc_phy_stf_chain_set()
2809 if (ISNPHY(pi)) in wlc_phy_stf_chain_set()
2812 pi->pubpi.phy_corenum = (u8)hweight8(pi->sh->phyrxchain); in wlc_phy_stf_chain_set()
2817 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_stf_chain_get() local
2819 *txchain = pi->sh->phytxchain; in wlc_phy_stf_chain_get()
2820 *rxchain = pi->sh->phyrxchain; in wlc_phy_stf_chain_get()
2827 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_stf_chain_active_get() local
2829 active_bitmap = (pi->phy_txcore_heatedup) ? 0x31 : 0x33; in wlc_phy_stf_chain_active_get()
2831 if (!pi->watchdog_override) in wlc_phy_stf_chain_active_get()
2834 if (NREV_GE(pi->pubpi.phy_rev, 6)) { in wlc_phy_stf_chain_active_get()
2835 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_stf_chain_active_get()
2836 nphy_currtemp = wlc_phy_tempsense_nphy(pi); in wlc_phy_stf_chain_active_get()
2837 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_stf_chain_active_get()
2839 if (!pi->phy_txcore_heatedup) { in wlc_phy_stf_chain_active_get()
2840 if (nphy_currtemp >= pi->phy_txcore_disable_temp) { in wlc_phy_stf_chain_active_get()
2842 pi->phy_txcore_heatedup = true; in wlc_phy_stf_chain_active_get()
2845 if (nphy_currtemp <= pi->phy_txcore_enable_temp) { in wlc_phy_stf_chain_active_get()
2847 pi->phy_txcore_heatedup = false; in wlc_phy_stf_chain_active_get()
2857 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_stf_ssmode_get() local
2867 if (pi->tx_power_target[siso_mcs_id] > in wlc_phy_stf_ssmode_get()
2868 (pi->tx_power_target[cdd_mcs_id] + 12)) in wlc_phy_stf_ssmode_get()
2879 void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode) in wlc_lcnphy_epa_switch() argument
2881 if ((pi->sh->chip == BCMA_CHIP_ID_BCM4313) && in wlc_lcnphy_epa_switch()
2882 (pi->sh->boardflags & BFL_FEM)) { in wlc_lcnphy_epa_switch()
2885 txant = wlapi_bmac_get_txant(pi->sh->physhim); in wlc_lcnphy_epa_switch()
2887 mod_phy_reg(pi, 0x44d, (0x1 << 2), (1) << 2); in wlc_lcnphy_epa_switch()
2889 mod_phy_reg(pi, 0x44c, (0x1 << 2), (1) << 2); in wlc_lcnphy_epa_switch()
2893 bcma_chipco_gpio_control(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2895 bcma_chipco_gpio_out(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2897 bcma_chipco_gpio_outen(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2900 mod_phy_reg(pi, 0x44c, (0x1 << 2), (0) << 2); in wlc_lcnphy_epa_switch()
2902 mod_phy_reg(pi, 0x44d, (0x1 << 2), (0) << 2); in wlc_lcnphy_epa_switch()
2904 bcma_chipco_gpio_out(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2906 bcma_chipco_gpio_outen(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2908 bcma_chipco_gpio_control(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2920 wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset, s8 *ofdmoffset) in wlc_phy_get_pwrdet_offsets() argument
2926 s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi, u16 chanspec) in wlc_phy_upd_rssi_offset() argument
2934 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_ipa_ison() local
2936 if (ISNPHY(pi)) in wlc_phy_txpower_ipa_ison()
2937 return wlc_phy_n_txpower_ipa_ison(pi); in wlc_phy_txpower_ipa_ison()