blob: d9184990c5db42990cbf191c62e256a0dcceaf84 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 7235c5d6995ae047f9223fe077ae753fb439dfed 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
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 059/199] mtk: mt76: mt7996: add fallback in case of missing
5 precal data
developer66e89bc2024-04-23 14:50:01 +08006
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
developer05f3b2b2024-08-19 19:17:34 +080018index fb4d031f..dffcd09d 100644
developer66e89bc2024-04-23 14:50:01 +080019--- a/mt7996/eeprom.c
20+++ b/mt7996/eeprom.c
developer05f3b2b2024-08-19 19:17:34 +080021@@ -490,17 +490,31 @@ static int mt7996_eeprom_load_precal(struct mt7996_dev *dev)
developer66e89bc2024-04-23 14:50:01 +080022 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)
developer05f3b2b2024-08-19 19:17:34 +080059@@ -655,9 +669,7 @@ int mt7996_eeprom_init(struct mt7996_dev *dev)
developer66e89bc2024-04-23 14:50:01 +080060 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
developer05f3b2b2024-08-19 19:17:34 +080071index ade07db7..8b642ecc 100644
developer66e89bc2024-04-23 14:50:01 +080072--- a/mt7996/init.c
73+++ b/mt7996/init.c
developer05f3b2b2024-08-19 19:17:34 +080074@@ -1011,7 +1011,7 @@ static int mt7996_init_hardware(struct mt7996_dev *dev)
developer66e89bc2024-04-23 14:50:01 +080075 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
developer05f3b2b2024-08-19 19:17:34 +080084index 39318595..3bc9dc15 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