e71c0978986a136231ea8dfcc8d31784587e9119
[cascardo/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 Status Register */
26 #define READ_STATUS             0x000000
27 #define READ_STATUS_BUSY        0
28 #define READ_STATUS_IDLE        1
29
30 /* Read Index Register */
31 #define READ_INDEX              0x000004
32
33 /* Read Data Size Register */
34 #define READ_DATA_SIZE          0x000008
35
36 /* Write Status Register */
37 #define WRITE_STATUS            0x00000C
38 #define WRITE_STATUS_BUSY       0
39 #define WRITE_STATUS_IDLE       1
40
41 /* Write Index Register */
42 #define WRITE_INDEX             0x000010
43
44 /* Write Status/Read Data Size Register 
45  * for network packet (less than 2048 bytes data)
46  */
47 #define WSTATUS_RSIZE           0x000014
48 #define WSTATUS_MASK            0x80    /* Write Status Register value */
49 #define RSIZE_MASK              0x7F    /* Read Data Size Register value [10:4] */
50
51 /* ARM to SD interrupt Enable */
52 #define INT_ENABLE              0x000020
53 /* ARM to SD interrupt Pending */
54 #define INT_PENDING             0x000024
55
56 #define INT_GCR_B               (1<<7)
57 #define INT_GCR_A               (1<<6)
58 #define INT_WRITE_STATUS        (1<<5)
59 #define INT_WRITE_INDEX         (1<<4)
60 #define INT_WRITE_SIZE          (1<<3)
61 #define INT_READ_STATUS         (1<<2)
62 #define INT_READ_INDEX          (1<<1)
63 #define INT_READ_SIZE           (1<<0)
64
65 /* General Communication Register A */
66 #define GCR_A                   0x000028
67 #define GCR_A_INIT              0
68 #define GCR_A_REMAP             1
69 #define GCR_A_RUN               2
70
71 /* General Communication Register B */
72 #define GCR_B                   0x00002C
73 #define GCR_B_ACTIVE            0
74 #define GCR_B_DOZE              1
75
76 /* Wakeup Register */
77 /* #define WAKEUP                       0x008104 */
78 /* #define WAKEUP_REQ           0x00 */
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 define
90  */
91 struct hw_info_t {
92         struct ks_sdio_card *sdio_card;
93         struct completion ks7010_sdio_wait;
94         struct workqueue_struct *ks7010sdio_wq;
95         struct delayed_work rw_wq;
96         unsigned char *read_buf;
97         struct tasklet_struct rx_bh_task;
98 };
99
100 struct ks_sdio_packet {
101         struct ks_sdio_packet *next;
102         u16 nb;
103         u8 buffer[0] __attribute__ ((aligned(4)));
104 };
105
106 struct ks_sdio_card {
107         struct sdio_func *func;
108         struct ks_wlan_private *priv;
109         spinlock_t lock;
110 };
111
112 /* Tx Device struct */
113 #define TX_DEVICE_BUFF_SIZE     1024
114
115 struct tx_device_buffer {
116         unsigned char *sendp;   /* pointer of send req data */
117         unsigned int size;
118         void (*complete_handler) (void *arg1, void *arg2);
119         void *arg1;
120         void *arg2;
121 };
122
123 struct tx_device {
124         struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE];
125         unsigned int qhead;     /* tx buffer queue first pointer */
126         unsigned int qtail;     /* tx buffer queue last pointer */
127         spinlock_t tx_dev_lock;
128 };
129
130 /* Rx Device struct */
131 #define RX_DATA_SIZE    (2 + 2 + 2347 + 1)
132 #define RX_DEVICE_BUFF_SIZE     32
133
134 struct rx_device_buffer {
135         unsigned char data[RX_DATA_SIZE];
136         unsigned int size;
137 };
138
139 struct rx_device {
140         struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE];
141         unsigned int qhead;     /* rx buffer queue first pointer */
142         unsigned int qtail;     /* rx buffer queue last pointer */
143         spinlock_t rx_dev_lock;
144 };
145 #define ROM_FILE "ks7010sd.rom"
146 #define KS_WLAN_DRIVER_VERSION_INFO  "ks7010 sdio linux 007"
147
148 #endif /* _KS7010_SDIO_H */