blob: 35eafe9a1fd5030a689543feb527bb0bbd03af39 [file] [log] [blame]
developer9237f442024-06-14 17:13:04 +08001From 60ed10d23382fef314766291e997d422ef9d9fd5 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Tue, 19 Mar 2024 17:33:49 +0800
developer9237f442024-06-14 17:13:04 +08004Subject: [PATCH 054/116] mtk: wifi: mt76: mt7996: add fallback in case of
developer66e89bc2024-04-23 14:50:01 +08005 missing precal data
6
7Align Wi-Fi 6 upstream changes
8https://github.com/openwrt/mt76/commit/2135e201e7a9339e018d4e2d4a33c73266e674d7
9
developer66e89bc2024-04-23 14:50:01 +080010Signed-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
17diff --git a/mt7996/eeprom.c b/mt7996/eeprom.c
developer9237f442024-06-14 17:13:04 +080018index 5eb8629..9987bda 100644
developer66e89bc2024-04-23 14:50:01 +080019--- 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)
70diff --git a/mt7996/init.c b/mt7996/init.c
developer9237f442024-06-14 17:13:04 +080071index 6430bfa..c10f667 100644
developer66e89bc2024-04-23 14:50:01 +080072--- 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;
83diff --git a/mt7996/main.c b/mt7996/main.c
developer9237f442024-06-14 17:13:04 +080084index 8e67616..c7cc66e 100644
developer66e89bc2024-04-23 14:50:01 +080085--- 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--
developer9237f442024-06-14 17:13:04 +0800972.18.0
developer66e89bc2024-04-23 14:50:01 +080098