@@ -2903,9 +2903,10 @@ static int mt7915_mcu_set_pre_cal(struct mt7915_dev *dev, u8 idx,
29032903int mt7915_mcu_apply_group_cal (struct mt7915_dev * dev )
29042904{
29052905 u8 idx = 0 , * cal = dev -> cal , * eep = dev -> mt76 .eeprom .data ;
2906- u32 total = MT_EE_CAL_GROUP_SIZE ;
2906+ u32 total = mt7915_get_cal_group_size (dev );
2907+ u32 offs = is_mt7915 (& dev -> mt76 ) ? MT_EE_DO_PRE_CAL : MT_EE_DO_PRE_CAL_V2 ;
29072908
2908- if (!(eep [MT_EE_DO_PRE_CAL ] & MT_EE_WIFI_CAL_GROUP ))
2909+ if (!(eep [offs ] & MT_EE_WIFI_CAL_GROUP ))
29092910 return 0 ;
29102911
29112912 /*
@@ -2941,75 +2942,145 @@ static int mt7915_find_freq_idx(const u16 *freqs, int n_freqs, u16 cur)
29412942 return -1 ;
29422943}
29432944
2944- static int mt7915_dpd_freq_idx (u16 freq , u8 bw )
2945+ static int mt7915_dpd_freq_idx (struct mt7915_dev * dev , u16 freq , u8 bw )
29452946{
2946- static const u16 freq_list [] = {
2947+ static const u16 freq_list_v1 [] = {
29472948 5180 , 5200 , 5220 , 5240 ,
29482949 5260 , 5280 , 5300 , 5320 ,
29492950 5500 , 5520 , 5540 , 5560 ,
29502951 5580 , 5600 , 5620 , 5640 ,
29512952 5660 , 5680 , 5700 , 5745 ,
29522953 5765 , 5785 , 5805 , 5825
29532954 };
2954- int offset_2g = ARRAY_SIZE (freq_list );
2955+ static const u16 freq_list_v2 [] = {
2956+ /* 6G BW20*/
2957+ 5955 , 5975 , 5995 , 6015 ,
2958+ 6035 , 6055 , 6075 , 6095 ,
2959+ 6115 , 6135 , 6155 , 6175 ,
2960+ 6195 , 6215 , 6235 , 6255 ,
2961+ 6275 , 6295 , 6315 , 6335 ,
2962+ 6355 , 6375 , 6395 , 6415 ,
2963+ 6435 , 6455 , 6475 , 6495 ,
2964+ 6515 , 6535 , 6555 , 6575 ,
2965+ 6595 , 6615 , 6635 , 6655 ,
2966+ 6675 , 6695 , 6715 , 6735 ,
2967+ 6755 , 6775 , 6795 , 6815 ,
2968+ 6835 , 6855 , 6875 , 6895 ,
2969+ 6915 , 6935 , 6955 , 6975 ,
2970+ 6995 , 7015 , 7035 , 7055 ,
2971+ 7075 , 7095 , 7115 ,
2972+ /* 6G BW160 */
2973+ 6025 , 6185 , 6345 , 6505 ,
2974+ 6665 , 6825 , 6985 ,
2975+ /* 5G BW20 */
2976+ 5180 , 5200 , 5220 , 5240 ,
2977+ 5260 , 5280 , 5300 , 5320 ,
2978+ 5500 , 5520 , 5540 , 5560 ,
2979+ 5580 , 5600 , 5620 , 5640 ,
2980+ 5660 , 5680 , 5700 , 5720 ,
2981+ 5745 , 5765 , 5785 , 5805 ,
2982+ 5825 , 5845 , 5865 , 5885 ,
2983+ /* 5G BW160 */
2984+ 5250 , 5570 , 5815
2985+ };
2986+ static const u16 freq_list_v2_7981 [] = {
2987+ /* 5G BW20 */
2988+ 5180 , 5200 , 5220 , 5240 ,
2989+ 5260 , 5280 , 5300 , 5320 ,
2990+ 5500 , 5520 , 5540 , 5560 ,
2991+ 5580 , 5600 , 5620 , 5640 ,
2992+ 5660 , 5680 , 5700 , 5720 ,
2993+ 5745 , 5765 , 5785 , 5805 ,
2994+ 5825 , 5845 , 5865 , 5885 ,
2995+ /* 5G BW160 */
2996+ 5250 , 5570 , 5815
2997+ };
2998+ const u16 * freq_list = freq_list_v1 ;
2999+ int n_freqs = ARRAY_SIZE (freq_list_v1 );
29553000 int idx ;
29563001
3002+ if (!is_mt7915 (& dev -> mt76 )) {
3003+ if (is_mt7981 (& dev -> mt76 )) {
3004+ freq_list = freq_list_v2_7981 ;
3005+ n_freqs = ARRAY_SIZE (freq_list_v2_7981 );
3006+ } else {
3007+ freq_list = freq_list_v2 ;
3008+ n_freqs = ARRAY_SIZE (freq_list_v2 );
3009+ }
3010+ }
3011+
29573012 if (freq < 4000 ) {
29583013 if (freq < 2432 )
2959- return offset_2g ;
3014+ return n_freqs ;
29603015 if (freq < 2457 )
2961- return offset_2g + 1 ;
3016+ return n_freqs + 1 ;
29623017
2963- return offset_2g + 2 ;
3018+ return n_freqs + 2 ;
29643019 }
29653020
2966- if (bw == NL80211_CHAN_WIDTH_80P80 || bw == NL80211_CHAN_WIDTH_160 )
3021+ if (bw == NL80211_CHAN_WIDTH_80P80 )
29673022 return -1 ;
29683023
29693024 if (bw != NL80211_CHAN_WIDTH_20 ) {
2970- idx = mt7915_find_freq_idx (freq_list , ARRAY_SIZE (freq_list ),
2971- freq + 10 );
3025+ idx = mt7915_find_freq_idx (freq_list , n_freqs , freq + 10 );
29723026 if (idx >= 0 )
29733027 return idx ;
29743028
2975- idx = mt7915_find_freq_idx (freq_list , ARRAY_SIZE (freq_list ),
2976- freq - 10 );
3029+ idx = mt7915_find_freq_idx (freq_list , n_freqs , freq - 10 );
29773030 if (idx >= 0 )
29783031 return idx ;
29793032 }
29803033
2981- return mt7915_find_freq_idx (freq_list , ARRAY_SIZE ( freq_list ) , freq );
3034+ return mt7915_find_freq_idx (freq_list , n_freqs , freq );
29823035}
29833036
29843037int mt7915_mcu_apply_tx_dpd (struct mt7915_phy * phy )
29853038{
29863039 struct mt7915_dev * dev = phy -> dev ;
29873040 struct cfg80211_chan_def * chandef = & phy -> mt76 -> chandef ;
2988- u16 total = 2 , center_freq = chandef -> center_freq1 ;
3041+ enum nl80211_band band = chandef -> chan -> band ;
3042+ u32 offs = is_mt7915 (& dev -> mt76 ) ? MT_EE_DO_PRE_CAL : MT_EE_DO_PRE_CAL_V2 ;
3043+ u16 center_freq = chandef -> center_freq1 ;
29893044 u8 * cal = dev -> cal , * eep = dev -> mt76 .eeprom .data ;
3045+ u8 dpd_mask , cal_num = is_mt7915 (& dev -> mt76 ) ? 2 : 3 ;
29903046 int idx ;
29913047
2992- if (!(eep [MT_EE_DO_PRE_CAL ] & MT_EE_WIFI_CAL_DPD ))
3048+ switch (band ) {
3049+ case NL80211_BAND_2GHZ :
3050+ dpd_mask = MT_EE_WIFI_CAL_DPD_2G ;
3051+ break ;
3052+ case NL80211_BAND_5GHZ :
3053+ dpd_mask = MT_EE_WIFI_CAL_DPD_5G ;
3054+ break ;
3055+ case NL80211_BAND_6GHZ :
3056+ dpd_mask = MT_EE_WIFI_CAL_DPD_6G ;
3057+ break ;
3058+ default :
3059+ dpd_mask = 0 ;
3060+ break ;
3061+ }
3062+
3063+ if (!(eep [offs ] & dpd_mask ))
29933064 return 0 ;
29943065
2995- idx = mt7915_dpd_freq_idx (center_freq , chandef -> width );
3066+ idx = mt7915_dpd_freq_idx (dev , center_freq , chandef -> width );
29963067 if (idx < 0 )
29973068 return - EINVAL ;
29983069
29993070 /* Items: Tx DPD, Tx Flatness */
3000- idx = idx * 2 ;
3001- cal += MT_EE_CAL_GROUP_SIZE ;
3071+ idx = idx * cal_num ;
3072+ cal += mt7915_get_cal_group_size ( dev ) + ( idx * MT_EE_CAL_UNIT ) ;
30023073
3003- while (total -- ) {
3074+ while (cal_num -- ) {
30043075 int ret ;
30053076
3006- cal += (idx * MT_EE_CAL_UNIT );
30073077 ret = mt7915_mcu_set_pre_cal (dev , idx , cal , MT_EE_CAL_UNIT ,
30083078 MCU_EXT_CMD (DPD_PRE_CAL_INFO ));
30093079 if (ret )
30103080 return ret ;
30113081
30123082 idx ++ ;
3083+ cal += MT_EE_CAL_UNIT ;
30133084 }
30143085
30153086 return 0 ;
0 commit comments