summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/eswin/sdio/sdio.h
blob: 6dde7c1e546d92070c86388b686a0c7660e06ad4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/**
 ******************************************************************************
 *
 * @file sdio.h
 *
 * @brief sdio driver definitions
 *
 * Copyright (C) ESWIN 2015-2020
 *
 ******************************************************************************
 */

#ifndef __SDIO_H
#define __SDIO_H

#include "ecrnx_defs.h"
#include "core.h"

#define	ESWIN_SDIO_VENDER	0x0296
#define	ESWIN_SDIO_DEVICE	0x5347

#define	ESWIN_SDIO_BLK_SIZE 	512

#define TX_SLOT 0
#define RX_SLOT 1

#define CREDIT_QUEUE_MAX (12)


#define TCN  (3*2)
#define TCNE (0)

#define CREDIT_AC0	4//(TCN*4+TCNE)	/* BK */
#define CREDIT_AC1	30//(TCN*3+TCNE)	/* BE */
#define CREDIT_AC2	4//(TCN*2+TCNE)	/* VI */
#define CREDIT_AC3	4//(TCN*1+TCNE)	/* VO */

struct sdio_sys_reg {
	u8 wakeup;	/* 0x0 */
	u8 status;	/* 0x1 */
	u16 chip_id;	/* 0x2-0x3 */
	u32 modem_id;	/* 0x4-0x7 */
	u32 sw_id;	/* 0x8-0xb */
	u32 board_id;	/* 0xc-0xf */
} __packed;

struct sdio_status_reg {
	struct {
		u8 mode;
		u8 enable;
		u8 latched_status;
		u8 status;
	} eirq;
	u8 txq_status[6];
	u8 rxq_status[6];
	u32 msg[4];

#define EIRQ_IO_ENABLE	(1<<2)
#define EIRQ_EDGE	(1<<1)
#define EIRQ_ACTIVE_LO	(1<<0)

#define EIRQ_DEV_SLEEP	(1<<3)
#define EIRQ_DEV_READY	(1<<2)
#define EIRQ_RXQ	(1<<1)
#define EIRQ_TXQ	(1<<0)

#define TXQ_ERROR	(1<<7)
#define TXQ_SLOT_COUNT	(0x7F)
#define RXQ_SLOT_COUNT	(0x7F)

} __packed;

struct sdio_rx_head_t {
	unsigned int	  next_rx_len;
	unsigned short	  data_len;
	unsigned short	  avl_len;
};

struct sdio_data_t {
	unsigned int	  credit_vif0;
	unsigned int	  credit_vif1;
	unsigned int	  info_wr;
	unsigned int	  info_rd;
};

struct eswin_sdio {
	struct eswin * tr;
	struct sdio_func   *func;
	struct sdio_func   *func2;

	/* work, kthread, ... */
	struct delayed_work work;
	struct task_struct *kthread;
	wait_queue_head_t wait; /* wait queue */

	struct task_struct *kthread_unpack;
	wait_queue_head_t wait_unpack;

	struct {
		struct sdio_sys_reg    sys;
		struct sdio_status_reg status;
	} hw;

	spinlock_t lock;
	struct {
		unsigned int head;
		unsigned int tail;
		unsigned int size;
		unsigned int count;
	} slot[2];
	/* VIF0(AC0~AC3), BCN, CONC, VIF1(AC0~AC3), padding*/
	u8 front[CREDIT_QUEUE_MAX];
	u8 rear[CREDIT_QUEUE_MAX];
	u8 credit_max[CREDIT_QUEUE_MAX];

/*
	unsigned long loopback_prev_cnt;
	unsigned long loopback_total_cnt;
	unsigned long loopback_last_jiffies;
	unsigned long loopback_read_usec;
	unsigned long loopback_write_usec;
	unsigned long loopback_measure_cnt;
*/
	//struct eswin_sdio_ops_t *ops;
	unsigned int	          recv_len;
	unsigned int	          recv_num;
//	struct dentry *debugfs;

	unsigned int	  credit_vif0;
	unsigned int	  credit_vif1;
	
	struct sdio_data_t sdio_info;
	unsigned int	  slave_avl_buf;
    atomic_t          slave_buf_suspend;
	unsigned int	  curr_tx_size;
	unsigned int	  next_rx_size;
//	struct sk_buff  *skb_tx_last;

	struct sk_buff_head skb_rx_list;
	//struct sk_buff_head *skb_rx_unpack_list;

};

struct sdio_ops {
	int (*start)(struct eswin *tr);
	int (*xmit)(struct eswin *tr, struct tx_buff_pkg_node * node);
	int (*suspend)(struct eswin *tr);
	int (*resume)(struct eswin *tr);
	int (*write)(struct eswin *tr, const void* data, const u32 len);
	int (*wait_ack)(struct eswin *tr);
};

extern int ecrnx_sdio_register_drv(void);
extern void ecrnx_sdio_unregister_drv(void);

#endif /* __SDIO_H */