dwc2var.h revision 1.3.4.2 1 1.3.4.2 rmind /* $NetBSD: dwc2var.h,v 1.3.4.2 2014/05/18 17:46:01 rmind Exp $ */
2 1.3.4.2 rmind
3 1.3.4.2 rmind /*-
4 1.3.4.2 rmind * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 1.3.4.2 rmind * All rights reserved.
6 1.3.4.2 rmind *
7 1.3.4.2 rmind * This code is derived from software contributed to The NetBSD Foundation
8 1.3.4.2 rmind * by Nick Hudson
9 1.3.4.2 rmind *
10 1.3.4.2 rmind * Redistribution and use in source and binary forms, with or without
11 1.3.4.2 rmind * modification, are permitted provided that the following conditions
12 1.3.4.2 rmind * are met:
13 1.3.4.2 rmind * 1. Redistributions of source code must retain the above copyright
14 1.3.4.2 rmind * notice, this list of conditions and the following disclaimer.
15 1.3.4.2 rmind * 2. Redistributions in binary form must reproduce the above copyright
16 1.3.4.2 rmind * notice, this list of conditions and the following disclaimer in the
17 1.3.4.2 rmind * documentation and/or other materials provided with the distribution.
18 1.3.4.2 rmind *
19 1.3.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.3.4.2 rmind * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.3.4.2 rmind * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.3.4.2 rmind * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.3.4.2 rmind * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.3.4.2 rmind * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.3.4.2 rmind * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.3.4.2 rmind * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.3.4.2 rmind * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.3.4.2 rmind * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.3.4.2 rmind * POSSIBILITY OF SUCH DAMAGE.
30 1.3.4.2 rmind */
31 1.3.4.2 rmind
32 1.3.4.2 rmind #ifndef _DWC2VAR_H_
33 1.3.4.2 rmind #define _DWC2VAR_H_
34 1.3.4.2 rmind
35 1.3.4.2 rmind #include <sys/pool.h>
36 1.3.4.2 rmind
37 1.3.4.2 rmind #define DWC2_MAXISOCPACKETS 16
38 1.3.4.2 rmind struct dwc2_hsotg;
39 1.3.4.2 rmind struct dwc2_qtd;
40 1.3.4.2 rmind
41 1.3.4.2 rmind struct dwc2_xfer {
42 1.3.4.2 rmind struct usbd_xfer xfer; /* Needs to be first */
43 1.3.4.2 rmind struct usb_task abort_task;
44 1.3.4.2 rmind
45 1.3.4.2 rmind struct dwc2_hcd_urb *urb;
46 1.3.4.2 rmind int packet_count;
47 1.3.4.2 rmind
48 1.3.4.2 rmind TAILQ_ENTRY(dwc2_xfer) xnext; /* list of complete xfers */
49 1.3.4.2 rmind };
50 1.3.4.2 rmind
51 1.3.4.2 rmind struct dwc2_pipe {
52 1.3.4.2 rmind struct usbd_pipe pipe; /* Must be first */
53 1.3.4.2 rmind
54 1.3.4.2 rmind /* Current transfer */
55 1.3.4.2 rmind void *priv; /* QH */
56 1.3.4.2 rmind
57 1.3.4.2 rmind /* DMA buffer for control endpoint requests */
58 1.3.4.2 rmind usb_dma_t req_dma;
59 1.3.4.2 rmind };
60 1.3.4.2 rmind
61 1.3.4.2 rmind
62 1.3.4.2 rmind #define DWC2_BUS2SC(bus) ((bus)->hci_private)
63 1.3.4.2 rmind #define DWC2_PIPE2SC(pipe) DWC2_BUS2SC((pipe)->device->bus)
64 1.3.4.2 rmind #define DWC2_XFER2SC(xfer) DWC2_PIPE2SC((xfer)->pipe)
65 1.3.4.2 rmind #define DWC2_DPIPE2SC(d) DWC2_BUS2SC((d)->pipe.device->bus)
66 1.3.4.2 rmind
67 1.3.4.2 rmind #define DWC2_XFER2DXFER(x) (struct dwc2_xfer *)(x)
68 1.3.4.2 rmind
69 1.3.4.2 rmind #define DWC2_XFER2DPIPE(x) (struct dwc2_pipe *)(x)->pipe;
70 1.3.4.2 rmind #define DWC2_PIPE2DPIPE(p) (struct dwc2_pipe *)(p)
71 1.3.4.2 rmind
72 1.3.4.2 rmind
73 1.3.4.2 rmind typedef struct dwc2_softc {
74 1.3.4.2 rmind device_t sc_dev;
75 1.3.4.2 rmind
76 1.3.4.2 rmind bus_space_tag_t sc_iot;
77 1.3.4.2 rmind bus_space_handle_t sc_ioh;
78 1.3.4.2 rmind bus_dma_tag_t sc_dmat;
79 1.3.4.2 rmind struct dwc2_core_params *sc_params;
80 1.3.4.2 rmind
81 1.3.4.2 rmind /*
82 1.3.4.2 rmind * Private
83 1.3.4.2 rmind */
84 1.3.4.2 rmind
85 1.3.4.2 rmind struct usbd_bus sc_bus;
86 1.3.4.2 rmind struct dwc2_hsotg *sc_hsotg;
87 1.3.4.2 rmind
88 1.3.4.2 rmind kmutex_t sc_lock;
89 1.3.4.2 rmind
90 1.3.4.2 rmind bool sc_hcdenabled;
91 1.3.4.2 rmind void *sc_rhc_si;
92 1.3.4.2 rmind
93 1.3.4.2 rmind usbd_xfer_handle sc_intrxfer;
94 1.3.4.2 rmind
95 1.3.4.2 rmind device_t sc_child; /* /dev/usb# device */
96 1.3.4.2 rmind char sc_dying;
97 1.3.4.2 rmind struct usb_dma_reserve sc_dma_reserve;
98 1.3.4.2 rmind
99 1.3.4.2 rmind char sc_vendor[32]; /* vendor string for root hub */
100 1.3.4.2 rmind int sc_id_vendor; /* vendor ID for root hub */
101 1.3.4.2 rmind
102 1.3.4.2 rmind TAILQ_HEAD(, dwc2_xfer) sc_complete; /* complete transfers */
103 1.3.4.2 rmind
104 1.3.4.2 rmind uint8_t sc_addr; /* device address */
105 1.3.4.2 rmind uint8_t sc_conf; /* device configuration */
106 1.3.4.2 rmind
107 1.3.4.2 rmind pool_cache_t sc_xferpool;
108 1.3.4.2 rmind pool_cache_t sc_qhpool;
109 1.3.4.2 rmind pool_cache_t sc_qtdpool;
110 1.3.4.2 rmind
111 1.3.4.2 rmind } dwc2_softc_t;
112 1.3.4.2 rmind
113 1.3.4.2 rmind int dwc2_init(struct dwc2_softc *);
114 1.3.4.2 rmind int dwc2_intr(void *);
115 1.3.4.2 rmind int dwc2_detach(dwc2_softc_t *, int);
116 1.3.4.2 rmind bool dwc2_shutdown(device_t, int);
117 1.3.4.2 rmind void dwc2_childdet(device_t, device_t);
118 1.3.4.2 rmind int dwc2_activate(device_t, enum devact);
119 1.3.4.2 rmind bool dwc2_resume(device_t, const pmf_qual_t *);
120 1.3.4.2 rmind bool dwc2_suspend(device_t, const pmf_qual_t *);
121 1.3.4.2 rmind
122 1.3.4.2 rmind void dwc2_worker(struct work *, void *);
123 1.3.4.2 rmind
124 1.3.4.2 rmind void dwc2_host_complete(struct dwc2_hsotg *, struct dwc2_qtd *,
125 1.3.4.2 rmind int);
126 1.3.4.2 rmind
127 1.3.4.2 rmind static inline void
128 1.3.4.2 rmind dwc2_root_intr(dwc2_softc_t *sc)
129 1.3.4.2 rmind {
130 1.3.4.2 rmind
131 1.3.4.2 rmind softint_schedule(sc->sc_rhc_si);
132 1.3.4.2 rmind }
133 1.3.4.2 rmind
134 1.3.4.2 rmind #endif /* _DWC_OTGVAR_H_ */
135