xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852bs/include/rtw_efuse.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2020 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #if defined(CONFIG_MP_INCLUDED)
16 #ifndef __RTW_EFUSE_H__
17 #define __RTW_EFUSE_H__
18 #include <drv_types.h>
19 #include <rtw_mp.h>
20 
21 #define RTW_MAX_EFUSE_MAP_LEN 2048
22 
23 enum rtw_efuse_type {
24 	RTW_EFUSE_WIFI = 0,
25 	RTW_EFUSE_BT,
26 	RTW_EFUSE_NONE,
27 };
28 
29 /* PHL efuse command */
30 enum rtw_efuse_phl_cmdid {
31 	RTW_EFUSE_CMD_WIFI_READ = 0,
32 	RTW_EFUSE_CMD_WIFI_WRITE = 1,
33 	RTW_EFUSE_CMD_WIFI_UPDATE = 2,
34 	RTW_EFUSE_CMD_WIFI_UPDATE_MAP = 3,
35 	RTW_EFUSE_CMD_WIFI_GET_OFFSET_MASK = 4,
36 	RTW_EFUSE_CMD_WIFI_GET_USAGE = 5,
37 	RTW_EFUSE_CMD_BT_READ = 6,
38 	RTW_EFUSE_CMD_BT_WRITE = 7,
39 	RTW_EFUSE_CMD_BT_UPDATE = 8,
40 	RTW_EFUSE_CMD_BT_UPDATE_MAP = 9,
41 	RTW_EFUSE_CMD_BT_GET_OFFSET_MASK = 10,
42 	RTW_EFUSE_CMD_BT_GET_USAGE = 11,
43 	RTW_EFUSE_CMD_WIFI_GET_LOG_SIZE = 12,
44 	RTW_EFUSE_CMD_WIFI_GET_SIZE = 13,
45 	RTW_EFUSE_CMD_WIFI_GET_AVL_SIZE = 14,
46 	RTW_EFUSE_CMD_AUTOLOAD_STATUS = 15,
47 	RTW_EFUSE_CMD_SHADOW_MAP2BUF = 16,
48 	RTW_EFUSE_CMD_FILE_MAP_LOAD = 17,
49 	RTW_EFUSE_CMD_FILE_MASK_LOAD = 18,
50 	RTW_MP_EFUSE_CMD_GET_INFO = 19,
51 	/* BT */
52 	RTW_EFUSE_CMD_BT_GET_LOG_SIZE = 20,
53 	RTW_EFUSE_CMD_BT_GET_SIZE = 21,
54 	RTW_EFUSE_CMD_BT_GET_AVL_SIZE = 22,
55 	RTW_EFUSE_CMD_BT_SHADOW_MAP2BUF = 23,
56 	RTW_EFUSE_CMD_BT_FILE_MAP_LOAD = 24,
57 	RTW_EFUSE_CMD_BT_FILE_MASK_LOAD = 25,
58 	RTW_EFUSE_CMD_BT_READ_HIDDEN = 26,
59 	RTW_EFUSE_CMD_BT_WRITE_HIDDEN = 27,
60 	RTW_MP_EFUSE_CMD_WIFI_GET_MAP_FROM =28,
61 	RTW_EFUSE_CMD_WIFI_GET_PHY_MAP = 29,
62 	RTW_EFUSE_CMD_BT_GET_PHY_MAP = 30,
63 	RTW_MP_EFUSE_CMD_WIFI_SET_RENEW = 31,
64 	RTW_EFUSE_CMD_WIFI_GET_MASK_BUF = 32,
65 	RTW_EFUSE_CMD_BT_GET_MASK_BUF = 33,
66 	RTW_EFUSE_CMD_MAX,
67 };
68 
69 struct rtw_efuse_phl_arg {
70 	u8 mp_class;
71 	u8 cmd;
72 	u8 cmd_ok;
73 	u8 status;
74 	u8 io_type;
75 	u16 io_offset;
76 	u32 io_value;
77 	u8 autoload;
78 	u8 pfile_path[200];
79 	u16 buf_len;
80 	u8 poutbuf[1536];
81 };
82 
83 enum RTW_EFUSE_MAP_STATUS {
84 	RTW_DEFAULT_MAP = 0,
85 	RTW_HW_LOG_MAP = 1,
86 	RTW_FILE_MAP = 2,
87 	RTW_EFUSE_UNKNOWN,
88 };
89 
90 #define RTW_EFUSE_FROM2STR(status)\
91 (status == RTW_DEFAULT_MAP) ? "DEFAULT" :\
92 (status == RTW_HW_LOG_MAP) ? "HW_LOG_EFUSE" :\
93 (status == RTW_FILE_MAP) ? "FILE_EFUSE" :\
94 "UNknow"
95 
96 s8 rtw_efuse_get_map_from(_adapter *padapter);
97 
98 u32 rtw_efuse_get_map_size(_adapter *padapter , u16 *size , enum rtw_efuse_phl_cmdid cmdid);
99 
100 u32 rtw_efuse_get_available_size(_adapter *padapter , u16 *size, u8 efuse_type);
101 
102 u8 rtw_efuse_map_read(_adapter * adapter, u16 addr, u16 cnts, u8 *data, u8 efuse_type);
103 
104 u8 rtw_efuse_map_write(_adapter * adapter, u16 addr, u16 cnts, u8 *data, u8 efuse_type, u8 bpg);
105 
106 int rtw_ioctl_efuse_get(struct net_device *dev,
107 				struct iw_request_info *info,
108 				union iwreq_data *wrqu, char *extra);
109 
110 int rtw_ioctl_efuse_set(struct net_device *dev,
111 				struct iw_request_info *info,
112 				union iwreq_data *wdata, char *extra);
113 
114 int rtw_ioctl_efuse_file_map_load(struct net_device *dev,
115 				struct iw_request_info *info,
116 				union iwreq_data *wrqu, char *extra);
117 
118 int rtw_ioctl_efuse_file_mask_load(struct net_device *dev,
119 				struct iw_request_info *info,
120 				union iwreq_data *wrqu, char *extra);
121 
122 int rtw_ioctl_efuse_bt_file_map_load(struct net_device *dev,
123 				struct iw_request_info *info,
124 				union iwreq_data *wrqu, char *extra);
125 
126 int rtw_ioctl_efuse_bt_file_mask_load(struct net_device *dev,
127 				struct iw_request_info *info,
128 				union iwreq_data *wrqu, char *extra);
129 
130 u8 rtw_efuse_raw_map_read(_adapter * adapter, u16 addr,
131 	            u16 cnts, u8 *data, u8 efuse_type);
132 
133 u8 rtw_efuse_bt_write_raw_hidden(_adapter * adapter, u16 addr,
134 				u16 cnts, u8 *data);
135 #endif
136 
137 #endif /*#if defined(CONFIG_MP_INCLUDED)*/
138