GNU Linux-libre 4.14.303-gnu1
[releases.git] / drivers / staging / ks7010 / ks7010_sdio.h
1 /*
2  *   Driver for KeyStream, KS7010 based SDIO cards.
3  *
4  *   Copyright (C) 2006-2008 KeyStream Corp.
5  *   Copyright (C) 2009 Renesas Technology Corp.
6  *
7  *   This program is free software; you can redistribute it and/or modify
8  *   it under the terms of the GNU General Public License version 2 as
9  *   published by the Free Software Foundation.
10  */
11 #ifndef _KS7010_SDIO_H
12 #define _KS7010_SDIO_H
13
14 #ifdef  DEVICE_ALIGNMENT
15 #undef  DEVICE_ALIGNMENT
16 #endif
17 #define DEVICE_ALIGNMENT 32
18
19 /*  SDIO KeyStream vendor and device */
20 #define SDIO_VENDOR_ID_KS_CODE_A        0x005b
21 #define SDIO_VENDOR_ID_KS_CODE_B        0x0023
22 /* Older sources suggest earlier versions were named 7910 or 79xx */
23 #define SDIO_DEVICE_ID_KS_7010          0x7910
24
25 /* Read/Write Status Register */
26 #define READ_STATUS             0x000000
27 #define WRITE_STATUS            0x00000C
28 enum reg_status_type {
29         REG_STATUS_BUSY,
30         REG_STATUS_IDLE
31 };
32
33 /* Read Index Register */
34 #define READ_INDEX              0x000004
35
36 /* Read Data Size Register */
37 #define READ_DATA_SIZE          0x000008
38
39 /* Write Index Register */
40 #define WRITE_INDEX             0x000010
41
42 /* Write Status/Read Data Size Register
43  * for network packet (less than 2048 bytes data)
44  */
45 #define WSTATUS_RSIZE           0x000014
46 #define WSTATUS_MASK            0x80    /* Write Status Register value */
47 #define RSIZE_MASK              0x7F    /* Read Data Size Register value [10:4] */
48
49 /* ARM to SD interrupt Enable */
50 #define INT_ENABLE              0x000020
51 /* ARM to SD interrupt Pending */
52 #define INT_PENDING             0x000024
53
54 #define INT_GCR_B              BIT(7)
55 #define INT_GCR_A              BIT(6)
56 #define INT_WRITE_STATUS       BIT(5)
57 #define INT_WRITE_INDEX        BIT(4)
58 #define INT_WRITE_SIZE         BIT(3)
59 #define INT_READ_STATUS        BIT(2)
60 #define INT_READ_INDEX         BIT(1)
61 #define INT_READ_SIZE          BIT(0)
62
63 /* General Communication Register A */
64 #define GCR_A                   0x000028
65 enum gen_com_reg_a {
66         GCR_A_INIT,
67         GCR_A_REMAP,
68         GCR_A_RUN
69 };
70
71 /* General Communication Register B */
72 #define GCR_B                   0x00002C
73 enum gen_com_reg_b {
74         GCR_B_ACTIVE,
75         GCR_B_DOZE
76 };
77
78 /* Wakeup Register */
79 #define WAKEUP                  0x008018
80 #define WAKEUP_REQ              0x5a
81
82 /* AHB Data Window  0x010000-0x01FFFF */
83 #define DATA_WINDOW             0x010000
84 #define WINDOW_SIZE             (64 * 1024)
85
86 #define KS7010_IRAM_ADDRESS     0x06000000
87
88 /**
89  * struct ks_sdio_card - SDIO device data.
90  *
91  * Structure is used as the &struct sdio_func private data.
92  *
93  * @func: Pointer to the SDIO function device.
94  * @priv: Pointer to the &struct net_device private data.
95  */
96 struct ks_sdio_card {
97         struct sdio_func *func;
98         struct ks_wlan_private *priv;
99 };
100
101 /* Tx Device struct */
102 #define TX_DEVICE_BUFF_SIZE     1024
103
104 /**
105  * struct tx_device_buffer - Queue item for the tx queue.
106  * @sendp: Pointer to the send request data.
107  * @size: Size of @sendp data.
108  * @complete_handler: Function called once data write to device is complete.
109  * @arg1: First argument to @complete_handler.
110  * @arg2: Second argument to @complete_handler.
111  */
112 struct tx_device_buffer {
113         unsigned char *sendp;
114         unsigned int size;
115         void (*complete_handler)(struct ks_wlan_private *priv,
116                                  struct sk_buff *skb);
117         struct sk_buff *skb;
118 };
119
120 /**
121  * struct tx_device - Tx buffer queue.
122  * @tx_device_buffer: Queue buffer.
123  * @qhead: Head of tx queue.
124  * @qtail: Tail of tx queue.
125  * @tx_dev_lock: Queue lock.
126  */
127 struct tx_device {
128         struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE];
129         unsigned int qhead;
130         unsigned int qtail;
131         spinlock_t tx_dev_lock; /* protect access to the queue */
132 };
133
134 /* Rx Device struct */
135 #define RX_DATA_SIZE    (2 + 2 + 2347 + 1)
136 #define RX_DEVICE_BUFF_SIZE     32
137
138 /**
139  * struct rx_device_buffer - Queue item for the rx queue.
140  * @data: rx data.
141  * @size: Size of @data.
142  */
143 struct rx_device_buffer {
144         unsigned char data[RX_DATA_SIZE];
145         unsigned int size;
146 };
147
148 /**
149  * struct rx_device - Rx buffer queue.
150  * @rx_device_buffer: Queue buffer.
151  * @qhead: Head of rx queue.
152  * @qtail: Tail of rx queue.
153  * @rx_dev_lock: Queue lock.
154  */
155 struct rx_device {
156         struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE];
157         unsigned int qhead;
158         unsigned int qtail;
159         spinlock_t rx_dev_lock; /* protect access to the queue */
160 };
161
162 #define ROM_FILE "/*(DEBLOBBED)*/"
163
164 #endif /* _KS7010_SDIO_H */