uipaq.c revision 1.2.18.7 1 1.2.18.7 yamt /* $NetBSD: uipaq.c,v 1.2.18.7 2008/02/27 08:36:47 yamt Exp $ */
2 1.2.18.2 yamt /* $OpenBSD: uipaq.c,v 1.1 2005/06/17 23:50:33 deraadt Exp $ */
3 1.2.18.2 yamt
4 1.2.18.2 yamt /*
5 1.2.18.2 yamt * Copyright (c) 2000-2005 The NetBSD Foundation, Inc.
6 1.2.18.2 yamt * All rights reserved.
7 1.2.18.2 yamt *
8 1.2.18.2 yamt * This code is derived from software contributed to The NetBSD Foundation
9 1.2.18.2 yamt * by Lennart Augustsson (lennart (at) augustsson.net) at
10 1.2.18.2 yamt * Carlstedt Research & Technology.
11 1.2.18.2 yamt *
12 1.2.18.2 yamt * Redistribution and use in source and binary forms, with or without
13 1.2.18.2 yamt * modification, are permitted provided that the following conditions
14 1.2.18.2 yamt * are met:
15 1.2.18.2 yamt * 1. Redistributions of source code must retain the above copyright
16 1.2.18.2 yamt * notice, this list of conditions and the following disclaimer.
17 1.2.18.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
18 1.2.18.2 yamt * notice, this list of conditions and the following disclaimer in the
19 1.2.18.2 yamt * documentation and/or other materials provided with the distribution.
20 1.2.18.2 yamt * 3. All advertising materials mentioning features or use of this software
21 1.2.18.2 yamt * must display the following acknowledgement:
22 1.2.18.2 yamt * This product includes software developed by the NetBSD
23 1.2.18.2 yamt * Foundation, Inc. and its contributors.
24 1.2.18.2 yamt * 4. Neither the name of The NetBSD Foundation nor the names of its
25 1.2.18.2 yamt * contributors may be used to endorse or promote products derived
26 1.2.18.2 yamt * from this software without specific prior written permission.
27 1.2.18.2 yamt *
28 1.2.18.2 yamt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29 1.2.18.2 yamt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30 1.2.18.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 1.2.18.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32 1.2.18.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 1.2.18.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 1.2.18.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 1.2.18.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 1.2.18.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 1.2.18.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 1.2.18.2 yamt * POSSIBILITY OF SUCH DAMAGE.
39 1.2.18.2 yamt */
40 1.2.18.2 yamt
41 1.2.18.2 yamt /*
42 1.2.18.2 yamt * iPAQ driver
43 1.2.18.2 yamt *
44 1.2.18.2 yamt * 19 July 2003: Incorporated changes suggested by Sam Lawrance from
45 1.2.18.2 yamt * the uppc module
46 1.2.18.2 yamt *
47 1.2.18.2 yamt *
48 1.2.18.2 yamt * Contact isis (at) cs.umd.edu if you have any questions/comments about this driver
49 1.2.18.2 yamt */
50 1.2.18.2 yamt
51 1.2.18.6 yamt #include <sys/cdefs.h>
52 1.2.18.7 yamt __KERNEL_RCSID(0, "$NetBSD: uipaq.c,v 1.2.18.7 2008/02/27 08:36:47 yamt Exp $");
53 1.2.18.6 yamt
54 1.2.18.2 yamt #include <sys/param.h>
55 1.2.18.2 yamt #include <sys/systm.h>
56 1.2.18.2 yamt #include <sys/kernel.h>
57 1.2.18.2 yamt #include <sys/device.h>
58 1.2.18.2 yamt #include <sys/conf.h>
59 1.2.18.2 yamt #include <sys/tty.h>
60 1.2.18.2 yamt
61 1.2.18.2 yamt #include <dev/usb/usb.h>
62 1.2.18.2 yamt
63 1.2.18.2 yamt #include <dev/usb/usbcdc.h> /*UCDC_* stuff */
64 1.2.18.2 yamt
65 1.2.18.2 yamt #include <dev/usb/usbdi.h>
66 1.2.18.2 yamt #include <dev/usb/usbdi_util.h>
67 1.2.18.2 yamt #include <dev/usb/usbdevs.h>
68 1.2.18.2 yamt
69 1.2.18.2 yamt #include <dev/usb/ucomvar.h>
70 1.2.18.2 yamt
71 1.2.18.2 yamt #ifdef UIPAQ_DEBUG
72 1.2.18.2 yamt #define DPRINTF(x) if (uipaqdebug) printf x
73 1.2.18.2 yamt #define DPRINTFN(n,x) if (uipaqdebug>(n)) printf x
74 1.2.18.2 yamt int uipaqdebug = 0;
75 1.2.18.2 yamt #else
76 1.2.18.2 yamt #define DPRINTF(x)
77 1.2.18.2 yamt #define DPRINTFN(n,x)
78 1.2.18.2 yamt #endif
79 1.2.18.2 yamt
80 1.2.18.2 yamt #define UIPAQ_CONFIG_NO 1
81 1.2.18.2 yamt #define UIPAQ_IFACE_INDEX 0
82 1.2.18.2 yamt
83 1.2.18.2 yamt #define UIPAQIBUFSIZE 1024
84 1.2.18.2 yamt #define UIPAQOBUFSIZE 1024
85 1.2.18.2 yamt
86 1.2.18.2 yamt struct uipaq_softc {
87 1.2.18.2 yamt USBBASEDEVICE sc_dev; /* base device */
88 1.2.18.2 yamt usbd_device_handle sc_udev; /* device */
89 1.2.18.2 yamt usbd_interface_handle sc_iface; /* interface */
90 1.2.18.2 yamt
91 1.2.18.7 yamt device_t sc_subdev; /* ucom uses that */
92 1.2.18.2 yamt u_int16_t sc_lcr; /* state for DTR/RTS */
93 1.2.18.2 yamt
94 1.2.18.2 yamt u_int16_t sc_flags;
95 1.2.18.2 yamt
96 1.2.18.2 yamt u_char sc_dying;
97 1.2.18.2 yamt };
98 1.2.18.2 yamt
99 1.2.18.2 yamt /* Callback routines */
100 1.2.18.2 yamt Static void uipaq_set(void *, int, int, int);
101 1.2.18.2 yamt
102 1.2.18.2 yamt
103 1.2.18.2 yamt /* Support routines. */
104 1.2.18.2 yamt /* based on uppc module by Sam Lawrance */
105 1.2.18.2 yamt Static void uipaq_dtr(struct uipaq_softc *sc, int onoff);
106 1.2.18.2 yamt Static void uipaq_rts(struct uipaq_softc *sc, int onoff);
107 1.2.18.2 yamt Static void uipaq_break(struct uipaq_softc* sc, int onoff);
108 1.2.18.2 yamt
109 1.2.18.2 yamt
110 1.2.18.2 yamt struct ucom_methods uipaq_methods = {
111 1.2.18.2 yamt NULL,
112 1.2.18.2 yamt uipaq_set,
113 1.2.18.2 yamt NULL,
114 1.2.18.2 yamt NULL,
115 1.2.18.2 yamt NULL, /*open*/
116 1.2.18.2 yamt NULL, /*close*/
117 1.2.18.2 yamt NULL,
118 1.2.18.2 yamt NULL
119 1.2.18.2 yamt };
120 1.2.18.2 yamt
121 1.2.18.2 yamt struct uipaq_type {
122 1.2.18.2 yamt struct usb_devno uv_dev;
123 1.2.18.2 yamt u_int16_t uv_flags;
124 1.2.18.2 yamt };
125 1.2.18.2 yamt
126 1.2.18.2 yamt static const struct uipaq_type uipaq_devs[] = {
127 1.2.18.2 yamt {{ USB_VENDOR_HP, USB_PRODUCT_HP_2215 }, 0 },
128 1.2.18.2 yamt {{ USB_VENDOR_HP, USB_PRODUCT_HP_568J }, 0},
129 1.2.18.2 yamt {{ USB_VENDOR_COMPAQ, USB_PRODUCT_COMPAQ_IPAQPOCKETPC} , 0},
130 1.2.18.3 yamt {{ USB_VENDOR_CASIO, USB_PRODUCT_CASIO_BE300} , 0},
131 1.2.18.3 yamt {{ USB_VENDOR_SHARP, USB_PRODUCT_SHARP_WS007SH} , 0}
132 1.2.18.2 yamt };
133 1.2.18.2 yamt
134 1.2.18.2 yamt #define uipaq_lookup(v, p) ((const struct uipaq_type *)usb_lookup(uipaq_devs, v, p))
135 1.2.18.2 yamt
136 1.2.18.7 yamt int uipaq_match(device_t, struct cfdata *, void *);
137 1.2.18.7 yamt void uipaq_attach(device_t, device_t, void *);
138 1.2.18.7 yamt void uipaq_childdet(device_t, device_t);
139 1.2.18.7 yamt int uipaq_detach(device_t, int);
140 1.2.18.7 yamt int uipaq_activate(device_t, enum devact);
141 1.2.18.7 yamt extern struct cfdriver uipaq_cd;
142 1.2.18.7 yamt CFATTACH_DECL2(uipaq, sizeof(struct uipaq_softc), uipaq_match,
143 1.2.18.7 yamt uipaq_attach, uipaq_detach, uipaq_activate, NULL, uipaq_childdet);
144 1.2.18.2 yamt
145 1.2.18.2 yamt USB_MATCH(uipaq)
146 1.2.18.2 yamt {
147 1.2.18.2 yamt USB_MATCH_START(uipaq, uaa);
148 1.2.18.2 yamt
149 1.2.18.2 yamt DPRINTFN(20,("uipaq: vendor=0x%x, product=0x%x\n",
150 1.2.18.2 yamt uaa->vendor, uaa->product));
151 1.2.18.2 yamt
152 1.2.18.2 yamt return (uipaq_lookup(uaa->vendor, uaa->product) != NULL ?
153 1.2.18.2 yamt UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
154 1.2.18.2 yamt }
155 1.2.18.2 yamt
156 1.2.18.2 yamt USB_ATTACH(uipaq)
157 1.2.18.2 yamt {
158 1.2.18.2 yamt USB_ATTACH_START(uipaq, sc, uaa);
159 1.2.18.2 yamt usbd_device_handle dev = uaa->device;
160 1.2.18.2 yamt usbd_interface_handle iface;
161 1.2.18.2 yamt usb_interface_descriptor_t *id;
162 1.2.18.2 yamt usb_endpoint_descriptor_t *ed;
163 1.2.18.2 yamt char *devinfop;
164 1.2.18.2 yamt char *devname = USBDEVNAME(sc->sc_dev);
165 1.2.18.2 yamt int i;
166 1.2.18.2 yamt usbd_status err;
167 1.2.18.2 yamt struct ucom_attach_args uca;
168 1.2.18.2 yamt
169 1.2.18.2 yamt DPRINTFN(10,("\nuipaq_attach: sc=%p\n", sc));
170 1.2.18.2 yamt
171 1.2.18.2 yamt /* Move the device into the configured state. */
172 1.2.18.2 yamt err = usbd_set_config_no(dev, UIPAQ_CONFIG_NO, 1);
173 1.2.18.2 yamt if (err) {
174 1.2.18.2 yamt printf("\n%s: failed to set configuration, err=%s\n",
175 1.2.18.2 yamt devname, usbd_errstr(err));
176 1.2.18.2 yamt goto bad;
177 1.2.18.2 yamt }
178 1.2.18.2 yamt
179 1.2.18.2 yamt err = usbd_device2interface_handle(dev, UIPAQ_IFACE_INDEX, &iface);
180 1.2.18.2 yamt if (err) {
181 1.2.18.2 yamt printf("\n%s: failed to get interface, err=%s\n",
182 1.2.18.2 yamt devname, usbd_errstr(err));
183 1.2.18.2 yamt goto bad;
184 1.2.18.2 yamt }
185 1.2.18.2 yamt
186 1.2.18.2 yamt devinfop = usbd_devinfo_alloc(dev, 0);
187 1.2.18.2 yamt USB_ATTACH_SETUP;
188 1.2.18.2 yamt printf("%s: %s\n", devname, devinfop);
189 1.2.18.2 yamt usbd_devinfo_free(devinfop);
190 1.2.18.2 yamt
191 1.2.18.2 yamt sc->sc_flags = uipaq_lookup(uaa->vendor, uaa->product)->uv_flags;
192 1.2.18.2 yamt
193 1.2.18.2 yamt id = usbd_get_interface_descriptor(iface);
194 1.2.18.2 yamt
195 1.2.18.2 yamt sc->sc_udev = dev;
196 1.2.18.2 yamt sc->sc_iface = iface;
197 1.2.18.2 yamt
198 1.2.18.2 yamt uca.ibufsize = UIPAQIBUFSIZE;
199 1.2.18.2 yamt uca.obufsize = UIPAQOBUFSIZE;
200 1.2.18.2 yamt uca.ibufsizepad = UIPAQIBUFSIZE;
201 1.2.18.2 yamt uca.opkthdrlen = 0;
202 1.2.18.2 yamt uca.device = dev;
203 1.2.18.2 yamt uca.iface = iface;
204 1.2.18.2 yamt uca.methods = &uipaq_methods;
205 1.2.18.2 yamt uca.arg = sc;
206 1.2.18.2 yamt uca.portno = UCOM_UNK_PORTNO;
207 1.2.18.2 yamt uca.info = "Generic";
208 1.2.18.2 yamt
209 1.2.18.2 yamt /* err = uipaq_init(sc);
210 1.2.18.2 yamt if (err) {
211 1.2.18.2 yamt printf("%s: init failed, %s\n", USBDEVNAME(sc->sc_dev),
212 1.2.18.2 yamt usbd_errstr(err));
213 1.2.18.2 yamt goto bad;
214 1.2.18.2 yamt }*/
215 1.2.18.2 yamt
216 1.2.18.2 yamt usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
217 1.2.18.2 yamt USBDEV(sc->sc_dev));
218 1.2.18.2 yamt
219 1.2.18.2 yamt uca.bulkin = uca.bulkout = -1;
220 1.2.18.2 yamt for (i=0; i<id->bNumEndpoints; i++) {
221 1.2.18.2 yamt ed = usbd_interface2endpoint_descriptor(iface, i);
222 1.2.18.2 yamt if (ed == NULL) {
223 1.2.18.2 yamt printf("%s: no endpoint descriptor for %d\n",
224 1.2.18.2 yamt devname,i);
225 1.2.18.2 yamt goto bad;
226 1.2.18.2 yamt }
227 1.2.18.2 yamt if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
228 1.2.18.2 yamt (ed->bmAttributes & UE_XFERTYPE) == UE_BULK) {
229 1.2.18.2 yamt uca.bulkin = ed->bEndpointAddress;
230 1.2.18.2 yamt } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
231 1.2.18.2 yamt (ed->bmAttributes & UE_XFERTYPE) == UE_BULK) {
232 1.2.18.2 yamt uca.bulkout = ed->bEndpointAddress;
233 1.2.18.2 yamt }
234 1.2.18.2 yamt }
235 1.2.18.2 yamt if (uca.bulkin == -1 || uca.bulkout == -1) {
236 1.2.18.2 yamt printf("%s: no proper endpoints found (%d,%d) \n",
237 1.2.18.2 yamt devname, uca.bulkin, uca.bulkout);
238 1.2.18.2 yamt USB_ATTACH_ERROR_RETURN;
239 1.2.18.2 yamt }
240 1.2.18.2 yamt
241 1.2.18.2 yamt sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, &uca,
242 1.2.18.2 yamt ucomprint, ucomsubmatch);
243 1.2.18.2 yamt
244 1.2.18.2 yamt USB_ATTACH_SUCCESS_RETURN;
245 1.2.18.2 yamt
246 1.2.18.2 yamt bad:
247 1.2.18.2 yamt DPRINTF(("uipaq_attach: ATTACH ERROR\n"));
248 1.2.18.2 yamt sc->sc_dying = 1;
249 1.2.18.2 yamt USB_ATTACH_ERROR_RETURN;
250 1.2.18.2 yamt }
251 1.2.18.2 yamt
252 1.2.18.2 yamt
253 1.2.18.2 yamt void
254 1.2.18.2 yamt uipaq_dtr(struct uipaq_softc* sc, int onoff)
255 1.2.18.2 yamt {
256 1.2.18.2 yamt usb_device_request_t req;
257 1.2.18.2 yamt usbd_status err;
258 1.2.18.2 yamt int retries = 3;
259 1.2.18.2 yamt
260 1.2.18.2 yamt DPRINTF(("%s: uipaq_dtr: onoff=%x\n", USBDEVNAME(sc->sc_dev), onoff));
261 1.2.18.2 yamt
262 1.2.18.2 yamt /* Avoid sending unnecessary requests */
263 1.2.18.2 yamt if (onoff && (sc->sc_lcr & UCDC_LINE_DTR))
264 1.2.18.2 yamt return;
265 1.2.18.2 yamt if (!onoff && !(sc->sc_lcr & UCDC_LINE_DTR))
266 1.2.18.2 yamt return;
267 1.2.18.2 yamt
268 1.2.18.2 yamt /* Other parameters depend on reg */
269 1.2.18.2 yamt req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
270 1.2.18.2 yamt req.bRequest = UCDC_SET_CONTROL_LINE_STATE;
271 1.2.18.2 yamt sc->sc_lcr = onoff ? sc->sc_lcr | UCDC_LINE_DTR : sc->sc_lcr & ~UCDC_LINE_DTR;
272 1.2.18.2 yamt USETW(req.wValue, sc->sc_lcr);
273 1.2.18.2 yamt USETW(req.wIndex, 0x0);
274 1.2.18.2 yamt USETW(req.wLength, 0);
275 1.2.18.2 yamt
276 1.2.18.2 yamt /* Fire off the request a few times if necessary */
277 1.2.18.2 yamt while (retries) {
278 1.2.18.2 yamt err = usbd_do_request(sc->sc_udev, &req, NULL);
279 1.2.18.2 yamt if (!err)
280 1.2.18.2 yamt break;
281 1.2.18.2 yamt retries--;
282 1.2.18.2 yamt }
283 1.2.18.2 yamt }
284 1.2.18.2 yamt
285 1.2.18.2 yamt
286 1.2.18.2 yamt void
287 1.2.18.2 yamt uipaq_rts(struct uipaq_softc* sc, int onoff)
288 1.2.18.2 yamt {
289 1.2.18.2 yamt usb_device_request_t req;
290 1.2.18.2 yamt usbd_status err;
291 1.2.18.2 yamt int retries = 3;
292 1.2.18.2 yamt
293 1.2.18.2 yamt DPRINTF(("%s: uipaq_rts: onoff=%x\n", USBDEVNAME(sc->sc_dev), onoff));
294 1.2.18.2 yamt
295 1.2.18.2 yamt /* Avoid sending unnecessary requests */
296 1.2.18.2 yamt if (onoff && (sc->sc_lcr & UCDC_LINE_RTS)) return;
297 1.2.18.2 yamt if (!onoff && !(sc->sc_lcr & UCDC_LINE_RTS)) return;
298 1.2.18.2 yamt
299 1.2.18.2 yamt req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
300 1.2.18.2 yamt req.bRequest = UCDC_SET_CONTROL_LINE_STATE;
301 1.2.18.2 yamt sc->sc_lcr = onoff ? sc->sc_lcr | UCDC_LINE_RTS : sc->sc_lcr & ~UCDC_LINE_RTS;
302 1.2.18.2 yamt USETW(req.wValue, sc->sc_lcr);
303 1.2.18.2 yamt USETW(req.wIndex, 0x0);
304 1.2.18.2 yamt USETW(req.wLength, 0);
305 1.2.18.2 yamt
306 1.2.18.2 yamt while (retries) {
307 1.2.18.2 yamt err = usbd_do_request(sc->sc_udev, &req, NULL);
308 1.2.18.2 yamt if (!err)
309 1.2.18.2 yamt break;
310 1.2.18.2 yamt retries--;
311 1.2.18.2 yamt }
312 1.2.18.2 yamt }
313 1.2.18.2 yamt
314 1.2.18.2 yamt
315 1.2.18.2 yamt void
316 1.2.18.2 yamt uipaq_break(struct uipaq_softc* sc, int onoff)
317 1.2.18.2 yamt {
318 1.2.18.2 yamt usb_device_request_t req;
319 1.2.18.2 yamt usbd_status err;
320 1.2.18.2 yamt int retries = 3;
321 1.2.18.2 yamt
322 1.2.18.2 yamt DPRINTF(("%s: uipaq_break: onoff=%x\n", USBDEVNAME(sc->sc_dev), onoff));
323 1.2.18.2 yamt
324 1.2.18.2 yamt req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
325 1.2.18.2 yamt req.bRequest = UCDC_SEND_BREAK;
326 1.2.18.2 yamt
327 1.2.18.2 yamt USETW(req.wValue, onoff ? UCDC_BREAK_ON : UCDC_BREAK_OFF);
328 1.2.18.2 yamt USETW(req.wIndex, 0x0);
329 1.2.18.2 yamt USETW(req.wLength, 0);
330 1.2.18.2 yamt
331 1.2.18.2 yamt while (retries) {
332 1.2.18.2 yamt err = usbd_do_request(sc->sc_udev, &req, NULL);
333 1.2.18.2 yamt if (!err)
334 1.2.18.2 yamt break;
335 1.2.18.2 yamt retries--;
336 1.2.18.2 yamt }
337 1.2.18.2 yamt }
338 1.2.18.2 yamt
339 1.2.18.2 yamt
340 1.2.18.2 yamt void
341 1.2.18.2 yamt uipaq_set(void *addr, int portno, int reg, int onoff)
342 1.2.18.2 yamt {
343 1.2.18.2 yamt struct uipaq_softc* sc = addr;
344 1.2.18.2 yamt
345 1.2.18.2 yamt switch (reg) {
346 1.2.18.2 yamt case UCOM_SET_DTR:
347 1.2.18.2 yamt uipaq_dtr(addr, onoff);
348 1.2.18.2 yamt break;
349 1.2.18.2 yamt case UCOM_SET_RTS:
350 1.2.18.2 yamt uipaq_rts(addr, onoff);
351 1.2.18.2 yamt break;
352 1.2.18.2 yamt case UCOM_SET_BREAK:
353 1.2.18.2 yamt uipaq_break(addr, onoff);
354 1.2.18.2 yamt break;
355 1.2.18.2 yamt default:
356 1.2.18.2 yamt printf("%s: unhandled set request: reg=%x onoff=%x\n",
357 1.2.18.2 yamt USBDEVNAME(sc->sc_dev), reg, onoff);
358 1.2.18.2 yamt return;
359 1.2.18.2 yamt }
360 1.2.18.2 yamt }
361 1.2.18.2 yamt
362 1.2.18.2 yamt
363 1.2.18.2 yamt int
364 1.2.18.7 yamt uipaq_activate(device_t self, enum devact act)
365 1.2.18.2 yamt {
366 1.2.18.7 yamt struct uipaq_softc *sc = device_private(self);
367 1.2.18.2 yamt int rv = 0;
368 1.2.18.2 yamt
369 1.2.18.2 yamt switch (act) {
370 1.2.18.2 yamt case DVACT_ACTIVATE:
371 1.2.18.2 yamt return (EOPNOTSUPP);
372 1.2.18.2 yamt break;
373 1.2.18.2 yamt
374 1.2.18.2 yamt case DVACT_DEACTIVATE:
375 1.2.18.2 yamt if (sc->sc_subdev != NULL)
376 1.2.18.2 yamt rv = config_deactivate(sc->sc_subdev);
377 1.2.18.2 yamt sc->sc_dying = 1;
378 1.2.18.2 yamt break;
379 1.2.18.2 yamt }
380 1.2.18.2 yamt return (rv);
381 1.2.18.2 yamt }
382 1.2.18.2 yamt
383 1.2.18.7 yamt void
384 1.2.18.7 yamt uipaq_childdet(device_t self, device_t child)
385 1.2.18.7 yamt {
386 1.2.18.7 yamt struct uipaq_softc *sc = device_private(self);
387 1.2.18.7 yamt
388 1.2.18.7 yamt KASSERT(sc->sc_subdev == child);
389 1.2.18.7 yamt sc->sc_subdev = NULL;
390 1.2.18.7 yamt }
391 1.2.18.7 yamt
392 1.2.18.2 yamt int
393 1.2.18.7 yamt uipaq_detach(device_t self, int flags)
394 1.2.18.2 yamt {
395 1.2.18.7 yamt struct uipaq_softc *sc = device_private(self);
396 1.2.18.2 yamt int rv = 0;
397 1.2.18.2 yamt
398 1.2.18.2 yamt DPRINTF(("uipaq_detach: sc=%p flags=%d\n", sc, flags));
399 1.2.18.2 yamt sc->sc_dying = 1;
400 1.2.18.7 yamt if (sc->sc_subdev != NULL)
401 1.2.18.2 yamt rv |= config_detach(sc->sc_subdev, flags);
402 1.2.18.2 yamt
403 1.2.18.2 yamt usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
404 1.2.18.2 yamt USBDEV(sc->sc_dev));
405 1.2.18.2 yamt
406 1.2.18.2 yamt return (rv);
407 1.2.18.2 yamt }
408 1.2.18.2 yamt
409