net:wireless:Support eswin usb wifi ECR6600U
[platform/kernel/linux-starfive.git] / drivers / net / wireless / eswin / sdio / sdio.h
1 /**
2  ******************************************************************************
3  *
4  * @file sdio.h
5  *
6  * @brief sdio driver definitions
7  *
8  * Copyright (C) ESWIN 2015-2020
9  *
10  ******************************************************************************
11  */
12
13 #ifndef __SDIO_H
14 #define __SDIO_H
15
16 #include "ecrnx_defs.h"
17 #include "core.h"
18
19 #define ESWIN_SDIO_VENDER       0x0296
20 #define ESWIN_SDIO_DEVICE       0x5347
21
22 #define ESWIN_SDIO_BLK_SIZE     512
23
24 #define TX_SLOT 0
25 #define RX_SLOT 1
26
27 #define CREDIT_QUEUE_MAX (12)
28
29
30 #define TCN  (3*2)
31 #define TCNE (0)
32
33 #define CREDIT_AC0      4//(TCN*4+TCNE) /* BK */
34 #define CREDIT_AC1      30//(TCN*3+TCNE)        /* BE */
35 #define CREDIT_AC2      4//(TCN*2+TCNE) /* VI */
36 #define CREDIT_AC3      4//(TCN*1+TCNE) /* VO */
37
38 struct sdio_sys_reg {
39         u8 wakeup;      /* 0x0 */
40         u8 status;      /* 0x1 */
41         u16 chip_id;    /* 0x2-0x3 */
42         u32 modem_id;   /* 0x4-0x7 */
43         u32 sw_id;      /* 0x8-0xb */
44         u32 board_id;   /* 0xc-0xf */
45 } __packed;
46
47 struct sdio_status_reg {
48         struct {
49                 u8 mode;
50                 u8 enable;
51                 u8 latched_status;
52                 u8 status;
53         } eirq;
54         u8 txq_status[6];
55         u8 rxq_status[6];
56         u32 msg[4];
57
58 #define EIRQ_IO_ENABLE  (1<<2)
59 #define EIRQ_EDGE       (1<<1)
60 #define EIRQ_ACTIVE_LO  (1<<0)
61
62 #define EIRQ_DEV_SLEEP  (1<<3)
63 #define EIRQ_DEV_READY  (1<<2)
64 #define EIRQ_RXQ        (1<<1)
65 #define EIRQ_TXQ        (1<<0)
66
67 #define TXQ_ERROR       (1<<7)
68 #define TXQ_SLOT_COUNT  (0x7F)
69 #define RXQ_SLOT_COUNT  (0x7F)
70
71 } __packed;
72
73 struct sdio_rx_head_t {
74         unsigned int      next_rx_len;
75         unsigned short    data_len;
76         unsigned short    avl_len;
77 };
78
79 struct sdio_data_t {
80         unsigned int      credit_vif0;
81         unsigned int      credit_vif1;
82         unsigned int      info_wr;
83         unsigned int      info_rd;
84 };
85
86 struct eswin_sdio {
87         struct eswin * tr;
88         struct sdio_func   *func;
89         struct sdio_func   *func2;
90
91         /* work, kthread, ... */
92         struct delayed_work work;
93         struct task_struct *kthread;
94         wait_queue_head_t wait; /* wait queue */
95
96         struct task_struct *kthread_unpack;
97         wait_queue_head_t wait_unpack;
98
99         struct {
100                 struct sdio_sys_reg    sys;
101                 struct sdio_status_reg status;
102         } hw;
103
104         spinlock_t lock;
105         struct {
106                 unsigned int head;
107                 unsigned int tail;
108                 unsigned int size;
109                 unsigned int count;
110         } slot[2];
111         /* VIF0(AC0~AC3), BCN, CONC, VIF1(AC0~AC3), padding*/
112         u8 front[CREDIT_QUEUE_MAX];
113         u8 rear[CREDIT_QUEUE_MAX];
114         u8 credit_max[CREDIT_QUEUE_MAX];
115
116 /*
117         unsigned long loopback_prev_cnt;
118         unsigned long loopback_total_cnt;
119         unsigned long loopback_last_jiffies;
120         unsigned long loopback_read_usec;
121         unsigned long loopback_write_usec;
122         unsigned long loopback_measure_cnt;
123 */
124         //struct eswin_sdio_ops_t *ops;
125         unsigned int              recv_len;
126         unsigned int              recv_num;
127 //      struct dentry *debugfs;
128
129         unsigned int      credit_vif0;
130         unsigned int      credit_vif1;
131         
132         struct sdio_data_t sdio_info;
133         unsigned int      slave_avl_buf;
134     atomic_t          slave_buf_suspend;
135         unsigned int      curr_tx_size;
136         unsigned int      next_rx_size;
137 //      struct sk_buff  *skb_tx_last;
138
139         struct sk_buff_head skb_rx_list;
140         //struct sk_buff_head *skb_rx_unpack_list;
141
142 };
143
144 struct sdio_ops {
145         int (*start)(struct eswin *tr);
146         int (*xmit)(struct eswin *tr, struct tx_buff_pkg_node * node);
147         int (*suspend)(struct eswin *tr);
148         int (*resume)(struct eswin *tr);
149         int (*write)(struct eswin *tr, const void* data, const u32 len);
150         int (*wait_ack)(struct eswin *tr);
151 };
152
153 extern int ecrnx_sdio_register_drv(void);
154 extern void ecrnx_sdio_unregister_drv(void);
155
156 #endif /* __SDIO_H */