Lines Matching refs:dev

8 mt7603_efuse_read(struct mt7603_dev *dev, u32 base, u16 addr, u8 *data)  in mt7603_efuse_read()  argument
13 val = mt76_rr(dev, base + MT_EFUSE_CTRL); in mt7603_efuse_read()
18 mt76_wr(dev, base + MT_EFUSE_CTRL, val); in mt7603_efuse_read()
20 if (!mt76_poll(dev, base + MT_EFUSE_CTRL, MT_EFUSE_CTRL_KICK, 0, 1000)) in mt7603_efuse_read()
25 val = mt76_rr(dev, base + MT_EFUSE_CTRL); in mt7603_efuse_read()
33 val = mt76_rr(dev, base + MT_EFUSE_RDATA(i)); in mt7603_efuse_read()
41 mt7603_efuse_init(struct mt7603_dev *dev) in mt7603_efuse_init() argument
43 u32 base = mt7603_reg_map(dev, MT_EFUSE_BASE); in mt7603_efuse_init()
48 if (mt76_rr(dev, base + MT_EFUSE_BASE_CTRL) & MT_EFUSE_BASE_CTRL_EMPTY) in mt7603_efuse_init()
51 dev->mt76.otp.data = devm_kzalloc(dev->mt76.dev, len, GFP_KERNEL); in mt7603_efuse_init()
52 dev->mt76.otp.size = len; in mt7603_efuse_init()
53 if (!dev->mt76.otp.data) in mt7603_efuse_init()
56 buf = dev->mt76.otp.data; in mt7603_efuse_init()
58 ret = mt7603_efuse_read(dev, base, i, buf + i); in mt7603_efuse_init()
67 mt7603_has_cal_free_data(struct mt7603_dev *dev, u8 *efuse) in mt7603_has_cal_free_data() argument
91 mt7603_apply_cal_free_data(struct mt7603_dev *dev, u8 *efuse) in mt7603_apply_cal_free_data() argument
104 struct device_node *np = dev->mt76.dev->of_node; in mt7603_apply_cal_free_data()
105 u8 *eeprom = dev->mt76.eeprom.data; in mt7603_apply_cal_free_data()
112 if (!mt7603_has_cal_free_data(dev, efuse)) in mt7603_apply_cal_free_data()
115 if (is_mt7628(dev)) in mt7603_apply_cal_free_data()
126 mt7603_eeprom_load(struct mt7603_dev *dev) in mt7603_eeprom_load() argument
130 ret = mt76_eeprom_init(&dev->mt76, MT7603_EEPROM_SIZE); in mt7603_eeprom_load()
134 return mt7603_efuse_init(dev); in mt7603_eeprom_load()
137 static int mt7603_check_eeprom(struct mt76_dev *dev) in mt7603_check_eeprom() argument
139 u16 val = get_unaligned_le16(dev->eeprom.data); in mt7603_check_eeprom()
151 static inline bool is_mt7688(struct mt7603_dev *dev) in is_mt7688() argument
153 return mt76_rr(dev, MT_EFUSE_BASE + 0x64) & BIT(4); in is_mt7688()
156 int mt7603_eeprom_init(struct mt7603_dev *dev) in mt7603_eeprom_init() argument
161 ret = mt7603_eeprom_load(dev); in mt7603_eeprom_init()
165 if (dev->mt76.otp.data) { in mt7603_eeprom_init()
166 if (mt7603_check_eeprom(&dev->mt76) == 0) in mt7603_eeprom_init()
167 mt7603_apply_cal_free_data(dev, dev->mt76.otp.data); in mt7603_eeprom_init()
169 memcpy(dev->mt76.eeprom.data, dev->mt76.otp.data, in mt7603_eeprom_init()
173 eeprom = (u8 *)dev->mt76.eeprom.data; in mt7603_eeprom_init()
174 dev->mphy.cap.has_2ghz = true; in mt7603_eeprom_init()
175 memcpy(dev->mphy.macaddr, eeprom + MT_EE_MAC_ADDR, ETH_ALEN); in mt7603_eeprom_init()
178 dev->mphy.antenna_mask = 3; in mt7603_eeprom_init()
181 is_mt7688(dev)) in mt7603_eeprom_init()
182 dev->mphy.antenna_mask = 1; in mt7603_eeprom_init()
184 mt76_eeprom_override(&dev->mphy); in mt7603_eeprom_init()