mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-28 11:49:32 +00:00
rtw88: new Realtek 802.11ac driver
This is a new mac80211 driver for Realtek 802.11ac wireless network chips. rtw88 now supports RTL8822BE/RTL8822CE now, with basic station mode functionalities. The firmware for both can be found at linux-firmware. https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git For RTL8822BE: rtw88/rtw8822b_fw.bin For RTL8822CE: rtw88/rtw8822c_fw.bin And for now, only PCI buses (RTL8xxxE) are supported. We will add support for USB and SDIO in the future. The bus interface abstraction can be seen in this driver such as hci.h. Most of the hardware setting are the same except for some TRX path or probing setup should be separated. Supported: * Basic STA/AP/ADHOC mode, and TDLS (STA is well tested) Missing feature: * WOW/PNO * USB & SDIO bus (such as RTL8xxxU/RTL8xxxS) * BT coexistence (8822B/8822C are combo ICs) * Multiple interfaces (for now single STA is better supported) * Dynamic hardware calibrations (to improve/stabilize performance) Potential problems: * static calibration spends too much time, and it is painful for driver to leave IDLE state. And slows down associate process. But reload function are under development, will be added soon! * TRX statictics misleading, as we are not reporting status correctly, or say, not reporting for "every" packet. The next patch set should have BT coexistence code since RTL8822B/C are combo ICs, and the driver for BT can be found after Linux Kernel v4.20. So it is better to add it first to make WiFi + BT work concurrently. Although now rtw88 is simple but we are developing more features for it. Even we want to add support for more chips such as RTL8821C/RTL8814B. Finally, rtw88 has many authors, listed alphabetically: Ping-Ke Shih <pkshih@realtek.com> Tzu-En Huang <tehuang@realtek.com> Yan-Hsuan Chuang <yhchuang@realtek.com> Reviewed-by: Stanislaw Gruszka <sgruszka@redhat.com> Reviewed-by: Brian Norris <briannorris@chromium.org> Tested-by: Brian Norris <briannorris@chromium.org> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
parent
c745f72266
commit
e3037485c6
42 changed files with 47514 additions and 0 deletions
|
@ -13396,6 +13396,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-testing.g
|
|||
S: Maintained
|
||||
F: drivers/net/wireless/realtek/rtlwifi/
|
||||
|
||||
REALTEK WIRELESS DRIVER (rtw88)
|
||||
M: Yan-Hsuan Chuang <yhchuang@realtek.com>
|
||||
L: linux-wireless@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/net/wireless/realtek/rtw88/
|
||||
|
||||
RTL8XXXU WIRELESS DRIVER (rtl8xxxu)
|
||||
M: Jes Sorensen <Jes.Sorensen@gmail.com>
|
||||
L: linux-wireless@vger.kernel.org
|
||||
|
|
|
@ -14,5 +14,6 @@ if WLAN_VENDOR_REALTEK
|
|||
source "drivers/net/wireless/realtek/rtl818x/Kconfig"
|
||||
source "drivers/net/wireless/realtek/rtlwifi/Kconfig"
|
||||
source "drivers/net/wireless/realtek/rtl8xxxu/Kconfig"
|
||||
source "drivers/net/wireless/realtek/rtw88/Kconfig"
|
||||
|
||||
endif # WLAN_VENDOR_REALTEK
|
||||
|
|
|
@ -6,4 +6,5 @@ obj-$(CONFIG_RTL8180) += rtl818x/
|
|||
obj-$(CONFIG_RTL8187) += rtl818x/
|
||||
obj-$(CONFIG_RTLWIFI) += rtlwifi/
|
||||
obj-$(CONFIG_RTL8XXXU) += rtl8xxxu/
|
||||
obj-$(CONFIG_RTW88) += rtw88/
|
||||
|
||||
|
|
54
drivers/net/wireless/realtek/rtw88/Kconfig
Normal file
54
drivers/net/wireless/realtek/rtw88/Kconfig
Normal file
|
@ -0,0 +1,54 @@
|
|||
menuconfig RTW88
|
||||
tristate "Realtek 802.11ac wireless chips support"
|
||||
depends on MAC80211
|
||||
help
|
||||
This module adds support for mac80211-based wireless drivers that
|
||||
enables Realtek IEEE 802.11ac wireless chipsets.
|
||||
|
||||
If you choose to build a module, it'll be called rtw88.
|
||||
|
||||
if RTW88
|
||||
|
||||
config RTW88_CORE
|
||||
tristate
|
||||
|
||||
config RTW88_PCI
|
||||
tristate
|
||||
|
||||
config RTW88_8822BE
|
||||
bool "Realtek 8822BE PCI wireless network adapter"
|
||||
depends on PCI
|
||||
select RTW88_CORE
|
||||
select RTW88_PCI
|
||||
help
|
||||
Select this option will enable support for 8822BE chipset
|
||||
|
||||
802.11ac PCIe wireless network adapter
|
||||
|
||||
config RTW88_8822CE
|
||||
bool "Realtek 8822CE PCI wireless network adapter"
|
||||
depends on PCI
|
||||
select RTW88_CORE
|
||||
select RTW88_PCI
|
||||
help
|
||||
Select this option will enable support for 8822CE chipset
|
||||
|
||||
802.11ac PCIe wireless network adapter
|
||||
|
||||
config RTW88_DEBUG
|
||||
bool "Realtek rtw88 debug support"
|
||||
depends on RTW88_CORE
|
||||
help
|
||||
Enable debug support
|
||||
|
||||
If unsure, say Y to simplify debug problems
|
||||
|
||||
config RTW88_DEBUGFS
|
||||
bool "Realtek rtw88 debugfs support"
|
||||
depends on RTW88_CORE
|
||||
help
|
||||
Enable debug support
|
||||
|
||||
If unsure, say Y to simplify debug problems
|
||||
|
||||
endif
|
20
drivers/net/wireless/realtek/rtw88/Makefile
Normal file
20
drivers/net/wireless/realtek/rtw88/Makefile
Normal file
|
@ -0,0 +1,20 @@
|
|||
obj-$(CONFIG_RTW88_CORE) += rtw88.o
|
||||
rtw88-y += main.o \
|
||||
mac80211.o \
|
||||
util.o \
|
||||
debug.o \
|
||||
tx.o \
|
||||
rx.o \
|
||||
mac.o \
|
||||
phy.o \
|
||||
efuse.o \
|
||||
fw.o \
|
||||
ps.o \
|
||||
sec.o \
|
||||
regd.o
|
||||
|
||||
rtw88-$(CONFIG_RTW88_8822BE) += rtw8822b.o rtw8822b_table.o
|
||||
rtw88-$(CONFIG_RTW88_8822CE) += rtw8822c.o rtw8822c_table.o
|
||||
|
||||
obj-$(CONFIG_RTW88_PCI) += rtwpci.o
|
||||
rtwpci-objs := pci.o
|
637
drivers/net/wireless/realtek/rtw88/debug.c
Normal file
637
drivers/net/wireless/realtek/rtw88/debug.c
Normal file
|
@ -0,0 +1,637 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include "main.h"
|
||||
#include "sec.h"
|
||||
#include "fw.h"
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef CONFIG_RTW88_DEBUGFS
|
||||
|
||||
struct rtw_debugfs_priv {
|
||||
struct rtw_dev *rtwdev;
|
||||
int (*cb_read)(struct seq_file *m, void *v);
|
||||
ssize_t (*cb_write)(struct file *filp, const char __user *buffer,
|
||||
size_t count, loff_t *loff);
|
||||
union {
|
||||
u32 cb_data;
|
||||
u8 *buf;
|
||||
struct {
|
||||
u32 page_offset;
|
||||
u32 page_num;
|
||||
} rsvd_page;
|
||||
struct {
|
||||
u8 rf_path;
|
||||
u32 rf_addr;
|
||||
u32 rf_mask;
|
||||
};
|
||||
struct {
|
||||
u32 addr;
|
||||
u32 len;
|
||||
} read_reg;
|
||||
};
|
||||
};
|
||||
|
||||
static int rtw_debugfs_single_show(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtw_debugfs_priv *debugfs_priv = m->private;
|
||||
|
||||
return debugfs_priv->cb_read(m, v);
|
||||
}
|
||||
|
||||
static ssize_t rtw_debugfs_common_write(struct file *filp,
|
||||
const char __user *buffer,
|
||||
size_t count, loff_t *loff)
|
||||
{
|
||||
struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
|
||||
|
||||
return debugfs_priv->cb_write(filp, buffer, count, loff);
|
||||
}
|
||||
|
||||
static ssize_t rtw_debugfs_single_write(struct file *filp,
|
||||
const char __user *buffer,
|
||||
size_t count, loff_t *loff)
|
||||
{
|
||||
struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
|
||||
struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
|
||||
|
||||
return debugfs_priv->cb_write(filp, buffer, count, loff);
|
||||
}
|
||||
|
||||
static int rtw_debugfs_single_open_rw(struct inode *inode, struct file *filp)
|
||||
{
|
||||
return single_open(filp, rtw_debugfs_single_show, inode->i_private);
|
||||
}
|
||||
|
||||
static int rtw_debugfs_close(struct inode *inode, struct file *filp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct file_operations file_ops_single_r = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = rtw_debugfs_single_open_rw,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = seq_release,
|
||||
};
|
||||
|
||||
static const struct file_operations file_ops_single_rw = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = rtw_debugfs_single_open_rw,
|
||||
.release = single_release,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.write = rtw_debugfs_single_write,
|
||||
};
|
||||
|
||||
static const struct file_operations file_ops_common_write = {
|
||||
.owner = THIS_MODULE,
|
||||
.write = rtw_debugfs_common_write,
|
||||
.open = simple_open,
|
||||
.release = rtw_debugfs_close,
|
||||
};
|
||||
|
||||
static int rtw_debugfs_get_read_reg(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtw_debugfs_priv *debugfs_priv = m->private;
|
||||
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
|
||||
u32 val, len, addr;
|
||||
|
||||
len = debugfs_priv->read_reg.len;
|
||||
addr = debugfs_priv->read_reg.addr;
|
||||
switch (len) {
|
||||
case 1:
|
||||
val = rtw_read8(rtwdev, addr);
|
||||
seq_printf(m, "reg 0x%03x: 0x%02x\n", addr, val);
|
||||
break;
|
||||
case 2:
|
||||
val = rtw_read16(rtwdev, addr);
|
||||
seq_printf(m, "reg 0x%03x: 0x%04x\n", addr, val);
|
||||
break;
|
||||
case 4:
|
||||
val = rtw_read32(rtwdev, addr);
|
||||
seq_printf(m, "reg 0x%03x: 0x%08x\n", addr, val);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_debugfs_get_rf_read(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtw_debugfs_priv *debugfs_priv = m->private;
|
||||
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
|
||||
u32 val, addr, mask;
|
||||
u8 path;
|
||||
|
||||
path = debugfs_priv->rf_path;
|
||||
addr = debugfs_priv->rf_addr;
|
||||
mask = debugfs_priv->rf_mask;
|
||||
|
||||
val = rtw_read_rf(rtwdev, path, addr, mask);
|
||||
|
||||
seq_printf(m, "rf_read path:%d addr:0x%08x mask:0x%08x val=0x%08x\n",
|
||||
path, addr, mask, val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_debugfs_copy_from_user(char tmp[], int size,
|
||||
const char __user *buffer, size_t count,
|
||||
int num)
|
||||
{
|
||||
int tmp_len;
|
||||
|
||||
if (count < num)
|
||||
return -EFAULT;
|
||||
|
||||
tmp_len = (count > size - 1 ? size - 1 : count);
|
||||
|
||||
if (!buffer || copy_from_user(tmp, buffer, tmp_len))
|
||||
return count;
|
||||
|
||||
tmp[tmp_len] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t rtw_debugfs_set_read_reg(struct file *filp,
|
||||
const char __user *buffer,
|
||||
size_t count, loff_t *loff)
|
||||
{
|
||||
struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
|
||||
struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
|
||||
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
|
||||
char tmp[32 + 1];
|
||||
u32 addr, len;
|
||||
int num;
|
||||
|
||||
rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
|
||||
|
||||
num = sscanf(tmp, "%x %x", &addr, &len);
|
||||
|
||||
if (num != 2)
|
||||
return count;
|
||||
|
||||
if (len != 1 && len != 2 && len != 4) {
|
||||
rtw_warn(rtwdev, "read reg setting wrong len\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
debugfs_priv->read_reg.addr = addr;
|
||||
debugfs_priv->read_reg.len = len;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static int rtw_debugfs_get_dump_cam(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtw_debugfs_priv *debugfs_priv = m->private;
|
||||
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
|
||||
u32 val, command;
|
||||
u32 hw_key_idx = debugfs_priv->cb_data << RTW_SEC_CAM_ENTRY_SHIFT;
|
||||
u32 read_cmd = RTW_SEC_CMD_POLLING;
|
||||
int i;
|
||||
|
||||
seq_printf(m, "cam entry%d\n", debugfs_priv->cb_data);
|
||||
seq_puts(m, "0x0 0x1 0x2 0x3 ");
|
||||
seq_puts(m, "0x4 0x5\n");
|
||||
mutex_lock(&rtwdev->mutex);
|
||||
for (i = 0; i <= 5; i++) {
|
||||
command = read_cmd | (hw_key_idx + i);
|
||||
rtw_write32(rtwdev, RTW_SEC_CMD_REG, command);
|
||||
val = rtw_read32(rtwdev, RTW_SEC_READ_REG);
|
||||
seq_printf(m, "%8.8x", val);
|
||||
if (i < 2)
|
||||
seq_puts(m, " ");
|
||||
}
|
||||
seq_puts(m, "\n");
|
||||
mutex_unlock(&rtwdev->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_debugfs_get_rsvd_page(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtw_debugfs_priv *debugfs_priv = m->private;
|
||||
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
|
||||
u8 page_size = rtwdev->chip->page_size;
|
||||
u32 buf_size = debugfs_priv->rsvd_page.page_num * page_size;
|
||||
u32 offset = debugfs_priv->rsvd_page.page_offset * page_size;
|
||||
u8 *buf;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
buf = vzalloc(buf_size);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = rtw_dump_drv_rsvd_page(rtwdev, offset, buf_size, (u32 *)buf);
|
||||
if (ret) {
|
||||
rtw_err(rtwdev, "failed to dump rsvd page\n");
|
||||
vfree(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < buf_size ; i += 8) {
|
||||
if (i % page_size == 0)
|
||||
seq_printf(m, "PAGE %d\n", (i + offset) / page_size);
|
||||
seq_printf(m, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
|
||||
*(buf + i), *(buf + i + 1),
|
||||
*(buf + i + 2), *(buf + i + 3),
|
||||
*(buf + i + 4), *(buf + i + 5),
|
||||
*(buf + i + 6), *(buf + i + 7));
|
||||
}
|
||||
vfree(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t rtw_debugfs_set_rsvd_page(struct file *filp,
|
||||
const char __user *buffer,
|
||||
size_t count, loff_t *loff)
|
||||
{
|
||||
struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
|
||||
struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
|
||||
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
|
||||
char tmp[32 + 1];
|
||||
u32 offset, page_num;
|
||||
int num;
|
||||
|
||||
rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
|
||||
|
||||
num = sscanf(tmp, "%d %d", &offset, &page_num);
|
||||
|
||||
if (num != 2) {
|
||||
rtw_warn(rtwdev, "invalid arguments\n");
|
||||
return num;
|
||||
}
|
||||
|
||||
debugfs_priv->rsvd_page.page_offset = offset;
|
||||
debugfs_priv->rsvd_page.page_num = page_num;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t rtw_debugfs_set_single_input(struct file *filp,
|
||||
const char __user *buffer,
|
||||
size_t count, loff_t *loff)
|
||||
{
|
||||
struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
|
||||
struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
|
||||
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
|
||||
char tmp[32 + 1];
|
||||
u32 input;
|
||||
int num;
|
||||
|
||||
rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 1);
|
||||
|
||||
num = kstrtoint(tmp, 0, &input);
|
||||
|
||||
if (num) {
|
||||
rtw_warn(rtwdev, "kstrtoint failed\n");
|
||||
return num;
|
||||
}
|
||||
|
||||
debugfs_priv->cb_data = input;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t rtw_debugfs_set_write_reg(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];
|
||||
u32 addr, val, len;
|
||||
int num;
|
||||
|
||||
rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
|
||||
|
||||
/* write BB/MAC register */
|
||||
num = sscanf(tmp, "%x %x %x", &addr, &val, &len);
|
||||
|
||||
if (num != 3)
|
||||
return count;
|
||||
|
||||
switch (len) {
|
||||
case 1:
|
||||
rtw_dbg(rtwdev, RTW_DBG_DEBUGFS,
|
||||
"reg write8 0x%03x: 0x%08x\n", addr, val);
|
||||
rtw_write8(rtwdev, addr, (u8)val);
|
||||
break;
|
||||
case 2:
|
||||
rtw_dbg(rtwdev, RTW_DBG_DEBUGFS,
|
||||
"reg write16 0x%03x: 0x%08x\n", addr, val);
|
||||
rtw_write16(rtwdev, addr, (u16)val);
|
||||
break;
|
||||
case 4:
|
||||
rtw_dbg(rtwdev, RTW_DBG_DEBUGFS,
|
||||
"reg write32 0x%03x: 0x%08x\n", addr, val);
|
||||
rtw_write32(rtwdev, addr, (u32)val);
|
||||
break;
|
||||
default:
|
||||
rtw_dbg(rtwdev, RTW_DBG_DEBUGFS,
|
||||
"error write length = %d\n", len);
|
||||
break;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t rtw_debugfs_set_rf_write(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];
|
||||
u32 path, addr, mask, val;
|
||||
int num;
|
||||
|
||||
rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 4);
|
||||
|
||||
num = sscanf(tmp, "%x %x %x %x", &path, &addr, &mask, &val);
|
||||
|
||||
if (num != 4) {
|
||||
rtw_warn(rtwdev, "invalid args, [path] [addr] [mask] [val]\n");
|
||||
return count;
|
||||
}
|
||||
|
||||
rtw_write_rf(rtwdev, path, addr, mask, val);
|
||||
rtw_dbg(rtwdev, RTW_DBG_DEBUGFS,
|
||||
"write_rf path:%d addr:0x%08x mask:0x%08x, val:0x%08x\n",
|
||||
path, addr, mask, val);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t rtw_debugfs_set_rf_read(struct file *filp,
|
||||
const char __user *buffer,
|
||||
size_t count, loff_t *loff)
|
||||
{
|
||||
struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
|
||||
struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
|
||||
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
|
||||
char tmp[32 + 1];
|
||||
u32 path, addr, mask;
|
||||
int num;
|
||||
|
||||
rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
|
||||
|
||||
num = sscanf(tmp, "%x %x %x", &path, &addr, &mask);
|
||||
|
||||
if (num != 3) {
|
||||
rtw_warn(rtwdev, "invalid args, [path] [addr] [mask] [val]\n");
|
||||
return count;
|
||||
}
|
||||
|
||||
debugfs_priv->rf_path = path;
|
||||
debugfs_priv->rf_addr = addr;
|
||||
debugfs_priv->rf_mask = mask;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static int rtw_debug_get_mac_page(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtw_debugfs_priv *debugfs_priv = m->private;
|
||||
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
|
||||
u32 val;
|
||||
u32 page = debugfs_priv->cb_data;
|
||||
int i, n;
|
||||
int max = 0xff;
|
||||
|
||||
val = rtw_read32(rtwdev, debugfs_priv->cb_data);
|
||||
for (n = 0; n <= max; ) {
|
||||
seq_printf(m, "\n%8.8x ", n + page);
|
||||
for (i = 0; i < 4 && n <= max; i++, n += 4)
|
||||
seq_printf(m, "%8.8x ",
|
||||
rtw_read32(rtwdev, (page | n)));
|
||||
}
|
||||
seq_puts(m, "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_debug_get_bb_page(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtw_debugfs_priv *debugfs_priv = m->private;
|
||||
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
|
||||
u32 val;
|
||||
u32 page = debugfs_priv->cb_data;
|
||||
int i, n;
|
||||
int max = 0xff;
|
||||
|
||||
val = rtw_read32(rtwdev, debugfs_priv->cb_data);
|
||||
for (n = 0; n <= max; ) {
|
||||
seq_printf(m, "\n%8.8x ", n + page);
|
||||
for (i = 0; i < 4 && n <= max; i++, n += 4)
|
||||
seq_printf(m, "%8.8x ",
|
||||
rtw_read32(rtwdev, (page | n)));
|
||||
}
|
||||
seq_puts(m, "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_debug_get_rf_dump(struct seq_file *m, void *v)
|
||||
{
|
||||
struct rtw_debugfs_priv *debugfs_priv = m->private;
|
||||
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
|
||||
u32 addr, offset, data;
|
||||
u8 path;
|
||||
|
||||
for (path = 0; path < rtwdev->hal.rf_path_num; path++) {
|
||||
seq_printf(m, "RF path:%d\n", path);
|
||||
for (addr = 0; addr < 0x100; addr += 4) {
|
||||
seq_printf(m, "%8.8x ", addr);
|
||||
for (offset = 0; offset < 4; offset++) {
|
||||
data = rtw_read_rf(rtwdev, path, addr + offset,
|
||||
0xffffffff);
|
||||
seq_printf(m, "%8.8x ", data);
|
||||
}
|
||||
seq_puts(m, "\n");
|
||||
}
|
||||
seq_puts(m, "\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define rtw_debug_impl_mac(page, addr) \
|
||||
static struct rtw_debugfs_priv rtw_debug_priv_mac_ ##page = { \
|
||||
.cb_read = rtw_debug_get_mac_page, \
|
||||
.cb_data = addr, \
|
||||
}
|
||||
|
||||
rtw_debug_impl_mac(0, 0x0000);
|
||||
rtw_debug_impl_mac(1, 0x0100);
|
||||
rtw_debug_impl_mac(2, 0x0200);
|
||||
rtw_debug_impl_mac(3, 0x0300);
|
||||
rtw_debug_impl_mac(4, 0x0400);
|
||||
rtw_debug_impl_mac(5, 0x0500);
|
||||
rtw_debug_impl_mac(6, 0x0600);
|
||||
rtw_debug_impl_mac(7, 0x0700);
|
||||
rtw_debug_impl_mac(10, 0x1000);
|
||||
rtw_debug_impl_mac(11, 0x1100);
|
||||
rtw_debug_impl_mac(12, 0x1200);
|
||||
rtw_debug_impl_mac(13, 0x1300);
|
||||
rtw_debug_impl_mac(14, 0x1400);
|
||||
rtw_debug_impl_mac(15, 0x1500);
|
||||
rtw_debug_impl_mac(16, 0x1600);
|
||||
rtw_debug_impl_mac(17, 0x1700);
|
||||
|
||||
#define rtw_debug_impl_bb(page, addr) \
|
||||
static struct rtw_debugfs_priv rtw_debug_priv_bb_ ##page = { \
|
||||
.cb_read = rtw_debug_get_bb_page, \
|
||||
.cb_data = addr, \
|
||||
}
|
||||
|
||||
rtw_debug_impl_bb(8, 0x0800);
|
||||
rtw_debug_impl_bb(9, 0x0900);
|
||||
rtw_debug_impl_bb(a, 0x0a00);
|
||||
rtw_debug_impl_bb(b, 0x0b00);
|
||||
rtw_debug_impl_bb(c, 0x0c00);
|
||||
rtw_debug_impl_bb(d, 0x0d00);
|
||||
rtw_debug_impl_bb(e, 0x0e00);
|
||||
rtw_debug_impl_bb(f, 0x0f00);
|
||||
rtw_debug_impl_bb(18, 0x1800);
|
||||
rtw_debug_impl_bb(19, 0x1900);
|
||||
rtw_debug_impl_bb(1a, 0x1a00);
|
||||
rtw_debug_impl_bb(1b, 0x1b00);
|
||||
rtw_debug_impl_bb(1c, 0x1c00);
|
||||
rtw_debug_impl_bb(1d, 0x1d00);
|
||||
rtw_debug_impl_bb(1e, 0x1e00);
|
||||
rtw_debug_impl_bb(1f, 0x1f00);
|
||||
rtw_debug_impl_bb(2c, 0x2c00);
|
||||
rtw_debug_impl_bb(2d, 0x2d00);
|
||||
rtw_debug_impl_bb(40, 0x4000);
|
||||
rtw_debug_impl_bb(41, 0x4100);
|
||||
|
||||
static struct rtw_debugfs_priv rtw_debug_priv_rf_dump = {
|
||||
.cb_read = rtw_debug_get_rf_dump,
|
||||
};
|
||||
|
||||
static struct rtw_debugfs_priv rtw_debug_priv_write_reg = {
|
||||
.cb_write = rtw_debugfs_set_write_reg,
|
||||
};
|
||||
|
||||
static struct rtw_debugfs_priv rtw_debug_priv_rf_write = {
|
||||
.cb_write = rtw_debugfs_set_rf_write,
|
||||
};
|
||||
|
||||
static struct rtw_debugfs_priv rtw_debug_priv_rf_read = {
|
||||
.cb_write = rtw_debugfs_set_rf_read,
|
||||
.cb_read = rtw_debugfs_get_rf_read,
|
||||
};
|
||||
|
||||
static struct rtw_debugfs_priv rtw_debug_priv_read_reg = {
|
||||
.cb_write = rtw_debugfs_set_read_reg,
|
||||
.cb_read = rtw_debugfs_get_read_reg,
|
||||
};
|
||||
|
||||
static struct rtw_debugfs_priv rtw_debug_priv_dump_cam = {
|
||||
.cb_write = rtw_debugfs_set_single_input,
|
||||
.cb_read = rtw_debugfs_get_dump_cam,
|
||||
};
|
||||
|
||||
static struct rtw_debugfs_priv rtw_debug_priv_rsvd_page = {
|
||||
.cb_write = rtw_debugfs_set_rsvd_page,
|
||||
.cb_read = rtw_debugfs_get_rsvd_page,
|
||||
};
|
||||
|
||||
#define rtw_debugfs_add_core(name, mode, fopname, parent) \
|
||||
do { \
|
||||
rtw_debug_priv_ ##name.rtwdev = rtwdev; \
|
||||
if (!debugfs_create_file(#name, mode, \
|
||||
parent, &rtw_debug_priv_ ##name,\
|
||||
&file_ops_ ##fopname)) \
|
||||
pr_debug("Unable to initialize debugfs:%s\n", \
|
||||
#name); \
|
||||
} while (0)
|
||||
|
||||
#define rtw_debugfs_add_w(name) \
|
||||
rtw_debugfs_add_core(name, S_IFREG | 0222, common_write, debugfs_topdir)
|
||||
#define rtw_debugfs_add_rw(name) \
|
||||
rtw_debugfs_add_core(name, S_IFREG | 0666, single_rw, debugfs_topdir)
|
||||
#define rtw_debugfs_add_r(name) \
|
||||
rtw_debugfs_add_core(name, S_IFREG | 0444, single_r, debugfs_topdir)
|
||||
|
||||
void rtw_debugfs_init(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct dentry *debugfs_topdir = rtwdev->debugfs;
|
||||
|
||||
debugfs_topdir = debugfs_create_dir("rtw88",
|
||||
rtwdev->hw->wiphy->debugfsdir);
|
||||
rtw_debugfs_add_w(write_reg);
|
||||
rtw_debugfs_add_rw(read_reg);
|
||||
rtw_debugfs_add_w(rf_write);
|
||||
rtw_debugfs_add_rw(rf_read);
|
||||
rtw_debugfs_add_rw(dump_cam);
|
||||
rtw_debugfs_add_rw(rsvd_page);
|
||||
rtw_debugfs_add_r(mac_0);
|
||||
rtw_debugfs_add_r(mac_1);
|
||||
rtw_debugfs_add_r(mac_2);
|
||||
rtw_debugfs_add_r(mac_3);
|
||||
rtw_debugfs_add_r(mac_4);
|
||||
rtw_debugfs_add_r(mac_5);
|
||||
rtw_debugfs_add_r(mac_6);
|
||||
rtw_debugfs_add_r(mac_7);
|
||||
rtw_debugfs_add_r(bb_8);
|
||||
rtw_debugfs_add_r(bb_9);
|
||||
rtw_debugfs_add_r(bb_a);
|
||||
rtw_debugfs_add_r(bb_b);
|
||||
rtw_debugfs_add_r(bb_c);
|
||||
rtw_debugfs_add_r(bb_d);
|
||||
rtw_debugfs_add_r(bb_e);
|
||||
rtw_debugfs_add_r(bb_f);
|
||||
rtw_debugfs_add_r(mac_10);
|
||||
rtw_debugfs_add_r(mac_11);
|
||||
rtw_debugfs_add_r(mac_12);
|
||||
rtw_debugfs_add_r(mac_13);
|
||||
rtw_debugfs_add_r(mac_14);
|
||||
rtw_debugfs_add_r(mac_15);
|
||||
rtw_debugfs_add_r(mac_16);
|
||||
rtw_debugfs_add_r(mac_17);
|
||||
rtw_debugfs_add_r(bb_18);
|
||||
rtw_debugfs_add_r(bb_19);
|
||||
rtw_debugfs_add_r(bb_1a);
|
||||
rtw_debugfs_add_r(bb_1b);
|
||||
rtw_debugfs_add_r(bb_1c);
|
||||
rtw_debugfs_add_r(bb_1d);
|
||||
rtw_debugfs_add_r(bb_1e);
|
||||
rtw_debugfs_add_r(bb_1f);
|
||||
if (rtwdev->chip->id == RTW_CHIP_TYPE_8822C) {
|
||||
rtw_debugfs_add_r(bb_2c);
|
||||
rtw_debugfs_add_r(bb_2d);
|
||||
rtw_debugfs_add_r(bb_40);
|
||||
rtw_debugfs_add_r(bb_41);
|
||||
}
|
||||
rtw_debugfs_add_r(rf_dump);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_RTW88_DEBUGFS */
|
||||
|
||||
#ifdef CONFIG_RTW88_DEBUG
|
||||
|
||||
void __rtw_dbg(struct rtw_dev *rtwdev, enum rtw_debug_mask mask,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
struct va_format vaf = {
|
||||
.fmt = fmt,
|
||||
};
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vaf.va = &args;
|
||||
|
||||
if (rtw_debug_mask & mask)
|
||||
dev_printk(KERN_DEBUG, rtwdev->dev, "%pV", &vaf);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
EXPORT_SYMBOL(__rtw_dbg);
|
||||
|
||||
#endif /* CONFIG_RTW88_DEBUG */
|
52
drivers/net/wireless/realtek/rtw88/debug.h
Normal file
52
drivers/net/wireless/realtek/rtw88/debug.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_DEBUG_H
|
||||
#define __RTW_DEBUG_H
|
||||
|
||||
enum rtw_debug_mask {
|
||||
RTW_DBG_PCI = 0x00000001,
|
||||
RTW_DBG_TX = 0x00000002,
|
||||
RTW_DBG_RX = 0x00000004,
|
||||
RTW_DBG_PHY = 0x00000008,
|
||||
RTW_DBG_FW = 0x00000010,
|
||||
RTW_DBG_EFUSE = 0x00000020,
|
||||
RTW_DBG_COEX = 0x00000040,
|
||||
RTW_DBG_RFK = 0x00000080,
|
||||
RTW_DBG_REGD = 0x00000100,
|
||||
RTW_DBG_DEBUGFS = 0x00000200,
|
||||
|
||||
RTW_DBG_ALL = 0xffffffff
|
||||
};
|
||||
|
||||
#ifdef CONFIG_RTW88_DEBUGFS
|
||||
|
||||
void rtw_debugfs_init(struct rtw_dev *rtwdev);
|
||||
|
||||
#else
|
||||
|
||||
static inline void rtw_debugfs_init(struct rtw_dev *rtwdev) {}
|
||||
|
||||
#endif /* CONFIG_RTW88_DEBUGFS */
|
||||
|
||||
#ifdef CONFIG_RTW88_DEBUG
|
||||
|
||||
__printf(3, 4)
|
||||
void __rtw_dbg(struct rtw_dev *rtwdev, enum rtw_debug_mask mask,
|
||||
const char *fmt, ...);
|
||||
|
||||
#define rtw_dbg(rtwdev, a...) __rtw_dbg(rtwdev, ##a)
|
||||
|
||||
#else
|
||||
|
||||
static inline void rtw_dbg(struct rtw_dev *rtwdev, enum rtw_debug_mask mask,
|
||||
const char *fmt, ...) {}
|
||||
|
||||
#endif /* CONFIG_RTW88_DEBUG */
|
||||
|
||||
#define rtw_info(rtwdev, a...) dev_info(rtwdev->dev, ##a)
|
||||
#define rtw_warn(rtwdev, a...) dev_warn(rtwdev->dev, ##a)
|
||||
#define rtw_err(rtwdev, a...) dev_err(rtwdev->dev, ##a)
|
||||
|
||||
#endif
|
160
drivers/net/wireless/realtek/rtw88/efuse.c
Normal file
160
drivers/net/wireless/realtek/rtw88/efuse.c
Normal file
|
@ -0,0 +1,160 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "efuse.h"
|
||||
#include "reg.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define RTW_EFUSE_BANK_WIFI 0x0
|
||||
|
||||
static void switch_efuse_bank(struct rtw_dev *rtwdev)
|
||||
{
|
||||
rtw_write32_mask(rtwdev, REG_LDO_EFUSE_CTRL, BIT_MASK_EFUSE_BANK_SEL,
|
||||
RTW_EFUSE_BANK_WIFI);
|
||||
}
|
||||
|
||||
#define invalid_efuse_header(hdr1, hdr2) \
|
||||
((hdr1) == 0xff || (((hdr1) & 0x1f) == 0xf && (hdr2) == 0xff))
|
||||
#define invalid_efuse_content(word_en, i) \
|
||||
(((word_en) & BIT(i)) != 0x0)
|
||||
#define get_efuse_blk_idx_2_byte(hdr1, hdr2) \
|
||||
((((hdr2) & 0xf0) >> 1) | (((hdr1) >> 5) & 0x07))
|
||||
#define get_efuse_blk_idx_1_byte(hdr1) \
|
||||
(((hdr1) & 0xf0) >> 4)
|
||||
#define block_idx_to_logical_idx(blk_idx, i) \
|
||||
(((blk_idx) << 3) + ((i) << 1))
|
||||
|
||||
/* efuse header format
|
||||
*
|
||||
* | 7 5 4 0 | 7 4 3 0 | 15 8 7 0 |
|
||||
* block[2:0] 0 1111 block[6:3] word_en[3:0] byte0 byte1
|
||||
* | header 1 (optional) | header 2 | word N |
|
||||
*
|
||||
* word_en: 4 bits each word. 0 -> write; 1 -> not write
|
||||
* N: 1~4, depends on word_en
|
||||
*/
|
||||
static int rtw_dump_logical_efuse_map(struct rtw_dev *rtwdev, u8 *phy_map,
|
||||
u8 *log_map)
|
||||
{
|
||||
u32 physical_size = rtwdev->efuse.physical_size;
|
||||
u32 protect_size = rtwdev->efuse.protect_size;
|
||||
u32 logical_size = rtwdev->efuse.logical_size;
|
||||
u32 phy_idx, log_idx;
|
||||
u8 hdr1, hdr2;
|
||||
u8 blk_idx;
|
||||
u8 word_en;
|
||||
int i;
|
||||
|
||||
for (phy_idx = 0; phy_idx < physical_size - protect_size;) {
|
||||
hdr1 = phy_map[phy_idx];
|
||||
hdr2 = phy_map[phy_idx + 1];
|
||||
if (invalid_efuse_header(hdr1, hdr2))
|
||||
break;
|
||||
|
||||
if ((hdr1 & 0x1f) == 0xf) {
|
||||
/* 2-byte header format */
|
||||
blk_idx = get_efuse_blk_idx_2_byte(hdr1, hdr2);
|
||||
word_en = hdr2 & 0xf;
|
||||
phy_idx += 2;
|
||||
} else {
|
||||
/* 1-byte header format */
|
||||
blk_idx = get_efuse_blk_idx_1_byte(hdr1);
|
||||
word_en = hdr1 & 0xf;
|
||||
phy_idx += 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (invalid_efuse_content(word_en, i))
|
||||
continue;
|
||||
|
||||
log_idx = block_idx_to_logical_idx(blk_idx, i);
|
||||
if (phy_idx + 1 > physical_size - protect_size ||
|
||||
log_idx + 1 > logical_size)
|
||||
return -EINVAL;
|
||||
|
||||
log_map[log_idx] = phy_map[phy_idx];
|
||||
log_map[log_idx + 1] = phy_map[phy_idx + 1];
|
||||
phy_idx += 2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_dump_physical_efuse_map(struct rtw_dev *rtwdev, u8 *map)
|
||||
{
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
u32 size = rtwdev->efuse.physical_size;
|
||||
u32 efuse_ctl;
|
||||
u32 addr;
|
||||
u32 cnt;
|
||||
|
||||
switch_efuse_bank(rtwdev);
|
||||
|
||||
/* disable 2.5V LDO */
|
||||
chip->ops->cfg_ldo25(rtwdev, false);
|
||||
|
||||
efuse_ctl = rtw_read32(rtwdev, REG_EFUSE_CTRL);
|
||||
|
||||
for (addr = 0; addr < size; addr++) {
|
||||
efuse_ctl &= ~(BIT_MASK_EF_DATA | BITS_EF_ADDR);
|
||||
efuse_ctl |= (addr & BIT_MASK_EF_ADDR) << BIT_SHIFT_EF_ADDR;
|
||||
rtw_write32(rtwdev, REG_EFUSE_CTRL, efuse_ctl & (~BIT_EF_FLAG));
|
||||
|
||||
cnt = 1000000;
|
||||
do {
|
||||
udelay(1);
|
||||
efuse_ctl = rtw_read32(rtwdev, REG_EFUSE_CTRL);
|
||||
if (--cnt == 0)
|
||||
return -EBUSY;
|
||||
} while (!(efuse_ctl & BIT_EF_FLAG));
|
||||
|
||||
*(map + addr) = (u8)(efuse_ctl & BIT_MASK_EF_DATA);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtw_parse_efuse_map(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
struct rtw_efuse *efuse = &rtwdev->efuse;
|
||||
u32 phy_size = efuse->physical_size;
|
||||
u32 log_size = efuse->logical_size;
|
||||
u8 *phy_map = NULL;
|
||||
u8 *log_map = NULL;
|
||||
int ret = 0;
|
||||
|
||||
phy_map = kmalloc(phy_size, GFP_KERNEL);
|
||||
log_map = kmalloc(log_size, GFP_KERNEL);
|
||||
if (!phy_map || !log_map) {
|
||||
ret = -ENOMEM;
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
ret = rtw_dump_physical_efuse_map(rtwdev, phy_map);
|
||||
if (ret) {
|
||||
rtw_err(rtwdev, "failed to dump efuse physical map\n");
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
memset(log_map, 0xff, log_size);
|
||||
ret = rtw_dump_logical_efuse_map(rtwdev, phy_map, log_map);
|
||||
if (ret) {
|
||||
rtw_err(rtwdev, "failed to dump efuse logical map\n");
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
ret = chip->ops->read_efuse(rtwdev, log_map);
|
||||
if (ret) {
|
||||
rtw_err(rtwdev, "failed to read efuse map\n");
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
out_free:
|
||||
kfree(log_map);
|
||||
kfree(phy_map);
|
||||
|
||||
return ret;
|
||||
}
|
26
drivers/net/wireless/realtek/rtw88/efuse.h
Normal file
26
drivers/net/wireless/realtek/rtw88/efuse.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_EFUSE_H__
|
||||
#define __RTW_EFUSE_H__
|
||||
|
||||
#define EFUSE_HW_CAP_IGNORE 0
|
||||
#define EFUSE_HW_CAP_PTCL_VHT 3
|
||||
#define EFUSE_HW_CAP_SUPP_BW80 7
|
||||
#define EFUSE_HW_CAP_SUPP_BW40 6
|
||||
|
||||
#define GET_EFUSE_HW_CAP_HCI(hw_cap) \
|
||||
le32_get_bits(*((__le32 *)(hw_cap) + 0x01), GENMASK(3, 0))
|
||||
#define GET_EFUSE_HW_CAP_BW(hw_cap) \
|
||||
le32_get_bits(*((__le32 *)(hw_cap) + 0x01), GENMASK(18, 16))
|
||||
#define GET_EFUSE_HW_CAP_NSS(hw_cap) \
|
||||
le32_get_bits(*((__le32 *)(hw_cap) + 0x01), GENMASK(20, 19))
|
||||
#define GET_EFUSE_HW_CAP_ANT_NUM(hw_cap) \
|
||||
le32_get_bits(*((__le32 *)(hw_cap) + 0x01), GENMASK(23, 21))
|
||||
#define GET_EFUSE_HW_CAP_PTCL(hw_cap) \
|
||||
le32_get_bits(*((__le32 *)(hw_cap) + 0x01), GENMASK(27, 26))
|
||||
|
||||
int rtw_parse_efuse_map(struct rtw_dev *rtwdev);
|
||||
|
||||
#endif
|
633
drivers/net/wireless/realtek/rtw88/fw.c
Normal file
633
drivers/net/wireless/realtek/rtw88/fw.c
Normal file
|
@ -0,0 +1,633 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "fw.h"
|
||||
#include "tx.h"
|
||||
#include "reg.h"
|
||||
#include "debug.h"
|
||||
|
||||
void rtw_fw_c2h_cmd_handle_ext(struct rtw_dev *rtwdev, struct sk_buff *skb)
|
||||
{
|
||||
struct rtw_c2h_cmd *c2h;
|
||||
u8 sub_cmd_id;
|
||||
|
||||
c2h = get_c2h_from_skb(skb);
|
||||
sub_cmd_id = c2h->payload[0];
|
||||
|
||||
switch (sub_cmd_id) {
|
||||
case C2H_CCX_RPT:
|
||||
rtw_tx_report_handle(rtwdev, skb);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rtw_fw_c2h_cmd_handle(struct rtw_dev *rtwdev, struct sk_buff *skb)
|
||||
{
|
||||
struct rtw_c2h_cmd *c2h;
|
||||
u32 pkt_offset;
|
||||
u8 len;
|
||||
|
||||
pkt_offset = *((u32 *)skb->cb);
|
||||
c2h = (struct rtw_c2h_cmd *)(skb->data + pkt_offset);
|
||||
len = skb->len - pkt_offset - 2;
|
||||
|
||||
rtw_dbg(rtwdev, RTW_DBG_FW, "recv C2H, id=0x%02x, seq=0x%02x, len=%d\n",
|
||||
c2h->id, c2h->seq, len);
|
||||
|
||||
switch (c2h->id) {
|
||||
case C2H_HALMAC:
|
||||
rtw_fw_c2h_cmd_handle_ext(rtwdev, skb);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void rtw_fw_send_h2c_command(struct rtw_dev *rtwdev, u8 *h2c)
|
||||
{
|
||||
u8 box;
|
||||
u8 box_state;
|
||||
u32 box_reg, box_ex_reg;
|
||||
u32 h2c_wait;
|
||||
int idx;
|
||||
|
||||
rtw_dbg(rtwdev, RTW_DBG_FW,
|
||||
"send H2C content %02x%02x%02x%02x %02x%02x%02x%02x\n",
|
||||
h2c[3], h2c[2], h2c[1], h2c[0],
|
||||
h2c[7], h2c[6], h2c[5], h2c[4]);
|
||||
|
||||
spin_lock(&rtwdev->h2c.lock);
|
||||
|
||||
box = rtwdev->h2c.last_box_num;
|
||||
switch (box) {
|
||||
case 0:
|
||||
box_reg = REG_HMEBOX0;
|
||||
box_ex_reg = REG_HMEBOX0_EX;
|
||||
break;
|
||||
case 1:
|
||||
box_reg = REG_HMEBOX1;
|
||||
box_ex_reg = REG_HMEBOX1_EX;
|
||||
break;
|
||||
case 2:
|
||||
box_reg = REG_HMEBOX2;
|
||||
box_ex_reg = REG_HMEBOX2_EX;
|
||||
break;
|
||||
case 3:
|
||||
box_reg = REG_HMEBOX3;
|
||||
box_ex_reg = REG_HMEBOX3_EX;
|
||||
break;
|
||||
default:
|
||||
WARN(1, "invalid h2c mail box number\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
h2c_wait = 20;
|
||||
do {
|
||||
box_state = rtw_read8(rtwdev, REG_HMETFR);
|
||||
} while ((box_state >> box) & 0x1 && --h2c_wait > 0);
|
||||
|
||||
if (!h2c_wait) {
|
||||
rtw_err(rtwdev, "failed to send h2c command\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (idx = 0; idx < 4; idx++)
|
||||
rtw_write8(rtwdev, box_reg + idx, h2c[idx]);
|
||||
for (idx = 0; idx < 4; idx++)
|
||||
rtw_write8(rtwdev, box_ex_reg + idx, h2c[idx + 4]);
|
||||
|
||||
if (++rtwdev->h2c.last_box_num >= 4)
|
||||
rtwdev->h2c.last_box_num = 0;
|
||||
|
||||
out:
|
||||
spin_unlock(&rtwdev->h2c.lock);
|
||||
}
|
||||
|
||||
static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt)
|
||||
{
|
||||
int ret;
|
||||
|
||||
spin_lock(&rtwdev->h2c.lock);
|
||||
|
||||
FW_OFFLOAD_H2C_SET_SEQ_NUM(h2c_pkt, rtwdev->h2c.seq);
|
||||
ret = rtw_hci_write_data_h2c(rtwdev, h2c_pkt, H2C_PKT_SIZE);
|
||||
if (ret)
|
||||
rtw_err(rtwdev, "failed to send h2c packet\n");
|
||||
rtwdev->h2c.seq++;
|
||||
|
||||
spin_unlock(&rtwdev->h2c.lock);
|
||||
}
|
||||
|
||||
void
|
||||
rtw_fw_send_general_info(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_fifo_conf *fifo = &rtwdev->fifo;
|
||||
u8 h2c_pkt[H2C_PKT_SIZE] = {0};
|
||||
u16 total_size = H2C_PKT_HDR_SIZE + 4;
|
||||
|
||||
rtw_h2c_pkt_set_header(h2c_pkt, H2C_PKT_GENERAL_INFO);
|
||||
|
||||
SET_PKT_H2C_TOTAL_LEN(h2c_pkt, total_size);
|
||||
|
||||
GENERAL_INFO_SET_FW_TX_BOUNDARY(h2c_pkt,
|
||||
fifo->rsvd_fw_txbuf_addr -
|
||||
fifo->rsvd_boundary);
|
||||
|
||||
rtw_fw_send_h2c_packet(rtwdev, h2c_pkt);
|
||||
}
|
||||
|
||||
void
|
||||
rtw_fw_send_phydm_info(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_hal *hal = &rtwdev->hal;
|
||||
struct rtw_efuse *efuse = &rtwdev->efuse;
|
||||
u8 h2c_pkt[H2C_PKT_SIZE] = {0};
|
||||
u16 total_size = H2C_PKT_HDR_SIZE + 8;
|
||||
u8 fw_rf_type = 0;
|
||||
|
||||
if (hal->rf_type == RF_1T1R)
|
||||
fw_rf_type = FW_RF_1T1R;
|
||||
else if (hal->rf_type == RF_2T2R)
|
||||
fw_rf_type = FW_RF_2T2R;
|
||||
|
||||
rtw_h2c_pkt_set_header(h2c_pkt, H2C_PKT_PHYDM_INFO);
|
||||
|
||||
SET_PKT_H2C_TOTAL_LEN(h2c_pkt, total_size);
|
||||
PHYDM_INFO_SET_REF_TYPE(h2c_pkt, efuse->rfe_option);
|
||||
PHYDM_INFO_SET_RF_TYPE(h2c_pkt, fw_rf_type);
|
||||
PHYDM_INFO_SET_CUT_VER(h2c_pkt, hal->cut_version);
|
||||
PHYDM_INFO_SET_RX_ANT_STATUS(h2c_pkt, hal->antenna_tx);
|
||||
PHYDM_INFO_SET_TX_ANT_STATUS(h2c_pkt, hal->antenna_rx);
|
||||
|
||||
rtw_fw_send_h2c_packet(rtwdev, h2c_pkt);
|
||||
}
|
||||
|
||||
void rtw_fw_do_iqk(struct rtw_dev *rtwdev, struct rtw_iqk_para *para)
|
||||
{
|
||||
u8 h2c_pkt[H2C_PKT_SIZE] = {0};
|
||||
u16 total_size = H2C_PKT_HDR_SIZE + 1;
|
||||
|
||||
rtw_h2c_pkt_set_header(h2c_pkt, H2C_PKT_IQK);
|
||||
SET_PKT_H2C_TOTAL_LEN(h2c_pkt, total_size);
|
||||
IQK_SET_CLEAR(h2c_pkt, para->clear);
|
||||
IQK_SET_SEGMENT_IQK(h2c_pkt, para->segment_iqk);
|
||||
|
||||
rtw_fw_send_h2c_packet(rtwdev, h2c_pkt);
|
||||
}
|
||||
|
||||
void rtw_fw_send_rssi_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si)
|
||||
{
|
||||
u8 h2c_pkt[H2C_PKT_SIZE] = {0};
|
||||
u8 rssi = ewma_rssi_read(&si->avg_rssi);
|
||||
bool stbc_en = si->stbc_en ? true : false;
|
||||
|
||||
SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RSSI_MONITOR);
|
||||
|
||||
SET_RSSI_INFO_MACID(h2c_pkt, si->mac_id);
|
||||
SET_RSSI_INFO_RSSI(h2c_pkt, rssi);
|
||||
SET_RSSI_INFO_STBC(h2c_pkt, stbc_en);
|
||||
|
||||
rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
|
||||
}
|
||||
|
||||
void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si)
|
||||
{
|
||||
u8 h2c_pkt[H2C_PKT_SIZE] = {0};
|
||||
bool no_update = si->updated;
|
||||
bool disable_pt = true;
|
||||
|
||||
SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO);
|
||||
|
||||
SET_RA_INFO_MACID(h2c_pkt, si->mac_id);
|
||||
SET_RA_INFO_RATE_ID(h2c_pkt, si->rate_id);
|
||||
SET_RA_INFO_INIT_RA_LVL(h2c_pkt, si->init_ra_lv);
|
||||
SET_RA_INFO_SGI_EN(h2c_pkt, si->sgi_enable);
|
||||
SET_RA_INFO_BW_MODE(h2c_pkt, si->bw_mode);
|
||||
SET_RA_INFO_LDPC(h2c_pkt, si->ldpc_en);
|
||||
SET_RA_INFO_NO_UPDATE(h2c_pkt, no_update);
|
||||
SET_RA_INFO_VHT_EN(h2c_pkt, si->vht_enable);
|
||||
SET_RA_INFO_DIS_PT(h2c_pkt, disable_pt);
|
||||
SET_RA_INFO_RA_MASK0(h2c_pkt, (si->ra_mask & 0xff));
|
||||
SET_RA_INFO_RA_MASK1(h2c_pkt, (si->ra_mask & 0xff00) >> 8);
|
||||
SET_RA_INFO_RA_MASK2(h2c_pkt, (si->ra_mask & 0xff0000) >> 16);
|
||||
SET_RA_INFO_RA_MASK3(h2c_pkt, (si->ra_mask & 0xff000000) >> 24);
|
||||
|
||||
si->init_ra_lv = 0;
|
||||
si->updated = true;
|
||||
|
||||
rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
|
||||
}
|
||||
|
||||
void rtw_fw_media_status_report(struct rtw_dev *rtwdev, u8 mac_id, bool connect)
|
||||
{
|
||||
u8 h2c_pkt[H2C_PKT_SIZE] = {0};
|
||||
|
||||
SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_MEDIA_STATUS_RPT);
|
||||
MEDIA_STATUS_RPT_SET_OP_MODE(h2c_pkt, connect);
|
||||
MEDIA_STATUS_RPT_SET_MACID(h2c_pkt, mac_id);
|
||||
|
||||
rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
|
||||
}
|
||||
|
||||
void rtw_fw_set_pwr_mode(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_lps_conf *conf = &rtwdev->lps_conf;
|
||||
u8 h2c_pkt[H2C_PKT_SIZE] = {0};
|
||||
|
||||
SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_SET_PWR_MODE);
|
||||
|
||||
SET_PWR_MODE_SET_MODE(h2c_pkt, conf->mode);
|
||||
SET_PWR_MODE_SET_RLBM(h2c_pkt, conf->rlbm);
|
||||
SET_PWR_MODE_SET_SMART_PS(h2c_pkt, conf->smart_ps);
|
||||
SET_PWR_MODE_SET_AWAKE_INTERVAL(h2c_pkt, conf->awake_interval);
|
||||
SET_PWR_MODE_SET_PORT_ID(h2c_pkt, conf->port_id);
|
||||
SET_PWR_MODE_SET_PWR_STATE(h2c_pkt, conf->state);
|
||||
|
||||
rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
|
||||
}
|
||||
|
||||
static u8 rtw_get_rsvd_page_location(struct rtw_dev *rtwdev,
|
||||
enum rtw_rsvd_packet_type type)
|
||||
{
|
||||
struct rtw_rsvd_page *rsvd_pkt;
|
||||
u8 location = 0;
|
||||
|
||||
list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) {
|
||||
if (type == rsvd_pkt->type)
|
||||
location = rsvd_pkt->page;
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
void rtw_send_rsvd_page_h2c(struct rtw_dev *rtwdev)
|
||||
{
|
||||
u8 h2c_pkt[H2C_PKT_SIZE] = {0};
|
||||
u8 location = 0;
|
||||
|
||||
SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RSVD_PAGE);
|
||||
|
||||
location = rtw_get_rsvd_page_location(rtwdev, RSVD_PROBE_RESP);
|
||||
*(h2c_pkt + 1) = location;
|
||||
rtw_dbg(rtwdev, RTW_DBG_FW, "RSVD_PROBE_RESP loc: %d\n", location);
|
||||
|
||||
location = rtw_get_rsvd_page_location(rtwdev, RSVD_PS_POLL);
|
||||
*(h2c_pkt + 2) = location;
|
||||
rtw_dbg(rtwdev, RTW_DBG_FW, "RSVD_PS_POLL loc: %d\n", location);
|
||||
|
||||
location = rtw_get_rsvd_page_location(rtwdev, RSVD_NULL);
|
||||
*(h2c_pkt + 3) = location;
|
||||
rtw_dbg(rtwdev, RTW_DBG_FW, "RSVD_NULL loc: %d\n", location);
|
||||
|
||||
location = rtw_get_rsvd_page_location(rtwdev, RSVD_QOS_NULL);
|
||||
*(h2c_pkt + 4) = location;
|
||||
rtw_dbg(rtwdev, RTW_DBG_FW, "RSVD_QOS_NULL loc: %d\n", location);
|
||||
|
||||
rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
|
||||
}
|
||||
|
||||
static struct sk_buff *
|
||||
rtw_beacon_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
|
||||
{
|
||||
struct sk_buff *skb_new;
|
||||
|
||||
if (vif->type != NL80211_IFTYPE_AP &&
|
||||
vif->type != NL80211_IFTYPE_ADHOC &&
|
||||
!ieee80211_vif_is_mesh(vif)) {
|
||||
skb_new = alloc_skb(1, GFP_KERNEL);
|
||||
if (!skb_new)
|
||||
return NULL;
|
||||
skb_put(skb_new, 1);
|
||||
} else {
|
||||
skb_new = ieee80211_beacon_get(hw, vif);
|
||||
}
|
||||
|
||||
return skb_new;
|
||||
}
|
||||
|
||||
static struct sk_buff *rtw_get_rsvd_page_skb(struct ieee80211_hw *hw,
|
||||
struct ieee80211_vif *vif,
|
||||
enum rtw_rsvd_packet_type type)
|
||||
{
|
||||
struct sk_buff *skb_new;
|
||||
|
||||
switch (type) {
|
||||
case RSVD_BEACON:
|
||||
skb_new = rtw_beacon_get(hw, vif);
|
||||
break;
|
||||
case RSVD_PS_POLL:
|
||||
skb_new = ieee80211_pspoll_get(hw, vif);
|
||||
break;
|
||||
case RSVD_PROBE_RESP:
|
||||
skb_new = ieee80211_proberesp_get(hw, vif);
|
||||
break;
|
||||
case RSVD_NULL:
|
||||
skb_new = ieee80211_nullfunc_get(hw, vif, false);
|
||||
break;
|
||||
case RSVD_QOS_NULL:
|
||||
skb_new = ieee80211_nullfunc_get(hw, vif, true);
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!skb_new)
|
||||
return NULL;
|
||||
|
||||
return skb_new;
|
||||
}
|
||||
|
||||
static void rtw_fill_rsvd_page_desc(struct rtw_dev *rtwdev, struct sk_buff *skb)
|
||||
{
|
||||
struct rtw_tx_pkt_info pkt_info;
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
u8 *pkt_desc;
|
||||
|
||||
memset(&pkt_info, 0, sizeof(pkt_info));
|
||||
rtw_rsvd_page_pkt_info_update(rtwdev, &pkt_info, skb);
|
||||
pkt_desc = skb_push(skb, chip->tx_pkt_desc_sz);
|
||||
memset(pkt_desc, 0, chip->tx_pkt_desc_sz);
|
||||
rtw_tx_fill_tx_desc(&pkt_info, skb);
|
||||
}
|
||||
|
||||
static inline u8 rtw_len_to_page(unsigned int len, u8 page_size)
|
||||
{
|
||||
return DIV_ROUND_UP(len, page_size);
|
||||
}
|
||||
|
||||
static void rtw_rsvd_page_list_to_buf(struct rtw_dev *rtwdev, u8 page_size,
|
||||
u8 page_margin, u32 page, u8 *buf,
|
||||
struct rtw_rsvd_page *rsvd_pkt)
|
||||
{
|
||||
struct sk_buff *skb = rsvd_pkt->skb;
|
||||
|
||||
if (rsvd_pkt->add_txdesc)
|
||||
rtw_fill_rsvd_page_desc(rtwdev, skb);
|
||||
|
||||
if (page >= 1)
|
||||
memcpy(buf + page_margin + page_size * (page - 1),
|
||||
skb->data, skb->len);
|
||||
else
|
||||
memcpy(buf, skb->data, skb->len);
|
||||
}
|
||||
|
||||
void rtw_add_rsvd_page(struct rtw_dev *rtwdev, enum rtw_rsvd_packet_type type,
|
||||
bool txdesc)
|
||||
{
|
||||
struct rtw_rsvd_page *rsvd_pkt;
|
||||
|
||||
lockdep_assert_held(&rtwdev->mutex);
|
||||
|
||||
list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) {
|
||||
if (rsvd_pkt->type == type)
|
||||
return;
|
||||
}
|
||||
|
||||
rsvd_pkt = kmalloc(sizeof(*rsvd_pkt), GFP_KERNEL);
|
||||
if (!rsvd_pkt)
|
||||
return;
|
||||
|
||||
rsvd_pkt->type = type;
|
||||
rsvd_pkt->add_txdesc = txdesc;
|
||||
list_add_tail(&rsvd_pkt->list, &rtwdev->rsvd_page_list);
|
||||
}
|
||||
|
||||
void rtw_reset_rsvd_page(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_rsvd_page *rsvd_pkt, *tmp;
|
||||
|
||||
lockdep_assert_held(&rtwdev->mutex);
|
||||
|
||||
list_for_each_entry_safe(rsvd_pkt, tmp, &rtwdev->rsvd_page_list, list) {
|
||||
if (rsvd_pkt->type == RSVD_BEACON)
|
||||
continue;
|
||||
list_del(&rsvd_pkt->list);
|
||||
kfree(rsvd_pkt);
|
||||
}
|
||||
}
|
||||
|
||||
int rtw_fw_write_data_rsvd_page(struct rtw_dev *rtwdev, u16 pg_addr,
|
||||
u8 *buf, u32 size)
|
||||
{
|
||||
u8 bckp[2];
|
||||
u8 val;
|
||||
u16 rsvd_pg_head;
|
||||
int ret;
|
||||
|
||||
lockdep_assert_held(&rtwdev->mutex);
|
||||
|
||||
if (!size)
|
||||
return -EINVAL;
|
||||
|
||||
pg_addr &= BIT_MASK_BCN_HEAD_1_V1;
|
||||
rtw_write16(rtwdev, REG_FIFOPAGE_CTRL_2, pg_addr | BIT_BCN_VALID_V1);
|
||||
|
||||
val = rtw_read8(rtwdev, REG_CR + 1);
|
||||
bckp[0] = val;
|
||||
val |= BIT_ENSWBCN >> 8;
|
||||
rtw_write8(rtwdev, REG_CR + 1, val);
|
||||
|
||||
val = rtw_read8(rtwdev, REG_FWHW_TXQ_CTRL + 2);
|
||||
bckp[1] = val;
|
||||
val &= ~(BIT_EN_BCNQ_DL >> 16);
|
||||
rtw_write8(rtwdev, REG_FWHW_TXQ_CTRL + 2, val);
|
||||
|
||||
ret = rtw_hci_write_data_rsvd_page(rtwdev, buf, size);
|
||||
if (ret) {
|
||||
rtw_err(rtwdev, "failed to write data to rsvd page\n");
|
||||
goto restore;
|
||||
}
|
||||
|
||||
if (!check_hw_ready(rtwdev, REG_FIFOPAGE_CTRL_2, BIT_BCN_VALID_V1, 1)) {
|
||||
rtw_err(rtwdev, "error beacon valid\n");
|
||||
ret = -EBUSY;
|
||||
}
|
||||
|
||||
restore:
|
||||
rsvd_pg_head = rtwdev->fifo.rsvd_boundary;
|
||||
rtw_write16(rtwdev, REG_FIFOPAGE_CTRL_2,
|
||||
rsvd_pg_head | BIT_BCN_VALID_V1);
|
||||
rtw_write8(rtwdev, REG_FWHW_TXQ_CTRL + 2, bckp[1]);
|
||||
rtw_write8(rtwdev, REG_CR + 1, bckp[0]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rtw_download_drv_rsvd_page(struct rtw_dev *rtwdev, u8 *buf, u32 size)
|
||||
{
|
||||
u32 pg_size;
|
||||
u32 pg_num = 0;
|
||||
u16 pg_addr = 0;
|
||||
|
||||
pg_size = rtwdev->chip->page_size;
|
||||
pg_num = size / pg_size + ((size & (pg_size - 1)) ? 1 : 0);
|
||||
if (pg_num > rtwdev->fifo.rsvd_drv_pg_num)
|
||||
return -ENOMEM;
|
||||
|
||||
pg_addr = rtwdev->fifo.rsvd_drv_addr;
|
||||
|
||||
return rtw_fw_write_data_rsvd_page(rtwdev, pg_addr, buf, size);
|
||||
}
|
||||
|
||||
static u8 *rtw_build_rsvd_page(struct rtw_dev *rtwdev,
|
||||
struct ieee80211_vif *vif, u32 *size)
|
||||
{
|
||||
struct ieee80211_hw *hw = rtwdev->hw;
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
struct sk_buff *iter;
|
||||
struct rtw_rsvd_page *rsvd_pkt;
|
||||
u32 page = 0;
|
||||
u8 total_page = 0;
|
||||
u8 page_size, page_margin, tx_desc_sz;
|
||||
u8 *buf;
|
||||
|
||||
page_size = chip->page_size;
|
||||
tx_desc_sz = chip->tx_pkt_desc_sz;
|
||||
page_margin = page_size - tx_desc_sz;
|
||||
|
||||
list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) {
|
||||
iter = rtw_get_rsvd_page_skb(hw, vif, rsvd_pkt->type);
|
||||
if (!iter) {
|
||||
rtw_err(rtwdev, "fail to build rsvd packet\n");
|
||||
goto release_skb;
|
||||
}
|
||||
rsvd_pkt->skb = iter;
|
||||
rsvd_pkt->page = total_page;
|
||||
if (rsvd_pkt->add_txdesc)
|
||||
total_page += rtw_len_to_page(iter->len + tx_desc_sz,
|
||||
page_size);
|
||||
else
|
||||
total_page += rtw_len_to_page(iter->len, page_size);
|
||||
}
|
||||
|
||||
if (total_page > rtwdev->fifo.rsvd_drv_pg_num) {
|
||||
rtw_err(rtwdev, "rsvd page over size: %d\n", total_page);
|
||||
goto release_skb;
|
||||
}
|
||||
|
||||
*size = (total_page - 1) * page_size + page_margin;
|
||||
buf = kzalloc(*size, GFP_KERNEL);
|
||||
if (!buf)
|
||||
goto release_skb;
|
||||
|
||||
list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) {
|
||||
rtw_rsvd_page_list_to_buf(rtwdev, page_size, page_margin,
|
||||
page, buf, rsvd_pkt);
|
||||
page += rtw_len_to_page(rsvd_pkt->skb->len, page_size);
|
||||
}
|
||||
list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list)
|
||||
kfree_skb(rsvd_pkt->skb);
|
||||
|
||||
return buf;
|
||||
|
||||
release_skb:
|
||||
list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list)
|
||||
kfree_skb(rsvd_pkt->skb);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
rtw_download_beacon(struct rtw_dev *rtwdev, struct ieee80211_vif *vif)
|
||||
{
|
||||
struct ieee80211_hw *hw = rtwdev->hw;
|
||||
struct sk_buff *skb;
|
||||
int ret = 0;
|
||||
|
||||
skb = rtw_beacon_get(hw, vif);
|
||||
if (!skb) {
|
||||
rtw_err(rtwdev, "failed to get beacon skb\n");
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = rtw_download_drv_rsvd_page(rtwdev, skb->data, skb->len);
|
||||
if (ret)
|
||||
rtw_err(rtwdev, "failed to download drv rsvd page\n");
|
||||
|
||||
dev_kfree_skb(skb);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int rtw_fw_download_rsvd_page(struct rtw_dev *rtwdev, struct ieee80211_vif *vif)
|
||||
{
|
||||
u8 *buf;
|
||||
u32 size;
|
||||
int ret;
|
||||
|
||||
buf = rtw_build_rsvd_page(rtwdev, vif, &size);
|
||||
if (!buf) {
|
||||
rtw_err(rtwdev, "failed to build rsvd page pkt\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = rtw_download_drv_rsvd_page(rtwdev, buf, size);
|
||||
if (ret) {
|
||||
rtw_err(rtwdev, "failed to download drv rsvd page\n");
|
||||
goto free;
|
||||
}
|
||||
|
||||
ret = rtw_download_beacon(rtwdev, vif);
|
||||
if (ret) {
|
||||
rtw_err(rtwdev, "failed to download beacon\n");
|
||||
goto free;
|
||||
}
|
||||
|
||||
free:
|
||||
kfree(buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int rtw_dump_drv_rsvd_page(struct rtw_dev *rtwdev,
|
||||
u32 offset, u32 size, u32 *buf)
|
||||
{
|
||||
struct rtw_fifo_conf *fifo = &rtwdev->fifo;
|
||||
u32 residue, i;
|
||||
u16 start_pg;
|
||||
u16 idx = 0;
|
||||
u16 ctl;
|
||||
u8 rcr;
|
||||
|
||||
if (size & 0x3) {
|
||||
rtw_warn(rtwdev, "should be 4-byte aligned\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
offset += fifo->rsvd_boundary << TX_PAGE_SIZE_SHIFT;
|
||||
residue = offset & (FIFO_PAGE_SIZE - 1);
|
||||
start_pg = offset >> FIFO_PAGE_SIZE_SHIFT;
|
||||
start_pg += RSVD_PAGE_START_ADDR;
|
||||
|
||||
rcr = rtw_read8(rtwdev, REG_RCR + 2);
|
||||
ctl = rtw_read16(rtwdev, REG_PKTBUF_DBG_CTRL) & 0xf000;
|
||||
|
||||
/* disable rx clock gate */
|
||||
rtw_write8(rtwdev, REG_RCR, rcr | BIT(3));
|
||||
|
||||
do {
|
||||
rtw_write16(rtwdev, REG_PKTBUF_DBG_CTRL, start_pg | ctl);
|
||||
|
||||
for (i = FIFO_DUMP_ADDR + residue;
|
||||
i < FIFO_DUMP_ADDR + FIFO_PAGE_SIZE; i += 4) {
|
||||
buf[idx++] = rtw_read32(rtwdev, i);
|
||||
size -= 4;
|
||||
if (size == 0)
|
||||
goto out;
|
||||
}
|
||||
|
||||
residue = 0;
|
||||
start_pg++;
|
||||
} while (size);
|
||||
|
||||
out:
|
||||
rtw_write16(rtwdev, REG_PKTBUF_DBG_CTRL, ctl);
|
||||
rtw_write8(rtwdev, REG_RCR + 2, rcr);
|
||||
return 0;
|
||||
}
|
222
drivers/net/wireless/realtek/rtw88/fw.h
Normal file
222
drivers/net/wireless/realtek/rtw88/fw.h
Normal file
|
@ -0,0 +1,222 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_FW_H_
|
||||
#define __RTW_FW_H_
|
||||
|
||||
#define H2C_PKT_SIZE 32
|
||||
#define H2C_PKT_HDR_SIZE 8
|
||||
|
||||
/* FW bin information */
|
||||
#define FW_HDR_SIZE 64
|
||||
#define FW_HDR_CHKSUM_SIZE 8
|
||||
#define FW_HDR_VERSION 4
|
||||
#define FW_HDR_SUBVERSION 6
|
||||
#define FW_HDR_SUBINDEX 7
|
||||
#define FW_HDR_MONTH 16
|
||||
#define FW_HDR_DATE 17
|
||||
#define FW_HDR_HOUR 18
|
||||
#define FW_HDR_MIN 19
|
||||
#define FW_HDR_YEAR 20
|
||||
#define FW_HDR_MEM_USAGE 24
|
||||
#define FW_HDR_H2C_FMT_VER 28
|
||||
#define FW_HDR_DMEM_ADDR 32
|
||||
#define FW_HDR_DMEM_SIZE 36
|
||||
#define FW_HDR_IMEM_SIZE 48
|
||||
#define FW_HDR_EMEM_SIZE 52
|
||||
#define FW_HDR_EMEM_ADDR 56
|
||||
#define FW_HDR_IMEM_ADDR 60
|
||||
|
||||
#define FIFO_PAGE_SIZE_SHIFT 12
|
||||
#define FIFO_PAGE_SIZE 4096
|
||||
#define RSVD_PAGE_START_ADDR 0x780
|
||||
#define FIFO_DUMP_ADDR 0x8000
|
||||
|
||||
enum rtw_c2h_cmd_id {
|
||||
C2H_BT_INFO = 0x09,
|
||||
C2H_HW_FEATURE_REPORT = 0x19,
|
||||
C2H_HW_FEATURE_DUMP = 0xfd,
|
||||
C2H_HALMAC = 0xff,
|
||||
};
|
||||
|
||||
enum rtw_c2h_cmd_id_ext {
|
||||
C2H_CCX_RPT = 0x0f,
|
||||
};
|
||||
|
||||
struct rtw_c2h_cmd {
|
||||
u8 id;
|
||||
u8 seq;
|
||||
u8 payload[0];
|
||||
} __packed;
|
||||
|
||||
enum rtw_rsvd_packet_type {
|
||||
RSVD_BEACON,
|
||||
RSVD_PS_POLL,
|
||||
RSVD_PROBE_RESP,
|
||||
RSVD_NULL,
|
||||
RSVD_QOS_NULL,
|
||||
};
|
||||
|
||||
enum rtw_fw_rf_type {
|
||||
FW_RF_1T2R = 0,
|
||||
FW_RF_2T4R = 1,
|
||||
FW_RF_2T2R = 2,
|
||||
FW_RF_2T3R = 3,
|
||||
FW_RF_1T1R = 4,
|
||||
FW_RF_2T2R_GREEN = 5,
|
||||
FW_RF_3T3R = 6,
|
||||
FW_RF_3T4R = 7,
|
||||
FW_RF_4T4R = 8,
|
||||
FW_RF_MAX_TYPE = 0xF,
|
||||
};
|
||||
|
||||
struct rtw_iqk_para {
|
||||
u8 clear;
|
||||
u8 segment_iqk;
|
||||
};
|
||||
|
||||
struct rtw_rsvd_page {
|
||||
struct list_head list;
|
||||
struct sk_buff *skb;
|
||||
enum rtw_rsvd_packet_type type;
|
||||
u8 page;
|
||||
bool add_txdesc;
|
||||
};
|
||||
|
||||
/* C2H */
|
||||
#define GET_CCX_REPORT_SEQNUM(c2h_payload) (c2h_payload[8] & 0xfc)
|
||||
#define GET_CCX_REPORT_STATUS(c2h_payload) (c2h_payload[9] & 0xc0)
|
||||
|
||||
/* PKT H2C */
|
||||
#define H2C_PKT_CMD_ID 0xFF
|
||||
#define H2C_PKT_CATEGORY 0x01
|
||||
|
||||
#define H2C_PKT_GENERAL_INFO 0x0D
|
||||
#define H2C_PKT_PHYDM_INFO 0x11
|
||||
#define H2C_PKT_IQK 0x0E
|
||||
|
||||
#define SET_PKT_H2C_CATEGORY(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(6, 0))
|
||||
#define SET_PKT_H2C_CMD_ID(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
|
||||
#define SET_PKT_H2C_SUB_CMD_ID(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 16))
|
||||
#define SET_PKT_H2C_TOTAL_LEN(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(15, 0))
|
||||
|
||||
static inline void rtw_h2c_pkt_set_header(u8 *h2c_pkt, u8 sub_id)
|
||||
{
|
||||
SET_PKT_H2C_CATEGORY(h2c_pkt, H2C_PKT_CATEGORY);
|
||||
SET_PKT_H2C_CMD_ID(h2c_pkt, H2C_PKT_CMD_ID);
|
||||
SET_PKT_H2C_SUB_CMD_ID(h2c_pkt, sub_id);
|
||||
}
|
||||
|
||||
#define FW_OFFLOAD_H2C_SET_SEQ_NUM(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(31, 16))
|
||||
#define GENERAL_INFO_SET_FW_TX_BOUNDARY(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(23, 16))
|
||||
|
||||
#define PHYDM_INFO_SET_REF_TYPE(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(7, 0))
|
||||
#define PHYDM_INFO_SET_RF_TYPE(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(15, 8))
|
||||
#define PHYDM_INFO_SET_CUT_VER(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(23, 16))
|
||||
#define PHYDM_INFO_SET_RX_ANT_STATUS(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(27, 24))
|
||||
#define PHYDM_INFO_SET_TX_ANT_STATUS(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, GENMASK(31, 28))
|
||||
#define IQK_SET_CLEAR(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(0))
|
||||
#define IQK_SET_SEGMENT_IQK(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x02, value, BIT(1))
|
||||
|
||||
/* Command H2C */
|
||||
#define H2C_CMD_RSVD_PAGE 0x0
|
||||
#define H2C_CMD_MEDIA_STATUS_RPT 0x01
|
||||
#define H2C_CMD_SET_PWR_MODE 0x20
|
||||
#define H2C_CMD_RA_INFO 0x40
|
||||
#define H2C_CMD_RSSI_MONITOR 0x42
|
||||
|
||||
#define SET_H2C_CMD_ID_CLASS(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(7, 0))
|
||||
|
||||
#define MEDIA_STATUS_RPT_SET_OP_MODE(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(8))
|
||||
#define MEDIA_STATUS_RPT_SET_MACID(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 16))
|
||||
|
||||
#define SET_PWR_MODE_SET_MODE(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(14, 8))
|
||||
#define SET_PWR_MODE_SET_RLBM(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(19, 16))
|
||||
#define SET_PWR_MODE_SET_SMART_PS(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(23, 20))
|
||||
#define SET_PWR_MODE_SET_AWAKE_INTERVAL(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
|
||||
#define SET_PWR_MODE_SET_PORT_ID(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(7, 5))
|
||||
#define SET_PWR_MODE_SET_PWR_STATE(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(15, 8))
|
||||
#define SET_RSSI_INFO_MACID(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
|
||||
#define SET_RSSI_INFO_RSSI(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(31, 24))
|
||||
#define SET_RSSI_INFO_STBC(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, BIT(1))
|
||||
#define SET_RA_INFO_MACID(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(15, 8))
|
||||
#define SET_RA_INFO_RATE_ID(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(20, 16))
|
||||
#define SET_RA_INFO_INIT_RA_LVL(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(22, 21))
|
||||
#define SET_RA_INFO_SGI_EN(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(23))
|
||||
#define SET_RA_INFO_BW_MODE(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(25, 24))
|
||||
#define SET_RA_INFO_LDPC(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(26))
|
||||
#define SET_RA_INFO_NO_UPDATE(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(27))
|
||||
#define SET_RA_INFO_VHT_EN(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, GENMASK(29, 28))
|
||||
#define SET_RA_INFO_DIS_PT(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, BIT(30))
|
||||
#define SET_RA_INFO_RA_MASK0(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(7, 0))
|
||||
#define SET_RA_INFO_RA_MASK1(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(15, 8))
|
||||
#define SET_RA_INFO_RA_MASK2(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(23, 16))
|
||||
#define SET_RA_INFO_RA_MASK3(h2c_pkt, value) \
|
||||
le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(31, 24))
|
||||
|
||||
static inline struct rtw_c2h_cmd *get_c2h_from_skb(struct sk_buff *skb)
|
||||
{
|
||||
u32 pkt_offset;
|
||||
|
||||
pkt_offset = *((u32 *)skb->cb);
|
||||
return (struct rtw_c2h_cmd *)(skb->data + pkt_offset);
|
||||
}
|
||||
|
||||
void rtw_fw_c2h_cmd_handle(struct rtw_dev *rtwdev, struct sk_buff *skb);
|
||||
void rtw_fw_send_general_info(struct rtw_dev *rtwdev);
|
||||
void rtw_fw_send_phydm_info(struct rtw_dev *rtwdev);
|
||||
|
||||
void rtw_fw_do_iqk(struct rtw_dev *rtwdev, struct rtw_iqk_para *para);
|
||||
void rtw_fw_set_pwr_mode(struct rtw_dev *rtwdev);
|
||||
void rtw_fw_send_rssi_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si);
|
||||
void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si);
|
||||
void rtw_fw_media_status_report(struct rtw_dev *rtwdev, u8 mac_id, bool conn);
|
||||
void rtw_add_rsvd_page(struct rtw_dev *rtwdev, enum rtw_rsvd_packet_type type,
|
||||
bool txdesc);
|
||||
int rtw_fw_write_data_rsvd_page(struct rtw_dev *rtwdev, u16 pg_addr,
|
||||
u8 *buf, u32 size);
|
||||
void rtw_reset_rsvd_page(struct rtw_dev *rtwdev);
|
||||
int rtw_fw_download_rsvd_page(struct rtw_dev *rtwdev,
|
||||
struct ieee80211_vif *vif);
|
||||
void rtw_send_rsvd_page_h2c(struct rtw_dev *rtwdev);
|
||||
int rtw_dump_drv_rsvd_page(struct rtw_dev *rtwdev,
|
||||
u32 offset, u32 size, u32 *buf);
|
||||
#endif
|
211
drivers/net/wireless/realtek/rtw88/hci.h
Normal file
211
drivers/net/wireless/realtek/rtw88/hci.h
Normal file
|
@ -0,0 +1,211 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_HCI_H__
|
||||
#define __RTW_HCI_H__
|
||||
|
||||
/* ops for PCI, USB and SDIO */
|
||||
struct rtw_hci_ops {
|
||||
int (*tx)(struct rtw_dev *rtwdev,
|
||||
struct rtw_tx_pkt_info *pkt_info,
|
||||
struct sk_buff *skb);
|
||||
int (*setup)(struct rtw_dev *rtwdev);
|
||||
int (*start)(struct rtw_dev *rtwdev);
|
||||
void (*stop)(struct rtw_dev *rtwdev);
|
||||
|
||||
int (*write_data_rsvd_page)(struct rtw_dev *rtwdev, u8 *buf, u32 size);
|
||||
int (*write_data_h2c)(struct rtw_dev *rtwdev, u8 *buf, u32 size);
|
||||
|
||||
u8 (*read8)(struct rtw_dev *rtwdev, u32 addr);
|
||||
u16 (*read16)(struct rtw_dev *rtwdev, u32 addr);
|
||||
u32 (*read32)(struct rtw_dev *rtwdev, u32 addr);
|
||||
void (*write8)(struct rtw_dev *rtwdev, u32 addr, u8 val);
|
||||
void (*write16)(struct rtw_dev *rtwdev, u32 addr, u16 val);
|
||||
void (*write32)(struct rtw_dev *rtwdev, u32 addr, u32 val);
|
||||
};
|
||||
|
||||
static inline int rtw_hci_tx(struct rtw_dev *rtwdev,
|
||||
struct rtw_tx_pkt_info *pkt_info,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
return rtwdev->hci.ops->tx(rtwdev, pkt_info, skb);
|
||||
}
|
||||
|
||||
static inline int rtw_hci_setup(struct rtw_dev *rtwdev)
|
||||
{
|
||||
return rtwdev->hci.ops->setup(rtwdev);
|
||||
}
|
||||
|
||||
static inline int rtw_hci_start(struct rtw_dev *rtwdev)
|
||||
{
|
||||
return rtwdev->hci.ops->start(rtwdev);
|
||||
}
|
||||
|
||||
static inline void rtw_hci_stop(struct rtw_dev *rtwdev)
|
||||
{
|
||||
rtwdev->hci.ops->stop(rtwdev);
|
||||
}
|
||||
|
||||
static inline int
|
||||
rtw_hci_write_data_rsvd_page(struct rtw_dev *rtwdev, u8 *buf, u32 size)
|
||||
{
|
||||
return rtwdev->hci.ops->write_data_rsvd_page(rtwdev, buf, size);
|
||||
}
|
||||
|
||||
static inline int
|
||||
rtw_hci_write_data_h2c(struct rtw_dev *rtwdev, u8 *buf, u32 size)
|
||||
{
|
||||
return rtwdev->hci.ops->write_data_h2c(rtwdev, buf, size);
|
||||
}
|
||||
|
||||
static inline u8 rtw_read8(struct rtw_dev *rtwdev, u32 addr)
|
||||
{
|
||||
return rtwdev->hci.ops->read8(rtwdev, addr);
|
||||
}
|
||||
|
||||
static inline u16 rtw_read16(struct rtw_dev *rtwdev, u32 addr)
|
||||
{
|
||||
return rtwdev->hci.ops->read16(rtwdev, addr);
|
||||
}
|
||||
|
||||
static inline u32 rtw_read32(struct rtw_dev *rtwdev, u32 addr)
|
||||
{
|
||||
return rtwdev->hci.ops->read32(rtwdev, addr);
|
||||
}
|
||||
|
||||
static inline void rtw_write8(struct rtw_dev *rtwdev, u32 addr, u8 val)
|
||||
{
|
||||
rtwdev->hci.ops->write8(rtwdev, addr, val);
|
||||
}
|
||||
|
||||
static inline void rtw_write16(struct rtw_dev *rtwdev, u32 addr, u16 val)
|
||||
{
|
||||
rtwdev->hci.ops->write16(rtwdev, addr, val);
|
||||
}
|
||||
|
||||
static inline void rtw_write32(struct rtw_dev *rtwdev, u32 addr, u32 val)
|
||||
{
|
||||
rtwdev->hci.ops->write32(rtwdev, addr, val);
|
||||
}
|
||||
|
||||
static inline void rtw_write8_set(struct rtw_dev *rtwdev, u32 addr, u8 bit)
|
||||
{
|
||||
u8 val;
|
||||
|
||||
val = rtw_read8(rtwdev, addr);
|
||||
rtw_write8(rtwdev, addr, val | bit);
|
||||
}
|
||||
|
||||
static inline void rtw_writ16_set(struct rtw_dev *rtwdev, u32 addr, u16 bit)
|
||||
{
|
||||
u16 val;
|
||||
|
||||
val = rtw_read16(rtwdev, addr);
|
||||
rtw_write16(rtwdev, addr, val | bit);
|
||||
}
|
||||
|
||||
static inline void rtw_write32_set(struct rtw_dev *rtwdev, u32 addr, u32 bit)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
val = rtw_read32(rtwdev, addr);
|
||||
rtw_write32(rtwdev, addr, val | bit);
|
||||
}
|
||||
|
||||
static inline void rtw_write8_clr(struct rtw_dev *rtwdev, u32 addr, u8 bit)
|
||||
{
|
||||
u8 val;
|
||||
|
||||
val = rtw_read8(rtwdev, addr);
|
||||
rtw_write8(rtwdev, addr, val & ~bit);
|
||||
}
|
||||
|
||||
static inline void rtw_write16_clr(struct rtw_dev *rtwdev, u32 addr, u16 bit)
|
||||
{
|
||||
u16 val;
|
||||
|
||||
val = rtw_read16(rtwdev, addr);
|
||||
rtw_write16(rtwdev, addr, val & ~bit);
|
||||
}
|
||||
|
||||
static inline void rtw_write32_clr(struct rtw_dev *rtwdev, u32 addr, u32 bit)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
val = rtw_read32(rtwdev, addr);
|
||||
rtw_write32(rtwdev, addr, val & ~bit);
|
||||
}
|
||||
|
||||
static inline u32
|
||||
rtw_read_rf(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path,
|
||||
u32 addr, u32 mask)
|
||||
{
|
||||
unsigned long flags;
|
||||
u32 val;
|
||||
|
||||
spin_lock_irqsave(&rtwdev->rf_lock, flags);
|
||||
val = rtwdev->chip->ops->read_rf(rtwdev, rf_path, addr, mask);
|
||||
spin_unlock_irqrestore(&rtwdev->rf_lock, flags);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rtw_write_rf(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path,
|
||||
u32 addr, u32 mask, u32 data)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&rtwdev->rf_lock, flags);
|
||||
rtwdev->chip->ops->write_rf(rtwdev, rf_path, addr, mask, data);
|
||||
spin_unlock_irqrestore(&rtwdev->rf_lock, flags);
|
||||
}
|
||||
|
||||
static inline u32
|
||||
rtw_read32_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask)
|
||||
{
|
||||
u32 shift = __ffs(mask);
|
||||
u32 orig;
|
||||
u32 ret;
|
||||
|
||||
orig = rtw_read32(rtwdev, addr);
|
||||
ret = (orig & mask) >> shift;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rtw_write32_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
|
||||
{
|
||||
u32 shift = __ffs(mask);
|
||||
u32 orig;
|
||||
u32 set;
|
||||
|
||||
WARN(addr & 0x3, "should be 4-byte aligned, addr = 0x%08x\n", addr);
|
||||
|
||||
orig = rtw_read32(rtwdev, addr);
|
||||
set = (orig & ~mask) | ((data << shift) & mask);
|
||||
rtw_write32(rtwdev, addr, set);
|
||||
}
|
||||
|
||||
static inline void
|
||||
rtw_write8_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u8 data)
|
||||
{
|
||||
u32 shift;
|
||||
u8 orig, set;
|
||||
|
||||
mask &= 0xff;
|
||||
shift = __ffs(mask);
|
||||
|
||||
orig = rtw_read8(rtwdev, addr);
|
||||
set = (orig & ~mask) | ((data << shift) & mask);
|
||||
rtw_write8(rtwdev, addr, set);
|
||||
}
|
||||
|
||||
static inline enum rtw_hci_type rtw_hci_type(struct rtw_dev *rtwdev)
|
||||
{
|
||||
return rtwdev->hci.type;
|
||||
}
|
||||
|
||||
#endif
|
965
drivers/net/wireless/realtek/rtw88/mac.c
Normal file
965
drivers/net/wireless/realtek/rtw88/mac.c
Normal file
|
@ -0,0 +1,965 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "mac.h"
|
||||
#include "reg.h"
|
||||
#include "fw.h"
|
||||
#include "debug.h"
|
||||
|
||||
void rtw_set_channel_mac(struct rtw_dev *rtwdev, u8 channel, u8 bw,
|
||||
u8 primary_ch_idx)
|
||||
{
|
||||
u8 txsc40 = 0, txsc20 = 0;
|
||||
u32 value32;
|
||||
u8 value8;
|
||||
|
||||
txsc20 = primary_ch_idx;
|
||||
if (txsc20 == 1 || txsc20 == 3)
|
||||
txsc40 = 9;
|
||||
else
|
||||
txsc40 = 10;
|
||||
rtw_write8(rtwdev, REG_DATA_SC,
|
||||
BIT_TXSC_20M(txsc20) | BIT_TXSC_40M(txsc40));
|
||||
|
||||
value32 = rtw_read32(rtwdev, REG_WMAC_TRXPTCL_CTL);
|
||||
value32 &= ~BIT_RFMOD;
|
||||
switch (bw) {
|
||||
case RTW_CHANNEL_WIDTH_80:
|
||||
value32 |= BIT_RFMOD_80M;
|
||||
break;
|
||||
case RTW_CHANNEL_WIDTH_40:
|
||||
value32 |= BIT_RFMOD_40M;
|
||||
break;
|
||||
case RTW_CHANNEL_WIDTH_20:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
rtw_write32(rtwdev, REG_WMAC_TRXPTCL_CTL, value32);
|
||||
|
||||
value32 = rtw_read32(rtwdev, REG_AFE_CTRL1) & ~(BIT_MAC_CLK_SEL);
|
||||
value32 |= (MAC_CLK_HW_DEF_80M << BIT_SHIFT_MAC_CLK_SEL);
|
||||
rtw_write32(rtwdev, REG_AFE_CTRL1, value32);
|
||||
|
||||
rtw_write8(rtwdev, REG_USTIME_TSF, MAC_CLK_SPEED);
|
||||
rtw_write8(rtwdev, REG_USTIME_EDCA, MAC_CLK_SPEED);
|
||||
|
||||
value8 = rtw_read8(rtwdev, REG_CCK_CHECK);
|
||||
value8 = value8 & ~BIT_CHECK_CCK_EN;
|
||||
if (channel > 35)
|
||||
value8 |= BIT_CHECK_CCK_EN;
|
||||
rtw_write8(rtwdev, REG_CCK_CHECK, value8);
|
||||
}
|
||||
|
||||
static int rtw_mac_pre_system_cfg(struct rtw_dev *rtwdev)
|
||||
{
|
||||
u32 value32;
|
||||
u8 value8;
|
||||
|
||||
rtw_write8(rtwdev, REG_RSV_CTRL, 0);
|
||||
|
||||
switch (rtw_hci_type(rtwdev)) {
|
||||
case RTW_HCI_TYPE_PCIE:
|
||||
rtw_write32_set(rtwdev, REG_HCI_OPT_CTRL, BIT_BT_DIG_CLK_EN);
|
||||
break;
|
||||
case RTW_HCI_TYPE_USB:
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* config PIN Mux */
|
||||
value32 = rtw_read32(rtwdev, REG_PAD_CTRL1);
|
||||
value32 |= BIT_PAPE_WLBT_SEL | BIT_LNAON_WLBT_SEL;
|
||||
rtw_write32(rtwdev, REG_PAD_CTRL1, value32);
|
||||
|
||||
value32 = rtw_read32(rtwdev, REG_LED_CFG);
|
||||
value32 &= ~(BIT_PAPE_SEL_EN | BIT_LNAON_SEL_EN);
|
||||
rtw_write32(rtwdev, REG_LED_CFG, value32);
|
||||
|
||||
value32 = rtw_read32(rtwdev, REG_GPIO_MUXCFG);
|
||||
value32 |= BIT_WLRFE_4_5_EN;
|
||||
rtw_write32(rtwdev, REG_GPIO_MUXCFG, value32);
|
||||
|
||||
/* disable BB/RF */
|
||||
value8 = rtw_read8(rtwdev, REG_SYS_FUNC_EN);
|
||||
value8 &= ~(BIT_FEN_BB_RSTB | BIT_FEN_BB_GLB_RST);
|
||||
rtw_write8(rtwdev, REG_SYS_FUNC_EN, value8);
|
||||
|
||||
value8 = rtw_read8(rtwdev, REG_RF_CTRL);
|
||||
value8 &= ~(BIT_RF_SDM_RSTB | BIT_RF_RSTB | BIT_RF_EN);
|
||||
rtw_write8(rtwdev, REG_RF_CTRL, value8);
|
||||
|
||||
value32 = rtw_read32(rtwdev, REG_WLRF1);
|
||||
value32 &= ~BIT_WLRF1_BBRF_EN;
|
||||
rtw_write32(rtwdev, REG_WLRF1, value32);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_pwr_cmd_polling(struct rtw_dev *rtwdev,
|
||||
struct rtw_pwr_seq_cmd *cmd)
|
||||
{
|
||||
u8 value;
|
||||
u8 flag = 0;
|
||||
u32 offset;
|
||||
u32 cnt = RTW_PWR_POLLING_CNT;
|
||||
|
||||
if (cmd->base == RTW_PWR_ADDR_SDIO)
|
||||
offset = cmd->offset | SDIO_LOCAL_OFFSET;
|
||||
else
|
||||
offset = cmd->offset;
|
||||
|
||||
do {
|
||||
cnt--;
|
||||
value = rtw_read8(rtwdev, offset);
|
||||
value &= cmd->mask;
|
||||
if (value == (cmd->value & cmd->mask))
|
||||
return 0;
|
||||
if (cnt == 0) {
|
||||
if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_PCIE &&
|
||||
flag == 0) {
|
||||
value = rtw_read8(rtwdev, REG_SYS_PW_CTRL);
|
||||
value |= BIT(3);
|
||||
rtw_write8(rtwdev, REG_SYS_PW_CTRL, value);
|
||||
value &= ~BIT(3);
|
||||
rtw_write8(rtwdev, REG_SYS_PW_CTRL, value);
|
||||
cnt = RTW_PWR_POLLING_CNT;
|
||||
flag = 1;
|
||||
} else {
|
||||
return -EBUSY;
|
||||
}
|
||||
} else {
|
||||
udelay(50);
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
|
||||
static int rtw_sub_pwr_seq_parser(struct rtw_dev *rtwdev, u8 intf_mask,
|
||||
u8 cut_mask, struct rtw_pwr_seq_cmd *cmd)
|
||||
{
|
||||
struct rtw_pwr_seq_cmd *cur_cmd;
|
||||
u32 offset;
|
||||
u8 value;
|
||||
|
||||
for (cur_cmd = cmd; cur_cmd->cmd != RTW_PWR_CMD_END; cur_cmd++) {
|
||||
if (!(cur_cmd->intf_mask & intf_mask) ||
|
||||
!(cur_cmd->cut_mask & cut_mask))
|
||||
continue;
|
||||
|
||||
switch (cur_cmd->cmd) {
|
||||
case RTW_PWR_CMD_WRITE:
|
||||
offset = cur_cmd->offset;
|
||||
|
||||
if (cur_cmd->base == RTW_PWR_ADDR_SDIO)
|
||||
offset |= SDIO_LOCAL_OFFSET;
|
||||
|
||||
value = rtw_read8(rtwdev, offset);
|
||||
value &= ~cur_cmd->mask;
|
||||
value |= (cur_cmd->value & cur_cmd->mask);
|
||||
rtw_write8(rtwdev, offset, value);
|
||||
break;
|
||||
case RTW_PWR_CMD_POLLING:
|
||||
if (rtw_pwr_cmd_polling(rtwdev, cur_cmd))
|
||||
return -EBUSY;
|
||||
break;
|
||||
case RTW_PWR_CMD_DELAY:
|
||||
if (cur_cmd->value == RTW_PWR_DELAY_US)
|
||||
udelay(cur_cmd->offset);
|
||||
else
|
||||
mdelay(cur_cmd->offset);
|
||||
break;
|
||||
case RTW_PWR_CMD_READ:
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_pwr_seq_parser(struct rtw_dev *rtwdev,
|
||||
struct rtw_pwr_seq_cmd **cmd_seq)
|
||||
{
|
||||
u8 cut_mask;
|
||||
u8 intf_mask;
|
||||
u8 cut;
|
||||
u32 idx = 0;
|
||||
struct rtw_pwr_seq_cmd *cmd;
|
||||
int ret;
|
||||
|
||||
cut = rtwdev->hal.cut_version;
|
||||
cut_mask = cut_version_to_mask(cut);
|
||||
switch (rtw_hci_type(rtwdev)) {
|
||||
case RTW_HCI_TYPE_PCIE:
|
||||
intf_mask = BIT(2);
|
||||
break;
|
||||
case RTW_HCI_TYPE_USB:
|
||||
intf_mask = BIT(1);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
do {
|
||||
cmd = cmd_seq[idx];
|
||||
if (!cmd)
|
||||
break;
|
||||
|
||||
ret = rtw_sub_pwr_seq_parser(rtwdev, intf_mask, cut_mask, cmd);
|
||||
if (ret)
|
||||
return -EBUSY;
|
||||
|
||||
idx++;
|
||||
} while (1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_mac_power_switch(struct rtw_dev *rtwdev, bool pwr_on)
|
||||
{
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
struct rtw_pwr_seq_cmd **pwr_seq;
|
||||
u8 rpwm;
|
||||
bool cur_pwr;
|
||||
|
||||
rpwm = rtw_read8(rtwdev, rtwdev->hci.rpwm_addr);
|
||||
|
||||
/* Check FW still exist or not */
|
||||
if (rtw_read16(rtwdev, REG_MCUFW_CTRL) == 0xC078) {
|
||||
rpwm = (rpwm ^ BIT_RPWM_TOGGLE) & BIT_RPWM_TOGGLE;
|
||||
rtw_write8(rtwdev, rtwdev->hci.rpwm_addr, rpwm);
|
||||
}
|
||||
|
||||
if (rtw_read8(rtwdev, REG_CR) == 0xea)
|
||||
cur_pwr = false;
|
||||
else if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_USB &&
|
||||
(rtw_read8(rtwdev, REG_SYS_STATUS1 + 1) & BIT(0)))
|
||||
cur_pwr = false;
|
||||
else
|
||||
cur_pwr = true;
|
||||
|
||||
if (pwr_on && cur_pwr)
|
||||
return -EALREADY;
|
||||
|
||||
pwr_seq = pwr_on ? chip->pwr_on_seq : chip->pwr_off_seq;
|
||||
if (rtw_pwr_seq_parser(rtwdev, pwr_seq))
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_mac_init_system_cfg(struct rtw_dev *rtwdev)
|
||||
{
|
||||
u8 sys_func_en = rtwdev->chip->sys_func_en;
|
||||
u8 value8;
|
||||
u32 value, tmp;
|
||||
|
||||
value = rtw_read32(rtwdev, REG_CPU_DMEM_CON);
|
||||
value |= BIT_WL_PLATFORM_RST | BIT_DDMA_EN;
|
||||
rtw_write32(rtwdev, REG_CPU_DMEM_CON, value);
|
||||
|
||||
rtw_write8(rtwdev, REG_SYS_FUNC_EN + 1, sys_func_en);
|
||||
value8 = (rtw_read8(rtwdev, REG_CR_EXT + 3) & 0xF0) | 0x0C;
|
||||
rtw_write8(rtwdev, REG_CR_EXT + 3, value8);
|
||||
|
||||
/* disable boot-from-flash for driver's DL FW */
|
||||
tmp = rtw_read32(rtwdev, REG_MCUFW_CTRL);
|
||||
if (tmp & BIT_BOOT_FSPI_EN) {
|
||||
rtw_write32(rtwdev, REG_MCUFW_CTRL, tmp & (~BIT_BOOT_FSPI_EN));
|
||||
value = rtw_read32(rtwdev, REG_GPIO_MUXCFG) & (~BIT_FSPI_EN);
|
||||
rtw_write32(rtwdev, REG_GPIO_MUXCFG, value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtw_mac_power_on(struct rtw_dev *rtwdev)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = rtw_mac_pre_system_cfg(rtwdev);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = rtw_mac_power_switch(rtwdev, true);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = rtw_mac_init_system_cfg(rtwdev);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
rtw_err(rtwdev, "mac power on failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rtw_mac_power_off(struct rtw_dev *rtwdev)
|
||||
{
|
||||
rtw_mac_power_switch(rtwdev, false);
|
||||
}
|
||||
|
||||
static bool check_firmware_size(const u8 *data, u32 size)
|
||||
{
|
||||
u32 dmem_size;
|
||||
u32 imem_size;
|
||||
u32 emem_size;
|
||||
u32 real_size;
|
||||
|
||||
dmem_size = le32_to_cpu(*((__le32 *)(data + FW_HDR_DMEM_SIZE)));
|
||||
imem_size = le32_to_cpu(*((__le32 *)(data + FW_HDR_IMEM_SIZE)));
|
||||
emem_size = ((*(data + FW_HDR_MEM_USAGE)) & BIT(4)) ?
|
||||
le32_to_cpu(*((__le32 *)(data + FW_HDR_EMEM_SIZE))) : 0;
|
||||
|
||||
dmem_size += FW_HDR_CHKSUM_SIZE;
|
||||
imem_size += FW_HDR_CHKSUM_SIZE;
|
||||
emem_size += emem_size ? FW_HDR_CHKSUM_SIZE : 0;
|
||||
real_size = FW_HDR_SIZE + dmem_size + imem_size + emem_size;
|
||||
if (real_size != size)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void wlan_cpu_enable(struct rtw_dev *rtwdev, bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
/* cpu io interface enable */
|
||||
rtw_write8_set(rtwdev, REG_RSV_CTRL + 1, BIT_WLMCU_IOIF);
|
||||
|
||||
/* cpu enable */
|
||||
rtw_write8_set(rtwdev, REG_SYS_FUNC_EN + 1, BIT_FEN_CPUEN);
|
||||
} else {
|
||||
/* cpu io interface disable */
|
||||
rtw_write8_clr(rtwdev, REG_SYS_FUNC_EN + 1, BIT_FEN_CPUEN);
|
||||
|
||||
/* cpu disable */
|
||||
rtw_write8_clr(rtwdev, REG_RSV_CTRL + 1, BIT_WLMCU_IOIF);
|
||||
}
|
||||
}
|
||||
|
||||
#define DLFW_RESTORE_REG_NUM 6
|
||||
|
||||
static void download_firmware_reg_backup(struct rtw_dev *rtwdev,
|
||||
struct rtw_backup_info *bckp)
|
||||
{
|
||||
u8 tmp;
|
||||
u8 bckp_idx = 0;
|
||||
|
||||
/* set HIQ to hi priority */
|
||||
bckp[bckp_idx].len = 1;
|
||||
bckp[bckp_idx].reg = REG_TXDMA_PQ_MAP + 1;
|
||||
bckp[bckp_idx].val = rtw_read8(rtwdev, REG_TXDMA_PQ_MAP + 1);
|
||||
bckp_idx++;
|
||||
tmp = RTW_DMA_MAPPING_HIGH << 6;
|
||||
rtw_write8(rtwdev, REG_TXDMA_PQ_MAP + 1, tmp);
|
||||
|
||||
/* DLFW only use HIQ, map HIQ to hi priority */
|
||||
bckp[bckp_idx].len = 1;
|
||||
bckp[bckp_idx].reg = REG_CR;
|
||||
bckp[bckp_idx].val = rtw_read8(rtwdev, REG_CR);
|
||||
bckp_idx++;
|
||||
bckp[bckp_idx].len = 4;
|
||||
bckp[bckp_idx].reg = REG_H2CQ_CSR;
|
||||
bckp[bckp_idx].val = BIT_H2CQ_FULL;
|
||||
bckp_idx++;
|
||||
tmp = BIT_HCI_TXDMA_EN | BIT_TXDMA_EN;
|
||||
rtw_write8(rtwdev, REG_CR, tmp);
|
||||
rtw_write32(rtwdev, REG_H2CQ_CSR, BIT_H2CQ_FULL);
|
||||
|
||||
/* Config hi priority queue and public priority queue page number */
|
||||
bckp[bckp_idx].len = 2;
|
||||
bckp[bckp_idx].reg = REG_FIFOPAGE_INFO_1;
|
||||
bckp[bckp_idx].val = rtw_read16(rtwdev, REG_FIFOPAGE_INFO_1);
|
||||
bckp_idx++;
|
||||
bckp[bckp_idx].len = 4;
|
||||
bckp[bckp_idx].reg = REG_RQPN_CTRL_2;
|
||||
bckp[bckp_idx].val = rtw_read32(rtwdev, REG_RQPN_CTRL_2) | BIT_LD_RQPN;
|
||||
bckp_idx++;
|
||||
rtw_write16(rtwdev, REG_FIFOPAGE_INFO_1, 0x200);
|
||||
rtw_write32(rtwdev, REG_RQPN_CTRL_2, bckp[bckp_idx - 1].val);
|
||||
|
||||
/* Disable beacon related functions */
|
||||
tmp = rtw_read8(rtwdev, REG_BCN_CTRL);
|
||||
bckp[bckp_idx].len = 1;
|
||||
bckp[bckp_idx].reg = REG_BCN_CTRL;
|
||||
bckp[bckp_idx].val = tmp;
|
||||
bckp_idx++;
|
||||
tmp = (u8)((tmp & (~BIT_EN_BCN_FUNCTION)) | BIT_DIS_TSF_UDT);
|
||||
rtw_write8(rtwdev, REG_BCN_CTRL, tmp);
|
||||
|
||||
WARN(bckp_idx != DLFW_RESTORE_REG_NUM, "wrong backup number\n");
|
||||
}
|
||||
|
||||
static void download_firmware_reset_platform(struct rtw_dev *rtwdev)
|
||||
{
|
||||
rtw_write8_clr(rtwdev, REG_CPU_DMEM_CON + 2, BIT_WL_PLATFORM_RST >> 16);
|
||||
rtw_write8_clr(rtwdev, REG_SYS_CLK_CTRL + 1, BIT_CPU_CLK_EN >> 8);
|
||||
rtw_write8_set(rtwdev, REG_CPU_DMEM_CON + 2, BIT_WL_PLATFORM_RST >> 16);
|
||||
rtw_write8_set(rtwdev, REG_SYS_CLK_CTRL + 1, BIT_CPU_CLK_EN >> 8);
|
||||
}
|
||||
|
||||
static void download_firmware_reg_restore(struct rtw_dev *rtwdev,
|
||||
struct rtw_backup_info *bckp,
|
||||
u8 bckp_num)
|
||||
{
|
||||
rtw_restore_reg(rtwdev, bckp, bckp_num);
|
||||
}
|
||||
|
||||
#define TX_DESC_SIZE 48
|
||||
|
||||
static int send_firmware_pkt_rsvd_page(struct rtw_dev *rtwdev, u16 pg_addr,
|
||||
const u8 *data, u32 size)
|
||||
{
|
||||
u8 *buf;
|
||||
int ret;
|
||||
|
||||
buf = kmemdup(data, size, GFP_KERNEL);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = rtw_fw_write_data_rsvd_page(rtwdev, pg_addr, buf, size);
|
||||
kfree(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
send_firmware_pkt(struct rtw_dev *rtwdev, u16 pg_addr, const u8 *data, u32 size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_USB &&
|
||||
!((size + TX_DESC_SIZE) & (512 - 1)))
|
||||
size += 1;
|
||||
|
||||
ret = send_firmware_pkt_rsvd_page(rtwdev, pg_addr, data, size);
|
||||
if (ret)
|
||||
rtw_err(rtwdev, "failed to download rsvd page\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
iddma_enable(struct rtw_dev *rtwdev, u32 src, u32 dst, u32 ctrl)
|
||||
{
|
||||
rtw_write32(rtwdev, REG_DDMA_CH0SA, src);
|
||||
rtw_write32(rtwdev, REG_DDMA_CH0DA, dst);
|
||||
rtw_write32(rtwdev, REG_DDMA_CH0CTRL, ctrl);
|
||||
|
||||
if (!check_hw_ready(rtwdev, REG_DDMA_CH0CTRL, BIT_DDMACH0_OWN, 0))
|
||||
return -EBUSY;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iddma_download_firmware(struct rtw_dev *rtwdev, u32 src, u32 dst,
|
||||
u32 len, u8 first)
|
||||
{
|
||||
u32 ch0_ctrl = BIT_DDMACH0_CHKSUM_EN | BIT_DDMACH0_OWN;
|
||||
|
||||
if (!check_hw_ready(rtwdev, REG_DDMA_CH0CTRL, BIT_DDMACH0_OWN, 0))
|
||||
return -EBUSY;
|
||||
|
||||
ch0_ctrl |= len & BIT_MASK_DDMACH0_DLEN;
|
||||
if (!first)
|
||||
ch0_ctrl |= BIT_DDMACH0_CHKSUM_CONT;
|
||||
|
||||
if (iddma_enable(rtwdev, src, dst, ch0_ctrl))
|
||||
return -EBUSY;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool
|
||||
check_fw_checksum(struct rtw_dev *rtwdev, u32 addr)
|
||||
{
|
||||
u8 fw_ctrl;
|
||||
|
||||
fw_ctrl = rtw_read8(rtwdev, REG_MCUFW_CTRL);
|
||||
|
||||
if (rtw_read32(rtwdev, REG_DDMA_CH0CTRL) & BIT_DDMACH0_CHKSUM_STS) {
|
||||
if (addr < OCPBASE_DMEM_88XX) {
|
||||
fw_ctrl |= BIT_IMEM_DW_OK;
|
||||
fw_ctrl &= ~BIT_IMEM_CHKSUM_OK;
|
||||
rtw_write8(rtwdev, REG_MCUFW_CTRL, fw_ctrl);
|
||||
} else {
|
||||
fw_ctrl |= BIT_DMEM_DW_OK;
|
||||
fw_ctrl &= ~BIT_DMEM_CHKSUM_OK;
|
||||
rtw_write8(rtwdev, REG_MCUFW_CTRL, fw_ctrl);
|
||||
}
|
||||
|
||||
rtw_err(rtwdev, "invalid fw checksum\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (addr < OCPBASE_DMEM_88XX) {
|
||||
fw_ctrl |= (BIT_IMEM_DW_OK | BIT_IMEM_CHKSUM_OK);
|
||||
rtw_write8(rtwdev, REG_MCUFW_CTRL, fw_ctrl);
|
||||
} else {
|
||||
fw_ctrl |= (BIT_DMEM_DW_OK | BIT_DMEM_CHKSUM_OK);
|
||||
rtw_write8(rtwdev, REG_MCUFW_CTRL, fw_ctrl);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int
|
||||
download_firmware_to_mem(struct rtw_dev *rtwdev, const u8 *data,
|
||||
u32 src, u32 dst, u32 size)
|
||||
{
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
u32 desc_size = chip->tx_pkt_desc_sz;
|
||||
u8 first_part;
|
||||
u32 mem_offset;
|
||||
u32 residue_size;
|
||||
u32 pkt_size;
|
||||
u32 max_size = 0x1000;
|
||||
u32 val;
|
||||
int ret;
|
||||
|
||||
mem_offset = 0;
|
||||
first_part = 1;
|
||||
residue_size = size;
|
||||
|
||||
val = rtw_read32(rtwdev, REG_DDMA_CH0CTRL);
|
||||
val |= BIT_DDMACH0_RESET_CHKSUM_STS;
|
||||
rtw_write32(rtwdev, REG_DDMA_CH0CTRL, val);
|
||||
|
||||
while (residue_size) {
|
||||
if (residue_size >= max_size)
|
||||
pkt_size = max_size;
|
||||
else
|
||||
pkt_size = residue_size;
|
||||
|
||||
ret = send_firmware_pkt(rtwdev, (u16)(src >> 7),
|
||||
data + mem_offset, pkt_size);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = iddma_download_firmware(rtwdev, OCPBASE_TXBUF_88XX +
|
||||
src + desc_size,
|
||||
dst + mem_offset, pkt_size,
|
||||
first_part);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
first_part = 0;
|
||||
mem_offset += pkt_size;
|
||||
residue_size -= pkt_size;
|
||||
}
|
||||
|
||||
if (!check_fw_checksum(rtwdev, dst))
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void update_firmware_info(struct rtw_dev *rtwdev,
|
||||
struct rtw_fw_state *fw)
|
||||
{
|
||||
const u8 *data = fw->firmware->data;
|
||||
|
||||
fw->h2c_version =
|
||||
le16_to_cpu(*((__le16 *)(data + FW_HDR_H2C_FMT_VER)));
|
||||
fw->version =
|
||||
le16_to_cpu(*((__le16 *)(data + FW_HDR_VERSION)));
|
||||
fw->sub_version = *(data + FW_HDR_SUBVERSION);
|
||||
fw->sub_index = *(data + FW_HDR_SUBINDEX);
|
||||
|
||||
rtw_dbg(rtwdev, RTW_DBG_FW, "fw h2c version: %x\n", fw->h2c_version);
|
||||
rtw_dbg(rtwdev, RTW_DBG_FW, "fw version: %x\n", fw->version);
|
||||
rtw_dbg(rtwdev, RTW_DBG_FW, "fw sub version: %x\n", fw->sub_version);
|
||||
rtw_dbg(rtwdev, RTW_DBG_FW, "fw sub index: %x\n", fw->sub_index);
|
||||
}
|
||||
|
||||
static int
|
||||
start_download_firmware(struct rtw_dev *rtwdev, const u8 *data, u32 size)
|
||||
{
|
||||
const u8 *cur_fw;
|
||||
u16 val;
|
||||
u32 imem_size;
|
||||
u32 dmem_size;
|
||||
u32 emem_size;
|
||||
u32 addr;
|
||||
int ret;
|
||||
|
||||
dmem_size = le32_to_cpu(*((__le32 *)(data + FW_HDR_DMEM_SIZE)));
|
||||
imem_size = le32_to_cpu(*((__le32 *)(data + FW_HDR_IMEM_SIZE)));
|
||||
emem_size = ((*(data + FW_HDR_MEM_USAGE)) & BIT(4)) ?
|
||||
le32_to_cpu(*((__le32 *)(data + FW_HDR_EMEM_SIZE))) : 0;
|
||||
dmem_size += FW_HDR_CHKSUM_SIZE;
|
||||
imem_size += FW_HDR_CHKSUM_SIZE;
|
||||
emem_size += emem_size ? FW_HDR_CHKSUM_SIZE : 0;
|
||||
|
||||
val = (u16)(rtw_read16(rtwdev, REG_MCUFW_CTRL) & 0x3800);
|
||||
val |= BIT_MCUFWDL_EN;
|
||||
rtw_write16(rtwdev, REG_MCUFW_CTRL, val);
|
||||
|
||||
cur_fw = data + FW_HDR_SIZE;
|
||||
addr = le32_to_cpu(*((__le32 *)(data + FW_HDR_DMEM_ADDR)));
|
||||
addr &= ~BIT(31);
|
||||
ret = download_firmware_to_mem(rtwdev, cur_fw, 0, addr, dmem_size);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
cur_fw = data + FW_HDR_SIZE + dmem_size;
|
||||
addr = le32_to_cpu(*((__le32 *)(data + FW_HDR_IMEM_ADDR)));
|
||||
addr &= ~BIT(31);
|
||||
ret = download_firmware_to_mem(rtwdev, cur_fw, 0, addr, imem_size);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (emem_size) {
|
||||
cur_fw = data + FW_HDR_SIZE + dmem_size + imem_size;
|
||||
addr = le32_to_cpu(*((__le32 *)(data + FW_HDR_EMEM_ADDR)));
|
||||
addr &= ~BIT(31);
|
||||
ret = download_firmware_to_mem(rtwdev, cur_fw, 0, addr,
|
||||
emem_size);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int download_firmware_validate(struct rtw_dev *rtwdev)
|
||||
{
|
||||
u32 fw_key;
|
||||
|
||||
if (!check_hw_ready(rtwdev, REG_MCUFW_CTRL, FW_READY_MASK, FW_READY)) {
|
||||
fw_key = rtw_read32(rtwdev, REG_FW_DBG7) & FW_KEY_MASK;
|
||||
if (fw_key == ILLEGAL_KEY_GROUP)
|
||||
rtw_err(rtwdev, "invalid fw key\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void download_firmware_end_flow(struct rtw_dev *rtwdev)
|
||||
{
|
||||
u16 fw_ctrl;
|
||||
|
||||
rtw_write32(rtwdev, REG_TXDMA_STATUS, BTI_PAGE_OVF);
|
||||
|
||||
/* Check IMEM & DMEM checksum is OK or not */
|
||||
fw_ctrl = rtw_read16(rtwdev, REG_MCUFW_CTRL);
|
||||
if ((fw_ctrl & BIT_CHECK_SUM_OK) != BIT_CHECK_SUM_OK)
|
||||
return;
|
||||
|
||||
fw_ctrl = (fw_ctrl | BIT_FW_DW_RDY) & ~BIT_MCUFWDL_EN;
|
||||
rtw_write16(rtwdev, REG_MCUFW_CTRL, fw_ctrl);
|
||||
}
|
||||
|
||||
int rtw_download_firmware(struct rtw_dev *rtwdev, struct rtw_fw_state *fw)
|
||||
{
|
||||
struct rtw_backup_info bckp[DLFW_RESTORE_REG_NUM];
|
||||
const u8 *data = fw->firmware->data;
|
||||
u32 size = fw->firmware->size;
|
||||
u32 ltecoex_bckp;
|
||||
int ret;
|
||||
|
||||
if (!check_firmware_size(data, size))
|
||||
return -EINVAL;
|
||||
|
||||
if (!ltecoex_read_reg(rtwdev, 0x38, <ecoex_bckp))
|
||||
return -EBUSY;
|
||||
|
||||
wlan_cpu_enable(rtwdev, false);
|
||||
|
||||
download_firmware_reg_backup(rtwdev, bckp);
|
||||
download_firmware_reset_platform(rtwdev);
|
||||
|
||||
ret = start_download_firmware(rtwdev, data, size);
|
||||
if (ret)
|
||||
goto dlfw_fail;
|
||||
|
||||
download_firmware_reg_restore(rtwdev, bckp, DLFW_RESTORE_REG_NUM);
|
||||
|
||||
download_firmware_end_flow(rtwdev);
|
||||
|
||||
wlan_cpu_enable(rtwdev, true);
|
||||
|
||||
if (!ltecoex_reg_write(rtwdev, 0x38, ltecoex_bckp))
|
||||
return -EBUSY;
|
||||
|
||||
ret = download_firmware_validate(rtwdev);
|
||||
if (ret)
|
||||
goto dlfw_fail;
|
||||
|
||||
update_firmware_info(rtwdev, fw);
|
||||
|
||||
/* reset desc and index */
|
||||
rtw_hci_setup(rtwdev);
|
||||
|
||||
rtwdev->h2c.last_box_num = 0;
|
||||
rtwdev->h2c.seq = 0;
|
||||
|
||||
rtw_fw_send_general_info(rtwdev);
|
||||
rtw_fw_send_phydm_info(rtwdev);
|
||||
|
||||
rtw_flag_set(rtwdev, RTW_FLAG_FW_RUNNING);
|
||||
|
||||
return 0;
|
||||
|
||||
dlfw_fail:
|
||||
/* Disable FWDL_EN */
|
||||
rtw_write8_clr(rtwdev, REG_MCUFW_CTRL, BIT_MCUFWDL_EN);
|
||||
rtw_write8_set(rtwdev, REG_SYS_FUNC_EN + 1, BIT_FEN_CPUEN);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int txdma_queue_mapping(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
struct rtw_rqpn *rqpn = NULL;
|
||||
u16 txdma_pq_map = 0;
|
||||
|
||||
switch (rtw_hci_type(rtwdev)) {
|
||||
case RTW_HCI_TYPE_PCIE:
|
||||
rqpn = &chip->rqpn_table[1];
|
||||
break;
|
||||
case RTW_HCI_TYPE_USB:
|
||||
if (rtwdev->hci.bulkout_num == 2)
|
||||
rqpn = &chip->rqpn_table[2];
|
||||
else if (rtwdev->hci.bulkout_num == 3)
|
||||
rqpn = &chip->rqpn_table[3];
|
||||
else if (rtwdev->hci.bulkout_num == 4)
|
||||
rqpn = &chip->rqpn_table[4];
|
||||
else
|
||||
return -EINVAL;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
txdma_pq_map |= BIT_TXDMA_HIQ_MAP(rqpn->dma_map_hi);
|
||||
txdma_pq_map |= BIT_TXDMA_MGQ_MAP(rqpn->dma_map_mg);
|
||||
txdma_pq_map |= BIT_TXDMA_BKQ_MAP(rqpn->dma_map_bk);
|
||||
txdma_pq_map |= BIT_TXDMA_BEQ_MAP(rqpn->dma_map_be);
|
||||
txdma_pq_map |= BIT_TXDMA_VIQ_MAP(rqpn->dma_map_vi);
|
||||
txdma_pq_map |= BIT_TXDMA_VOQ_MAP(rqpn->dma_map_vo);
|
||||
rtw_write16(rtwdev, REG_TXDMA_PQ_MAP, txdma_pq_map);
|
||||
|
||||
rtw_write8(rtwdev, REG_CR, 0);
|
||||
rtw_write8(rtwdev, REG_CR, MAC_TRX_ENABLE);
|
||||
rtw_write32(rtwdev, REG_H2CQ_CSR, BIT_H2CQ_FULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_trx_fifo_info(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_fifo_conf *fifo = &rtwdev->fifo;
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
u16 cur_pg_addr;
|
||||
u8 csi_buf_pg_num = chip->csi_buf_pg_num;
|
||||
|
||||
/* config rsvd page num */
|
||||
fifo->rsvd_drv_pg_num = 8;
|
||||
fifo->txff_pg_num = chip->txff_size >> 7;
|
||||
fifo->rsvd_pg_num = fifo->rsvd_drv_pg_num +
|
||||
RSVD_PG_H2C_EXTRAINFO_NUM +
|
||||
RSVD_PG_H2C_STATICINFO_NUM +
|
||||
RSVD_PG_H2CQ_NUM +
|
||||
RSVD_PG_CPU_INSTRUCTION_NUM +
|
||||
RSVD_PG_FW_TXBUF_NUM +
|
||||
csi_buf_pg_num;
|
||||
|
||||
if (fifo->rsvd_pg_num > fifo->txff_pg_num)
|
||||
return -ENOMEM;
|
||||
|
||||
fifo->acq_pg_num = fifo->txff_pg_num - fifo->rsvd_pg_num;
|
||||
fifo->rsvd_boundary = fifo->txff_pg_num - fifo->rsvd_pg_num;
|
||||
|
||||
cur_pg_addr = fifo->txff_pg_num;
|
||||
cur_pg_addr -= csi_buf_pg_num;
|
||||
fifo->rsvd_csibuf_addr = cur_pg_addr;
|
||||
cur_pg_addr -= RSVD_PG_FW_TXBUF_NUM;
|
||||
fifo->rsvd_fw_txbuf_addr = cur_pg_addr;
|
||||
cur_pg_addr -= RSVD_PG_CPU_INSTRUCTION_NUM;
|
||||
fifo->rsvd_cpu_instr_addr = cur_pg_addr;
|
||||
cur_pg_addr -= RSVD_PG_H2CQ_NUM;
|
||||
fifo->rsvd_h2cq_addr = cur_pg_addr;
|
||||
cur_pg_addr -= RSVD_PG_H2C_STATICINFO_NUM;
|
||||
fifo->rsvd_h2c_sta_info_addr = cur_pg_addr;
|
||||
cur_pg_addr -= RSVD_PG_H2C_EXTRAINFO_NUM;
|
||||
fifo->rsvd_h2c_info_addr = cur_pg_addr;
|
||||
cur_pg_addr -= fifo->rsvd_drv_pg_num;
|
||||
fifo->rsvd_drv_addr = cur_pg_addr;
|
||||
|
||||
if (fifo->rsvd_boundary != fifo->rsvd_drv_addr) {
|
||||
rtw_err(rtwdev, "wrong rsvd driver address\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int priority_queue_cfg(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_fifo_conf *fifo = &rtwdev->fifo;
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
struct rtw_page_table *pg_tbl = NULL;
|
||||
u16 pubq_num;
|
||||
int ret;
|
||||
|
||||
ret = set_trx_fifo_info(rtwdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
switch (rtw_hci_type(rtwdev)) {
|
||||
case RTW_HCI_TYPE_PCIE:
|
||||
pg_tbl = &chip->page_table[1];
|
||||
break;
|
||||
case RTW_HCI_TYPE_USB:
|
||||
if (rtwdev->hci.bulkout_num == 2)
|
||||
pg_tbl = &chip->page_table[2];
|
||||
else if (rtwdev->hci.bulkout_num == 3)
|
||||
pg_tbl = &chip->page_table[3];
|
||||
else if (rtwdev->hci.bulkout_num == 4)
|
||||
pg_tbl = &chip->page_table[4];
|
||||
else
|
||||
return -EINVAL;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pubq_num = fifo->acq_pg_num - pg_tbl->hq_num - pg_tbl->lq_num -
|
||||
pg_tbl->nq_num - pg_tbl->exq_num - pg_tbl->gapq_num;
|
||||
rtw_write16(rtwdev, REG_FIFOPAGE_INFO_1, pg_tbl->hq_num);
|
||||
rtw_write16(rtwdev, REG_FIFOPAGE_INFO_2, pg_tbl->lq_num);
|
||||
rtw_write16(rtwdev, REG_FIFOPAGE_INFO_3, pg_tbl->nq_num);
|
||||
rtw_write16(rtwdev, REG_FIFOPAGE_INFO_4, pg_tbl->exq_num);
|
||||
rtw_write16(rtwdev, REG_FIFOPAGE_INFO_5, pubq_num);
|
||||
rtw_write32_set(rtwdev, REG_RQPN_CTRL_2, BIT_LD_RQPN);
|
||||
|
||||
rtw_write16(rtwdev, REG_FIFOPAGE_CTRL_2, fifo->rsvd_boundary);
|
||||
rtw_write8_set(rtwdev, REG_FWHW_TXQ_CTRL + 2, BIT_EN_WR_FREE_TAIL >> 16);
|
||||
|
||||
rtw_write16(rtwdev, REG_BCNQ_BDNY_V1, fifo->rsvd_boundary);
|
||||
rtw_write16(rtwdev, REG_FIFOPAGE_CTRL_2 + 2, fifo->rsvd_boundary);
|
||||
rtw_write16(rtwdev, REG_BCNQ1_BDNY_V1, fifo->rsvd_boundary);
|
||||
rtw_write32(rtwdev, REG_RXFF_BNDY, chip->rxff_size - C2H_PKT_BUF - 1);
|
||||
rtw_write8_set(rtwdev, REG_AUTO_LLT_V1, BIT_AUTO_INIT_LLT_V1);
|
||||
|
||||
if (!check_hw_ready(rtwdev, REG_AUTO_LLT_V1, BIT_AUTO_INIT_LLT_V1, 0))
|
||||
return -EBUSY;
|
||||
|
||||
rtw_write8(rtwdev, REG_CR + 3, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int init_h2c(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_fifo_conf *fifo = &rtwdev->fifo;
|
||||
u8 value8;
|
||||
u32 value32;
|
||||
u32 h2cq_addr;
|
||||
u32 h2cq_size;
|
||||
u32 h2cq_free;
|
||||
u32 wp, rp;
|
||||
|
||||
h2cq_addr = fifo->rsvd_h2cq_addr << TX_PAGE_SIZE_SHIFT;
|
||||
h2cq_size = RSVD_PG_H2CQ_NUM << TX_PAGE_SIZE_SHIFT;
|
||||
|
||||
value32 = rtw_read32(rtwdev, REG_H2C_HEAD);
|
||||
value32 = (value32 & 0xFFFC0000) | h2cq_addr;
|
||||
rtw_write32(rtwdev, REG_H2C_HEAD, value32);
|
||||
|
||||
value32 = rtw_read32(rtwdev, REG_H2C_READ_ADDR);
|
||||
value32 = (value32 & 0xFFFC0000) | h2cq_addr;
|
||||
rtw_write32(rtwdev, REG_H2C_READ_ADDR, value32);
|
||||
|
||||
value32 = rtw_read32(rtwdev, REG_H2C_TAIL);
|
||||
value32 &= 0xFFFC0000;
|
||||
value32 |= (h2cq_addr + h2cq_size);
|
||||
rtw_write32(rtwdev, REG_H2C_TAIL, value32);
|
||||
|
||||
value8 = rtw_read8(rtwdev, REG_H2C_INFO);
|
||||
value8 = (u8)((value8 & 0xFC) | 0x01);
|
||||
rtw_write8(rtwdev, REG_H2C_INFO, value8);
|
||||
|
||||
value8 = rtw_read8(rtwdev, REG_H2C_INFO);
|
||||
value8 = (u8)((value8 & 0xFB) | 0x04);
|
||||
rtw_write8(rtwdev, REG_H2C_INFO, value8);
|
||||
|
||||
value8 = rtw_read8(rtwdev, REG_TXDMA_OFFSET_CHK + 1);
|
||||
value8 = (u8)((value8 & 0x7f) | 0x80);
|
||||
rtw_write8(rtwdev, REG_TXDMA_OFFSET_CHK + 1, value8);
|
||||
|
||||
wp = rtw_read32(rtwdev, REG_H2C_PKT_WRITEADDR) & 0x3FFFF;
|
||||
rp = rtw_read32(rtwdev, REG_H2C_PKT_READADDR) & 0x3FFFF;
|
||||
h2cq_free = wp >= rp ? h2cq_size - (wp - rp) : rp - wp;
|
||||
|
||||
if (h2cq_size != h2cq_free) {
|
||||
rtw_err(rtwdev, "H2C queue mismatch\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_init_trx_cfg(struct rtw_dev *rtwdev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = txdma_queue_mapping(rtwdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = priority_queue_cfg(rtwdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = init_h2c(rtwdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_drv_info_cfg(struct rtw_dev *rtwdev)
|
||||
{
|
||||
u8 value8;
|
||||
|
||||
rtw_write8(rtwdev, REG_RX_DRVINFO_SZ, PHY_STATUS_SIZE);
|
||||
value8 = rtw_read8(rtwdev, REG_TRXFF_BNDY + 1);
|
||||
value8 &= 0xF0;
|
||||
/* For rxdesc len = 0 issue */
|
||||
value8 |= 0xF;
|
||||
rtw_write8(rtwdev, REG_TRXFF_BNDY + 1, value8);
|
||||
rtw_write32_set(rtwdev, REG_RCR, BIT_APP_PHYSTS);
|
||||
rtw_write32_clr(rtwdev, REG_WMAC_OPTION_FUNCTION + 4, BIT(8) | BIT(9));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtw_mac_init(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
int ret;
|
||||
|
||||
ret = rtw_init_trx_cfg(rtwdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = chip->ops->mac_init(rtwdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = rtw_drv_info_cfg(rtwdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
35
drivers/net/wireless/realtek/rtw88/mac.h
Normal file
35
drivers/net/wireless/realtek/rtw88/mac.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_MAC_H__
|
||||
#define __RTW_MAC_H__
|
||||
|
||||
#define RTW_HW_PORT_NUM 5
|
||||
#define cut_version_to_mask(cut) (0x1 << ((cut) + 1))
|
||||
#define SDIO_LOCAL_OFFSET 0x10250000
|
||||
#define DDMA_POLLING_COUNT 1000
|
||||
#define C2H_PKT_BUF 256
|
||||
#define PHY_STATUS_SIZE 4
|
||||
#define ILLEGAL_KEY_GROUP 0xFAAAAA00
|
||||
|
||||
/* HW memory address */
|
||||
#define OCPBASE_TXBUF_88XX 0x18780000
|
||||
#define OCPBASE_DMEM_88XX 0x00200000
|
||||
#define OCPBASE_EMEM_88XX 0x00100000
|
||||
|
||||
#define RSVD_PG_DRV_NUM 16
|
||||
#define RSVD_PG_H2C_EXTRAINFO_NUM 24
|
||||
#define RSVD_PG_H2C_STATICINFO_NUM 8
|
||||
#define RSVD_PG_H2CQ_NUM 8
|
||||
#define RSVD_PG_CPU_INSTRUCTION_NUM 0
|
||||
#define RSVD_PG_FW_TXBUF_NUM 4
|
||||
|
||||
void rtw_set_channel_mac(struct rtw_dev *rtwdev, u8 channel, u8 bw,
|
||||
u8 primary_ch_idx);
|
||||
int rtw_mac_power_on(struct rtw_dev *rtwdev);
|
||||
void rtw_mac_power_off(struct rtw_dev *rtwdev);
|
||||
int rtw_download_firmware(struct rtw_dev *rtwdev, struct rtw_fw_state *fw);
|
||||
int rtw_mac_init(struct rtw_dev *rtwdev);
|
||||
|
||||
#endif
|
481
drivers/net/wireless/realtek/rtw88/mac80211.c
Normal file
481
drivers/net/wireless/realtek/rtw88/mac80211.c
Normal file
|
@ -0,0 +1,481 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "sec.h"
|
||||
#include "tx.h"
|
||||
#include "fw.h"
|
||||
#include "mac.h"
|
||||
#include "ps.h"
|
||||
#include "reg.h"
|
||||
#include "debug.h"
|
||||
|
||||
static void rtw_ops_tx(struct ieee80211_hw *hw,
|
||||
struct ieee80211_tx_control *control,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct rtw_tx_pkt_info pkt_info = {0};
|
||||
|
||||
if (!rtw_flag_check(rtwdev, RTW_FLAG_RUNNING))
|
||||
goto out;
|
||||
|
||||
rtw_tx_pkt_info_update(rtwdev, &pkt_info, control, skb);
|
||||
if (rtw_hci_tx(rtwdev, &pkt_info, skb))
|
||||
goto out;
|
||||
|
||||
return;
|
||||
|
||||
out:
|
||||
ieee80211_free_txskb(hw, skb);
|
||||
}
|
||||
|
||||
static int rtw_ops_start(struct ieee80211_hw *hw)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&rtwdev->mutex);
|
||||
ret = rtw_core_start(rtwdev);
|
||||
mutex_unlock(&rtwdev->mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void rtw_ops_stop(struct ieee80211_hw *hw)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
|
||||
mutex_lock(&rtwdev->mutex);
|
||||
rtw_core_stop(rtwdev);
|
||||
mutex_unlock(&rtwdev->mutex);
|
||||
}
|
||||
|
||||
static int rtw_ops_config(struct ieee80211_hw *hw, u32 changed)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&rtwdev->mutex);
|
||||
|
||||
if (changed & IEEE80211_CONF_CHANGE_IDLE) {
|
||||
if (hw->conf.flags & IEEE80211_CONF_IDLE) {
|
||||
rtw_enter_ips(rtwdev);
|
||||
} else {
|
||||
ret = rtw_leave_ips(rtwdev);
|
||||
if (ret) {
|
||||
rtw_err(rtwdev, "failed to leave idle state\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed & IEEE80211_CONF_CHANGE_CHANNEL)
|
||||
rtw_set_channel(rtwdev);
|
||||
|
||||
out:
|
||||
mutex_unlock(&rtwdev->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct rtw_vif_port rtw_vif_port[] = {
|
||||
[0] = {
|
||||
.mac_addr = {.addr = 0x0610},
|
||||
.bssid = {.addr = 0x0618},
|
||||
.net_type = {.addr = 0x0100, .mask = 0x30000},
|
||||
.aid = {.addr = 0x06a8, .mask = 0x7ff},
|
||||
},
|
||||
[1] = {
|
||||
.mac_addr = {.addr = 0x0700},
|
||||
.bssid = {.addr = 0x0708},
|
||||
.net_type = {.addr = 0x0100, .mask = 0xc0000},
|
||||
.aid = {.addr = 0x0710, .mask = 0x7ff},
|
||||
},
|
||||
[2] = {
|
||||
.mac_addr = {.addr = 0x1620},
|
||||
.bssid = {.addr = 0x1628},
|
||||
.net_type = {.addr = 0x1100, .mask = 0x3},
|
||||
.aid = {.addr = 0x1600, .mask = 0x7ff},
|
||||
},
|
||||
[3] = {
|
||||
.mac_addr = {.addr = 0x1630},
|
||||
.bssid = {.addr = 0x1638},
|
||||
.net_type = {.addr = 0x1100, .mask = 0xc},
|
||||
.aid = {.addr = 0x1604, .mask = 0x7ff},
|
||||
},
|
||||
[4] = {
|
||||
.mac_addr = {.addr = 0x1640},
|
||||
.bssid = {.addr = 0x1648},
|
||||
.net_type = {.addr = 0x1100, .mask = 0x30},
|
||||
.aid = {.addr = 0x1608, .mask = 0x7ff},
|
||||
},
|
||||
};
|
||||
|
||||
static int rtw_ops_add_interface(struct ieee80211_hw *hw,
|
||||
struct ieee80211_vif *vif)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
|
||||
enum rtw_net_type net_type;
|
||||
u32 config = 0;
|
||||
u8 port = 0;
|
||||
|
||||
rtwvif->port = port;
|
||||
rtwvif->vif = vif;
|
||||
rtwvif->stats.tx_unicast = 0;
|
||||
rtwvif->stats.rx_unicast = 0;
|
||||
rtwvif->stats.tx_cnt = 0;
|
||||
rtwvif->stats.rx_cnt = 0;
|
||||
rtwvif->in_lps = false;
|
||||
rtwvif->conf = &rtw_vif_port[port];
|
||||
|
||||
mutex_lock(&rtwdev->mutex);
|
||||
|
||||
switch (vif->type) {
|
||||
case NL80211_IFTYPE_AP:
|
||||
case NL80211_IFTYPE_MESH_POINT:
|
||||
net_type = RTW_NET_AP_MODE;
|
||||
break;
|
||||
case NL80211_IFTYPE_ADHOC:
|
||||
net_type = RTW_NET_AD_HOC;
|
||||
break;
|
||||
case NL80211_IFTYPE_STATION:
|
||||
default:
|
||||
net_type = RTW_NET_NO_LINK;
|
||||
break;
|
||||
}
|
||||
|
||||
ether_addr_copy(rtwvif->mac_addr, vif->addr);
|
||||
config |= PORT_SET_MAC_ADDR;
|
||||
rtwvif->net_type = net_type;
|
||||
config |= PORT_SET_NET_TYPE;
|
||||
rtw_vif_port_config(rtwdev, rtwvif, config);
|
||||
|
||||
mutex_unlock(&rtwdev->mutex);
|
||||
|
||||
rtw_info(rtwdev, "start vif %pM on port %d\n", vif->addr, rtwvif->port);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rtw_ops_remove_interface(struct ieee80211_hw *hw,
|
||||
struct ieee80211_vif *vif)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
|
||||
u32 config = 0;
|
||||
|
||||
rtw_info(rtwdev, "stop vif %pM on port %d\n", vif->addr, rtwvif->port);
|
||||
|
||||
mutex_lock(&rtwdev->mutex);
|
||||
|
||||
eth_zero_addr(rtwvif->mac_addr);
|
||||
config |= PORT_SET_MAC_ADDR;
|
||||
rtwvif->net_type = RTW_NET_NO_LINK;
|
||||
config |= PORT_SET_NET_TYPE;
|
||||
rtw_vif_port_config(rtwdev, rtwvif, config);
|
||||
|
||||
mutex_unlock(&rtwdev->mutex);
|
||||
}
|
||||
|
||||
static void rtw_ops_configure_filter(struct ieee80211_hw *hw,
|
||||
unsigned int changed_flags,
|
||||
unsigned int *new_flags,
|
||||
u64 multicast)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
|
||||
*new_flags &= FIF_ALLMULTI | FIF_OTHER_BSS | FIF_FCSFAIL |
|
||||
FIF_BCN_PRBRESP_PROMISC;
|
||||
|
||||
mutex_lock(&rtwdev->mutex);
|
||||
|
||||
if (changed_flags & FIF_ALLMULTI) {
|
||||
if (*new_flags & FIF_ALLMULTI)
|
||||
rtwdev->hal.rcr |= BIT_AM | BIT_AB;
|
||||
else
|
||||
rtwdev->hal.rcr &= ~(BIT_AM | BIT_AB);
|
||||
}
|
||||
if (changed_flags & FIF_FCSFAIL) {
|
||||
if (*new_flags & FIF_FCSFAIL)
|
||||
rtwdev->hal.rcr |= BIT_ACRC32;
|
||||
else
|
||||
rtwdev->hal.rcr &= ~(BIT_ACRC32);
|
||||
}
|
||||
if (changed_flags & FIF_OTHER_BSS) {
|
||||
if (*new_flags & FIF_OTHER_BSS)
|
||||
rtwdev->hal.rcr |= BIT_AAP;
|
||||
else
|
||||
rtwdev->hal.rcr &= ~(BIT_AAP);
|
||||
}
|
||||
if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
|
||||
if (*new_flags & FIF_BCN_PRBRESP_PROMISC)
|
||||
rtwdev->hal.rcr &= ~(BIT_CBSSID_BCN | BIT_CBSSID_DATA);
|
||||
else
|
||||
rtwdev->hal.rcr |= BIT_CBSSID_BCN;
|
||||
}
|
||||
|
||||
rtw_dbg(rtwdev, RTW_DBG_RX,
|
||||
"config rx filter, changed=0x%08x, new=0x%08x, rcr=0x%08x\n",
|
||||
changed_flags, *new_flags, rtwdev->hal.rcr);
|
||||
|
||||
rtw_write32(rtwdev, REG_RCR, rtwdev->hal.rcr);
|
||||
|
||||
mutex_unlock(&rtwdev->mutex);
|
||||
}
|
||||
|
||||
static void rtw_ops_bss_info_changed(struct ieee80211_hw *hw,
|
||||
struct ieee80211_vif *vif,
|
||||
struct ieee80211_bss_conf *conf,
|
||||
u32 changed)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
|
||||
u32 config = 0;
|
||||
|
||||
mutex_lock(&rtwdev->mutex);
|
||||
|
||||
if (changed & BSS_CHANGED_ASSOC) {
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
enum rtw_net_type net_type;
|
||||
|
||||
if (conf->assoc) {
|
||||
net_type = RTW_NET_MGD_LINKED;
|
||||
chip->ops->do_iqk(rtwdev);
|
||||
|
||||
rtwvif->aid = conf->aid;
|
||||
rtw_add_rsvd_page(rtwdev, RSVD_PS_POLL, true);
|
||||
rtw_add_rsvd_page(rtwdev, RSVD_QOS_NULL, true);
|
||||
rtw_add_rsvd_page(rtwdev, RSVD_NULL, true);
|
||||
rtw_fw_download_rsvd_page(rtwdev, vif);
|
||||
rtw_send_rsvd_page_h2c(rtwdev);
|
||||
} else {
|
||||
net_type = RTW_NET_NO_LINK;
|
||||
rtwvif->aid = 0;
|
||||
rtw_reset_rsvd_page(rtwdev);
|
||||
}
|
||||
|
||||
rtwvif->net_type = net_type;
|
||||
config |= PORT_SET_NET_TYPE;
|
||||
config |= PORT_SET_AID;
|
||||
}
|
||||
|
||||
if (changed & BSS_CHANGED_BSSID) {
|
||||
ether_addr_copy(rtwvif->bssid, conf->bssid);
|
||||
config |= PORT_SET_BSSID;
|
||||
}
|
||||
|
||||
if (changed & BSS_CHANGED_BEACON)
|
||||
rtw_fw_download_rsvd_page(rtwdev, vif);
|
||||
|
||||
rtw_vif_port_config(rtwdev, rtwvif, config);
|
||||
|
||||
mutex_unlock(&rtwdev->mutex);
|
||||
}
|
||||
|
||||
static u8 rtw_acquire_macid(struct rtw_dev *rtwdev)
|
||||
{
|
||||
unsigned long mac_id;
|
||||
|
||||
mac_id = find_first_zero_bit(rtwdev->mac_id_map, RTW_MAX_MAC_ID_NUM);
|
||||
if (mac_id < RTW_MAX_MAC_ID_NUM)
|
||||
set_bit(mac_id, rtwdev->mac_id_map);
|
||||
|
||||
return mac_id;
|
||||
}
|
||||
|
||||
static void rtw_release_macid(struct rtw_dev *rtwdev, u8 mac_id)
|
||||
{
|
||||
clear_bit(mac_id, rtwdev->mac_id_map);
|
||||
}
|
||||
|
||||
static int rtw_ops_sta_add(struct ieee80211_hw *hw,
|
||||
struct ieee80211_vif *vif,
|
||||
struct ieee80211_sta *sta)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&rtwdev->mutex);
|
||||
|
||||
si->mac_id = rtw_acquire_macid(rtwdev);
|
||||
if (si->mac_id >= RTW_MAX_MAC_ID_NUM) {
|
||||
ret = -ENOSPC;
|
||||
goto out;
|
||||
}
|
||||
|
||||
si->sta = sta;
|
||||
si->vif = vif;
|
||||
si->init_ra_lv = 1;
|
||||
ewma_rssi_init(&si->avg_rssi);
|
||||
|
||||
rtw_update_sta_info(rtwdev, si);
|
||||
rtw_fw_media_status_report(rtwdev, si->mac_id, true);
|
||||
|
||||
rtwdev->sta_cnt++;
|
||||
|
||||
rtw_info(rtwdev, "sta %pM joined with macid %d\n",
|
||||
sta->addr, si->mac_id);
|
||||
|
||||
out:
|
||||
mutex_unlock(&rtwdev->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rtw_ops_sta_remove(struct ieee80211_hw *hw,
|
||||
struct ieee80211_vif *vif,
|
||||
struct ieee80211_sta *sta)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv;
|
||||
|
||||
mutex_lock(&rtwdev->mutex);
|
||||
|
||||
rtw_release_macid(rtwdev, si->mac_id);
|
||||
rtw_fw_media_status_report(rtwdev, si->mac_id, false);
|
||||
|
||||
rtwdev->sta_cnt--;
|
||||
|
||||
rtw_info(rtwdev, "sta %pM with macid %d left\n",
|
||||
sta->addr, si->mac_id);
|
||||
|
||||
mutex_unlock(&rtwdev->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_ops_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
|
||||
struct ieee80211_vif *vif, struct ieee80211_sta *sta,
|
||||
struct ieee80211_key_conf *key)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct rtw_sec_desc *sec = &rtwdev->sec;
|
||||
u8 hw_key_type;
|
||||
u8 hw_key_idx;
|
||||
int ret = 0;
|
||||
|
||||
switch (key->cipher) {
|
||||
case WLAN_CIPHER_SUITE_WEP40:
|
||||
hw_key_type = RTW_CAM_WEP40;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_WEP104:
|
||||
hw_key_type = RTW_CAM_WEP104;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_TKIP:
|
||||
hw_key_type = RTW_CAM_TKIP;
|
||||
key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
hw_key_type = RTW_CAM_AES;
|
||||
key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
/* suppress error messages */
|
||||
return -EOPNOTSUPP;
|
||||
default:
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
mutex_lock(&rtwdev->mutex);
|
||||
|
||||
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
|
||||
hw_key_idx = rtw_sec_get_free_cam(sec);
|
||||
} else {
|
||||
/* multiple interfaces? */
|
||||
hw_key_idx = key->keyidx;
|
||||
}
|
||||
|
||||
if (hw_key_idx > sec->total_cam_num) {
|
||||
ret = -ENOSPC;
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case SET_KEY:
|
||||
/* need sw generated IV */
|
||||
key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
|
||||
key->hw_key_idx = hw_key_idx;
|
||||
rtw_sec_write_cam(rtwdev, sec, sta, key,
|
||||
hw_key_type, hw_key_idx);
|
||||
break;
|
||||
case DISABLE_KEY:
|
||||
rtw_sec_clear_cam(rtwdev, sec, key->hw_key_idx);
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
mutex_unlock(&rtwdev->mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rtw_ops_ampdu_action(struct ieee80211_hw *hw,
|
||||
struct ieee80211_vif *vif,
|
||||
struct ieee80211_ampdu_params *params)
|
||||
{
|
||||
struct ieee80211_sta *sta = params->sta;
|
||||
u16 tid = params->tid;
|
||||
|
||||
switch (params->action) {
|
||||
case IEEE80211_AMPDU_TX_START:
|
||||
ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
|
||||
break;
|
||||
case IEEE80211_AMPDU_TX_STOP_CONT:
|
||||
case IEEE80211_AMPDU_TX_STOP_FLUSH:
|
||||
case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
|
||||
ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
|
||||
break;
|
||||
case IEEE80211_AMPDU_TX_OPERATIONAL:
|
||||
case IEEE80211_AMPDU_RX_START:
|
||||
case IEEE80211_AMPDU_RX_STOP:
|
||||
break;
|
||||
default:
|
||||
WARN_ON(1);
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rtw_ops_sw_scan_start(struct ieee80211_hw *hw,
|
||||
struct ieee80211_vif *vif,
|
||||
const u8 *mac_addr)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
|
||||
|
||||
rtw_leave_lps(rtwdev, rtwvif);
|
||||
|
||||
rtw_flag_set(rtwdev, RTW_FLAG_DIG_DISABLE);
|
||||
rtw_flag_set(rtwdev, RTW_FLAG_SCANNING);
|
||||
}
|
||||
|
||||
static void rtw_ops_sw_scan_complete(struct ieee80211_hw *hw,
|
||||
struct ieee80211_vif *vif)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
|
||||
rtw_flag_clear(rtwdev, RTW_FLAG_SCANNING);
|
||||
rtw_flag_clear(rtwdev, RTW_FLAG_DIG_DISABLE);
|
||||
}
|
||||
|
||||
const struct ieee80211_ops rtw_ops = {
|
||||
.tx = rtw_ops_tx,
|
||||
.start = rtw_ops_start,
|
||||
.stop = rtw_ops_stop,
|
||||
.config = rtw_ops_config,
|
||||
.add_interface = rtw_ops_add_interface,
|
||||
.remove_interface = rtw_ops_remove_interface,
|
||||
.configure_filter = rtw_ops_configure_filter,
|
||||
.bss_info_changed = rtw_ops_bss_info_changed,
|
||||
.sta_add = rtw_ops_sta_add,
|
||||
.sta_remove = rtw_ops_sta_remove,
|
||||
.set_key = rtw_ops_set_key,
|
||||
.ampdu_action = rtw_ops_ampdu_action,
|
||||
.sw_scan_start = rtw_ops_sw_scan_start,
|
||||
.sw_scan_complete = rtw_ops_sw_scan_complete,
|
||||
};
|
||||
EXPORT_SYMBOL(rtw_ops);
|
1211
drivers/net/wireless/realtek/rtw88/main.c
Normal file
1211
drivers/net/wireless/realtek/rtw88/main.c
Normal file
File diff suppressed because it is too large
Load diff
1104
drivers/net/wireless/realtek/rtw88/main.h
Normal file
1104
drivers/net/wireless/realtek/rtw88/main.h
Normal file
File diff suppressed because it is too large
Load diff
1211
drivers/net/wireless/realtek/rtw88/pci.c
Normal file
1211
drivers/net/wireless/realtek/rtw88/pci.c
Normal file
File diff suppressed because it is too large
Load diff
237
drivers/net/wireless/realtek/rtw88/pci.h
Normal file
237
drivers/net/wireless/realtek/rtw88/pci.h
Normal file
|
@ -0,0 +1,237 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTK_PCI_H_
|
||||
#define __RTK_PCI_H_
|
||||
|
||||
#define RTK_PCI_DEVICE(vend, dev, hw_config) \
|
||||
PCI_DEVICE(vend, dev), \
|
||||
.driver_data = (kernel_ulong_t)&(hw_config),
|
||||
|
||||
#define RTK_DEFAULT_TX_DESC_NUM 128
|
||||
#define RTK_BEQ_TX_DESC_NUM 256
|
||||
|
||||
#define RTK_MAX_RX_DESC_NUM 512
|
||||
/* 8K + rx desc size */
|
||||
#define RTK_PCI_RX_BUF_SIZE (8192 + 24)
|
||||
|
||||
#define RTK_PCI_CTRL 0x300
|
||||
#define BIT_RST_TRXDMA_INTF BIT(20)
|
||||
#define BIT_RX_TAG_EN BIT(15)
|
||||
#define REG_DBI_WDATA_V1 0x03E8
|
||||
#define REG_DBI_FLAG_V1 0x03F0
|
||||
#define REG_MDIO_V1 0x03F4
|
||||
#define REG_PCIE_MIX_CFG 0x03F8
|
||||
#define BIT_MDIO_WFLAG_V1 BIT(5)
|
||||
|
||||
#define BIT_PCI_BCNQ_FLAG BIT(4)
|
||||
#define RTK_PCI_TXBD_DESA_BCNQ 0x308
|
||||
#define RTK_PCI_TXBD_DESA_H2CQ 0x1320
|
||||
#define RTK_PCI_TXBD_DESA_MGMTQ 0x310
|
||||
#define RTK_PCI_TXBD_DESA_BKQ 0x330
|
||||
#define RTK_PCI_TXBD_DESA_BEQ 0x328
|
||||
#define RTK_PCI_TXBD_DESA_VIQ 0x320
|
||||
#define RTK_PCI_TXBD_DESA_VOQ 0x318
|
||||
#define RTK_PCI_TXBD_DESA_HI0Q 0x340
|
||||
#define RTK_PCI_RXBD_DESA_MPDUQ 0x338
|
||||
|
||||
/* BCNQ is specialized for rsvd page, does not need to specify a number */
|
||||
#define RTK_PCI_TXBD_NUM_H2CQ 0x1328
|
||||
#define RTK_PCI_TXBD_NUM_MGMTQ 0x380
|
||||
#define RTK_PCI_TXBD_NUM_BKQ 0x38A
|
||||
#define RTK_PCI_TXBD_NUM_BEQ 0x388
|
||||
#define RTK_PCI_TXBD_NUM_VIQ 0x386
|
||||
#define RTK_PCI_TXBD_NUM_VOQ 0x384
|
||||
#define RTK_PCI_TXBD_NUM_HI0Q 0x38C
|
||||
#define RTK_PCI_RXBD_NUM_MPDUQ 0x382
|
||||
#define RTK_PCI_TXBD_IDX_H2CQ 0x132C
|
||||
#define RTK_PCI_TXBD_IDX_MGMTQ 0x3B0
|
||||
#define RTK_PCI_TXBD_IDX_BKQ 0x3AC
|
||||
#define RTK_PCI_TXBD_IDX_BEQ 0x3A8
|
||||
#define RTK_PCI_TXBD_IDX_VIQ 0x3A4
|
||||
#define RTK_PCI_TXBD_IDX_VOQ 0x3A0
|
||||
#define RTK_PCI_TXBD_IDX_HI0Q 0x3B8
|
||||
#define RTK_PCI_RXBD_IDX_MPDUQ 0x3B4
|
||||
|
||||
#define RTK_PCI_TXBD_RWPTR_CLR 0x39C
|
||||
#define RTK_PCI_TXBD_H2CQ_CSR 0x1330
|
||||
|
||||
#define BIT_CLR_H2CQ_HOST_IDX BIT(16)
|
||||
#define BIT_CLR_H2CQ_HW_IDX BIT(8)
|
||||
|
||||
#define RTK_PCI_HIMR0 0x0B0
|
||||
#define RTK_PCI_HISR0 0x0B4
|
||||
#define RTK_PCI_HIMR1 0x0B8
|
||||
#define RTK_PCI_HISR1 0x0BC
|
||||
#define RTK_PCI_HIMR2 0x10B0
|
||||
#define RTK_PCI_HISR2 0x10B4
|
||||
#define RTK_PCI_HIMR3 0x10B8
|
||||
#define RTK_PCI_HISR3 0x10BC
|
||||
/* IMR 0 */
|
||||
#define IMR_TIMER2 BIT(31)
|
||||
#define IMR_TIMER1 BIT(30)
|
||||
#define IMR_PSTIMEOUT BIT(29)
|
||||
#define IMR_GTINT4 BIT(28)
|
||||
#define IMR_GTINT3 BIT(27)
|
||||
#define IMR_TBDER BIT(26)
|
||||
#define IMR_TBDOK BIT(25)
|
||||
#define IMR_TSF_BIT32_TOGGLE BIT(24)
|
||||
#define IMR_BCNDMAINT0 BIT(20)
|
||||
#define IMR_BCNDOK0 BIT(16)
|
||||
#define IMR_HSISR_IND_ON_INT BIT(15)
|
||||
#define IMR_BCNDMAINT_E BIT(14)
|
||||
#define IMR_ATIMEND BIT(12)
|
||||
#define IMR_HISR1_IND_INT BIT(11)
|
||||
#define IMR_C2HCMD BIT(10)
|
||||
#define IMR_CPWM2 BIT(9)
|
||||
#define IMR_CPWM BIT(8)
|
||||
#define IMR_HIGHDOK BIT(7)
|
||||
#define IMR_MGNTDOK BIT(6)
|
||||
#define IMR_BKDOK BIT(5)
|
||||
#define IMR_BEDOK BIT(4)
|
||||
#define IMR_VIDOK BIT(3)
|
||||
#define IMR_VODOK BIT(2)
|
||||
#define IMR_RDU BIT(1)
|
||||
#define IMR_ROK BIT(0)
|
||||
/* IMR 1 */
|
||||
#define IMR_TXFIFO_TH_INT BIT(30)
|
||||
#define IMR_BTON_STS_UPDATE BIT(29)
|
||||
#define IMR_MCUERR BIT(28)
|
||||
#define IMR_BCNDMAINT7 BIT(27)
|
||||
#define IMR_BCNDMAINT6 BIT(26)
|
||||
#define IMR_BCNDMAINT5 BIT(25)
|
||||
#define IMR_BCNDMAINT4 BIT(24)
|
||||
#define IMR_BCNDMAINT3 BIT(23)
|
||||
#define IMR_BCNDMAINT2 BIT(22)
|
||||
#define IMR_BCNDMAINT1 BIT(21)
|
||||
#define IMR_BCNDOK7 BIT(20)
|
||||
#define IMR_BCNDOK6 BIT(19)
|
||||
#define IMR_BCNDOK5 BIT(18)
|
||||
#define IMR_BCNDOK4 BIT(17)
|
||||
#define IMR_BCNDOK3 BIT(16)
|
||||
#define IMR_BCNDOK2 BIT(15)
|
||||
#define IMR_BCNDOK1 BIT(14)
|
||||
#define IMR_ATIMEND_E BIT(13)
|
||||
#define IMR_ATIMEND BIT(12)
|
||||
#define IMR_TXERR BIT(11)
|
||||
#define IMR_RXERR BIT(10)
|
||||
#define IMR_TXFOVW BIT(9)
|
||||
#define IMR_RXFOVW BIT(8)
|
||||
#define IMR_CPU_MGQ_TXDONE BIT(5)
|
||||
#define IMR_PS_TIMER_C BIT(4)
|
||||
#define IMR_PS_TIMER_B BIT(3)
|
||||
#define IMR_PS_TIMER_A BIT(2)
|
||||
#define IMR_CPUMGQ_TX_TIMER BIT(1)
|
||||
/* IMR 3 */
|
||||
#define IMR_H2CDOK BIT(16)
|
||||
|
||||
/* one element is reserved to know if the ring is closed */
|
||||
static inline int avail_desc(u32 wp, u32 rp, u32 len)
|
||||
{
|
||||
if (rp > wp)
|
||||
return rp - wp - 1;
|
||||
else
|
||||
return len - wp + rp - 1;
|
||||
}
|
||||
|
||||
#define RTK_PCI_TXBD_OWN_OFFSET 15
|
||||
#define RTK_PCI_TXBD_BCN_WORK 0x383
|
||||
|
||||
struct rtw_pci_tx_buffer_desc {
|
||||
__le16 buf_size;
|
||||
__le16 psb_len;
|
||||
__le32 dma;
|
||||
};
|
||||
|
||||
struct rtw_pci_tx_data {
|
||||
dma_addr_t dma;
|
||||
u8 sn;
|
||||
};
|
||||
|
||||
struct rtw_pci_ring {
|
||||
u8 *head;
|
||||
dma_addr_t dma;
|
||||
|
||||
u8 desc_size;
|
||||
|
||||
u32 len;
|
||||
u32 wp;
|
||||
u32 rp;
|
||||
};
|
||||
|
||||
struct rtw_pci_tx_ring {
|
||||
struct rtw_pci_ring r;
|
||||
struct sk_buff_head queue;
|
||||
bool queue_stopped;
|
||||
};
|
||||
|
||||
struct rtw_pci_rx_buffer_desc {
|
||||
__le16 buf_size;
|
||||
__le16 total_pkt_size;
|
||||
__le32 dma;
|
||||
};
|
||||
|
||||
struct rtw_pci_rx_ring {
|
||||
struct rtw_pci_ring r;
|
||||
struct sk_buff *buf[RTK_MAX_RX_DESC_NUM];
|
||||
};
|
||||
|
||||
#define RX_TAG_MAX 8192
|
||||
|
||||
struct rtw_pci {
|
||||
struct pci_dev *pdev;
|
||||
|
||||
/* used for pci interrupt */
|
||||
spinlock_t irq_lock;
|
||||
u32 irq_mask[4];
|
||||
bool irq_enabled;
|
||||
|
||||
u16 rx_tag;
|
||||
struct rtw_pci_tx_ring tx_rings[RTK_MAX_TX_QUEUE_NUM];
|
||||
struct rtw_pci_rx_ring rx_rings[RTK_MAX_RX_QUEUE_NUM];
|
||||
|
||||
void __iomem *mmap;
|
||||
};
|
||||
|
||||
static u32 max_num_of_tx_queue(u8 queue)
|
||||
{
|
||||
u32 max_num;
|
||||
|
||||
switch (queue) {
|
||||
case RTW_TX_QUEUE_BE:
|
||||
max_num = RTK_BEQ_TX_DESC_NUM;
|
||||
break;
|
||||
case RTW_TX_QUEUE_BCN:
|
||||
max_num = 1;
|
||||
break;
|
||||
default:
|
||||
max_num = RTK_DEFAULT_TX_DESC_NUM;
|
||||
break;
|
||||
}
|
||||
|
||||
return max_num;
|
||||
}
|
||||
|
||||
static inline struct
|
||||
rtw_pci_tx_data *rtw_pci_get_tx_data(struct sk_buff *skb)
|
||||
{
|
||||
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
|
||||
|
||||
BUILD_BUG_ON(sizeof(struct rtw_pci_tx_data) >
|
||||
sizeof(info->status.status_driver_data));
|
||||
|
||||
return (struct rtw_pci_tx_data *)info->status.status_driver_data;
|
||||
}
|
||||
|
||||
static inline
|
||||
struct rtw_pci_tx_buffer_desc *get_tx_buffer_desc(struct rtw_pci_tx_ring *ring,
|
||||
u32 size)
|
||||
{
|
||||
u8 *buf_desc;
|
||||
|
||||
buf_desc = ring->r.head + ring->r.wp * size;
|
||||
return (struct rtw_pci_tx_buffer_desc *)buf_desc;
|
||||
}
|
||||
|
||||
#endif
|
1724
drivers/net/wireless/realtek/rtw88/phy.c
Normal file
1724
drivers/net/wireless/realtek/rtw88/phy.c
Normal file
File diff suppressed because it is too large
Load diff
134
drivers/net/wireless/realtek/rtw88/phy.h
Normal file
134
drivers/net/wireless/realtek/rtw88/phy.h
Normal file
|
@ -0,0 +1,134 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_PHY_H_
|
||||
#define __RTW_PHY_H_
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
extern u8 rtw_cck_rates[];
|
||||
extern u8 rtw_ofdm_rates[];
|
||||
extern u8 rtw_ht_1s_rates[];
|
||||
extern u8 rtw_ht_2s_rates[];
|
||||
extern u8 rtw_vht_1s_rates[];
|
||||
extern u8 rtw_vht_2s_rates[];
|
||||
extern u8 *rtw_rate_section[];
|
||||
extern u8 rtw_rate_size[];
|
||||
|
||||
void rtw_phy_init(struct rtw_dev *rtwdev);
|
||||
void rtw_phy_dynamic_mechanism(struct rtw_dev *rtwdev);
|
||||
u8 rtw_phy_rf_power_2_rssi(s8 *rf_power, u8 path_num);
|
||||
u32 rtw_phy_read_rf(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path,
|
||||
u32 addr, u32 mask);
|
||||
bool rtw_phy_write_rf_reg_sipi(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path,
|
||||
u32 addr, u32 mask, u32 data);
|
||||
bool rtw_phy_write_rf_reg(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path,
|
||||
u32 addr, u32 mask, u32 data);
|
||||
bool rtw_phy_write_rf_reg_mix(struct rtw_dev *rtwdev, enum rtw_rf_path rf_path,
|
||||
u32 addr, u32 mask, u32 data);
|
||||
void phy_store_tx_power_by_rate(void *adapter, u32 band, u32 rfpath, u32 txnum,
|
||||
u32 regaddr, u32 bitmask, u32 data);
|
||||
void phy_set_tx_power_limit(struct rtw_dev *rtwdev, u8 regd, u8 band,
|
||||
u8 bw, u8 rs, u8 ch, s8 pwr_limit);
|
||||
void phy_set_tx_power_index_by_rs(void *adapter, u8 ch, u8 path, u8 rs);
|
||||
void rtw_phy_setup_phy_cond(struct rtw_dev *rtwdev, u32 pkg);
|
||||
void rtw_parse_tbl_phy_cond(struct rtw_dev *rtwdev, const struct rtw_table *tbl);
|
||||
void rtw_parse_tbl_bb_pg(struct rtw_dev *rtwdev, const struct rtw_table *tbl);
|
||||
void rtw_parse_tbl_txpwr_lmt(struct rtw_dev *rtwdev, const struct rtw_table *tbl);
|
||||
void rtw_phy_cfg_mac(struct rtw_dev *rtwdev, const struct rtw_table *tbl,
|
||||
u32 addr, u32 data);
|
||||
void rtw_phy_cfg_agc(struct rtw_dev *rtwdev, const struct rtw_table *tbl,
|
||||
u32 addr, u32 data);
|
||||
void rtw_phy_cfg_bb(struct rtw_dev *rtwdev, const struct rtw_table *tbl,
|
||||
u32 addr, u32 data);
|
||||
void rtw_phy_cfg_rf(struct rtw_dev *rtwdev, const struct rtw_table *tbl,
|
||||
u32 addr, u32 data);
|
||||
void rtw_hw_init_tx_power(struct rtw_hal *hal);
|
||||
void rtw_phy_load_tables(struct rtw_dev *rtwdev);
|
||||
void rtw_phy_set_tx_power_level(struct rtw_dev *rtwdev, u8 channel);
|
||||
void rtw_phy_tx_power_by_rate_config(struct rtw_hal *hal);
|
||||
void rtw_phy_tx_power_limit_config(struct rtw_hal *hal);
|
||||
|
||||
#define RTW_DECL_TABLE_PHY_COND_CORE(name, cfg, path) \
|
||||
const struct rtw_table name ## _tbl = { \
|
||||
.data = name, \
|
||||
.size = ARRAY_SIZE(name), \
|
||||
.parse = rtw_parse_tbl_phy_cond, \
|
||||
.do_cfg = cfg, \
|
||||
.rf_path = path, \
|
||||
}
|
||||
|
||||
#define RTW_DECL_TABLE_PHY_COND(name, cfg) \
|
||||
RTW_DECL_TABLE_PHY_COND_CORE(name, cfg, 0)
|
||||
|
||||
#define RTW_DECL_TABLE_RF_RADIO(name, path) \
|
||||
RTW_DECL_TABLE_PHY_COND_CORE(name, rtw_phy_cfg_rf, RF_PATH_ ## path)
|
||||
|
||||
#define RTW_DECL_TABLE_BB_PG(name) \
|
||||
const struct rtw_table name ## _tbl = { \
|
||||
.data = name, \
|
||||
.size = ARRAY_SIZE(name), \
|
||||
.parse = rtw_parse_tbl_bb_pg, \
|
||||
}
|
||||
|
||||
#define RTW_DECL_TABLE_TXPWR_LMT(name) \
|
||||
const struct rtw_table name ## _tbl = { \
|
||||
.data = name, \
|
||||
.size = ARRAY_SIZE(name), \
|
||||
.parse = rtw_parse_tbl_txpwr_lmt, \
|
||||
}
|
||||
|
||||
static inline const struct rtw_rfe_def *rtw_get_rfe_def(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
struct rtw_efuse *efuse = &rtwdev->efuse;
|
||||
const struct rtw_rfe_def *rfe_def = NULL;
|
||||
|
||||
if (chip->rfe_defs_size == 0)
|
||||
return NULL;
|
||||
|
||||
if (efuse->rfe_option < chip->rfe_defs_size)
|
||||
rfe_def = &chip->rfe_defs[efuse->rfe_option];
|
||||
|
||||
rtw_dbg(rtwdev, RTW_DBG_PHY, "use rfe_def[%d]\n", efuse->rfe_option);
|
||||
return rfe_def;
|
||||
}
|
||||
|
||||
static inline int rtw_check_supported_rfe(struct rtw_dev *rtwdev)
|
||||
{
|
||||
const struct rtw_rfe_def *rfe_def = rtw_get_rfe_def(rtwdev);
|
||||
|
||||
if (!rfe_def || !rfe_def->phy_pg_tbl || !rfe_def->txpwr_lmt_tbl) {
|
||||
rtw_err(rtwdev, "rfe %d isn't supported\n",
|
||||
rtwdev->efuse.rfe_option);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtw_phy_dig_write(struct rtw_dev *rtwdev, u8 igi);
|
||||
|
||||
#define MASKBYTE0 0xff
|
||||
#define MASKBYTE1 0xff00
|
||||
#define MASKBYTE2 0xff0000
|
||||
#define MASKBYTE3 0xff000000
|
||||
#define MASKHWORD 0xffff0000
|
||||
#define MASKLWORD 0x0000ffff
|
||||
#define MASKDWORD 0xffffffff
|
||||
#define RFREG_MASK 0xfffff
|
||||
|
||||
#define MASK7BITS 0x7f
|
||||
#define MASK12BITS 0xfff
|
||||
#define MASKH4BITS 0xf0000000
|
||||
#define MASK20BITS 0xfffff
|
||||
#define MASK24BITS 0xffffff
|
||||
|
||||
#define MASKH3BYTES 0xffffff00
|
||||
#define MASKL3BYTES 0x00ffffff
|
||||
#define MASKBYTE2HIGHNIBBLE 0x00f00000
|
||||
#define MASKBYTE3LOWNIBBLE 0x0f000000
|
||||
#define MASKL3BYTES 0x00ffffff
|
||||
|
||||
#endif
|
166
drivers/net/wireless/realtek/rtw88/ps.c
Normal file
166
drivers/net/wireless/realtek/rtw88/ps.c
Normal file
|
@ -0,0 +1,166 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "fw.h"
|
||||
#include "ps.h"
|
||||
#include "mac.h"
|
||||
#include "debug.h"
|
||||
|
||||
static int rtw_ips_pwr_up(struct rtw_dev *rtwdev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = rtw_core_start(rtwdev);
|
||||
if (ret)
|
||||
rtw_err(rtwdev, "leave idle state failed\n");
|
||||
|
||||
rtw_set_channel(rtwdev);
|
||||
rtw_flag_clear(rtwdev, RTW_FLAG_INACTIVE_PS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int rtw_enter_ips(struct rtw_dev *rtwdev)
|
||||
{
|
||||
rtw_flag_set(rtwdev, RTW_FLAG_INACTIVE_PS);
|
||||
|
||||
rtw_core_stop(rtwdev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rtw_restore_port_cfg_iter(void *data, u8 *mac,
|
||||
struct ieee80211_vif *vif)
|
||||
{
|
||||
struct rtw_dev *rtwdev = data;
|
||||
struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
|
||||
u32 config = ~0;
|
||||
|
||||
rtw_vif_port_config(rtwdev, rtwvif, config);
|
||||
}
|
||||
|
||||
int rtw_leave_ips(struct rtw_dev *rtwdev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = rtw_ips_pwr_up(rtwdev);
|
||||
if (ret) {
|
||||
rtw_err(rtwdev, "failed to leave ips state\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
rtw_iterate_vifs_atomic(rtwdev, rtw_restore_port_cfg_iter, rtwdev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rtw_leave_lps_core(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_lps_conf *conf = &rtwdev->lps_conf;
|
||||
|
||||
conf->state = RTW_ALL_ON;
|
||||
conf->awake_interval = 1;
|
||||
conf->rlbm = 0;
|
||||
conf->smart_ps = 0;
|
||||
|
||||
rtw_fw_set_pwr_mode(rtwdev);
|
||||
rtw_flag_clear(rtwdev, RTW_FLAG_LEISURE_PS);
|
||||
}
|
||||
|
||||
static void rtw_enter_lps_core(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_lps_conf *conf = &rtwdev->lps_conf;
|
||||
|
||||
conf->state = RTW_RF_OFF;
|
||||
conf->awake_interval = 1;
|
||||
conf->rlbm = 1;
|
||||
conf->smart_ps = 2;
|
||||
|
||||
rtw_fw_set_pwr_mode(rtwdev);
|
||||
rtw_flag_set(rtwdev, RTW_FLAG_LEISURE_PS);
|
||||
}
|
||||
|
||||
void rtw_lps_work(struct work_struct *work)
|
||||
{
|
||||
struct rtw_dev *rtwdev = container_of(work, struct rtw_dev,
|
||||
lps_work.work);
|
||||
struct rtw_lps_conf *conf = &rtwdev->lps_conf;
|
||||
struct rtw_vif *rtwvif = conf->rtwvif;
|
||||
|
||||
if (WARN_ON(!rtwvif))
|
||||
return;
|
||||
|
||||
if (conf->mode == RTW_MODE_LPS)
|
||||
rtw_enter_lps_core(rtwdev);
|
||||
else
|
||||
rtw_leave_lps_core(rtwdev);
|
||||
}
|
||||
|
||||
void rtw_enter_lps_irqsafe(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif)
|
||||
{
|
||||
struct rtw_lps_conf *conf = &rtwdev->lps_conf;
|
||||
|
||||
if (rtwvif->in_lps)
|
||||
return;
|
||||
|
||||
conf->mode = RTW_MODE_LPS;
|
||||
conf->rtwvif = rtwvif;
|
||||
rtwvif->in_lps = true;
|
||||
|
||||
ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->lps_work, 0);
|
||||
}
|
||||
|
||||
void rtw_leave_lps_irqsafe(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif)
|
||||
{
|
||||
struct rtw_lps_conf *conf = &rtwdev->lps_conf;
|
||||
|
||||
if (!rtwvif->in_lps)
|
||||
return;
|
||||
|
||||
conf->mode = RTW_MODE_ACTIVE;
|
||||
conf->rtwvif = rtwvif;
|
||||
rtwvif->in_lps = false;
|
||||
|
||||
ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->lps_work, 0);
|
||||
}
|
||||
|
||||
bool rtw_in_lps(struct rtw_dev *rtwdev)
|
||||
{
|
||||
return rtw_flag_check(rtwdev, RTW_FLAG_LEISURE_PS);
|
||||
}
|
||||
|
||||
void rtw_enter_lps(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif)
|
||||
{
|
||||
struct rtw_lps_conf *conf = &rtwdev->lps_conf;
|
||||
|
||||
if (WARN_ON(!rtwvif))
|
||||
return;
|
||||
|
||||
if (rtwvif->in_lps)
|
||||
return;
|
||||
|
||||
conf->mode = RTW_MODE_LPS;
|
||||
conf->rtwvif = rtwvif;
|
||||
rtwvif->in_lps = true;
|
||||
|
||||
rtw_enter_lps_core(rtwdev);
|
||||
}
|
||||
|
||||
void rtw_leave_lps(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif)
|
||||
{
|
||||
struct rtw_lps_conf *conf = &rtwdev->lps_conf;
|
||||
|
||||
if (WARN_ON(!rtwvif))
|
||||
return;
|
||||
|
||||
if (!rtwvif->in_lps)
|
||||
return;
|
||||
|
||||
conf->mode = RTW_MODE_ACTIVE;
|
||||
conf->rtwvif = rtwvif;
|
||||
rtwvif->in_lps = false;
|
||||
|
||||
rtw_leave_lps_core(rtwdev);
|
||||
}
|
20
drivers/net/wireless/realtek/rtw88/ps.h
Normal file
20
drivers/net/wireless/realtek/rtw88/ps.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_PS_H_
|
||||
#define __RTW_PS_H_
|
||||
|
||||
#define RTW_LPS_THRESHOLD 2
|
||||
|
||||
int rtw_enter_ips(struct rtw_dev *rtwdev);
|
||||
int rtw_leave_ips(struct rtw_dev *rtwdev);
|
||||
|
||||
void rtw_lps_work(struct work_struct *work);
|
||||
void rtw_enter_lps_irqsafe(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif);
|
||||
void rtw_leave_lps_irqsafe(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif);
|
||||
void rtw_enter_lps(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif);
|
||||
void rtw_leave_lps(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif);
|
||||
bool rtw_in_lps(struct rtw_dev *rtwdev);
|
||||
|
||||
#endif
|
421
drivers/net/wireless/realtek/rtw88/reg.h
Normal file
421
drivers/net/wireless/realtek/rtw88/reg.h
Normal file
|
@ -0,0 +1,421 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_REG_DEF_H__
|
||||
#define __RTW_REG_DEF_H__
|
||||
|
||||
#define REG_SYS_FUNC_EN 0x0002
|
||||
#define BIT_FEN_CPUEN BIT(2)
|
||||
#define BIT_FEN_BB_GLB_RST BIT(1)
|
||||
#define BIT_FEN_BB_RSTB BIT(0)
|
||||
#define REG_SYS_PW_CTRL 0x0004
|
||||
#define REG_SYS_CLK_CTRL 0x0008
|
||||
#define BIT_CPU_CLK_EN BIT(14)
|
||||
|
||||
#define REG_RSV_CTRL 0x001C
|
||||
#define DISABLE_PI 0x3
|
||||
#define ENABLE_PI 0x2
|
||||
#define BITS_RFC_DIRECT (BIT(31) | BIT(30))
|
||||
#define BIT_WLMCU_IOIF BIT(0)
|
||||
#define REG_RF_CTRL 0x001F
|
||||
#define BIT_RF_SDM_RSTB BIT(2)
|
||||
#define BIT_RF_RSTB BIT(1)
|
||||
#define BIT_RF_EN BIT(0)
|
||||
|
||||
#define REG_AFE_CTRL1 0x0024
|
||||
#define BIT_MAC_CLK_SEL (BIT(20) | BIT(21))
|
||||
#define REG_EFUSE_CTRL 0x0030
|
||||
#define BIT_EF_FLAG BIT(31)
|
||||
#define BIT_SHIFT_EF_ADDR 8
|
||||
#define BIT_MASK_EF_ADDR 0x3ff
|
||||
#define BIT_MASK_EF_DATA 0xff
|
||||
#define BITS_EF_ADDR (BIT_MASK_EF_ADDR << BIT_SHIFT_EF_ADDR)
|
||||
|
||||
#define REG_LDO_EFUSE_CTRL 0x0034
|
||||
#define BIT_MASK_EFUSE_BANK_SEL (BIT(8) | BIT(9))
|
||||
|
||||
#define REG_GPIO_MUXCFG 0x0040
|
||||
#define BIT_FSPI_EN BIT(19)
|
||||
#define BIT_WLRFE_4_5_EN BIT(2)
|
||||
|
||||
#define REG_LED_CFG 0x004C
|
||||
#define BIT_LNAON_SEL_EN BIT(26)
|
||||
#define BIT_PAPE_SEL_EN BIT(25)
|
||||
#define REG_PAD_CTRL1 0x0064
|
||||
#define BIT_PAPE_WLBT_SEL BIT(29)
|
||||
#define BIT_LNAON_WLBT_SEL BIT(28)
|
||||
#define REG_WL_BT_PWR_CTRL 0x0068
|
||||
#define BIT_BT_FUNC_EN BIT(18)
|
||||
#define BIT_BT_DIG_CLK_EN BIT(8)
|
||||
#define REG_HCI_OPT_CTRL 0x0074
|
||||
|
||||
#define REG_MCUFW_CTRL 0x0080
|
||||
#define BIT_ANA_PORT_EN BIT(22)
|
||||
#define BIT_MAC_PORT_EN BIT(21)
|
||||
#define BIT_BOOT_FSPI_EN BIT(20)
|
||||
#define BIT_FW_INIT_RDY BIT(15)
|
||||
#define BIT_FW_DW_RDY BIT(14)
|
||||
#define BIT_RPWM_TOGGLE BIT(7)
|
||||
#define BIT_DMEM_CHKSUM_OK BIT(6)
|
||||
#define BIT_DMEM_DW_OK BIT(5)
|
||||
#define BIT_IMEM_CHKSUM_OK BIT(4)
|
||||
#define BIT_IMEM_DW_OK BIT(3)
|
||||
#define BIT_IMEM_BOOT_LOAD_CHECKSUM_OK BIT(2)
|
||||
#define BIT_MCUFWDL_EN BIT(0)
|
||||
#define BIT_CHECK_SUM_OK (BIT(4) | BIT(6))
|
||||
#define FW_READY (BIT_FW_INIT_RDY | BIT_FW_DW_RDY | \
|
||||
BIT_IMEM_DW_OK | BIT_DMEM_DW_OK | \
|
||||
BIT_CHECK_SUM_OK)
|
||||
#define FW_READY_MASK 0xffff
|
||||
|
||||
#define REG_WLRF1 0x00EC
|
||||
#define REG_SYS_CFG1 0x00F0
|
||||
#define BIT_RTL_ID BIT(23)
|
||||
#define BIT_RF_TYPE_ID BIT(27)
|
||||
#define BIT_SHIFT_VENDOR_ID 16
|
||||
#define BIT_MASK_VENDOR_ID 0xf
|
||||
#define BIT_VENDOR_ID(x) (((x) & BIT_MASK_VENDOR_ID) << BIT_SHIFT_VENDOR_ID)
|
||||
#define BITS_VENDOR_ID (BIT_MASK_VENDOR_ID << BIT_SHIFT_VENDOR_ID)
|
||||
#define BIT_CLEAR_VENDOR_ID(x) ((x) & (~BITS_VENDOR_ID))
|
||||
#define BIT_GET_VENDOR_ID(x) (((x) >> BIT_SHIFT_VENDOR_ID) & BIT_MASK_VENDOR_ID)
|
||||
#define BIT_SHIFT_CHIP_VER 12
|
||||
#define BIT_MASK_CHIP_VER 0xf
|
||||
#define BIT_CHIP_VER(x) (((x) & BIT_MASK_CHIP_VER) << BIT_SHIFT_CHIP_VER)
|
||||
#define BITS_CHIP_VER (BIT_MASK_CHIP_VER << BIT_SHIFT_CHIP_VER)
|
||||
#define BIT_CLEAR_CHIP_VER(x) ((x) & (~BITS_CHIP_VER))
|
||||
#define BIT_GET_CHIP_VER(x) (((x) >> BIT_SHIFT_CHIP_VER) & BIT_MASK_CHIP_VER)
|
||||
#define REG_SYS_STATUS1 0x00F4
|
||||
#define REG_SYS_STATUS2 0x00F8
|
||||
#define REG_SYS_CFG2 0x00FC
|
||||
#define REG_WLRF1 0x00EC
|
||||
#define BIT_WLRF1_BBRF_EN (BIT(24) | BIT(25) | BIT(26))
|
||||
#define REG_CR 0x0100
|
||||
#define BIT_32K_CAL_TMR_EN BIT(10)
|
||||
#define BIT_MAC_SEC_EN BIT(9)
|
||||
#define BIT_ENSWBCN BIT(8)
|
||||
#define BIT_MACRXEN BIT(7)
|
||||
#define BIT_MACTXEN BIT(6)
|
||||
#define BIT_SCHEDULE_EN BIT(5)
|
||||
#define BIT_PROTOCOL_EN BIT(4)
|
||||
#define BIT_RXDMA_EN BIT(3)
|
||||
#define BIT_TXDMA_EN BIT(2)
|
||||
#define BIT_HCI_RXDMA_EN BIT(1)
|
||||
#define BIT_HCI_TXDMA_EN BIT(0)
|
||||
#define MAC_TRX_ENABLE (BIT_HCI_TXDMA_EN | BIT_HCI_RXDMA_EN | BIT_TXDMA_EN | \
|
||||
BIT_RXDMA_EN | BIT_PROTOCOL_EN | BIT_SCHEDULE_EN | \
|
||||
BIT_MACTXEN | BIT_MACRXEN)
|
||||
#define BIT_SHIFT_TXDMA_VOQ_MAP 4
|
||||
#define BIT_MASK_TXDMA_VOQ_MAP 0x3
|
||||
#define BIT_TXDMA_VOQ_MAP(x) \
|
||||
(((x) & BIT_MASK_TXDMA_VOQ_MAP) << BIT_SHIFT_TXDMA_VOQ_MAP)
|
||||
#define BIT_SHIFT_TXDMA_VIQ_MAP 6
|
||||
#define BIT_MASK_TXDMA_VIQ_MAP 0x3
|
||||
#define BIT_TXDMA_VIQ_MAP(x) \
|
||||
(((x) & BIT_MASK_TXDMA_VIQ_MAP) << BIT_SHIFT_TXDMA_VIQ_MAP)
|
||||
#define REG_TXDMA_PQ_MAP 0x010C
|
||||
#define BIT_SHIFT_TXDMA_BEQ_MAP 8
|
||||
#define BIT_MASK_TXDMA_BEQ_MAP 0x3
|
||||
#define BIT_TXDMA_BEQ_MAP(x) \
|
||||
(((x) & BIT_MASK_TXDMA_BEQ_MAP) << BIT_SHIFT_TXDMA_BEQ_MAP)
|
||||
#define BIT_SHIFT_TXDMA_BKQ_MAP 10
|
||||
#define BIT_MASK_TXDMA_BKQ_MAP 0x3
|
||||
#define BIT_TXDMA_BKQ_MAP(x) \
|
||||
(((x) & BIT_MASK_TXDMA_BKQ_MAP) << BIT_SHIFT_TXDMA_BKQ_MAP)
|
||||
#define BIT_SHIFT_TXDMA_MGQ_MAP 12
|
||||
#define BIT_MASK_TXDMA_MGQ_MAP 0x3
|
||||
#define BIT_TXDMA_MGQ_MAP(x) \
|
||||
(((x) & BIT_MASK_TXDMA_MGQ_MAP) << BIT_SHIFT_TXDMA_MGQ_MAP)
|
||||
#define BIT_SHIFT_TXDMA_HIQ_MAP 14
|
||||
#define BIT_MASK_TXDMA_HIQ_MAP 0x3
|
||||
#define BIT_TXDMA_HIQ_MAP(x) \
|
||||
(((x) & BIT_MASK_TXDMA_HIQ_MAP) << BIT_SHIFT_TXDMA_HIQ_MAP)
|
||||
#define BIT_SHIFT_TXSC_40M 4
|
||||
#define BIT_MASK_TXSC_40M 0xf
|
||||
#define BIT_TXSC_40M(x) \
|
||||
(((x) & BIT_MASK_TXSC_40M) << BIT_SHIFT_TXSC_40M)
|
||||
#define BIT_SHIFT_TXSC_20M 0
|
||||
#define BIT_MASK_TXSC_20M 0xf
|
||||
#define BIT_TXSC_20M(x) \
|
||||
(((x) & BIT_MASK_TXSC_20M) << BIT_SHIFT_TXSC_20M)
|
||||
#define BIT_SHIFT_MAC_CLK_SEL 20
|
||||
#define MAC_CLK_HW_DEF_80M 0
|
||||
#define MAC_CLK_HW_DEF_40M 1
|
||||
#define MAC_CLK_HW_DEF_20M 2
|
||||
#define MAC_CLK_SPEED 80
|
||||
|
||||
#define REG_CR 0x0100
|
||||
#define REG_TRXFF_BNDY 0x0114
|
||||
#define REG_RXFF_BNDY 0x011C
|
||||
#define REG_PKTBUF_DBG_CTRL 0x0140
|
||||
#define REG_C2HEVT 0x01A0
|
||||
#define REG_HMETFR 0x01CC
|
||||
#define REG_HMEBOX0 0x01D0
|
||||
#define REG_HMEBOX1 0x01D4
|
||||
#define REG_HMEBOX2 0x01D8
|
||||
#define REG_HMEBOX3 0x01DC
|
||||
#define REG_HMEBOX0_EX 0x01F0
|
||||
#define REG_HMEBOX1_EX 0x01F4
|
||||
#define REG_HMEBOX2_EX 0x01F8
|
||||
#define REG_HMEBOX3_EX 0x01FC
|
||||
|
||||
#define REG_FIFOPAGE_CTRL_2 0x0204
|
||||
#define BIT_BCN_VALID_V1 BIT(15)
|
||||
#define BIT_MASK_BCN_HEAD_1_V1 0xfff
|
||||
#define REG_AUTO_LLT_V1 0x0208
|
||||
#define BIT_AUTO_INIT_LLT_V1 BIT(0)
|
||||
#define REG_TXDMA_OFFSET_CHK 0x020C
|
||||
#define REG_TXDMA_STATUS 0x0210
|
||||
#define BTI_PAGE_OVF BIT(2)
|
||||
#define REG_RQPN_CTRL_1 0x0228
|
||||
#define REG_RQPN_CTRL_2 0x022C
|
||||
#define BIT_LD_RQPN BIT(31)
|
||||
#define REG_FIFOPAGE_INFO_1 0x0230
|
||||
#define REG_FIFOPAGE_INFO_2 0x0234
|
||||
#define REG_FIFOPAGE_INFO_3 0x0238
|
||||
#define REG_FIFOPAGE_INFO_4 0x023C
|
||||
#define REG_FIFOPAGE_INFO_5 0x0240
|
||||
#define REG_H2C_HEAD 0x0244
|
||||
#define REG_H2C_TAIL 0x0248
|
||||
#define REG_H2C_READ_ADDR 0x024C
|
||||
#define REG_H2C_INFO 0x0254
|
||||
|
||||
#define REG_FWHW_TXQ_CTRL 0x0420
|
||||
#define BIT_EN_BCNQ_DL BIT(22)
|
||||
#define BIT_EN_WR_FREE_TAIL BIT(20)
|
||||
#define REG_BCNQ_BDNY_V1 0x0424
|
||||
#define REG_LIFETIME_EN 0x0426
|
||||
#define BIT_BA_PARSER_EN BIT(5)
|
||||
#define REG_SPEC_SIFS 0x0428
|
||||
#define REG_DARFRC 0x0430
|
||||
#define REG_DARFRCH 0x0434
|
||||
#define REG_RARFRCH 0x043C
|
||||
#define REG_ARFR0 0x0444
|
||||
#define REG_ARFRH0 0x0448
|
||||
#define REG_ARFR1_V1 0x044C
|
||||
#define REG_ARFRH1_V1 0x0450
|
||||
#define REG_CCK_CHECK 0x0454
|
||||
#define BIT_CHECK_CCK_EN BIT(7)
|
||||
#define REG_AMPDU_MAX_TIME_V1 0x0455
|
||||
#define REG_BCNQ1_BDNY_V1 0x0456
|
||||
#define REG_TX_HANG_CTRL 0x045E
|
||||
#define BIT_EN_EOF_V1 BIT(2)
|
||||
#define REG_DATA_SC 0x0483
|
||||
#define REG_ARFR4 0x049C
|
||||
#define REG_ARFRH4 0x04A0
|
||||
#define REG_ARFR5 0x04A4
|
||||
#define REG_ARFRH5 0x04A8
|
||||
#define REG_SW_AMPDU_BURST_MODE_CTRL 0x04BC
|
||||
#define BIT_PRE_TX_CMD BIT(6)
|
||||
#define REG_PROT_MODE_CTRL 0x04C8
|
||||
#define REG_BAR_MODE_CTRL 0x04CC
|
||||
#define REG_PRECNT_CTRL 0x04E5
|
||||
#define BIT_EN_PRECNT BIT(11)
|
||||
|
||||
#define REG_EDCA_VO_PARAM 0x0500
|
||||
#define REG_EDCA_VI_PARAM 0x0504
|
||||
#define REG_EDCA_BE_PARAM 0x0508
|
||||
#define REG_EDCA_BK_PARAM 0x050C
|
||||
#define REG_PIFS 0x0512
|
||||
#define REG_SIFS 0x0514
|
||||
#define BIT_SHIFT_SIFS_OFDM_CTX 8
|
||||
#define BIT_SHIFT_SIFS_CCK_TRX 16
|
||||
#define BIT_SHIFT_SIFS_OFDM_TRX 24
|
||||
#define REG_SLOT 0x051B
|
||||
#define REG_TX_PTCL_CTRL 0x0520
|
||||
#define BIT_SIFS_BK_EN BIT(12)
|
||||
#define REG_TXPAUSE 0x0522
|
||||
#define REG_RD_CTRL 0x0524
|
||||
#define BIT_DIS_TXOP_CFE BIT(10)
|
||||
#define BIT_DIS_LSIG_CFE BIT(9)
|
||||
#define BIT_DIS_STBC_CFE BIT(8)
|
||||
#define REG_TBTT_PROHIBIT 0x0540
|
||||
#define BIT_SHIFT_TBTT_HOLD_TIME_AP 8
|
||||
#define REG_RD_NAV_NXT 0x0544
|
||||
#define REG_BCN_CTRL 0x0550
|
||||
#define BIT_DIS_TSF_UDT BIT(4)
|
||||
#define BIT_EN_BCN_FUNCTION BIT(3)
|
||||
#define REG_BCN_CTRL_CLINT0 0x0551
|
||||
#define REG_DRVERLYINT 0x0558
|
||||
#define REG_BCNDMATIM 0x0559
|
||||
#define REG_USTIME_TSF 0x055C
|
||||
#define REG_BCN_MAX_ERR 0x055D
|
||||
#define REG_RXTSF_OFFSET_CCK 0x055E
|
||||
#define REG_MISC_CTRL 0x0577
|
||||
#define BIT_EN_FREE_CNT BIT(3)
|
||||
#define BIT_DIS_SECOND_CCA (BIT(0) | BIT(1))
|
||||
#define REG_TIMER0_SRC_SEL 0x05B4
|
||||
#define BIT_TSFT_SEL_TIMER0 (BIT(4) | BIT(5) | BIT(6))
|
||||
|
||||
#define REG_TCR 0x0604
|
||||
#define REG_RCR 0x0608
|
||||
#define BIT_APP_FCS BIT(31)
|
||||
#define BIT_APP_MIC BIT(30)
|
||||
#define BIT_APP_ICV BIT(29)
|
||||
#define BIT_APP_PHYSTS BIT(28)
|
||||
#define BIT_APP_BASSN BIT(27)
|
||||
#define BIT_VHT_DACK BIT(26)
|
||||
#define BIT_TCPOFLD_EN BIT(25)
|
||||
#define BIT_ENMBID BIT(24)
|
||||
#define BIT_LSIGEN BIT(23)
|
||||
#define BIT_MFBEN BIT(22)
|
||||
#define BIT_DISCHKPPDLLEN BIT(21)
|
||||
#define BIT_PKTCTL_DLEN BIT(20)
|
||||
#define BIT_TIM_PARSER_EN BIT(18)
|
||||
#define BIT_BC_MD_EN BIT(17)
|
||||
#define BIT_UC_MD_EN BIT(16)
|
||||
#define BIT_RXSK_PERPKT BIT(15)
|
||||
#define BIT_HTC_LOC_CTRL BIT(14)
|
||||
#define BIT_RPFM_CAM_ENABLE BIT(12)
|
||||
#define BIT_TA_BCN BIT(11)
|
||||
#define BIT_DISDECMYPKT BIT(10)
|
||||
#define BIT_AICV BIT(9)
|
||||
#define BIT_ACRC32 BIT(8)
|
||||
#define BIT_CBSSID_BCN BIT(7)
|
||||
#define BIT_CBSSID_DATA BIT(6)
|
||||
#define BIT_APWRMGT BIT(5)
|
||||
#define BIT_ADD3 BIT(4)
|
||||
#define BIT_AB BIT(3)
|
||||
#define BIT_AM BIT(2)
|
||||
#define BIT_APM BIT(1)
|
||||
#define BIT_AAP BIT(0)
|
||||
#define REG_RX_PKT_LIMIT 0x060C
|
||||
#define REG_RX_DRVINFO_SZ 0x060F
|
||||
#define BIT_APP_PHYSTS BIT(28)
|
||||
#define REG_USTIME_EDCA 0x0638
|
||||
#define REG_ACKTO_CCK 0x0639
|
||||
#define REG_RESP_SIFS_CCK 0x063C
|
||||
#define REG_RESP_SIFS_OFDM 0x063E
|
||||
#define REG_ACKTO 0x0640
|
||||
#define REG_EIFS 0x0642
|
||||
#define REG_NAV_CTRL 0x0650
|
||||
#define REG_WMAC_TRXPTCL_CTL 0x0668
|
||||
#define BIT_RFMOD (BIT(7) | BIT(8))
|
||||
#define BIT_RFMOD_80M BIT(8)
|
||||
#define BIT_RFMOD_40M BIT(7)
|
||||
#define REG_WMAC_TRXPTCL_CTL_H 0x066C
|
||||
#define REG_RXFLTMAP0 0x06A0
|
||||
#define REG_RXFLTMAP1 0x06A2
|
||||
#define REG_RXFLTMAP2 0x06A4
|
||||
#define REG_BBPSF_CTRL 0x06DC
|
||||
|
||||
#define REG_WMAC_OPTION_FUNCTION 0x07D0
|
||||
#define REG_WMAC_OPTION_FUNCTION_1 0x07D4
|
||||
|
||||
#define REG_ANAPAR_XTAL_0 0x1040
|
||||
#define REG_CPU_DMEM_CON 0x1080
|
||||
#define BIT_WL_PLATFORM_RST BIT(16)
|
||||
#define BIT_WL_SECURITY_CLK BIT(15)
|
||||
#define BIT_DDMA_EN BIT(8)
|
||||
|
||||
#define REG_H2C_PKT_READADDR 0x10D0
|
||||
#define REG_H2C_PKT_WRITEADDR 0x10D4
|
||||
#define REG_FW_DBG7 0x10FC
|
||||
#define FW_KEY_MASK 0xffffff00
|
||||
|
||||
#define REG_CR_EXT 0x1100
|
||||
|
||||
#define REG_DDMA_CH0SA 0x1200
|
||||
#define REG_DDMA_CH0DA 0x1204
|
||||
#define REG_DDMA_CH0CTRL 0x1208
|
||||
#define BIT_DDMACH0_OWN BIT(31)
|
||||
#define BIT_DDMACH0_CHKSUM_EN BIT(29)
|
||||
#define BIT_DDMACH0_CHKSUM_STS BIT(27)
|
||||
#define BIT_DDMACH0_RESET_CHKSUM_STS BIT(25)
|
||||
#define BIT_DDMACH0_CHKSUM_CONT BIT(24)
|
||||
#define BIT_MASK_DDMACH0_DLEN 0x3ffff
|
||||
|
||||
#define REG_H2CQ_CSR 0x1330
|
||||
#define BIT_H2CQ_FULL BIT(31)
|
||||
#define REG_FAST_EDCA_VOVI_SETTING 0x1448
|
||||
#define REG_FAST_EDCA_BEBK_SETTING 0x144C
|
||||
|
||||
#define REG_RXPSF_CTRL 0x1610
|
||||
#define BIT_RXGCK_FIFOTHR_EN BIT(28)
|
||||
|
||||
#define BIT_SHIFT_RXGCK_VHT_FIFOTHR 26
|
||||
#define BIT_MASK_RXGCK_VHT_FIFOTHR 0x3
|
||||
#define BIT_RXGCK_VHT_FIFOTHR(x) \
|
||||
(((x) & BIT_MASK_RXGCK_VHT_FIFOTHR) << BIT_SHIFT_RXGCK_VHT_FIFOTHR)
|
||||
#define BITS_RXGCK_VHT_FIFOTHR \
|
||||
(BIT_MASK_RXGCK_VHT_FIFOTHR << BIT_SHIFT_RXGCK_VHT_FIFOTHR)
|
||||
|
||||
#define BIT_SHIFT_RXGCK_HT_FIFOTHR 24
|
||||
#define BIT_MASK_RXGCK_HT_FIFOTHR 0x3
|
||||
#define BIT_RXGCK_HT_FIFOTHR(x) \
|
||||
(((x) & BIT_MASK_RXGCK_HT_FIFOTHR) << BIT_SHIFT_RXGCK_HT_FIFOTHR)
|
||||
#define BITS_RXGCK_HT_FIFOTHR \
|
||||
(BIT_MASK_RXGCK_HT_FIFOTHR << BIT_SHIFT_RXGCK_HT_FIFOTHR)
|
||||
|
||||
#define BIT_SHIFT_RXGCK_OFDM_FIFOTHR 22
|
||||
#define BIT_MASK_RXGCK_OFDM_FIFOTHR 0x3
|
||||
#define BIT_RXGCK_OFDM_FIFOTHR(x) \
|
||||
(((x) & BIT_MASK_RXGCK_OFDM_FIFOTHR) << BIT_SHIFT_RXGCK_OFDM_FIFOTHR)
|
||||
#define BITS_RXGCK_OFDM_FIFOTHR \
|
||||
(BIT_MASK_RXGCK_OFDM_FIFOTHR << BIT_SHIFT_RXGCK_OFDM_FIFOTHR)
|
||||
|
||||
#define BIT_SHIFT_RXGCK_CCK_FIFOTHR 20
|
||||
#define BIT_MASK_RXGCK_CCK_FIFOTHR 0x3
|
||||
#define BIT_RXGCK_CCK_FIFOTHR(x) \
|
||||
(((x) & BIT_MASK_RXGCK_CCK_FIFOTHR) << BIT_SHIFT_RXGCK_CCK_FIFOTHR)
|
||||
#define BITS_RXGCK_CCK_FIFOTHR \
|
||||
(BIT_MASK_RXGCK_CCK_FIFOTHR << BIT_SHIFT_RXGCK_CCK_FIFOTHR)
|
||||
|
||||
#define BIT_RXGCK_OFDMCCA_EN BIT(16)
|
||||
|
||||
#define BIT_SHIFT_RXPSF_PKTLENTHR 13
|
||||
#define BIT_MASK_RXPSF_PKTLENTHR 0x7
|
||||
#define BIT_RXPSF_PKTLENTHR(x) \
|
||||
(((x) & BIT_MASK_RXPSF_PKTLENTHR) << BIT_SHIFT_RXPSF_PKTLENTHR)
|
||||
#define BITS_RXPSF_PKTLENTHR \
|
||||
(BIT_MASK_RXPSF_PKTLENTHR << BIT_SHIFT_RXPSF_PKTLENTHR)
|
||||
#define BIT_CLEAR_RXPSF_PKTLENTHR(x) ((x) & (~BITS_RXPSF_PKTLENTHR))
|
||||
#define BIT_SET_RXPSF_PKTLENTHR(x, v) \
|
||||
(BIT_CLEAR_RXPSF_PKTLENTHR(x) | BIT_RXPSF_PKTLENTHR(v))
|
||||
|
||||
#define BIT_RXPSF_CTRLEN BIT(12)
|
||||
#define BIT_RXPSF_VHTCHKEN BIT(11)
|
||||
#define BIT_RXPSF_HTCHKEN BIT(10)
|
||||
#define BIT_RXPSF_OFDMCHKEN BIT(9)
|
||||
#define BIT_RXPSF_CCKCHKEN BIT(8)
|
||||
#define BIT_RXPSF_OFDMRST BIT(7)
|
||||
#define BIT_RXPSF_CCKRST BIT(6)
|
||||
#define BIT_RXPSF_MHCHKEN BIT(5)
|
||||
#define BIT_RXPSF_CONT_ERRCHKEN BIT(4)
|
||||
#define BIT_RXPSF_ALL_ERRCHKEN BIT(3)
|
||||
|
||||
#define BIT_SHIFT_RXPSF_ERRTHR 0
|
||||
#define BIT_MASK_RXPSF_ERRTHR 0x7
|
||||
#define BIT_RXPSF_ERRTHR(x) \
|
||||
(((x) & BIT_MASK_RXPSF_ERRTHR) << BIT_SHIFT_RXPSF_ERRTHR)
|
||||
#define BITS_RXPSF_ERRTHR (BIT_MASK_RXPSF_ERRTHR << BIT_SHIFT_RXPSF_ERRTHR)
|
||||
#define BIT_CLEAR_RXPSF_ERRTHR(x) ((x) & (~BITS_RXPSF_ERRTHR))
|
||||
#define BIT_GET_RXPSF_ERRTHR(x) \
|
||||
(((x) >> BIT_SHIFT_RXPSF_ERRTHR) & BIT_MASK_RXPSF_ERRTHR)
|
||||
#define BIT_SET_RXPSF_ERRTHR(x, v) \
|
||||
(BIT_CLEAR_RXPSF_ERRTHR(x) | BIT_RXPSF_ERRTHR(v))
|
||||
|
||||
#define REG_RXPSF_TYPE_CTRL 0x1614
|
||||
#define REG_GENERAL_OPTION 0x1664
|
||||
#define BIT_DUMMY_FCS_READY_MASK_EN BIT(9)
|
||||
|
||||
#define REG_WL2LTECOEX_INDIRECT_ACCESS_CTRL_V1 0x1700
|
||||
#define REG_WL2LTECOEX_INDIRECT_ACCESS_WRITE_DATA_V1 0x1704
|
||||
#define REG_WL2LTECOEX_INDIRECT_ACCESS_READ_DATA_V1 0x1708
|
||||
#define LTECOEX_READY BIT(29)
|
||||
#define LTECOEX_ACCESS_CTRL REG_WL2LTECOEX_INDIRECT_ACCESS_CTRL_V1
|
||||
#define LTECOEX_WRITE_DATA REG_WL2LTECOEX_INDIRECT_ACCESS_WRITE_DATA_V1
|
||||
#define LTECOEX_READ_DATA REG_WL2LTECOEX_INDIRECT_ACCESS_READ_DATA_V1
|
||||
|
||||
#define RF_DTXLOK 0x08
|
||||
#define RF_CFGCH 0x18
|
||||
#define RF_LUTWA 0x33
|
||||
#define RF_LUTWD1 0x3e
|
||||
#define RF_LUTWD0 0x3f
|
||||
#define RF_XTALX2 0xb8
|
||||
#define RF_MALSEL 0xbe
|
||||
#define RF_LUTDBG 0xdf
|
||||
#define RF_LUTWE2 0xee
|
||||
#define RF_LUTWE 0xef
|
||||
|
||||
#endif
|
391
drivers/net/wireless/realtek/rtw88/regd.c
Normal file
391
drivers/net/wireless/realtek/rtw88/regd.c
Normal file
|
@ -0,0 +1,391 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "regd.h"
|
||||
#include "debug.h"
|
||||
#include "phy.h"
|
||||
|
||||
#define COUNTRY_CHPLAN_ENT(_alpha2, _chplan, _txpwr_regd) \
|
||||
{.alpha2 = (_alpha2), \
|
||||
.chplan = (_chplan), \
|
||||
.txpwr_regd = (_txpwr_regd) \
|
||||
}
|
||||
|
||||
/* If country code is not correctly defined in efuse,
|
||||
* use worldwide country code and txpwr regd.
|
||||
*/
|
||||
static const struct rtw_regulatory rtw_defined_chplan =
|
||||
COUNTRY_CHPLAN_ENT("00", RTW_CHPLAN_REALTEK_DEFINE, RTW_REGD_WW);
|
||||
|
||||
static const struct rtw_regulatory all_chplan_map[] = {
|
||||
COUNTRY_CHPLAN_ENT("AD", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AE", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AF", RTW_CHPLAN_ETSI1_ETSI4, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AG", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AI", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AL", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AM", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AN", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AO", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AQ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AR", RTW_CHPLAN_FCC2_FCC7, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("AS", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("AT", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AU", RTW_CHPLAN_WORLD_ACMA1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("AW", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("AZ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BA", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BB", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("BD", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BE", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BF", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BG", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BH", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BI", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BJ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BN", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BO", RTW_CHPLAN_WORLD_FCC7, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("BR", RTW_CHPLAN_FCC2_FCC1, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("BS", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("BW", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BY", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("BZ", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("CA", RTW_CHPLAN_IC1_IC2, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("CC", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CD", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CF", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CG", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CH", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CI", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CK", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CL", RTW_CHPLAN_WORLD_CHILE1, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("CM", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CN", RTW_CHPLAN_WORLD_ETSI7, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CO", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("CR", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("CV", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CX", RTW_CHPLAN_WORLD_ACMA1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CY", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("CZ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("DE", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("DJ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("DK", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("DM", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("DO", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("DZ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("EC", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("EE", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("EG", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("EH", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("ER", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("ES", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("ET", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("FI", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("FJ", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("FK", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("FM", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("FO", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("FR", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GA", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GB", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GD", RTW_CHPLAN_FCC1_FCC7, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("GE", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GF", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GG", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GH", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GI", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GL", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GM", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GN", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GP", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GQ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GR", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GS", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GT", RTW_CHPLAN_FCC2_FCC7, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("GU", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("GW", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("GY", RTW_CHPLAN_FCC1_NCC3, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("HK", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("HM", RTW_CHPLAN_WORLD_ACMA1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("HN", RTW_CHPLAN_WORLD_FCC5, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("HR", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("HT", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("HU", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("ID", RTW_CHPLAN_ETSI1_ETSI12, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("IE", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("IL", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("IM", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("IN", RTW_CHPLAN_WORLD_ETSI7, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("IQ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("IR", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("IS", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("IT", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("JE", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("JM", RTW_CHPLAN_WORLD_ETSI10, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("JO", RTW_CHPLAN_WORLD_ETSI8, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("JP", RTW_CHPLAN_MKK1_MKK1, RTW_REGD_MKK),
|
||||
COUNTRY_CHPLAN_ENT("KE", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("KG", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("KH", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("KI", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("KN", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("KR", RTW_CHPLAN_KCC1_KCC2, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("KW", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("KY", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("KZ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("LA", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("LB", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("LC", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("LI", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("LK", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("LR", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("LS", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("LT", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("LU", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("LV", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("LY", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MA", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MC", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MD", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("ME", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MF", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("MG", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MH", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("MK", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("ML", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MM", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MN", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MO", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MP", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("MQ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MR", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MS", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MT", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MU", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MV", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MW", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MX", RTW_CHPLAN_FCC2_FCC7, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("MY", RTW_CHPLAN_WORLD_ETSI20, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("MZ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("NA", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("NC", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("NE", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("NF", RTW_CHPLAN_WORLD_ACMA1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("NG", RTW_CHPLAN_WORLD_ETSI20, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("NI", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("NL", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("NO", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("NP", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("NR", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("NU", RTW_CHPLAN_WORLD_ACMA1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("NZ", RTW_CHPLAN_WORLD_ACMA1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("OM", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("PA", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("PE", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("PF", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("PG", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("PH", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("PK", RTW_CHPLAN_WORLD_ETSI10, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("PL", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("PM", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("PR", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("PT", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("PW", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("PY", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("QA", RTW_CHPLAN_WORLD_ETSI10, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("RE", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("RO", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("RS", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("RU", RTW_CHPLAN_WORLD_ETSI14, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("RW", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SA", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SB", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SC", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("SE", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SG", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SH", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SI", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SJ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SK", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SL", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SM", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SN", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SO", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("SR", RTW_CHPLAN_FCC2_FCC17, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("ST", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("SV", RTW_CHPLAN_WORLD_FCC3, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("SX", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("SZ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TC", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TD", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TF", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TG", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TH", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TJ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TK", RTW_CHPLAN_WORLD_ACMA1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TM", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TN", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TO", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TR", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TT", RTW_CHPLAN_ETSI1_ETSI4, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("TW", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("TZ", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("UA", RTW_CHPLAN_WORLD_ETSI3, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("UG", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("US", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("UY", RTW_CHPLAN_WORLD_FCC3, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("UZ", RTW_CHPLAN_WORLD_ETSI6, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("VA", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("VC", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("VE", RTW_CHPLAN_WORLD_FCC3, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("VI", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("VN", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("VU", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("WF", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("WS", RTW_CHPLAN_FCC2_FCC11, RTW_REGD_FCC),
|
||||
COUNTRY_CHPLAN_ENT("YE", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("YT", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("ZA", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("ZM", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
COUNTRY_CHPLAN_ENT("ZW", RTW_CHPLAN_WORLD_ETSI1, RTW_REGD_ETSI),
|
||||
};
|
||||
|
||||
static void rtw_regd_apply_beaconing_flags(struct wiphy *wiphy,
|
||||
enum nl80211_reg_initiator initiator)
|
||||
{
|
||||
enum nl80211_band band;
|
||||
struct ieee80211_supported_band *sband;
|
||||
const struct ieee80211_reg_rule *reg_rule;
|
||||
struct ieee80211_channel *ch;
|
||||
unsigned int i;
|
||||
|
||||
for (band = 0; band < NUM_NL80211_BANDS; band++) {
|
||||
if (!wiphy->bands[band])
|
||||
continue;
|
||||
|
||||
sband = wiphy->bands[band];
|
||||
for (i = 0; i < sband->n_channels; i++) {
|
||||
ch = &sband->channels[i];
|
||||
|
||||
reg_rule = freq_reg_info(wiphy,
|
||||
MHZ_TO_KHZ(ch->center_freq));
|
||||
if (IS_ERR(reg_rule))
|
||||
continue;
|
||||
|
||||
ch->flags &= ~IEEE80211_CHAN_DISABLED;
|
||||
|
||||
if (!(reg_rule->flags & NL80211_RRF_NO_IR))
|
||||
ch->flags &= ~IEEE80211_CHAN_NO_IR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void rtw_regd_apply_hw_cap_flags(struct wiphy *wiphy)
|
||||
{
|
||||
struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
|
||||
struct ieee80211_supported_band *sband;
|
||||
struct ieee80211_channel *ch;
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct rtw_efuse *efuse = &rtwdev->efuse;
|
||||
int i;
|
||||
|
||||
if (efuse->hw_cap.bw & BIT(RTW_CHANNEL_WIDTH_80))
|
||||
return;
|
||||
|
||||
sband = wiphy->bands[NL80211_BAND_2GHZ];
|
||||
if (!sband)
|
||||
goto out_5g;
|
||||
|
||||
for (i = 0; i < sband->n_channels; i++) {
|
||||
ch = &sband->channels[i];
|
||||
ch->flags |= IEEE80211_CHAN_NO_80MHZ;
|
||||
}
|
||||
|
||||
out_5g:
|
||||
sband = wiphy->bands[NL80211_BAND_5GHZ];
|
||||
if (!sband)
|
||||
return;
|
||||
|
||||
for (i = 0; i < sband->n_channels; i++) {
|
||||
ch = &sband->channels[i];
|
||||
ch->flags |= IEEE80211_CHAN_NO_80MHZ;
|
||||
}
|
||||
}
|
||||
|
||||
static void rtw_regd_apply_world_flags(struct wiphy *wiphy,
|
||||
enum nl80211_reg_initiator initiator)
|
||||
{
|
||||
rtw_regd_apply_beaconing_flags(wiphy, initiator);
|
||||
}
|
||||
|
||||
static struct rtw_regulatory rtw_regd_find_reg_by_name(char *alpha2)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(all_chplan_map); i++) {
|
||||
if (!memcmp(all_chplan_map[i].alpha2, alpha2, 2))
|
||||
return all_chplan_map[i];
|
||||
}
|
||||
|
||||
return rtw_defined_chplan;
|
||||
}
|
||||
|
||||
static int rtw_regd_notifier_apply(struct rtw_dev *rtwdev,
|
||||
struct wiphy *wiphy,
|
||||
struct regulatory_request *request)
|
||||
{
|
||||
if (request->initiator == NL80211_REGDOM_SET_BY_USER)
|
||||
return 0;
|
||||
rtwdev->regd = rtw_regd_find_reg_by_name(request->alpha2);
|
||||
rtw_regd_apply_world_flags(wiphy, request->initiator);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rtw_regd_init_wiphy(struct rtw_regulatory *reg, struct wiphy *wiphy,
|
||||
void (*reg_notifier)(struct wiphy *wiphy,
|
||||
struct regulatory_request *request))
|
||||
{
|
||||
wiphy->reg_notifier = reg_notifier;
|
||||
|
||||
wiphy->regulatory_flags &= ~REGULATORY_CUSTOM_REG;
|
||||
wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG;
|
||||
wiphy->regulatory_flags &= ~REGULATORY_DISABLE_BEACON_HINTS;
|
||||
|
||||
rtw_regd_apply_hw_cap_flags(wiphy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtw_regd_init(struct rtw_dev *rtwdev,
|
||||
void (*reg_notifier)(struct wiphy *wiphy,
|
||||
struct regulatory_request *request))
|
||||
{
|
||||
struct wiphy *wiphy = rtwdev->hw->wiphy;
|
||||
|
||||
if (!wiphy)
|
||||
return -EINVAL;
|
||||
|
||||
rtwdev->regd = rtw_regd_find_reg_by_name(rtwdev->efuse.country_code);
|
||||
rtw_regd_init_wiphy(&rtwdev->regd, wiphy, reg_notifier);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtw_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request)
|
||||
{
|
||||
struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct rtw_hal *hal = &rtwdev->hal;
|
||||
|
||||
rtw_regd_notifier_apply(rtwdev, wiphy, request);
|
||||
rtw_dbg(rtwdev, RTW_DBG_REGD,
|
||||
"get alpha2 %c%c from initiator %d, mapping to chplan 0x%x, txregd %d\n",
|
||||
request->alpha2[0], request->alpha2[1], request->initiator,
|
||||
rtwdev->regd.chplan, rtwdev->regd.txpwr_regd);
|
||||
|
||||
rtw_phy_set_tx_power_level(rtwdev, hal->current_channel);
|
||||
}
|
67
drivers/net/wireless/realtek/rtw88/regd.h
Normal file
67
drivers/net/wireless/realtek/rtw88/regd.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_REGD_H_
|
||||
#define __RTW_REGD_H_
|
||||
|
||||
#define IEEE80211_CHAN_NO_IBSS IEEE80211_CHAN_NO_IR
|
||||
#define IEEE80211_CHAN_PASSIVE_SCAN IEEE80211_CHAN_NO_IR
|
||||
enum rtw_chplan_id {
|
||||
RTW_CHPLAN_WORLD_ETSI1 = 0x26,
|
||||
RTW_CHPLAN_MKK1_MKK1 = 0x27,
|
||||
RTW_CHPLAN_IC1_IC2 = 0x2B,
|
||||
RTW_CHPLAN_WORLD_CHILE1 = 0x2D,
|
||||
RTW_CHPLAN_WORLD_FCC3 = 0x30,
|
||||
RTW_CHPLAN_WORLD_FCC5 = 0x32,
|
||||
RTW_CHPLAN_FCC1_FCC7 = 0x34,
|
||||
RTW_CHPLAN_WORLD_ETSI3 = 0x36,
|
||||
RTW_CHPLAN_ETSI1_ETSI12 = 0x3D,
|
||||
RTW_CHPLAN_KCC1_KCC2 = 0x3E,
|
||||
RTW_CHPLAN_ETSI1_ETSI4 = 0x42,
|
||||
RTW_CHPLAN_FCC1_NCC3 = 0x44,
|
||||
RTW_CHPLAN_WORLD_ACMA1 = 0x45,
|
||||
RTW_CHPLAN_WORLD_ETSI6 = 0x47,
|
||||
RTW_CHPLAN_WORLD_ETSI7 = 0x48,
|
||||
RTW_CHPLAN_WORLD_ETSI8 = 0x49,
|
||||
RTW_CHPLAN_WORLD_ETSI10 = 0x51,
|
||||
RTW_CHPLAN_WORLD_ETSI14 = 0x59,
|
||||
RTW_CHPLAN_FCC2_FCC7 = 0x61,
|
||||
RTW_CHPLAN_FCC2_FCC1 = 0x62,
|
||||
RTW_CHPLAN_WORLD_FCC7 = 0x73,
|
||||
RTW_CHPLAN_FCC2_FCC17 = 0x74,
|
||||
RTW_CHPLAN_WORLD_ETSI20 = 0x75,
|
||||
RTW_CHPLAN_FCC2_FCC11 = 0x76,
|
||||
RTW_CHPLAN_REALTEK_DEFINE = 0x7f,
|
||||
};
|
||||
|
||||
struct country_code_to_enum_rd {
|
||||
u16 countrycode;
|
||||
const char *iso_name;
|
||||
};
|
||||
|
||||
enum country_code_type {
|
||||
COUNTRY_CODE_FCC = 0,
|
||||
COUNTRY_CODE_IC = 1,
|
||||
COUNTRY_CODE_ETSI = 2,
|
||||
COUNTRY_CODE_SPAIN = 3,
|
||||
COUNTRY_CODE_FRANCE = 4,
|
||||
COUNTRY_CODE_MKK = 5,
|
||||
COUNTRY_CODE_MKK1 = 6,
|
||||
COUNTRY_CODE_ISRAEL = 7,
|
||||
COUNTRY_CODE_TELEC = 8,
|
||||
COUNTRY_CODE_MIC = 9,
|
||||
COUNTRY_CODE_GLOBAL_DOMAIN = 10,
|
||||
COUNTRY_CODE_WORLD_WIDE_13 = 11,
|
||||
COUNTRY_CODE_TELEC_NETGEAR = 12,
|
||||
COUNTRY_CODE_WORLD_WIDE_13_5G_ALL = 13,
|
||||
|
||||
/* new channel plan above this */
|
||||
COUNTRY_CODE_MAX
|
||||
};
|
||||
|
||||
int rtw_regd_init(struct rtw_dev *rtwdev,
|
||||
void (*reg_notifier)(struct wiphy *wiphy,
|
||||
struct regulatory_request *request));
|
||||
void rtw_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request);
|
||||
#endif
|
1594
drivers/net/wireless/realtek/rtw88/rtw8822b.c
Normal file
1594
drivers/net/wireless/realtek/rtw88/rtw8822b.c
Normal file
File diff suppressed because it is too large
Load diff
170
drivers/net/wireless/realtek/rtw88/rtw8822b.h
Normal file
170
drivers/net/wireless/realtek/rtw88/rtw8822b.h
Normal file
|
@ -0,0 +1,170 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW8822B_H__
|
||||
#define __RTW8822B_H__
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#define RCR_VHT_ACK BIT(26)
|
||||
|
||||
struct rtw8822bu_efuse {
|
||||
u8 res4[4]; /* 0xd0 */
|
||||
u8 usb_optional_function;
|
||||
u8 res5[0x1e];
|
||||
u8 res6[2];
|
||||
u8 serial[0x0b]; /* 0xf5 */
|
||||
u8 vid; /* 0x100 */
|
||||
u8 res7;
|
||||
u8 pid;
|
||||
u8 res8[4];
|
||||
u8 mac_addr[ETH_ALEN]; /* 0x107 */
|
||||
u8 res9[2];
|
||||
u8 vendor_name[0x07];
|
||||
u8 res10[2];
|
||||
u8 device_name[0x14];
|
||||
u8 res11[0xcf];
|
||||
u8 package_type; /* 0x1fb */
|
||||
u8 res12[0x4];
|
||||
};
|
||||
|
||||
struct rtw8822be_efuse {
|
||||
u8 mac_addr[ETH_ALEN]; /* 0xd0 */
|
||||
u8 vender_id[2];
|
||||
u8 device_id[2];
|
||||
u8 sub_vender_id[2];
|
||||
u8 sub_device_id[2];
|
||||
u8 pmc[2];
|
||||
u8 exp_device_cap[2];
|
||||
u8 msi_cap;
|
||||
u8 ltr_cap; /* 0xe3 */
|
||||
u8 exp_link_control[2];
|
||||
u8 link_cap[4];
|
||||
u8 link_control[2];
|
||||
u8 serial_number[8];
|
||||
u8 res0:2; /* 0xf4 */
|
||||
u8 ltr_en:1;
|
||||
u8 res1:2;
|
||||
u8 obff:2;
|
||||
u8 res2:3;
|
||||
u8 obff_cap:2;
|
||||
u8 res3:4;
|
||||
u8 res4[3];
|
||||
u8 class_code[3];
|
||||
u8 pci_pm_L1_2_supp:1;
|
||||
u8 pci_pm_L1_1_supp:1;
|
||||
u8 aspm_pm_L1_2_supp:1;
|
||||
u8 aspm_pm_L1_1_supp:1;
|
||||
u8 L1_pm_substates_supp:1;
|
||||
u8 res5:3;
|
||||
u8 port_common_mode_restore_time;
|
||||
u8 port_t_power_on_scale:2;
|
||||
u8 res6:1;
|
||||
u8 port_t_power_on_value:5;
|
||||
u8 res7;
|
||||
};
|
||||
|
||||
struct rtw8822b_efuse {
|
||||
__le16 rtl_id;
|
||||
u8 res0[0x0e];
|
||||
|
||||
/* power index for four RF paths */
|
||||
struct rtw_txpwr_idx txpwr_idx_table[4];
|
||||
|
||||
u8 channel_plan; /* 0xb8 */
|
||||
u8 xtal_k;
|
||||
u8 thermal_meter;
|
||||
u8 iqk_lck;
|
||||
u8 pa_type; /* 0xbc */
|
||||
u8 lna_type_2g[2]; /* 0xbd */
|
||||
u8 lna_type_5g[2];
|
||||
u8 rf_board_option;
|
||||
u8 rf_feature_option;
|
||||
u8 rf_bt_setting;
|
||||
u8 eeprom_version;
|
||||
u8 eeprom_customer_id;
|
||||
u8 tx_bb_swing_setting_2g;
|
||||
u8 tx_bb_swing_setting_5g;
|
||||
u8 tx_pwr_calibrate_rate;
|
||||
u8 rf_antenna_option; /* 0xc9 */
|
||||
u8 rfe_option;
|
||||
u8 country_code[2];
|
||||
u8 res[3];
|
||||
union {
|
||||
struct rtw8822bu_efuse u;
|
||||
struct rtw8822be_efuse e;
|
||||
};
|
||||
};
|
||||
|
||||
static inline void
|
||||
_rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
|
||||
{
|
||||
/* 0xC00-0xCFF and 0xE00-0xEFF have the same layout */
|
||||
rtw_write32_mask(rtwdev, addr, mask, data);
|
||||
rtw_write32_mask(rtwdev, addr + 0x200, mask, data);
|
||||
}
|
||||
|
||||
#define rtw_write32s_mask(rtwdev, addr, mask, data) \
|
||||
do { \
|
||||
BUILD_BUG_ON((addr) < 0xC00 || (addr) >= 0xD00); \
|
||||
\
|
||||
_rtw_write32s_mask(rtwdev, addr, mask, data); \
|
||||
} while (0)
|
||||
|
||||
/* phy status page0 */
|
||||
#define GET_PHY_STAT_P0_PWDB(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8))
|
||||
|
||||
/* phy status page1 */
|
||||
#define GET_PHY_STAT_P1_PWDB_A(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8))
|
||||
#define GET_PHY_STAT_P1_PWDB_B(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(23, 16))
|
||||
#define GET_PHY_STAT_P1_RF_MODE(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x03), GENMASK(29, 28))
|
||||
#define GET_PHY_STAT_P1_L_RXSC(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(11, 8))
|
||||
#define GET_PHY_STAT_P1_HT_RXSC(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(15, 12))
|
||||
|
||||
#define REG_HTSTFWT 0x800
|
||||
#define REG_RXPSEL 0x808
|
||||
#define BIT_RX_PSEL_RST (BIT(28) | BIT(29))
|
||||
#define REG_TXPSEL 0x80c
|
||||
#define REG_RXCCAMSK 0x814
|
||||
#define REG_CCASEL 0x82c
|
||||
#define REG_PDMFTH 0x830
|
||||
#define REG_CCA2ND 0x838
|
||||
#define REG_L1WT 0x83c
|
||||
#define REG_L1PKWT 0x840
|
||||
#define REG_MRC 0x850
|
||||
#define REG_CLKTRK 0x860
|
||||
#define REG_ADCCLK 0x8ac
|
||||
#define REG_ADC160 0x8c4
|
||||
#define REG_ADC40 0x8c8
|
||||
#define REG_CDDTXP 0x93c
|
||||
#define REG_TXPSEL1 0x940
|
||||
#define REG_ACBB0 0x948
|
||||
#define REG_ACBBRXFIR 0x94c
|
||||
#define REG_ACGG2TBL 0x958
|
||||
#define REG_RXSB 0xa00
|
||||
#define REG_ADCINI 0xa04
|
||||
#define REG_TXSF2 0xa24
|
||||
#define REG_TXSF6 0xa28
|
||||
#define REG_RXDESC 0xa2c
|
||||
#define REG_ENTXCCK 0xa80
|
||||
#define REG_AGCTR_A 0xc08
|
||||
#define REG_TXDFIR 0xc20
|
||||
#define REG_RXIGI_A 0xc50
|
||||
#define REG_TRSW 0xca0
|
||||
#define REG_RFESEL0 0xcb0
|
||||
#define REG_RFESEL8 0xcb4
|
||||
#define REG_RFECTL 0xcb8
|
||||
#define REG_RFEINV 0xcbc
|
||||
#define REG_AGCTR_B 0xe08
|
||||
#define REG_RXIGI_B 0xe50
|
||||
#define REG_ANTWT 0x1904
|
||||
#define REG_IQKFAILMSK 0x1bf0
|
||||
|
||||
#endif
|
20783
drivers/net/wireless/realtek/rtw88/rtw8822b_table.c
Normal file
20783
drivers/net/wireless/realtek/rtw88/rtw8822b_table.c
Normal file
File diff suppressed because it is too large
Load diff
18
drivers/net/wireless/realtek/rtw88/rtw8822b_table.h
Normal file
18
drivers/net/wireless/realtek/rtw88/rtw8822b_table.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW8822B_TABLE_H__
|
||||
#define __RTW8822B_TABLE_H__
|
||||
|
||||
extern const struct rtw_table rtw8822b_mac_tbl;
|
||||
extern const struct rtw_table rtw8822b_agc_tbl;
|
||||
extern const struct rtw_table rtw8822b_bb_tbl;
|
||||
extern const struct rtw_table rtw8822b_bb_pg_type2_tbl;
|
||||
extern const struct rtw_table rtw8822b_bb_pg_type5_tbl;
|
||||
extern const struct rtw_table rtw8822b_rf_a_tbl;
|
||||
extern const struct rtw_table rtw8822b_rf_b_tbl;
|
||||
extern const struct rtw_table rtw8822b_txpwr_lmt_type2_tbl;
|
||||
extern const struct rtw_table rtw8822b_txpwr_lmt_type5_tbl;
|
||||
|
||||
#endif
|
1890
drivers/net/wireless/realtek/rtw88/rtw8822c.c
Normal file
1890
drivers/net/wireless/realtek/rtw88/rtw8822c.c
Normal file
File diff suppressed because it is too large
Load diff
186
drivers/net/wireless/realtek/rtw88/rtw8822c.h
Normal file
186
drivers/net/wireless/realtek/rtw88/rtw8822c.h
Normal file
|
@ -0,0 +1,186 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW8822C_H__
|
||||
#define __RTW8822C_H__
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
struct rtw8822cu_efuse {
|
||||
u8 res0[0x30]; /* 0x120 */
|
||||
u8 vid[2]; /* 0x150 */
|
||||
u8 pid[2];
|
||||
u8 res1[3];
|
||||
u8 mac_addr[ETH_ALEN]; /* 0x157 */
|
||||
u8 res2[0x3d];
|
||||
};
|
||||
|
||||
struct rtw8822ce_efuse {
|
||||
u8 mac_addr[ETH_ALEN]; /* 0x120 */
|
||||
u8 vender_id[2];
|
||||
u8 device_id[2];
|
||||
u8 sub_vender_id[2];
|
||||
u8 sub_device_id[2];
|
||||
u8 pmc[2];
|
||||
u8 exp_device_cap[2];
|
||||
u8 msi_cap;
|
||||
u8 ltr_cap; /* 0x133 */
|
||||
u8 exp_link_control[2];
|
||||
u8 link_cap[4];
|
||||
u8 link_control[2];
|
||||
u8 serial_number[8];
|
||||
u8 res0:2; /* 0x144 */
|
||||
u8 ltr_en:1;
|
||||
u8 res1:2;
|
||||
u8 obff:2;
|
||||
u8 res2:3;
|
||||
u8 obff_cap:2;
|
||||
u8 res3:4;
|
||||
u8 class_code[3];
|
||||
u8 res4;
|
||||
u8 pci_pm_L1_2_supp:1;
|
||||
u8 pci_pm_L1_1_supp:1;
|
||||
u8 aspm_pm_L1_2_supp:1;
|
||||
u8 aspm_pm_L1_1_supp:1;
|
||||
u8 L1_pm_substates_supp:1;
|
||||
u8 res5:3;
|
||||
u8 port_common_mode_restore_time;
|
||||
u8 port_t_power_on_scale:2;
|
||||
u8 res6:1;
|
||||
u8 port_t_power_on_value:5;
|
||||
u8 res7;
|
||||
};
|
||||
|
||||
struct rtw8822c_efuse {
|
||||
__le16 rtl_id;
|
||||
u8 res0[0x0e];
|
||||
|
||||
/* power index for four RF paths */
|
||||
struct rtw_txpwr_idx txpwr_idx_table[4];
|
||||
|
||||
u8 channel_plan; /* 0xb8 */
|
||||
u8 xtal_k;
|
||||
u8 res1;
|
||||
u8 iqk_lck;
|
||||
u8 res2[5]; /* 0xbc */
|
||||
u8 rf_board_option;
|
||||
u8 rf_feature_option;
|
||||
u8 rf_bt_setting;
|
||||
u8 eeprom_version;
|
||||
u8 eeprom_customer_id;
|
||||
u8 tx_bb_swing_setting_2g;
|
||||
u8 tx_bb_swing_setting_5g;
|
||||
u8 tx_pwr_calibrate_rate;
|
||||
u8 rf_antenna_option; /* 0xc9 */
|
||||
u8 rfe_option;
|
||||
u8 country_code[2];
|
||||
u8 res3[3];
|
||||
u8 path_a_thermal; /* 0xd0 */
|
||||
u8 path_b_thermal;
|
||||
u8 res4[2];
|
||||
u8 rx_gain_gap_2g_ofdm;
|
||||
u8 res5;
|
||||
u8 rx_gain_gap_2g_cck;
|
||||
u8 res6;
|
||||
u8 rx_gain_gap_5gl;
|
||||
u8 res7;
|
||||
u8 rx_gain_gap_5gm;
|
||||
u8 res8;
|
||||
u8 rx_gain_gap_5gh;
|
||||
u8 res9;
|
||||
u8 res10[0x42];
|
||||
union {
|
||||
struct rtw8822cu_efuse u;
|
||||
struct rtw8822ce_efuse e;
|
||||
};
|
||||
};
|
||||
|
||||
#define DACK_PATH_8822C 2
|
||||
#define DACK_REG_8822C 16
|
||||
#define DACK_RF_8822C 1
|
||||
#define DACK_SN_8822C 100
|
||||
|
||||
/* phy status page0 */
|
||||
#define GET_PHY_STAT_P0_PWDB_A(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8))
|
||||
#define GET_PHY_STAT_P0_PWDB_B(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(7, 0))
|
||||
#define GET_PHY_STAT_P0_GAIN_A(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(21, 16))
|
||||
#define GET_PHY_STAT_P0_GAIN_B(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(29, 24))
|
||||
|
||||
/* phy status page1 */
|
||||
#define GET_PHY_STAT_P1_PWDB_A(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8))
|
||||
#define GET_PHY_STAT_P1_PWDB_B(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(23, 16))
|
||||
#define GET_PHY_STAT_P1_L_RXSC(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(11, 8))
|
||||
#define GET_PHY_STAT_P1_HT_RXSC(phy_stat) \
|
||||
le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(15, 12))
|
||||
|
||||
#define REG_ANAPARLDO_POW_MAC 0x0029
|
||||
#define BIT_LDOE25_PON BIT(0)
|
||||
#define REG_RRSR 0x0440
|
||||
#define BITS_RRSR_RSC (BIT(21) | BIT(22))
|
||||
|
||||
#define REG_TXDFIR0 0x808
|
||||
#define REG_DFIRBW 0x810
|
||||
#define REG_ANTMAP0 0x820
|
||||
#define REG_ANTMAP 0x824
|
||||
#define REG_DYMPRITH 0x86c
|
||||
#define REG_DYMENTH0 0x870
|
||||
#define REG_DYMENTH 0x874
|
||||
#define REG_DYMTHMIN 0x8a4
|
||||
#define REG_TXBWCTL 0x9b0
|
||||
#define REG_TXCLK 0x9b4
|
||||
#define REG_SCOTRK 0xc30
|
||||
#define REG_MRCM 0xc38
|
||||
#define REG_AGCSWSH 0xc44
|
||||
#define REG_ANTWTPD 0xc54
|
||||
#define REG_ORITXCODE 0x1800
|
||||
#define REG_3WIRE 0x180c
|
||||
#define BIT_3WIRE_TX_EN BIT(0)
|
||||
#define BIT_3WIRE_RX_EN BIT(1)
|
||||
#define BIT_3WIRE_PI_ON BIT(28)
|
||||
#define REG_RXAGCCTL0 0x18ac
|
||||
#define REG_CCKSB 0x1a00
|
||||
#define REG_RXCCKSEL 0x1a04
|
||||
#define REG_BGCTRL 0x1a14
|
||||
#define BITS_RX_IQ_WEIGHT (BIT(8) | BIT(9))
|
||||
#define REG_TXF0 0x1a20
|
||||
#define REG_TXF1 0x1a24
|
||||
#define REG_TXF2 0x1a28
|
||||
#define REG_CCANRX 0x1a2c
|
||||
#define BIT_CCK_FA_RST (BIT(14) | BIT(15))
|
||||
#define BIT_OFDM_FA_RST (BIT(12) | BIT(13))
|
||||
#define REG_CCK_FACNT 0x1a5c
|
||||
#define REG_CCKTXONLY 0x1a80
|
||||
#define BIT_BB_CCK_CHECK_EN BIT(18)
|
||||
#define REG_TXF3 0x1a98
|
||||
#define REG_TXF4 0x1a9c
|
||||
#define REG_TXF5 0x1aa0
|
||||
#define REG_TXF6 0x1aac
|
||||
#define REG_TXF7 0x1ab0
|
||||
#define REG_TXANT 0x1c28
|
||||
#define REG_ENCCK 0x1c3c
|
||||
#define BIT_CCK_BLK_EN BIT(1)
|
||||
#define BIT_CCK_OFDM_BLK_EN (BIT(0) | BIT(1))
|
||||
#define REG_CCAMSK 0x1c80
|
||||
#define REG_RXFNCTL 0x1d30
|
||||
#define REG_RXIGI 0x1d70
|
||||
#define REG_ENFN 0x1e24
|
||||
#define REG_TXANTSEG 0x1e28
|
||||
#define REG_TXLGMAP 0x1e2c
|
||||
#define REG_CCKPATH 0x1e5c
|
||||
#define REG_CNT_CTRL 0x1eb4
|
||||
#define BIT_ALL_CNT_RST BIT(25)
|
||||
#define REG_OFDM_FACNT 0x2d00
|
||||
#define REG_OFDM_TXCNT 0x2de0
|
||||
#define REG_ORITXCODE2 0x4100
|
||||
#define REG_3WIRE2 0x410c
|
||||
#define REG_RXAGCCTL 0x41ac
|
||||
|
||||
#endif
|
11753
drivers/net/wireless/realtek/rtw88/rtw8822c_table.c
Normal file
11753
drivers/net/wireless/realtek/rtw88/rtw8822c_table.c
Normal file
File diff suppressed because it is too large
Load diff
17
drivers/net/wireless/realtek/rtw88/rtw8822c_table.h
Normal file
17
drivers/net/wireless/realtek/rtw88/rtw8822c_table.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW8822C_TABLE_H__
|
||||
#define __RTW8822C_TABLE_H__
|
||||
|
||||
extern const struct rtw_table rtw8822c_mac_tbl;
|
||||
extern const struct rtw_table rtw8822c_agc_tbl;
|
||||
extern const struct rtw_table rtw8822c_bb_tbl;
|
||||
extern const struct rtw_table rtw8822c_bb_pg_type0_tbl;
|
||||
extern const struct rtw_table rtw8822c_rf_a_tbl;
|
||||
extern const struct rtw_table rtw8822c_rf_b_tbl;
|
||||
extern const struct rtw_table rtw8822c_txpwr_lmt_type0_tbl;
|
||||
extern const struct rtw_table rtw8822c_array_mp_cal_init_tbl;
|
||||
|
||||
#endif
|
151
drivers/net/wireless/realtek/rtw88/rx.c
Normal file
151
drivers/net/wireless/realtek/rtw88/rx.c
Normal file
|
@ -0,0 +1,151 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "rx.h"
|
||||
#include "ps.h"
|
||||
|
||||
void rtw_rx_stats(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct ieee80211_hdr *hdr;
|
||||
struct rtw_vif *rtwvif;
|
||||
|
||||
hdr = (struct ieee80211_hdr *)skb->data;
|
||||
|
||||
if (!ieee80211_is_data(hdr->frame_control))
|
||||
return;
|
||||
|
||||
if (!is_broadcast_ether_addr(hdr->addr1) &&
|
||||
!is_multicast_ether_addr(hdr->addr1)) {
|
||||
rtwdev->stats.rx_unicast += skb->len;
|
||||
rtwdev->stats.rx_cnt++;
|
||||
if (vif) {
|
||||
rtwvif = (struct rtw_vif *)vif->drv_priv;
|
||||
rtwvif->stats.rx_unicast += skb->len;
|
||||
rtwvif->stats.rx_cnt++;
|
||||
if (rtwvif->stats.rx_cnt > RTW_LPS_THRESHOLD)
|
||||
rtw_leave_lps_irqsafe(rtwdev, rtwvif);
|
||||
}
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(rtw_rx_stats);
|
||||
|
||||
struct rtw_rx_addr_match_data {
|
||||
struct rtw_dev *rtwdev;
|
||||
struct ieee80211_hdr *hdr;
|
||||
struct rtw_rx_pkt_stat *pkt_stat;
|
||||
u8 *bssid;
|
||||
};
|
||||
|
||||
static void rtw_rx_addr_match_iter(void *data, u8 *mac,
|
||||
struct ieee80211_vif *vif)
|
||||
{
|
||||
struct rtw_rx_addr_match_data *iter_data = data;
|
||||
struct ieee80211_sta *sta;
|
||||
struct ieee80211_hdr *hdr = iter_data->hdr;
|
||||
struct rtw_dev *rtwdev = iter_data->rtwdev;
|
||||
struct rtw_sta_info *si;
|
||||
struct rtw_rx_pkt_stat *pkt_stat = iter_data->pkt_stat;
|
||||
u8 *bssid = iter_data->bssid;
|
||||
|
||||
if (ether_addr_equal(vif->bss_conf.bssid, bssid) &&
|
||||
(ether_addr_equal(vif->addr, hdr->addr1) ||
|
||||
ieee80211_is_beacon(hdr->frame_control)))
|
||||
sta = ieee80211_find_sta_by_ifaddr(rtwdev->hw, hdr->addr2,
|
||||
vif->addr);
|
||||
else
|
||||
return;
|
||||
|
||||
if (!sta)
|
||||
return;
|
||||
|
||||
si = (struct rtw_sta_info *)sta->drv_priv;
|
||||
ewma_rssi_add(&si->avg_rssi, pkt_stat->rssi);
|
||||
}
|
||||
|
||||
static void rtw_rx_addr_match(struct rtw_dev *rtwdev,
|
||||
struct rtw_rx_pkt_stat *pkt_stat,
|
||||
struct ieee80211_hdr *hdr)
|
||||
{
|
||||
struct rtw_rx_addr_match_data data = {};
|
||||
|
||||
if (pkt_stat->crc_err || pkt_stat->icv_err || !pkt_stat->phy_status ||
|
||||
ieee80211_is_ctl(hdr->frame_control))
|
||||
return;
|
||||
|
||||
data.rtwdev = rtwdev;
|
||||
data.hdr = hdr;
|
||||
data.pkt_stat = pkt_stat;
|
||||
data.bssid = get_hdr_bssid(hdr);
|
||||
|
||||
rtw_iterate_vifs_atomic(rtwdev, rtw_rx_addr_match_iter, &data);
|
||||
}
|
||||
|
||||
void rtw_rx_fill_rx_status(struct rtw_dev *rtwdev,
|
||||
struct rtw_rx_pkt_stat *pkt_stat,
|
||||
struct ieee80211_hdr *hdr,
|
||||
struct ieee80211_rx_status *rx_status,
|
||||
u8 *phy_status)
|
||||
{
|
||||
struct ieee80211_hw *hw = rtwdev->hw;
|
||||
|
||||
memset(rx_status, 0, sizeof(*rx_status));
|
||||
rx_status->freq = hw->conf.chandef.chan->center_freq;
|
||||
rx_status->band = hw->conf.chandef.chan->band;
|
||||
if (pkt_stat->crc_err)
|
||||
rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
|
||||
if (pkt_stat->decrypted)
|
||||
rx_status->flag |= RX_FLAG_DECRYPTED;
|
||||
|
||||
if (pkt_stat->rate >= DESC_RATEVHT1SS_MCS0)
|
||||
rx_status->encoding = RX_ENC_VHT;
|
||||
else if (pkt_stat->rate >= DESC_RATEMCS0)
|
||||
rx_status->encoding = RX_ENC_HT;
|
||||
|
||||
if (pkt_stat->rate >= DESC_RATEVHT1SS_MCS0 &&
|
||||
pkt_stat->rate <= DESC_RATEVHT1SS_MCS9) {
|
||||
rx_status->nss = 1;
|
||||
rx_status->rate_idx = pkt_stat->rate - DESC_RATEVHT1SS_MCS0;
|
||||
} else if (pkt_stat->rate >= DESC_RATEVHT2SS_MCS0 &&
|
||||
pkt_stat->rate <= DESC_RATEVHT2SS_MCS9) {
|
||||
rx_status->nss = 2;
|
||||
rx_status->rate_idx = pkt_stat->rate - DESC_RATEVHT2SS_MCS0;
|
||||
} else if (pkt_stat->rate >= DESC_RATEVHT3SS_MCS0 &&
|
||||
pkt_stat->rate <= DESC_RATEVHT3SS_MCS9) {
|
||||
rx_status->nss = 3;
|
||||
rx_status->rate_idx = pkt_stat->rate - DESC_RATEVHT3SS_MCS0;
|
||||
} else if (pkt_stat->rate >= DESC_RATEVHT4SS_MCS0 &&
|
||||
pkt_stat->rate <= DESC_RATEVHT4SS_MCS9) {
|
||||
rx_status->nss = 4;
|
||||
rx_status->rate_idx = pkt_stat->rate - DESC_RATEVHT4SS_MCS0;
|
||||
} else if (pkt_stat->rate >= DESC_RATEMCS0 &&
|
||||
pkt_stat->rate <= DESC_RATEMCS15) {
|
||||
rx_status->rate_idx = pkt_stat->rate - DESC_RATEMCS0;
|
||||
} else if (rx_status->band == NL80211_BAND_5GHZ &&
|
||||
pkt_stat->rate >= DESC_RATE6M &&
|
||||
pkt_stat->rate <= DESC_RATE54M) {
|
||||
rx_status->rate_idx = pkt_stat->rate - DESC_RATE6M;
|
||||
} else if (rx_status->band == NL80211_BAND_2GHZ &&
|
||||
pkt_stat->rate >= DESC_RATE1M &&
|
||||
pkt_stat->rate <= DESC_RATE54M) {
|
||||
rx_status->rate_idx = pkt_stat->rate - DESC_RATE1M;
|
||||
} else {
|
||||
rx_status->rate_idx = 0;
|
||||
}
|
||||
|
||||
rx_status->flag |= RX_FLAG_MACTIME_START;
|
||||
rx_status->mactime = pkt_stat->tsf_low;
|
||||
|
||||
if (pkt_stat->bw == RTW_CHANNEL_WIDTH_80)
|
||||
rx_status->bw = RATE_INFO_BW_80;
|
||||
else if (pkt_stat->bw == RTW_CHANNEL_WIDTH_40)
|
||||
rx_status->bw = RATE_INFO_BW_40;
|
||||
else
|
||||
rx_status->bw = RATE_INFO_BW_20;
|
||||
|
||||
rx_status->signal = pkt_stat->signal_power;
|
||||
|
||||
rtw_rx_addr_match(rtwdev, pkt_stat, hdr);
|
||||
}
|
41
drivers/net/wireless/realtek/rtw88/rx.h
Normal file
41
drivers/net/wireless/realtek/rtw88/rx.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_RX_H_
|
||||
#define __RTW_RX_H_
|
||||
|
||||
#define GET_RX_DESC_PHYST(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x00), BIT(26))
|
||||
#define GET_RX_DESC_ICV_ERR(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x00), BIT(15))
|
||||
#define GET_RX_DESC_CRC32(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x00), BIT(14))
|
||||
#define GET_RX_DESC_SWDEC(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x00), BIT(27))
|
||||
#define GET_RX_DESC_C2H(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x02), BIT(28))
|
||||
#define GET_RX_DESC_PKT_LEN(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x00), GENMASK(13, 0))
|
||||
#define GET_RX_DESC_DRV_INFO_SIZE(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x00), GENMASK(19, 16))
|
||||
#define GET_RX_DESC_SHIFT(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x00), GENMASK(25, 24))
|
||||
#define GET_RX_DESC_RX_RATE(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x03), GENMASK(6, 0))
|
||||
#define GET_RX_DESC_MACID(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x01), GENMASK(6, 0))
|
||||
#define GET_RX_DESC_PPDU_CNT(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x02), GENMASK(30, 29))
|
||||
#define GET_RX_DESC_TSFL(rxdesc) \
|
||||
le32_get_bits(*((__le32 *)(rxdesc) + 0x05), GENMASK(31, 0))
|
||||
|
||||
void rtw_rx_stats(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
|
||||
struct sk_buff *skb);
|
||||
void rtw_rx_fill_rx_status(struct rtw_dev *rtwdev,
|
||||
struct rtw_rx_pkt_stat *pkt_stat,
|
||||
struct ieee80211_hdr *hdr,
|
||||
struct ieee80211_rx_status *rx_status,
|
||||
u8 *phy_status);
|
||||
|
||||
#endif
|
120
drivers/net/wireless/realtek/rtw88/sec.c
Normal file
120
drivers/net/wireless/realtek/rtw88/sec.c
Normal file
|
@ -0,0 +1,120 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "sec.h"
|
||||
#include "reg.h"
|
||||
|
||||
int rtw_sec_get_free_cam(struct rtw_sec_desc *sec)
|
||||
{
|
||||
/* if default key search is enabled, the first 4 cam entries
|
||||
* are used to direct map to group key with its key->key_idx, so
|
||||
* driver should use cam entries after 4 to install pairwise key
|
||||
*/
|
||||
if (sec->default_key_search)
|
||||
return find_next_zero_bit(sec->cam_map, RTW_MAX_SEC_CAM_NUM,
|
||||
RTW_SEC_DEFAULT_KEY_NUM);
|
||||
|
||||
return find_first_zero_bit(sec->cam_map, RTW_MAX_SEC_CAM_NUM);
|
||||
}
|
||||
|
||||
void rtw_sec_write_cam(struct rtw_dev *rtwdev,
|
||||
struct rtw_sec_desc *sec,
|
||||
struct ieee80211_sta *sta,
|
||||
struct ieee80211_key_conf *key,
|
||||
u8 hw_key_type, u8 hw_key_idx)
|
||||
{
|
||||
struct rtw_cam_entry *cam = &sec->cam_table[hw_key_idx];
|
||||
u32 write_cmd;
|
||||
u32 command;
|
||||
u32 content;
|
||||
u32 addr;
|
||||
int i, j;
|
||||
|
||||
set_bit(hw_key_idx, sec->cam_map);
|
||||
cam->valid = true;
|
||||
cam->group = !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE);
|
||||
cam->hw_key_type = hw_key_type;
|
||||
cam->key = key;
|
||||
if (sta)
|
||||
ether_addr_copy(cam->addr, sta->addr);
|
||||
else
|
||||
eth_broadcast_addr(cam->addr);
|
||||
|
||||
write_cmd = RTW_SEC_CMD_WRITE_ENABLE | RTW_SEC_CMD_POLLING;
|
||||
addr = hw_key_idx << RTW_SEC_CAM_ENTRY_SHIFT;
|
||||
for (i = 5; i >= 0; i--) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
content = ((key->keyidx & 0x3)) |
|
||||
((hw_key_type & 0x7) << 2) |
|
||||
(cam->group << 6) |
|
||||
(cam->valid << 15) |
|
||||
(cam->addr[0] << 16) |
|
||||
(cam->addr[1] << 24);
|
||||
break;
|
||||
case 1:
|
||||
content = (cam->addr[2]) |
|
||||
(cam->addr[3] << 8) |
|
||||
(cam->addr[4] << 16) |
|
||||
(cam->addr[5] << 24);
|
||||
break;
|
||||
default:
|
||||
j = (i - 2) << 2;
|
||||
content = (key->key[j]) |
|
||||
(key->key[j + 1] << 8) |
|
||||
(key->key[j + 2] << 16) |
|
||||
(key->key[j + 3] << 24);
|
||||
break;
|
||||
}
|
||||
|
||||
command = write_cmd | (addr + i);
|
||||
rtw_write32(rtwdev, RTW_SEC_WRITE_REG, content);
|
||||
rtw_write32(rtwdev, RTW_SEC_CMD_REG, command);
|
||||
}
|
||||
}
|
||||
|
||||
void rtw_sec_clear_cam(struct rtw_dev *rtwdev,
|
||||
struct rtw_sec_desc *sec,
|
||||
u8 hw_key_idx)
|
||||
{
|
||||
struct rtw_cam_entry *cam = &sec->cam_table[hw_key_idx];
|
||||
u32 write_cmd;
|
||||
u32 command;
|
||||
u32 addr;
|
||||
|
||||
clear_bit(hw_key_idx, sec->cam_map);
|
||||
cam->valid = false;
|
||||
cam->key = NULL;
|
||||
eth_zero_addr(cam->addr);
|
||||
|
||||
write_cmd = RTW_SEC_CMD_WRITE_ENABLE | RTW_SEC_CMD_POLLING;
|
||||
addr = hw_key_idx << RTW_SEC_CAM_ENTRY_SHIFT;
|
||||
command = write_cmd | addr;
|
||||
rtw_write32(rtwdev, RTW_SEC_WRITE_REG, 0);
|
||||
rtw_write32(rtwdev, RTW_SEC_CMD_REG, command);
|
||||
}
|
||||
|
||||
void rtw_sec_enable_sec_engine(struct rtw_dev *rtwdev)
|
||||
{
|
||||
struct rtw_sec_desc *sec = &rtwdev->sec;
|
||||
u16 ctrl_reg;
|
||||
u16 sec_config;
|
||||
|
||||
/* default use default key search for now */
|
||||
sec->default_key_search = true;
|
||||
|
||||
ctrl_reg = rtw_read16(rtwdev, REG_CR);
|
||||
ctrl_reg |= RTW_SEC_ENGINE_EN;
|
||||
rtw_write16(rtwdev, REG_CR, ctrl_reg);
|
||||
|
||||
sec_config = rtw_read16(rtwdev, RTW_SEC_CONFIG);
|
||||
|
||||
sec_config |= RTW_SEC_TX_DEC_EN | RTW_SEC_RX_DEC_EN;
|
||||
if (sec->default_key_search)
|
||||
sec_config |= RTW_SEC_TX_UNI_USE_DK | RTW_SEC_RX_UNI_USE_DK |
|
||||
RTW_SEC_TX_BC_USE_DK | RTW_SEC_RX_BC_USE_DK;
|
||||
|
||||
rtw_write16(rtwdev, RTW_SEC_CONFIG, sec_config);
|
||||
}
|
39
drivers/net/wireless/realtek/rtw88/sec.h
Normal file
39
drivers/net/wireless/realtek/rtw88/sec.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_SEC_H_
|
||||
#define __RTW_SEC_H_
|
||||
|
||||
#define RTW_SEC_CMD_REG 0x670
|
||||
#define RTW_SEC_WRITE_REG 0x674
|
||||
#define RTW_SEC_READ_REG 0x678
|
||||
#define RTW_SEC_CONFIG 0x680
|
||||
|
||||
#define RTW_SEC_CAM_ENTRY_SHIFT 3
|
||||
#define RTW_SEC_DEFAULT_KEY_NUM 4
|
||||
#define RTW_SEC_CMD_WRITE_ENABLE BIT(16)
|
||||
#define RTW_SEC_CMD_CLEAR BIT(30)
|
||||
#define RTW_SEC_CMD_POLLING BIT(31)
|
||||
|
||||
#define RTW_SEC_TX_UNI_USE_DK BIT(0)
|
||||
#define RTW_SEC_RX_UNI_USE_DK BIT(1)
|
||||
#define RTW_SEC_TX_DEC_EN BIT(2)
|
||||
#define RTW_SEC_RX_DEC_EN BIT(3)
|
||||
#define RTW_SEC_TX_BC_USE_DK BIT(6)
|
||||
#define RTW_SEC_RX_BC_USE_DK BIT(7)
|
||||
|
||||
#define RTW_SEC_ENGINE_EN BIT(9)
|
||||
|
||||
int rtw_sec_get_free_cam(struct rtw_sec_desc *sec);
|
||||
void rtw_sec_write_cam(struct rtw_dev *rtwdev,
|
||||
struct rtw_sec_desc *sec,
|
||||
struct ieee80211_sta *sta,
|
||||
struct ieee80211_key_conf *key,
|
||||
u8 hw_key_type, u8 hw_key_idx);
|
||||
void rtw_sec_clear_cam(struct rtw_dev *rtwdev,
|
||||
struct rtw_sec_desc *sec,
|
||||
u8 hw_key_idx);
|
||||
void rtw_sec_enable_sec_engine(struct rtw_dev *rtwdev);
|
||||
|
||||
#endif
|
367
drivers/net/wireless/realtek/rtw88/tx.c
Normal file
367
drivers/net/wireless/realtek/rtw88/tx.c
Normal file
|
@ -0,0 +1,367 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "tx.h"
|
||||
#include "fw.h"
|
||||
#include "ps.h"
|
||||
|
||||
static
|
||||
void rtw_tx_stats(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct ieee80211_hdr *hdr;
|
||||
struct rtw_vif *rtwvif;
|
||||
|
||||
hdr = (struct ieee80211_hdr *)skb->data;
|
||||
|
||||
if (!ieee80211_is_data(hdr->frame_control))
|
||||
return;
|
||||
|
||||
if (!is_broadcast_ether_addr(hdr->addr1) &&
|
||||
!is_multicast_ether_addr(hdr->addr1)) {
|
||||
rtwdev->stats.tx_unicast += skb->len;
|
||||
rtwdev->stats.tx_cnt++;
|
||||
if (vif) {
|
||||
rtwvif = (struct rtw_vif *)vif->drv_priv;
|
||||
rtwvif->stats.tx_unicast += skb->len;
|
||||
rtwvif->stats.tx_cnt++;
|
||||
if (rtwvif->stats.tx_cnt > RTW_LPS_THRESHOLD)
|
||||
rtw_leave_lps_irqsafe(rtwdev, rtwvif);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rtw_tx_fill_tx_desc(struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb)
|
||||
{
|
||||
__le32 *txdesc = (__le32 *)skb->data;
|
||||
|
||||
SET_TX_DESC_TXPKTSIZE(txdesc, pkt_info->tx_pkt_size);
|
||||
SET_TX_DESC_OFFSET(txdesc, pkt_info->offset);
|
||||
SET_TX_DESC_PKT_OFFSET(txdesc, pkt_info->pkt_offset);
|
||||
SET_TX_DESC_QSEL(txdesc, pkt_info->qsel);
|
||||
SET_TX_DESC_BMC(txdesc, pkt_info->bmc);
|
||||
SET_TX_DESC_RATE_ID(txdesc, pkt_info->rate_id);
|
||||
SET_TX_DESC_DATARATE(txdesc, pkt_info->rate);
|
||||
SET_TX_DESC_DISDATAFB(txdesc, pkt_info->dis_rate_fallback);
|
||||
SET_TX_DESC_USE_RATE(txdesc, pkt_info->use_rate);
|
||||
SET_TX_DESC_SEC_TYPE(txdesc, pkt_info->sec_type);
|
||||
SET_TX_DESC_DATA_BW(txdesc, pkt_info->bw);
|
||||
SET_TX_DESC_SW_SEQ(txdesc, pkt_info->seq);
|
||||
SET_TX_DESC_MAX_AGG_NUM(txdesc, pkt_info->ampdu_factor);
|
||||
SET_TX_DESC_AMPDU_DENSITY(txdesc, pkt_info->ampdu_density);
|
||||
SET_TX_DESC_DATA_STBC(txdesc, pkt_info->stbc);
|
||||
SET_TX_DESC_DATA_LDPC(txdesc, pkt_info->ldpc);
|
||||
SET_TX_DESC_AGG_EN(txdesc, pkt_info->ampdu_en);
|
||||
SET_TX_DESC_LS(txdesc, pkt_info->ls);
|
||||
SET_TX_DESC_DATA_SHORT(txdesc, pkt_info->short_gi);
|
||||
SET_TX_DESC_SPE_RPT(txdesc, pkt_info->report);
|
||||
SET_TX_DESC_SW_DEFINE(txdesc, pkt_info->sn);
|
||||
}
|
||||
EXPORT_SYMBOL(rtw_tx_fill_tx_desc);
|
||||
|
||||
static u8 get_tx_ampdu_factor(struct ieee80211_sta *sta)
|
||||
{
|
||||
u8 exp = sta->ht_cap.ampdu_factor;
|
||||
|
||||
/* the least ampdu factor is 8K, and the value in the tx desc is the
|
||||
* max aggregation num, which represents val * 2 packets can be
|
||||
* aggregated in an AMPDU, so here we should use 8/2=4 as the base
|
||||
*/
|
||||
return (BIT(2) << exp) - 1;
|
||||
}
|
||||
|
||||
static u8 get_tx_ampdu_density(struct ieee80211_sta *sta)
|
||||
{
|
||||
return sta->ht_cap.ampdu_density;
|
||||
}
|
||||
|
||||
static u8 get_highest_ht_tx_rate(struct rtw_dev *rtwdev,
|
||||
struct ieee80211_sta *sta)
|
||||
{
|
||||
u8 rate;
|
||||
|
||||
if (rtwdev->hal.rf_type == RF_2T2R && sta->ht_cap.mcs.rx_mask[1] != 0)
|
||||
rate = DESC_RATEMCS15;
|
||||
else
|
||||
rate = DESC_RATEMCS7;
|
||||
|
||||
return rate;
|
||||
}
|
||||
|
||||
static u8 get_highest_vht_tx_rate(struct rtw_dev *rtwdev,
|
||||
struct ieee80211_sta *sta)
|
||||
{
|
||||
struct rtw_efuse *efuse = &rtwdev->efuse;
|
||||
u8 rate;
|
||||
u16 tx_mcs_map;
|
||||
|
||||
tx_mcs_map = le16_to_cpu(sta->vht_cap.vht_mcs.tx_mcs_map);
|
||||
if (efuse->hw_cap.nss == 1) {
|
||||
switch (tx_mcs_map & 0x3) {
|
||||
case IEEE80211_VHT_MCS_SUPPORT_0_7:
|
||||
rate = DESC_RATEVHT1SS_MCS7;
|
||||
break;
|
||||
case IEEE80211_VHT_MCS_SUPPORT_0_8:
|
||||
rate = DESC_RATEVHT1SS_MCS8;
|
||||
break;
|
||||
default:
|
||||
case IEEE80211_VHT_MCS_SUPPORT_0_9:
|
||||
rate = DESC_RATEVHT1SS_MCS9;
|
||||
break;
|
||||
}
|
||||
} else if (efuse->hw_cap.nss >= 2) {
|
||||
switch ((tx_mcs_map & 0xc) >> 2) {
|
||||
case IEEE80211_VHT_MCS_SUPPORT_0_7:
|
||||
rate = DESC_RATEVHT2SS_MCS7;
|
||||
break;
|
||||
case IEEE80211_VHT_MCS_SUPPORT_0_8:
|
||||
rate = DESC_RATEVHT2SS_MCS8;
|
||||
break;
|
||||
default:
|
||||
case IEEE80211_VHT_MCS_SUPPORT_0_9:
|
||||
rate = DESC_RATEVHT2SS_MCS9;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
rate = DESC_RATEVHT1SS_MCS9;
|
||||
}
|
||||
|
||||
return rate;
|
||||
}
|
||||
|
||||
static void rtw_tx_report_enable(struct rtw_dev *rtwdev,
|
||||
struct rtw_tx_pkt_info *pkt_info)
|
||||
{
|
||||
struct rtw_tx_report *tx_report = &rtwdev->tx_report;
|
||||
|
||||
/* [11:8], reserved, fills with zero
|
||||
* [7:2], tx report sequence number
|
||||
* [1:0], firmware use, fills with zero
|
||||
*/
|
||||
pkt_info->sn = (atomic_inc_return(&tx_report->sn) << 2) & 0xfc;
|
||||
pkt_info->report = true;
|
||||
}
|
||||
|
||||
void rtw_tx_report_purge_timer(struct timer_list *t)
|
||||
{
|
||||
struct rtw_dev *rtwdev = from_timer(rtwdev, t, tx_report.purge_timer);
|
||||
struct rtw_tx_report *tx_report = &rtwdev->tx_report;
|
||||
unsigned long flags;
|
||||
|
||||
if (skb_queue_len(&tx_report->queue) == 0)
|
||||
return;
|
||||
|
||||
WARN(1, "purge skb(s) not reported by firmware\n");
|
||||
|
||||
spin_lock_irqsave(&tx_report->q_lock, flags);
|
||||
skb_queue_purge(&tx_report->queue);
|
||||
spin_unlock_irqrestore(&tx_report->q_lock, flags);
|
||||
}
|
||||
|
||||
void rtw_tx_report_enqueue(struct rtw_dev *rtwdev, struct sk_buff *skb, u8 sn)
|
||||
{
|
||||
struct rtw_tx_report *tx_report = &rtwdev->tx_report;
|
||||
unsigned long flags;
|
||||
u8 *drv_data;
|
||||
|
||||
/* pass sn to tx report handler through driver data */
|
||||
drv_data = (u8 *)IEEE80211_SKB_CB(skb)->status.status_driver_data;
|
||||
*drv_data = sn;
|
||||
|
||||
spin_lock_irqsave(&tx_report->q_lock, flags);
|
||||
__skb_queue_tail(&tx_report->queue, skb);
|
||||
spin_unlock_irqrestore(&tx_report->q_lock, flags);
|
||||
|
||||
mod_timer(&tx_report->purge_timer, jiffies + RTW_TX_PROBE_TIMEOUT);
|
||||
}
|
||||
EXPORT_SYMBOL(rtw_tx_report_enqueue);
|
||||
|
||||
static void rtw_tx_report_tx_status(struct rtw_dev *rtwdev,
|
||||
struct sk_buff *skb, bool acked)
|
||||
{
|
||||
struct ieee80211_tx_info *info;
|
||||
|
||||
info = IEEE80211_SKB_CB(skb);
|
||||
ieee80211_tx_info_clear_status(info);
|
||||
if (acked)
|
||||
info->flags |= IEEE80211_TX_STAT_ACK;
|
||||
else
|
||||
info->flags &= ~IEEE80211_TX_STAT_ACK;
|
||||
|
||||
ieee80211_tx_status_irqsafe(rtwdev->hw, skb);
|
||||
}
|
||||
|
||||
void rtw_tx_report_handle(struct rtw_dev *rtwdev, struct sk_buff *skb)
|
||||
{
|
||||
struct rtw_tx_report *tx_report = &rtwdev->tx_report;
|
||||
struct rtw_c2h_cmd *c2h;
|
||||
struct sk_buff *cur, *tmp;
|
||||
unsigned long flags;
|
||||
u8 sn, st;
|
||||
u8 *n;
|
||||
|
||||
c2h = get_c2h_from_skb(skb);
|
||||
|
||||
sn = GET_CCX_REPORT_SEQNUM(c2h->payload);
|
||||
st = GET_CCX_REPORT_STATUS(c2h->payload);
|
||||
|
||||
spin_lock_irqsave(&tx_report->q_lock, flags);
|
||||
skb_queue_walk_safe(&tx_report->queue, cur, tmp) {
|
||||
n = (u8 *)IEEE80211_SKB_CB(cur)->status.status_driver_data;
|
||||
if (*n == sn) {
|
||||
__skb_unlink(cur, &tx_report->queue);
|
||||
rtw_tx_report_tx_status(rtwdev, cur, st == 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&tx_report->q_lock, flags);
|
||||
}
|
||||
|
||||
static void rtw_tx_mgmt_pkt_info_update(struct rtw_dev *rtwdev,
|
||||
struct rtw_tx_pkt_info *pkt_info,
|
||||
struct ieee80211_tx_control *control,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
pkt_info->use_rate = true;
|
||||
pkt_info->rate_id = 6;
|
||||
pkt_info->dis_rate_fallback = true;
|
||||
}
|
||||
|
||||
static void rtw_tx_data_pkt_info_update(struct rtw_dev *rtwdev,
|
||||
struct rtw_tx_pkt_info *pkt_info,
|
||||
struct ieee80211_tx_control *control,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct ieee80211_sta *sta = control->sta;
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
|
||||
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
|
||||
struct rtw_sta_info *si;
|
||||
u16 seq;
|
||||
u8 ampdu_factor = 0;
|
||||
u8 ampdu_density = 0;
|
||||
bool ampdu_en = false;
|
||||
u8 rate = DESC_RATE6M;
|
||||
u8 rate_id = 6;
|
||||
u8 bw = RTW_CHANNEL_WIDTH_20;
|
||||
bool stbc = false;
|
||||
bool ldpc = false;
|
||||
|
||||
seq = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
|
||||
|
||||
/* for broadcast/multicast, use default values */
|
||||
if (!sta)
|
||||
goto out;
|
||||
|
||||
if (info->flags & IEEE80211_TX_CTL_AMPDU) {
|
||||
ampdu_en = true;
|
||||
ampdu_factor = get_tx_ampdu_factor(sta);
|
||||
ampdu_density = get_tx_ampdu_density(sta);
|
||||
}
|
||||
|
||||
if (sta->vht_cap.vht_supported)
|
||||
rate = get_highest_vht_tx_rate(rtwdev, sta);
|
||||
else if (sta->ht_cap.ht_supported)
|
||||
rate = get_highest_ht_tx_rate(rtwdev, sta);
|
||||
else if (sta->supp_rates[0] <= 0xf)
|
||||
rate = DESC_RATE11M;
|
||||
else
|
||||
rate = DESC_RATE54M;
|
||||
|
||||
si = (struct rtw_sta_info *)sta->drv_priv;
|
||||
|
||||
bw = si->bw_mode;
|
||||
rate_id = si->rate_id;
|
||||
stbc = si->stbc_en;
|
||||
ldpc = si->ldpc_en;
|
||||
|
||||
out:
|
||||
pkt_info->seq = seq;
|
||||
pkt_info->ampdu_factor = ampdu_factor;
|
||||
pkt_info->ampdu_density = ampdu_density;
|
||||
pkt_info->ampdu_en = ampdu_en;
|
||||
pkt_info->rate = rate;
|
||||
pkt_info->rate_id = rate_id;
|
||||
pkt_info->bw = bw;
|
||||
pkt_info->stbc = stbc;
|
||||
pkt_info->ldpc = ldpc;
|
||||
}
|
||||
|
||||
void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev,
|
||||
struct rtw_tx_pkt_info *pkt_info,
|
||||
struct ieee80211_tx_control *control,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
|
||||
struct rtw_sta_info *si;
|
||||
struct ieee80211_vif *vif = NULL;
|
||||
__le16 fc = hdr->frame_control;
|
||||
u8 sec_type = 0;
|
||||
bool bmc;
|
||||
|
||||
if (control->sta) {
|
||||
si = (struct rtw_sta_info *)control->sta->drv_priv;
|
||||
vif = si->vif;
|
||||
}
|
||||
|
||||
if (ieee80211_is_mgmt(fc) || ieee80211_is_nullfunc(fc))
|
||||
rtw_tx_mgmt_pkt_info_update(rtwdev, pkt_info, control, skb);
|
||||
else if (ieee80211_is_data(fc))
|
||||
rtw_tx_data_pkt_info_update(rtwdev, pkt_info, control, skb);
|
||||
|
||||
if (info->control.hw_key) {
|
||||
struct ieee80211_key_conf *key = info->control.hw_key;
|
||||
|
||||
switch (key->cipher) {
|
||||
case WLAN_CIPHER_SUITE_WEP40:
|
||||
case WLAN_CIPHER_SUITE_WEP104:
|
||||
case WLAN_CIPHER_SUITE_TKIP:
|
||||
sec_type = 0x01;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
sec_type = 0x03;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bmc = is_broadcast_ether_addr(hdr->addr1) ||
|
||||
is_multicast_ether_addr(hdr->addr1);
|
||||
|
||||
if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)
|
||||
rtw_tx_report_enable(rtwdev, pkt_info);
|
||||
|
||||
pkt_info->bmc = bmc;
|
||||
pkt_info->sec_type = sec_type;
|
||||
pkt_info->tx_pkt_size = skb->len;
|
||||
pkt_info->offset = chip->tx_pkt_desc_sz;
|
||||
pkt_info->qsel = skb->priority;
|
||||
pkt_info->ls = true;
|
||||
|
||||
/* maybe merge with tx status ? */
|
||||
rtw_tx_stats(rtwdev, vif, skb);
|
||||
}
|
||||
|
||||
void rtw_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,
|
||||
struct rtw_tx_pkt_info *pkt_info,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct rtw_chip_info *chip = rtwdev->chip;
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
|
||||
bool bmc;
|
||||
|
||||
bmc = is_broadcast_ether_addr(hdr->addr1) ||
|
||||
is_multicast_ether_addr(hdr->addr1);
|
||||
pkt_info->use_rate = true;
|
||||
pkt_info->rate_id = 6;
|
||||
pkt_info->dis_rate_fallback = true;
|
||||
pkt_info->bmc = bmc;
|
||||
pkt_info->tx_pkt_size = skb->len;
|
||||
pkt_info->offset = chip->tx_pkt_desc_sz;
|
||||
pkt_info->qsel = skb->priority;
|
||||
pkt_info->ls = true;
|
||||
}
|
89
drivers/net/wireless/realtek/rtw88/tx.h
Normal file
89
drivers/net/wireless/realtek/rtw88/tx.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_TX_H_
|
||||
#define __RTW_TX_H_
|
||||
|
||||
#define RTK_TX_MAX_AGG_NUM_MASK 0x1f
|
||||
|
||||
#define RTW_TX_PROBE_TIMEOUT msecs_to_jiffies(500)
|
||||
|
||||
#define SET_TX_DESC_TXPKTSIZE(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x00, value, GENMASK(15, 0))
|
||||
#define SET_TX_DESC_OFFSET(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x00, value, GENMASK(23, 16))
|
||||
#define SET_TX_DESC_PKT_OFFSET(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x01, value, GENMASK(28, 24))
|
||||
#define SET_TX_DESC_QSEL(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x01, value, GENMASK(12, 8))
|
||||
#define SET_TX_DESC_BMC(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x00, value, BIT(24))
|
||||
#define SET_TX_DESC_RATE_ID(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x01, value, GENMASK(20, 16))
|
||||
#define SET_TX_DESC_DATARATE(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x04, value, GENMASK(6, 0))
|
||||
#define SET_TX_DESC_DISDATAFB(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, BIT(10))
|
||||
#define SET_TX_DESC_USE_RATE(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, BIT(8))
|
||||
#define SET_TX_DESC_SEC_TYPE(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x01, value, GENMASK(23, 22))
|
||||
#define SET_TX_DESC_DATA_BW(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x05, value, GENMASK(6, 5))
|
||||
#define SET_TX_DESC_SW_SEQ(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x09, value, GENMASK(23, 12))
|
||||
#define SET_TX_DESC_MAX_AGG_NUM(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, GENMASK(21, 17))
|
||||
#define SET_TX_DESC_AMPDU_DENSITY(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x02, value, GENMASK(22, 20))
|
||||
#define SET_TX_DESC_DATA_STBC(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x05, value, GENMASK(9, 8))
|
||||
#define SET_TX_DESC_DATA_LDPC(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x05, value, BIT(7))
|
||||
#define SET_TX_DESC_AGG_EN(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x02, value, BIT(12))
|
||||
#define SET_TX_DESC_LS(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x00, value, BIT(26))
|
||||
#define SET_TX_DESC_DATA_SHORT(txdesc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x05, value, BIT(4))
|
||||
#define SET_TX_DESC_SPE_RPT(tx_desc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x02, value, BIT(19))
|
||||
#define SET_TX_DESC_SW_DEFINE(tx_desc, value) \
|
||||
le32p_replace_bits((__le32 *)(txdesc) + 0x06, value, GENMASK(11, 0))
|
||||
|
||||
enum rtw_tx_desc_queue_select {
|
||||
TX_DESC_QSEL_TID0 = 0,
|
||||
TX_DESC_QSEL_TID1 = 1,
|
||||
TX_DESC_QSEL_TID2 = 2,
|
||||
TX_DESC_QSEL_TID3 = 3,
|
||||
TX_DESC_QSEL_TID4 = 4,
|
||||
TX_DESC_QSEL_TID5 = 5,
|
||||
TX_DESC_QSEL_TID6 = 6,
|
||||
TX_DESC_QSEL_TID7 = 7,
|
||||
TX_DESC_QSEL_TID8 = 8,
|
||||
TX_DESC_QSEL_TID9 = 9,
|
||||
TX_DESC_QSEL_TID10 = 10,
|
||||
TX_DESC_QSEL_TID11 = 11,
|
||||
TX_DESC_QSEL_TID12 = 12,
|
||||
TX_DESC_QSEL_TID13 = 13,
|
||||
TX_DESC_QSEL_TID14 = 14,
|
||||
TX_DESC_QSEL_TID15 = 15,
|
||||
TX_DESC_QSEL_BEACON = 16,
|
||||
TX_DESC_QSEL_HIGH = 17,
|
||||
TX_DESC_QSEL_MGMT = 18,
|
||||
TX_DESC_QSEL_H2C = 19,
|
||||
};
|
||||
|
||||
void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev,
|
||||
struct rtw_tx_pkt_info *pkt_info,
|
||||
struct ieee80211_tx_control *control,
|
||||
struct sk_buff *skb);
|
||||
void rtw_tx_fill_tx_desc(struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb);
|
||||
void rtw_tx_report_enqueue(struct rtw_dev *rtwdev, struct sk_buff *skb, u8 sn);
|
||||
void rtw_tx_report_handle(struct rtw_dev *rtwdev, struct sk_buff *skb);
|
||||
void rtw_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,
|
||||
struct rtw_tx_pkt_info *pkt_info,
|
||||
struct sk_buff *skb);
|
||||
|
||||
#endif
|
72
drivers/net/wireless/realtek/rtw88/util.c
Normal file
72
drivers/net/wireless/realtek/rtw88/util.c
Normal file
|
@ -0,0 +1,72 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "util.h"
|
||||
#include "reg.h"
|
||||
|
||||
bool check_hw_ready(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 target)
|
||||
{
|
||||
u32 cnt;
|
||||
|
||||
for (cnt = 0; cnt < 1000; cnt++) {
|
||||
if (rtw_read32_mask(rtwdev, addr, mask) == target)
|
||||
return true;
|
||||
|
||||
udelay(10);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ltecoex_read_reg(struct rtw_dev *rtwdev, u16 offset, u32 *val)
|
||||
{
|
||||
if (!check_hw_ready(rtwdev, LTECOEX_ACCESS_CTRL, LTECOEX_READY, 1))
|
||||
return false;
|
||||
|
||||
rtw_write32(rtwdev, LTECOEX_ACCESS_CTRL, 0x800F0000 | offset);
|
||||
*val = rtw_read32(rtwdev, LTECOEX_READ_DATA);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ltecoex_reg_write(struct rtw_dev *rtwdev, u16 offset, u32 value)
|
||||
{
|
||||
if (!check_hw_ready(rtwdev, LTECOEX_ACCESS_CTRL, LTECOEX_READY, 1))
|
||||
return false;
|
||||
|
||||
rtw_write32(rtwdev, LTECOEX_WRITE_DATA, value);
|
||||
rtw_write32(rtwdev, LTECOEX_ACCESS_CTRL, 0xC00F0000 | offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void rtw_restore_reg(struct rtw_dev *rtwdev,
|
||||
struct rtw_backup_info *bckp, u32 num)
|
||||
{
|
||||
u8 len;
|
||||
u32 reg;
|
||||
u32 val;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num; i++, bckp++) {
|
||||
len = bckp->len;
|
||||
reg = bckp->reg;
|
||||
val = bckp->val;
|
||||
|
||||
switch (len) {
|
||||
case 1:
|
||||
rtw_write8(rtwdev, reg, (u8)val);
|
||||
break;
|
||||
case 2:
|
||||
rtw_write16(rtwdev, reg, (u16)val);
|
||||
break;
|
||||
case 4:
|
||||
rtw_write32(rtwdev, reg, (u32)val);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
34
drivers/net/wireless/realtek/rtw88/util.h
Normal file
34
drivers/net/wireless/realtek/rtw88/util.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/* Copyright(c) 2018-2019 Realtek Corporation
|
||||
*/
|
||||
|
||||
#ifndef __RTW_UTIL_H__
|
||||
#define __RTW_UTIL_H__
|
||||
|
||||
struct rtw_dev;
|
||||
|
||||
#define rtw_iterate_vifs(rtwdev, iterator, data) \
|
||||
ieee80211_iterate_active_interfaces(rtwdev->hw, \
|
||||
IEEE80211_IFACE_ITER_NORMAL, iterator, data)
|
||||
#define rtw_iterate_vifs_atomic(rtwdev, iterator, data) \
|
||||
ieee80211_iterate_active_interfaces_atomic(rtwdev->hw, \
|
||||
IEEE80211_IFACE_ITER_NORMAL, iterator, data)
|
||||
#define rtw_iterate_stas_atomic(rtwdev, iterator, data) \
|
||||
ieee80211_iterate_stations_atomic(rtwdev->hw, iterator, data)
|
||||
|
||||
static inline u8 *get_hdr_bssid(struct ieee80211_hdr *hdr)
|
||||
{
|
||||
__le16 fc = hdr->frame_control;
|
||||
u8 *bssid;
|
||||
|
||||
if (ieee80211_has_tods(fc))
|
||||
bssid = hdr->addr1;
|
||||
else if (ieee80211_has_fromds(fc))
|
||||
bssid = hdr->addr2;
|
||||
else
|
||||
bssid = hdr->addr3;
|
||||
|
||||
return bssid;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue