blob: 0b7ad11d81dcb2ed72be2f26ab2bf4c0d3376c14 [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From f516af1b0691dcf72ad4a38ce5e6c06cb94ed9be 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
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 047/223] mtk: mt76: mt7996: add fallback in case of missing
developer05f3b2b2024-08-19 19:17:34 +08005 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---
developerd0c89452024-10-11 16:53:27 +080012 mt7996/eeprom.c | 26 ++++++++++++++++++++------
developer66e89bc2024-04-23 14:50:01 +080013 mt7996/init.c | 2 +-
14 mt7996/main.c | 2 +-
developerd0c89452024-10-11 16:53:27 +080015 3 files changed, 22 insertions(+), 8 deletions(-)
developer66e89bc2024-04-23 14:50:01 +080016
17diff --git a/mt7996/eeprom.c b/mt7996/eeprom.c
developerd0c89452024-10-11 16:53:27 +080018index f1c29e8d..3ec146d0 100644
developer66e89bc2024-04-23 14:50:01 +080019--- a/mt7996/eeprom.c
20+++ b/mt7996/eeprom.c
developerd0c89452024-10-11 16:53:27 +080021@@ -535,17 +535,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;
developerd0c89452024-10-11 16:53:27 +080044
45- return mt76_get_of_data_from_nvmem(mdev, dev->cal, "precal", size);
developer66e89bc2024-04-23 14:50:01 +080046+ 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;
developerd0c89452024-10-11 16:53:27 +080054+
developer66e89bc2024-04-23 14:50:01 +080055+ return ret;
56 }
57
58 static int mt7996_apply_cal_free_data(struct mt7996_dev *dev)
developer66e89bc2024-04-23 14:50:01 +080059diff --git a/mt7996/init.c b/mt7996/init.c
developerd0c89452024-10-11 16:53:27 +080060index 3421326a..eac00df0 100644
developer66e89bc2024-04-23 14:50:01 +080061--- a/mt7996/init.c
62+++ b/mt7996/init.c
developerd0c89452024-10-11 16:53:27 +080063@@ -1021,7 +1021,7 @@ static int mt7996_init_hardware(struct mt7996_dev *dev)
developer66e89bc2024-04-23 14:50:01 +080064 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;
72diff --git a/mt7996/main.c b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +080073index ea4679dd..f02f447e 100644
developer66e89bc2024-04-23 14:50:01 +080074--- a/mt7996/main.c
75+++ b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +080076@@ -338,7 +338,7 @@ int mt7996_set_channel(struct mt76_phy *mphy)
77 struct mt7996_phy *phy = mphy->priv;
78 int ret;
developer66e89bc2024-04-23 14:50:01 +080079
80- if (dev->flash_mode) {
81+ if (dev->cal) {
82 ret = mt7996_mcu_apply_tx_dpd(phy);
83 if (ret)
84 goto out;
85--
developerd0c89452024-10-11 16:53:27 +0800862.45.2
developer66e89bc2024-04-23 14:50:01 +080087