xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8822be/hal/hal_halmac.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2015 - 2016 Realtek Corporation. All rights reserved.
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  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef _HAL_HALMAC_H_
21 #define _HAL_HALMAC_H_
22 
23 #include <drv_types.h>		/* adapter_to_dvobj(), struct intf_hdl and etc. */
24 #include "halmac/halmac_api.h"	/* PHALMAC_ADAPTER and etc. */
25 
26 /* HALMAC Definition for Driver */
27 #define RTW_HALMAC_H2C_MAX_SIZE		HALMAC_H2C_CMD_ORIGINAL_SIZE_88XX
28 #define RTW_HALMAC_BA_SSN_RPT_SIZE	4
29 
30 #define dvobj_set_halmac(d, mac)	((d)->halmac = (mac))
31 #define dvobj_to_halmac(d)		((PHALMAC_ADAPTER)((d)->halmac))
32 #define adapter_to_halmac(p)		dvobj_to_halmac(adapter_to_dvobj(p))
33 
34 /* for H2C cmd */
35 #define MAX_H2C_BOX_NUMS 4
36 #define MESSAGE_BOX_SIZE 4
37 #define EX_MESSAGE_BOX_SIZE 4
38 
39 typedef enum _RTW_HALMAC_MODE {
40 	RTW_HALMAC_MODE_NORMAL,
41 	RTW_HALMAC_MODE_WIFI_TEST,
42 } RTW_HALMAC_MODE;
43 
44 extern HALMAC_PLATFORM_API rtw_halmac_platform_api;
45 
46 /* HALMAC API for Driver(HAL) */
47 u8 rtw_halmac_read8(struct intf_hdl *, u32 addr);
48 u16 rtw_halmac_read16(struct intf_hdl *, u32 addr);
49 u32 rtw_halmac_read32(struct intf_hdl *, u32 addr);
50 int rtw_halmac_write8(struct intf_hdl *, u32 addr, u8 value);
51 int rtw_halmac_write16(struct intf_hdl *, u32 addr, u16 value);
52 int rtw_halmac_write32(struct intf_hdl *, u32 addr, u32 value);
53 
54 int rtw_halmac_init_adapter(struct dvobj_priv *, PHALMAC_PLATFORM_API);
55 int rtw_halmac_deinit_adapter(struct dvobj_priv *);
56 int rtw_halmac_poweron(struct dvobj_priv *);
57 int rtw_halmac_poweroff(struct dvobj_priv *);
58 int rtw_halmac_init_hal(struct dvobj_priv *);
59 int rtw_halmac_init_hal_fw(struct dvobj_priv *, u8 *fw, u32 fwsize);
60 int rtw_halmac_init_hal_fw_file(struct dvobj_priv *, u8 *fwpath);
61 int rtw_halmac_deinit_hal(struct dvobj_priv *);
62 int rtw_halmac_self_verify(struct dvobj_priv *);
63 int rtw_halmac_dlfw(struct dvobj_priv *, u8 *fw, u32 fwsize);
64 int rtw_halmac_dlfw_from_file(struct dvobj_priv *, u8 *fwpath);
65 int rtw_halmac_phy_power_switch(struct dvobj_priv *, u8 enable);
66 int rtw_halmac_send_h2c(struct dvobj_priv *, u8 *h2c);
67 int rtw_halmac_c2h_handle(struct dvobj_priv *, u8 *c2h, u32 size);
68 int rtw_halmac_get_available_efuse_size(struct dvobj_priv *d, u32 *size);
69 
70 int rtw_halmac_get_physical_efuse_size(struct dvobj_priv *, u32 *size);
71 int rtw_halmac_read_physical_efuse_map(struct dvobj_priv *, u8 *map, u32 size);
72 int rtw_halmac_read_physical_efuse(struct dvobj_priv *, u32 offset, u32 cnt, u8 *data);
73 int rtw_halmac_write_physical_efuse(struct dvobj_priv *, u32 offset, u32 cnt, u8 *data);
74 int rtw_halmac_get_logical_efuse_size(struct dvobj_priv *, u32 *size);
75 int rtw_halmac_read_logical_efuse_map(struct dvobj_priv *, u8 *map, u32 size);
76 int rtw_halmac_write_logical_efuse_map(struct dvobj_priv *, u8 *map, u32 size, u8 *maskmap, u32 masksize);
77 int rtw_halmac_read_logical_efuse(struct dvobj_priv *, u32 offset, u32 cnt, u8 *data);
78 int rtw_halmac_write_logical_efuse(struct dvobj_priv *, u32 offset, u32 cnt, u8 *data);
79 
80 int rtw_halmac_write_bt_physical_efuse(struct dvobj_priv *, u32 offset, u32 cnt, u8 *data);
81 int rtw_halmac_read_bt_physical_efuse_map(struct dvobj_priv *, u8 *map, u32 size);
82 
83 int rtw_halmac_config_rx_info(struct dvobj_priv *, HALMAC_DRV_INFO);
84 int rtw_halmac_set_mac_address(struct dvobj_priv *, enum _hw_port, u8 *addr);
85 int rtw_halmac_set_bssid(struct dvobj_priv *d, enum _hw_port hwport, u8 *addr);
86 
87 int rtw_halmac_set_bandwidth(struct dvobj_priv *, u8 channel, u8 pri_ch_idx, u8 bw);
88 int rtw_halmac_rx_agg_switch(struct dvobj_priv *, u8 enable);
89 int rtw_halmac_get_hw_value(struct dvobj_priv *d, HALMAC_HW_ID hw_id, VOID *pvalue);
90 
91 int rtw_halmac_get_wow_reason(struct dvobj_priv *, u8 *reason);
92 int rtw_halmac_get_drv_info_sz(struct dvobj_priv *d, u8 *sz);
93 
94 int rtw_halmac_get_rsvd_drv_pg_bndy(struct dvobj_priv *dvobj, u16 *drv_pg);
95 int rtw_halmac_download_rsvd_page(struct dvobj_priv *dvobj, u16 page_idx, u8 *pbuf, u8 length);
96 
97 #ifdef CONFIG_SDIO_HCI
98 int rtw_halmac_query_tx_page_num(struct dvobj_priv *);
99 int rtw_halmac_get_tx_queue_page_num(struct dvobj_priv *, u8 queue, u32 *page);
100 u32 rtw_halmac_sdio_get_tx_addr(struct dvobj_priv *, u8 *desc, u32 size);
101 int rtw_halmac_sdio_tx_allowed(struct dvobj_priv *, u8 *buf, u32 size);
102 u32 rtw_halmac_sdio_get_rx_addr(struct dvobj_priv *, u8 *seq);
103 #endif /* CONFIG_SDIO_HCI */
104 
105 #ifdef CONFIG_USB_HCI
106 u8 rtw_halmac_usb_get_bulkout_id(struct dvobj_priv *, u8 *buf, u32 size);
107 u8 rtw_halmac_switch_usb_mode(struct dvobj_priv *d, enum RTW_USB_SPEED usb_mode);
108 #endif /* CONFIG_USB_HCI */
109 
110 #endif /* _HAL_HALMAC_H_ */
111