blob: 06b79387e4c32560d5166c0f52592f220560706a [file] [log] [blame]
developer1f55fcf2024-10-17 14:52:33 +08001From 478bf79875d21c0eac4b2c8e2e78fb951f9e80ab 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
developer1f55fcf2024-10-17 14:52:33 +08004Subject: [PATCH 047/193] 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
developer1f55fcf2024-10-17 14:52:33 +080018index f1c29e8..3ec146d 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
developer1f55fcf2024-10-17 14:52:33 +080060index 92d4d6f..849a639 100644
developer66e89bc2024-04-23 14:50:01 +080061--- a/mt7996/init.c
62+++ b/mt7996/init.c
developer1f55fcf2024-10-17 14:52:33 +080063@@ -1018,7 +1018,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
developer1f55fcf2024-10-17 14:52:33 +080073index 9376d69..2721491 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