developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1 | From 60ed10d23382fef314766291e997d422ef9d9fd5 Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Tue, 19 Mar 2024 17:33:49 +0800 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 4 | Subject: [PATCH 054/116] mtk: wifi: mt76: mt7996: add fallback in case of |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 5 | missing precal data |
| 6 | |
| 7 | Align Wi-Fi 6 upstream changes |
| 8 | https://github.com/openwrt/mt76/commit/2135e201e7a9339e018d4e2d4a33c73266e674d7 |
| 9 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 10 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 11 | --- |
| 12 | mt7996/eeprom.c | 30 +++++++++++++++++++++--------- |
| 13 | mt7996/init.c | 2 +- |
| 14 | mt7996/main.c | 2 +- |
| 15 | 3 files changed, 23 insertions(+), 11 deletions(-) |
| 16 | |
| 17 | diff --git a/mt7996/eeprom.c b/mt7996/eeprom.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 18 | index 5eb8629..9987bda 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 19 | --- a/mt7996/eeprom.c |
| 20 | +++ b/mt7996/eeprom.c |
| 21 | @@ -487,17 +487,31 @@ static int mt7996_eeprom_load_precal(struct mt7996_dev *dev) |
| 22 | size = MT_EE_CAL_GROUP_SIZE + MT_EE_CAL_DPD_SIZE; |
| 23 | |
| 24 | dev->cal = devm_kzalloc(mdev->dev, size, GFP_KERNEL); |
| 25 | - if (!dev->cal) |
| 26 | - return -ENOMEM; |
| 27 | + if (!dev->cal) { |
| 28 | + ret = -ENOMEM; |
| 29 | + goto fail; |
| 30 | + } |
| 31 | |
| 32 | - if (dev->bin_file_mode) |
| 33 | - return mt7996_eeprom_load_precal_binfile(dev, MT_EE_PRECAL, size); |
| 34 | + if (dev->bin_file_mode) { |
| 35 | + ret = mt7996_eeprom_load_precal_binfile(dev, MT_EE_PRECAL, size); |
| 36 | + if (ret) |
| 37 | + goto fail; |
| 38 | + } |
| 39 | |
| 40 | ret = mt76_get_of_data_from_mtd(mdev, dev->cal, offs, size); |
| 41 | if (!ret) |
| 42 | - return ret; |
| 43 | + return 0; |
| 44 | + |
| 45 | + ret = mt76_get_of_data_from_nvmem(mdev, dev->cal, "precal", size); |
| 46 | + if (!ret) |
| 47 | + return 0; |
| 48 | + |
| 49 | +fail: |
| 50 | + dev_warn(dev->mt76.dev, "Failed to load precal data: %d\n", ret); |
| 51 | + devm_kfree(dev->mt76.dev, dev->cal); |
| 52 | + dev->cal = NULL; |
| 53 | |
| 54 | - return mt76_get_of_data_from_nvmem(mdev, dev->cal, "precal", size); |
| 55 | + return ret; |
| 56 | } |
| 57 | |
| 58 | static int mt7996_apply_cal_free_data(struct mt7996_dev *dev) |
| 59 | @@ -652,9 +666,7 @@ int mt7996_eeprom_init(struct mt7996_dev *dev) |
| 60 | if (ret) |
| 61 | return ret; |
| 62 | |
| 63 | - ret = mt7996_eeprom_load_precal(dev); |
| 64 | - if (ret) |
| 65 | - return ret; |
| 66 | + mt7996_eeprom_load_precal(dev); |
| 67 | |
| 68 | ret = mt7996_apply_cal_free_data(dev); |
| 69 | if (ret) |
| 70 | diff --git a/mt7996/init.c b/mt7996/init.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 71 | index 6430bfa..c10f667 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 72 | --- a/mt7996/init.c |
| 73 | +++ b/mt7996/init.c |
| 74 | @@ -1010,7 +1010,7 @@ static int mt7996_init_hardware(struct mt7996_dev *dev) |
| 75 | if (ret < 0) |
| 76 | return ret; |
| 77 | |
| 78 | - if (dev->flash_mode) { |
| 79 | + if (dev->cal) { |
| 80 | ret = mt7996_mcu_apply_group_cal(dev); |
| 81 | if (ret) |
| 82 | return ret; |
| 83 | diff --git a/mt7996/main.c b/mt7996/main.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 84 | index 8e67616..c7cc66e 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 85 | --- a/mt7996/main.c |
| 86 | +++ b/mt7996/main.c |
| 87 | @@ -345,7 +345,7 @@ int mt7996_set_channel(struct mt7996_phy *phy) |
| 88 | |
| 89 | mt76_set_channel(phy->mt76); |
| 90 | |
| 91 | - if (dev->flash_mode) { |
| 92 | + if (dev->cal) { |
| 93 | ret = mt7996_mcu_apply_tx_dpd(phy); |
| 94 | if (ret) |
| 95 | goto out; |
| 96 | -- |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 97 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 98 | |