Lines Matching +full:eeprom +full:- +full:data

1 // SPDX-License-Identifier: ISC
10 #include "eeprom.h"
17 void *src = dev->mt76.eeprom.data + MT_EE_MAC_ADDR; in mt76x2_eeprom_get_macaddr()
19 memcpy(dev->mphy.macaddr, src, ETH_ALEN); in mt76x2_eeprom_get_macaddr()
80 struct device_node *np = dev->mt76.dev->of_node; in mt76x2_apply_cal_free_data()
81 u8 *eeprom = dev->mt76.eeprom.data; in mt76x2_apply_cal_free_data() local
83 eeprom[MT_EE_TX_POWER_0_START_5G], in mt76x2_apply_cal_free_data()
84 eeprom[MT_EE_TX_POWER_0_START_5G + 1], in mt76x2_apply_cal_free_data()
85 eeprom[MT_EE_TX_POWER_1_START_5G], in mt76x2_apply_cal_free_data()
86 eeprom[MT_EE_TX_POWER_1_START_5G + 1] in mt76x2_apply_cal_free_data()
91 if (!np || !of_property_read_bool(np, "mediatek,eeprom-merge-otp")) in mt76x2_apply_cal_free_data()
100 eeprom[offset] = efuse[offset]; in mt76x2_apply_cal_free_data()
105 memcpy(eeprom + MT_EE_TX_POWER_0_START_5G, prev_grp0, 2); in mt76x2_apply_cal_free_data()
108 memcpy(eeprom + MT_EE_TX_POWER_1_START_5G, prev_grp0 + 2, 2); in mt76x2_apply_cal_free_data()
112 eeprom[MT_EE_BT_RCAL_RESULT] = val & 0xff; in mt76x2_apply_cal_free_data()
116 eeprom[MT_EE_BT_VCDL_CALIBRATION + 1] = val >> 8; in mt76x2_apply_cal_free_data()
120 eeprom[MT_EE_BT_PMUCFG] = val & 0xff; in mt76x2_apply_cal_free_data()
125 u16 val = get_unaligned_le16(dev->mt76.eeprom.data); in mt76x2_check_eeprom()
128 val = get_unaligned_le16(dev->mt76.eeprom.data + MT_EE_PCI_ID); in mt76x2_check_eeprom()
135 dev_err(dev->mt76.dev, "EEPROM data check failed: %04x\n", val); in mt76x2_check_eeprom()
136 return -EINVAL; in mt76x2_check_eeprom()
147 ret = mt76_eeprom_init(&dev->mt76, MT7662_EEPROM_SIZE); in mt76x2_eeprom_load()
155 dev->mt76.otp.data = devm_kzalloc(dev->mt76.dev, MT7662_EEPROM_SIZE, in mt76x2_eeprom_load()
157 dev->mt76.otp.size = MT7662_EEPROM_SIZE; in mt76x2_eeprom_load()
158 if (!dev->mt76.otp.data) in mt76x2_eeprom_load()
159 return -ENOMEM; in mt76x2_eeprom_load()
161 efuse = dev->mt76.otp.data; in mt76x2_eeprom_load()
170 /* FIXME: check if efuse data is complete */ in mt76x2_eeprom_load()
172 memcpy(dev->mt76.eeprom.data, efuse, MT7662_EEPROM_SIZE); in mt76x2_eeprom_load()
177 return -ENOENT; in mt76x2_eeprom_load()
185 s8 *dest = dev->cal.rx.high_gain; in mt76x2_set_rx_gain_group()
200 s8 *dest = dev->cal.rx.rssi_offset; in mt76x2_set_rssi_offset()
256 struct ieee80211_channel *chan = dev->mphy.chandef.chan; in mt76x2_read_rx_gain()
257 int channel = chan->hw_value; in mt76x2_read_rx_gain()
262 if (chan->band == NL80211_BAND_2GHZ) in mt76x2_read_rx_gain()
269 mt76x02_get_rx_gain(dev, chan->band, &val, &lna_2g, lna_5g); in mt76x2_read_rx_gain()
273 dev->cal.rx.mcu_gain = (lna_2g & 0xff); in mt76x2_read_rx_gain()
274 dev->cal.rx.mcu_gain |= (lna_5g[0] & 0xff) << 8; in mt76x2_read_rx_gain()
275 dev->cal.rx.mcu_gain |= (lna_5g[1] & 0xff) << 16; in mt76x2_read_rx_gain()
276 dev->cal.rx.mcu_gain |= (lna_5g[2] & 0xff) << 24; in mt76x2_read_rx_gain()
279 dev->cal.rx.lna_gain = mt76x02_sign_extend(lna, 8); in mt76x2_read_rx_gain()
289 is_5ghz = chan->band == NL80211_BAND_5GHZ; in mt76x2_get_rate_power()
294 t->cck[0] = t->cck[1] = mt76x02_rate_power_val(val); in mt76x2_get_rate_power()
295 t->cck[2] = t->cck[3] = mt76x02_rate_power_val(val >> 8); in mt76x2_get_rate_power()
301 t->ofdm[0] = t->ofdm[1] = mt76x02_rate_power_val(val); in mt76x2_get_rate_power()
302 t->ofdm[2] = t->ofdm[3] = mt76x02_rate_power_val(val >> 8); in mt76x2_get_rate_power()
308 t->ofdm[4] = t->ofdm[5] = mt76x02_rate_power_val(val); in mt76x2_get_rate_power()
309 t->ofdm[6] = t->ofdm[7] = mt76x02_rate_power_val(val >> 8); in mt76x2_get_rate_power()
312 t->ht[0] = t->ht[1] = mt76x02_rate_power_val(val); in mt76x2_get_rate_power()
313 t->ht[2] = t->ht[3] = mt76x02_rate_power_val(val >> 8); in mt76x2_get_rate_power()
316 t->ht[4] = t->ht[5] = mt76x02_rate_power_val(val); in mt76x2_get_rate_power()
317 t->ht[6] = t->ht[7] = mt76x02_rate_power_val(val >> 8); in mt76x2_get_rate_power()
320 t->ht[8] = t->ht[9] = mt76x02_rate_power_val(val); in mt76x2_get_rate_power()
321 t->ht[10] = t->ht[11] = mt76x02_rate_power_val(val >> 8); in mt76x2_get_rate_power()
324 t->ht[12] = t->ht[13] = mt76x02_rate_power_val(val); in mt76x2_get_rate_power()
325 t->ht[14] = t->ht[15] = mt76x02_rate_power_val(val >> 8); in mt76x2_get_rate_power()
330 t->vht[0] = t->vht[1] = mt76x02_rate_power_val(val >> 8); in mt76x2_get_rate_power()
340 int channel = chan->hw_value; in mt76x2_get_power_info_2g()
342 u8 data[6]; in mt76x2_get_power_info_2g() local
352 mt76x02_eeprom_copy(dev, offset, data, sizeof(data)); in mt76x2_get_power_info_2g()
354 t->chain[chain].tssi_slope = data[0]; in mt76x2_get_power_info_2g()
355 t->chain[chain].tssi_offset = data[1]; in mt76x2_get_power_info_2g()
356 t->chain[chain].target_power = data[2]; in mt76x2_get_power_info_2g()
357 t->chain[chain].delta = in mt76x2_get_power_info_2g()
358 mt76x02_sign_extend_optional(data[delta_idx], 7); in mt76x2_get_power_info_2g()
361 t->target_power = val >> 8; in mt76x2_get_power_info_2g()
370 int channel = chan->hw_value; in mt76x2_get_power_info_5g()
374 u8 data[5]; in mt76x2_get_power_info_5g() local
404 mt76x02_eeprom_copy(dev, offset, data, sizeof(data)); in mt76x2_get_power_info_5g()
406 t->chain[chain].tssi_slope = data[0]; in mt76x2_get_power_info_5g()
407 t->chain[chain].tssi_offset = data[1]; in mt76x2_get_power_info_5g()
408 t->chain[chain].target_power = data[2]; in mt76x2_get_power_info_5g()
409 t->chain[chain].delta = in mt76x2_get_power_info_5g()
410 mt76x02_sign_extend_optional(data[delta_idx], 7); in mt76x2_get_power_info_5g()
413 t->target_power = val & 0xff; in mt76x2_get_power_info_5g()
427 if (chan->band == NL80211_BAND_5GHZ) { in mt76x2_get_power_info()
441 !mt76x02_field_valid(t->target_power)) in mt76x2_get_power_info()
442 t->target_power = t->chain[0].target_power; in mt76x2_get_power_info()
444 t->delta_bw40 = mt76x02_rate_power_val(bw40); in mt76x2_get_power_info()
445 t->delta_bw80 = mt76x02_rate_power_val(bw80); in mt76x2_get_power_info()
451 enum nl80211_band band = dev->mphy.chandef.chan->band; in mt76x2_get_temp_comp()
458 return -EINVAL; in mt76x2_get_temp_comp()
461 return -EINVAL; in mt76x2_get_temp_comp()
464 t->temp_25_ref = val & 0x7f; in mt76x2_get_temp_comp()
474 t->high_slope = slope & 0xff; in mt76x2_get_temp_comp()
475 t->low_slope = slope >> 8; in mt76x2_get_temp_comp()
476 t->lower_bound = 0 - (bounds & 0xf); in mt76x2_get_temp_comp()
477 t->upper_bound = (bounds >> 4) & 0xf; in mt76x2_get_temp_comp()
493 mt76_eeprom_override(&dev->mphy); in mt76x2_eeprom_init()
494 dev->mphy.macaddr[0] &= ~BIT(1); in mt76x2_eeprom_init()