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.
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.
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
21 #include <linux/types.h>
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
29 * For that reason, we are using byte offsets for control registers and word
30 * offsets for everything else.
33 typedef u32 __nocast zd_addr_t
;
36 ADDR_BASE_MASK
= 0xff000000,
37 ADDR_OFFSET_MASK
= 0x0000ffff,
38 ADDR_ZERO_MASK
= 0x00ff0000,
39 NULL_BASE
= 0x00000000,
40 USB_BASE
= 0x01000000,
42 CR_MAX_OFFSET
= 0x0b30,
43 E2P_BASE
= 0x03000000,
44 E2P_MAX_OFFSET
= 0x007e,
46 FW_MAX_OFFSET
= 0x0005,
49 #define ZD_ADDR_BASE(addr) ((u32)(addr) & ADDR_BASE_MASK)
50 #define ZD_OFFSET(addr) ((u32)(addr) & ADDR_OFFSET_MASK)
52 #define ZD_ADDR(base, offset) \
53 ((zd_addr_t)(((base) & ADDR_BASE_MASK) | ((offset) & ADDR_OFFSET_MASK)))
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 */
61 static inline zd_addr_t
zd_inc_word(zd_addr_t addr
)
63 u32 base
= ZD_ADDR_BASE(addr
);
64 u32 offset
= ZD_OFFSET(addr
);
66 offset
+= base
== CR_BASE
? 2 : 1;
71 #endif /* _ZD_TYPES_H */