xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852be/phl/phl_regulation.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /******************************************************************************
2*4882a593Smuzhiyun  *
3*4882a593Smuzhiyun  * Copyright(c) 2020 Realtek Corporation.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * This program is free software; you can redistribute it and/or modify it
6*4882a593Smuzhiyun  * under the terms of version 2 of the GNU General Public License as
7*4882a593Smuzhiyun  * published by the Free Software Foundation.
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * This program is distributed in the hope that it will be useful, but WITHOUT
10*4882a593Smuzhiyun  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12*4882a593Smuzhiyun  * more details.
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  *****************************************************************************/
15*4882a593Smuzhiyun #ifndef _PHL_REGULATION_H_
16*4882a593Smuzhiyun #define _PHL_REGULATION_H_
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun #define MAX_CH_NUM_GROUP 24
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun enum rtw_regulation_freq_group {
21*4882a593Smuzhiyun 	FREQ_GROUP_2GHZ = 0x0,
22*4882a593Smuzhiyun 	FREQ_GROUP_5GHZ_BAND1,
23*4882a593Smuzhiyun 	FREQ_GROUP_5GHZ_BAND2,
24*4882a593Smuzhiyun 	FREQ_GROUP_5GHZ_BAND3,
25*4882a593Smuzhiyun 	FREQ_GROUP_5GHZ_BAND4,
26*4882a593Smuzhiyun 	FREQ_GROUP_6GHZ_UNII5,
27*4882a593Smuzhiyun 	FREQ_GROUP_6GHZ_UNII6,
28*4882a593Smuzhiyun 	FREQ_GROUP_6GHZ_UNII7,
29*4882a593Smuzhiyun 	FREQ_GROUP_6GHZ_UNII8,
30*4882a593Smuzhiyun 	FREQ_GROUP_6GHZ_PSC,
31*4882a593Smuzhiyun 	FREQ_GROUP_MAX
32*4882a593Smuzhiyun };
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun enum rtw_regulation_status {
35*4882a593Smuzhiyun 	REGULATION_SUCCESS = 0x0,
36*4882a593Smuzhiyun 	REGULATION_FAILURE,
37*4882a593Smuzhiyun 	REGULATION_DOMAIN_MISMATCH,
38*4882a593Smuzhiyun 	REGULATION_INVALID_2GHZ_RD,
39*4882a593Smuzhiyun 	REGULATION_INVALID_5GHZ_RD,
40*4882a593Smuzhiyun 	REGULATION_INVALID_DOMAIN
41*4882a593Smuzhiyun };
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun struct rtw_regulation_chplan_group {
44*4882a593Smuzhiyun 	u32 cnt;
45*4882a593Smuzhiyun 	struct rtw_regulation_channel ch[MAX_CH_NUM_GROUP];
46*4882a593Smuzhiyun };
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun #define MAX_HISTORY_NUM 20
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun #define INVALID_DOMAIN_CODE 0xffff
51*4882a593Smuzhiyun #define INVALID_CHDEF 0xff
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun struct rtw_domain {
54*4882a593Smuzhiyun 	u16 code;
55*4882a593Smuzhiyun 	u8 reason;
56*4882a593Smuzhiyun };
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun struct rtw_regulation {
59*4882a593Smuzhiyun 	_os_lock lock;
60*4882a593Smuzhiyun 	u8 init; /* regulation sw initialization */
61*4882a593Smuzhiyun 	u8 invalid_cnt;
62*4882a593Smuzhiyun 	u8 history_cnt;
63*4882a593Smuzhiyun 	struct rtw_domain history[MAX_HISTORY_NUM];
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun 	/* working regulation */
66*4882a593Smuzhiyun 	bool valid; /* true if domain code successfully set */
67*4882a593Smuzhiyun 	u16 capability; /* rtw_regulation_capability */
68*4882a593Smuzhiyun 	struct rtw_domain domain;
69*4882a593Smuzhiyun 	char country[2];
70*4882a593Smuzhiyun 	u8 tpo; /* tx power overwrite */
71*4882a593Smuzhiyun 	u8 support_mode;
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun 	u8 ch_idx2g; /* 2ghz chdef index */
74*4882a593Smuzhiyun 	u8 regulation_2g;
75*4882a593Smuzhiyun 	u8 ch_idx5g; /* 5ghz chdef index */
76*4882a593Smuzhiyun 	u8 regulation_5g;
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun 	struct rtw_regulation_chplan_group chplan[FREQ_GROUP_MAX];
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun 	/* 6 ghz */
81*4882a593Smuzhiyun 	u8 invalid_cnt_6g;
82*4882a593Smuzhiyun 	u8 history_cnt_6g;
83*4882a593Smuzhiyun 	struct rtw_domain history_6g[MAX_HISTORY_NUM];
84*4882a593Smuzhiyun 	bool valid_6g; /* true if domain code successfully set */
85*4882a593Smuzhiyun 	struct rtw_domain domain_6g;
86*4882a593Smuzhiyun 	u8 ch_idx6g; /* 6ghz chdef index */
87*4882a593Smuzhiyun 	u8 regulation_6g;
88*4882a593Smuzhiyun };
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun bool rtw_phl_regulation_query_ch(void *phl, enum band_type band, u8 channel,
91*4882a593Smuzhiyun 					struct rtw_regulation_channel *ch);
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun u8 rtw_phl_get_domain_regulation_2g(u8 domain);
94*4882a593Smuzhiyun u8 rtw_phl_get_domain_regulation_5g(u8 domain);
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun #endif /* _PHL_REGULATION_H_ */
97