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