1 /* $NetBSD: umodem.c,v 1.58 2008/05/24 16:40:58 cube Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net) at
9 * Carlstedt Research & Technology.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
34 * Comm Class spec: http://www.usb.org/developers/devclass_docs/usbccs10.pdf
35 * http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
40 * - Add error recovery in various places; the big problem is what
41 * to do in a callback if there is an error.
42 * - Implement a Call Device for modems without multiplexed commands.
46 #include <sys/cdefs.h>
47 __KERNEL_RCSID(0, "$NetBSD: umodem.c,v 1.58 2008/05/24 16:40:58 cube Exp $");
49 #include <sys/param.h>
50 #include <sys/systm.h>
51 #include <sys/kernel.h>
52 #include <sys/ioctl.h>
56 #include <sys/select.h>
58 #include <sys/vnode.h>
59 #include <sys/device.h>
62 #include <dev/usb/usb.h>
63 #include <dev/usb/usbcdc.h>
65 #include <dev/usb/usbdi.h>
66 #include <dev/usb/usbdi_util.h>
67 #include <dev/usb/usbdevs.h>
68 #include <dev/usb/usb_quirks.h>
70 #include <dev/usb/ucomvar.h>
71 #include <dev/usb/umodemvar.h>
73 Static
struct ucom_methods umodem_methods
= {
84 USB_DECLARE_DRIVER(umodem
);
88 USB_IFMATCH_START(umodem
, uaa
);
89 usb_interface_descriptor_t
*id
;
92 if (uaa
->class != UICLASS_CDC
||
93 uaa
->subclass
!= UISUBCLASS_ABSTRACT_CONTROL_MODEL
||
94 uaa
->proto
!= UIPROTO_CDC_AT
)
97 id
= usbd_get_interface_descriptor(uaa
->iface
);
98 if (umodem_get_caps(uaa
->device
, &cm
, &acm
, id
) == -1)
101 return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO
);
106 USB_IFATTACH_START(umodem
, sc
, uaa
);
107 struct ucom_attach_args uca
;
109 uca
.portno
= UCOM_UNK_PORTNO
;
110 uca
.methods
= &umodem_methods
;
113 if (umodem_common_attach(self
, sc
, uaa
, &uca
))
114 USB_ATTACH_ERROR_RETURN
;
115 USB_ATTACH_SUCCESS_RETURN
;
119 umodem_activate(device_ptr_t self
, enum devact act
)
121 struct umodem_softc
*sc
= device_private(self
);
123 return umodem_common_activate(sc
, act
);
128 USB_DETACH_START(umodem
, sc
);
133 return umodem_common_detach(sc
, flags
);