2008-06-27 20:05:59 +04:00
|
|
|
/* $NetBSD: umodem.c,v 1.59 2008/06/27 16:05:59 drochner Exp $ */
|
1998-12-03 22:58:09 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2000-04-27 19:26:44 +04:00
|
|
|
* by Lennart Augustsson (lennart@augustsson.net) at
|
1998-12-03 22:58:09 +03:00
|
|
|
* Carlstedt Research & Technology.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1999-01-10 14:13:36 +03:00
|
|
|
/*
|
2003-11-07 20:03:25 +03:00
|
|
|
* Comm Class spec: http://www.usb.org/developers/devclass_docs/usbccs10.pdf
|
|
|
|
* http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
|
1999-08-17 00:26:53 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO:
|
|
|
|
* - Add error recovery in various places; the big problem is what
|
|
|
|
* to do in a callback if there is an error.
|
|
|
|
* - Implement a Call Device for modems without multiplexed commands.
|
|
|
|
*
|
1999-01-10 14:13:36 +03:00
|
|
|
*/
|
|
|
|
|
2001-11-13 09:24:53 +03:00
|
|
|
#include <sys/cdefs.h>
|
2008-06-27 20:05:59 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: umodem.c,v 1.59 2008/06/27 16:05:59 drochner Exp $");
|
2001-11-13 09:24:53 +03:00
|
|
|
|
1998-12-03 22:58:09 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/ioctl.h>
|
1998-12-26 15:53:00 +03:00
|
|
|
#include <sys/conf.h>
|
1998-12-03 22:58:09 +03:00
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/poll.h>
|
|
|
|
|
|
|
|
#include <dev/usb/usb.h>
|
1999-08-17 00:26:53 +04:00
|
|
|
#include <dev/usb/usbcdc.h>
|
|
|
|
|
1998-12-03 22:58:09 +03:00
|
|
|
#include <dev/usb/usbdi.h>
|
|
|
|
#include <dev/usb/usbdi_util.h>
|
|
|
|
#include <dev/usb/usbdevs.h>
|
|
|
|
#include <dev/usb/usb_quirks.h>
|
|
|
|
|
2000-01-25 11:12:58 +03:00
|
|
|
#include <dev/usb/ucomvar.h>
|
2005-04-15 18:14:09 +04:00
|
|
|
#include <dev/usb/umodemvar.h>
|
1999-08-17 00:26:53 +04:00
|
|
|
|
2000-03-27 16:33:53 +04:00
|
|
|
Static struct ucom_methods umodem_methods = {
|
2000-01-25 11:12:58 +03:00
|
|
|
umodem_get_status,
|
|
|
|
umodem_set,
|
|
|
|
umodem_param,
|
|
|
|
umodem_ioctl,
|
2001-02-16 23:15:57 +03:00
|
|
|
umodem_open,
|
|
|
|
umodem_close,
|
2000-04-14 18:21:55 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2000-01-25 11:12:58 +03:00
|
|
|
};
|
1998-12-03 22:58:09 +03:00
|
|
|
|
1998-12-26 15:53:00 +03:00
|
|
|
USB_DECLARE_DRIVER(umodem);
|
1998-12-03 22:58:09 +03:00
|
|
|
|
1998-12-26 15:53:00 +03:00
|
|
|
USB_MATCH(umodem)
|
1998-12-03 22:58:09 +03:00
|
|
|
{
|
Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!
2007-03-13 16:51:53 +03:00
|
|
|
USB_IFMATCH_START(umodem, uaa);
|
1998-12-03 22:58:09 +03:00
|
|
|
usb_interface_descriptor_t *id;
|
1999-08-17 00:26:53 +04:00
|
|
|
int cm, acm;
|
2000-10-22 12:20:09 +04:00
|
|
|
|
Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!
2007-03-13 16:51:53 +03:00
|
|
|
if (uaa->class != UICLASS_CDC ||
|
|
|
|
uaa->subclass != UISUBCLASS_ABSTRACT_CONTROL_MODEL ||
|
|
|
|
uaa->proto != UIPROTO_CDC_AT)
|
1998-12-03 22:58:09 +03:00
|
|
|
return (UMATCH_NONE);
|
1999-08-17 00:26:53 +04:00
|
|
|
|
1998-12-03 22:58:09 +03:00
|
|
|
id = usbd_get_interface_descriptor(uaa->iface);
|
2005-04-15 18:43:05 +04:00
|
|
|
if (umodem_get_caps(uaa->device, &cm, &acm, id) == -1)
|
1999-08-17 00:26:53 +04:00
|
|
|
return (UMATCH_NONE);
|
|
|
|
|
1998-12-09 03:18:10 +03:00
|
|
|
return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO);
|
1998-12-03 22:58:09 +03:00
|
|
|
}
|
|
|
|
|
1998-12-26 15:53:00 +03:00
|
|
|
USB_ATTACH(umodem)
|
1998-12-03 22:58:09 +03:00
|
|
|
{
|
Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!
2007-03-13 16:51:53 +03:00
|
|
|
USB_IFATTACH_START(umodem, sc, uaa);
|
2000-01-25 11:12:58 +03:00
|
|
|
struct ucom_attach_args uca;
|
1999-08-17 00:26:53 +04:00
|
|
|
|
2000-01-25 11:12:58 +03:00
|
|
|
uca.portno = UCOM_UNK_PORTNO;
|
|
|
|
uca.methods = &umodem_methods;
|
2001-01-24 00:56:17 +03:00
|
|
|
uca.info = NULL;
|
2000-01-25 11:12:58 +03:00
|
|
|
|
2005-04-15 18:14:09 +04:00
|
|
|
if (umodem_common_attach(self, sc, uaa, &uca))
|
|
|
|
USB_ATTACH_ERROR_RETURN;
|
1998-12-26 15:53:00 +03:00
|
|
|
USB_ATTACH_SUCCESS_RETURN;
|
1999-08-17 00:26:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-06-01 18:28:57 +04:00
|
|
|
umodem_activate(device_ptr_t self, enum devact act)
|
1999-08-17 00:26:53 +04:00
|
|
|
{
|
2008-05-24 20:40:58 +04:00
|
|
|
struct umodem_softc *sc = device_private(self);
|
1999-08-17 00:26:53 +04:00
|
|
|
|
2005-04-15 18:14:09 +04:00
|
|
|
return umodem_common_activate(sc, act);
|
1999-08-17 00:26:53 +04:00
|
|
|
}
|
|
|
|
|
2000-02-02 16:18:45 +03:00
|
|
|
USB_DETACH(umodem)
|
1999-08-17 00:26:53 +04:00
|
|
|
{
|
2000-02-02 16:18:45 +03:00
|
|
|
USB_DETACH_START(umodem, sc);
|
2005-04-15 18:14:09 +04:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
int flags = 0;
|
|
|
|
#endif
|
2000-02-02 16:18:45 +03:00
|
|
|
|
2005-04-15 18:14:09 +04:00
|
|
|
return umodem_common_detach(sc, flags);
|
1999-08-17 00:26:53 +04:00
|
|
|
}
|