1 | /*- |
---|
2 | * Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org> |
---|
3 | * All rights reserved. |
---|
4 | * |
---|
5 | * Redistribution and use in source and binary forms, with or without |
---|
6 | * modification, are permitted provided that the following conditions |
---|
7 | * are met: |
---|
8 | * 1. Redistributions of source code must retain the above copyright |
---|
9 | * notice, this list of conditions and the following disclaimer. |
---|
10 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
11 | * notice, this list of conditions and the following disclaimer in the |
---|
12 | * documentation and/or other materials provided with the distribution. |
---|
13 | * |
---|
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
---|
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
---|
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
24 | * SUCH DAMAGE. |
---|
25 | * |
---|
26 | * $FreeBSD$ |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef R12A_ROM_IMAGE_H |
---|
30 | #define R12A_ROM_IMAGE_H |
---|
31 | |
---|
32 | #include <dev/rtwn/rtl8812a/r12a_rom_defs.h> |
---|
33 | |
---|
34 | #define R12A_DEF_TX_PWR_2G 0x2d |
---|
35 | #define R12A_DEF_TX_PWR_5G 0xfe |
---|
36 | |
---|
37 | struct r12a_tx_pwr_2g { |
---|
38 | uint8_t cck[R12A_GROUP_2G]; |
---|
39 | uint8_t ht40[R12A_GROUP_2G - 1]; |
---|
40 | } __packed; |
---|
41 | |
---|
42 | struct r12a_tx_pwr_diff_2g { |
---|
43 | uint8_t ht20_ofdm; |
---|
44 | struct { |
---|
45 | uint8_t ht40_ht20; |
---|
46 | uint8_t ofdm_cck; |
---|
47 | } __packed diff123[R12A_MAX_TX_COUNT - 1]; |
---|
48 | } __packed; |
---|
49 | |
---|
50 | struct r12a_tx_pwr_5g { |
---|
51 | uint8_t ht40[R12A_GROUP_5G]; |
---|
52 | } __packed; |
---|
53 | |
---|
54 | struct r12a_tx_pwr_diff_5g { |
---|
55 | uint8_t ht20_ofdm; |
---|
56 | uint8_t ht40_ht20[R12A_MAX_TX_COUNT - 1]; |
---|
57 | uint8_t ofdm_ofdm[2]; |
---|
58 | uint8_t ht80_ht160[R12A_MAX_TX_COUNT]; |
---|
59 | } __packed; |
---|
60 | |
---|
61 | struct r12a_tx_pwr { |
---|
62 | struct r12a_tx_pwr_2g pwr_2g; |
---|
63 | struct r12a_tx_pwr_diff_2g pwr_diff_2g; |
---|
64 | struct r12a_tx_pwr_5g pwr_5g; |
---|
65 | struct r12a_tx_pwr_diff_5g pwr_diff_5g; |
---|
66 | } __packed; |
---|
67 | |
---|
68 | /* |
---|
69 | * RTL8812AU/RTL8821AU ROM image. |
---|
70 | */ |
---|
71 | struct r12a_rom { |
---|
72 | uint8_t reserved1[16]; |
---|
73 | struct r12a_tx_pwr tx_pwr[R12A_MAX_RF_PATH]; |
---|
74 | uint8_t channel_plan; |
---|
75 | uint8_t crystalcap; |
---|
76 | #define R12A_ROM_CRYSTALCAP_DEF 0x20 |
---|
77 | |
---|
78 | uint8_t thermal_meter; |
---|
79 | uint8_t iqk_lck; |
---|
80 | uint8_t pa_type; |
---|
81 | #define R12A_ROM_IS_PA_EXT_2GHZ(pa_type) (((pa_type) & 0x30) == 0x30) |
---|
82 | #define R12A_ROM_IS_PA_EXT_5GHZ(pa_type) (((pa_type) & 0x03) == 0x03) |
---|
83 | #define R21A_ROM_IS_PA_EXT_2GHZ(pa_type) (((pa_type) & 0x10) == 0x10) |
---|
84 | #define R21A_ROM_IS_PA_EXT_5GHZ(pa_type) (((pa_type) & 0x01) == 0x01) |
---|
85 | |
---|
86 | uint8_t lna_type_2g; |
---|
87 | #define R12A_ROM_IS_LNA_EXT(lna_type) (((lna_type) & 0x88) == 0x88) |
---|
88 | #define R21A_ROM_IS_LNA_EXT(lna_type) (((lna_type) & 0x08) == 0x08) |
---|
89 | |
---|
90 | #define R12A_GET_ROM_PA_TYPE(lna_type, chain) \ |
---|
91 | (((lna_type) >> ((chain) * 4 + 2)) & 0x01) |
---|
92 | #define R12A_GET_ROM_LNA_TYPE(lna_type, chain) \ |
---|
93 | (((lna_type) >> ((chain) * 4)) & 0x03) |
---|
94 | |
---|
95 | uint8_t reserved2; |
---|
96 | uint8_t lna_type_5g; |
---|
97 | uint8_t reserved3; |
---|
98 | uint8_t rf_board_opt; |
---|
99 | #define R12A_BOARD_TYPE_COMBO_MF 5 |
---|
100 | |
---|
101 | uint8_t rf_feature_opt; |
---|
102 | uint8_t rf_bt_opt; |
---|
103 | #define R12A_RF_BT_OPT_ANT_NUM 0x01 |
---|
104 | |
---|
105 | uint8_t version; |
---|
106 | uint8_t customer_id; |
---|
107 | uint8_t tx_bbswing_2g; |
---|
108 | uint8_t tx_bbswing_5g; |
---|
109 | uint8_t tx_pwr_calib_rate; |
---|
110 | uint8_t rf_ant_opt; |
---|
111 | uint8_t rfe_option; |
---|
112 | uint8_t reserved4[5]; |
---|
113 | uint16_t vid_12a; |
---|
114 | uint16_t pid_12a; |
---|
115 | uint8_t reserved5[3]; |
---|
116 | uint8_t macaddr_12a[IEEE80211_ADDR_LEN]; |
---|
117 | uint8_t reserved6[2]; |
---|
118 | uint8_t string_12a[8]; /* "Realtek " */ |
---|
119 | uint8_t reserved7[25]; |
---|
120 | uint16_t vid_21a; |
---|
121 | uint16_t pid_21a; |
---|
122 | uint8_t reserved8[3]; |
---|
123 | uint8_t macaddr_21a[IEEE80211_ADDR_LEN]; |
---|
124 | uint8_t reserved9[2]; |
---|
125 | uint8_t string_21a[8]; /* "Realtek " */ |
---|
126 | uint8_t reserved10[2]; |
---|
127 | uint8_t string_ven[23]; /* XXX variable length? */ |
---|
128 | uint8_t reserved11[208]; |
---|
129 | } __packed; |
---|
130 | |
---|
131 | _Static_assert(sizeof(struct r12a_rom) == R12A_EFUSE_MAP_LEN, |
---|
132 | "R12A_EFUSE_MAP_LEN must be equal to sizeof(struct r12a_rom)!"); |
---|
133 | |
---|
134 | #endif /* R12A_ROM_IMAGE_H */ |
---|