RTL8852AU, RTL8852CU, and RTL8922AU will need a different TX channel
to bulk out endpoint mapping, so create a new struct rtw89_usb_info
and move the mapping there. Initialise it in each chip's driver.
Struct rtw89_usb_info will also hold some registers which are located
at different offsets in RTL8852CU compared to the other wifi 6 chips.
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/de11cfae-1dc0-4514-95b2-02b1bbfa92be@gmail.com
struct rtw89_dev;
struct rtw89_pci_info;
+struct rtw89_usb_info;
struct rtw89_mac_gen_def;
struct rtw89_phy_gen_def;
struct rtw89_fw_blacklist;
union rtw89_bus_info {
const struct rtw89_pci_info *pci;
+ const struct rtw89_usb_info *usb;
};
struct rtw89_driver_info {
#include "rtw8851b.h"
#include "usb.h"
+static const struct rtw89_usb_info rtw8851b_usb_info = {
+ .bulkout_id = {
+ [RTW89_DMA_ACH0] = 3,
+ [RTW89_DMA_ACH1] = 4,
+ [RTW89_DMA_ACH2] = 5,
+ [RTW89_DMA_ACH3] = 6,
+ [RTW89_DMA_B0MG] = 0,
+ [RTW89_DMA_B0HI] = 1,
+ [RTW89_DMA_H2C] = 2,
+ },
+};
+
static const struct rtw89_driver_info rtw89_8851bu_info = {
.chip = &rtw8851b_chip_info,
.variant = NULL,
.quirks = NULL,
+ .bus = {
+ .usb = &rtw8851b_usb_info,
+ }
};
static const struct usb_device_id rtw_8851bu_id_table[] = {
#include "rtw8852b.h"
#include "usb.h"
+static const struct rtw89_usb_info rtw8852b_usb_info = {
+ .bulkout_id = {
+ [RTW89_DMA_ACH0] = 3,
+ [RTW89_DMA_ACH1] = 4,
+ [RTW89_DMA_ACH2] = 5,
+ [RTW89_DMA_ACH3] = 6,
+ [RTW89_DMA_B0MG] = 0,
+ [RTW89_DMA_B0HI] = 1,
+ [RTW89_DMA_H2C] = 2,
+ },
+};
+
static const struct rtw89_driver_info rtw89_8852bu_info = {
.chip = &rtw8852b_chip_info,
.variant = NULL,
.quirks = NULL,
+ .bus = {
+ .usb = &rtw8852b_usb_info,
+ }
};
static const struct usb_device_id rtw_8852bu_id_table[] = {
return 42; /* TODO some kind of calculation? */
}
-static u8 rtw89_usb_get_bulkout_id(u8 ch_dma)
-{
- switch (ch_dma) {
- case RTW89_DMA_ACH0:
- return 3;
- case RTW89_DMA_ACH1:
- return 4;
- case RTW89_DMA_ACH2:
- return 5;
- case RTW89_DMA_ACH3:
- return 6;
- default:
- case RTW89_DMA_B0MG:
- return 0;
- case RTW89_DMA_B0HI:
- return 1;
- case RTW89_DMA_H2C:
- return 2;
- }
-}
-
static void rtw89_usb_write_port_complete(struct urb *urb)
{
struct rtw89_usb_tx_ctrl_block *txcb = urb->context;
void *data, int len, void *context)
{
struct rtw89_usb *rtwusb = rtw89_usb_priv(rtwdev);
+ const struct rtw89_usb_info *info = rtwusb->info;
struct usb_device *usbd = rtwusb->udev;
struct urb *urb;
- u8 bulkout_id = rtw89_usb_get_bulkout_id(ch_dma);
+ u8 bulkout_id = info->bulkout_id[ch_dma];
unsigned int pipe;
int ret;
rtwusb = rtw89_usb_priv(rtwdev);
rtwusb->rtwdev = rtwdev;
+ rtwusb->info = info->bus.usb;
rtwdev->hci.ops = &rtw89_usb_ops;
rtwdev->hci.type = RTW89_HCI_TYPE_USB;
#define RTW89_MAX_ENDPOINT_NUM 9
#define RTW89_MAX_BULKOUT_NUM 7
+struct rtw89_usb_info {
+ u8 bulkout_id[RTW89_DMA_CH_NUM];
+};
+
struct rtw89_usb_rx_ctrl_block {
struct rtw89_dev *rtwdev;
struct urb *rx_urb;
struct rtw89_usb {
struct rtw89_dev *rtwdev;
struct usb_device *udev;
+ const struct rtw89_usb_info *info;
__le32 *vendor_req_buf;