developer | 81ca9d6 | 2022-10-14 11:23:22 +0800 | [diff] [blame] | 1 | From 6ed6cb4cf561159bcd935f48000abce3652fb682 Mon Sep 17 00:00:00 2001 |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Thu, 7 Jul 2022 11:09:59 +0800 |
developer | 81ca9d6 | 2022-10-14 11:23:22 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1120/1127] mt76: mt7915: implement bin file mode |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 5 | |
| 6 | Change-Id: I2a726341541a11cbecdb210b33a8e79aefbd6cf3 |
| 7 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 8 | --- |
developer | 071927d | 2022-08-31 20:39:29 +0800 | [diff] [blame] | 9 | eeprom.c | 18 +++++++++++++++++ |
| 10 | mt76.h | 1 + |
| 11 | mt7915/eeprom.c | 53 +++++++++++++++++++++++++++++++++++++++---------- |
| 12 | mt7915/mt7915.h | 10 ++++++++++ |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 13 | 4 files changed, 71 insertions(+), 11 deletions(-) |
| 14 | |
| 15 | diff --git a/eeprom.c b/eeprom.c |
developer | 81ca9d6 | 2022-10-14 11:23:22 +0800 | [diff] [blame] | 16 | index 4c50bfe6..baca86fd 100644 |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 17 | --- a/eeprom.c |
| 18 | +++ b/eeprom.c |
developer | 071927d | 2022-08-31 20:39:29 +0800 | [diff] [blame] | 19 | @@ -104,6 +104,24 @@ out_put_node: |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 20 | } |
| 21 | EXPORT_SYMBOL_GPL(mt76_get_of_eeprom); |
| 22 | |
| 23 | +bool mt76_check_bin_file_mode(struct mt76_dev *dev) |
| 24 | +{ |
| 25 | + struct device_node *np = dev->dev->of_node; |
| 26 | + const __be32 *bin_file_mode; |
| 27 | + bool ret = false; |
| 28 | + |
| 29 | + if (!np) |
| 30 | + return false; |
| 31 | + |
| 32 | + bin_file_mode = of_get_property(np, "bin_file_mode", NULL); |
developer | d59e477 | 2022-07-14 13:48:49 +0800 | [diff] [blame] | 33 | + if (bin_file_mode && be32_to_cpu(*bin_file_mode)) |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 34 | + ret = true; |
| 35 | + |
| 36 | + of_node_put(np); |
| 37 | + return ret; |
| 38 | +} |
| 39 | +EXPORT_SYMBOL_GPL(mt76_check_bin_file_mode); |
| 40 | + |
| 41 | void |
| 42 | mt76_eeprom_override(struct mt76_phy *phy) |
| 43 | { |
| 44 | diff --git a/mt76.h b/mt76.h |
developer | 81ca9d6 | 2022-10-14 11:23:22 +0800 | [diff] [blame] | 45 | index 3ca449f7..e547f79e 100644 |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 46 | --- a/mt76.h |
| 47 | +++ b/mt76.h |
developer | c226de8 | 2022-10-03 12:24:57 +0800 | [diff] [blame] | 48 | @@ -1001,6 +1001,7 @@ void mt76_seq_puts_array(struct seq_file *file, const char *str, |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 49 | int mt76_eeprom_init(struct mt76_dev *dev, int len); |
| 50 | void mt76_eeprom_override(struct mt76_phy *phy); |
| 51 | int mt76_get_of_eeprom(struct mt76_dev *dev, void *data, int offset, int len); |
| 52 | +bool mt76_check_bin_file_mode(struct mt76_dev *dev); |
| 53 | |
| 54 | struct mt76_queue * |
| 55 | mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc, |
| 56 | diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c |
developer | 81ca9d6 | 2022-10-14 11:23:22 +0800 | [diff] [blame] | 57 | index d58a3201..632ecc7b 100644 |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 58 | --- a/mt7915/eeprom.c |
| 59 | +++ b/mt7915/eeprom.c |
| 60 | @@ -46,26 +46,36 @@ static char *mt7915_eeprom_name(struct mt7915_dev *dev) |
| 61 | { |
| 62 | switch (mt76_chip(&dev->mt76)) { |
| 63 | case 0x7915: |
| 64 | - return dev->dbdc_support ? |
| 65 | - MT7915_EEPROM_DEFAULT_DBDC : MT7915_EEPROM_DEFAULT; |
| 66 | + if (dev->bin_file_mode) |
| 67 | + return dev->dbdc_support ? |
| 68 | + MT7915_BIN_FILE_DBDC : MT7915_BIN_FILE; |
| 69 | + else |
| 70 | + return dev->dbdc_support ? |
| 71 | + MT7915_EEPROM_DEFAULT_DBDC : MT7915_EEPROM_DEFAULT; |
| 72 | case 0x7986: |
| 73 | switch (mt7915_check_adie(dev, true)) { |
| 74 | case MT7976_ONE_ADIE_DBDC: |
| 75 | - return MT7986_EEPROM_MT7976_DEFAULT_DBDC; |
| 76 | + return dev->bin_file_mode ? |
| 77 | + MT7986_BIN_FILE_MT7976_DBDC : MT7986_EEPROM_MT7976_DEFAULT_DBDC; |
| 78 | case MT7975_ONE_ADIE: |
| 79 | - return MT7986_EEPROM_MT7975_DEFAULT; |
| 80 | + return dev->bin_file_mode ? |
| 81 | + MT7986_BIN_FILE_MT7975 : MT7986_EEPROM_MT7975_DEFAULT; |
| 82 | case MT7976_ONE_ADIE: |
| 83 | - return MT7986_EEPROM_MT7976_DEFAULT; |
| 84 | + return dev->bin_file_mode ? |
| 85 | + MT7986_BIN_FILE_MT7976 : MT7986_EEPROM_MT7976_DEFAULT; |
| 86 | case MT7975_DUAL_ADIE: |
| 87 | - return MT7986_EEPROM_MT7975_DUAL_DEFAULT; |
| 88 | + return dev->bin_file_mode ? |
| 89 | + MT7986_BIN_FILE_MT7975_DUAL : MT7986_EEPROM_MT7975_DUAL_DEFAULT; |
| 90 | case MT7976_DUAL_ADIE: |
| 91 | - return MT7986_EEPROM_MT7976_DUAL_DEFAULT; |
| 92 | + return dev->bin_file_mode ? |
| 93 | + MT7986_BIN_FILE_MT7976_DUAL : MT7986_EEPROM_MT7976_DUAL_DEFAULT; |
| 94 | default: |
| 95 | break; |
| 96 | } |
| 97 | return NULL; |
| 98 | default: |
| 99 | - return MT7916_EEPROM_DEFAULT; |
| 100 | + return dev->bin_file_mode ? |
| 101 | + MT7916_BIN_FILE : MT7916_EEPROM_DEFAULT; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | @@ -81,7 +91,10 @@ mt7915_eeprom_load_default(struct mt7915_dev *dev) |
| 106 | return ret; |
| 107 | |
| 108 | if (!fw || !fw->data) { |
| 109 | - dev_err(dev->mt76.dev, "Invalid default bin\n"); |
| 110 | + if (dev->bin_file_mode) |
| 111 | + dev_err(dev->mt76.dev, "Invalid bin (bin file mode)\n"); |
| 112 | + else |
| 113 | + dev_err(dev->mt76.dev, "Invalid default bin\n"); |
| 114 | ret = -EINVAL; |
| 115 | goto out; |
| 116 | } |
developer | c226de8 | 2022-10-03 12:24:57 +0800 | [diff] [blame] | 117 | @@ -221,12 +234,30 @@ int mt7915_eeprom_init(struct mt7915_dev *dev) |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 118 | { |
| 119 | int ret; |
| 120 | |
| 121 | - ret = mt7915_eeprom_load(dev); |
| 122 | + dev->bin_file_mode = mt76_check_bin_file_mode(&dev->mt76); |
| 123 | + |
| 124 | + if (dev->bin_file_mode) { |
| 125 | + dev->mt76.eeprom.size = mt7915_eeprom_size(dev); |
| 126 | + dev->mt76.eeprom.data = devm_kzalloc(dev->mt76.dev, dev->mt76.eeprom.size, |
| 127 | + GFP_KERNEL); |
| 128 | + if (!dev->mt76.eeprom.data) |
| 129 | + return -ENOMEM; |
| 130 | + ret = mt7915_eeprom_load_default(dev); |
| 131 | + } else { |
| 132 | + ret = mt7915_eeprom_load(dev); |
| 133 | + } |
| 134 | + |
| 135 | if (ret < 0) { |
| 136 | if (ret != -EINVAL) |
| 137 | return ret; |
| 138 | |
| 139 | - dev_warn(dev->mt76.dev, "eeprom load fail, use default bin\n"); |
| 140 | + if (dev->bin_file_mode) { |
| 141 | + dev_warn(dev->mt76.dev, "bin file load fail, use default bin\n"); |
| 142 | + dev->bin_file_mode = false; |
| 143 | + } else { |
| 144 | + dev_warn(dev->mt76.dev, "eeprom load fail, use default bin\n"); |
| 145 | + } |
| 146 | + |
| 147 | ret = mt7915_eeprom_load_default(dev); |
| 148 | if (ret) |
| 149 | return ret; |
| 150 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 81ca9d6 | 2022-10-14 11:23:22 +0800 | [diff] [blame] | 151 | index 1b08686e..5fa1dfac 100644 |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 152 | --- a/mt7915/mt7915.h |
| 153 | +++ b/mt7915/mt7915.h |
| 154 | @@ -51,6 +51,15 @@ |
| 155 | #define MT7986_EEPROM_MT7976_DEFAULT_DBDC "mediatek/mt7986_eeprom_mt7976_dbdc.bin" |
| 156 | #define MT7986_EEPROM_MT7976_DUAL_DEFAULT "mediatek/mt7986_eeprom_mt7976_dual.bin" |
| 157 | |
| 158 | +#define MT7915_BIN_FILE "mediatek/mt7915_binfile.bin" |
| 159 | +#define MT7915_BIN_FILE_DBDC "mediatek/mt7915_binfile_dbdc.bin" |
| 160 | +#define MT7916_BIN_FILE "mediatek/mt7916_binfile.bin" |
| 161 | +#define MT7986_BIN_FILE_MT7975 "mediatek/mt7986_binfile_mt7975.bin" |
| 162 | +#define MT7986_BIN_FILE_MT7975_DUAL "mediatek/mt7986_binfile_mt7975_dual.bin" |
| 163 | +#define MT7986_BIN_FILE_MT7976 "mediatek/mt7986_binfile_mt7976.bin" |
| 164 | +#define MT7986_BIN_FILE_MT7976_DBDC "mediatek/mt7986_binfile_mt7976_dbdc.bin" |
| 165 | +#define MT7986_BIN_FILE_MT7976_DUAL "mediatek/mt7986_binfile_mt7976_dual.bin" |
| 166 | + |
| 167 | #define MT7915_EEPROM_SIZE 3584 |
| 168 | #define MT7916_EEPROM_SIZE 4096 |
| 169 | |
developer | 20747c1 | 2022-09-16 14:09:40 +0800 | [diff] [blame] | 170 | @@ -373,6 +382,7 @@ struct mt7915_dev { |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 171 | |
| 172 | bool dbdc_support; |
| 173 | bool flash_mode; |
| 174 | + bool bin_file_mode; |
| 175 | bool muru_debug; |
| 176 | bool ibf; |
| 177 | |
| 178 | -- |
developer | 81ca9d6 | 2022-10-14 11:23:22 +0800 | [diff] [blame] | 179 | 2.25.1 |
developer | ceb4001 | 2022-07-07 17:30:32 +0800 | [diff] [blame] | 180 | |