102ac6454SAndrew Thompson /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 45d38a4d4SEd Schouten * Copyright (c) 2007 Hans Petter Selasky <hselasky@FreeBSD.org> 502ac6454SAndrew Thompson * All rights reserved. 602ac6454SAndrew Thompson * 702ac6454SAndrew Thompson * Redistribution and use in source and binary forms, with or without 802ac6454SAndrew Thompson * modification, are permitted provided that the following conditions 902ac6454SAndrew Thompson * are met: 1002ac6454SAndrew Thompson * 1. Redistributions of source code must retain the above copyright 1102ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer. 1202ac6454SAndrew Thompson * 2. Redistributions in binary form must reproduce the above copyright 1302ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer in the 1402ac6454SAndrew Thompson * documentation and/or other materials provided with the distribution. 1502ac6454SAndrew Thompson * 1602ac6454SAndrew Thompson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1702ac6454SAndrew Thompson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1802ac6454SAndrew Thompson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1902ac6454SAndrew Thompson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2002ac6454SAndrew Thompson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2102ac6454SAndrew Thompson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2202ac6454SAndrew Thompson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2302ac6454SAndrew Thompson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2402ac6454SAndrew Thompson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2502ac6454SAndrew Thompson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2602ac6454SAndrew Thompson * SUCH DAMAGE. 2702ac6454SAndrew Thompson */ 2802ac6454SAndrew Thompson 2902ac6454SAndrew Thompson #ifndef _USS820_DCI_H_ 3002ac6454SAndrew Thompson #define _USS820_DCI_H_ 3102ac6454SAndrew Thompson 3202ac6454SAndrew Thompson #define USS820_MAX_DEVICES (USB_MIN_DEVICES + 1) 3302ac6454SAndrew Thompson 3402ac6454SAndrew Thompson #define USS820_EP_MAX 8 /* maximum number of endpoints */ 3502ac6454SAndrew Thompson 3602ac6454SAndrew Thompson #define USS820_TXDAT 0x00 /* Transmit FIFO data */ 3702ac6454SAndrew Thompson 3802ac6454SAndrew Thompson #define USS820_TXCNTL 0x01 /* Transmit FIFO byte count low */ 3902ac6454SAndrew Thompson #define USS820_TXCNTL_MASK 0xFF 4002ac6454SAndrew Thompson 4102ac6454SAndrew Thompson #define USS820_TXCNTH 0x02 /* Transmit FIFO byte count high */ 4202ac6454SAndrew Thompson #define USS820_TXCNTH_MASK 0x03 4302ac6454SAndrew Thompson #define USS820_TXCNTH_UNUSED 0xFC 4402ac6454SAndrew Thompson 4502ac6454SAndrew Thompson #define USS820_TXCON 0x03 /* USB transmit FIFO control */ 4602ac6454SAndrew Thompson #define USS820_TXCON_REVRP 0x01 4702ac6454SAndrew Thompson #define USS820_TXCON_ADVRM 0x02 4802ac6454SAndrew Thompson #define USS820_TXCON_ATM 0x04 /* Automatic Transmit Management */ 4902ac6454SAndrew Thompson #define USS820_TXCON_TXISO 0x08 /* Transmit Isochronous Data */ 5002ac6454SAndrew Thompson #define USS820_TXCON_UNUSED 0x10 5102ac6454SAndrew Thompson #define USS820_TXCON_FFSZ_16_64 0x00 5202ac6454SAndrew Thompson #define USS820_TXCON_FFSZ_64_256 0x20 5302ac6454SAndrew Thompson #define USS820_TXCON_FFSZ_8_512 0x40 5402ac6454SAndrew Thompson #define USS820_TXCON_FFSZ_32_1024 0x60 5502ac6454SAndrew Thompson #define USS820_TXCON_FFSZ_MASK 0x60 5602ac6454SAndrew Thompson #define USS820_TXCON_TXCLR 0x80 /* Transmit FIFO clear */ 5702ac6454SAndrew Thompson 5802ac6454SAndrew Thompson #define USS820_TXFLG 0x04 /* Transmit FIFO flag (Read Only) */ 5902ac6454SAndrew Thompson #define USS820_TXFLG_TXOVF 0x01 /* TX overrun */ 6002ac6454SAndrew Thompson #define USS820_TXFLG_TXURF 0x02 /* TX underrun */ 6102ac6454SAndrew Thompson #define USS820_TXFLG_TXFULL 0x04 /* TX full */ 6202ac6454SAndrew Thompson #define USS820_TXFLG_TXEMP 0x08 /* TX empty */ 6302ac6454SAndrew Thompson #define USS820_TXFLG_UNUSED 0x30 6402ac6454SAndrew Thompson #define USS820_TXFLG_TXFIF0 0x40 6502ac6454SAndrew Thompson #define USS820_TXFLG_TXFIF1 0x80 6602ac6454SAndrew Thompson 6702ac6454SAndrew Thompson #define USS820_RXDAT 0x05 /* Receive FIFO data */ 6802ac6454SAndrew Thompson 6902ac6454SAndrew Thompson #define USS820_RXCNTL 0x06 /* Receive FIFO byte count low */ 7002ac6454SAndrew Thompson #define USS820_RXCNTL_MASK 0xFF 7102ac6454SAndrew Thompson 7202ac6454SAndrew Thompson #define USS820_RXCNTH 0x07 /* Receive FIFO byte count high */ 7302ac6454SAndrew Thompson #define USS820_RXCNTH_MASK 0x03 7402ac6454SAndrew Thompson #define USS820_RXCNTH_UNUSED 0xFC 7502ac6454SAndrew Thompson 7602ac6454SAndrew Thompson #define USS820_RXCON 0x08 /* Receive FIFO control */ 7702ac6454SAndrew Thompson #define USS820_RXCON_REVWP 0x01 7802ac6454SAndrew Thompson #define USS820_RXCON_ADVWM 0x02 7902ac6454SAndrew Thompson #define USS820_RXCON_ARM 0x04 /* Auto Receive Management */ 8002ac6454SAndrew Thompson #define USS820_RXCON_RXISO 0x08 /* Receive Isochronous Data */ 8102ac6454SAndrew Thompson #define USS820_RXCON_RXFFRC 0x10 /* FIFO Read Complete */ 8202ac6454SAndrew Thompson #define USS820_RXCON_FFSZ_16_64 0x00 8302ac6454SAndrew Thompson #define USS820_RXCON_FFSZ_64_256 0x20 8402ac6454SAndrew Thompson #define USS820_RXCON_FFSZ_8_512 0x40 8502ac6454SAndrew Thompson #define USS820_RXCON_FFSZ_32_1024 0x60 8602ac6454SAndrew Thompson #define USS820_RXCON_RXCLR 0x80 /* Receive FIFO clear */ 8702ac6454SAndrew Thompson 8802ac6454SAndrew Thompson #define USS820_RXFLG 0x09 /* Receive FIFO flag (Read Only) */ 8902ac6454SAndrew Thompson #define USS820_RXFLG_RXOVF 0x01 /* RX overflow */ 9002ac6454SAndrew Thompson #define USS820_RXFLG_RXURF 0x02 /* RX underflow */ 9102ac6454SAndrew Thompson #define USS820_RXFLG_RXFULL 0x04 /* RX full */ 9202ac6454SAndrew Thompson #define USS820_RXFLG_RXEMP 0x08 /* RX empty */ 9302ac6454SAndrew Thompson #define USS820_RXFLG_RXFLUSH 0x10 /* RX flush */ 9402ac6454SAndrew Thompson #define USS820_RXFLG_UNUSED 0x20 9502ac6454SAndrew Thompson #define USS820_RXFLG_RXFIF0 0x40 9602ac6454SAndrew Thompson #define USS820_RXFLG_RXFIF1 0x80 9702ac6454SAndrew Thompson 9802ac6454SAndrew Thompson #define USS820_EPINDEX 0x0a /* Endpoint index selection */ 9902ac6454SAndrew Thompson #define USS820_EPINDEX_MASK 0x07 10002ac6454SAndrew Thompson #define USS820_EPINDEX_UNUSED 0xF8 10102ac6454SAndrew Thompson 10202ac6454SAndrew Thompson #define USS820_EPCON 0x0b /* Endpoint control */ 10302ac6454SAndrew Thompson #define USS820_EPCON_TXEPEN 0x01 /* Transmit Endpoint Enable */ 10402ac6454SAndrew Thompson #define USS820_EPCON_TXOE 0x02 /* Transmit Output Enable */ 10502ac6454SAndrew Thompson #define USS820_EPCON_RXEPEN 0x04 /* Receive Endpoint Enable */ 10602ac6454SAndrew Thompson #define USS820_EPCON_RXIE 0x08 /* Receive Input Enable */ 10702ac6454SAndrew Thompson #define USS820_EPCON_RXSPM 0x10 /* Receive Single-Packet Mode */ 10802ac6454SAndrew Thompson #define USS820_EPCON_CTLEP 0x20 /* Control Endpoint */ 10902ac6454SAndrew Thompson #define USS820_EPCON_TXSTL 0x40 /* Stall Transmit Endpoint */ 11002ac6454SAndrew Thompson #define USS820_EPCON_RXSTL 0x80 /* Stall Receive Endpoint */ 11102ac6454SAndrew Thompson 11202ac6454SAndrew Thompson #define USS820_TXSTAT 0x0c /* Transmit status */ 11302ac6454SAndrew Thompson #define USS820_TXSTAT_TXACK 0x01 /* Transmit Acknowledge */ 11402ac6454SAndrew Thompson #define USS820_TXSTAT_TXERR 0x02 /* Transmit Error */ 11502ac6454SAndrew Thompson #define USS820_TXSTAT_TXVOID 0x04 /* Transmit Void */ 11602ac6454SAndrew Thompson #define USS820_TXSTAT_TXSOVW 0x08 /* Transmit Data Sequence Overwrite 11702ac6454SAndrew Thompson * Bit */ 11802ac6454SAndrew Thompson #define USS820_TXSTAT_TXFLUSH 0x10 /* Transmit FIFO Packet Flushed */ 11902ac6454SAndrew Thompson #define USS820_TXSTAT_TXNAKE 0x20 /* Transmit NAK Mode Enable */ 12002ac6454SAndrew Thompson #define USS820_TXSTAT_TXDSAM 0x40 /* Transmit Data-Set-Available Mode */ 12102ac6454SAndrew Thompson #define USS820_TXSTAT_TXSEQ 0x80 /* Transmitter Current Sequence Bit */ 12202ac6454SAndrew Thompson 12302ac6454SAndrew Thompson #define USS820_RXSTAT 0x0d /* Receive status */ 12402ac6454SAndrew Thompson #define USS820_RXSTAT_RXACK 0x01 /* Receive Acknowledge */ 12502ac6454SAndrew Thompson #define USS820_RXSTAT_RXERR 0x02 /* Receive Error */ 12602ac6454SAndrew Thompson #define USS820_RXSTAT_RXVOID 0x04 /* Receive Void */ 12702ac6454SAndrew Thompson #define USS820_RXSTAT_RXSOVW 0x08 /* Receive Data Sequence Overwrite Bit */ 12802ac6454SAndrew Thompson #define USS820_RXSTAT_EDOVW 0x10 /* End Overwrite Flag */ 12902ac6454SAndrew Thompson #define USS820_RXSTAT_STOVW 0x20 /* Start Overwrite Flag */ 13002ac6454SAndrew Thompson #define USS820_RXSTAT_RXSETUP 0x40 /* Received SETUP token */ 13102ac6454SAndrew Thompson #define USS820_RXSTAT_RXSEQ 0x80 /* Receiver Endpoint Sequence Bit */ 13202ac6454SAndrew Thompson 13302ac6454SAndrew Thompson #define USS820_SOFL 0x0e /* Start Of Frame counter low */ 13402ac6454SAndrew Thompson #define USS820_SOFL_MASK 0xFF 13502ac6454SAndrew Thompson 13602ac6454SAndrew Thompson #define USS820_SOFH 0x0f /* Start Of Frame counter high */ 13702ac6454SAndrew Thompson #define USS820_SOFH_MASK 0x07 13802ac6454SAndrew Thompson #define USS820_SOFH_SOFDIS 0x08 /* SOF Pin Output Disable */ 13902ac6454SAndrew Thompson #define USS820_SOFH_FTLOCK 0x10 /* Frame Timer Lock */ 14002ac6454SAndrew Thompson #define USS820_SOFH_SOFIE 0x20 /* SOF Interrupt Enable */ 14102ac6454SAndrew Thompson #define USS820_SOFH_ASOF 0x40 /* Any Start of Frame */ 14202ac6454SAndrew Thompson #define USS820_SOFH_SOFACK 0x80 /* SOF Token Received Without Error */ 14302ac6454SAndrew Thompson 14402ac6454SAndrew Thompson #define USS820_FADDR 0x10 /* Function Address */ 14502ac6454SAndrew Thompson #define USS820_FADDR_MASK 0x7F 14602ac6454SAndrew Thompson #define USS820_FADDR_UNUSED 0x80 14702ac6454SAndrew Thompson 14802ac6454SAndrew Thompson #define USS820_SCR 0x11 /* System Control */ 14902ac6454SAndrew Thompson #define USS820_SCR_UNUSED 0x01 15002ac6454SAndrew Thompson #define USS820_SCR_T_IRQ 0x02 /* Global Interrupt Enable */ 15102ac6454SAndrew Thompson #define USS820_SCR_IRQLVL 0x04 /* Interrupt Mode */ 15202ac6454SAndrew Thompson #define USS820_SCR_SRESET 0x08 /* Software reset */ 15302ac6454SAndrew Thompson #define USS820_SCR_IE_RESET 0x10 /* Enable Reset Interrupt */ 15402ac6454SAndrew Thompson #define USS820_SCR_IE_SUSP 0x20 /* Enable Suspend Interrupt */ 15502ac6454SAndrew Thompson #define USS820_SCR_RWUPE 0x40 /* Enable Remote Wake-Up Feature */ 15602ac6454SAndrew Thompson #define USS820_SCR_IRQPOL 0x80 /* IRQ polarity */ 15702ac6454SAndrew Thompson 15802ac6454SAndrew Thompson #define USS820_SSR 0x12 /* System Status */ 15902ac6454SAndrew Thompson #define USS820_SSR_RESET 0x01 /* Reset Condition Detected on USB 16002ac6454SAndrew Thompson * cable */ 16102ac6454SAndrew Thompson #define USS820_SSR_SUSPEND 0x02 /* Suspend Detected */ 16202ac6454SAndrew Thompson #define USS820_SSR_RESUME 0x04 /* Resume Detected */ 16302ac6454SAndrew Thompson #define USS820_SSR_SUSPDIS 0x08 /* Suspend Disable */ 16402ac6454SAndrew Thompson #define USS820_SSR_SUSPPO 0x10 /* Suspend Power Off */ 16502ac6454SAndrew Thompson #define USS820_SSR_UNUSED 0xE0 16602ac6454SAndrew Thompson 16702ac6454SAndrew Thompson #define USS820_UNK0 0x13 /* Unknown */ 16802ac6454SAndrew Thompson #define USS820_UNK0_UNUSED 0xFF 16902ac6454SAndrew Thompson 17002ac6454SAndrew Thompson #define USS820_SBI 0x14 /* Serial bus interrupt low */ 17102ac6454SAndrew Thompson #define USS820_SBI_FTXD0 0x01 /* Function Transmit Done, EP 0 */ 17202ac6454SAndrew Thompson #define USS820_SBI_FRXD0 0x02 /* Function Receive Done, EP 0 */ 17302ac6454SAndrew Thompson #define USS820_SBI_FTXD1 0x04 17402ac6454SAndrew Thompson #define USS820_SBI_FRXD1 0x08 17502ac6454SAndrew Thompson #define USS820_SBI_FTXD2 0x10 17602ac6454SAndrew Thompson #define USS820_SBI_FRXD2 0x20 17702ac6454SAndrew Thompson #define USS820_SBI_FTXD3 0x40 17802ac6454SAndrew Thompson #define USS820_SBI_FRXD3 0x80 17902ac6454SAndrew Thompson 18002ac6454SAndrew Thompson #define USS820_SBI1 0x15 /* Serial bus interrupt high */ 18102ac6454SAndrew Thompson #define USS820_SBI1_FTXD4 0x01 18202ac6454SAndrew Thompson #define USS820_SBI1_FRXD4 0x02 18302ac6454SAndrew Thompson #define USS820_SBI1_FTXD5 0x04 18402ac6454SAndrew Thompson #define USS820_SBI1_FRXD5 0x08 18502ac6454SAndrew Thompson #define USS820_SBI1_FTXD6 0x10 18602ac6454SAndrew Thompson #define USS820_SBI1_FRXD6 0x20 18702ac6454SAndrew Thompson #define USS820_SBI1_FTXD7 0x40 18802ac6454SAndrew Thompson #define USS820_SBI1_FRXD7 0x80 18902ac6454SAndrew Thompson 19002ac6454SAndrew Thompson #define USS820_SBIE 0x16 /* Serial bus interrupt enable low */ 19102ac6454SAndrew Thompson #define USS820_SBIE_FTXIE0 0x01 19202ac6454SAndrew Thompson #define USS820_SBIE_FRXIE0 0x02 19302ac6454SAndrew Thompson #define USS820_SBIE_FTXIE1 0x04 19402ac6454SAndrew Thompson #define USS820_SBIE_FRXIE1 0x08 19502ac6454SAndrew Thompson #define USS820_SBIE_FTXIE2 0x10 19602ac6454SAndrew Thompson #define USS820_SBIE_FRXIE2 0x20 19702ac6454SAndrew Thompson #define USS820_SBIE_FTXIE3 0x40 19802ac6454SAndrew Thompson #define USS820_SBIE_FRXIE3 0x80 19902ac6454SAndrew Thompson 20002ac6454SAndrew Thompson #define USS820_SBIE1 0x17 /* Serial bus interrupt enable high */ 20102ac6454SAndrew Thompson #define USS820_SBIE1_FTXIE4 0x01 20202ac6454SAndrew Thompson #define USS820_SBIE1_FRXIE4 0x02 20302ac6454SAndrew Thompson #define USS820_SBIE1_FTXIE5 0x04 20402ac6454SAndrew Thompson #define USS820_SBIE1_FRXIE5 0x08 20502ac6454SAndrew Thompson #define USS820_SBIE1_FTXIE6 0x10 20602ac6454SAndrew Thompson #define USS820_SBIE1_FRXIE6 0x20 20702ac6454SAndrew Thompson #define USS820_SBIE1_FTXIE7 0x40 20802ac6454SAndrew Thompson #define USS820_SBIE1_FRXIE7 0x80 20902ac6454SAndrew Thompson 21002ac6454SAndrew Thompson #define USS820_REV 0x18 /* Hardware revision */ 21102ac6454SAndrew Thompson #define USS820_REV_MIN 0x0F 21202ac6454SAndrew Thompson #define USS820_REV_MAJ 0xF0 21302ac6454SAndrew Thompson 21402ac6454SAndrew Thompson #define USS820_LOCK 0x19 /* Suspend power-off locking */ 21502ac6454SAndrew Thompson #define USS820_LOCK_UNLOCKED 0x01 21602ac6454SAndrew Thompson #define USS820_LOCK_UNUSED 0xFE 21702ac6454SAndrew Thompson 21802ac6454SAndrew Thompson #define USS820_PEND 0x1a /* Pend hardware status update */ 21902ac6454SAndrew Thompson #define USS820_PEND_PEND 0x01 22002ac6454SAndrew Thompson #define USS820_PEND_UNUSED 0xFE 22102ac6454SAndrew Thompson 22202ac6454SAndrew Thompson #define USS820_SCRATCH 0x1b /* Scratch firmware information */ 22302ac6454SAndrew Thompson #define USS820_SCRATCH_MASK 0x7F 22402ac6454SAndrew Thompson #define USS820_SCRATCH_IE_RESUME 0x80 /* Enable Resume Interrupt */ 22502ac6454SAndrew Thompson 22602ac6454SAndrew Thompson #define USS820_MCSR 0x1c /* Miscellaneous control and status */ 22702ac6454SAndrew Thompson #define USS820_MCSR_DPEN 0x01 /* DPLS Pull-Up Enable */ 22802ac6454SAndrew Thompson #define USS820_MCSR_SUSPLOE 0x02 /* Suspend Lock Out Enable */ 22902ac6454SAndrew Thompson #define USS820_MCSR_BDFEAT 0x04 /* Board Feature Enable */ 23002ac6454SAndrew Thompson #define USS820_MCSR_FEAT 0x08 /* Feature Enable */ 23102ac6454SAndrew Thompson #define USS820_MCSR_PKGID 0x10 /* Package Identification */ 23202ac6454SAndrew Thompson #define USS820_MCSR_SUSPS 0x20 /* Suspend Status */ 23302ac6454SAndrew Thompson #define USS820_MCSR_INIT 0x40 /* Device Initialized */ 23402ac6454SAndrew Thompson #define USS820_MCSR_RWUPR 0x80 /* Remote Wakeup-Up Remember */ 23502ac6454SAndrew Thompson 23602ac6454SAndrew Thompson #define USS820_DSAV 0x1d /* Data set available low (Read Only) */ 23702ac6454SAndrew Thompson #define USS820_DSAV_TXAV0 0x01 23802ac6454SAndrew Thompson #define USS820_DSAV_RXAV0 0x02 23902ac6454SAndrew Thompson #define USS820_DSAV_TXAV1 0x04 24002ac6454SAndrew Thompson #define USS820_DSAV_RXAV1 0x08 24102ac6454SAndrew Thompson #define USS820_DSAV_TXAV2 0x10 24202ac6454SAndrew Thompson #define USS820_DSAV_RXAV2 0x20 24302ac6454SAndrew Thompson #define USS820_DSAV_TXAV3 0x40 24402ac6454SAndrew Thompson #define USS820_DSAV_RXAV3 0x80 24502ac6454SAndrew Thompson 24602ac6454SAndrew Thompson #define USS820_DSAV1 0x1e /* Data set available high */ 24702ac6454SAndrew Thompson #define USS820_DSAV1_TXAV4 0x01 24802ac6454SAndrew Thompson #define USS820_DSAV1_RXAV4 0x02 24902ac6454SAndrew Thompson #define USS820_DSAV1_TXAV5 0x04 25002ac6454SAndrew Thompson #define USS820_DSAV1_RXAV5 0x08 25102ac6454SAndrew Thompson #define USS820_DSAV1_TXAV6 0x10 25202ac6454SAndrew Thompson #define USS820_DSAV1_RXAV6 0x20 25302ac6454SAndrew Thompson #define USS820_DSAV1_TXAV7 0x40 25402ac6454SAndrew Thompson #define USS820_DSAV1_RXAV7 0x80 25502ac6454SAndrew Thompson 25602ac6454SAndrew Thompson #define USS820_UNK1 0x1f /* Unknown */ 25702ac6454SAndrew Thompson #define USS820_UNK1_UNKNOWN 0xFF 25802ac6454SAndrew Thompson 2596d3fae95SHans Petter Selasky #ifndef USS820_REG_STRIDE 2606d3fae95SHans Petter Selasky #define USS820_REG_STRIDE 1 2616d3fae95SHans Petter Selasky #endif 2626d3fae95SHans Petter Selasky 26302ac6454SAndrew Thompson #define USS820_READ_1(sc, reg) \ 2646d3fae95SHans Petter Selasky bus_space_read_1((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg) * USS820_REG_STRIDE) 26502ac6454SAndrew Thompson 26602ac6454SAndrew Thompson #define USS820_WRITE_1(sc, reg, data) \ 2676d3fae95SHans Petter Selasky bus_space_write_1((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg) * USS820_REG_STRIDE, (data)) 26802ac6454SAndrew Thompson 26902ac6454SAndrew Thompson struct uss820dci_td; 2706d3fae95SHans Petter Selasky struct uss820dci_softc; 27102ac6454SAndrew Thompson 2726d3fae95SHans Petter Selasky typedef uint8_t (uss820dci_cmd_t)(struct uss820dci_softc *, struct uss820dci_td *td); 27302ac6454SAndrew Thompson 27402ac6454SAndrew Thompson struct uss820dci_td { 27502ac6454SAndrew Thompson struct uss820dci_td *obj_next; 27602ac6454SAndrew Thompson uss820dci_cmd_t *func; 277760bc48eSAndrew Thompson struct usb_page_cache *pc; 27802ac6454SAndrew Thompson uint32_t offset; 27902ac6454SAndrew Thompson uint32_t remainder; 28002ac6454SAndrew Thompson uint16_t max_packet_size; 28102ac6454SAndrew Thompson uint8_t ep_index; 28202ac6454SAndrew Thompson uint8_t error:1; 28302ac6454SAndrew Thompson uint8_t alt_next:1; 28402ac6454SAndrew Thompson uint8_t short_pkt:1; 28502ac6454SAndrew Thompson uint8_t support_multi_buffer:1; 28602ac6454SAndrew Thompson uint8_t did_stall:1; 287476183dfSAndrew Thompson uint8_t did_enable:1; 28802ac6454SAndrew Thompson }; 28902ac6454SAndrew Thompson 29002ac6454SAndrew Thompson struct uss820_std_temp { 29102ac6454SAndrew Thompson uss820dci_cmd_t *func; 292760bc48eSAndrew Thompson struct usb_page_cache *pc; 29302ac6454SAndrew Thompson struct uss820dci_td *td; 29402ac6454SAndrew Thompson struct uss820dci_td *td_next; 29502ac6454SAndrew Thompson uint32_t len; 29602ac6454SAndrew Thompson uint32_t offset; 29702ac6454SAndrew Thompson uint16_t max_frame_size; 29802ac6454SAndrew Thompson uint8_t short_pkt; 29902ac6454SAndrew Thompson /* 30002ac6454SAndrew Thompson * short_pkt = 0: transfer should be short terminated 30102ac6454SAndrew Thompson * short_pkt = 1: transfer should not be short terminated 30202ac6454SAndrew Thompson */ 30302ac6454SAndrew Thompson uint8_t setup_alt_next; 304476183dfSAndrew Thompson uint8_t did_stall; 30502ac6454SAndrew Thompson }; 30602ac6454SAndrew Thompson 30702ac6454SAndrew Thompson struct uss820dci_config_desc { 308760bc48eSAndrew Thompson struct usb_config_descriptor confd; 309760bc48eSAndrew Thompson struct usb_interface_descriptor ifcd; 310760bc48eSAndrew Thompson struct usb_endpoint_descriptor endpd; 31102ac6454SAndrew Thompson } __packed; 31202ac6454SAndrew Thompson 31302ac6454SAndrew Thompson union uss820_hub_temp { 31402ac6454SAndrew Thompson uWord wValue; 315760bc48eSAndrew Thompson struct usb_port_status ps; 31602ac6454SAndrew Thompson }; 31702ac6454SAndrew Thompson 31802ac6454SAndrew Thompson struct uss820_flags { 31902ac6454SAndrew Thompson uint8_t change_connect:1; 32002ac6454SAndrew Thompson uint8_t change_suspend:1; 32102ac6454SAndrew Thompson uint8_t status_suspend:1; /* set if suspended */ 32202ac6454SAndrew Thompson uint8_t status_vbus:1; /* set if present */ 32302ac6454SAndrew Thompson uint8_t status_bus_reset:1; /* set if reset complete */ 32402ac6454SAndrew Thompson uint8_t clocks_off:1; 32502ac6454SAndrew Thompson uint8_t port_powered:1; 32602ac6454SAndrew Thompson uint8_t port_enabled:1; 32702ac6454SAndrew Thompson uint8_t d_pulled_up:1; 32802ac6454SAndrew Thompson uint8_t mcsr_feat:1; 32902ac6454SAndrew Thompson }; 33002ac6454SAndrew Thompson 33102ac6454SAndrew Thompson struct uss820dci_softc { 332760bc48eSAndrew Thompson struct usb_bus sc_bus; 33302ac6454SAndrew Thompson union uss820_hub_temp sc_hub_temp; 33402ac6454SAndrew Thompson 335760bc48eSAndrew Thompson struct usb_device *sc_devices[USS820_MAX_DEVICES]; 33602ac6454SAndrew Thompson struct resource *sc_io_res; 33702ac6454SAndrew Thompson struct resource *sc_irq_res; 33802ac6454SAndrew Thompson void *sc_intr_hdl; 33902ac6454SAndrew Thompson bus_size_t sc_io_size; 34002ac6454SAndrew Thompson bus_space_tag_t sc_io_tag; 34102ac6454SAndrew Thompson bus_space_handle_t sc_io_hdl; 34202ac6454SAndrew Thompson 3436d3fae95SHans Petter Selasky uint32_t sc_xfer_complete; 3446d3fae95SHans Petter Selasky 34502ac6454SAndrew Thompson uint8_t sc_rt_addr; /* root HUB address */ 34602ac6454SAndrew Thompson uint8_t sc_dv_addr; /* device address */ 34702ac6454SAndrew Thompson uint8_t sc_conf; /* root HUB config */ 34802ac6454SAndrew Thompson 34902ac6454SAndrew Thompson uint8_t sc_hub_idata[1]; 35002ac6454SAndrew Thompson 35102ac6454SAndrew Thompson struct uss820_flags sc_flags; 35202ac6454SAndrew Thompson }; 35302ac6454SAndrew Thompson 35402ac6454SAndrew Thompson /* prototypes */ 35502ac6454SAndrew Thompson 356e0a69b51SAndrew Thompson usb_error_t uss820dci_init(struct uss820dci_softc *sc); 35702ac6454SAndrew Thompson void uss820dci_uninit(struct uss820dci_softc *sc); 3586d3fae95SHans Petter Selasky driver_filter_t uss820dci_filter_interrupt; 3596d3fae95SHans Petter Selasky driver_intr_t uss820dci_interrupt; 36002ac6454SAndrew Thompson 36102ac6454SAndrew Thompson #endif /* _USS820_DCI_H_ */ 362