1 /* $FreeBSD$ */
2
3 /*-
4 * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28 #ifndef _OCTUSB_H_
29 #define _OCTUSB_H_
30
31 #define OCTUSB_MAX_DEVICES MIN(USB_MAX_DEVICES, 64)
32 /*
33 * The second port is on a different IRQ and so we disable it for now.
34 */
35 #if 1
36 #define OCTUSB_MAX_PORTS 1 /* hardcoded */
37 #else
38 #define OCTUSB_MAX_PORTS 2 /* hardcoded */
39 #endif
40 #define OCTUSB_MAX_FIXUP 4096 /* bytes */
41 #define OCTUSB_INTR_ENDPT 0x01
42
43 struct octusb_qh;
44 struct octusb_td;
45 struct octusb_softc;
46
47 typedef uint8_t (octusb_cmd_t)(struct octusb_td *td);
48
49 struct octusb_td {
50 struct octusb_qh *qh;
51 struct octusb_td *obj_next;
52 struct usb_page_cache *pc;
53 octusb_cmd_t *func;
54
55 uint32_t remainder;
56 uint32_t offset;
57
58 uint8_t error_any:1;
59 uint8_t error_stall:1;
60 uint8_t short_pkt:1;
61 uint8_t alt_next:1;
62 uint8_t reserved:4;
63 };
64
65 struct octusb_qh {
66
67 uint64_t fixup_phys;
68
69 struct octusb_softc *sc;
70 struct usb_page_cache *fixup_pc;
71 uint8_t *fixup_buf;
72
73 cvmx_usb_iso_packet_t iso_pkt;
74
75 uint32_t fixup_off;
76
77 uint16_t max_frame_size;
78 uint16_t max_packet_size;
79 uint16_t fixup_actlen;
80 uint16_t fixup_len;
81 uint16_t ep_interval;
82
83 uint8_t dev_addr;
84 uint8_t dev_speed;
85 uint8_t ep_allocated;
86 uint8_t ep_mult;
87 uint8_t ep_num;
88 uint8_t ep_type;
89 uint8_t ep_toggle_next;
90 uint8_t port_index;
91 uint8_t fixup_complete;
92 uint8_t fixup_pending;
93 uint8_t hs_hub_addr;
94 uint8_t hs_hub_port;
95
96 int fixup_handle;
97 int ep_handle;
98 };
99
100 struct octusb_config_desc {
101 struct usb_config_descriptor confd;
102 struct usb_interface_descriptor ifcd;
103 struct usb_endpoint_descriptor endpd;
104 } __packed;
105
106 union octusb_hub_desc {
107 struct usb_status stat;
108 struct usb_port_status ps;
109 uint8_t temp[128];
110 };
111
112 struct octusb_port {
113 cvmx_usb_state_t state;
114 uint8_t disabled;
115 };
116
117 struct octusb_softc {
118
119 struct usb_bus sc_bus; /* base device */
120 union octusb_hub_desc sc_hub_desc;
121
122 struct usb_device *sc_devices[OCTUSB_MAX_DEVICES];
123
124 struct resource *sc_irq_res;
125 void *sc_intr_hdl;
126
127 struct octusb_port sc_port[OCTUSB_MAX_PORTS];
128 device_t sc_dev;
129
130 struct usb_hub_descriptor_min sc_hubd;
131
132 uint8_t sc_noport; /* number of ports */
133 uint8_t sc_addr; /* device address */
134 uint8_t sc_conf; /* device configuration */
135 uint8_t sc_isreset; /* set if current port is reset */
136
137 uint8_t sc_hub_idata[1];
138 };
139
140 usb_bus_mem_cb_t octusb_iterate_hw_softc;
141 usb_error_t octusb_init(struct octusb_softc *);
142 usb_error_t octusb_uninit(struct octusb_softc *);
143 void octusb_interrupt(struct octusb_softc *);
144
145 #endif /* _OCTUSB_H_ */
Cache object: b729371adea4d28c107ce6c40851e6d0
|