phy.c (196dd92a00ff0e8186d89b2d3d0f848ecc701cd9) phy.c (d9112042d9942648825d3ebe837dd33dbd7c6ddb)
1// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2/* Copyright(c) 2019-2020 Realtek Corporation
3 */
4
5#include "debug.h"
6#include "fw.h"
7#include "mac.h"
8#include "phy.h"

--- 787 unchanged lines hidden (view full) ---

796
797 if (ad_sel)
798 return rtw89_phy_write_rf(rtwdev, rf_path, addr, mask, data);
799 else
800 return rtw89_phy_write_rf_a(rtwdev, rf_path, addr, mask, data);
801}
802EXPORT_SYMBOL(rtw89_phy_write_rf_v1);
803
1// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2/* Copyright(c) 2019-2020 Realtek Corporation
3 */
4
5#include "debug.h"
6#include "fw.h"
7#include "mac.h"
8#include "phy.h"

--- 787 unchanged lines hidden (view full) ---

796
797 if (ad_sel)
798 return rtw89_phy_write_rf(rtwdev, rf_path, addr, mask, data);
799 else
800 return rtw89_phy_write_rf_a(rtwdev, rf_path, addr, mask, data);
801}
802EXPORT_SYMBOL(rtw89_phy_write_rf_v1);
803
804static bool rtw89_chip_rf_v1(struct rtw89_dev *rtwdev)
805{
806 return rtwdev->chip->ops->write_rf == rtw89_phy_write_rf_v1;
807}
808
804static void rtw89_phy_bb_reset(struct rtw89_dev *rtwdev,
805 enum rtw89_phy_idx phy_idx)
806{
807 const struct rtw89_chip_info *chip = rtwdev->chip;
808
809 chip->ops->bb_reset(rtwdev, phy_idx);
810}
811

--- 306 unchanged lines hidden (view full) ---

1118 goto out;
1119 }
1120out:
1121 info->curr_idx = 0;
1122
1123 return ret;
1124}
1125
809static void rtw89_phy_bb_reset(struct rtw89_dev *rtwdev,
810 enum rtw89_phy_idx phy_idx)
811{
812 const struct rtw89_chip_info *chip = rtwdev->chip;
813
814 chip->ops->bb_reset(rtwdev, phy_idx);
815}
816

--- 306 unchanged lines hidden (view full) ---

1123 goto out;
1124 }
1125out:
1126 info->curr_idx = 0;
1127
1128 return ret;
1129}
1130
1131static void rtw89_phy_config_rf_reg_noio(struct rtw89_dev *rtwdev,
1132 const struct rtw89_reg2_def *reg,
1133 enum rtw89_rf_path rf_path,
1134 void *extra_data)
1135{
1136 u32 addr = reg->addr;
1137
1138 if (addr == 0xfe || addr == 0xfd || addr == 0xfc || addr == 0xfb ||
1139 addr == 0xfa || addr == 0xf9)
1140 return;
1141
1142 if (rtw89_chip_rf_v1(rtwdev) && addr < 0x100)
1143 return;
1144
1145 rtw89_phy_cofig_rf_reg_store(rtwdev, reg, rf_path,
1146 (struct rtw89_fw_h2c_rf_reg_info *)extra_data);
1147}
1148
1126static void rtw89_phy_config_rf_reg(struct rtw89_dev *rtwdev,
1127 const struct rtw89_reg2_def *reg,
1128 enum rtw89_rf_path rf_path,
1129 void *extra_data)
1130{
1131 if (reg->addr == 0xfe) {
1132 mdelay(50);
1133 } else if (reg->addr == 0xfd) {

--- 196 unchanged lines hidden (view full) ---

1330
1331static u32 rtw89_phy_nctl_poll(struct rtw89_dev *rtwdev)
1332{
1333 rtw89_phy_write32(rtwdev, 0x8080, 0x4);
1334 udelay(1);
1335 return rtw89_phy_read32(rtwdev, 0x8080);
1336}
1337
1149static void rtw89_phy_config_rf_reg(struct rtw89_dev *rtwdev,
1150 const struct rtw89_reg2_def *reg,
1151 enum rtw89_rf_path rf_path,
1152 void *extra_data)
1153{
1154 if (reg->addr == 0xfe) {
1155 mdelay(50);
1156 } else if (reg->addr == 0xfd) {

--- 196 unchanged lines hidden (view full) ---

1353
1354static u32 rtw89_phy_nctl_poll(struct rtw89_dev *rtwdev)
1355{
1356 rtw89_phy_write32(rtwdev, 0x8080, 0x4);
1357 udelay(1);
1358 return rtw89_phy_read32(rtwdev, 0x8080);
1359}
1360
1338void rtw89_phy_init_rf_reg(struct rtw89_dev *rtwdev)
1361void rtw89_phy_init_rf_reg(struct rtw89_dev *rtwdev, bool noio)
1339{
1340 void (*config)(struct rtw89_dev *rtwdev, const struct rtw89_reg2_def *reg,
1341 enum rtw89_rf_path rf_path, void *data);
1342 const struct rtw89_chip_info *chip = rtwdev->chip;
1343 const struct rtw89_phy_table *rf_table;
1344 struct rtw89_fw_h2c_rf_reg_info *rf_reg_info;
1345 u8 path;
1346
1347 rf_reg_info = kzalloc(sizeof(*rf_reg_info), GFP_KERNEL);
1348 if (!rf_reg_info)
1349 return;
1350
1351 for (path = RF_PATH_A; path < chip->rf_path_num; path++) {
1352 rf_table = chip->rf_table[path];
1353 rf_reg_info->rf_path = rf_table->rf_path;
1362{
1363 void (*config)(struct rtw89_dev *rtwdev, const struct rtw89_reg2_def *reg,
1364 enum rtw89_rf_path rf_path, void *data);
1365 const struct rtw89_chip_info *chip = rtwdev->chip;
1366 const struct rtw89_phy_table *rf_table;
1367 struct rtw89_fw_h2c_rf_reg_info *rf_reg_info;
1368 u8 path;
1369
1370 rf_reg_info = kzalloc(sizeof(*rf_reg_info), GFP_KERNEL);
1371 if (!rf_reg_info)
1372 return;
1373
1374 for (path = RF_PATH_A; path < chip->rf_path_num; path++) {
1375 rf_table = chip->rf_table[path];
1376 rf_reg_info->rf_path = rf_table->rf_path;
1354 config = rf_table->config ? rf_table->config : rtw89_phy_config_rf_reg;
1377 if (noio)
1378 config = rtw89_phy_config_rf_reg_noio;
1379 else
1380 config = rf_table->config ? rf_table->config :
1381 rtw89_phy_config_rf_reg;
1355 rtw89_phy_init_reg(rtwdev, rf_table, config, (void *)rf_reg_info);
1356 if (rtw89_phy_config_rf_reg_fw(rtwdev, rf_reg_info))
1357 rtw89_warn(rtwdev, "rf path %d reg h2c config failed\n",
1358 rf_reg_info->rf_path);
1359 }
1360 kfree(rf_reg_info);
1361}
1362

--- 2777 unchanged lines hidden ---
1382 rtw89_phy_init_reg(rtwdev, rf_table, config, (void *)rf_reg_info);
1383 if (rtw89_phy_config_rf_reg_fw(rtwdev, rf_reg_info))
1384 rtw89_warn(rtwdev, "rf path %d reg h2c config failed\n",
1385 rf_reg_info->rf_path);
1386 }
1387 kfree(rf_reg_info);
1388}
1389

--- 2777 unchanged lines hidden ---