1967439c7SZong-Zhe Yang /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2967439c7SZong-Zhe Yang  * Copyright(c) 2020-2022  Realtek Corporation
3967439c7SZong-Zhe Yang  */
4967439c7SZong-Zhe Yang 
5967439c7SZong-Zhe Yang #ifndef __RTW89_CHAN_H__
6967439c7SZong-Zhe Yang #define __RTW89_CHAN_H__
7967439c7SZong-Zhe Yang 
8967439c7SZong-Zhe Yang #include "core.h"
9967439c7SZong-Zhe Yang 
10967439c7SZong-Zhe Yang static inline bool rtw89_get_entity_state(struct rtw89_dev *rtwdev)
11967439c7SZong-Zhe Yang {
12967439c7SZong-Zhe Yang 	struct rtw89_hal *hal = &rtwdev->hal;
13967439c7SZong-Zhe Yang 
14967439c7SZong-Zhe Yang 	return READ_ONCE(hal->entity_active);
15967439c7SZong-Zhe Yang }
16967439c7SZong-Zhe Yang 
17967439c7SZong-Zhe Yang static inline void rtw89_set_entity_state(struct rtw89_dev *rtwdev, bool active)
18967439c7SZong-Zhe Yang {
19967439c7SZong-Zhe Yang 	struct rtw89_hal *hal = &rtwdev->hal;
20967439c7SZong-Zhe Yang 
21967439c7SZong-Zhe Yang 	WRITE_ONCE(hal->entity_active, active);
22967439c7SZong-Zhe Yang }
23967439c7SZong-Zhe Yang 
247cf674ffSZong-Zhe Yang static inline
257cf674ffSZong-Zhe Yang enum rtw89_entity_mode rtw89_get_entity_mode(struct rtw89_dev *rtwdev)
267cf674ffSZong-Zhe Yang {
277cf674ffSZong-Zhe Yang 	struct rtw89_hal *hal = &rtwdev->hal;
287cf674ffSZong-Zhe Yang 
297cf674ffSZong-Zhe Yang 	return READ_ONCE(hal->entity_mode);
307cf674ffSZong-Zhe Yang }
317cf674ffSZong-Zhe Yang 
327cf674ffSZong-Zhe Yang static inline void rtw89_set_entity_mode(struct rtw89_dev *rtwdev,
337cf674ffSZong-Zhe Yang 					 enum rtw89_entity_mode mode)
347cf674ffSZong-Zhe Yang {
357cf674ffSZong-Zhe Yang 	struct rtw89_hal *hal = &rtwdev->hal;
367cf674ffSZong-Zhe Yang 
377cf674ffSZong-Zhe Yang 	WRITE_ONCE(hal->entity_mode, mode);
387cf674ffSZong-Zhe Yang }
397cf674ffSZong-Zhe Yang 
40bb8152b3SZong-Zhe Yang void rtw89_chan_create(struct rtw89_chan *chan, u8 center_chan, u8 primary_chan,
41bb8152b3SZong-Zhe Yang 		       enum rtw89_band band, enum rtw89_bandwidth bandwidth);
42cbb145b9SZong-Zhe Yang bool rtw89_assign_entity_chan(struct rtw89_dev *rtwdev,
43cbb145b9SZong-Zhe Yang 			      enum rtw89_sub_entity_idx idx,
44cbb145b9SZong-Zhe Yang 			      const struct rtw89_chan *new);
45494399b2SZong-Zhe Yang void rtw89_config_entity_chandef(struct rtw89_dev *rtwdev,
46494399b2SZong-Zhe Yang 				 enum rtw89_sub_entity_idx idx,
47494399b2SZong-Zhe Yang 				 const struct cfg80211_chan_def *chandef);
48a88b6cc4SZong-Zhe Yang void rtw89_entity_init(struct rtw89_dev *rtwdev);
497cf674ffSZong-Zhe Yang enum rtw89_entity_mode rtw89_entity_recalc(struct rtw89_dev *rtwdev);
50*84b50f41SZong-Zhe Yang int rtw89_chanctx_ops_add(struct rtw89_dev *rtwdev,
51*84b50f41SZong-Zhe Yang 			  struct ieee80211_chanctx_conf *ctx);
52*84b50f41SZong-Zhe Yang void rtw89_chanctx_ops_remove(struct rtw89_dev *rtwdev,
53*84b50f41SZong-Zhe Yang 			      struct ieee80211_chanctx_conf *ctx);
54*84b50f41SZong-Zhe Yang void rtw89_chanctx_ops_change(struct rtw89_dev *rtwdev,
55*84b50f41SZong-Zhe Yang 			      struct ieee80211_chanctx_conf *ctx,
56*84b50f41SZong-Zhe Yang 			      u32 changed);
57*84b50f41SZong-Zhe Yang int rtw89_chanctx_ops_assign_vif(struct rtw89_dev *rtwdev,
58*84b50f41SZong-Zhe Yang 				 struct rtw89_vif *rtwvif,
59*84b50f41SZong-Zhe Yang 				 struct ieee80211_chanctx_conf *ctx);
60*84b50f41SZong-Zhe Yang void rtw89_chanctx_ops_unassign_vif(struct rtw89_dev *rtwdev,
61*84b50f41SZong-Zhe Yang 				    struct rtw89_vif *rtwvif,
62*84b50f41SZong-Zhe Yang 				    struct ieee80211_chanctx_conf *ctx);
63cbb145b9SZong-Zhe Yang 
64967439c7SZong-Zhe Yang #endif
65