iwm: Add a device family definition for 9000 chips.

Convert existing device family checks to avoid assuming that the device
family is always one of IWM_DEVICE_FAMILY_7000 or _8000.

Submitted by:	lwhsu, Guo Wen Jun <blockk2000@gmail.com>
MFC after:	2 weeks
This commit is contained in:
Mark Johnston 2019-11-07 23:35:01 +00:00
parent 381471bc83
commit 3bf2d5dd64
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=354501
3 changed files with 18 additions and 16 deletions

View File

@ -1651,7 +1651,7 @@ iwm_trans_pcie_fw_alive(struct iwm_softc *sc, uint32_t scd_base_addr)
iwm_nic_unlock(sc);
/* Enable L1-Active */
if (sc->cfg->device_family != IWM_DEVICE_FAMILY_8000) {
if (sc->cfg->device_family < IWM_DEVICE_FAMILY_8000) {
iwm_clear_bits_prph(sc, IWM_APMG_PCIDEV_STT_REG,
IWM_APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
}
@ -2069,7 +2069,7 @@ static int
iwm_get_sku(const struct iwm_softc *sc, const uint16_t *nvm_sw,
const uint16_t *phy_sku)
{
if (sc->cfg->device_family != IWM_DEVICE_FAMILY_8000)
if (sc->cfg->device_family < IWM_DEVICE_FAMILY_8000)
return le16_to_cpup(nvm_sw + IWM_SKU);
return le32_to_cpup((const uint32_t *)(phy_sku + IWM_SKU_8000));
@ -2078,7 +2078,7 @@ iwm_get_sku(const struct iwm_softc *sc, const uint16_t *nvm_sw,
static int
iwm_get_nvm_version(const struct iwm_softc *sc, const uint16_t *nvm_sw)
{
if (sc->cfg->device_family != IWM_DEVICE_FAMILY_8000)
if (sc->cfg->device_family < IWM_DEVICE_FAMILY_8000)
return le16_to_cpup(nvm_sw + IWM_NVM_VERSION);
else
return le32_to_cpup((const uint32_t *)(nvm_sw +
@ -2089,7 +2089,7 @@ static int
iwm_get_radio_cfg(const struct iwm_softc *sc, const uint16_t *nvm_sw,
const uint16_t *phy_sku)
{
if (sc->cfg->device_family != IWM_DEVICE_FAMILY_8000)
if (sc->cfg->device_family < IWM_DEVICE_FAMILY_8000)
return le16_to_cpup(nvm_sw + IWM_RADIO_CFG);
return le32_to_cpup((const uint32_t *)(phy_sku + IWM_RADIO_CFG_8000));
@ -2100,7 +2100,7 @@ iwm_get_n_hw_addrs(const struct iwm_softc *sc, const uint16_t *nvm_sw)
{
int n_hw_addr;
if (sc->cfg->device_family != IWM_DEVICE_FAMILY_8000)
if (sc->cfg->device_family < IWM_DEVICE_FAMILY_8000)
return le16_to_cpup(nvm_sw + IWM_N_HW_ADDRS);
n_hw_addr = le32_to_cpup((const uint32_t *)(nvm_sw + IWM_N_HW_ADDRS_8000));
@ -2112,7 +2112,7 @@ static void
iwm_set_radio_cfg(const struct iwm_softc *sc, struct iwm_nvm_data *data,
uint32_t radio_cfg)
{
if (sc->cfg->device_family != IWM_DEVICE_FAMILY_8000) {
if (sc->cfg->device_family < IWM_DEVICE_FAMILY_8000) {
data->radio_cfg_type = IWM_NVM_RF_CFG_TYPE_MSK(radio_cfg);
data->radio_cfg_step = IWM_NVM_RF_CFG_STEP_MSK(radio_cfg);
data->radio_cfg_dash = IWM_NVM_RF_CFG_DASH_MSK(radio_cfg);
@ -2138,7 +2138,7 @@ iwm_set_hw_address(struct iwm_softc *sc, struct iwm_nvm_data *data,
iwm_set_hw_address_from_csr(sc, data);
} else
#endif
if (sc->cfg->device_family != IWM_DEVICE_FAMILY_8000) {
if (sc->cfg->device_family < IWM_DEVICE_FAMILY_8000) {
const uint8_t *hw_addr = (const uint8_t *)(nvm_hw + IWM_HW_ADDR);
/* The byte order is little endian 16 bit, meaning 214365 */
@ -2170,7 +2170,7 @@ iwm_parse_nvm_data(struct iwm_softc *sc,
uint32_t sku, radio_cfg;
uint16_t lar_config;
if (sc->cfg->device_family != IWM_DEVICE_FAMILY_8000) {
if (sc->cfg->device_family < IWM_DEVICE_FAMILY_8000) {
data = malloc(sizeof(*data) +
IWM_NUM_CHANNELS * sizeof(uint16_t),
M_DEVBUF, M_NOWAIT | M_ZERO);
@ -2194,7 +2194,8 @@ iwm_parse_nvm_data(struct iwm_softc *sc,
data->n_hw_addrs = iwm_get_n_hw_addrs(sc, nvm_sw);
if (sc->cfg->device_family == IWM_DEVICE_FAMILY_8000) {
if (sc->cfg->device_family >= IWM_DEVICE_FAMILY_8000) {
/* TODO: use IWL_NVM_EXT */
uint16_t lar_offset = data->nvm_version < 0xE39 ?
IWM_NVM_LAR_OFFSET_8000_OLD :
IWM_NVM_LAR_OFFSET_8000;
@ -2242,7 +2243,7 @@ iwm_parse_nvm_sections(struct iwm_softc *sc, struct iwm_nvm_section *sections)
"Can't parse empty OTP/NVM sections\n");
return NULL;
}
} else if (sc->cfg->device_family == IWM_DEVICE_FAMILY_8000) {
} else if (sc->cfg->device_family >= IWM_DEVICE_FAMILY_8000) {
/* SW and REGULATORY sections are mandatory */
if (!sections[IWM_NVM_SECTION_TYPE_SW].data ||
!sections[IWM_NVM_SECTION_TYPE_REGULATORY].data) {
@ -2672,7 +2673,7 @@ iwm_start_fw(struct iwm_softc *sc, const struct iwm_fw_img *fw)
IWM_WRITE(sc, IWM_CSR_UCODE_DRV_GP1_CLR, IWM_CSR_UCODE_SW_BIT_RFKILL);
/* Load the given image to the HW */
if (sc->cfg->device_family == IWM_DEVICE_FAMILY_8000)
if (sc->cfg->device_family >= IWM_DEVICE_FAMILY_8000)
ret = iwm_pcie_load_given_ucode_8000(sc, fw);
else
ret = iwm_pcie_load_given_ucode(sc, fw);
@ -2823,7 +2824,7 @@ iwm_mvm_load_ucode_wait_alive(struct iwm_softc *sc,
IWM_MVM_UCODE_ALIVE_TIMEOUT);
IWM_LOCK(sc);
if (error) {
if (sc->cfg->device_family == IWM_DEVICE_FAMILY_8000) {
if (sc->cfg->device_family >= IWM_DEVICE_FAMILY_8000) {
uint32_t a = 0x5a5a5a5a, b = 0x5a5a5a5a;
if (iwm_nic_lock(sc)) {
a = iwm_read_prph(sc, IWM_SB_CPU_1_STATUS);
@ -4458,7 +4459,7 @@ iwm_mvm_is_lar_supported(struct iwm_softc *sc)
* Enable LAR only if it is supported by the FW (TLV) &&
* enabled in the NVM
*/
if (sc->cfg->device_family == IWM_DEVICE_FAMILY_8000)
if (sc->cfg->device_family >= IWM_DEVICE_FAMILY_8000)
return nvm_lar && tlv_lar;
else
return tlv_lar;
@ -5802,7 +5803,7 @@ iwm_attach(device_t dev)
* "dash" value). To keep hw_rev backwards compatible - we'll store it
* in the old format.
*/
if (sc->cfg->device_family == IWM_DEVICE_FAMILY_8000) {
if (sc->cfg->device_family >= IWM_DEVICE_FAMILY_8000) {
int ret;
uint32_t hw_step;

View File

@ -78,6 +78,7 @@ enum iwm_device_family {
IWM_DEVICE_FAMILY_UNDEFINED,
IWM_DEVICE_FAMILY_7000,
IWM_DEVICE_FAMILY_8000,
IWM_DEVICE_FAMILY_9000,
};
#define IWM_DEFAULT_MAX_TX_POWER 22

View File

@ -282,7 +282,7 @@ iwm_nic_lock(struct iwm_softc *sc)
IWM_SETBITS(sc, IWM_CSR_GP_CNTRL,
IWM_CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
if (sc->cfg->device_family == IWM_DEVICE_FAMILY_8000)
if (sc->cfg->device_family >= IWM_DEVICE_FAMILY_8000)
DELAY(2);
if (iwm_poll_bit(sc, IWM_CSR_GP_CNTRL,
@ -475,7 +475,7 @@ iwm_apm_init(struct iwm_softc *sc)
IWM_DPRINTF(sc, IWM_DEBUG_RESET, "iwm apm start\n");
/* Disable L0S exit timer (platform NMI Work/Around) */
if (sc->cfg->device_family != IWM_DEVICE_FAMILY_8000) {
if (sc->cfg->device_family < IWM_DEVICE_FAMILY_8000) {
IWM_SETBITS(sc, IWM_CSR_GIO_CHICKEN_BITS,
IWM_CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
}