Commit c376c1fc authored by Tzu-En Huang's avatar Tzu-En Huang Committed by Kalle Valo

rtw88: add h2c command in debugfs

It's very useful to send H2C command for debug usage. Add an entry
for sending H2C command to firmware.

usage example:
echo 42,00,00,43,02,00,00,00 > /sys/kernel/debug/ieee80211/phyX/rtw88
Signed-off-by: default avatarTzu-En Huang <tehuang@realtek.com>
Signed-off-by: default avatarYan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200717064937.27966-8-yhchuang@realtek.com
parent 752310ed
...@@ -344,6 +344,31 @@ static ssize_t rtw_debugfs_set_write_reg(struct file *filp, ...@@ -344,6 +344,31 @@ static ssize_t rtw_debugfs_set_write_reg(struct file *filp,
return count; return count;
} }
static ssize_t rtw_debugfs_set_h2c(struct file *filp,
const char __user *buffer,
size_t count, loff_t *loff)
{
struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
char tmp[32 + 1];
u8 param[8];
int num;
rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
num = sscanf(tmp, "%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx",
&param[0], &param[1], &param[2], &param[3],
&param[4], &param[5], &param[6], &param[7]);
if (num != 8) {
rtw_info(rtwdev, "invalid H2C command format for debug\n");
return -EINVAL;
}
rtw_fw_h2c_cmd_dbg(rtwdev, param);
return count;
}
static ssize_t rtw_debugfs_set_rf_write(struct file *filp, static ssize_t rtw_debugfs_set_rf_write(struct file *filp,
const char __user *buffer, const char __user *buffer,
size_t count, loff_t *loff) size_t count, loff_t *loff)
...@@ -808,6 +833,10 @@ static struct rtw_debugfs_priv rtw_debug_priv_write_reg = { ...@@ -808,6 +833,10 @@ static struct rtw_debugfs_priv rtw_debug_priv_write_reg = {
.cb_write = rtw_debugfs_set_write_reg, .cb_write = rtw_debugfs_set_write_reg,
}; };
static struct rtw_debugfs_priv rtw_debug_priv_h2c = {
.cb_write = rtw_debugfs_set_h2c,
};
static struct rtw_debugfs_priv rtw_debug_priv_rf_write = { static struct rtw_debugfs_priv rtw_debug_priv_rf_write = {
.cb_write = rtw_debugfs_set_rf_write, .cb_write = rtw_debugfs_set_rf_write,
}; };
...@@ -877,6 +906,7 @@ void rtw_debugfs_init(struct rtw_dev *rtwdev) ...@@ -877,6 +906,7 @@ void rtw_debugfs_init(struct rtw_dev *rtwdev)
rtw_debugfs_add_r(phy_info); rtw_debugfs_add_r(phy_info);
rtw_debugfs_add_r(coex_info); rtw_debugfs_add_r(coex_info);
rtw_debugfs_add_rw(coex_enable); rtw_debugfs_add_rw(coex_enable);
rtw_debugfs_add_w(h2c);
rtw_debugfs_add_r(mac_0); rtw_debugfs_add_r(mac_0);
rtw_debugfs_add_r(mac_1); rtw_debugfs_add_r(mac_1);
rtw_debugfs_add_r(mac_2); rtw_debugfs_add_r(mac_2);
......
...@@ -253,6 +253,11 @@ static void rtw_fw_send_h2c_command(struct rtw_dev *rtwdev, ...@@ -253,6 +253,11 @@ static void rtw_fw_send_h2c_command(struct rtw_dev *rtwdev,
spin_unlock(&rtwdev->h2c.lock); spin_unlock(&rtwdev->h2c.lock);
} }
void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c)
{
rtw_fw_send_h2c_command(rtwdev, h2c);
}
static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt) static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt)
{ {
int ret; int ret;
......
...@@ -563,4 +563,6 @@ void rtw_fw_set_nlo_info(struct rtw_dev *rtwdev, bool enable); ...@@ -563,4 +563,6 @@ void rtw_fw_set_nlo_info(struct rtw_dev *rtwdev, bool enable);
void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev, void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev,
struct cfg80211_ssid *ssid); struct cfg80211_ssid *ssid);
void rtw_fw_channel_switch(struct rtw_dev *rtwdev, bool enable); void rtw_fw_channel_switch(struct rtw_dev *rtwdev, bool enable);
void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment