1 /* $NetBSD: sl811hsvar.h,v 1.11 2013/10/02 22:55:04 skrll Exp $ */ 2 3 /* 4 * Not (c) 2007 Matthew Orgass 5 * This file is public domain, meaning anyone can make any use of part or all 6 * of this file including copying into other works without credit. Any use, 7 * modified or not, is solely the responsibility of the user. If this file is 8 * part of a collection then use in the collection is governed by the terms of 9 * the collection. 10 */ 11 12 /* 13 * Cypress/ScanLogic SL811HS USB Host Controller 14 */ 15 16 #include <sys/gcq.h> 17 18 #define SC_DEV(sc) ((sc)->sc_dev) 19 #define SC_NAME(sc) (device_xname(SC_DEV(sc))) 20 21 typedef unsigned int Frame; 22 struct slhci_pipe; 23 24 /* Generally transfer related items. */ 25 struct slhci_transfers { 26 struct usbd_xfer *rootintr; 27 struct slhci_pipe *spipe[2]; /* current transfer (unless canceled) */ 28 struct gcq_head q[3]; /* transfer queues, Q_* index */ 29 struct gcq_head timed; /* intr transfer multi-frame wait */ 30 struct gcq_head to; /* timeout list */ 31 struct gcq_head ap; /* all pipes */ 32 Frame frame; /* current frame */ 33 unsigned int flags; /* F_* flags */ 34 int pend; /* pending for waitintr */ 35 int reserved_bustime; 36 int16_t len[2]; /* length of transfer or -1 if none */ 37 uint8_t current_tregs[2][4]; /* ab, ADR, LEN, PID, DEV */ 38 uint8_t copyin[2]; /* copyin ADR, LEN */ 39 uint8_t rootaddr; /* device address of root hub */ 40 uint8_t rootconf; /* root configuration */ 41 uint8_t max_current; /* max current / 2 */ 42 uint8_t sltype; /* revision */ 43 }; 44 45 enum power_change { 46 POWER_OFF, 47 POWER_ON, 48 }; 49 50 typedef void (*PowerFunc)(void *, enum power_change); 51 52 /* Attachment code must call slhci_preinit before registering the ISR */ 53 struct slhci_softc { 54 device_t sc_dev; 55 struct usbd_bus sc_bus; 56 57 kmutex_t sc_lock; 58 kmutex_t sc_intr_lock; 59 60 struct slhci_transfers sc_transfers; /* Info useful in transfers. */ 61 62 struct gcq_head sc_waitq; 63 64 bus_space_tag_t sc_iot; 65 bus_space_handle_t sc_ioh; 66 67 struct callout sc_timer; /* for reset */ 68 69 PowerFunc sc_enable_power; 70 71 device_t sc_child; 72 73 struct timeval sc_reserved_warn_rate; 74 struct timeval sc_overflow_warn_rate; 75 76 void *sc_cb_softintr; 77 78 unsigned int sc_ier_check; 79 80 int sc_mem_use; /* XXX SLHCI_MEM_ACCOUNTING */ 81 82 uint8_t sc_ier; /* enabled interrupts */ 83 uint32_t sc_stride; /* port stride */ 84 }; 85 86 /* last preinit arguments are: max current (in mA, not mA/2), port stride */ 87 /* register access uses byte access, but stride offsets the data port */ 88 int slhci_supported_rev(uint8_t); 89 void slhci_preinit(struct slhci_softc *, PowerFunc, bus_space_tag_t, 90 bus_space_handle_t, uint16_t, uint32_t); 91 int slhci_attach(struct slhci_softc *); 92 int slhci_detach(struct slhci_softc *, int); 93 int slhci_activate(device_t, enum devact); 94 int slhci_intr(void *); 95 96