xref: /openbsd/sys/dev/usb/uowreg.h (revision 09467b48)
1 /*	$OpenBSD: uowreg.h,v 1.5 2006/10/08 20:04:23 grange Exp $	*/
2 
3 /*
4  * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef _DEV_USB_UOWREG_H_
20 #define _DEV_USB_UOWREG_H_
21 
22 /*
23  * Maxim/Dallas DS2490 USB 1-Wire adapter register definitions.
24  */
25 
26 /* USB core interface */
27 #define DS2490_USB_CONFIG	1	/* configuration */
28 #define DS2490_USB_IFACE	0	/* interface */
29 
30 /* Command type codes */
31 #define DS2490_CONTROL_CMD	0x00	/* control */
32 #define DS2490_COMM_CMD		0x01	/* communication */
33 #define DS2490_MODE_CMD		0x02	/* mode */
34 
35 /* Control command codes */
36 #define DS2490_CTL_RESET_DEVICE		0x0000
37 #define DS2490_CTL_START_EXE		0x0001
38 #define DS2490_CTL_RESUME_EXE		0x0002
39 #define DS2490_CTL_HALT_EXE_IDLE	0x0003
40 #define DS2490_CTL_HALT_EXE_DONE	0x0004
41 #define DS2490_CTL_FLUSH_COMM_CMDS	0x0007
42 #define DS2490_CTL_FLUSH_RCV_BUFFER	0x0008
43 #define DS2490_CTL_FLUSH_XMT_BUFFER	0x0009
44 #define DS2490_CTL_GET_COMM_CMDS	0x000a
45 
46 /* Communication command codes */
47 #define DS2490_COMM_SET_DURATION	0x0012
48 #define DS2490_COMM_PULSE		0x0030
49 #define DS2490_COMM_1WIRE_RESET		0x0042
50 #define DS2490_COMM_BIT_IO		0x0020
51 #define DS2490_COMM_BYTE_IO		0x0052
52 #define DS2490_COMM_BLOCK_IO		0x0074
53 #define DS2490_COMM_MATCH_ACCESS	0x0064
54 #define DS2490_COMM_READ_STRAIGHT	0x0080
55 #define DS2490_COMM_DO_RELEASE		0x6092
56 #define DS2490_COMM_SET_PATH		0x00a2
57 #define DS2490_COMM_WRITE_SRAM_PAGE	0x00b2
58 #define DS2490_COMM_WRITE_EPROM		0x00c4
59 #define DS2490_COMM_READ_CRC_PROT_PAGE	0x00d4
60 #define DS2490_COMM_READ_REDIR_PAGE_CRC	0x21e4
61 #define DS2490_COMM_SEARCH_ACCESS	0x00f4
62 
63 /* Communication command embedded command parameter bits */
64 #define DS2490_BIT_IM			(1 << 0)
65 #define DS2490_BIT_D			(1 << 3)
66 #define DS2490_BIT_CH			(1 << 3)
67 #define DS2490_BIT_R			(1 << 3)
68 #define DS2490_BIT_SE			(1 << 3)
69 #define DS2490_BIT_SM			(1 << 3)
70 #define DS2490_BIT_TYPE			(1 << 3)
71 #define DS2490_BIT_Z			(1 << 3)
72 #define DS2490_BIT_RST			(1 << 8)
73 #define DS2490_BIT_ICP			(1 << 9)
74 #define DS2490_BIT_NTF			(1 << 10)
75 #define DS2490_BIT_F			(1 << 11)
76 #define DS2490_BIT_SPU			(1 << 12)
77 #define DS2490_BIT_DT			(1 << 13)
78 #define DS2490_BIT_CIB			(1 << 14)
79 #define DS2490_BIT_PS			(1 << 14)
80 #define DS2490_BIT_PST			(1 << 14)
81 #define DS2490_BIT_RTS			(1 << 14)
82 
83 /* Mode command codes */
84 #define DS2490_MOD_PULSE_EN		0x0000
85 #define DS2490_MOD_SPEED_CHANGE_EN	0x0001
86 #define DS2490_MOD_1WIRE_SPEED		0x0002
87 #define DS2490_MOD_STRONG_PU_DURATION	0x0003
88 #define DS2490_MOD_PULLDOWN_SLEWRATE	0x0004
89 #define DS2490_MOD_PROG_PULSE_DURATION	0x0005
90 #define DS2490_MOD_WRITE1_LOWTIME	0x0006
91 #define DS2490_MOD_DSOW0_TREC		0x0007
92 
93 /* State registers */
94 #define DS2490_ST_BEGIN		0x00
95 #define DS2490_ST_ENFL		0x00	/* enabled flags */
96 #define DS2490_ST_ENFL_SPUE		(1 << 0)	/* strong pullup */
97 #define DS2490_ST_ENFL_PRGE		(1 << 1)	/* programming pulse */
98 #define DS2490_ST_ENFL_SPCE		(1 << 2)	/* speed change */
99 #define DS2490_ST_SPEED		0x01	/* bus speed */
100 #define DS2490_ST_SPUDUR	0x02	/* strong pullup duration */
101 #define DS2490_ST_PRGDUR	0x03	/* programming pullup duration */
102 #define DS2490_ST_PDSRC		0x04	/* pulldown slew rate control */
103 #define DS2490_ST_W1LT		0x05	/* write-1 low time */
104 #define DS2490_ST_DSO		0x06	/* data sample offset */
105 #define DS2490_ST_STFL		0x08	/* status flags */
106 #define DS2490_ST_STFL_SPUA		(1 << 0)	/* strong pullup */
107 #define DS2490_ST_STFL_PRGA		(1 << 1)	/* programming pulse */
108 #define DS2490_ST_STFL_12VP		(1 << 2)	/* 12V prog voltage */
109 #define DS2490_ST_STFL_PMOD		(1 << 3)	/* ext power */
110 #define DS2490_ST_STFL_HALT		(1 << 4)	/* halted */
111 #define DS2490_ST_STFL_IDLE		(1 << 5)	/* idle */
112 #define DS2490_ST_STFL_EP0F		(1 << 7)	/* EP0 FIFO status */
113 #define DS2490_ST_STFL_BITS		"\020\001SPUA\002PRGA\00312VP\004PMOD\005HALT\006IDLE\010EP0F"
114 
115 #define DS2490_ST_CC1		0x09	/* communication command byte 1 */
116 #define DS2490_ST_CC2		0x0a	/* communication command byte 2 */
117 #define DS2490_ST_CCBUF		0x0b	/* communication command buf status */
118 #define DS2490_ST_OBUF		0x0c	/* data out buf status */
119 #define DS2490_ST_IBUF		0x0d	/* data in buf status */
120 #define DS2490_ST_END		0x0f
121 
122 /* Result registers */
123 #define DS2490_RES_BEGIN	0x10
124 #define DS2490_RES_END		0x1f
125 #define DS2490_RES_DETECT	0xa5	/* device detect */
126 
127 #define DS2490_NREGS		(DS2490_RES_END + 1)
128 
129 #define DS2490_CMDFIFOSIZE	16	/* command FIFO size */
130 #define DS2490_DATAFIFOSIZE	128	/* data FIFO size */
131 
132 #endif	/* !_DEV_USB_UOWREG_H_ */
133