1 1.5 dsainty /* $NetBSD: ustirreg.h,v 1.5 2019/09/22 07:28:35 dsainty Exp $ */ 2 1.1 augustss 3 1.1 augustss /* 4 1.1 augustss * Copyright (c) 2001 The NetBSD Foundation, Inc. 5 1.1 augustss * All rights reserved. 6 1.1 augustss * 7 1.1 augustss * This code is derived from software contributed to The NetBSD Foundation 8 1.5 dsainty * by David Sainty <dsainty (at) NetBSD.org> 9 1.1 augustss * 10 1.1 augustss * Redistribution and use in source and binary forms, with or without 11 1.1 augustss * modification, are permitted provided that the following conditions 12 1.1 augustss * are met: 13 1.1 augustss * 1. Redistributions of source code must retain the above copyright 14 1.1 augustss * notice, this list of conditions and the following disclaimer. 15 1.1 augustss * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 augustss * notice, this list of conditions and the following disclaimer in the 17 1.1 augustss * documentation and/or other materials provided with the distribution. 18 1.1 augustss * 19 1.1 augustss * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 augustss * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 augustss * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 augustss * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 augustss * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 augustss * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 augustss * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 augustss * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 augustss * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 augustss * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 augustss * POSSIBILITY OF SUCH DAMAGE. 30 1.1 augustss */ 31 1.1 augustss 32 1.1 augustss /* 33 1.1 augustss * Registers definitions for SigmaTel STIr4200 USB/IrDA Bridge 34 1.1 augustss * Controller. Documentation available at: 35 1.2 dsainty * http://www.sigmatel.com/technical_docs.htm 36 1.2 dsainty * http://extranet.sigmatel.com/library/infrared/stir4200/stir4200-ds-1-0.pdf 37 1.1 augustss */ 38 1.1 augustss 39 1.1 augustss /* Notes: 40 1.1 augustss * 41 1.1 augustss * The data sheet states that the TX and RX frames are prepended with 42 1.1 augustss * BOF characters. This appears to be incorrect, the standard 0xff 43 1.1 augustss * characters behave as expected. 44 1.1 augustss * 45 1.1 augustss * There does not appear to be any way to get asynchronous 46 1.1 augustss * notifications from this device that data is waiting. You simply do 47 1.1 augustss * have to poll continuously looking for a non-zero-length result. 48 1.1 augustss * 49 1.1 augustss * The SigmaTel drivers provided with the device for other operating 50 1.1 augustss * systems poll at full USB speed (1000 per second), which has a 51 1.1 augustss * significant impact on the system. 52 1.1 augustss */ 53 1.1 augustss 54 1.1 augustss /* 55 1.1 augustss * The SigmaTel device is controlled via an array of registers, with 56 1.1 augustss * generic register read/write commands. This is a completely 57 1.1 augustss * different approach to that defined in the USB IrDA standard. 58 1.1 augustss */ 59 1.1 augustss #define STIR_REG_MODE 1 60 1.1 augustss #define STIR_REG_BRATE 2 61 1.1 augustss #define STIR_REG_CONTROL 3 62 1.1 augustss #define STIR_REG_SENSITIVITY 4 63 1.1 augustss #define STIR_REG_STATUS 5 64 1.1 augustss #define STIR_REG_FFCNT_LSB 6 65 1.1 augustss #define STIR_REG_FFCNT_MSB 7 66 1.1 augustss #define STIR_REG_DPLL 8 67 1.1 augustss #define STIR_REG_IRDIG 9 68 1.1 augustss 69 1.1 augustss /* Register numbers range from zero to STIR_MAX_REG */ 70 1.1 augustss #define STIR_MAX_REG 15 71 1.1 augustss 72 1.1 augustss 73 1.3 dsainty /* 74 1.3 dsainty * Mode register bits 75 1.3 dsainty * 76 1.3 dsainty * The MIR bit was documented in earlier revisions of the data sheet, 77 1.3 dsainty * but in the current published version (version 1.0, March 2002) the 78 1.3 dsainty * MIR bit is documented as "reserved". Possibly the device has a 79 1.3 dsainty * design flaw affecting the MIR data rates. 80 1.3 dsainty */ 81 1.1 augustss #define STIR_RMODE_FIR 0x80 82 1.1 augustss #define STIR_RMODE_MIR 0x40 83 1.1 augustss #define STIR_RMODE_SIR 0x20 84 1.1 augustss #define STIR_RMODE_ASK 0x10 85 1.1 augustss 86 1.1 augustss /* 87 1.1 augustss * FASTRXEN can be set to enable simultaneous reads and writes. It 88 1.1 augustss * isn't clear that this is useful, the RX and TX data is mixed into 89 1.1 augustss * the FIFO and the chip appears to get into a funny state. In the 90 1.1 augustss * absence of good documentation about this bit, leave it disabled! 91 1.1 augustss */ 92 1.1 augustss #define STIR_RMODE_FASTRXEN 0x08 93 1.1 augustss 94 1.1 augustss #define STIR_RMODE_FFRSTEN 0x04 95 1.1 augustss 96 1.1 augustss /* FFSPRST must be set to enable the FIFO */ 97 1.1 augustss #define STIR_RMODE_FFSPRST 0x02 98 1.1 augustss 99 1.1 augustss /* 100 1.1 augustss * High bit baud rate generator value, used in conjunction with the 101 1.1 augustss * BRATE register. 102 1.1 augustss */ 103 1.1 augustss #define STIR_RMODE_PDCLK8 0x01 104 1.1 augustss 105 1.1 augustss 106 1.1 augustss /* Status register bits */ 107 1.1 augustss #define STIR_RSTATUS_EOFRAME 0x80 108 1.1 augustss #define STIR_RSTATUS_FFUNDER 0x40 109 1.1 augustss #define STIR_RSTATUS_FFOVER 0x20 110 1.1 augustss 111 1.1 augustss /* Set in write direction, cleared in read direction */ 112 1.1 augustss #define STIR_RSTATUS_FFDIR 0x10 113 1.1 augustss 114 1.1 augustss /* 115 1.1 augustss * FFCLR is write-only, and the only writable bit in the STATUS 116 1.1 augustss * register. 117 1.1 augustss */ 118 1.1 augustss #define STIR_RSTATUS_FFCLR 0x08 119 1.1 augustss 120 1.1 augustss #define STIR_RSTATUS_FFEMPTY 0x04 121 1.1 augustss #define STIR_RSTATUS_FFRXERR 0x02 122 1.1 augustss #define STIR_RSTATUS_FFTXERR 0x01 123 1.1 augustss 124 1.1 augustss 125 1.1 augustss /* Extract data from portions of registers */ 126 1.1 augustss #define STIR_GET_SENSITIVITY_CHIPREVISION(x) ((x) & 7) 127 1.1 augustss 128 1.1 augustss /* 129 1.1 augustss * According to the documentation, FFCNT may be off by as much as 3 130 1.1 augustss * bytes. 131 1.1 augustss */ 132 1.1 augustss #define STIR_FFCNT_MARGIN 3 133 1.1 augustss 134 1.1 augustss /* 135 1.1 augustss * The FIFO size for the device is a fixed 4k bytes 136 1.1 augustss */ 137 1.1 augustss #define STIR_FIFO_SIZE 0x1000 138 1.1 augustss 139 1.1 augustss /* 140 1.1 augustss * Vendor specific device requests 141 1.1 augustss */ 142 1.1 augustss #define STIR_CMD_WRITEMULTIREG 0x00 143 1.1 augustss #define STIR_CMD_READMULTIREG 0x01 144 1.1 augustss #define STIR_CMD_READROM 0x02 145 1.1 augustss #define STIR_CMD_WRITESINGLEREG 0x03 146 1.1 augustss 147 1.1 augustss /* 148 1.1 augustss * The MSB is the MODE register setting, the LSB is the BRATE register 149 1.1 augustss * setting. 150 1.3 dsainty * 151 1.3 dsainty * The MIR rates (576000 and 1152000) were documented in earlier 152 1.3 dsainty * revisions of the data sheet, but in the current published version 153 1.3 dsainty * these data rates have disappeared. Possibly the device has a 154 1.3 dsainty * design flaw affecting the MIR data rates. 155 1.1 augustss */ 156 1.1 augustss #define STIR_BRMODE_4000000 0x8002 157 1.1 augustss #define STIR_BRMODE_1152000 0x4001 158 1.1 augustss #define STIR_BRMODE_576000 0x4003 159 1.1 augustss #define STIR_BRMODE_115200 0x2009 160 1.1 augustss #define STIR_BRMODE_57600 0x2013 161 1.1 augustss #define STIR_BRMODE_38400 0x201d 162 1.1 augustss #define STIR_BRMODE_19200 0x203b 163 1.1 augustss #define STIR_BRMODE_9600 0x2077 164 1.1 augustss #define STIR_BRMODE_2400 0x21df 165 1.1 augustss 166 1.1 augustss /* 167 1.1 augustss * Extract values from STIR_BRMODE values. 168 1.1 augustss */ 169 1.1 augustss #define STIR_BRMODE_MODEREG(x) ((x) >> 8) 170 1.1 augustss #define STIR_BRMODE_BRATEREG(x) ((x) & 0xff) 171 1.1 augustss 172 1.1 augustss /* 173 1.1 augustss * Each transmit frame starts with the sequence: 174 1.1 augustss * 175 1.1 augustss * 0x55 0xaa LSB(Length) MSB(Length) 176 1.1 augustss */ 177 1.1 augustss #define STIR_OUTPUT_HEADER_SIZE 4 178 1.1 augustss #define STIR_OUTPUT_HEADER_BYTE0 0x55 179 1.1 augustss #define STIR_OUTPUT_HEADER_BYTE1 0xaa 180