Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 938a0447 authored by Ping-Ke Shih's avatar Ping-Ke Shih Committed by Greg Kroah-Hartman
Browse files

staging: r8822be: Add code for halmac sub-driver



The RTL8822BE, an 802.11ac wireless network card, is now appearing in
new computers. Its driver is being placed in staging to reduce the time
that users of this new card will have access to in-kernel drivers.

New Realtek devices implement a common sub-driver to control the MAC
layer. The RTL8822BE is the first of these devices, thus its introduction
involves some extra code. In the wireless tree, this will be a separate
module; however, it is compiled into the 8822be driver here.

Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Cc: Yan-Hsuan Chuang <yhchuang@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b53b764b
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 * Copyright(c) 2016  Realtek Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
 * wlanfae <wlanfae@realtek.com>
 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
 * Hsinchu 300, Taiwan.
 *
 * Larry Finger <Larry.Finger@lwfinger.net>
 *
 *****************************************************************************/
#ifndef _HALMAC_2_PLATFORM_H_
#define _HALMAC_2_PLATFORM_H_

#include "../wifi.h"
#include <asm/byteorder.h>

#define HALMAC_PLATFORM_LITTLE_ENDIAN 1
#define HALMAC_PLATFORM_BIG_ENDIAN 0

/* Note : Named HALMAC_PLATFORM_LITTLE_ENDIAN / HALMAC_PLATFORM_BIG_ENDIAN
 * is not mandatory. But Little endian must be '1'. Big endian must be '0'
 */
#if defined(__LITTLE_ENDIAN)
#define HALMAC_SYSTEM_ENDIAN HALMAC_PLATFORM_LITTLE_ENDIAN
#elif defined(__BIG_ENDIAN)
#define HALMAC_SYSTEM_ENDIAN HALMAC_PLATFORM_BIG_ENDIAN
#else
#error
#endif

/* define the Platform SDIO Bus CLK */
#define PLATFORM_SD_CLK 50000000 /*50MHz*/

/* define the Rx FIFO expanding mode packet size unit for 8821C and 8822B */
/* Should be 8 Byte alignment */
#define HALMAC_RX_FIFO_EXPANDING_MODE_PKT_SIZE 16 /*Bytes*/

#endif /* _HALMAC_2_PLATFORM_H_ */
+132 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 * Copyright(c) 2016  Realtek Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
 * wlanfae <wlanfae@realtek.com>
 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
 * Hsinchu 300, Taiwan.
 *
 * Larry Finger <Larry.Finger@lwfinger.net>
 *
 *****************************************************************************/
#ifndef _HALMAC_8822B_CFG_H_
#define _HALMAC_8822B_CFG_H_

#include "halmac_8822b_pwr_seq.h"
#include "halmac_api_8822b.h"
#include "halmac_api_8822b_usb.h"
#include "halmac_api_8822b_sdio.h"
#include "halmac_api_8822b_pcie.h"
#include "../../halmac_bit2.h"
#include "../../halmac_reg2.h"
#include "../../halmac_api.h"

#define HALMAC_TX_FIFO_SIZE_8822B 262144 /* 256k */
#define HALMAC_TX_FIFO_SIZE_LA_8822B 131072 /* 128k */
#define HALMAC_RX_FIFO_SIZE_8822B 24576 /* 24k */
#define HALMAC_TX_PAGE_SIZE_8822B 128 /* PageSize 128Byte */
#define HALMAC_TX_ALIGN_SIZE_8822B 8
#define HALMAC_TX_PAGE_SIZE_2_POWER_8822B 7 /* 128 = 2^7 */
#define HALMAC_SECURITY_CAM_ENTRY_NUM_8822B 64 /* CAM Entry size */
#define HALMAC_TX_AGG_ALIGNMENT_SIZE_8822B 8
#define HALMAC_TX_DESC_SIZE_8822B 48
#define HALMAC_RX_DESC_SIZE_8822B 24
#define HALMAC_RX_DESC_DUMMY_SIZE_MAX_8822B 120
#define HALMAC_C2H_PKT_BUF_8822B 256
#define HALMAC_RX_FIFO_EXPANDING_MODE_PKT_SIZE_MAX_8822B 80 /* align 8 Byte*/
#define HALMAC_RX_FIFO_EXPANDING_UNIT_8822B                                    \
	(HALMAC_RX_DESC_SIZE_8822B + HALMAC_RX_DESC_DUMMY_SIZE_MAX_8822B +     \
	 HALMAC_RX_FIFO_EXPANDING_MODE_PKT_SIZE) /* align 8 Byte*/
#define HALMAC_RX_FIFO_EXPANDING_UNIT_MAX_8822B                                \
	(HALMAC_RX_DESC_SIZE_8822B + HALMAC_RX_DESC_DUMMY_SIZE_MAX_8822B +     \
	 HALMAC_RX_FIFO_EXPANDING_MODE_PKT_SIZE_MAX_8822B) /* align 8 Byte*/

#define HALMAC_TX_FIFO_SIZE_EX_1_BLK_8822B 196608 /* 192k */
#define HALMAC_RX_FIFO_SIZE_EX_1_BLK_8822B                                     \
	((((HALMAC_RX_FIFO_EXPANDING_UNIT_8822B << 8) - 1) >> 10)              \
	 << 10) /* < 56k*/
#define HALMAC_RX_FIFO_SIZE_EX_1_BLK_MAX_8822B                                 \
	((((HALMAC_RX_FIFO_EXPANDING_UNIT_MAX_8822B << 8) - 1) >> 10)          \
	 << 10) /* 55k*/
#define HALMAC_TX_FIFO_SIZE_EX_2_BLK_8822B 131072 /* 128k */
#define HALMAC_RX_FIFO_SIZE_EX_2_BLK_8822B 155648 /* 152k */
#define HALMAC_TX_FIFO_SIZE_EX_3_BLK_8822B 65536 /* 64k */
#define HALMAC_RX_FIFO_SIZE_EX_3_BLK_8822B 221184 /* 216k */

/* TXFIFO LAYOUT
 * HIGH_QUEUE
 * NORMAL_QUEUE
 * LOW_QUEUE
 * EXTRA_QUEUE
 * PUBLIC_QUEUE -- decided after all other queue are defined
 * GAP_QUEUE -- Used to separate AC queue and Rsvd page
 *
 * RSVD_DRIVER -- Driver used rsvd page area
 * RSVD_H2C_EXTRAINFO -- Extra Information for h2c
 * RSVD_H2C_QUEUE -- h2c queue in rsvd page
 * RSVD_CPU_INSTRUCTION -- extend fw code
 * RSVD_FW_TXBUFF -- fw used this area to send packet
 *
 * Symbol: HALMAC_MODE_QUEUE_UNIT_CHIP, ex: HALMAC_LB_2BULKOUT_FWCMD_PGNUM_8822B
 */
#define HALMAC_EXTRA_INFO_BUFF_SIZE_FULL_FIFO_8822B                            \
	16384 /*16K, only used in init case*/

#define HALMAC_RSVD_DRV_PGNUM_8822B 16 /*2048*/
#define HALMAC_RSVD_H2C_EXTRAINFO_PGNUM_8822B 32 /*4096*/
#define HALMAC_RSVD_H2C_QUEUE_PGNUM_8822B 8 /*1024*/
#define HALMAC_RSVD_CPU_INSTRUCTION_PGNUM_8822B 0 /*0*/
#define HALMAC_RSVD_FW_TXBUFF_PGNUM_8822B 4 /*512*/

#define HALMAC_EFUSE_SIZE_8822B 1024 /* 0x400 */
#define HALMAC_BT_EFUSE_SIZE_8822B 128 /* 0x80 */
#define HALMAC_EEPROM_SIZE_8822B 0x300
#define HALMAC_CR_TRX_ENABLE_8822B                                             \
	(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 HALMAC_BLK_DESC_NUM_8822B 0x3 /* Only for USB */

/* AMPDU max time (unit : 32us) */
#define HALMAC_AMPDU_MAX_TIME_8822B 0x70

/* Protect mode control */
#define HALMAC_PROT_RTS_LEN_TH_8822B 0xFF
#define HALMAC_PROT_RTS_TX_TIME_TH_8822B 0x08
#define HALMAC_PROT_MAX_AGG_PKT_LIMIT_8822B 0x20
#define HALMAC_PROT_RTS_MAX_AGG_PKT_LIMIT_8822B 0x20

/* Fast EDCA setting */
#define HALMAC_FAST_EDCA_VO_TH_8822B 0x06
#define HALMAC_FAST_EDCA_VI_TH_8822B 0x06
#define HALMAC_FAST_EDCA_BE_TH_8822B 0x06
#define HALMAC_FAST_EDCA_BK_TH_8822B 0x06

/* BAR setting */
#define HALMAC_BAR_RETRY_LIMIT_8822B 0x01
#define HALMAC_RA_TRY_RATE_AGG_LIMIT_8822B 0x08

enum halmac_normal_rxagg_th_to_8822b {
	HALMAC_NORMAL_RXAGG_THRESHOLD_8822B = 0xFF,
	HALMAC_NORMAL_RXAGG_TIMEOUT_8822B = 0x01,
};

enum halmac_loopback_rxagg_th_to_8822b {
	HALMAC_LOOPBACK_RXAGG_THRESHOLD_8822B = 0xFF,
	HALMAC_LOOPBACK_RXAGG_TIMEOUT_8822B = 0x01,
};

#endif
+106 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 * Copyright(c) 2016  Realtek Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
 * wlanfae <wlanfae@realtek.com>
 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
 * Hsinchu 300, Taiwan.
 *
 * Larry Finger <Larry.Finger@lwfinger.net>
 *
 *****************************************************************************/
#include "../halmac_88xx_cfg.h"
#include "halmac_8822b_cfg.h"

/**
 * ============ip sel item list============
 * HALMAC_IP_SEL_INTF_PHY
 *	USB2 : usb2 phy, 1byte value
 *	USB3 : usb3 phy, 2byte value
 *	PCIE1 : pcie gen1 mdio, 2byte value
 *	PCIE2 : pcie gen2 mdio, 2byte value
 * HALMAC_IP_SEL_MAC
 *	USB2, USB3, PCIE1, PCIE2 : mac ip, 1byte value
 * HALMAC_IP_SEL_PCIE_DBI
 *	USB2 USB3 : none
 *	PCIE1, PCIE2 : pcie dbi, 1byte value
 */

struct halmac_intf_phy_para_ HALMAC_RTL8822B_USB2_PHY[] = {
	/* {offset, value, ip sel, cut mask, platform mask} */
	{0xFFFF, 0x00, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_ALL,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
};

struct halmac_intf_phy_para_ HALMAC_RTL8822B_USB3_PHY[] = {
	/* {offset, value, ip sel, cut mask, platform mask} */
	{0x0001, 0xA841, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_D,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0xFFFF, 0x0000, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_ALL,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
};

struct halmac_intf_phy_para_ HALMAC_RTL8822B_PCIE_PHY_GEN1[] = {
	/* {offset, value, ip sel, cut mask, platform mask} */
	{0x0001, 0xA841, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0002, 0x60C6, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0008, 0x3596, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0009, 0x321C, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x000A, 0x9623, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0020, 0x94FF, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0021, 0xFFCF, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0026, 0xC006, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0029, 0xFF0E, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x002A, 0x1840, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0xFFFF, 0x0000, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_ALL,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
};

struct halmac_intf_phy_para_ HALMAC_RTL8822B_PCIE_PHY_GEN2[] = {
	/* {offset, value, ip sel, cut mask, platform mask} */
	{0x0001, 0xA841, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0002, 0x60C6, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0008, 0x3597, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0009, 0x321C, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x000A, 0x9623, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0020, 0x94FF, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0021, 0xFFCF, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0026, 0xC006, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x0029, 0xFF0E, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0x002A, 0x3040, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_C,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
	{0xFFFF, 0x0000, HALMAC_IP_SEL_INTF_PHY, HALMAC_INTF_PHY_CUT_ALL,
	 HALMAC_INTF_PHY_PLATFORM_ALL},
};
+563 −0

File added.

Preview size limit exceeded, changes collapsed.

+40 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 * Copyright(c) 2016  Realtek Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
 * wlanfae <wlanfae@realtek.com>
 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
 * Hsinchu 300, Taiwan.
 *
 * Larry Finger <Larry.Finger@lwfinger.net>
 *
 *****************************************************************************/
#ifndef HALMAC_POWER_SEQUENCE_8822B
#define HALMAC_POWER_SEQUENCE_8822B

#include "../../halmac_pwr_seq_cmd.h"

#define HALMAC_8822B_PWR_SEQ_VER "V17"
extern struct halmac_wl_pwr_cfg_ *halmac_8822b_card_disable_flow[];
extern struct halmac_wl_pwr_cfg_ *halmac_8822b_card_enable_flow[];
extern struct halmac_wl_pwr_cfg_ *halmac_8822b_suspend_flow[];
extern struct halmac_wl_pwr_cfg_ *halmac_8822b_resume_flow[];
extern struct halmac_wl_pwr_cfg_ *halmac_8822b_hwpdn_flow[];
extern struct halmac_wl_pwr_cfg_ *halmac_8822b_enter_lps_flow[];
extern struct halmac_wl_pwr_cfg_ *halmac_8822b_enter_deep_lps_flow[];
extern struct halmac_wl_pwr_cfg_ *halmac_8822b_leave_lps_flow[];

#endif
Loading