While idle, we need a default chandef to set channel for things,
such as scan. Before support of mac80211 chanctx, mac80211 would
configure a default one on ieee80211_hw::conf::chandef. And we
just queried it whenever we did set channel. However, after support
of mac80211 chanctx, the flow won't work like before.
Besides, we don't now query chandef from ieee80211_hw::conf::chandef
either. So, similar to mac80211 without using chanctx, we configure
the default chandef with ieee80211_channel of index 0 in 2GHz.
Although we have not added the support of mac80211 chanctx here,
this configuration should be compatible before that. So, we commit
this ahead.
Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220809104952.61355-10-pkshih@realtek.com
 {
        __rtw89_config_entity_chandef(rtwdev, idx, chandef, true);
 }
+
+static void rtw89_config_default_chandef(struct rtw89_dev *rtwdev)
+{
+       struct cfg80211_chan_def chandef = {0};
+
+       rtw89_get_default_chandef(&chandef);
+       __rtw89_config_entity_chandef(rtwdev, RTW89_SUB_ENTITY_0, &chandef, false);
+}
+
+void rtw89_entity_init(struct rtw89_dev *rtwdev)
+{
+       struct rtw89_hal *hal = &rtwdev->hal;
+
+       bitmap_zero(hal->entity_map, NUM_OF_RTW89_SUB_ENTITY);
+       rtw89_config_default_chandef(rtwdev);
+}
 
 void rtw89_config_entity_chandef(struct rtw89_dev *rtwdev,
                                 enum rtw89_sub_entity_idx idx,
                                 const struct cfg80211_chan_def *chandef);
+void rtw89_entity_init(struct rtw89_dev *rtwdev);
 
 #endif
 
        }
 }
 
+void rtw89_get_default_chandef(struct cfg80211_chan_def *chandef)
+{
+       cfg80211_chandef_create(chandef, &rtw89_channels_2ghz[0],
+                               NL80211_CHAN_NO_HT);
+}
+
 static void rtw89_get_channel_params(const struct cfg80211_chan_def *chandef,
                                     struct rtw89_chan *chan)
 {
                return ret;
        }
        rtw89_ser_init(rtwdev);
+       rtw89_entity_init(rtwdev);
 
        return 0;
 }
 
 int rtw89_core_register(struct rtw89_dev *rtwdev);
 void rtw89_core_unregister(struct rtw89_dev *rtwdev);
 void rtw89_core_set_chip_txpwr(struct rtw89_dev *rtwdev);
+void rtw89_get_default_chandef(struct cfg80211_chan_def *chandef);
 void rtw89_set_channel(struct rtw89_dev *rtwdev);
 u8 rtw89_core_acquire_bit_map(unsigned long *addr, unsigned long size);
 void rtw89_core_release_bit_map(unsigned long *addr, u8 bit);
 
 #include <linux/devcoredump.h>
 
 #include "cam.h"
+#include "chan.h"
 #include "debug.h"
 #include "fw.h"
 #include "mac.h"
 
        ser_reset_mac_binding(rtwdev);
        rtw89_core_stop(rtwdev);
+       rtw89_entity_init(rtwdev);
        INIT_LIST_HEAD(&rtwdev->rtwvifs_list);
 }