1 /* $OpenBSD: ohcivar.h,v 1.39 2017/06/01 09:47:55 mpi Exp $ */ 2 /* $NetBSD: ohcivar.h,v 1.32 2003/02/22 05:24:17 tsutsui Exp $ */ 3 /* $FreeBSD: src/sys/dev/usb/ohcivar.h,v 1.13 1999/11/17 22:33:41 n_hibma Exp $ */ 4 5 /* 6 * Copyright (c) 1998 The NetBSD Foundation, Inc. 7 * All rights reserved. 8 * 9 * This code is derived from software contributed to The NetBSD Foundation 10 * by Lennart Augustsson (lennart@augustsson.net) at 11 * Carlstedt Research & Technology. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 struct ohci_soft_ed { 36 struct ohci_ed ed; 37 struct ohci_soft_ed *next; 38 ohci_physaddr_t physaddr; 39 }; 40 #define OHCI_SED_SIZE ((sizeof (struct ohci_soft_ed) + OHCI_ED_ALIGN - 1) / OHCI_ED_ALIGN * OHCI_ED_ALIGN) 41 #define OHCI_SED_CHUNK 128 42 43 44 struct ohci_soft_td { 45 struct ohci_td td; 46 struct ohci_soft_td *nexttd; /* mirrors nexttd in TD */ 47 struct ohci_soft_td *dnext; /* next in done list */ 48 ohci_physaddr_t physaddr; 49 LIST_ENTRY(ohci_soft_td) hnext; 50 struct usbd_xfer *xfer; 51 u_int16_t len; 52 u_int16_t flags; 53 #define OHCI_CALL_DONE 0x0001 54 #define OHCI_ADD_LEN 0x0002 55 }; 56 #define OHCI_STD_SIZE ((sizeof (struct ohci_soft_td) + OHCI_TD_ALIGN - 1) / OHCI_TD_ALIGN * OHCI_TD_ALIGN) 57 #define OHCI_STD_CHUNK 128 58 59 60 struct ohci_soft_itd { 61 struct ohci_itd itd; 62 struct ohci_soft_itd *nextitd; /* mirrors nexttd in ITD */ 63 struct ohci_soft_itd *dnext; /* next in done list */ 64 ohci_physaddr_t physaddr; 65 LIST_ENTRY(ohci_soft_itd) hnext; 66 struct usbd_xfer *xfer; 67 u_int16_t flags; 68 #ifdef DIAGNOSTIC 69 char isdone; 70 #endif 71 }; 72 #define OHCI_SITD_SIZE ((sizeof (struct ohci_soft_itd) + OHCI_ITD_ALIGN - 1) / OHCI_ITD_ALIGN * OHCI_ITD_ALIGN) 73 #define OHCI_SITD_CHUNK 64 74 75 76 #define OHCI_NO_EDS (2*OHCI_NO_INTRS-1) 77 78 #define OHCI_HASH_SIZE 128 79 80 struct ohci_softc { 81 struct usbd_bus sc_bus; /* base device */ 82 bus_space_tag_t iot; 83 bus_space_handle_t ioh; 84 bus_size_t sc_size; 85 86 struct usb_dma sc_hccadma; 87 struct ohci_hcca *sc_hcca; 88 struct ohci_soft_ed *sc_eds[OHCI_NO_EDS]; 89 u_int sc_bws[OHCI_NO_INTRS]; 90 91 u_int32_t sc_eintrs; 92 struct ohci_soft_ed *sc_isoc_head; 93 struct ohci_soft_ed *sc_ctrl_head; 94 struct ohci_soft_ed *sc_bulk_head; 95 96 LIST_HEAD(, ohci_soft_td) sc_hash_tds[OHCI_HASH_SIZE]; 97 LIST_HEAD(, ohci_soft_itd) sc_hash_itds[OHCI_HASH_SIZE]; 98 99 int sc_noport; 100 u_int8_t sc_conf; /* device configuration */ 101 102 char sc_softwake; 103 104 struct ohci_soft_ed *sc_freeeds; 105 struct ohci_soft_td *sc_freetds; 106 struct ohci_soft_itd *sc_freeitds; 107 108 struct usbd_xfer *sc_intrxfer; 109 110 struct ohci_soft_itd *sc_sidone; 111 struct ohci_soft_td *sc_sdone; 112 113 char sc_vendor[16]; 114 int sc_id_vendor; 115 116 u_int32_t sc_control; /* Preserved during suspend/standby */ 117 u_int32_t sc_intre; 118 u_int32_t sc_ival; 119 120 u_int sc_overrun_cnt; 121 struct timeval sc_overrun_ntc; 122 123 struct timeout sc_tmo_rhsc; 124 }; 125 126 struct ohci_xfer { 127 struct usbd_xfer xfer; 128 }; 129 130 usbd_status ohci_checkrev(struct ohci_softc *); 131 usbd_status ohci_handover(struct ohci_softc *); 132 usbd_status ohci_init(struct ohci_softc *); 133 int ohci_intr(void *); 134 int ohci_detach(struct device *, int); 135 int ohci_activate(struct device *, int); 136