dwc2var.h revision 1.3.10.3 1 1.3.10.2 tls /* $NetBSD: dwc2var.h,v 1.3.10.3 2017/12/03 11:38:01 jdolecek 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 struct dwc2_hsotg;
38 1.3.10.2 tls struct dwc2_qtd;
39 1.3.10.2 tls
40 1.3.10.2 tls struct dwc2_xfer {
41 1.3.10.2 tls struct usbd_xfer xfer; /* Needs to be first */
42 1.3.10.3 jdolecek struct usb_task abort_task;
43 1.3.10.2 tls
44 1.3.10.2 tls struct dwc2_hcd_urb *urb;
45 1.3.10.2 tls
46 1.3.10.2 tls TAILQ_ENTRY(dwc2_xfer) xnext; /* list of complete xfers */
47 1.3.10.2 tls };
48 1.3.10.2 tls
49 1.3.10.2 tls struct dwc2_pipe {
50 1.3.10.2 tls struct usbd_pipe pipe; /* Must be first */
51 1.3.10.2 tls
52 1.3.10.2 tls /* Current transfer */
53 1.3.10.2 tls void *priv; /* QH */
54 1.3.10.2 tls
55 1.3.10.2 tls /* DMA buffer for control endpoint requests */
56 1.3.10.2 tls usb_dma_t req_dma;
57 1.3.10.2 tls };
58 1.3.10.2 tls
59 1.3.10.2 tls
60 1.3.10.3 jdolecek #define DWC2_BUS2SC(bus) ((bus)->ub_hcpriv)
61 1.3.10.3 jdolecek #define DWC2_PIPE2SC(pipe) DWC2_BUS2SC((pipe)->up_dev->ud_bus)
62 1.3.10.3 jdolecek #define DWC2_XFER2SC(xfer) DWC2_BUS2SC((xfer)->ux_bus)
63 1.3.10.3 jdolecek #define DWC2_DPIPE2SC(d) DWC2_BUS2SC((d)->pipe.up_dev->ud_bus)
64 1.3.10.2 tls
65 1.3.10.2 tls #define DWC2_XFER2DXFER(x) (struct dwc2_xfer *)(x)
66 1.3.10.2 tls
67 1.3.10.3 jdolecek #define DWC2_XFER2DPIPE(x) (struct dwc2_pipe *)(x)->ux_pipe;
68 1.3.10.2 tls #define DWC2_PIPE2DPIPE(p) (struct dwc2_pipe *)(p)
69 1.3.10.2 tls
70 1.3.10.2 tls
71 1.3.10.2 tls typedef struct dwc2_softc {
72 1.3.10.2 tls device_t sc_dev;
73 1.3.10.2 tls
74 1.3.10.2 tls bus_space_tag_t sc_iot;
75 1.3.10.2 tls bus_space_handle_t sc_ioh;
76 1.3.10.2 tls bus_dma_tag_t sc_dmat;
77 1.3.10.2 tls struct dwc2_core_params *sc_params;
78 1.3.10.3 jdolecek int (*sc_set_dma_addr)(device_t, bus_addr_t, int);
79 1.3.10.2 tls
80 1.3.10.2 tls /*
81 1.3.10.2 tls * Private
82 1.3.10.2 tls */
83 1.3.10.2 tls
84 1.3.10.2 tls struct usbd_bus sc_bus;
85 1.3.10.2 tls struct dwc2_hsotg *sc_hsotg;
86 1.3.10.2 tls
87 1.3.10.2 tls kmutex_t sc_lock;
88 1.3.10.2 tls
89 1.3.10.2 tls bool sc_hcdenabled;
90 1.3.10.2 tls void *sc_rhc_si;
91 1.3.10.2 tls
92 1.3.10.3 jdolecek struct usbd_xfer *sc_intrxfer;
93 1.3.10.2 tls
94 1.3.10.2 tls device_t sc_child; /* /dev/usb# device */
95 1.3.10.2 tls char sc_dying;
96 1.3.10.2 tls
97 1.3.10.2 tls TAILQ_HEAD(, dwc2_xfer) sc_complete; /* complete transfers */
98 1.3.10.2 tls
99 1.3.10.2 tls pool_cache_t sc_xferpool;
100 1.3.10.2 tls pool_cache_t sc_qhpool;
101 1.3.10.2 tls pool_cache_t sc_qtdpool;
102 1.3.10.2 tls
103 1.3.10.2 tls } dwc2_softc_t;
104 1.3.10.2 tls
105 1.3.10.2 tls int dwc2_init(struct dwc2_softc *);
106 1.3.10.2 tls int dwc2_intr(void *);
107 1.3.10.2 tls int dwc2_detach(dwc2_softc_t *, int);
108 1.3.10.2 tls bool dwc2_shutdown(device_t, int);
109 1.3.10.2 tls void dwc2_childdet(device_t, device_t);
110 1.3.10.2 tls int dwc2_activate(device_t, enum devact);
111 1.3.10.2 tls bool dwc2_resume(device_t, const pmf_qual_t *);
112 1.3.10.2 tls bool dwc2_suspend(device_t, const pmf_qual_t *);
113 1.3.10.2 tls
114 1.3.10.2 tls void dwc2_worker(struct work *, void *);
115 1.3.10.2 tls
116 1.3.10.2 tls void dwc2_host_complete(struct dwc2_hsotg *, struct dwc2_qtd *,
117 1.3.10.2 tls int);
118 1.3.10.2 tls
119 1.3.10.2 tls static inline void
120 1.3.10.2 tls dwc2_root_intr(dwc2_softc_t *sc)
121 1.3.10.2 tls {
122 1.3.10.2 tls
123 1.3.10.2 tls softint_schedule(sc->sc_rhc_si);
124 1.3.10.2 tls }
125 1.3.10.2 tls
126 1.3.10.2 tls #endif /* _DWC_OTGVAR_H_ */
127