Lines Matching refs:pi

37 #define VALID_RADIO(pi, radioid)        ( \  argument
38 (ISNPHY(pi) ? VALID_N_RADIO(radioid) : false) || \
39 (ISLCNPHY(pi) ? VALID_LCN_RADIO(radioid) : false))
131 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phyreg_enter() local
132 wlapi_bmac_ucode_wake_override_phyreg_set(pi->sh->physhim); in wlc_phyreg_enter()
137 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phyreg_exit() local
138 wlapi_bmac_ucode_wake_override_phyreg_clear(pi->sh->physhim); in wlc_phyreg_exit()
143 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_radioreg_enter() local
144 wlapi_bmac_mctrl(pi->sh->physhim, MCTL_LOCK_RADIO, MCTL_LOCK_RADIO); in wlc_radioreg_enter()
151 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_radioreg_exit() local
153 (void)bcma_read16(pi->d11core, D11REGOFFS(phyversion)); in wlc_radioreg_exit()
154 pi->phy_wreg = 0; in wlc_radioreg_exit()
155 wlapi_bmac_mctrl(pi->sh->physhim, MCTL_LOCK_RADIO, 0); in wlc_radioreg_exit()
158 u16 read_radio_reg(struct brcms_phy *pi, u16 addr) in read_radio_reg() argument
165 switch (pi->pubpi.phy_type) { in read_radio_reg()
169 if (NREV_GE(pi->pubpi.phy_rev, 7)) in read_radio_reg()
185 if ((D11REV_GE(pi->sh->corerev, 24)) || in read_radio_reg()
186 (D11REV_IS(pi->sh->corerev, 22) in read_radio_reg()
187 && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { in read_radio_reg()
188 bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), addr); in read_radio_reg()
189 data = bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); in read_radio_reg()
191 bcma_wflush16(pi->d11core, D11REGOFFS(phy4waddr), addr); in read_radio_reg()
192 data = bcma_read16(pi->d11core, D11REGOFFS(phy4wdatalo)); in read_radio_reg()
194 pi->phy_wreg = 0; in read_radio_reg()
199 void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) in write_radio_reg() argument
201 if ((D11REV_GE(pi->sh->corerev, 24)) || in write_radio_reg()
202 (D11REV_IS(pi->sh->corerev, 22) in write_radio_reg()
203 && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { in write_radio_reg()
205 bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), addr); in write_radio_reg()
206 bcma_write16(pi->d11core, D11REGOFFS(radioregdata), val); in write_radio_reg()
208 bcma_wflush16(pi->d11core, D11REGOFFS(phy4waddr), addr); in write_radio_reg()
209 bcma_write16(pi->d11core, D11REGOFFS(phy4wdatalo), val); in write_radio_reg()
212 if ((pi->d11core->bus->hosttype == BCMA_HOSTTYPE_PCI) && in write_radio_reg()
213 (++pi->phy_wreg >= pi->phy_wreg_limit)) { in write_radio_reg()
214 (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); in write_radio_reg()
215 pi->phy_wreg = 0; in write_radio_reg()
219 static u32 read_radio_id(struct brcms_phy *pi) in read_radio_id() argument
223 if (D11REV_GE(pi->sh->corerev, 24)) { in read_radio_id()
226 bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 0); in read_radio_id()
227 b0 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); in read_radio_id()
228 bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 1); in read_radio_id()
229 b1 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); in read_radio_id()
230 bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 2); in read_radio_id()
231 b2 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); in read_radio_id()
236 bcma_wflush16(pi->d11core, D11REGOFFS(phy4waddr), RADIO_IDCODE); in read_radio_id()
237 id = (u32) bcma_read16(pi->d11core, D11REGOFFS(phy4wdatalo)); in read_radio_id()
238 id |= (u32) bcma_read16(pi->d11core, in read_radio_id()
241 pi->phy_wreg = 0; in read_radio_id()
245 void and_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) in and_radio_reg() argument
249 rval = read_radio_reg(pi, addr); in and_radio_reg()
250 write_radio_reg(pi, addr, (rval & val)); in and_radio_reg()
253 void or_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) in or_radio_reg() argument
257 rval = read_radio_reg(pi, addr); in or_radio_reg()
258 write_radio_reg(pi, addr, (rval | val)); in or_radio_reg()
261 void xor_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask) in xor_radio_reg() argument
265 rval = read_radio_reg(pi, addr); in xor_radio_reg()
266 write_radio_reg(pi, addr, (rval ^ mask)); in xor_radio_reg()
269 void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val) in mod_radio_reg() argument
273 rval = read_radio_reg(pi, addr); in mod_radio_reg()
274 write_radio_reg(pi, addr, (rval & ~mask) | (val & mask)); in mod_radio_reg()
277 void write_phy_channel_reg(struct brcms_phy *pi, uint val) in write_phy_channel_reg() argument
279 bcma_write16(pi->d11core, D11REGOFFS(phychannel), val); in write_phy_channel_reg()
282 u16 read_phy_reg(struct brcms_phy *pi, u16 addr) in read_phy_reg() argument
284 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); in read_phy_reg()
286 pi->phy_wreg = 0; in read_phy_reg()
287 return bcma_read16(pi->d11core, D11REGOFFS(phyregdata)); in read_phy_reg()
290 void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) in write_phy_reg() argument
293 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); in write_phy_reg()
294 bcma_write16(pi->d11core, D11REGOFFS(phyregdata), val); in write_phy_reg()
296 (void)bcma_read16(pi->d11core, D11REGOFFS(phyregdata)); in write_phy_reg()
298 bcma_write32(pi->d11core, D11REGOFFS(phyregaddr), addr | (val << 16)); in write_phy_reg()
299 if ((pi->d11core->bus->hosttype == BCMA_HOSTTYPE_PCI) && in write_phy_reg()
300 (++pi->phy_wreg >= pi->phy_wreg_limit)) { in write_phy_reg()
301 pi->phy_wreg = 0; in write_phy_reg()
302 (void)bcma_read16(pi->d11core, D11REGOFFS(phyversion)); in write_phy_reg()
307 void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) in and_phy_reg() argument
309 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); in and_phy_reg()
310 bcma_mask16(pi->d11core, D11REGOFFS(phyregdata), val); in and_phy_reg()
311 pi->phy_wreg = 0; in and_phy_reg()
314 void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) in or_phy_reg() argument
316 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); in or_phy_reg()
317 bcma_set16(pi->d11core, D11REGOFFS(phyregdata), val); in or_phy_reg()
318 pi->phy_wreg = 0; in or_phy_reg()
321 void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val) in mod_phy_reg() argument
324 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); in mod_phy_reg()
325 bcma_maskset16(pi->d11core, D11REGOFFS(phyregdata), ~mask, val); in mod_phy_reg()
326 pi->phy_wreg = 0; in mod_phy_reg()
329 static void wlc_set_phy_uninitted(struct brcms_phy *pi) in wlc_set_phy_uninitted() argument
333 pi->initialized = false; in wlc_set_phy_uninitted()
335 pi->tx_vos = 0xffff; in wlc_set_phy_uninitted()
336 pi->nrssi_table_delta = 0x7fffffff; in wlc_set_phy_uninitted()
337 pi->rc_cal = 0xffff; in wlc_set_phy_uninitted()
338 pi->mintxbias = 0xffff; in wlc_set_phy_uninitted()
339 pi->txpwridx = -1; in wlc_set_phy_uninitted()
340 if (ISNPHY(pi)) { in wlc_set_phy_uninitted()
341 pi->phy_spuravoid = SPURAVOID_DISABLE; in wlc_set_phy_uninitted()
343 if (NREV_GE(pi->pubpi.phy_rev, 3) in wlc_set_phy_uninitted()
344 && NREV_LT(pi->pubpi.phy_rev, 7)) in wlc_set_phy_uninitted()
345 pi->phy_spuravoid = SPURAVOID_AUTO; in wlc_set_phy_uninitted()
347 pi->nphy_papd_skip = 0; in wlc_set_phy_uninitted()
348 pi->nphy_papd_epsilon_offset[0] = 0xf588; in wlc_set_phy_uninitted()
349 pi->nphy_papd_epsilon_offset[1] = 0xf588; in wlc_set_phy_uninitted()
350 pi->nphy_txpwr_idx[0] = 128; in wlc_set_phy_uninitted()
351 pi->nphy_txpwr_idx[1] = 128; in wlc_set_phy_uninitted()
352 pi->nphy_txpwrindex[0].index_internal = 40; in wlc_set_phy_uninitted()
353 pi->nphy_txpwrindex[1].index_internal = 40; in wlc_set_phy_uninitted()
354 pi->phy_pabias = 0; in wlc_set_phy_uninitted()
356 pi->phy_spuravoid = SPURAVOID_AUTO; in wlc_set_phy_uninitted()
358 pi->radiopwr = 0xffff; in wlc_set_phy_uninitted()
361 pi->stats_11b_txpower[i][j] = -1; in wlc_set_phy_uninitted()
397 static void wlc_phy_timercb_phycal(struct brcms_phy *pi) in wlc_phy_timercb_phycal() argument
401 if (PHY_PERICAL_MPHASE_PENDING(pi)) { in wlc_phy_timercb_phycal()
402 if (!pi->sh->up) { in wlc_phy_timercb_phycal()
403 wlc_phy_cal_perical_mphase_reset(pi); in wlc_phy_timercb_phycal()
407 if (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi)) { in wlc_phy_timercb_phycal()
410 wlc_phy_cal_perical_mphase_restart(pi); in wlc_phy_timercb_phycal()
412 wlc_phy_cal_perical_nphy_run(pi, PHY_PERICAL_AUTO); in wlc_phy_timercb_phycal()
413 wlapi_add_timer(pi->phycal_timer, delay, 0); in wlc_phy_timercb_phycal()
419 static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi) in wlc_phy_get_radio_ver() argument
423 ver = read_radio_id(pi); in wlc_phy_get_radio_ver()
432 struct brcms_phy *pi; in wlc_phy_attach() local
448 pi = sh->phy_head; in wlc_phy_attach()
449 if ((sflags & SISF_DB_PHY) && pi) { in wlc_phy_attach()
450 wlapi_bmac_corereset(pi->sh->physhim, pi->pubpi.coreflags); in wlc_phy_attach()
451 pi->refcnt++; in wlc_phy_attach()
452 return &pi->pubpi_ro; in wlc_phy_attach()
455 pi = kzalloc(sizeof(struct brcms_phy), GFP_ATOMIC); in wlc_phy_attach()
456 if (pi == NULL) in wlc_phy_attach()
458 pi->wiphy = wiphy; in wlc_phy_attach()
459 pi->d11core = d11core; in wlc_phy_attach()
460 pi->sh = sh; in wlc_phy_attach()
461 pi->phy_init_por = true; in wlc_phy_attach()
462 pi->phy_wreg_limit = PHY_WREG_LIMIT; in wlc_phy_attach()
464 pi->txpwr_percent = 100; in wlc_phy_attach()
466 pi->do_initcal = true; in wlc_phy_attach()
468 pi->phycal_tempdelta = 0; in wlc_phy_attach()
471 pi->pubpi.coreflags = SICF_GMODE; in wlc_phy_attach()
473 wlapi_bmac_corereset(pi->sh->physhim, pi->pubpi.coreflags); in wlc_phy_attach()
474 phyversion = bcma_read16(pi->d11core, D11REGOFFS(phyversion)); in wlc_phy_attach()
476 pi->pubpi.phy_type = PHY_TYPE(phyversion); in wlc_phy_attach()
477 pi->pubpi.phy_rev = phyversion & PV_PV_MASK; in wlc_phy_attach()
479 if (pi->pubpi.phy_type == PHY_TYPE_LCNXN) { in wlc_phy_attach()
480 pi->pubpi.phy_type = PHY_TYPE_N; in wlc_phy_attach()
481 pi->pubpi.phy_rev += LCNXN_BASEREV; in wlc_phy_attach()
483 pi->pubpi.phy_corenum = PHY_CORE_NUM_2; in wlc_phy_attach()
484 pi->pubpi.ana_rev = (phyversion & PV_AV_MASK) >> PV_AV_SHIFT; in wlc_phy_attach()
486 if (pi->pubpi.phy_type != PHY_TYPE_N && in wlc_phy_attach()
487 pi->pubpi.phy_type != PHY_TYPE_LCN) in wlc_phy_attach()
491 if (!ISNPHY(pi)) in wlc_phy_attach()
493 } else if (!ISNPHY(pi) && !ISLCNPHY(pi)) { in wlc_phy_attach()
497 wlc_phy_anacore((struct brcms_phy_pub *) pi, ON); in wlc_phy_attach()
499 idcode = wlc_phy_get_radio_ver(pi); in wlc_phy_attach()
500 pi->pubpi.radioid = in wlc_phy_attach()
502 pi->pubpi.radiorev = in wlc_phy_attach()
504 pi->pubpi.radiover = in wlc_phy_attach()
506 if (!VALID_RADIO(pi, pi->pubpi.radioid)) in wlc_phy_attach()
509 wlc_phy_switch_radio((struct brcms_phy_pub *) pi, OFF); in wlc_phy_attach()
511 wlc_set_phy_uninitted(pi); in wlc_phy_attach()
513 pi->bw = WL_CHANSPEC_BW_20; in wlc_phy_attach()
514 pi->radio_chanspec = (bandtype == BRCM_BAND_2G) ? in wlc_phy_attach()
517 pi->rxiq_samps = PHY_NOISE_SAMPLE_LOG_NUM_NPHY; in wlc_phy_attach()
518 pi->rxiq_antsel = ANT_RX_DIV_DEF; in wlc_phy_attach()
520 pi->watchdog_override = true; in wlc_phy_attach()
522 pi->cal_type_override = PHY_PERICAL_AUTO; in wlc_phy_attach()
524 pi->nphy_saved_noisevars.bufcount = 0; in wlc_phy_attach()
526 if (ISNPHY(pi)) in wlc_phy_attach()
527 pi->min_txpower = PHY_TXPWR_MIN_NPHY; in wlc_phy_attach()
529 pi->min_txpower = PHY_TXPWR_MIN; in wlc_phy_attach()
531 pi->sh->phyrxchain = 0x3; in wlc_phy_attach()
533 pi->rx2tx_biasentry = -1; in wlc_phy_attach()
535 pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP; in wlc_phy_attach()
536 pi->phy_txcore_enable_temp = in wlc_phy_attach()
538 pi->phy_tempsense_offset = 0; in wlc_phy_attach()
539 pi->phy_txcore_heatedup = false; in wlc_phy_attach()
541 pi->nphy_lastcal_temp = -50; in wlc_phy_attach()
543 pi->phynoise_polling = true; in wlc_phy_attach()
544 if (ISNPHY(pi) || ISLCNPHY(pi)) in wlc_phy_attach()
545 pi->phynoise_polling = false; in wlc_phy_attach()
548 pi->txpwr_limit[i] = BRCMS_TXPWR_MAX; in wlc_phy_attach()
549 pi->txpwr_env_limit[i] = BRCMS_TXPWR_MAX; in wlc_phy_attach()
550 pi->tx_user_target[i] = BRCMS_TXPWR_MAX; in wlc_phy_attach()
553 pi->radiopwr_override = RADIOPWR_OVERRIDE_DEF; in wlc_phy_attach()
555 pi->user_txpwr_at_rfport = false; in wlc_phy_attach()
557 if (ISNPHY(pi)) { in wlc_phy_attach()
559 pi->phycal_timer = wlapi_init_timer(pi->sh->physhim, in wlc_phy_attach()
561 pi, "phycal"); in wlc_phy_attach()
562 if (!pi->phycal_timer) in wlc_phy_attach()
565 if (!wlc_phy_attach_nphy(pi)) in wlc_phy_attach()
568 } else if (ISLCNPHY(pi)) { in wlc_phy_attach()
569 if (!wlc_phy_attach_lcnphy(pi)) in wlc_phy_attach()
574 pi->refcnt++; in wlc_phy_attach()
575 pi->next = pi->sh->phy_head; in wlc_phy_attach()
576 sh->phy_head = pi; in wlc_phy_attach()
578 memcpy(&pi->pubpi_ro, &pi->pubpi, sizeof(struct brcms_phy_pub)); in wlc_phy_attach()
580 return &pi->pubpi_ro; in wlc_phy_attach()
583 kfree(pi); in wlc_phy_attach()
589 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_detach() local
592 if (--pi->refcnt) in wlc_phy_detach()
595 if (pi->phycal_timer) { in wlc_phy_detach()
596 wlapi_free_timer(pi->phycal_timer); in wlc_phy_detach()
597 pi->phycal_timer = NULL; in wlc_phy_detach()
600 if (pi->sh->phy_head == pi) in wlc_phy_detach()
601 pi->sh->phy_head = pi->next; in wlc_phy_detach()
602 else if (pi->sh->phy_head->next == pi) in wlc_phy_detach()
603 pi->sh->phy_head->next = NULL; in wlc_phy_detach()
605 if (pi->pi_fptr.detach) in wlc_phy_detach()
606 (pi->pi_fptr.detach)(pi); in wlc_phy_detach()
608 kfree(pi); in wlc_phy_detach()
616 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_get_phyversion() local
617 *phytype = (u16) pi->pubpi.phy_type; in wlc_phy_get_phyversion()
618 *phyrev = (u16) pi->pubpi.phy_rev; in wlc_phy_get_phyversion()
619 *radioid = pi->pubpi.radioid; in wlc_phy_get_phyversion()
620 *radiover = pi->pubpi.radiorev; in wlc_phy_get_phyversion()
627 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_get_encore() local
628 return pi->pubpi.abgphy_encore; in wlc_phy_get_encore()
633 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_get_coreflags() local
634 return pi->pubpi.coreflags; in wlc_phy_get_coreflags()
639 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_anacore() local
641 if (ISNPHY(pi)) { in wlc_phy_anacore()
643 if (NREV_GE(pi->pubpi.phy_rev, 3)) { in wlc_phy_anacore()
644 write_phy_reg(pi, 0xa6, 0x0d); in wlc_phy_anacore()
645 write_phy_reg(pi, 0x8f, 0x0); in wlc_phy_anacore()
646 write_phy_reg(pi, 0xa7, 0x0d); in wlc_phy_anacore()
647 write_phy_reg(pi, 0xa5, 0x0); in wlc_phy_anacore()
649 write_phy_reg(pi, 0xa5, 0x0); in wlc_phy_anacore()
652 if (NREV_GE(pi->pubpi.phy_rev, 3)) { in wlc_phy_anacore()
653 write_phy_reg(pi, 0x8f, 0x07ff); in wlc_phy_anacore()
654 write_phy_reg(pi, 0xa6, 0x0fd); in wlc_phy_anacore()
655 write_phy_reg(pi, 0xa5, 0x07ff); in wlc_phy_anacore()
656 write_phy_reg(pi, 0xa7, 0x0fd); in wlc_phy_anacore()
658 write_phy_reg(pi, 0xa5, 0x7fff); in wlc_phy_anacore()
661 } else if (ISLCNPHY(pi)) { in wlc_phy_anacore()
663 and_phy_reg(pi, 0x43b, in wlc_phy_anacore()
666 or_phy_reg(pi, 0x43c, in wlc_phy_anacore()
668 or_phy_reg(pi, 0x43b, in wlc_phy_anacore()
676 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_clk_bwbits() local
680 if (pi && (ISNPHY(pi) || ISLCNPHY(pi))) { in wlc_phy_clk_bwbits()
681 switch (pi->bw) { in wlc_phy_clk_bwbits()
701 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_por_inform() local
703 pi->phy_init_por = true; in wlc_phy_por_inform()
708 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_edcrs_lock() local
710 pi->edcrs_threshold_lock = lock; in wlc_phy_edcrs_lock()
712 write_phy_reg(pi, 0x22c, 0x46b); in wlc_phy_edcrs_lock()
713 write_phy_reg(pi, 0x22d, 0x46b); in wlc_phy_edcrs_lock()
714 write_phy_reg(pi, 0x22e, 0x3c0); in wlc_phy_edcrs_lock()
715 write_phy_reg(pi, 0x22f, 0x3c0); in wlc_phy_edcrs_lock()
720 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_initcal_enable() local
722 pi->do_initcal = initcal; in wlc_phy_initcal_enable()
727 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_hw_clk_state_upd() local
729 if (!pi || !pi->sh) in wlc_phy_hw_clk_state_upd()
732 pi->sh->clk = newstate; in wlc_phy_hw_clk_state_upd()
737 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_hw_state_upd() local
739 if (!pi || !pi->sh) in wlc_phy_hw_state_upd()
742 pi->sh->up = newstate; in wlc_phy_hw_state_upd()
749 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_init() local
751 if (pi->init_in_progress) in wlc_phy_init()
754 pi->init_in_progress = true; in wlc_phy_init()
756 pi->radio_chanspec = chanspec; in wlc_phy_init()
758 mc = bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); in wlc_phy_init()
762 if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) in wlc_phy_init()
763 pi->measure_hold |= PHY_HOLD_FOR_NOT_ASSOC; in wlc_phy_init()
765 if (WARN(!(bcma_aread32(pi->d11core, BCMA_IOST) & SISF_FCLKA), in wlc_phy_init()
769 phy_init = pi->pi_fptr.init; in wlc_phy_init()
776 if (CHSPEC_BW(pi->radio_chanspec) != pi->bw) in wlc_phy_init()
777 wlapi_bmac_bw_set(pi->sh->physhim, in wlc_phy_init()
778 CHSPEC_BW(pi->radio_chanspec)); in wlc_phy_init()
780 pi->nphy_gain_boost = true; in wlc_phy_init()
782 wlc_phy_switch_radio((struct brcms_phy_pub *) pi, ON); in wlc_phy_init()
784 (*phy_init)(pi); in wlc_phy_init()
786 pi->phy_init_por = false; in wlc_phy_init()
788 if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) in wlc_phy_init()
789 wlc_phy_do_dummy_tx(pi, true, OFF); in wlc_phy_init()
791 if (!(ISNPHY(pi))) in wlc_phy_init()
792 wlc_phy_txpower_update_shm(pi); in wlc_phy_init()
794 wlc_phy_ant_rxdiv_set((struct brcms_phy_pub *) pi, pi->sh->rx_antdiv); in wlc_phy_init()
796 pi->init_in_progress = false; in wlc_phy_init()
801 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_cal_init() local
804 if (WARN((bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & in wlc_phy_cal_init()
808 if (!pi->initialized) { in wlc_phy_cal_init()
809 cal_init = pi->pi_fptr.calinit; in wlc_phy_cal_init()
811 (*cal_init)(pi); in wlc_phy_cal_init()
813 pi->initialized = true; in wlc_phy_cal_init()
819 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_down() local
822 if (pi->phycal_timer in wlc_phy_down()
823 && !wlapi_del_timer(pi->phycal_timer)) in wlc_phy_down()
826 pi->nphy_iqcal_chanspec_2G = 0; in wlc_phy_down()
827 pi->nphy_iqcal_chanspec_5G = 0; in wlc_phy_down()
833 wlc_phy_table_addr(struct brcms_phy *pi, uint tbl_id, uint tbl_offset, in wlc_phy_table_addr() argument
836 write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset); in wlc_phy_table_addr()
838 pi->tbl_data_hi = tblDataHi; in wlc_phy_table_addr()
839 pi->tbl_data_lo = tblDataLo; in wlc_phy_table_addr()
841 if (pi->sh->chip == BCMA_CHIP_ID_BCM43224 && in wlc_phy_table_addr()
842 pi->sh->chiprev == 1) { in wlc_phy_table_addr()
843 pi->tbl_addr = tblAddr; in wlc_phy_table_addr()
844 pi->tbl_save_id = tbl_id; in wlc_phy_table_addr()
845 pi->tbl_save_offset = tbl_offset; in wlc_phy_table_addr()
849 void wlc_phy_table_data_write(struct brcms_phy *pi, uint width, u32 val) in wlc_phy_table_data_write() argument
851 if ((pi->sh->chip == BCMA_CHIP_ID_BCM43224) && in wlc_phy_table_data_write()
852 (pi->sh->chiprev == 1) && in wlc_phy_table_data_write()
853 (pi->tbl_save_id == NPHY_TBL_ID_ANTSWCTRLLUT)) { in wlc_phy_table_data_write()
854 read_phy_reg(pi, pi->tbl_data_lo); in wlc_phy_table_data_write()
856 write_phy_reg(pi, pi->tbl_addr, in wlc_phy_table_data_write()
857 (pi->tbl_save_id << 10) | pi->tbl_save_offset); in wlc_phy_table_data_write()
858 pi->tbl_save_offset++; in wlc_phy_table_data_write()
862 write_phy_reg(pi, pi->tbl_data_hi, (u16) (val >> 16)); in wlc_phy_table_data_write()
863 write_phy_reg(pi, pi->tbl_data_lo, (u16) val); in wlc_phy_table_data_write()
865 write_phy_reg(pi, pi->tbl_data_lo, (u16) val); in wlc_phy_table_data_write()
870 wlc_phy_write_table(struct brcms_phy *pi, const struct phytbl_info *ptbl_info, in wlc_phy_write_table() argument
881 write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset); in wlc_phy_write_table()
885 if ((pi->sh->chip == BCMA_CHIP_ID_BCM43224) && in wlc_phy_write_table()
886 (pi->sh->chiprev == 1) && in wlc_phy_write_table()
888 read_phy_reg(pi, tblDataLo); in wlc_phy_write_table()
890 write_phy_reg(pi, tblAddr, in wlc_phy_write_table()
895 write_phy_reg(pi, tblDataHi, in wlc_phy_write_table()
897 write_phy_reg(pi, tblDataLo, (u16) ptbl_32b[idx]); in wlc_phy_write_table()
899 write_phy_reg(pi, tblDataLo, ptbl_16b[idx]); in wlc_phy_write_table()
901 write_phy_reg(pi, tblDataLo, ptbl_8b[idx]); in wlc_phy_write_table()
907 wlc_phy_read_table(struct brcms_phy *pi, const struct phytbl_info *ptbl_info, in wlc_phy_read_table() argument
918 write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset); in wlc_phy_read_table()
922 if ((pi->sh->chip == BCMA_CHIP_ID_BCM43224) && in wlc_phy_read_table()
923 (pi->sh->chiprev == 1)) { in wlc_phy_read_table()
924 (void)read_phy_reg(pi, tblDataLo); in wlc_phy_read_table()
926 write_phy_reg(pi, tblAddr, in wlc_phy_read_table()
931 ptbl_32b[idx] = read_phy_reg(pi, tblDataLo); in wlc_phy_read_table()
932 ptbl_32b[idx] |= (read_phy_reg(pi, tblDataHi) << 16); in wlc_phy_read_table()
934 ptbl_16b[idx] = read_phy_reg(pi, tblDataLo); in wlc_phy_read_table()
936 ptbl_8b[idx] = (u8) read_phy_reg(pi, tblDataLo); in wlc_phy_read_table()
942 wlc_phy_init_radio_regs_allbands(struct brcms_phy *pi, in wlc_phy_init_radio_regs_allbands() argument
949 write_radio_reg(pi, radioregs[i].address, in wlc_phy_init_radio_regs_allbands()
959 wlc_phy_init_radio_regs(struct brcms_phy *pi, in wlc_phy_init_radio_regs() argument
967 if (CHSPEC_IS5G(pi->radio_chanspec)) { in wlc_phy_init_radio_regs()
969 write_radio_reg(pi, in wlc_phy_init_radio_regs()
973 if (ISNPHY(pi) && (++count % 4 == 0)) in wlc_phy_init_radio_regs()
974 BRCMS_PHY_WAR_PR51571(pi); in wlc_phy_init_radio_regs()
978 write_radio_reg(pi, in wlc_phy_init_radio_regs()
982 if (ISNPHY(pi) && (++count % 4 == 0)) in wlc_phy_init_radio_regs()
983 BRCMS_PHY_WAR_PR51571(pi); in wlc_phy_init_radio_regs()
993 void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) in wlc_phy_do_dummy_tx() argument
996 struct bcma_device *core = pi->d11core; in wlc_phy_do_dummy_tx()
1009 wlapi_bmac_write_template_ram(pi->sh->physhim, 0, DUMMY_PKT_LEN, in wlc_phy_do_dummy_tx()
1014 if (D11REV_GE(pi->sh->corerev, 11)) in wlc_phy_do_dummy_tx()
1021 if (ISNPHY(pi) || ISLCNPHY(pi)) in wlc_phy_do_dummy_tx()
1036 if (ISNPHY(pi)) in wlc_phy_do_dummy_tx()
1037 wlc_phy_pa_override_nphy(pi, OFF); in wlc_phy_do_dummy_tx()
1040 if (ISNPHY(pi) || ISLCNPHY(pi)) in wlc_phy_do_dummy_tx()
1066 if (ISNPHY(pi)) in wlc_phy_do_dummy_tx()
1067 wlc_phy_pa_override_nphy(pi, ON); in wlc_phy_do_dummy_tx()
1073 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_hold_upd() local
1076 mboolset(pi->measure_hold, id); in wlc_phy_hold_upd()
1078 mboolclr(pi->measure_hold, id); in wlc_phy_hold_upd()
1085 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_mute_upd() local
1088 mboolset(pi->measure_hold, PHY_HOLD_FOR_MUTE); in wlc_phy_mute_upd()
1090 mboolclr(pi->measure_hold, PHY_HOLD_FOR_MUTE); in wlc_phy_mute_upd()
1093 pi->nphy_perical_last = pi->sh->now - pi->sh->glacial_timer; in wlc_phy_mute_upd()
1099 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_clear_tssi() local
1101 if (ISNPHY(pi)) { in wlc_phy_clear_tssi()
1104 wlapi_bmac_write_shm(pi->sh->physhim, M_B_TSSI_0, NULL_TSSI_W); in wlc_phy_clear_tssi()
1105 wlapi_bmac_write_shm(pi->sh->physhim, M_B_TSSI_1, NULL_TSSI_W); in wlc_phy_clear_tssi()
1106 wlapi_bmac_write_shm(pi->sh->physhim, M_G_TSSI_0, NULL_TSSI_W); in wlc_phy_clear_tssi()
1107 wlapi_bmac_write_shm(pi->sh->physhim, M_G_TSSI_1, NULL_TSSI_W); in wlc_phy_clear_tssi()
1111 static bool wlc_phy_cal_txpower_recalc_sw(struct brcms_phy *pi) in wlc_phy_cal_txpower_recalc_sw() argument
1118 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_switch_radio() local
1119 (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); in wlc_phy_switch_radio()
1121 if (ISNPHY(pi)) { in wlc_phy_switch_radio()
1122 wlc_phy_switch_radio_nphy(pi, on); in wlc_phy_switch_radio()
1123 } else if (ISLCNPHY(pi)) { in wlc_phy_switch_radio()
1125 and_phy_reg(pi, 0x44c, in wlc_phy_switch_radio()
1129 and_phy_reg(pi, 0x4b0, ~((0x1 << 3) | (0x1 << 11))); in wlc_phy_switch_radio()
1130 and_phy_reg(pi, 0x4f9, ~(0x1 << 3)); in wlc_phy_switch_radio()
1132 and_phy_reg(pi, 0x44d, in wlc_phy_switch_radio()
1136 or_phy_reg(pi, 0x44c, in wlc_phy_switch_radio()
1141 and_phy_reg(pi, 0x4b7, ~((0x7f << 8))); in wlc_phy_switch_radio()
1142 and_phy_reg(pi, 0x4b1, ~((0x1 << 13))); in wlc_phy_switch_radio()
1143 or_phy_reg(pi, 0x4b0, (0x1 << 3) | (0x1 << 11)); in wlc_phy_switch_radio()
1144 and_phy_reg(pi, 0x4fa, ~((0x1 << 3))); in wlc_phy_switch_radio()
1145 or_phy_reg(pi, 0x4f9, (0x1 << 3)); in wlc_phy_switch_radio()
1152 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_bw_state_get() local
1154 return pi->bw; in wlc_phy_bw_state_get()
1159 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_bw_state_set() local
1161 pi->bw = bw; in wlc_phy_bw_state_set()
1166 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_radio_set() local
1167 pi->radio_chanspec = newch; in wlc_phy_chanspec_radio_set()
1173 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_get() local
1175 return pi->radio_chanspec; in wlc_phy_chanspec_get()
1180 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_set() local
1188 wlapi_bmac_write_shm(pi->sh->physhim, M_CURCHANNEL, m_cur_channel); in wlc_phy_chanspec_set()
1190 chanspec_set = pi->pi_fptr.chanset; in wlc_phy_chanspec_set()
1192 (*chanspec_set)(pi, chanspec); in wlc_phy_chanspec_set()
1212 int wlc_phy_chanspec_bandrange_get(struct brcms_phy *pi, u16 chanspec) in wlc_phy_chanspec_bandrange_get() argument
1218 if (ISNPHY(pi)) in wlc_phy_chanspec_bandrange_get()
1219 range = wlc_phy_get_chan_freq_range_nphy(pi, channel); in wlc_phy_chanspec_bandrange_get()
1220 else if (ISLCNPHY(pi)) in wlc_phy_chanspec_bandrange_get()
1229 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_ch14_widefilter_set() local
1231 pi->channel_14_wide_filter = wide_filter; in wlc_phy_chanspec_ch14_widefilter_set()
1249 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_band_validch() local
1258 if ((pi->a_band_high_disable) && (channel >= FIRST_REF5_CHANNUM) in wlc_phy_chanspec_band_validch()
1270 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_chanspec_band_firstch() local
1278 if (ISNPHY(pi) && pi->bw == WL_CHANSPEC_BW_40) { in wlc_phy_chanspec_band_firstch()
1300 if ((pi->a_band_high_disable) && (channel >= FIRST_REF5_CHANNUM) in wlc_phy_chanspec_band_firstch()
1314 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_get() local
1316 *qdbm = pi->tx_user_target[0]; in wlc_phy_txpower_get()
1318 *override = pi->txpwroverride; in wlc_phy_txpower_get()
1326 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_target_set() local
1328 memcpy(&pi->tx_user_target[TXP_FIRST_CCK], in wlc_phy_txpower_target_set()
1331 memcpy(&pi->tx_user_target[TXP_FIRST_OFDM], in wlc_phy_txpower_target_set()
1333 memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_20_CDD], in wlc_phy_txpower_target_set()
1336 memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_40_SISO], in wlc_phy_txpower_target_set()
1338 memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_40_CDD], in wlc_phy_txpower_target_set()
1341 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_SISO], in wlc_phy_txpower_target_set()
1343 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_CDD], in wlc_phy_txpower_target_set()
1345 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_STBC], in wlc_phy_txpower_target_set()
1347 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_SDM], in wlc_phy_txpower_target_set()
1350 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_SISO], in wlc_phy_txpower_target_set()
1352 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_CDD], in wlc_phy_txpower_target_set()
1354 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_STBC], in wlc_phy_txpower_target_set()
1356 memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_SDM], in wlc_phy_txpower_target_set()
1359 if (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & MCTL_EN_MAC) in wlc_phy_txpower_target_set()
1363 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_txpower_target_set()
1365 wlc_phy_txpower_recalc_target(pi); in wlc_phy_txpower_target_set()
1366 wlc_phy_cal_txpower_recalc_sw(pi); in wlc_phy_txpower_target_set()
1369 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_txpower_target_set()
1374 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_set() local
1381 pi->tx_user_target[i] = (u8) qdbm; in wlc_phy_txpower_set()
1383 pi->txpwroverride = false; in wlc_phy_txpower_set()
1385 if (pi->sh->up) { in wlc_phy_txpower_set()
1386 if (!SCAN_INPROG_PHY(pi)) { in wlc_phy_txpower_set()
1389 suspend = (0 == (bcma_read32(pi->d11core, in wlc_phy_txpower_set()
1394 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_txpower_set()
1396 wlc_phy_txpower_recalc_target(pi); in wlc_phy_txpower_set()
1397 wlc_phy_cal_txpower_recalc_sw(pi); in wlc_phy_txpower_set()
1400 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_txpower_set()
1410 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_sromlimit() local
1413 *min_pwr = pi->min_txpower * BRCMS_TXPWR_DB_FACTOR; in wlc_phy_txpower_sromlimit()
1415 if (ISNPHY(pi)) { in wlc_phy_txpower_sromlimit()
1418 wlc_phy_txpower_sromlimit_get_nphy(pi, channel, max_pwr, in wlc_phy_txpower_sromlimit()
1424 *max_pwr = pi->tx_srom_max_rate_2g[txp_rate_idx]; in wlc_phy_txpower_sromlimit()
1437 if (pi->hwtxpwr) { in wlc_phy_txpower_sromlimit()
1438 *max_pwr = pi->hwtxpwr[i]; in wlc_phy_txpower_sromlimit()
1443 pi->tx_srom_max_rate_5g_mid[txp_rate_idx]; in wlc_phy_txpower_sromlimit()
1447 pi->tx_srom_max_rate_5g_hi[txp_rate_idx]; in wlc_phy_txpower_sromlimit()
1450 pi->tx_srom_max_rate_5g_low[txp_rate_idx]; in wlc_phy_txpower_sromlimit()
1459 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_sromlimit_max_get() local
1467 max_num_rate = ISNPHY(pi) ? TXP_NUM_RATES : in wlc_phy_txpower_sromlimit_max_get()
1468 ISLCNPHY(pi) ? (TXP_LAST_SISO_MCS_20 + in wlc_phy_txpower_sromlimit_max_get()
1496 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_get_target_min() local
1498 return pi->tx_power_min; in wlc_phy_txpower_get_target_min()
1503 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_get_target_max() local
1505 return pi->tx_power_max; in wlc_phy_txpower_get_target_max()
1508 static s8 wlc_phy_env_measure_vbat(struct brcms_phy *pi) in wlc_phy_env_measure_vbat() argument
1510 if (ISLCNPHY(pi)) in wlc_phy_env_measure_vbat()
1511 return wlc_lcnphy_vbatsense(pi, 0); in wlc_phy_env_measure_vbat()
1516 static s8 wlc_phy_env_measure_temperature(struct brcms_phy *pi) in wlc_phy_env_measure_temperature() argument
1518 if (ISLCNPHY(pi)) in wlc_phy_env_measure_temperature()
1519 return wlc_lcnphy_tempsense_degree(pi, 0); in wlc_phy_env_measure_temperature()
1524 static void wlc_phy_upd_env_txpwr_rate_limits(struct brcms_phy *pi, u32 band) in wlc_phy_upd_env_txpwr_rate_limits() argument
1530 pi->txpwr_env_limit[i] = BRCMS_TXPWR_MAX; in wlc_phy_upd_env_txpwr_rate_limits()
1532 vbat = wlc_phy_env_measure_vbat(pi); in wlc_phy_upd_env_txpwr_rate_limits()
1533 temp = wlc_phy_env_measure_temperature(pi); in wlc_phy_upd_env_txpwr_rate_limits()
1538 wlc_user_txpwr_antport_to_rfport(struct brcms_phy *pi, uint chan, u32 band, in wlc_user_txpwr_antport_to_rfport() argument
1544 void wlc_phy_txpower_recalc_target(struct brcms_phy *pi) in wlc_phy_txpower_recalc_target() argument
1555 u32 band = CHSPEC2BAND(pi->radio_chanspec); in wlc_phy_txpower_recalc_target()
1558 chspec = pi->radio_chanspec; in wlc_phy_txpower_recalc_target()
1567 if (ISLCNPHY(pi)) { in wlc_phy_txpower_recalc_target()
1570 if (CHSPEC_IS40(pi->radio_chanspec)) { in wlc_phy_txpower_recalc_target()
1571 offset_mcs = pi->mcs40_po; in wlc_phy_txpower_recalc_target()
1574 pi->tx_srom_max_rate_2g[i - 8] = in wlc_phy_txpower_recalc_target()
1575 pi->tx_srom_max_2g - in wlc_phy_txpower_recalc_target()
1580 offset_mcs = pi->mcs20_po; in wlc_phy_txpower_recalc_target()
1583 pi->tx_srom_max_rate_2g[i - 8] = in wlc_phy_txpower_recalc_target()
1584 pi->tx_srom_max_2g - in wlc_phy_txpower_recalc_target()
1591 max_num_rate = ((ISNPHY(pi)) ? (TXP_NUM_RATES) : in wlc_phy_txpower_recalc_target()
1592 ((ISLCNPHY(pi)) ? in wlc_phy_txpower_recalc_target()
1595 wlc_phy_upd_env_txpwr_rate_limits(pi, band); in wlc_phy_txpower_recalc_target()
1599 tx_pwr_target[rate] = pi->tx_user_target[rate]; in wlc_phy_txpower_recalc_target()
1601 if (pi->user_txpwr_at_rfport) in wlc_phy_txpower_recalc_target()
1603 wlc_user_txpwr_antport_to_rfport(pi, in wlc_phy_txpower_recalc_target()
1608 wlc_phy_txpower_sromlimit((struct brcms_phy_pub *) pi, in wlc_phy_txpower_recalc_target()
1612 maxtxpwr = min(maxtxpwr, pi->txpwr_limit[rate]); in wlc_phy_txpower_recalc_target()
1620 if (pi->txpwr_percent <= 100) in wlc_phy_txpower_recalc_target()
1621 maxtxpwr = (maxtxpwr * pi->txpwr_percent) / 100; in wlc_phy_txpower_recalc_target()
1626 min(tx_pwr_target[rate], pi->txpwr_env_limit[rate]); in wlc_phy_txpower_recalc_target()
1635 memset(pi->tx_power_offset, 0, sizeof(pi->tx_power_offset)); in wlc_phy_txpower_recalc_target()
1636 pi->tx_power_max = tx_pwr_max; in wlc_phy_txpower_recalc_target()
1637 pi->tx_power_min = tx_pwr_min; in wlc_phy_txpower_recalc_target()
1638 pi->tx_power_max_rate_ind = tx_pwr_max_rate_ind; in wlc_phy_txpower_recalc_target()
1641 pi->tx_power_target[rate] = tx_pwr_target[rate]; in wlc_phy_txpower_recalc_target()
1643 if (!pi->hwpwrctrl || ISNPHY(pi)) in wlc_phy_txpower_recalc_target()
1644 pi->tx_power_offset[rate] = in wlc_phy_txpower_recalc_target()
1645 pi->tx_power_max - pi->tx_power_target[rate]; in wlc_phy_txpower_recalc_target()
1647 pi->tx_power_offset[rate] = in wlc_phy_txpower_recalc_target()
1648 pi->tx_power_target[rate] - pi->tx_power_min; in wlc_phy_txpower_recalc_target()
1651 txpwr_recalc_fn = pi->pi_fptr.txpwrrecalc; in wlc_phy_txpower_recalc_target()
1653 (*txpwr_recalc_fn)(pi); in wlc_phy_txpower_recalc_target()
1657 wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr, in wlc_phy_txpower_reg_limit_calc() argument
1666 pi->txpwr_limit[rate1] = txpwr->cck[rate2]; in wlc_phy_txpower_reg_limit_calc()
1670 pi->txpwr_limit[rate1] = txpwr->ofdm[rate2]; in wlc_phy_txpower_reg_limit_calc()
1672 if (ISNPHY(pi)) { in wlc_phy_txpower_reg_limit_calc()
1715 pi->txpwr_limit[rate1] = in wlc_phy_txpower_reg_limit_calc()
1760 pi->txpwr_limit[rate1] = in wlc_phy_txpower_reg_limit_calc()
1781 pi->txpwr_limit[rate1] = txpwr_ptr1[rate2]; in wlc_phy_txpower_reg_limit_calc()
1800 pi->txpwr_limit[rate1] = txpwr_ptr1[rate2]; in wlc_phy_txpower_reg_limit_calc()
1803 pi->txpwr_limit[WL_TX_POWER_MCS_32] = txpwr->mcs32; in wlc_phy_txpower_reg_limit_calc()
1805 pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST] = in wlc_phy_txpower_reg_limit_calc()
1806 min(pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST], in wlc_phy_txpower_reg_limit_calc()
1807 pi->txpwr_limit[WL_TX_POWER_MCS_32]); in wlc_phy_txpower_reg_limit_calc()
1808 pi->txpwr_limit[WL_TX_POWER_MCS_32] = in wlc_phy_txpower_reg_limit_calc()
1809 pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST]; in wlc_phy_txpower_reg_limit_calc()
1815 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpwr_percent_set() local
1817 pi->txpwr_percent = txpwr_percent; in wlc_phy_txpwr_percent_set()
1822 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_machwcap_set() local
1824 pi->sh->machwcap = machwcap; in wlc_phy_machwcap_set()
1829 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_runbist_config() local
1834 if (!ISNPHY(pi)) in wlc_phy_runbist_config()
1837 if (NREV_IS(pi->pubpi.phy_rev, 3) in wlc_phy_runbist_config()
1838 || NREV_IS(pi->pubpi.phy_rev, 4)) { in wlc_phy_runbist_config()
1839 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), in wlc_phy_runbist_config()
1841 bcma_set16(pi->d11core, D11REGOFFS(phyregdata), in wlc_phy_runbist_config()
1845 if (NREV_IS(pi->pubpi.phy_rev, 3) in wlc_phy_runbist_config()
1846 || NREV_IS(pi->pubpi.phy_rev, 4)) { in wlc_phy_runbist_config()
1847 bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), in wlc_phy_runbist_config()
1849 bcma_write16(pi->d11core, D11REGOFFS(phyregdata), rxc); in wlc_phy_runbist_config()
1860 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_limit_set() local
1862 wlc_phy_txpower_reg_limit_calc(pi, txpwr, chanspec); in wlc_phy_txpower_limit_set()
1864 if (ISLCNPHY(pi)) { in wlc_phy_txpower_limit_set()
1869 pi->txpwr_limit[i] = txpwr->mcs_20_siso[j]; in wlc_phy_txpower_limit_set()
1871 pi->txpwr_limit[i] = txpwr->ofdm[j]; in wlc_phy_txpower_limit_set()
1875 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_txpower_limit_set()
1877 wlc_phy_txpower_recalc_target(pi); in wlc_phy_txpower_limit_set()
1878 wlc_phy_cal_txpower_recalc_sw(pi); in wlc_phy_txpower_limit_set()
1879 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_txpower_limit_set()
1884 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_ofdm_rateset_war() local
1886 pi->ofdm_rateset_war = war; in wlc_phy_ofdm_rateset_war()
1891 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_bf_preempt_enable() local
1893 pi->bf_preempt_4306 = bf_preempt; in wlc_phy_bf_preempt_enable()
1896 void wlc_phy_txpower_update_shm(struct brcms_phy *pi) in wlc_phy_txpower_update_shm() argument
1899 if (ISNPHY(pi)) in wlc_phy_txpower_update_shm()
1902 if (!pi->sh->clk) in wlc_phy_txpower_update_shm()
1905 if (pi->hwpwrctrl) { in wlc_phy_txpower_update_shm()
1908 wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_MAX, 63); in wlc_phy_txpower_update_shm()
1909 wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_N, in wlc_phy_txpower_update_shm()
1912 wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_TARGET, in wlc_phy_txpower_update_shm()
1913 pi->tx_power_min << NUM_TSSI_FRAMES); in wlc_phy_txpower_update_shm()
1915 wlapi_bmac_write_shm(pi->sh->physhim, M_TXPWR_CUR, in wlc_phy_txpower_update_shm()
1916 pi->hwpwr_txcur); in wlc_phy_txpower_update_shm()
1923 pi->sh->physhim, in wlc_phy_txpower_update_shm()
1925 wlapi_bmac_write_shm(pi->sh->physhim, offset + 6, in wlc_phy_txpower_update_shm()
1926 pi->tx_power_offset[j]); in wlc_phy_txpower_update_shm()
1927 wlapi_bmac_write_shm(pi->sh->physhim, offset + 14, in wlc_phy_txpower_update_shm()
1928 -(pi->tx_power_offset[j] / 2)); in wlc_phy_txpower_update_shm()
1931 wlapi_bmac_mhf(pi->sh->physhim, MHF2, MHF2_HWPWRCTL, in wlc_phy_txpower_update_shm()
1937 pi->tx_power_offset[i] = in wlc_phy_txpower_update_shm()
1938 (u8) roundup(pi->tx_power_offset[i], 8); in wlc_phy_txpower_update_shm()
1939 wlapi_bmac_write_shm(pi->sh->physhim, M_OFDM_OFFSET, in wlc_phy_txpower_update_shm()
1941 ((pi->tx_power_offset[TXP_FIRST_OFDM] in wlc_phy_txpower_update_shm()
1948 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_hw_ctrl_get() local
1950 if (ISNPHY(pi)) in wlc_phy_txpower_hw_ctrl_get()
1951 return pi->nphy_txpwrctrl; in wlc_phy_txpower_hw_ctrl_get()
1953 return pi->hwpwrctrl; in wlc_phy_txpower_hw_ctrl_get()
1958 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_hw_ctrl_set() local
1961 if (!pi->hwpwrctrl_capable) in wlc_phy_txpower_hw_ctrl_set()
1964 pi->hwpwrctrl = hwpwrctrl; in wlc_phy_txpower_hw_ctrl_set()
1965 pi->nphy_txpwrctrl = hwpwrctrl; in wlc_phy_txpower_hw_ctrl_set()
1966 pi->txpwrctrl = hwpwrctrl; in wlc_phy_txpower_hw_ctrl_set()
1968 if (ISNPHY(pi)) { in wlc_phy_txpower_hw_ctrl_set()
1969 suspend = (0 == (bcma_read32(pi->d11core, in wlc_phy_txpower_hw_ctrl_set()
1973 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_txpower_hw_ctrl_set()
1975 wlc_phy_txpwrctrl_enable_nphy(pi, pi->nphy_txpwrctrl); in wlc_phy_txpower_hw_ctrl_set()
1976 if (pi->nphy_txpwrctrl == PHY_TPC_HW_OFF) in wlc_phy_txpower_hw_ctrl_set()
1977 wlc_phy_txpwr_fixpower_nphy(pi); in wlc_phy_txpower_hw_ctrl_set()
1979 mod_phy_reg(pi, 0x1e7, (0x7f << 0), in wlc_phy_txpower_hw_ctrl_set()
1980 pi->saved_txpwr_idx); in wlc_phy_txpower_hw_ctrl_set()
1983 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_txpower_hw_ctrl_set()
1987 void wlc_phy_txpower_ipa_upd(struct brcms_phy *pi) in wlc_phy_txpower_ipa_upd() argument
1990 if (NREV_GE(pi->pubpi.phy_rev, 3)) { in wlc_phy_txpower_ipa_upd()
1991 pi->ipa2g_on = (pi->srom_fem2g.extpagain == 2); in wlc_phy_txpower_ipa_upd()
1992 pi->ipa5g_on = (pi->srom_fem5g.extpagain == 2); in wlc_phy_txpower_ipa_upd()
1994 pi->ipa2g_on = false; in wlc_phy_txpower_ipa_upd()
1995 pi->ipa5g_on = false; in wlc_phy_txpower_ipa_upd()
1999 static u32 wlc_phy_txpower_est_power_nphy(struct brcms_phy *pi) in wlc_phy_txpower_est_power_nphy() argument
2006 estPower1 = read_phy_reg(pi, 0x118); in wlc_phy_txpower_est_power_nphy()
2007 estPower2 = read_phy_reg(pi, 0x119); in wlc_phy_txpower_est_power_nphy()
2019 tx0_status = read_phy_reg(pi, 0x1ed); in wlc_phy_txpower_est_power_nphy()
2020 tx1_status = read_phy_reg(pi, 0x1ee); in wlc_phy_txpower_est_power_nphy()
2041 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_get_current() local
2049 if (ISNPHY(pi)) { in wlc_phy_txpower_get_current()
2052 if (pi->nphy_txpwrctrl == PHY_TPC_HW_ON) in wlc_phy_txpower_get_current()
2055 } else if (ISLCNPHY(pi)) { in wlc_phy_txpower_get_current()
2058 if (pi->radiopwr_override == RADIOPWR_OVERRIDE_DEF) in wlc_phy_txpower_get_current()
2060 if (pi->hwpwrctrl) in wlc_phy_txpower_get_current()
2064 num_rates = ((ISNPHY(pi)) ? (TXP_NUM_RATES) : in wlc_phy_txpower_get_current()
2065 ((ISLCNPHY(pi)) ? in wlc_phy_txpower_get_current()
2069 power->user_limit[rate] = pi->tx_user_target[rate]; in wlc_phy_txpower_get_current()
2073 power->target[rate] = pi->tx_power_target[rate]; in wlc_phy_txpower_get_current()
2076 if (ISNPHY(pi)) { in wlc_phy_txpower_get_current()
2079 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_txpower_get_current()
2080 wlc_phyreg_enter((struct brcms_phy_pub *) pi); in wlc_phy_txpower_get_current()
2081 est_pout = wlc_phy_txpower_est_power_nphy(pi); in wlc_phy_txpower_get_current()
2082 wlc_phyreg_exit((struct brcms_phy_pub *) pi); in wlc_phy_txpower_get_current()
2083 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_txpower_get_current()
2103 power->tx_power_max[0] = pi->tx_power_max; in wlc_phy_txpower_get_current()
2104 power->tx_power_max[1] = pi->tx_power_max; in wlc_phy_txpower_get_current()
2106 power->tx_power_max_rate_ind[0] = pi->tx_power_max_rate_ind; in wlc_phy_txpower_get_current()
2107 power->tx_power_max_rate_ind[1] = pi->tx_power_max_rate_ind; in wlc_phy_txpower_get_current()
2108 } else if (pi->hwpwrctrl && pi->sh->up) { in wlc_phy_txpower_get_current()
2111 if (ISLCNPHY(pi)) { in wlc_phy_txpower_get_current()
2113 power->tx_power_max[0] = pi->tx_power_max; in wlc_phy_txpower_get_current()
2114 power->tx_power_max[1] = pi->tx_power_max; in wlc_phy_txpower_get_current()
2117 pi->tx_power_max_rate_ind; in wlc_phy_txpower_get_current()
2119 pi->tx_power_max_rate_ind; in wlc_phy_txpower_get_current()
2121 if (wlc_phy_tpc_isenabled_lcnphy(pi)) in wlc_phy_txpower_get_current()
2130 wlc_lcnphy_get_tssi(pi, (s8 *) &power->est_Pout[0], in wlc_phy_txpower_get_current()
2139 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_antsel_type_set() local
2141 pi->antsel_type = antsel_type; in wlc_phy_antsel_type_set()
2146 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_test_ison() local
2148 return pi->phytest_on; in wlc_phy_test_ison()
2153 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_ant_rxdiv_set() local
2156 pi->sh->rx_antdiv = val; in wlc_phy_ant_rxdiv_set()
2158 if (!(ISNPHY(pi) && D11REV_IS(pi->sh->corerev, 16))) { in wlc_phy_ant_rxdiv_set()
2160 wlapi_bmac_mhf(pi->sh->physhim, MHF1, MHF1_ANTDIV, in wlc_phy_ant_rxdiv_set()
2163 wlapi_bmac_mhf(pi->sh->physhim, MHF1, MHF1_ANTDIV, 0, in wlc_phy_ant_rxdiv_set()
2167 if (ISNPHY(pi)) in wlc_phy_ant_rxdiv_set()
2170 if (!pi->sh->clk) in wlc_phy_ant_rxdiv_set()
2173 suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & in wlc_phy_ant_rxdiv_set()
2176 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_ant_rxdiv_set()
2178 if (ISLCNPHY(pi)) { in wlc_phy_ant_rxdiv_set()
2180 mod_phy_reg(pi, 0x410, (0x1 << 1), 0x01 << 1); in wlc_phy_ant_rxdiv_set()
2181 mod_phy_reg(pi, 0x410, in wlc_phy_ant_rxdiv_set()
2185 mod_phy_reg(pi, 0x410, (0x1 << 1), 0x00 << 1); in wlc_phy_ant_rxdiv_set()
2186 mod_phy_reg(pi, 0x410, (0x1 << 0), (u16) val << 0); in wlc_phy_ant_rxdiv_set()
2191 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_ant_rxdiv_set()
2197 wlc_phy_noise_calc_phy(struct brcms_phy *pi, u32 *cmplx_pwr, s8 *pwr_ant) in wlc_phy_noise_calc_phy() argument
2203 wlc_phy_compute_dB(cmplx_pwr, cmplx_pwr_dbm, pi->pubpi.phy_corenum); in wlc_phy_noise_calc_phy()
2205 for (i = 0; i < pi->pubpi.phy_corenum; i++) { in wlc_phy_noise_calc_phy()
2206 if (NREV_GE(pi->pubpi.phy_rev, 3)) in wlc_phy_noise_calc_phy()
2213 for (i = 0; i < pi->pubpi.phy_corenum; i++) { in wlc_phy_noise_calc_phy()
2214 pi->nphy_noise_win[i][pi->nphy_noise_index] = cmplx_pwr_dbm[i]; in wlc_phy_noise_calc_phy()
2217 pi->nphy_noise_index = in wlc_phy_noise_calc_phy()
2218 MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); in wlc_phy_noise_calc_phy()
2222 static void wlc_phy_noise_cb(struct brcms_phy *pi, u8 channel, s8 noise_dbm) in wlc_phy_noise_cb() argument
2224 if (!pi->phynoise_state) in wlc_phy_noise_cb()
2227 if (pi->phynoise_state & PHY_NOISE_STATE_MON) { in wlc_phy_noise_cb()
2228 if (pi->phynoise_chan_watchdog == channel) { in wlc_phy_noise_cb()
2229 pi->sh->phy_noise_window[pi->sh->phy_noise_index] = in wlc_phy_noise_cb()
2231 pi->sh->phy_noise_index = in wlc_phy_noise_cb()
2232 MODINC(pi->sh->phy_noise_index, MA_WINDOW_SZ); in wlc_phy_noise_cb()
2234 pi->phynoise_state &= ~PHY_NOISE_STATE_MON; in wlc_phy_noise_cb()
2237 if (pi->phynoise_state & PHY_NOISE_STATE_EXTERNAL) in wlc_phy_noise_cb()
2238 pi->phynoise_state &= ~PHY_NOISE_STATE_EXTERNAL; in wlc_phy_noise_cb()
2242 static s8 wlc_phy_noise_read_shmem(struct brcms_phy *pi) in wlc_phy_noise_read_shmem() argument
2254 for (idx = 0, core = 0; core < pi->pubpi.phy_corenum; idx += 2, in wlc_phy_noise_read_shmem()
2256 lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP(idx)); in wlc_phy_noise_read_shmem()
2257 hi = wlapi_bmac_read_shm(pi->sh->physhim, in wlc_phy_noise_read_shmem()
2268 wlc_phy_noise_calc_phy(pi, cmplx_pwr, noise_dbm_ant); in wlc_phy_noise_read_shmem()
2270 for (core = 0; core < pi->pubpi.phy_corenum; core++) { in wlc_phy_noise_read_shmem()
2271 pi->nphy_noise_win[core][pi->nphy_noise_index] = in wlc_phy_noise_read_shmem()
2277 pi->nphy_noise_index = in wlc_phy_noise_read_shmem()
2278 MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ); in wlc_phy_noise_read_shmem()
2286 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_noise_sample_intr() local
2291 if (ISLCNPHY(pi)) { in wlc_phy_noise_sample_intr()
2297 jssi_aux = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_AUX); in wlc_phy_noise_sample_intr()
2300 lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP0); in wlc_phy_noise_sample_intr()
2301 hi = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP1); in wlc_phy_noise_sample_intr()
2304 lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP2); in wlc_phy_noise_sample_intr()
2305 hi = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP3); in wlc_phy_noise_sample_intr()
2310 status_1 = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_0); in wlc_phy_noise_sample_intr()
2315 pi->pubpi.phy_corenum); in wlc_phy_noise_sample_intr()
2316 pwr_offset_dB = (read_phy_reg(pi, 0x434) & 0xFF); in wlc_phy_noise_sample_intr()
2327 } else if (ISNPHY(pi)) { in wlc_phy_noise_sample_intr()
2329 jssi_aux = wlapi_bmac_read_shm(pi->sh->physhim, M_JSSI_AUX); in wlc_phy_noise_sample_intr()
2332 noise_dbm = wlc_phy_noise_read_shmem(pi); in wlc_phy_noise_sample_intr()
2335 wlc_phy_noise_cb(pi, channel, noise_dbm); in wlc_phy_noise_sample_intr()
2342 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_noise_sample_request() local
2344 bool sampling_in_progress = (pi->phynoise_state != 0); in wlc_phy_noise_sample_request()
2349 pi->phynoise_chan_watchdog = ch; in wlc_phy_noise_sample_request()
2350 pi->phynoise_state |= PHY_NOISE_STATE_MON; in wlc_phy_noise_sample_request()
2354 pi->phynoise_state |= PHY_NOISE_STATE_EXTERNAL; in wlc_phy_noise_sample_request()
2364 pi->phynoise_now = pi->sh->now; in wlc_phy_noise_sample_request()
2366 if (pi->phy_fixed_noise) { in wlc_phy_noise_sample_request()
2367 if (ISNPHY(pi)) { in wlc_phy_noise_sample_request()
2368 pi->nphy_noise_win[WL_ANT_IDX_1][pi->nphy_noise_index] = in wlc_phy_noise_sample_request()
2370 pi->nphy_noise_win[WL_ANT_IDX_2][pi->nphy_noise_index] = in wlc_phy_noise_sample_request()
2372 pi->nphy_noise_index = MODINC_POW2(pi->nphy_noise_index, in wlc_phy_noise_sample_request()
2383 if (ISLCNPHY(pi)) { in wlc_phy_noise_sample_request()
2384 if (!pi->phynoise_polling in wlc_phy_noise_sample_request()
2386 wlapi_bmac_write_shm(pi->sh->physhim, M_JSSI_0, 0); in wlc_phy_noise_sample_request()
2387 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP0, 0); in wlc_phy_noise_sample_request()
2388 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP1, 0); in wlc_phy_noise_sample_request()
2389 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP2, 0); in wlc_phy_noise_sample_request()
2390 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP3, 0); in wlc_phy_noise_sample_request()
2392 bcma_set32(pi->d11core, D11REGOFFS(maccommand), in wlc_phy_noise_sample_request()
2395 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_noise_sample_request()
2396 wlc_lcnphy_deaf_mode(pi, (bool) 0); in wlc_phy_noise_sample_request()
2397 noise_dbm = (s8) wlc_lcnphy_rx_signal_power(pi, 20); in wlc_phy_noise_sample_request()
2398 wlc_lcnphy_deaf_mode(pi, (bool) 1); in wlc_phy_noise_sample_request()
2399 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_noise_sample_request()
2402 } else if (ISNPHY(pi)) { in wlc_phy_noise_sample_request()
2403 if (!pi->phynoise_polling in wlc_phy_noise_sample_request()
2406 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP0, 0); in wlc_phy_noise_sample_request()
2407 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP1, 0); in wlc_phy_noise_sample_request()
2408 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP2, 0); in wlc_phy_noise_sample_request()
2409 wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP3, 0); in wlc_phy_noise_sample_request()
2411 bcma_set32(pi->d11core, D11REGOFFS(maccommand), in wlc_phy_noise_sample_request()
2429 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_noise_sample_request()
2430 classif_state = wlc_phy_classifier_nphy(pi, 0, 0); in wlc_phy_noise_sample_request()
2431 wlc_phy_classifier_nphy(pi, 3, 0); in wlc_phy_noise_sample_request()
2432 wlc_phy_rx_iq_est_nphy(pi, est, num_samps, wait_time, in wlc_phy_noise_sample_request()
2434 wlc_phy_classifier_nphy(pi, (0x7 << 0), classif_state); in wlc_phy_noise_sample_request()
2435 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_noise_sample_request()
2437 for (i = 0; i < pi->pubpi.phy_corenum; i++) in wlc_phy_noise_sample_request()
2441 wlc_phy_noise_calc_phy(pi, cmplx_pwr, noise_dbm_ant); in wlc_phy_noise_sample_request()
2443 for (i = 0; i < pi->pubpi.phy_corenum; i++) { in wlc_phy_noise_sample_request()
2444 pi->nphy_noise_win[i][pi->nphy_noise_index] = in wlc_phy_noise_sample_request()
2450 pi->nphy_noise_index = MODINC_POW2(pi->nphy_noise_index, in wlc_phy_noise_sample_request()
2460 wlc_phy_noise_cb(pi, ch, noise_dbm); in wlc_phy_noise_sample_request()
2534 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_rssi_compute() local
2536 if ((pi->sh->corerev >= 11) in wlc_phy_rssi_compute()
2542 if (ISLCNPHY(pi)) { in wlc_phy_rssi_compute()
2544 struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; in wlc_phy_rssi_compute()
2559 if (ISLCNPHY(pi)) { in wlc_phy_rssi_compute()
2564 rssi = wlc_phy_rssi_compute_nphy(pi, rxh); in wlc_phy_rssi_compute()
2583 struct brcms_phy *pi; in wlc_phy_set_deaf() local
2584 pi = (struct brcms_phy *) ppi; in wlc_phy_set_deaf()
2586 if (ISLCNPHY(pi)) in wlc_phy_set_deaf()
2587 wlc_lcnphy_deaf_mode(pi, true); in wlc_phy_set_deaf()
2588 else if (ISNPHY(pi)) in wlc_phy_set_deaf()
2589 wlc_nphy_deaf_mode(pi, true); in wlc_phy_set_deaf()
2594 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_watchdog() local
2596 pi->sh->now++; in wlc_phy_watchdog()
2598 if (!pi->watchdog_override) in wlc_phy_watchdog()
2601 if (!(SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi))) in wlc_phy_watchdog()
2602 wlc_phy_noise_sample_request((struct brcms_phy_pub *) pi, in wlc_phy_watchdog()
2604 CHSPEC_CHANNEL(pi-> in wlc_phy_watchdog()
2607 if (pi->phynoise_state && (pi->sh->now - pi->phynoise_now) > 5) in wlc_phy_watchdog()
2608 pi->phynoise_state = 0; in wlc_phy_watchdog()
2610 if ((!pi->phycal_txpower) || in wlc_phy_watchdog()
2611 ((pi->sh->now - pi->phycal_txpower) >= pi->sh->fast_timer)) { in wlc_phy_watchdog()
2613 if (!SCAN_INPROG_PHY(pi) && wlc_phy_cal_txpower_recalc_sw(pi)) in wlc_phy_watchdog()
2614 pi->phycal_txpower = pi->sh->now; in wlc_phy_watchdog()
2617 if ((SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi) in wlc_phy_watchdog()
2618 || ASSOC_INPROG_PHY(pi))) in wlc_phy_watchdog()
2621 if (ISNPHY(pi) && !pi->disable_percal && !delay_phy_cal) { in wlc_phy_watchdog()
2623 if ((pi->nphy_perical != PHY_PERICAL_DISABLE) && in wlc_phy_watchdog()
2624 (pi->nphy_perical != PHY_PERICAL_MANUAL) && in wlc_phy_watchdog()
2625 ((pi->sh->now - pi->nphy_perical_last) >= in wlc_phy_watchdog()
2626 pi->sh->glacial_timer)) in wlc_phy_watchdog()
2627 wlc_phy_cal_perical((struct brcms_phy_pub *) pi, in wlc_phy_watchdog()
2630 wlc_phy_txpwr_papd_cal_nphy(pi); in wlc_phy_watchdog()
2633 if (ISLCNPHY(pi)) { in wlc_phy_watchdog()
2634 if (pi->phy_forcecal || in wlc_phy_watchdog()
2635 ((pi->sh->now - pi->phy_lastcal) >= in wlc_phy_watchdog()
2636 pi->sh->glacial_timer)) { in wlc_phy_watchdog()
2637 if (!(SCAN_RM_IN_PROGRESS(pi) || ASSOC_INPROG_PHY(pi))) in wlc_phy_watchdog()
2639 pi, in wlc_phy_watchdog()
2642 (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi) in wlc_phy_watchdog()
2643 || ASSOC_INPROG_PHY(pi) in wlc_phy_watchdog()
2644 || pi->carrier_suppr_disable in wlc_phy_watchdog()
2645 || pi->disable_percal)) in wlc_phy_watchdog()
2646 wlc_lcnphy_calib_modes(pi, in wlc_phy_watchdog()
2654 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_BSSinit() local
2659 pi->sh->phy_noise_window[i] = (s8) (rssi & 0xff); in wlc_phy_BSSinit()
2660 if (ISLCNPHY(pi)) { in wlc_phy_BSSinit()
2662 pi->sh->phy_noise_window[i] = in wlc_phy_BSSinit()
2665 pi->sh->phy_noise_index = 0; in wlc_phy_BSSinit()
2669 pi->nphy_noise_win[k][i] = PHY_NOISE_FIXED_VAL_NPHY; in wlc_phy_BSSinit()
2671 pi->nphy_noise_index = 0; in wlc_phy_BSSinit()
2686 void wlc_phy_cal_perical_mphase_reset(struct brcms_phy *pi) in wlc_phy_cal_perical_mphase_reset() argument
2688 wlapi_del_timer(pi->phycal_timer); in wlc_phy_cal_perical_mphase_reset()
2690 pi->cal_type_override = PHY_PERICAL_AUTO; in wlc_phy_cal_perical_mphase_reset()
2691 pi->mphase_cal_phase_id = MPHASE_CAL_STATE_IDLE; in wlc_phy_cal_perical_mphase_reset()
2692 pi->mphase_txcal_cmdidx = 0; in wlc_phy_cal_perical_mphase_reset()
2696 wlc_phy_cal_perical_mphase_schedule(struct brcms_phy *pi, uint delay) in wlc_phy_cal_perical_mphase_schedule() argument
2699 if ((pi->nphy_perical != PHY_PERICAL_MPHASE) && in wlc_phy_cal_perical_mphase_schedule()
2700 (pi->nphy_perical != PHY_PERICAL_MANUAL)) in wlc_phy_cal_perical_mphase_schedule()
2703 wlapi_del_timer(pi->phycal_timer); in wlc_phy_cal_perical_mphase_schedule()
2705 pi->mphase_cal_phase_id = MPHASE_CAL_STATE_INIT; in wlc_phy_cal_perical_mphase_schedule()
2706 wlapi_add_timer(pi->phycal_timer, delay, 0); in wlc_phy_cal_perical_mphase_schedule()
2714 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_cal_perical() local
2716 if (!ISNPHY(pi)) in wlc_phy_cal_perical()
2719 if ((pi->nphy_perical == PHY_PERICAL_DISABLE) || in wlc_phy_cal_perical()
2720 (pi->nphy_perical == PHY_PERICAL_MANUAL)) in wlc_phy_cal_perical()
2728 if (pi->nphy_perical == PHY_PERICAL_MPHASE) { in wlc_phy_cal_perical()
2729 if (PHY_PERICAL_MPHASE_PENDING(pi)) in wlc_phy_cal_perical()
2730 wlc_phy_cal_perical_mphase_reset(pi); in wlc_phy_cal_perical()
2733 pi, in wlc_phy_cal_perical()
2741 if ((pi->nphy_perical == PHY_PERICAL_MPHASE) && in wlc_phy_cal_perical()
2742 PHY_PERICAL_MPHASE_PENDING(pi)) in wlc_phy_cal_perical()
2743 wlc_phy_cal_perical_mphase_reset(pi); in wlc_phy_cal_perical()
2745 pi->first_cal_after_assoc = true; in wlc_phy_cal_perical()
2747 pi->cal_type_override = PHY_PERICAL_FULL; in wlc_phy_cal_perical()
2749 if (pi->phycal_tempdelta) in wlc_phy_cal_perical()
2750 pi->nphy_lastcal_temp = wlc_phy_tempsense_nphy(pi); in wlc_phy_cal_perical()
2752 wlc_phy_cal_perical_nphy_run(pi, PHY_PERICAL_FULL); in wlc_phy_cal_perical()
2756 if (pi->phycal_tempdelta) { in wlc_phy_cal_perical()
2757 nphy_currtemp = wlc_phy_tempsense_nphy(pi); in wlc_phy_cal_perical()
2759 (nphy_currtemp > pi->nphy_lastcal_temp) ? in wlc_phy_cal_perical()
2760 nphy_currtemp - pi->nphy_lastcal_temp : in wlc_phy_cal_perical()
2761 pi->nphy_lastcal_temp - nphy_currtemp; in wlc_phy_cal_perical()
2763 if ((delta_temp < (s16) pi->phycal_tempdelta) && in wlc_phy_cal_perical()
2764 (pi->nphy_txiqlocal_chanspec == in wlc_phy_cal_perical()
2765 pi->radio_chanspec)) in wlc_phy_cal_perical()
2768 pi->nphy_lastcal_temp = nphy_currtemp; in wlc_phy_cal_perical()
2772 if (pi->nphy_perical == PHY_PERICAL_MPHASE) { in wlc_phy_cal_perical()
2773 if (!PHY_PERICAL_MPHASE_PENDING(pi)) in wlc_phy_cal_perical()
2775 pi, in wlc_phy_cal_perical()
2777 } else if (pi->nphy_perical == PHY_PERICAL_SPHASE) in wlc_phy_cal_perical()
2778 wlc_phy_cal_perical_nphy_run(pi, in wlc_phy_cal_perical()
2787 void wlc_phy_cal_perical_mphase_restart(struct brcms_phy *pi) in wlc_phy_cal_perical_mphase_restart() argument
2789 pi->mphase_cal_phase_id = MPHASE_CAL_STATE_INIT; in wlc_phy_cal_perical_mphase_restart()
2790 pi->mphase_txcal_cmdidx = 0; in wlc_phy_cal_perical_mphase_restart()
2807 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_stf_chain_init() local
2809 pi->sh->hw_phytxchain = txchain; in wlc_phy_stf_chain_init()
2810 pi->sh->hw_phyrxchain = rxchain; in wlc_phy_stf_chain_init()
2811 pi->sh->phytxchain = txchain; in wlc_phy_stf_chain_init()
2812 pi->sh->phyrxchain = rxchain; in wlc_phy_stf_chain_init()
2813 pi->pubpi.phy_corenum = (u8)hweight8(pi->sh->phyrxchain); in wlc_phy_stf_chain_init()
2818 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_stf_chain_set() local
2820 pi->sh->phytxchain = txchain; in wlc_phy_stf_chain_set()
2822 if (ISNPHY(pi)) in wlc_phy_stf_chain_set()
2825 pi->pubpi.phy_corenum = (u8)hweight8(pi->sh->phyrxchain); in wlc_phy_stf_chain_set()
2830 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_stf_chain_get() local
2832 *txchain = pi->sh->phytxchain; in wlc_phy_stf_chain_get()
2833 *rxchain = pi->sh->phyrxchain; in wlc_phy_stf_chain_get()
2840 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_stf_chain_active_get() local
2842 active_bitmap = (pi->phy_txcore_heatedup) ? 0x31 : 0x33; in wlc_phy_stf_chain_active_get()
2844 if (!pi->watchdog_override) in wlc_phy_stf_chain_active_get()
2847 if (NREV_GE(pi->pubpi.phy_rev, 6)) { in wlc_phy_stf_chain_active_get()
2848 wlapi_suspend_mac_and_wait(pi->sh->physhim); in wlc_phy_stf_chain_active_get()
2849 nphy_currtemp = wlc_phy_tempsense_nphy(pi); in wlc_phy_stf_chain_active_get()
2850 wlapi_enable_mac(pi->sh->physhim); in wlc_phy_stf_chain_active_get()
2852 if (!pi->phy_txcore_heatedup) { in wlc_phy_stf_chain_active_get()
2853 if (nphy_currtemp >= pi->phy_txcore_disable_temp) { in wlc_phy_stf_chain_active_get()
2855 pi->phy_txcore_heatedup = true; in wlc_phy_stf_chain_active_get()
2858 if (nphy_currtemp <= pi->phy_txcore_enable_temp) { in wlc_phy_stf_chain_active_get()
2860 pi->phy_txcore_heatedup = false; in wlc_phy_stf_chain_active_get()
2870 struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro); in wlc_phy_stf_ssmode_get() local
2880 if (pi->tx_power_target[siso_mcs_id] > in wlc_phy_stf_ssmode_get()
2881 (pi->tx_power_target[cdd_mcs_id] + 12)) in wlc_phy_stf_ssmode_get()
2892 void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode) in wlc_lcnphy_epa_switch() argument
2894 if ((pi->sh->chip == BCMA_CHIP_ID_BCM4313) && in wlc_lcnphy_epa_switch()
2895 (pi->sh->boardflags & BFL_FEM)) { in wlc_lcnphy_epa_switch()
2898 txant = wlapi_bmac_get_txant(pi->sh->physhim); in wlc_lcnphy_epa_switch()
2900 mod_phy_reg(pi, 0x44d, (0x1 << 2), (1) << 2); in wlc_lcnphy_epa_switch()
2902 mod_phy_reg(pi, 0x44c, (0x1 << 2), (1) << 2); in wlc_lcnphy_epa_switch()
2906 bcma_chipco_gpio_control(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2908 bcma_chipco_gpio_out(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2910 bcma_chipco_gpio_outen(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2913 mod_phy_reg(pi, 0x44c, (0x1 << 2), (0) << 2); in wlc_lcnphy_epa_switch()
2915 mod_phy_reg(pi, 0x44d, (0x1 << 2), (0) << 2); in wlc_lcnphy_epa_switch()
2917 bcma_chipco_gpio_out(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2919 bcma_chipco_gpio_outen(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2921 bcma_chipco_gpio_control(&pi->d11core->bus->drv_cc, in wlc_lcnphy_epa_switch()
2933 wlc_phy_get_pwrdet_offsets(struct brcms_phy *pi, s8 *cckoffset, s8 *ofdmoffset) in wlc_phy_get_pwrdet_offsets() argument
2939 s8 wlc_phy_upd_rssi_offset(struct brcms_phy *pi, s8 rssi, u16 chanspec) in wlc_phy_upd_rssi_offset() argument
2947 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); in wlc_phy_txpower_ipa_ison() local
2949 if (ISNPHY(pi)) in wlc_phy_txpower_ipa_ison()
2950 return wlc_phy_n_txpower_ipa_ison(pi); in wlc_phy_txpower_ipa_ison()