xref: /OK3568_Linux_fs/external/rkwifibt/tools/rtk_hciattach/rtb_fwc.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  *  Copyright (C) 2018 Realtek Semiconductor Corporation.
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  */
14 
15 struct rtb_struct;
16 
17 #define BAUDRATE_4BYTES
18 
19 #define ROM_LMP_NONE            0x0000
20 #define ROM_LMP_8723a           0x1200
21 #define ROM_LMP_8723b           0x8723
22 #define ROM_LMP_8821a           0x8821
23 #define ROM_LMP_8761a           0x8761
24 #define ROM_LMP_8761btc		0x8763
25 
26 #define ROM_LMP_8703a           0x87b3
27 #define ROM_LMP_8763a           0x8763
28 #define ROM_LMP_8703b           0x8703
29 #define ROM_LMP_8723c           0x87c3 /* ??????? */
30 #define ROM_LMP_8822b           0x8822
31 #define ROM_LMP_8822c           0x8822
32 #define ROM_LMP_8852a           0x8852
33 #define ROM_LMP_8723cs_xx       0x8704
34 #define ROM_LMP_8723cs_cg       0x8705
35 #define ROM_LMP_8723cs_vf       0x8706
36 
37 /* Chip type */
38 #define CHIP_8852BS    0
39 #define CHIP_8703AS    1
40 #define CHIP_8723CS_CG 3
41 #define CHIP_8723CS_VF 4
42 #define CHIP_8723CS_XX 5
43 #define CHIP_8703BS   7
44 #define CHIP_8725AS   0x05
45 #define CHIP_8852BPE_VR 0x06
46 #define CHIP_8852BPS    0x0A
47 
48 /* software id */
49 #define CHIP_UNKNOWN	0x00
50 #define CHIP_8761AT	0x1F
51 #define CHIP_8761ATF	0x2F
52 #define CHIP_8761BTC	0x3F
53 #define CHIP_8761BH4	0x4F
54 #define CHIP_8723BS	0x5F
55 #define CHIP_BEFORE	0x6F
56 #define CHIP_8822BS	0x70
57 #define CHIP_8723DS	0x71
58 #define CHIP_8821CS	0x72
59 #define CHIP_8822CS	0x73
60 #define CHIP_8761B	0x74
61 #define CHIP_8852AS	0x75
62 #define CHIP_8723FS	0x76
63 #define CHIP_8852CS	0x77
64 #define CHIP_8852BP	0x78
65 
66 #define RTL_FW_MATCH_CHIP_TYPE  (1 << 0)
67 #define RTL_FW_MATCH_HCI_VER    (1 << 1)
68 #define RTL_FW_MATCH_HCI_REV    (1 << 2)
69 struct patch_info {
70 	uint32_t    match_flags;
71 	uint8_t     chip_type;
72 	uint16_t    lmp_subver;
73 	uint16_t    proj_id;
74 	uint8_t     hci_ver;
75 	uint16_t    hci_rev;
76 	char        *patch_file;
77 	char        *config_file;
78 	char        *ic_name;
79 };
80 
81 struct patch_info *get_patch_entry(struct rtb_struct *btrtl);
82 uint8_t *rtb_read_config(const char *file, int *cfg_len, uint8_t chip_type);
83 uint8_t *rtb_read_firmware(struct rtb_struct *btrtl, int *fw_len);
84 uint8_t *rtb_get_final_patch(int fd, int proto, int *rlen);
85