b3d642833e2cf22dfd5739527c3d2ed6ab085ab1
[deliverable/linux.git] / drivers / net / wireless / zd1211rw / zd_types.h
1 /* zd_types.h
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18 #ifndef _ZD_TYPES_H
19 #define _ZD_TYPES_H
20
21 #include <linux/types.h>
22
23 /* We have three register spaces mapped into the overall USB address space of
24 * 64K words (16-bit values). There is the control register space of
25 * double-word registers, the eeprom register space and the firmware register
26 * space. The control register space is byte mapped, the others are word
27 * mapped.
28 *
29 * For that reason, we are using byte offsets for control registers and word
30 * offsets for everything else.
31 */
32
33 typedef u32 __nocast zd_addr_t;
34
35 enum {
36 ADDR_BASE_MASK = 0xff000000,
37 ADDR_OFFSET_MASK = 0x0000ffff,
38 ADDR_ZERO_MASK = 0x00ff0000,
39 NULL_BASE = 0x00000000,
40 USB_BASE = 0x01000000,
41 CR_BASE = 0x02000000,
42 CR_MAX_OFFSET = 0x0b30,
43 E2P_BASE = 0x03000000,
44 E2P_MAX_OFFSET = 0x007e,
45 FW_BASE = 0x04000000,
46 FW_MAX_OFFSET = 0x0005,
47 };
48
49 #define ZD_ADDR_BASE(addr) ((u32)(addr) & ADDR_BASE_MASK)
50 #define ZD_OFFSET(addr) ((u32)(addr) & ADDR_OFFSET_MASK)
51
52 #define ZD_ADDR(base, offset) \
53 ((zd_addr_t)(((base) & ADDR_BASE_MASK) | ((offset) & ADDR_OFFSET_MASK)))
54
55 #define ZD_NULL_ADDR ((zd_addr_t)0)
56 #define USB_REG(offset) ZD_ADDR(USB_BASE, offset) /* word addressing */
57 #define CTL_REG(offset) ZD_ADDR(CR_BASE, offset) /* byte addressing */
58 #define E2P_DATA(offset) ZD_ADDR(E2P_BASE, offset) /* word addressing */
59 #define FW_REG(offset) ZD_ADDR(FW_BASE, offset) /* word addressing */
60
61 static inline zd_addr_t zd_inc_word(zd_addr_t addr)
62 {
63 u32 base = ZD_ADDR_BASE(addr);
64 u32 offset = ZD_OFFSET(addr);
65
66 offset += base == CR_BASE ? 2 : 1;
67
68 return base | offset;
69 }
70
71 #endif /* _ZD_TYPES_H */
This page took 0.0345 seconds and 4 git commands to generate.