| From ba976379e903eb0a26276037718d5679ae95051a Mon Sep 17 00:00:00 2001 |
| From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| Date: Thu, 13 Oct 2022 13:22:05 +0800 |
| Subject: [PATCH 1127/1128] mt76: mt7915: add E3 re-bonding for low yield rate |
| issue |
| |
| Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| --- |
| mt7915/eeprom.c | 27 ++++++++++++++++++++++++++- |
| mt7915/mcu.c | 13 ++++++++++--- |
| mt7915/mt7915.h | 3 ++- |
| 3 files changed, 38 insertions(+), 5 deletions(-) |
| |
| diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c |
| index 4d2d9ca..b3d2bbc 100644 |
| --- a/mt7915/eeprom.c |
| +++ b/mt7915/eeprom.c |
| @@ -97,7 +97,7 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev) |
| MT7915_EEPROM_BLOCK_SIZE); |
| for (i = 0; i < block_num; i++) |
| mt7915_mcu_get_eeprom(dev, |
| - i * MT7915_EEPROM_BLOCK_SIZE); |
| + i * MT7915_EEPROM_BLOCK_SIZE, NULL); |
| dev->eeprom_mode = EFUSE_MODE; |
| } |
| |
| @@ -198,6 +198,29 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev, |
| dev->chainshift = hweight8(dev->mphy.chainmask); |
| } |
| |
| +void mt7915_eeprom_rebonding(struct mt7915_dev *dev) |
| +{ |
| +#define MT7976_ADIE_MASK BIT(1) |
| +#define MT7986_ADIE1_EFFUSE_OFFSET 0x1000 |
| +#define MT7986_ADIE1_MT7976C_OFFSET 0x270 |
| +#define MT7986_ADIE1_E3_OFFSET 0x271 |
| + u32 adie_offset, sku = mt7915_check_adie(dev, true); |
| + u8 read_buf, *eeprom = dev->mt76.eeprom.data; |
| + |
| + if (!(sku & MT7976_ADIE_MASK)) |
| + return; |
| + |
| + adie_offset = (sku == MT7976_DUAL_ADIE) ? MT7986_ADIE1_EFFUSE_OFFSET : 0; |
| + |
| + /* 7976 A-Die, To identify MT7976C */ |
| + mt7915_mcu_get_eeprom(dev, MT7986_ADIE1_MT7976C_OFFSET + adie_offset, &read_buf); |
| + eeprom[MT7986_ADIE1_MT7976C_OFFSET] = read_buf; |
| + |
| + /* E3 re-binding */ |
| + mt7915_mcu_get_eeprom(dev, MT7986_ADIE1_E3_OFFSET + adie_offset, &read_buf); |
| + eeprom[MT7986_ADIE1_E3_OFFSET] = read_buf; |
| +} |
| + |
| int mt7915_eeprom_init(struct mt7915_dev *dev) |
| { |
| int ret; |
| @@ -229,6 +252,8 @@ int mt7915_eeprom_init(struct mt7915_dev *dev) |
| return ret; |
| } |
| |
| + mt7915_eeprom_rebonding(dev); |
| + |
| ret = mt7915_eeprom_load_precal(dev); |
| if (ret) |
| return ret; |
| diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
| index 39c8e2c..fad3559 100644 |
| --- a/mt7915/mcu.c |
| +++ b/mt7915/mcu.c |
| @@ -2779,7 +2779,7 @@ int mt7915_mcu_set_eeprom(struct mt7915_dev *dev, bool flash_mode) |
| &req, sizeof(req), true); |
| } |
| |
| -int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset) |
| +int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf) |
| { |
| struct mt7915_mcu_eeprom_info req = { |
| .addr = cpu_to_le32(round_down(offset, |
| @@ -2796,8 +2796,15 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset) |
| return ret; |
| |
| res = (struct mt7915_mcu_eeprom_info *)skb->data; |
| - buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr); |
| - memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE); |
| + |
| + if (read_buf) { |
| + u32 offs = offset % MT7915_EEPROM_BLOCK_SIZE; |
| + *read_buf = res->data[offs]; |
| + } else { |
| + buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr); |
| + memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE); |
| + } |
| + |
| dev_kfree_skb(skb); |
| |
| return 0; |
| diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
| index 4cdcb63..dbd634a 100644 |
| --- a/mt7915/mt7915.h |
| +++ b/mt7915/mt7915.h |
| @@ -560,6 +560,7 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id); |
| |
| int mt7915_register_device(struct mt7915_dev *dev); |
| void mt7915_unregister_device(struct mt7915_dev *dev); |
| +void mt7915_eeprom_rebonding(struct mt7915_dev *dev); |
| int mt7915_eeprom_init(struct mt7915_dev *dev); |
| void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev, |
| struct mt7915_phy *phy); |
| @@ -613,7 +614,7 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev, |
| struct ieee80211_sta *sta, |
| void *data, u32 field); |
| int mt7915_mcu_set_eeprom(struct mt7915_dev *dev, bool flash_mode); |
| -int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset); |
| +int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf); |
| int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num); |
| int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable, |
| bool hdr_trans); |
| -- |
| 2.18.0 |
| |