xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/ssv6xxx/hci/ssv_hci.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (c) 2015 South Silicon Valley Microelectronics Inc.
3  * Copyright (c) 2015 iComm Corporation
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef _SSV_HCI_H_
18 #define _SSV_HCI_H_
19 #define SSV_HW_TXQ_NUM 5
20 #define SSV_HW_TXQ_MAX_SIZE 64
21 #define SSV_HW_TXQ_RESUME_THRES ((SSV_HW_TXQ_MAX_SIZE >> 2) *3)
22 #define HCI_FLAGS_ENQUEUE_HEAD 0x00000001
23 #define HCI_FLAGS_NO_FLOWCTRL 0x00000002
24 struct ssv_hw_txq {
25     u32 txq_no;
26     struct sk_buff_head qhead;
27     int max_qsize;
28     int resum_thres;
29     bool paused;
30     u32 tx_pkt;
31     u32 tx_flags;
32 };
33 struct ssv6xxx_hci_ops {
34     int (*hci_start)(void);
35     int (*hci_stop)(void);
36     int (*hci_read_word)(u32 addr, u32 *regval);
37     int (*hci_write_word)(u32 addr, u32 regval);
38     int (*hci_load_fw)(u8 *firmware_name, u8 openfile);
39     int (*hci_tx)(struct sk_buff *, int, u32);
40 #if 0
41     int (*hci_rx)(struct sk_buff *);
42 #endif
43     int (*hci_tx_pause)(u32 txq_mask);
44     int (*hci_tx_resume)(u32 txq_mask);
45     int (*hci_txq_flush)(u32 txq_mask);
46     int (*hci_txq_flush_by_sta)(int aid);
47     bool (*hci_txq_empty)(int txqid);
48     int (*hci_pmu_wakeup)(void);
49     int (*hci_send_cmd)(struct sk_buff *);
50 #ifdef CONFIG_SSV6XXX_DEBUGFS
51     bool (*hci_init_debugfs)(struct dentry *dev_deugfs_dir);
52     void (*hci_deinit_debugfs)(void);
53 #endif
54     int (*hci_write_sram)(u32 addr, u8* data, u32 size);
55     int (*hci_interface_reset)(void);
56 };
57 struct ssv6xxx_hci_info {
58     struct device *dev;
59     struct ssv6xxx_hwif_ops *if_ops;
60     struct ssv6xxx_hci_ops *hci_ops;
61     #if !defined(USE_THREAD_RX) || defined(USE_BATCH_RX)
62     int (*hci_rx_cb)(struct sk_buff_head *, void *);
63     #else
64     int (*hci_rx_cb)(struct sk_buff *, void *);
65     #endif
66     void *rx_cb_args;
67     void (*hci_tx_cb)(struct sk_buff_head *, void *);
68     void *tx_cb_args;
69     int (*hci_tx_flow_ctrl_cb)(void *, int, bool, int debug);
70     void *tx_fctrl_cb_args;
71     void (*hci_tx_buf_free_cb)(struct sk_buff *, void *);
72     void *tx_buf_free_args;
73     void (*hci_skb_update_cb)(struct sk_buff *, void *);
74     void *skb_update_args;
75     void (*hci_tx_q_empty_cb)(u32 txq_no, void *);
76     void *tx_q_empty_args;
77 };
78 int ssv6xxx_hci_deregister(void);
79 int ssv6xxx_hci_register(struct ssv6xxx_hci_info *);
80 #endif
81