]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/staging/ks7010/ks7010_sdio.h
22c7ba7981041b3ba6d34594552f8393d5fff7b2
[linux.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 struct ks_sdio_card {
89         struct sdio_func *func;
90         struct ks_wlan_private *priv;
91 };
92
93 /* Tx Device struct */
94 #define TX_DEVICE_BUFF_SIZE     1024
95
96 /**
97  * struct tx_device_buffer - Queue item for the tx queue.
98  * @sendp: Pointer to the send request data.
99  * @size: Size of @sendp data.
100  * @complete_handler: Function called once data write to device is complete.
101  * @arg1: First argument to @complete_handler.
102  * @arg2: Second argument to @complete_handler.
103  */
104 struct tx_device_buffer {
105         unsigned char *sendp;
106         unsigned int size;
107         void (*complete_handler)(struct ks_wlan_private *priv,
108                                  struct sk_buff *skb);
109         struct sk_buff *skb;
110 };
111
112 /**
113  * struct tx_device - Tx buffer queue.
114  * @tx_device_buffer: Queue buffer.
115  * @qhead: Head of tx queue.
116  * @qtail: Tail of tx queue.
117  * @tx_dev_lock: Queue lock.
118  */
119 struct tx_device {
120         struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE];
121         unsigned int qhead;
122         unsigned int qtail;
123         spinlock_t tx_dev_lock; /* protect access to the queue */
124 };
125
126 /* Rx Device struct */
127 #define RX_DATA_SIZE    (2 + 2 + 2347 + 1)
128 #define RX_DEVICE_BUFF_SIZE     32
129
130 /**
131  * struct rx_device_buffer - Queue item for the rx queue.
132  * @data: rx data.
133  * @size: Size of @data.
134  */
135 struct rx_device_buffer {
136         unsigned char data[RX_DATA_SIZE];
137         unsigned int size;
138 };
139
140 /**
141  * struct rx_device - Rx buffer queue.
142  * @rx_device_buffer: Queue buffer.
143  * @qhead: Head of rx queue.
144  * @qtail: Tail of rx queue.
145  * @rx_dev_lock: Queue lock.
146  */
147 struct rx_device {
148         struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE];
149         unsigned int qhead;
150         unsigned int qtail;
151         spinlock_t rx_dev_lock; /* protect access to the queue */
152 };
153
154 #define ROM_FILE "ks7010sd.rom"
155
156 #endif /* _KS7010_SDIO_H */