master
1/*-
2 * Copyright 2008-2012 - Symmetricom, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions, and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28/*
29 * FTDI USB serial converter chip ioctl commands.
30 */
31
32#ifndef _USB_UFTDIIO_H_
33#define _USB_UFTDIIO_H_
34
35#include <sys/ioccom.h>
36
37enum uftdi_bitmodes
38{
39 UFTDI_BITMODE_ASYNC = 0,
40 UFTDI_BITMODE_MPSSE = 1,
41 UFTDI_BITMODE_SYNC = 2,
42 UFTDI_BITMODE_CPU_EMUL = 3,
43 UFTDI_BITMODE_FAST_SERIAL = 4,
44 UFTDI_BITMODE_CBUS = 5,
45 UFTDI_BITMODE_NONE = 0xff, /* aka UART mode. */
46};
47
48/*
49 * For UFTDIIOC_SET_BITMODE:
50 * mode = One of the uftdi_bitmodes enum values.
51 * iomask = Mask of bits enabled for bitbang output.
52 *
53 * For UFTDIIOC_GET_BITMODE:
54 * mode = Mode most recently set using UFTDIIOC_SET_BITMODE.
55 * iomask = Returned snapshot of DBUS0..DBUS7 pin states at time of call.
56 * Pin states can be read in any mode, not just bitbang modes.
57 */
58struct uftdi_bitmode
59{
60 uint8_t mode;
61 uint8_t iomask;
62};
63
64/*
65 * For UFTDIIOC_READ_EEPROM, UFTDIIOC_WRITE_EEPROM:
66 *
67 * IO is done in 16-bit words at the chip level; offset and length are in bytes,
68 * but must each be evenly divisible by two.
69 *
70 * It is not necessary to erase before writing. For the FT232R device (only)
71 * you must set the latency timer to 0x77 before doing a series of eeprom writes
72 * (and restore it to the prior value when done).
73 */
74struct uftdi_eeio
75{
76 uint16_t offset;
77 uint16_t length;
78 uint16_t data[64];
79};
80
81/* Pass this value to confirm that eeprom erase request is not accidental. */
82#define UFTDI_CONFIRM_ERASE 0x26139108
83
84#define UFTDIIOC_RESET_IO _IO('c', 0) /* Reset config, flush fifos.*/
85#define UFTDIIOC_RESET_RX _IO('c', 1) /* Flush input fifo. */
86#define UFTDIIOC_RESET_TX _IO('c', 2) /* Flush output fifo. */
87#define UFTDIIOC_SET_BITMODE _IOW('c', 3, struct uftdi_bitmode)
88#define UFTDIIOC_GET_BITMODE _IOR('c', 4, struct uftdi_bitmode)
89#define UFTDIIOC_SET_ERROR_CHAR _IOW('c', 5, int) /* -1 to disable */
90#define UFTDIIOC_SET_EVENT_CHAR _IOW('c', 6, int) /* -1 to disable */
91#define UFTDIIOC_SET_LATENCY _IOW('c', 7, int) /* 1-255 ms */
92#define UFTDIIOC_GET_LATENCY _IOR('c', 8, int)
93#define UFTDIIOC_GET_HWREV _IOR('c', 9, int)
94#define UFTDIIOC_READ_EEPROM _IOWR('c', 10, struct uftdi_eeio)
95#define UFTDIIOC_WRITE_EEPROM _IOW('c', 11, struct uftdi_eeio)
96#define UFTDIIOC_ERASE_EEPROM _IOW('c', 12, int)
97
98#endif