developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 1 | From ba976379e903eb0a26276037718d5679ae95051a Mon Sep 17 00:00:00 2001 |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Thu, 13 Oct 2022 13:22:05 +0800 |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1127/1128] mt76: mt7915: add E3 re-bonding for low yield rate |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 5 | issue |
| 6 | |
| 7 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 8 | --- |
| 9 | mt7915/eeprom.c | 27 ++++++++++++++++++++++++++- |
| 10 | mt7915/mcu.c | 13 ++++++++++--- |
| 11 | mt7915/mt7915.h | 3 ++- |
| 12 | 3 files changed, 38 insertions(+), 5 deletions(-) |
| 13 | |
| 14 | diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 15 | index 4d2d9ca..b3d2bbc 100644 |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 16 | --- a/mt7915/eeprom.c |
| 17 | +++ b/mt7915/eeprom.c |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 18 | @@ -97,7 +97,7 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev) |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 19 | MT7915_EEPROM_BLOCK_SIZE); |
| 20 | for (i = 0; i < block_num; i++) |
| 21 | mt7915_mcu_get_eeprom(dev, |
| 22 | - i * MT7915_EEPROM_BLOCK_SIZE); |
| 23 | + i * MT7915_EEPROM_BLOCK_SIZE, NULL); |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 24 | dev->eeprom_mode = EFUSE_MODE; |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 25 | } |
| 26 | |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 27 | @@ -198,6 +198,29 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev, |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 28 | dev->chainshift = hweight8(dev->mphy.chainmask); |
| 29 | } |
| 30 | |
| 31 | +void mt7915_eeprom_rebonding(struct mt7915_dev *dev) |
| 32 | +{ |
| 33 | +#define MT7976_ADIE_MASK BIT(1) |
| 34 | +#define MT7986_ADIE1_EFFUSE_OFFSET 0x1000 |
| 35 | +#define MT7986_ADIE1_MT7976C_OFFSET 0x270 |
| 36 | +#define MT7986_ADIE1_E3_OFFSET 0x271 |
| 37 | + u32 adie_offset, sku = mt7915_check_adie(dev, true); |
| 38 | + u8 read_buf, *eeprom = dev->mt76.eeprom.data; |
| 39 | + |
| 40 | + if (!(sku & MT7976_ADIE_MASK)) |
| 41 | + return; |
| 42 | + |
| 43 | + adie_offset = (sku == MT7976_DUAL_ADIE) ? MT7986_ADIE1_EFFUSE_OFFSET : 0; |
| 44 | + |
| 45 | + /* 7976 A-Die, To identify MT7976C */ |
| 46 | + mt7915_mcu_get_eeprom(dev, MT7986_ADIE1_MT7976C_OFFSET + adie_offset, &read_buf); |
| 47 | + eeprom[MT7986_ADIE1_MT7976C_OFFSET] = read_buf; |
| 48 | + |
| 49 | + /* E3 re-binding */ |
| 50 | + mt7915_mcu_get_eeprom(dev, MT7986_ADIE1_E3_OFFSET + adie_offset, &read_buf); |
| 51 | + eeprom[MT7986_ADIE1_E3_OFFSET] = read_buf; |
| 52 | +} |
| 53 | + |
| 54 | int mt7915_eeprom_init(struct mt7915_dev *dev) |
| 55 | { |
| 56 | int ret; |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 57 | @@ -229,6 +252,8 @@ int mt7915_eeprom_init(struct mt7915_dev *dev) |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 58 | return ret; |
| 59 | } |
| 60 | |
| 61 | + mt7915_eeprom_rebonding(dev); |
| 62 | + |
| 63 | ret = mt7915_eeprom_load_precal(dev); |
| 64 | if (ret) |
| 65 | return ret; |
| 66 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 67 | index 39c8e2c..fad3559 100644 |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 68 | --- a/mt7915/mcu.c |
| 69 | +++ b/mt7915/mcu.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 70 | @@ -2779,7 +2779,7 @@ int mt7915_mcu_set_eeprom(struct mt7915_dev *dev, bool flash_mode) |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 71 | &req, sizeof(req), true); |
| 72 | } |
| 73 | |
| 74 | -int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset) |
| 75 | +int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf) |
| 76 | { |
| 77 | struct mt7915_mcu_eeprom_info req = { |
| 78 | .addr = cpu_to_le32(round_down(offset, |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 79 | @@ -2796,8 +2796,15 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset) |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 80 | return ret; |
| 81 | |
| 82 | res = (struct mt7915_mcu_eeprom_info *)skb->data; |
| 83 | - buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr); |
| 84 | - memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE); |
| 85 | + |
| 86 | + if (read_buf) { |
| 87 | + u32 offs = offset % MT7915_EEPROM_BLOCK_SIZE; |
| 88 | + *read_buf = res->data[offs]; |
| 89 | + } else { |
| 90 | + buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr); |
| 91 | + memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE); |
| 92 | + } |
| 93 | + |
| 94 | dev_kfree_skb(skb); |
| 95 | |
| 96 | return 0; |
| 97 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 98 | index 4cdcb63..dbd634a 100644 |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 99 | --- a/mt7915/mt7915.h |
| 100 | +++ b/mt7915/mt7915.h |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 101 | @@ -560,6 +560,7 @@ u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id); |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 102 | |
| 103 | int mt7915_register_device(struct mt7915_dev *dev); |
| 104 | void mt7915_unregister_device(struct mt7915_dev *dev); |
| 105 | +void mt7915_eeprom_rebonding(struct mt7915_dev *dev); |
| 106 | int mt7915_eeprom_init(struct mt7915_dev *dev); |
| 107 | void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev, |
| 108 | struct mt7915_phy *phy); |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 109 | @@ -613,7 +614,7 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev, |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 110 | struct ieee80211_sta *sta, |
| 111 | void *data, u32 field); |
| 112 | int mt7915_mcu_set_eeprom(struct mt7915_dev *dev, bool flash_mode); |
| 113 | -int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset); |
| 114 | +int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf); |
| 115 | int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num); |
| 116 | int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable, |
| 117 | bool hdr_trans); |
| 118 | -- |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 119 | 2.18.0 |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 120 | |