developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 1 | From f516af1b0691dcf72ad4a38ce5e6c06cb94ed9be 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 | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 047/223] mtk: mt76: mt7996: add fallback in case of missing |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 5 | precal data |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 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 | --- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 12 | mt7996/eeprom.c | 26 ++++++++++++++++++++------ |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 13 | mt7996/init.c | 2 +- |
| 14 | mt7996/main.c | 2 +- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 15 | 3 files changed, 22 insertions(+), 8 deletions(-) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 16 | |
| 17 | diff --git a/mt7996/eeprom.c b/mt7996/eeprom.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 18 | index f1c29e8d..3ec146d0 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 19 | --- a/mt7996/eeprom.c |
| 20 | +++ b/mt7996/eeprom.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 21 | @@ -535,17 +535,31 @@ static int mt7996_eeprom_load_precal(struct mt7996_dev *dev) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 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; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 44 | |
| 45 | - return mt76_get_of_data_from_nvmem(mdev, dev->cal, "precal", size); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 46 | + ret = mt76_get_of_data_from_nvmem(mdev, dev->cal, "precal", size); |
| 47 | + if (!ret) |
| 48 | + return 0; |
| 49 | + |
| 50 | +fail: |
| 51 | + dev_warn(dev->mt76.dev, "Failed to load precal data: %d\n", ret); |
| 52 | + devm_kfree(dev->mt76.dev, dev->cal); |
| 53 | + dev->cal = NULL; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 54 | + |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 55 | + return ret; |
| 56 | } |
| 57 | |
| 58 | static int mt7996_apply_cal_free_data(struct mt7996_dev *dev) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 59 | diff --git a/mt7996/init.c b/mt7996/init.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 60 | index 3421326a..eac00df0 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 61 | --- a/mt7996/init.c |
| 62 | +++ b/mt7996/init.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 63 | @@ -1021,7 +1021,7 @@ static int mt7996_init_hardware(struct mt7996_dev *dev) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 64 | if (ret < 0) |
| 65 | return ret; |
| 66 | |
| 67 | - if (dev->flash_mode) { |
| 68 | + if (dev->cal) { |
| 69 | ret = mt7996_mcu_apply_group_cal(dev); |
| 70 | if (ret) |
| 71 | return ret; |
| 72 | diff --git a/mt7996/main.c b/mt7996/main.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 73 | index ea4679dd..f02f447e 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 74 | --- a/mt7996/main.c |
| 75 | +++ b/mt7996/main.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 76 | @@ -338,7 +338,7 @@ int mt7996_set_channel(struct mt76_phy *mphy) |
| 77 | struct mt7996_phy *phy = mphy->priv; |
| 78 | int ret; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 79 | |
| 80 | - if (dev->flash_mode) { |
| 81 | + if (dev->cal) { |
| 82 | ret = mt7996_mcu_apply_tx_dpd(phy); |
| 83 | if (ret) |
| 84 | goto out; |
| 85 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 86 | 2.45.2 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 87 | |