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 _HAL_EXT_TX_PWR_LMT_C_
16 #include "hal_headers.h"
17
18
19 enum rtw_hal_status
rtw_hal_set_power_lmt(void * hal,u8 band_idx)20 rtw_hal_set_power_lmt(void *hal, u8 band_idx)
21 {
22 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
23 enum rtw_hal_status status = RTW_HAL_STATUS_SUCCESS;
24 enum phl_phy_idx phy_idx = HW_PHY_0;
25
26 if (band_idx == 1)
27 phy_idx = HW_PHY_1;
28
29 status = rtw_hal_rf_set_power(hal_info, phy_idx, PWR_LIMIT);
30
31 return status;
32 }
33
34 void
rtw_hal_set_ext_pwr_lmt_en(void * hal,bool enable)35 rtw_hal_set_ext_pwr_lmt_en(void *hal,
36 bool enable)
37 {
38 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
39 struct rtw_hal_com_t *hal_com = hal_info->hal_com;
40
41 PHL_INFO("%s: en(%d)\n", __func__, enable);
42
43 hal_com->ext_pwr_lmt_en = enable;
44 }
45
46 void
rtw_hal_enable_ext_pwr_lmt(void * hal,u8 hw_band,struct rtw_tpu_ext_pwr_lmt_info * ext_pwr_lmt_info)47 rtw_hal_enable_ext_pwr_lmt(void *hal, u8 hw_band,
48 struct rtw_tpu_ext_pwr_lmt_info *ext_pwr_lmt_info)
49 {
50 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
51 struct rtw_hal_com_t *hal_com = hal_info->hal_com;
52 struct rtw_tpu_ext_pwr_lmt_info *tpu_ext_pwr_lmt_info;
53 u8 i;
54
55 PHL_INFO("%s\n", __func__);
56
57 tpu_ext_pwr_lmt_info = &(hal_com->rtw_tpu_ext_pwr_lmt_i[hw_band]);
58
59 /* Fill external tx power limit into hal_com->rtw_tpu_ext_pwr_lmt_info */
60 for (i = 0; i < HAL_MAX_PATH; i++) {
61 tpu_ext_pwr_lmt_info->ext_pwr_lmt_2_4g[i]
62 = ext_pwr_lmt_info->ext_pwr_lmt_2_4g[i];
63
64 tpu_ext_pwr_lmt_info->ext_pwr_lmt_5g_band1[i]
65 = ext_pwr_lmt_info->ext_pwr_lmt_5g_band1[i];
66 tpu_ext_pwr_lmt_info->ext_pwr_lmt_5g_band2[i]
67 = ext_pwr_lmt_info->ext_pwr_lmt_5g_band2[i];
68 tpu_ext_pwr_lmt_info->ext_pwr_lmt_5g_band3[i]
69 = ext_pwr_lmt_info->ext_pwr_lmt_5g_band3[i];
70 tpu_ext_pwr_lmt_info->ext_pwr_lmt_5g_band4[i]
71 = ext_pwr_lmt_info->ext_pwr_lmt_5g_band4[i];
72 }
73
74 rtw_hal_rf_update_ext_pwr_lmt_table(hal_info);
75
76 /* enable external tx power limit mechanism */
77 hal_com->ext_pwr_lmt_en = true;
78 }
79
80