1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2014 - 2017 Jes Sorensen <Jes.Sorensen@gmail.com>
5 * Register definitions taken from original Realtek rtl8723au driver
8 #include <asm/byteorder.h>
10 #define RTL8XXXU_DEBUG_REG_WRITE 0x01
11 #define RTL8XXXU_DEBUG_REG_READ 0x02
12 #define RTL8XXXU_DEBUG_RFREG_WRITE 0x04
13 #define RTL8XXXU_DEBUG_RFREG_READ 0x08
14 #define RTL8XXXU_DEBUG_CHANNEL 0x10
15 #define RTL8XXXU_DEBUG_TX 0x20
16 #define RTL8XXXU_DEBUG_TX_DUMP 0x40
17 #define RTL8XXXU_DEBUG_RX 0x80
18 #define RTL8XXXU_DEBUG_RX_DUMP 0x100
19 #define RTL8XXXU_DEBUG_USB 0x200
20 #define RTL8XXXU_DEBUG_KEY 0x400
21 #define RTL8XXXU_DEBUG_H2C 0x800
22 #define RTL8XXXU_DEBUG_ACTION 0x1000
23 #define RTL8XXXU_DEBUG_EFUSE 0x2000
24 #define RTL8XXXU_DEBUG_INTERRUPT 0x4000
26 #define RTW_USB_CONTROL_MSG_TIMEOUT 500
27 #define RTL8XXXU_MAX_REG_POLL 500
28 #define USB_INTR_CONTENT_LENGTH 56
30 #define RTL8XXXU_OUT_ENDPOINTS 4
32 #define REALTEK_USB_READ 0xc0
33 #define REALTEK_USB_WRITE 0x40
34 #define REALTEK_USB_CMD_REQ 0x05
35 #define REALTEK_USB_CMD_IDX 0x00
37 #define TX_TOTAL_PAGE_NUM 0xf8
38 #define TX_TOTAL_PAGE_NUM_8192E 0xf3
39 #define TX_TOTAL_PAGE_NUM_8723B 0xf7
40 /* (HPQ + LPQ + NPQ + PUBQ) = TX_TOTAL_PAGE_NUM */
41 #define TX_PAGE_NUM_PUBQ 0xe7
42 #define TX_PAGE_NUM_HI_PQ 0x0c
43 #define TX_PAGE_NUM_LO_PQ 0x02
44 #define TX_PAGE_NUM_NORM_PQ 0x02
46 #define TX_PAGE_NUM_PUBQ_8192E 0xe7
47 #define TX_PAGE_NUM_HI_PQ_8192E 0x08
48 #define TX_PAGE_NUM_LO_PQ_8192E 0x0c
49 #define TX_PAGE_NUM_NORM_PQ_8192E 0x00
51 #define TX_PAGE_NUM_PUBQ_8723B 0xe7
52 #define TX_PAGE_NUM_HI_PQ_8723B 0x0c
53 #define TX_PAGE_NUM_LO_PQ_8723B 0x02
54 #define TX_PAGE_NUM_NORM_PQ_8723B 0x02
56 #define RTL_FW_PAGE_SIZE 4096
57 #define RTL8XXXU_FIRMWARE_POLL_MAX 1000
59 #define RTL8723A_CHANNEL_GROUPS 3
60 #define RTL8723A_MAX_RF_PATHS 2
61 #define RTL8723B_CHANNEL_GROUPS 6
62 #define RTL8723B_TX_COUNT 4
63 #define RTL8723B_MAX_RF_PATHS 4
64 #define RTL8XXXU_MAX_CHANNEL_GROUPS 6
65 #define RF6052_MAX_TX_PWR 0x3f
67 #define EFUSE_MAP_LEN 512
68 #define EFUSE_MAX_SECTION_8723A 64
69 #define EFUSE_REAL_CONTENT_LEN_8723A 512
70 #define EFUSE_BT_MAP_LEN_8723A 1024
71 #define EFUSE_MAX_WORD_UNIT 4
73 enum rtl8xxxu_rtl_chip
{
97 enum rtl8xxxu_rx_type
{
103 struct rtl8xxxu_rxdesc16
{
104 #ifdef __LITTLE_ENDIAN
241 struct rtl8xxxu_rxdesc24
{
242 #ifdef __LITTLE_ENDIAN
264 u32 a1fit
:4; /* 16 */
279 u32 rx_is_qos
:1; /* 16 */
292 u32 usb_agg_pktnum
:8; /* 16 */
348 u32 usb_agg_pktnum
:8;
349 u32 dummy3_1
:2; /* 16 */
366 struct rtl8xxxu_txdesc32
{
380 struct rtl8xxxu_txdesc40
{
396 /* CCK Rates, TxHT = 0 */
397 #define DESC_RATE_1M 0x00
398 #define DESC_RATE_2M 0x01
399 #define DESC_RATE_5_5M 0x02
400 #define DESC_RATE_11M 0x03
402 /* OFDM Rates, TxHT = 0 */
403 #define DESC_RATE_6M 0x04
404 #define DESC_RATE_9M 0x05
405 #define DESC_RATE_12M 0x06
406 #define DESC_RATE_18M 0x07
407 #define DESC_RATE_24M 0x08
408 #define DESC_RATE_36M 0x09
409 #define DESC_RATE_48M 0x0a
410 #define DESC_RATE_54M 0x0b
412 /* MCS Rates, TxHT = 1 */
413 #define DESC_RATE_MCS0 0x0c
414 #define DESC_RATE_MCS1 0x0d
415 #define DESC_RATE_MCS2 0x0e
416 #define DESC_RATE_MCS3 0x0f
417 #define DESC_RATE_MCS4 0x10
418 #define DESC_RATE_MCS5 0x11
419 #define DESC_RATE_MCS6 0x12
420 #define DESC_RATE_MCS7 0x13
421 #define DESC_RATE_MCS8 0x14
422 #define DESC_RATE_MCS9 0x15
423 #define DESC_RATE_MCS10 0x16
424 #define DESC_RATE_MCS11 0x17
425 #define DESC_RATE_MCS12 0x18
426 #define DESC_RATE_MCS13 0x19
427 #define DESC_RATE_MCS14 0x1a
428 #define DESC_RATE_MCS15 0x1b
429 #define DESC_RATE_MCS15_SG 0x1c
430 #define DESC_RATE_MCS32 0x20
432 #define TXDESC_OFFSET_SZ 0
433 #define TXDESC_OFFSET_SHT 16
435 #define TXDESC_BMC BIT(24)
436 #define TXDESC_LSG BIT(26)
437 #define TXDESC_FSG BIT(27)
438 #define TXDESC_OWN BIT(31)
440 #define TXDESC_BROADMULTICAST BIT(0)
441 #define TXDESC_HTC BIT(1)
442 #define TXDESC_LAST_SEGMENT BIT(2)
443 #define TXDESC_FIRST_SEGMENT BIT(3)
444 #define TXDESC_LINIP BIT(4)
445 #define TXDESC_NO_ACM BIT(5)
446 #define TXDESC_GF BIT(6)
447 #define TXDESC_OWN BIT(7)
452 * Bits 0-7 differ dependent on chip generation. For 8723au bits 5/6 are
453 * aggregation enable and break respectively. For 8723bu, bits 0-7 are macid.
455 #define TXDESC_PKT_OFFSET_SZ 0
456 #define TXDESC32_AGG_ENABLE BIT(5)
457 #define TXDESC32_AGG_BREAK BIT(6)
458 #define TXDESC40_MACID_SHIFT 0
459 #define TXDESC40_MACID_MASK 0x00f0
460 #define TXDESC_QUEUE_SHIFT 8
461 #define TXDESC_QUEUE_MASK 0x1f00
462 #define TXDESC_QUEUE_BK 0x2
463 #define TXDESC_QUEUE_BE 0x0
464 #define TXDESC_QUEUE_VI 0x5
465 #define TXDESC_QUEUE_VO 0x7
466 #define TXDESC_QUEUE_BEACON 0x10
467 #define TXDESC_QUEUE_HIGH 0x11
468 #define TXDESC_QUEUE_MGNT 0x12
469 #define TXDESC_QUEUE_CMD 0x13
470 #define TXDESC_QUEUE_MAX (TXDESC_QUEUE_CMD + 1)
471 #define TXDESC40_RDG_NAV_EXT BIT(13)
472 #define TXDESC40_LSIG_TXOP_ENABLE BIT(14)
473 #define TXDESC40_PIFS BIT(15)
475 #define DESC_RATE_ID_SHIFT 16
476 #define DESC_RATE_ID_MASK 0xf
477 #define TXDESC_NAVUSEHDR BIT(20)
478 #define TXDESC_SEC_RC4 0x00400000
479 #define TXDESC_SEC_AES 0x00c00000
480 #define TXDESC_PKT_OFFSET_SHIFT 26
481 #define TXDESC_AGG_EN BIT(29)
482 #define TXDESC_HWPC BIT(31)
485 #define TXDESC40_PAID_SHIFT 0
486 #define TXDESC40_PAID_MASK 0x1ff
487 #define TXDESC40_CCA_RTS_SHIFT 10
488 #define TXDESC40_CCA_RTS_MASK 0xc00
489 #define TXDESC40_AGG_ENABLE BIT(12)
490 #define TXDESC40_RDG_ENABLE BIT(13)
491 #define TXDESC40_AGG_BREAK BIT(16)
492 #define TXDESC40_MORE_FRAG BIT(17)
493 #define TXDESC40_RAW BIT(18)
494 #define TXDESC32_ACK_REPORT BIT(19)
495 #define TXDESC40_SPE_RPT BIT(19)
496 #define TXDESC_AMPDU_DENSITY_SHIFT 20
497 #define TXDESC40_BT_INT BIT(23)
498 #define TXDESC40_GID_SHIFT 24
501 #define TXDESC40_USE_DRIVER_RATE BIT(8)
502 #define TXDESC40_CTS_SELF_ENABLE BIT(11)
503 #define TXDESC40_RTS_CTS_ENABLE BIT(12)
504 #define TXDESC40_HW_RTS_ENABLE BIT(13)
505 #define TXDESC32_SEQ_SHIFT 16
506 #define TXDESC32_SEQ_MASK 0x0fff0000
509 #define TXDESC32_RTS_RATE_SHIFT 0
510 #define TXDESC32_RTS_RATE_MASK 0x3f
511 #define TXDESC32_QOS BIT(6)
512 #define TXDESC32_HW_SEQ_ENABLE BIT(7)
513 #define TXDESC32_USE_DRIVER_RATE BIT(8)
514 #define TXDESC_DISABLE_DATA_FB BIT(10)
515 #define TXDESC32_CTS_SELF_ENABLE BIT(11)
516 #define TXDESC32_RTS_CTS_ENABLE BIT(12)
517 #define TXDESC32_HW_RTS_ENABLE BIT(13)
518 #define TXDESC_PRIME_CH_OFF_LOWER BIT(20)
519 #define TXDESC_PRIME_CH_OFF_UPPER BIT(21)
520 #define TXDESC32_SHORT_PREAMBLE BIT(24)
521 #define TXDESC_DATA_BW BIT(25)
522 #define TXDESC_RTS_DATA_BW BIT(27)
523 #define TXDESC_RTS_PRIME_CH_OFF_LOWER BIT(28)
524 #define TXDESC_RTS_PRIME_CH_OFF_UPPER BIT(29)
525 #define TXDESC40_DATA_RATE_FB_SHIFT 8
526 #define TXDESC40_DATA_RATE_FB_MASK 0x00001f00
527 #define TXDESC40_RETRY_LIMIT_ENABLE BIT(17)
528 #define TXDESC40_RETRY_LIMIT_SHIFT 18
529 #define TXDESC40_RETRY_LIMIT_MASK 0x00fc0000
530 #define TXDESC40_RTS_RATE_SHIFT 24
531 #define TXDESC40_RTS_RATE_MASK 0x3f000000
534 #define TXDESC40_SHORT_PREAMBLE BIT(4)
535 #define TXDESC32_SHORT_GI BIT(6)
536 #define TXDESC_CCX_TAG BIT(7)
537 #define TXDESC32_RETRY_LIMIT_ENABLE BIT(17)
538 #define TXDESC32_RETRY_LIMIT_SHIFT 18
539 #define TXDESC32_RETRY_LIMIT_MASK 0x00fc0000
542 #define TXDESC_MAX_AGG_SHIFT 11
545 #define TXDESC40_HW_SEQ_ENABLE BIT(15)
548 #define TXDESC40_SEQ_SHIFT 12
549 #define TXDESC40_SEQ_MASK 0x00fff000
551 struct phy_rx_agc_info
{
552 #ifdef __LITTLE_ENDIAN
559 struct rtl8723au_phy_stats
{
560 struct phy_rx_agc_info path_agc
[RTL8723A_MAX_RF_PATHS
];
561 u8 ch_corr
[RTL8723A_MAX_RF_PATHS
];
562 u8 cck_sig_qual_ofdm_pwdb_all
;
563 u8 cck_agc_rpt_ofdm_cfosho_a
;
564 u8 cck_rpt_b_ofdm_cfosho_b
;
566 u8 noise_power_db_msb
;
567 u8 path_cfotail
[RTL8723A_MAX_RF_PATHS
];
568 u8 pcts_mask
[RTL8723A_MAX_RF_PATHS
];
569 s8 stream_rxevm
[RTL8723A_MAX_RF_PATHS
];
570 u8 path_rxsnr
[RTL8723A_MAX_RF_PATHS
];
571 u8 noise_power_db_lsb
;
573 u8 stream_csi
[RTL8723A_MAX_RF_PATHS
];
574 u8 stream_target_csi
[RTL8723A_MAX_RF_PATHS
];
578 #ifdef __LITTLE_ENDIAN
579 u8 antsel_rx_keep_2
:1; /* ex_intf_flg:1; */
584 u8 antenna_select_b
:1;
586 #else /* _BIG_ENDIAN_ */
588 u8 antenna_select_b
:1;
593 u8 antsel_rx_keep_2
:1; /* ex_intf_flg:1; */
600 #define RTL8XXXU_ADDA_REGS 16
601 #define RTL8XXXU_MAC_REGS 4
602 #define RTL8XXXU_BB_REGS 9
604 struct rtl8xxxu_firmware_header
{
605 __le16 signature
; /* 92C0: test chip; 92C,
609 u8 category
; /* AP/NIC and USB/PCI */
612 __le16 major_version
; /* FW Version */
613 u8 minor_version
; /* FW Subversion, default 0x00 */
616 u8 month
; /* Release time Month field */
617 u8 date
; /* Release time Date field */
618 u8 hour
; /* Release time Hour field */
619 u8 minute
; /* Release time Minute field */
621 __le16 ramcodesize
; /* Size of RAM code */
624 __le32 svn_idx
; /* SVN entry index */
634 * 8723au/8192cu/8188ru required base power index offset tables.
636 struct rtl8xxxu_power_base
{
659 * The 8723au has 3 channel groups: 1-3, 4-9, and 10-14
661 struct rtl8723au_idx
{
662 #ifdef __LITTLE_ENDIAN
669 } __attribute__((packed
));
671 struct rtl8723au_efuse
{
674 u8 cck_tx_power_index_A
[3]; /* 0x10 */
675 u8 cck_tx_power_index_B
[3];
676 u8 ht40_1s_tx_power_index_A
[3]; /* 0x16 */
677 u8 ht40_1s_tx_power_index_B
[3];
679 * The following entries are half-bytes split as:
680 * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
682 struct rtl8723au_idx ht20_tx_power_index_diff
[3];
683 struct rtl8723au_idx ofdm_tx_power_index_diff
[3];
684 struct rtl8723au_idx ht40_max_power_offset
[3];
685 struct rtl8723au_idx ht20_max_power_offset
[3];
686 u8 channel_plan
; /* 0x28 */
694 u8 version
/* 0x30 */;
695 u8 customer_id_major
;
696 u8 customer_id_minor
;
698 u8 chipset
; /* 0x34 */
704 u8 mac_addr
[ETH_ALEN
]; /* 0xc6 */
708 u8 device_name
[0x29]; /* 0xd7 */
711 struct rtl8192cu_efuse
{
720 __le16 smid
; /* 0x10 */
722 u8 mac_addr
[ETH_ALEN
]; /* 0x16 */
726 u8 device_name
[0x14]; /* 0x28 */
727 u8 res4
[0x1e]; /* 0x3c */
728 u8 cck_tx_power_index_A
[3]; /* 0x5a */
729 u8 cck_tx_power_index_B
[3];
730 u8 ht40_1s_tx_power_index_A
[3]; /* 0x60 */
731 u8 ht40_1s_tx_power_index_B
[3];
733 * The following entries are half-bytes split as:
734 * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
736 struct rtl8723au_idx ht40_2s_tx_power_index_diff
[3];
737 struct rtl8723au_idx ht20_tx_power_index_diff
[3]; /* 0x69 */
738 struct rtl8723au_idx ofdm_tx_power_index_diff
[3];
739 struct rtl8723au_idx ht40_max_power_offset
[3]; /* 0x6f */
740 struct rtl8723au_idx ht20_max_power_offset
[3];
741 u8 channel_plan
; /* 0x75 */
744 u8 thermal_meter
; /* xtal_k */ /* 0x78 */
749 u8 res5
[1]; /* 0x7d */
754 struct rtl8723bu_pwr_idx
{
755 #ifdef __LITTLE_ENDIAN
766 } __attribute__((packed
));
768 struct rtl8723bu_efuse_tx_power
{
771 struct rtl8723au_idx ht20_ofdm_1s_diff
;
772 struct rtl8723bu_pwr_idx pwr_diff
[3];
773 u8 dummy5g
[24]; /* max channel group (14) + power diff offset (10) */
776 struct rtl8723bu_efuse
{
779 struct rtl8723bu_efuse_tx_power tx_power_index_A
; /* 0x10 */
780 struct rtl8723bu_efuse_tx_power tx_power_index_B
; /* 0x3a */
781 struct rtl8723bu_efuse_tx_power tx_power_index_C
; /* 0x64 */
782 struct rtl8723bu_efuse_tx_power tx_power_index_D
; /* 0x8e */
783 u8 channel_plan
; /* 0xb8 */
787 u8 pa_type
; /* 0xbc */
788 u8 lna_type_2g
; /* 0xbd */
791 u8 rf_feature_option
;
794 u8 eeprom_customer_id
;
796 u8 tx_pwr_calibrate_rate
;
797 u8 rf_antenna_option
; /* 0xc9 */
800 u8 usb_optional_function
;
803 u8 serial
[0x0b]; /* 0xf5 */
808 u8 mac_addr
[ETH_ALEN
]; /* 0x107 */
810 u8 vendor_name
[0x07];
812 u8 device_name
[0x14];
814 u8 package_type
; /* 0x1fb */
818 struct rtl8192eu_efuse_tx_power
{
821 struct rtl8723au_idx ht20_ofdm_1s_diff
;
822 struct rtl8723bu_pwr_idx pwr_diff
[3];
823 u8 dummy5g
[24]; /* max channel group (14) + power diff offset (10) */
826 struct rtl8192eu_efuse
{
829 struct rtl8192eu_efuse_tx_power tx_power_index_A
; /* 0x10 */
830 struct rtl8192eu_efuse_tx_power tx_power_index_B
; /* 0x3a */
832 u8 channel_plan
; /* 0xb8 */
836 u8 pa_type
; /* 0xbc */
837 u8 lna_type_2g
; /* 0xbd */
839 u8 lna_type_5g
; /* 0xbf */
842 u8 rf_feature_option
;
845 u8 eeprom_customer_id
;
847 u8 rf_antenna_option
; /* 0xc9 */
853 u8 usb_optional_function
;
855 u8 mac_addr
[ETH_ALEN
]; /* 0xd7 */
859 u8 device_name
[0x0b]; /* 0xe8 */
861 u8 serial
[0x0b]; /* 0xf5 */
863 u8 unknown
[0x0d]; /* 0x130 */
867 struct rtl8xxxu_reg8val
{
872 struct rtl8xxxu_reg32val
{
877 struct rtl8xxxu_rfregval
{
882 enum rtl8xxxu_rfpath
{
887 struct rtl8xxxu_rfregs
{
896 #define H2C_MAX_MBOX 4
897 #define H2C_EXT BIT(7)
898 #define H2C_JOIN_BSS_DISCONNECT 0
899 #define H2C_JOIN_BSS_CONNECT 1
902 * H2C (firmware) commands differ between the older generation chips
903 * 8188[cr]u, 819[12]cu, and 8723au, and the more recent chips 8723bu,
904 * 8192[de]u, 8192eu, and 8812.
907 H2C_SET_POWER_MODE
= 1,
908 H2C_JOIN_BSS_REPORT
= 2,
910 H2C_SET_RATE_MASK
= (6 | H2C_EXT
),
917 H2C_8723B_RSVD_PAGE
= 0x00,
918 H2C_8723B_MEDIA_STATUS_RPT
= 0x01,
919 H2C_8723B_SCAN_ENABLE
= 0x02,
920 H2C_8723B_KEEP_ALIVE
= 0x03,
921 H2C_8723B_DISCON_DECISION
= 0x04,
922 H2C_8723B_PSD_OFFLOAD
= 0x05,
923 H2C_8723B_AP_OFFLOAD
= 0x08,
924 H2C_8723B_BCN_RSVDPAGE
= 0x09,
925 H2C_8723B_PROBERSP_RSVDPAGE
= 0x0A,
926 H2C_8723B_FCS_RSVDPAGE
= 0x10,
927 H2C_8723B_FCS_INFO
= 0x11,
928 H2C_8723B_AP_WOW_GPIO_CTRL
= 0x13,
931 * PoweSave Class: 001
933 H2C_8723B_SET_PWR_MODE
= 0x20,
934 H2C_8723B_PS_TUNING_PARA
= 0x21,
935 H2C_8723B_PS_TUNING_PARA2
= 0x22,
936 H2C_8723B_P2P_LPS_PARAM
= 0x23,
937 H2C_8723B_P2P_PS_OFFLOAD
= 0x24,
938 H2C_8723B_PS_SCAN_ENABLE
= 0x25,
939 H2C_8723B_SAP_PS_
= 0x26,
940 H2C_8723B_INACTIVE_PS_
= 0x27,
941 H2C_8723B_FWLPS_IN_IPS_
= 0x28,
944 * Dynamic Mechanism Class: 010
946 H2C_8723B_MACID_CFG_RAID
= 0x40,
947 H2C_8723B_TXBF
= 0x41,
948 H2C_8723B_RSSI_SETTING
= 0x42,
949 H2C_8723B_AP_REQ_TXRPT
= 0x43,
950 H2C_8723B_INIT_RATE_COLLECT
= 0x44,
955 H2C_8723B_B_TYPE_TDMA
= 0x60,
956 H2C_8723B_BT_INFO
= 0x61,
957 H2C_8723B_FORCE_BT_TXPWR
= 0x62,
958 H2C_8723B_BT_IGNORE_WLANACT
= 0x63,
959 H2C_8723B_DAC_SWING_VALUE
= 0x64,
960 H2C_8723B_ANT_SEL_RSV
= 0x65,
961 H2C_8723B_WL_OPMODE
= 0x66,
962 H2C_8723B_BT_MP_OPER
= 0x67,
963 H2C_8723B_BT_CONTROL
= 0x68,
964 H2C_8723B_BT_WIFI_CTRL
= 0x69,
965 H2C_8723B_BT_FW_PATCH
= 0x6a,
966 H2C_8723B_BT_WLAN_CALIBRATION
= 0x6d,
967 H2C_8723B_BT_GRANT
= 0x6e,
972 H2C_8723B_WOWLAN
= 0x80,
973 H2C_8723B_REMOTE_WAKE_CTRL
= 0x81,
974 H2C_8723B_AOAC_GLOBAL_INFO
= 0x82,
975 H2C_8723B_AOAC_RSVD_PAGE
= 0x83,
976 H2C_8723B_AOAC_RSVD_PAGE2
= 0x84,
977 H2C_8723B_D0_SCAN_OFFLOAD_CTRL
= 0x85,
978 H2C_8723B_D0_SCAN_OFFLOAD_INFO
= 0x86,
979 H2C_8723B_CHNL_SWITCH_OFFLOAD
= 0x87,
981 H2C_8723B_RESET_TSF
= 0xC0,
1014 } __packed media_status_rpt
;
1026 * [4:5] - VHT enable
1035 } __packed b_macid_cfg
;
1043 } __packed b_type_dma
;
1054 } __packed bt_mp_oper
;
1058 } __packed bt_wlan_calibration
;
1062 } __packed ignore_wlan
;
1067 } __packed ant_sel_rsv
;
1071 } __packed bt_grant
;
1075 enum c2h_evt_8723b
{
1076 C2H_8723B_DEBUG
= 0,
1078 C2H_8723B_AP_RPT_RSP
= 2,
1079 C2H_8723B_CCX_TX_RPT
= 3,
1080 C2H_8723B_BT_RSSI
= 4,
1081 C2H_8723B_BT_OP_MODE
= 5,
1082 C2H_8723B_EXT_RA_RPT
= 6,
1083 C2H_8723B_BT_INFO
= 9,
1084 C2H_8723B_HW_INFO_EXCH
= 0x0a,
1085 C2H_8723B_BT_MP_INFO
= 0x0b,
1086 C2H_8723B_RA_REPORT
= 0x0c,
1087 C2H_8723B_FW_DEBUG
= 0xff,
1090 enum bt_info_src_8723b
{
1091 BT_INFO_SRC_8723B_WIFI_FW
= 0x0,
1092 BT_INFO_SRC_8723B_BT_RSP
= 0x1,
1093 BT_INFO_SRC_8723B_BT_ACTIVE_SEND
= 0x2,
1096 enum bt_mp_oper_opcode_8723b
{
1097 BT_MP_OP_GET_BT_VERSION
= 0x00,
1098 BT_MP_OP_RESET
= 0x01,
1099 BT_MP_OP_TEST_CTRL
= 0x02,
1100 BT_MP_OP_SET_BT_MODE
= 0x03,
1101 BT_MP_OP_SET_CHNL_TX_GAIN
= 0x04,
1102 BT_MP_OP_SET_PKT_TYPE_LEN
= 0x05,
1103 BT_MP_OP_SET_PKT_CNT_L_PL_TYPE
= 0x06,
1104 BT_MP_OP_SET_PKT_CNT_H_PKT_INTV
= 0x07,
1105 BT_MP_OP_SET_PKT_HEADER
= 0x08,
1106 BT_MP_OP_SET_WHITENCOEFF
= 0x09,
1107 BT_MP_OP_SET_BD_ADDR_L
= 0x0a,
1108 BT_MP_OP_SET_BD_ADDR_H
= 0x0b,
1109 BT_MP_OP_WRITE_REG_ADDR
= 0x0c,
1110 BT_MP_OP_WRITE_REG_VALUE
= 0x0d,
1111 BT_MP_OP_GET_BT_STATUS
= 0x0e,
1112 BT_MP_OP_GET_BD_ADDR_L
= 0x0f,
1113 BT_MP_OP_GET_BD_ADDR_H
= 0x10,
1114 BT_MP_OP_READ_REG
= 0x11,
1115 BT_MP_OP_SET_TARGET_BD_ADDR_L
= 0x12,
1116 BT_MP_OP_SET_TARGET_BD_ADDR_H
= 0x13,
1117 BT_MP_OP_SET_TX_POWER_CALIBRATION
= 0x14,
1118 BT_MP_OP_GET_RX_PKT_CNT_L
= 0x15,
1119 BT_MP_OP_GET_RX_PKT_CNT_H
= 0x16,
1120 BT_MP_OP_GET_RX_ERROR_BITS_L
= 0x17,
1121 BT_MP_OP_GET_RX_ERROR_BITS_H
= 0x18,
1122 BT_MP_OP_GET_RSSI
= 0x19,
1123 BT_MP_OP_GET_CFO_HDR_QUALITY_L
= 0x1a,
1124 BT_MP_OP_GET_CFO_HDR_QUALITY_H
= 0x1b,
1125 BT_MP_OP_GET_TARGET_BD_ADDR_L
= 0x1c,
1126 BT_MP_OP_GET_TARGET_BD_ADDR_H
= 0x1d,
1127 BT_MP_OP_GET_AFH_MAP_L
= 0x1e,
1128 BT_MP_OP_GET_AFH_MAP_M
= 0x1f,
1129 BT_MP_OP_GET_AFH_MAP_H
= 0x20,
1130 BT_MP_OP_GET_AFH_STATUS
= 0x21,
1131 BT_MP_OP_SET_TRACKING_INTERVAL
= 0x22,
1132 BT_MP_OP_SET_THERMAL_METER
= 0x23,
1133 BT_MP_OP_ENABLE_CFO_TRACKING
= 0x24,
1136 enum rtl8xxxu_bw_mode
{
1137 RTL8XXXU_CHANNEL_WIDTH_20
= 0,
1138 RTL8XXXU_CHANNEL_WIDTH_40
= 1,
1139 RTL8XXXU_CHANNEL_WIDTH_80
= 2,
1140 RTL8XXXU_CHANNEL_WIDTH_160
= 3,
1141 RTL8XXXU_CHANNEL_WIDTH_80_80
= 4,
1142 RTL8XXXU_CHANNEL_WIDTH_MAX
= 5,
1145 struct rtl8723bu_c2h
{
1159 } __packed bt_mp_info
;
1161 u8 response_source
:4;
1196 } __packed ra_report
;
1200 struct rtl8xxxu_fileops
;
1203 enum wireless_mode
{
1204 WIRELESS_MODE_UNKNOWN
= 0,
1206 WIRELESS_MODE_B
= BIT(0),
1207 WIRELESS_MODE_G
= BIT(1),
1208 WIRELESS_MODE_A
= BIT(2),
1209 WIRELESS_MODE_N_24G
= BIT(3),
1210 WIRELESS_MODE_N_5G
= BIT(4),
1211 WIRELESS_AUTO
= BIT(5),
1212 WIRELESS_MODE_AC
= BIT(6),
1213 WIRELESS_MODE_MAX
= 0x7F,
1216 /* from rtlwifi/wifi.h */
1217 enum ratr_table_mode_new
{
1218 RATEID_IDX_BGN_40M_2SS
= 0,
1219 RATEID_IDX_BGN_40M_1SS
= 1,
1220 RATEID_IDX_BGN_20M_2SS_BN
= 2,
1221 RATEID_IDX_BGN_20M_1SS_BN
= 3,
1222 RATEID_IDX_GN_N2SS
= 4,
1223 RATEID_IDX_GN_N1SS
= 5,
1227 RATEID_IDX_VHT_2SS
= 9,
1228 RATEID_IDX_VHT_1SS
= 10,
1229 RATEID_IDX_MIX1
= 11,
1230 RATEID_IDX_MIX2
= 12,
1231 RATEID_IDX_VHT_3SS
= 13,
1232 RATEID_IDX_BGN_3SS
= 14,
1235 #define BT_INFO_8723B_1ANT_B_FTP BIT(7)
1236 #define BT_INFO_8723B_1ANT_B_A2DP BIT(6)
1237 #define BT_INFO_8723B_1ANT_B_HID BIT(5)
1238 #define BT_INFO_8723B_1ANT_B_SCO_BUSY BIT(4)
1239 #define BT_INFO_8723B_1ANT_B_ACL_BUSY BIT(3)
1240 #define BT_INFO_8723B_1ANT_B_INQ_PAGE BIT(2)
1241 #define BT_INFO_8723B_1ANT_B_SCO_ESCO BIT(1)
1242 #define BT_INFO_8723B_1ANT_B_CONNECTION BIT(0)
1244 enum _BT_8723B_1ANT_STATUS
{
1245 BT_8723B_1ANT_STATUS_NON_CONNECTED_IDLE
= 0x0,
1246 BT_8723B_1ANT_STATUS_CONNECTED_IDLE
= 0x1,
1247 BT_8723B_1ANT_STATUS_INQ_PAGE
= 0x2,
1248 BT_8723B_1ANT_STATUS_ACL_BUSY
= 0x3,
1249 BT_8723B_1ANT_STATUS_SCO_BUSY
= 0x4,
1250 BT_8723B_1ANT_STATUS_ACL_SCO_BUSY
= 0x5,
1251 BT_8723B_1ANT_STATUS_MAX
1254 struct rtl8xxxu_btcoex
{
1263 bool c2h_bt_inquiry
;
1266 #define RTL8XXXU_RATR_STA_INIT 0
1267 #define RTL8XXXU_RATR_STA_HIGH 1
1268 #define RTL8XXXU_RATR_STA_MID 2
1269 #define RTL8XXXU_RATR_STA_LOW 3
1271 #define RTL8XXXU_NOISE_FLOOR_MIN -100
1272 #define RTL8XXXU_SNR_THRESH_HIGH 50
1273 #define RTL8XXXU_SNR_THRESH_LOW 20
1275 struct rtl8xxxu_ra_report
{
1276 struct rate_info txrate
;
1281 struct rtl8xxxu_priv
{
1282 struct ieee80211_hw
*hw
;
1283 struct usb_device
*udev
;
1284 struct rtl8xxxu_fileops
*fops
;
1286 spinlock_t tx_urb_lock
;
1287 struct list_head tx_urb_free_list
;
1288 int tx_urb_free_count
;
1291 spinlock_t rx_urb_lock
;
1292 struct list_head rx_urb_pending_list
;
1293 int rx_urb_pending_count
;
1295 struct work_struct rx_urb_wq
;
1297 u8 mac_addr
[ETH_ALEN
];
1299 char chip_vendor
[8];
1300 u8 cck_tx_power_index_A
[RTL8XXXU_MAX_CHANNEL_GROUPS
];
1301 u8 cck_tx_power_index_B
[RTL8XXXU_MAX_CHANNEL_GROUPS
];
1302 u8 ht40_1s_tx_power_index_A
[RTL8XXXU_MAX_CHANNEL_GROUPS
];
1303 u8 ht40_1s_tx_power_index_B
[RTL8XXXU_MAX_CHANNEL_GROUPS
];
1305 * The following entries are half-bytes split as:
1306 * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
1308 struct rtl8723au_idx ht40_2s_tx_power_index_diff
[
1309 RTL8723A_CHANNEL_GROUPS
];
1310 struct rtl8723au_idx ht20_tx_power_index_diff
[RTL8723A_CHANNEL_GROUPS
];
1311 struct rtl8723au_idx ofdm_tx_power_index_diff
[RTL8723A_CHANNEL_GROUPS
];
1312 struct rtl8723au_idx ht40_max_power_offset
[RTL8723A_CHANNEL_GROUPS
];
1313 struct rtl8723au_idx ht20_max_power_offset
[RTL8723A_CHANNEL_GROUPS
];
1315 * Newer generation chips only keep power diffs per TX count,
1316 * not per channel group.
1318 struct rtl8723au_idx ofdm_tx_power_diff
[RTL8723B_TX_COUNT
];
1319 struct rtl8723au_idx ht20_tx_power_diff
[RTL8723B_TX_COUNT
];
1320 struct rtl8723au_idx ht40_tx_power_diff
[RTL8723B_TX_COUNT
];
1321 struct rtl8xxxu_power_base
*power_base
;
1324 u32 is_multi_func
:1;
1326 u32 has_bluetooth
:1;
1327 u32 enable_bluetooth
:1;
1332 u32 has_polarity_ctrl
:1;
1335 u32 usb_interrupts
:1;
1336 u32 ep_tx_high_queue
:1;
1337 u32 ep_tx_normal_queue
:1;
1338 u32 ep_tx_low_queue
:1;
1340 u32 rx_buf_aggregation
:1;
1342 unsigned int pipe_interrupt
;
1343 unsigned int pipe_in
;
1344 unsigned int pipe_out
[TXDESC_QUEUE_MAX
];
1345 u8 out_ep
[RTL8XXXU_OUT_ENDPOINTS
];
1357 struct mutex h2c_mutex
;
1359 struct usb_anchor rx_anchor
;
1360 struct usb_anchor tx_anchor
;
1361 struct usb_anchor int_anchor
;
1362 struct rtl8xxxu_firmware_header
*fw_data
;
1364 struct mutex usb_buf_mutex
;
1371 u8 raw
[EFUSE_MAP_LEN
];
1372 struct rtl8723au_efuse efuse8723
;
1373 struct rtl8723bu_efuse efuse8723bu
;
1374 struct rtl8192cu_efuse efuse8192
;
1375 struct rtl8192eu_efuse efuse8192eu
;
1377 u32 adda_backup
[RTL8XXXU_ADDA_REGS
];
1378 u32 mac_backup
[RTL8XXXU_MAC_REGS
];
1379 u32 bb_backup
[RTL8XXXU_BB_REGS
];
1380 u32 bb_recovery_backup
[RTL8XXXU_BB_REGS
];
1381 enum rtl8xxxu_rtl_chip rtl_chip
;
1384 u8 int_buf
[USB_INTR_CONTENT_LENGTH
];
1387 * Only one virtual interface permitted because only STA mode
1388 * is supported and no iface_combinations are provided.
1390 struct ieee80211_vif
*vif
;
1391 struct delayed_work ra_watchdog
;
1392 struct work_struct c2hcmd_work
;
1393 struct sk_buff_head c2hcmd_queue
;
1394 spinlock_t c2hcmd_lock
;
1395 struct rtl8xxxu_btcoex bt_coex
;
1396 struct rtl8xxxu_ra_report ra_report
;
1399 struct rtl8xxxu_rx_urb
{
1401 struct ieee80211_hw
*hw
;
1402 struct list_head list
;
1405 struct rtl8xxxu_tx_urb
{
1407 struct ieee80211_hw
*hw
;
1408 struct list_head list
;
1411 struct rtl8xxxu_fileops
{
1412 int (*parse_efuse
) (struct rtl8xxxu_priv
*priv
);
1413 int (*load_firmware
) (struct rtl8xxxu_priv
*priv
);
1414 int (*power_on
) (struct rtl8xxxu_priv
*priv
);
1415 void (*power_off
) (struct rtl8xxxu_priv
*priv
);
1416 void (*reset_8051
) (struct rtl8xxxu_priv
*priv
);
1417 int (*llt_init
) (struct rtl8xxxu_priv
*priv
);
1418 void (*init_phy_bb
) (struct rtl8xxxu_priv
*priv
);
1419 int (*init_phy_rf
) (struct rtl8xxxu_priv
*priv
);
1420 void (*phy_init_antenna_selection
) (struct rtl8xxxu_priv
*priv
);
1421 void (*phy_iq_calibrate
) (struct rtl8xxxu_priv
*priv
);
1422 void (*config_channel
) (struct ieee80211_hw
*hw
);
1423 int (*parse_rx_desc
) (struct rtl8xxxu_priv
*priv
, struct sk_buff
*skb
);
1424 void (*init_aggregation
) (struct rtl8xxxu_priv
*priv
);
1425 void (*init_statistics
) (struct rtl8xxxu_priv
*priv
);
1426 void (*enable_rf
) (struct rtl8xxxu_priv
*priv
);
1427 void (*disable_rf
) (struct rtl8xxxu_priv
*priv
);
1428 void (*usb_quirks
) (struct rtl8xxxu_priv
*priv
);
1429 void (*set_tx_power
) (struct rtl8xxxu_priv
*priv
, int channel
,
1431 void (*update_rate_mask
) (struct rtl8xxxu_priv
*priv
,
1432 u32 ramask
, u8 rateid
, int sgi
);
1433 void (*report_connect
) (struct rtl8xxxu_priv
*priv
,
1434 u8 macid
, bool connect
);
1435 void (*fill_txdesc
) (struct ieee80211_hw
*hw
, struct ieee80211_hdr
*hdr
,
1436 struct ieee80211_tx_info
*tx_info
,
1437 struct rtl8xxxu_txdesc32
*tx_desc
, bool sgi
,
1438 bool short_preamble
, bool ampdu_enable
,
1440 int writeN_block_size
;
1441 int rx_agg_buf_size
;
1446 u8 gen2_thermal_meter
:1;
1447 u8 needs_full_init
:1;
1449 u32 adda_1t_path_on
;
1450 u32 adda_2t_path_on_a
;
1451 u32 adda_2t_path_on_b
;
1455 struct rtl8xxxu_reg8val
*mactable
;
1462 extern int rtl8xxxu_debug
;
1464 extern struct rtl8xxxu_reg8val rtl8xxxu_gen1_mac_init_table
[];
1465 extern const u32 rtl8xxxu_iqk_phy_iq_bb_reg
[];
1466 u8
rtl8xxxu_read8(struct rtl8xxxu_priv
*priv
, u16 addr
);
1467 u16
rtl8xxxu_read16(struct rtl8xxxu_priv
*priv
, u16 addr
);
1468 u32
rtl8xxxu_read32(struct rtl8xxxu_priv
*priv
, u16 addr
);
1469 int rtl8xxxu_write8(struct rtl8xxxu_priv
*priv
, u16 addr
, u8 val
);
1470 int rtl8xxxu_write16(struct rtl8xxxu_priv
*priv
, u16 addr
, u16 val
);
1471 int rtl8xxxu_write32(struct rtl8xxxu_priv
*priv
, u16 addr
, u32 val
);
1472 u32
rtl8xxxu_read_rfreg(struct rtl8xxxu_priv
*priv
,
1473 enum rtl8xxxu_rfpath path
, u8 reg
);
1474 int rtl8xxxu_write_rfreg(struct rtl8xxxu_priv
*priv
,
1475 enum rtl8xxxu_rfpath path
, u8 reg
, u32 data
);
1476 void rtl8xxxu_save_regs(struct rtl8xxxu_priv
*priv
, const u32
*regs
,
1477 u32
*backup
, int count
);
1478 void rtl8xxxu_restore_regs(struct rtl8xxxu_priv
*priv
, const u32
*regs
,
1479 u32
*backup
, int count
);
1480 void rtl8xxxu_save_mac_regs(struct rtl8xxxu_priv
*priv
,
1481 const u32
*reg
, u32
*backup
);
1482 void rtl8xxxu_restore_mac_regs(struct rtl8xxxu_priv
*priv
,
1483 const u32
*reg
, u32
*backup
);
1484 void rtl8xxxu_path_adda_on(struct rtl8xxxu_priv
*priv
, const u32
*regs
,
1486 void rtl8xxxu_mac_calibration(struct rtl8xxxu_priv
*priv
,
1487 const u32
*regs
, u32
*backup
);
1488 void rtl8xxxu_fill_iqk_matrix_a(struct rtl8xxxu_priv
*priv
, bool iqk_ok
,
1489 int result
[][8], int candidate
, bool tx_only
);
1490 void rtl8xxxu_fill_iqk_matrix_b(struct rtl8xxxu_priv
*priv
, bool iqk_ok
,
1491 int result
[][8], int candidate
, bool tx_only
);
1492 int rtl8xxxu_init_phy_rf(struct rtl8xxxu_priv
*priv
,
1493 struct rtl8xxxu_rfregval
*table
,
1494 enum rtl8xxxu_rfpath path
);
1495 int rtl8xxxu_init_phy_regs(struct rtl8xxxu_priv
*priv
,
1496 struct rtl8xxxu_reg32val
*array
);
1497 int rtl8xxxu_load_firmware(struct rtl8xxxu_priv
*priv
, char *fw_name
);
1498 void rtl8xxxu_firmware_self_reset(struct rtl8xxxu_priv
*priv
);
1499 void rtl8xxxu_power_off(struct rtl8xxxu_priv
*priv
);
1500 void rtl8xxxu_reset_8051(struct rtl8xxxu_priv
*priv
);
1501 int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv
*priv
);
1502 void rtl8xxxu_gen2_prepare_calibrate(struct rtl8xxxu_priv
*priv
, u8 start
);
1503 int rtl8xxxu_flush_fifo(struct rtl8xxxu_priv
*priv
);
1504 int rtl8xxxu_gen2_h2c_cmd(struct rtl8xxxu_priv
*priv
,
1505 struct h2c_cmd
*h2c
, int len
);
1506 int rtl8xxxu_active_to_lps(struct rtl8xxxu_priv
*priv
);
1507 void rtl8xxxu_disabled_to_emu(struct rtl8xxxu_priv
*priv
);
1508 int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv
*priv
);
1509 void rtl8xxxu_gen1_phy_iq_calibrate(struct rtl8xxxu_priv
*priv
);
1510 void rtl8xxxu_gen1_init_phy_bb(struct rtl8xxxu_priv
*priv
);
1511 void rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv
*priv
,
1512 int channel
, bool ht40
);
1513 void rtl8xxxu_gen1_config_channel(struct ieee80211_hw
*hw
);
1514 void rtl8xxxu_gen2_config_channel(struct ieee80211_hw
*hw
);
1515 void rtl8xxxu_gen1_usb_quirks(struct rtl8xxxu_priv
*priv
);
1516 void rtl8xxxu_gen2_usb_quirks(struct rtl8xxxu_priv
*priv
);
1517 void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv
*priv
,
1518 u32 ramask
, u8 rateid
, int sgi
);
1519 void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv
*priv
,
1520 u32 ramask
, u8 rateid
, int sgi
);
1521 void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv
*priv
,
1522 u8 macid
, bool connect
);
1523 void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv
*priv
,
1524 u8 macid
, bool connect
);
1525 void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv
*priv
);
1526 void rtl8xxxu_gen1_enable_rf(struct rtl8xxxu_priv
*priv
);
1527 void rtl8xxxu_gen1_disable_rf(struct rtl8xxxu_priv
*priv
);
1528 void rtl8xxxu_gen2_disable_rf(struct rtl8xxxu_priv
*priv
);
1529 int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv
*priv
, struct sk_buff
*skb
);
1530 int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv
*priv
, struct sk_buff
*skb
);
1531 int rtl8xxxu_gen2_channel_to_group(int channel
);
1532 bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv
*priv
,
1533 int result
[][8], int c1
, int c2
);
1534 void rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw
*hw
, struct ieee80211_hdr
*hdr
,
1535 struct ieee80211_tx_info
*tx_info
,
1536 struct rtl8xxxu_txdesc32
*tx_desc
, bool sgi
,
1537 bool short_preamble
, bool ampdu_enable
,
1539 void rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw
*hw
, struct ieee80211_hdr
*hdr
,
1540 struct ieee80211_tx_info
*tx_info
,
1541 struct rtl8xxxu_txdesc32
*tx_desc32
, bool sgi
,
1542 bool short_preamble
, bool ampdu_enable
,
1544 void rtl8723bu_set_ps_tdma(struct rtl8xxxu_priv
*priv
,
1545 u8 arg1
, u8 arg2
, u8 arg3
, u8 arg4
, u8 arg5
);
1547 extern struct rtl8xxxu_fileops rtl8192cu_fops
;
1548 extern struct rtl8xxxu_fileops rtl8192eu_fops
;
1549 extern struct rtl8xxxu_fileops rtl8723au_fops
;
1550 extern struct rtl8xxxu_fileops rtl8723bu_fops
;