1 /******************************************************************************
2 *
3 * Copyright(c) 2019 Realtek Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 *****************************************************************************/
15 #define _PHL_EXT_TX_PWR_LMT_C_
16 #include "phl_headers.h"
17
18 /**
19 * The function to update current TX power limit value to HW register
20 * @phl: see struct phl_info_t
21 * @hw_band: 0x0: band0, 0x1: band1
22 *
23 */
24 enum rtw_phl_status
rtw_phl_set_power_lmt(void * phl,u8 hw_band)25 rtw_phl_set_power_lmt(void *phl, u8 hw_band)
26 {
27 struct phl_info_t *phl_info = (struct phl_info_t *)phl;
28 enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
29
30 if (rtw_hal_set_power_lmt(phl_info->hal, hw_band)==RTW_HAL_STATUS_SUCCESS)
31 phl_status = RTW_PHL_STATUS_SUCCESS;
32
33 return phl_status;
34 }
35
36 /**
37 * The function to get TX power limit value with specific parameters
38 * @phl: see struct phl_info_t
39 * @hw_band: 0x0: band0, 0x1: band1
40 * @rate: data rate
41 * @bandwidth: banddwidth
42 * @beamforming: 0: TX w/o BF, 1: TX w/ BF
43 * @tx_num: tx number, 0: 1TX, 1: 2TX
44 * @channel: center channel
45 *
46 */
rtw_phl_get_power_limit(void * phl,u8 hw_band,u16 rate,u8 bandwidth,u8 beamforming,u8 tx_num,u8 channel)47 s8 rtw_phl_get_power_limit(void *phl, u8 hw_band,
48 u16 rate, u8 bandwidth, u8 beamforming, u8 tx_num, u8 channel)
49 {
50 struct phl_info_t *phl_info = (struct phl_info_t *)phl;
51
52 return rtw_hal_rf_get_power_limit(phl_info->hal, hw_band, rate,
53 bandwidth, beamforming, tx_num, channel);
54 }
55
56 /**
57 * The function to update user defined extended tx power limit to halrf
58 * @phl: see struct phl_info_t
59 * @hw_band: 0x0: band0, 0x1: band1
60 * @ext_pwr_lmt_info: table of extended tx power limit value
61 *
62 * Note,
63 * This function will enable extended tx power limit mechanism.
64 * After enabled this mechanism, halrf will use
65 * min(original tx power limit, extended tx power limit) to be
66 * final tx power limit value.
67 *
68 */
69 void
rtw_phl_enable_ext_pwr_lmt(void * phl,u8 hw_band,struct rtw_phl_ext_pwr_lmt_info * ext_pwr_lmt_info)70 rtw_phl_enable_ext_pwr_lmt(void *phl, u8 hw_band,
71 struct rtw_phl_ext_pwr_lmt_info *ext_pwr_lmt_info)
72 {
73 struct phl_info_t *phl_info = (struct phl_info_t *)phl;
74 struct rtw_tpu_ext_pwr_lmt_info tpu_ext_pwr_lmt_info = {0};
75 u8 i;
76
77 for (i = 0; i < HAL_MAX_PATH; i++) {
78 tpu_ext_pwr_lmt_info.ext_pwr_lmt_2_4g[i]
79 = ext_pwr_lmt_info->ext_pwr_lmt_2_4g[i];
80
81 tpu_ext_pwr_lmt_info.ext_pwr_lmt_5g_band1[i]
82 = ext_pwr_lmt_info->ext_pwr_lmt_5g_band1[i];
83 tpu_ext_pwr_lmt_info.ext_pwr_lmt_5g_band2[i]
84 = ext_pwr_lmt_info->ext_pwr_lmt_5g_band2[i];
85 tpu_ext_pwr_lmt_info.ext_pwr_lmt_5g_band3[i]
86 = ext_pwr_lmt_info->ext_pwr_lmt_5g_band3[i];
87 tpu_ext_pwr_lmt_info.ext_pwr_lmt_5g_band4[i]
88 = ext_pwr_lmt_info->ext_pwr_lmt_5g_band4[i];
89 }
90
91 rtw_hal_enable_ext_pwr_lmt(phl_info->hal, hw_band,
92 &tpu_ext_pwr_lmt_info);
93 }
94
95
96