On Tue, Jan 07, 2014 at 12:08:02PM +0100, Martin Pieuchot wrote: > On 03/01/14(Fri) 14:24, Fabian Raetz wrote: > > Hi tech@, > > > > here is an updated patch. > > > > it seems like Intel Centrino Wireless-N 2030 and > > Intel Centrino Wireless-N 2230 have the same pciids... > > > > this makes patch apply again with newest pcidevs changes. > > Please also make sure to use tab and not space when appropriate ;) You > can check style(9) if in doubt ! > ups :) attached is a diff - which follows style(9) (hopefully) and - fixes a firmware error by handling IWN_FW_TLV_ENH_SENS and IWN_FW_TLV_PHY_CALIB in iwn_read_firmware_tlv().
@mike, only style changes since the last patch i send you. Regards, Fabian Index: if_iwn.c =================================================================== RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v retrieving revision 1.127 diff -u -p -r1.127 if_iwn.c --- if_iwn.c 6 Dec 2013 21:03:04 -0000 1.127 +++ if_iwn.c 7 Jan 2014 20:51:38 -0000 @@ -94,6 +94,8 @@ static const struct pci_matchid iwn_devi { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_130_2 }, { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_6235_1 }, { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_6235_2 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_2x30_1 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_2x30_2 }, }; int iwn_match(struct device *, void *, void *); @@ -244,6 +246,7 @@ int iwn5000_send_calibration(struct iwn int iwn5000_send_wimax_coex(struct iwn_softc *); int iwn5000_crystal_calib(struct iwn_softc *); int iwn5000_temp_offset_calib(struct iwn_softc *); +int iwn5000_temp_offset_calibv2(struct iwn_softc *); int iwn4965_post_alive(struct iwn_softc *); int iwn5000_post_alive(struct iwn_softc *); int iwn4965_load_bootcode(struct iwn_softc *, const uint8_t *, @@ -605,6 +608,8 @@ iwn5000_attach(struct iwn_softc *sc, pci sc->fw_data_maxsz = IWN5000_FW_DATA_MAXSZ; sc->fwsz = IWN5000_FWSZ; sc->sched_txfact_addr = IWN5000_SCHED_TXFACT; + sc->reset_noise_gain = IWN5000_PHY_CALIB_RESET_NOISE_GAIN; + sc->noise_gain = IWN5000_PHY_CALIB_NOISE_GAIN; switch (sc->hw_type) { case IWN_HW_REV_TYPE_5100: @@ -651,6 +656,11 @@ iwn5000_attach(struct iwn_softc *sc, pci } else sc->fwname = "iwn-6005"; break; + case IWN_HW_REV_TYPE_2030: + sc->limits = &iwn2030_sensitivity_limits; + sc->fwname = "iwn-2030"; + sc->sc_flags |= IWN_FLAG_ADV_BT_COEX; + break; default: printf(": adapter type %d not supported\n", sc->hw_type); return ENOTSUP; @@ -1529,6 +1539,14 @@ iwn5000_read_eeprom(struct iwn_softc *sc hdr.version, hdr.pa_type, letoh16(hdr.volt))); sc->calib_ver = hdr.version; + if (sc->hw_type == IWN_HW_REV_TYPE_2030) { + sc->eeprom_voltage = letoh16(hdr.volt); + iwn_read_prom_data(sc, base + IWN5000_EEPROM_TEMP, &val, 2); + sc->eeprom_temp_high = letoh16(val); + iwn_read_prom_data(sc, base + IWN5000_EEPROM_VOLT, &val, 2); + sc->eeprom_temp = letoh16(val); + } + if (sc->hw_type == IWN_HW_REV_TYPE_5150) { /* Compute temperature offset. */ iwn_read_prom_data(sc, base + IWN5000_EEPROM_TEMP, &val, 2); @@ -2095,7 +2113,8 @@ iwn5000_rx_calib_results(struct iwn_soft switch (calib->code) { case IWN5000_PHY_CALIB_DC: - if (sc->hw_type == IWN_HW_REV_TYPE_5150) + if (sc->hw_type == IWN_HW_REV_TYPE_5150 || + sc->hw_type == IWN_HW_REV_TYPE_2030) idx = 0; break; case IWN5000_PHY_CALIB_LO: @@ -3822,7 +3841,7 @@ iwn5000_init_gains(struct iwn_softc *sc) struct iwn_phy_calib cmd; memset(&cmd, 0, sizeof cmd); - cmd.code = IWN5000_PHY_CALIB_RESET_NOISE_GAIN; + cmd.code = sc->reset_noise_gain; cmd.ngroups = 1; cmd.isvalid = 1; DPRINTF(("setting initial differential gains\n")); @@ -3872,7 +3891,7 @@ iwn5000_set_gains(struct iwn_softc *sc) div = (sc->hw_type == IWN_HW_REV_TYPE_6050) ? 20 : 30; memset(&cmd, 0, sizeof cmd); - cmd.code = IWN5000_PHY_CALIB_NOISE_GAIN; + cmd.code = sc->noise_gain; cmd.ngroups = 1; cmd.isvalid = 1; /* Get first available RX antenna as referential. */ @@ -4161,28 +4180,51 @@ iwn_send_advanced_btcoex(struct iwn_soft 0xc0004000, 0x00004000, 0xf0005000, 0xf0005000, }; struct iwn6000_btcoex_config btconfig; + struct iwn2000_btcoex_config btconfig2k; struct iwn_btcoex_priotable btprio; struct iwn_btcoex_prot btprot; int error, i; memset(&btconfig, 0, sizeof btconfig); - btconfig.flags = IWN_BT_FLAG_COEX6000_CHAN_INHIBITION | - (IWN_BT_FLAG_COEX6000_MODE_3W << IWN_BT_FLAG_COEX6000_MODE_SHIFT) | - IWN_BT_FLAG_SYNC_2_BT_DISABLE; - btconfig.max_kill = 5; - btconfig.bt3_t7_timer = 1; - btconfig.kill_ack = htole32(0xffff0000); - btconfig.kill_cts = htole32(0xffff0000); - btconfig.sample_time = 2; - btconfig.bt3_t2_timer = 0xc; - for (i = 0; i < 12; i++) - btconfig.lookup_table[i] = htole32(btcoex_3wire[i]); - btconfig.valid = htole16(0xff); - btconfig.prio_boost = 0xf0; - DPRINTF(("configuring advanced bluetooth coexistence\n")); - error = iwn_cmd(sc, IWN_CMD_BT_COEX, &btconfig, sizeof(btconfig), 1); - if (error != 0) - return (error); + memset(&btconfig2k, 0, sizeof btconfig2k); + + if (sc->hw_type == IWN_HW_REV_TYPE_2030) { + btconfig2k.flags = IWN_BT_FLAG_COEX6000_CHAN_INHIBITION | + (IWN_BT_FLAG_COEX6000_MODE_3W << IWN_BT_FLAG_COEX6000_MODE_SHIFT) | + IWN_BT_FLAG_SYNC_2_BT_DISABLE; + btconfig2k.max_kill = 5; + btconfig2k.bt3_t7_timer = 1; + btconfig2k.kill_ack = htole32(0xffff0000); + btconfig2k.kill_cts = htole32(0xffff0000); + btconfig2k.sample_time = 2; + btconfig2k.bt3_t2_timer = 0xc; + for (i = 0; i < 12; i++) + btconfig2k.lookup_table[i] = htole32(btcoex_3wire[i]); + btconfig2k.valid = htole16(0xff); + btconfig2k.prio_boost = htole32(0xf0); + DPRINTF(("configuring advanced bluetooth coexistence\n")); + error = iwn_cmd(sc, IWN_CMD_BT_COEX, &btconfig2k, sizeof(btconfig2k), 1); + if (error != 0) + return (error); + } else { + btconfig.flags = IWN_BT_FLAG_COEX6000_CHAN_INHIBITION | + (IWN_BT_FLAG_COEX6000_MODE_3W << IWN_BT_FLAG_COEX6000_MODE_SHIFT) | + IWN_BT_FLAG_SYNC_2_BT_DISABLE; + btconfig.max_kill = 5; + btconfig.bt3_t7_timer = 1; + btconfig.kill_ack = htole32(0xffff0000); + btconfig.kill_cts = htole32(0xffff0000); + btconfig.sample_time = 2; + btconfig.bt3_t2_timer = 0xc; + for (i = 0; i < 12; i++) + btconfig.lookup_table[i] = htole32(btcoex_3wire[i]); + btconfig.valid = htole16(0xff); + btconfig.prio_boost = 0xf0; + DPRINTF(("configuring advanced bluetooth coexistence\n")); + error = iwn_cmd(sc, IWN_CMD_BT_COEX, &btconfig, sizeof(btconfig), 1); + if (error != 0) + return (error); + } memset(&btprio, 0, sizeof btprio); btprio.calib_init1 = 0x6; @@ -4233,14 +4275,21 @@ iwn_config(struct iwn_softc *sc) uint16_t rxchain; int error; + /* Set radio temperature sensor offset. */ if (sc->hw_type == IWN_HW_REV_TYPE_6005) { - /* Set radio temperature sensor offset. */ error = iwn5000_temp_offset_calib(sc); if (error != 0) { printf("%s: could not set temperature offset\n", sc->sc_dev.dv_xname); return error; } + } else if (sc->hw_type == IWN_HW_REV_TYPE_2030) { + error = iwn5000_temp_offset_calibv2(sc); + if (error != 0) { + printf("%s: could not set temperature offset v2\n", + sc->sc_dev.dv_xname); + return error; + } } if (sc->hw_type == IWN_HW_REV_TYPE_6050 || @@ -5005,6 +5054,33 @@ iwn5000_temp_offset_calib(struct iwn_sof return iwn_cmd(sc, IWN_CMD_PHY_CALIB, &cmd, sizeof cmd, 0); } +int +iwn5000_temp_offset_calibv2(struct iwn_softc *sc) +{ + struct iwn5000_phy_calib_temp_offsetv2 cmd; + + memset(&cmd, 0, sizeof cmd); + cmd.code = IWN5000_PHY_CALIB_TEMP_OFFSET; + cmd.ngroups = 1; + cmd.isvalid = 1; + if (sc->eeprom_temp != 0) { + cmd.offset_low = htole16(sc->eeprom_temp); + cmd.offset_high = htole16(sc->eeprom_temp_high); + } + else { + cmd.offset_low = htole16(IWN_DEFAULT_TEMP_OFFSET); + cmd.offset_high = htole16(IWN_DEFAULT_TEMP_OFFSET); + } + cmd.burnt_voltage_ref = htole16(sc->eeprom_voltage); + + DPRINTF(("setting radio sensor low offset to %d, high offset to %d, voltage to %d\n", + letoh16(cmd.offset_low), + letoh16(cmd.offset_high), + letoh16(cmd.burnt_voltage_ref))); + + return iwn_cmd(sc, IWN_CMD_PHY_CALIB, &cmd, sizeof cmd, 0); +} + /* * This function is called after the runtime firmware notifies us of its * readiness (called in a process context). @@ -5394,7 +5470,7 @@ iwn_read_firmware_tlv(struct iwn_softc * const struct iwn_fw_tlv *tlv; const uint8_t *ptr, *end; uint64_t altmask; - uint32_t len; + uint32_t len, tmp; if (fw->size < sizeof (*hdr)) { printf("%s: firmware too short: %zu bytes\n", @@ -5458,6 +5534,17 @@ iwn_read_firmware_tlv(struct iwn_softc * fw->boot.text = ptr; fw->boot.textsz = len; break; + case IWN_FW_TLV_ENH_SENS: + if (!len) + sc->sc_flags |= IWN_FLAG_ENH_SENS; + break; + case IWN_FW_TLV_PHY_CALIB: + tmp = letoh32(*ptr); + if (tmp < 253) { + sc->reset_noise_gain = tmp; + sc->noise_gain = tmp + 1; + } + break; default: DPRINTF(("TLV type %d not handled\n", letoh16(tlv->type))); @@ -5681,6 +5768,9 @@ iwn5000_nic_config(struct iwn_softc *sc) } if (sc->hw_type == IWN_HW_REV_TYPE_6005) IWN_SETBITS(sc, IWN_GP_DRIVER, IWN_GP_DRIVER_6050_1X2); + + if (sc->hw_type == IWN_HW_REV_TYPE_2030) + IWN_SETBITS(sc, IWN_GP_DRIVER, IWN_GP_DRIVER_REG_BIT_RADIO_IQ_INVERT); return 0; } Index: if_iwnreg.h =================================================================== RCS file: /cvs/src/sys/dev/pci/if_iwnreg.h,v retrieving revision 1.45 diff -u -p -r1.45 if_iwnreg.h --- if_iwnreg.h 26 Nov 2013 20:33:17 -0000 1.45 +++ if_iwnreg.h 7 Jan 2014 20:51:39 -0000 @@ -205,6 +205,7 @@ #define IWN_HW_REV_TYPE_6000 7 #define IWN_HW_REV_TYPE_6050 8 #define IWN_HW_REV_TYPE_6005 11 +#define IWN_HW_REV_TYPE_2030 12 /* Possible flags for register IWN_GIO_CHICKEN. */ #define IWN_GIO_CHICKEN_L1A_NO_L0S_RX (1 << 23) @@ -219,6 +220,7 @@ #define IWN_GP_DRIVER_RADIO_2X2_IPA (2 << 0) #define IWN_GP_DRIVER_CALIB_VER6 (1 << 2) #define IWN_GP_DRIVER_6050_1X2 (1 << 3) +#define IWN_GP_DRIVER_REG_BIT_RADIO_IQ_INVERT (0x00000080) /* Possible flags for register IWN_UCODE_GP1_CLR. */ #define IWN_UCODE_GP1_RFKILL (1 << 1) @@ -878,6 +880,28 @@ struct iwn6000_btcoex_config { uint16_t rx_prio_boost; } __packed; +/* Structure for enhanced command IWN_CMD_BLUETOOTH for 2000 Series. */ +struct iwn2000_btcoex_config { + uint8_t flags; /* Cf Flags in iwn6000_btcoex_config */ + uint8_t lead_time; + uint8_t max_kill; + uint8_t bt3_t7_timer; + uint32_t kill_ack; + uint32_t kill_cts; + uint8_t sample_time; + uint8_t bt3_t2_timer; + uint16_t bt4_reaction; + uint32_t lookup_table[12]; + uint16_t bt4_decision; + uint16_t valid; + + uint32_t prio_boost; /* size change prior to iwn6000_btcoex_config */ + uint8_t reserved; /* added prior to iwn6000_btcoex_config */ + + uint8_t tx_prio_boost; + uint16_t rx_prio_boost; +} __packed; + /* Structure for command IWN_CMD_BT_COEX_PRIOTABLE */ struct iwn_btcoex_priotable { uint8_t calib_init1; @@ -998,6 +1022,17 @@ struct iwn5000_phy_calib_temp_offset { uint16_t reserved; } __packed; +struct iwn5000_phy_calib_temp_offsetv2 { + uint8_t code; + uint8_t group; + uint8_t ngroups; + uint8_t isvalid; + int16_t offset_high; + int16_t offset_low; + int16_t burnt_voltage_ref; + int16_t reserved; +} __packed; + struct iwn_phy_calib_gain { uint8_t code; uint8_t group; @@ -1366,6 +1401,8 @@ struct iwn_fw_tlv { #define IWN_FW_TLV_INIT_DATA 4 #define IWN_FW_TLV_BOOT_TEXT 5 #define IWN_FW_TLV_PBREQ_MAXLEN 6 +#define IWN_FW_TLV_ENH_SENS 14 +#define IWN_FW_TLV_PHY_CALIB 15 uint16_t alt; uint32_t len; @@ -1717,6 +1754,19 @@ static const struct iwn_sensitivity_limi 97, 97, 100 +}; + +/* Get value from linux kernel 3.2.+ in Drivers/net/wireless/iwlwifi/iwl-2000.c */ +static const struct iwn_sensitivity_limits iwn2030_sensitivity_limits = { + 105, 110, + 128, 232, + 80, 145, + 128, 232, + 125, 175, + 160, 310, + 97, + 97, + 110 }; /* Map TID to TX scheduler's FIFO. */ Index: if_iwnvar.h =================================================================== RCS file: /cvs/src/sys/dev/pci/if_iwnvar.h,v retrieving revision 1.26 diff -u -p -r1.26 if_iwnvar.h --- if_iwnvar.h 30 Nov 2013 19:41:21 -0000 1.26 +++ if_iwnvar.h 7 Jan 2014 20:51:39 -0000 @@ -218,6 +218,8 @@ struct iwn_softc { uint32_t fw_data_maxsz; uint32_t fwsz; bus_size_t sched_txfact_addr; + uint32_t reset_noise_gain; + uint32_t noise_gain; /* TX scheduler rings. */ struct iwn_dma_info sched_dma; @@ -274,6 +276,7 @@ struct iwn_softc { char eeprom_domain[4]; uint32_t eeprom_crystal; int16_t eeprom_temp; + int16_t eeprom_temp_high; int16_t eeprom_voltage; int8_t maxpwr2GHz; int8_t maxpwr5GHz; Index: pcidevs =================================================================== RCS file: /cvs/src/sys/dev/pci/pcidevs,v retrieving revision 1.1707 diff -u -p -r1.1707 pcidevs --- pcidevs 3 Jan 2014 10:31:09 -0000 1.1707 +++ pcidevs 7 Jan 2014 20:51:41 -0000 @@ -2812,8 +2812,8 @@ product INTEL WL_6235_1 0x088e Centrino product INTEL WL_6235_2 0x088f Centrino Advanced-N 6235 product INTEL WL_6150_1 0x0885 Centrino Wireless-N 6150 product INTEL WL_6150_2 0x0886 Centrino Wireless-N 6150 -product INTEL WL_2030_1 0x0887 Centrino Wireless-N 2030 -product INTEL WL_2030_2 0x0888 Centrino Wireless-N 2030 +product INTEL WL_2x30_1 0x0887 Centrino Wireless-N 2230 +product INTEL WL_2x30_2 0x0888 Centrino Wireless-N 2230 product INTEL WL_2000_1 0x0890 Centrino Wireless-N 2000 product INTEL WL_2000_2 0x0891 Centrino Wireless-N 2000 product INTEL WL_135_1 0x0892 Centrino Wireless-N 135