2021-08-07 19:18:40 +03:00
|
|
|
/* $NetBSD: uipaq.c,v 1.30 2021/08/07 16:19:17 thorpej Exp $ */
|
2005-07-18 15:36:46 +04:00
|
|
|
/* $OpenBSD: uipaq.c,v 1.1 2005/06/17 23:50:33 deraadt Exp $ */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2000-2005 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Lennart Augustsson (lennart@augustsson.net) at
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* iPAQ driver
|
2016-04-23 13:15:27 +03:00
|
|
|
*
|
2005-07-18 15:36:46 +04:00
|
|
|
* 19 July 2003: Incorporated changes suggested by Sam Lawrance from
|
|
|
|
* the uppc module
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contact isis@cs.umd.edu if you have any questions/comments about this driver
|
|
|
|
*/
|
|
|
|
|
2007-12-11 15:29:11 +03:00
|
|
|
#include <sys/cdefs.h>
|
2021-08-07 19:18:40 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: uipaq.c,v 1.30 2021/08/07 16:19:17 thorpej Exp $");
|
2016-11-25 15:56:29 +03:00
|
|
|
|
|
|
|
#ifdef _KERNEL_OPT
|
|
|
|
#include "opt_usb.h"
|
|
|
|
#endif
|
2007-12-11 15:29:11 +03:00
|
|
|
|
2005-07-18 15:36:46 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
|
|
|
|
#include <dev/usb/usb.h>
|
|
|
|
|
|
|
|
#include <dev/usb/usbcdc.h> /*UCDC_* stuff */
|
|
|
|
|
|
|
|
#include <dev/usb/usbdi.h>
|
|
|
|
#include <dev/usb/usbdi_util.h>
|
|
|
|
#include <dev/usb/usbdevs.h>
|
|
|
|
|
|
|
|
#include <dev/usb/ucomvar.h>
|
|
|
|
|
|
|
|
#ifdef UIPAQ_DEBUG
|
|
|
|
#define DPRINTF(x) if (uipaqdebug) printf x
|
|
|
|
#define DPRINTFN(n,x) if (uipaqdebug>(n)) printf x
|
|
|
|
int uipaqdebug = 0;
|
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#define DPRINTFN(n,x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define UIPAQ_CONFIG_NO 1
|
|
|
|
#define UIPAQ_IFACE_INDEX 0
|
|
|
|
|
|
|
|
#define UIPAQIBUFSIZE 1024
|
|
|
|
#define UIPAQOBUFSIZE 1024
|
|
|
|
|
|
|
|
struct uipaq_softc {
|
2010-11-04 01:34:23 +03:00
|
|
|
device_t sc_dev; /* base device */
|
2016-04-23 13:15:27 +03:00
|
|
|
struct usbd_device * sc_udev; /* device */
|
|
|
|
struct usbd_interface * sc_iface; /* interface */
|
2005-07-18 15:36:46 +04:00
|
|
|
|
2008-02-18 08:24:24 +03:00
|
|
|
device_t sc_subdev; /* ucom uses that */
|
2016-04-23 13:15:27 +03:00
|
|
|
uint16_t sc_lcr; /* state for DTR/RTS */
|
2005-07-18 15:36:46 +04:00
|
|
|
|
2016-04-23 13:15:27 +03:00
|
|
|
uint16_t sc_flags;
|
2005-07-18 15:36:46 +04:00
|
|
|
|
2019-05-09 05:43:35 +03:00
|
|
|
bool sc_dying;
|
2005-07-18 15:36:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Callback routines */
|
2019-05-09 05:43:35 +03:00
|
|
|
static void uipaq_set(void *, int, int, int);
|
|
|
|
static int uipaq_open(void *, int);
|
2005-07-18 15:36:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* Support routines. */
|
|
|
|
/* based on uppc module by Sam Lawrance */
|
2019-05-09 05:43:35 +03:00
|
|
|
static void uipaq_dtr(struct uipaq_softc *, int);
|
|
|
|
static void uipaq_rts(struct uipaq_softc *, int);
|
|
|
|
static void uipaq_break(struct uipaq_softc *, int);
|
2005-07-18 15:36:46 +04:00
|
|
|
|
|
|
|
|
2020-01-07 09:42:26 +03:00
|
|
|
static const struct ucom_methods uipaq_methods = {
|
2016-04-23 13:15:27 +03:00
|
|
|
.ucom_set = uipaq_set,
|
2019-05-09 05:43:35 +03:00
|
|
|
.ucom_open = uipaq_open,
|
2005-07-18 15:36:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct uipaq_type {
|
|
|
|
struct usb_devno uv_dev;
|
2016-04-23 13:15:27 +03:00
|
|
|
uint16_t uv_flags;
|
2005-07-18 15:36:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct uipaq_type uipaq_devs[] = {
|
|
|
|
{{ USB_VENDOR_HP, USB_PRODUCT_HP_2215 }, 0 },
|
|
|
|
{{ USB_VENDOR_HP, USB_PRODUCT_HP_568J }, 0},
|
|
|
|
{{ USB_VENDOR_COMPAQ, USB_PRODUCT_COMPAQ_IPAQPOCKETPC} , 0},
|
2007-01-31 13:09:17 +03:00
|
|
|
{{ USB_VENDOR_CASIO, USB_PRODUCT_CASIO_BE300} , 0},
|
2008-07-08 12:47:32 +04:00
|
|
|
{{ USB_VENDOR_SHARP, USB_PRODUCT_SHARP_WS007SH} , 0},
|
|
|
|
{{ USB_VENDOR_SHARP, USB_PRODUCT_SHARP_WS011SH} , 0}
|
2005-07-18 15:36:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define uipaq_lookup(v, p) ((const struct uipaq_type *)usb_lookup(uipaq_devs, v, p))
|
|
|
|
|
2020-01-07 09:42:26 +03:00
|
|
|
static int uipaq_match(device_t, cfdata_t, void *);
|
|
|
|
static void uipaq_attach(device_t, device_t, void *);
|
|
|
|
static void uipaq_childdet(device_t, device_t);
|
|
|
|
static int uipaq_detach(device_t, int);
|
2019-05-05 06:17:54 +03:00
|
|
|
|
2008-05-24 20:40:58 +04:00
|
|
|
CFATTACH_DECL2_NEW(uipaq, sizeof(struct uipaq_softc), uipaq_match,
|
2019-05-09 05:43:35 +03:00
|
|
|
uipaq_attach, uipaq_detach, NULL, NULL, uipaq_childdet);
|
2005-07-18 15:36:46 +04:00
|
|
|
|
2020-01-07 09:42:26 +03:00
|
|
|
static int
|
2010-11-04 01:34:23 +03:00
|
|
|
uipaq_match(device_t parent, cfdata_t match, void *aux)
|
2005-07-18 15:36:46 +04:00
|
|
|
{
|
2010-11-04 01:34:23 +03:00
|
|
|
struct usb_attach_arg *uaa = aux;
|
2005-07-18 15:36:46 +04:00
|
|
|
|
2020-03-13 21:17:40 +03:00
|
|
|
DPRINTFN(20,("uipaq: vendor=%#x, product=%#x\n",
|
2016-04-23 13:15:27 +03:00
|
|
|
uaa->uaa_vendor, uaa->uaa_product));
|
2005-07-18 15:36:46 +04:00
|
|
|
|
2016-04-23 13:15:27 +03:00
|
|
|
return uipaq_lookup(uaa->uaa_vendor, uaa->uaa_product) != NULL ?
|
|
|
|
UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
|
2005-07-18 15:36:46 +04:00
|
|
|
}
|
|
|
|
|
2020-01-07 09:42:26 +03:00
|
|
|
static void
|
2010-11-04 01:34:23 +03:00
|
|
|
uipaq_attach(device_t parent, device_t self, void *aux)
|
2005-07-18 15:36:46 +04:00
|
|
|
{
|
2010-11-04 01:34:23 +03:00
|
|
|
struct uipaq_softc *sc = device_private(self);
|
|
|
|
struct usb_attach_arg *uaa = aux;
|
2016-04-23 13:15:27 +03:00
|
|
|
struct usbd_device *dev = uaa->uaa_device;
|
|
|
|
struct usbd_interface *iface;
|
2005-07-18 15:36:46 +04:00
|
|
|
usb_interface_descriptor_t *id;
|
|
|
|
usb_endpoint_descriptor_t *ed;
|
|
|
|
char *devinfop;
|
2008-05-24 20:40:58 +04:00
|
|
|
const char *devname = device_xname(self);
|
2005-07-18 15:36:46 +04:00
|
|
|
int i;
|
|
|
|
usbd_status err;
|
2016-04-23 13:15:27 +03:00
|
|
|
struct ucom_attach_args ucaa;
|
2005-07-18 15:36:46 +04:00
|
|
|
|
|
|
|
DPRINTFN(10,("\nuipaq_attach: sc=%p\n", sc));
|
|
|
|
|
2008-05-24 20:40:58 +04:00
|
|
|
sc->sc_dev = self;
|
2019-05-09 05:43:35 +03:00
|
|
|
sc->sc_dying = false;
|
2008-05-24 20:40:58 +04:00
|
|
|
|
2009-09-23 23:07:19 +04:00
|
|
|
aprint_naive("\n");
|
|
|
|
aprint_normal("\n");
|
|
|
|
|
|
|
|
devinfop = usbd_devinfo_alloc(dev, 0);
|
|
|
|
aprint_normal_dev(self, "%s\n", devinfop);
|
|
|
|
usbd_devinfo_free(devinfop);
|
|
|
|
|
2005-07-18 15:36:46 +04:00
|
|
|
/* Move the device into the configured state. */
|
|
|
|
err = usbd_set_config_no(dev, UIPAQ_CONFIG_NO, 1);
|
|
|
|
if (err) {
|
2016-07-07 09:55:38 +03:00
|
|
|
aprint_error_dev(self, "failed to set configuration, err=%s\n",
|
|
|
|
usbd_errstr(err));
|
2005-07-18 15:36:46 +04:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = usbd_device2interface_handle(dev, UIPAQ_IFACE_INDEX, &iface);
|
|
|
|
if (err) {
|
2008-05-24 20:40:58 +04:00
|
|
|
aprint_error("\n%s: failed to get interface, err=%s\n",
|
2005-07-18 15:36:46 +04:00
|
|
|
devname, usbd_errstr(err));
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2016-04-23 13:15:27 +03:00
|
|
|
sc->sc_flags = uipaq_lookup(uaa->uaa_vendor, uaa->uaa_product)->uv_flags;
|
2005-07-18 15:36:46 +04:00
|
|
|
|
|
|
|
id = usbd_get_interface_descriptor(iface);
|
|
|
|
|
|
|
|
sc->sc_udev = dev;
|
|
|
|
sc->sc_iface = iface;
|
|
|
|
|
2016-04-23 13:15:27 +03:00
|
|
|
ucaa.ucaa_ibufsize = UIPAQIBUFSIZE;
|
|
|
|
ucaa.ucaa_obufsize = UIPAQOBUFSIZE;
|
|
|
|
ucaa.ucaa_ibufsizepad = UIPAQIBUFSIZE;
|
|
|
|
ucaa.ucaa_opkthdrlen = 0;
|
|
|
|
ucaa.ucaa_device = dev;
|
|
|
|
ucaa.ucaa_iface = iface;
|
|
|
|
ucaa.ucaa_methods = &uipaq_methods;
|
|
|
|
ucaa.ucaa_arg = sc;
|
|
|
|
ucaa.ucaa_portno = UCOM_UNK_PORTNO;
|
|
|
|
ucaa.ucaa_info = "Generic";
|
2005-07-18 15:36:46 +04:00
|
|
|
|
|
|
|
/* err = uipaq_init(sc);
|
|
|
|
if (err) {
|
2010-11-04 01:34:23 +03:00
|
|
|
printf("%s: init failed, %s\n", device_xname(sc->sc_dev),
|
2005-07-18 15:36:46 +04:00
|
|
|
usbd_errstr(err));
|
|
|
|
goto bad;
|
|
|
|
}*/
|
|
|
|
|
2016-07-07 09:55:38 +03:00
|
|
|
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev);
|
2005-07-18 15:36:46 +04:00
|
|
|
|
2016-04-23 13:15:27 +03:00
|
|
|
ucaa.ucaa_bulkin = ucaa.ucaa_bulkout = -1;
|
2005-07-18 15:36:46 +04:00
|
|
|
for (i=0; i<id->bNumEndpoints; i++) {
|
|
|
|
ed = usbd_interface2endpoint_descriptor(iface, i);
|
|
|
|
if (ed == NULL) {
|
2008-05-24 20:40:58 +04:00
|
|
|
aprint_error_dev(self,
|
|
|
|
"no endpoint descriptor for %d\n", i);
|
2005-07-18 15:36:46 +04:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
|
|
|
|
(ed->bmAttributes & UE_XFERTYPE) == UE_BULK) {
|
2016-04-23 13:15:27 +03:00
|
|
|
ucaa.ucaa_bulkin = ed->bEndpointAddress;
|
2005-07-18 15:36:46 +04:00
|
|
|
} else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
|
|
|
|
(ed->bmAttributes & UE_XFERTYPE) == UE_BULK) {
|
2016-04-23 13:15:27 +03:00
|
|
|
ucaa.ucaa_bulkout = ed->bEndpointAddress;
|
2005-07-18 15:36:46 +04:00
|
|
|
}
|
|
|
|
}
|
2016-04-23 13:15:27 +03:00
|
|
|
if (ucaa.ucaa_bulkin == -1 || ucaa.ucaa_bulkout == -1) {
|
2008-05-24 20:40:58 +04:00
|
|
|
aprint_error_dev(self, "no proper endpoints found (%d,%d) \n",
|
2016-04-23 13:15:27 +03:00
|
|
|
ucaa.ucaa_bulkin, ucaa.ucaa_bulkout);
|
2010-11-04 01:34:23 +03:00
|
|
|
return;
|
2005-07-18 15:36:46 +04:00
|
|
|
}
|
|
|
|
|
Merge thorpej-cfargs branch:
Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.
Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)
Remove unnecessary or redundant interface attributes where they're not
needed.
There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)
...and a sentinel value CFARG_EOL.
Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.
Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
2021-04-25 02:36:23 +03:00
|
|
|
sc->sc_subdev = config_found(self, &ucaa, ucomprint,
|
2021-08-07 19:18:40 +03:00
|
|
|
CFARGS(.submatch = ucomsubmatch));
|
2005-07-18 15:36:46 +04:00
|
|
|
|
2010-11-04 01:34:23 +03:00
|
|
|
return;
|
2005-07-18 15:36:46 +04:00
|
|
|
|
|
|
|
bad:
|
|
|
|
DPRINTF(("uipaq_attach: ATTACH ERROR\n"));
|
2019-05-09 05:43:35 +03:00
|
|
|
sc->sc_dying = true;
|
2010-11-04 01:34:23 +03:00
|
|
|
return;
|
2005-07-18 15:36:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
uipaq_dtr(struct uipaq_softc* sc, int onoff)
|
|
|
|
{
|
|
|
|
usb_device_request_t req;
|
|
|
|
usbd_status err;
|
|
|
|
int retries = 3;
|
|
|
|
|
2010-11-04 01:34:23 +03:00
|
|
|
DPRINTF(("%s: uipaq_dtr: onoff=%x\n", device_xname(sc->sc_dev), onoff));
|
2005-07-18 15:36:46 +04:00
|
|
|
|
|
|
|
/* Avoid sending unnecessary requests */
|
|
|
|
if (onoff && (sc->sc_lcr & UCDC_LINE_DTR))
|
|
|
|
return;
|
|
|
|
if (!onoff && !(sc->sc_lcr & UCDC_LINE_DTR))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Other parameters depend on reg */
|
|
|
|
req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
|
|
|
|
req.bRequest = UCDC_SET_CONTROL_LINE_STATE;
|
2016-07-07 09:55:38 +03:00
|
|
|
sc->sc_lcr = onoff ? sc->sc_lcr | UCDC_LINE_DTR
|
|
|
|
: sc->sc_lcr & ~UCDC_LINE_DTR;
|
2005-07-18 15:36:46 +04:00
|
|
|
USETW(req.wValue, sc->sc_lcr);
|
|
|
|
USETW(req.wIndex, 0x0);
|
|
|
|
USETW(req.wLength, 0);
|
|
|
|
|
|
|
|
/* Fire off the request a few times if necessary */
|
|
|
|
while (retries) {
|
|
|
|
err = usbd_do_request(sc->sc_udev, &req, NULL);
|
|
|
|
if (!err)
|
|
|
|
break;
|
|
|
|
retries--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
uipaq_rts(struct uipaq_softc* sc, int onoff)
|
|
|
|
{
|
|
|
|
usb_device_request_t req;
|
|
|
|
usbd_status err;
|
|
|
|
int retries = 3;
|
|
|
|
|
2010-11-04 01:34:23 +03:00
|
|
|
DPRINTF(("%s: uipaq_rts: onoff=%x\n", device_xname(sc->sc_dev), onoff));
|
2005-07-18 15:36:46 +04:00
|
|
|
|
|
|
|
/* Avoid sending unnecessary requests */
|
|
|
|
if (onoff && (sc->sc_lcr & UCDC_LINE_RTS)) return;
|
|
|
|
if (!onoff && !(sc->sc_lcr & UCDC_LINE_RTS)) return;
|
|
|
|
|
|
|
|
req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
|
|
|
|
req.bRequest = UCDC_SET_CONTROL_LINE_STATE;
|
2016-07-07 09:55:38 +03:00
|
|
|
sc->sc_lcr = onoff ? sc->sc_lcr | UCDC_LINE_RTS
|
|
|
|
: sc->sc_lcr & ~UCDC_LINE_RTS;
|
2005-07-18 15:36:46 +04:00
|
|
|
USETW(req.wValue, sc->sc_lcr);
|
|
|
|
USETW(req.wIndex, 0x0);
|
|
|
|
USETW(req.wLength, 0);
|
|
|
|
|
|
|
|
while (retries) {
|
|
|
|
err = usbd_do_request(sc->sc_udev, &req, NULL);
|
|
|
|
if (!err)
|
|
|
|
break;
|
|
|
|
retries--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
uipaq_break(struct uipaq_softc* sc, int onoff)
|
|
|
|
{
|
|
|
|
usb_device_request_t req;
|
|
|
|
usbd_status err;
|
|
|
|
int retries = 3;
|
|
|
|
|
2016-07-07 09:55:38 +03:00
|
|
|
DPRINTF(("%s: uipaq_break: onoff=%x\n", device_xname(sc->sc_dev),
|
|
|
|
onoff));
|
2005-07-18 15:36:46 +04:00
|
|
|
|
|
|
|
req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
|
|
|
|
req.bRequest = UCDC_SEND_BREAK;
|
|
|
|
|
|
|
|
USETW(req.wValue, onoff ? UCDC_BREAK_ON : UCDC_BREAK_OFF);
|
|
|
|
USETW(req.wIndex, 0x0);
|
|
|
|
USETW(req.wLength, 0);
|
|
|
|
|
|
|
|
while (retries) {
|
|
|
|
err = usbd_do_request(sc->sc_udev, &req, NULL);
|
|
|
|
if (!err)
|
|
|
|
break;
|
|
|
|
retries--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-11-16 04:32:37 +03:00
|
|
|
uipaq_set(void *addr, int portno, int reg, int onoff)
|
2005-07-18 15:36:46 +04:00
|
|
|
{
|
|
|
|
struct uipaq_softc* sc = addr;
|
|
|
|
|
2019-05-09 05:43:35 +03:00
|
|
|
if (sc->sc_dying)
|
|
|
|
return;
|
|
|
|
|
2005-07-18 15:36:46 +04:00
|
|
|
switch (reg) {
|
|
|
|
case UCOM_SET_DTR:
|
|
|
|
uipaq_dtr(addr, onoff);
|
|
|
|
break;
|
|
|
|
case UCOM_SET_RTS:
|
|
|
|
uipaq_rts(addr, onoff);
|
|
|
|
break;
|
|
|
|
case UCOM_SET_BREAK:
|
|
|
|
uipaq_break(addr, onoff);
|
|
|
|
break;
|
|
|
|
default:
|
2008-05-24 20:40:58 +04:00
|
|
|
aprint_error_dev(sc->sc_dev,
|
|
|
|
"unhandled set request: reg=%x onoff=%x\n", reg, onoff);
|
2005-07-18 15:36:46 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-09 05:43:35 +03:00
|
|
|
static int
|
|
|
|
uipaq_open(void *arg, int portno)
|
2005-07-18 15:36:46 +04:00
|
|
|
{
|
2019-05-09 05:43:35 +03:00
|
|
|
struct uipaq_softc *sc = arg;
|
2005-07-18 15:36:46 +04:00
|
|
|
|
2019-05-09 05:43:35 +03:00
|
|
|
if (sc->sc_dying)
|
|
|
|
return EIO;
|
|
|
|
|
|
|
|
return 0;
|
2005-07-18 15:36:46 +04:00
|
|
|
}
|
|
|
|
|
2020-01-07 09:42:26 +03:00
|
|
|
static void
|
2008-02-18 08:24:24 +03:00
|
|
|
uipaq_childdet(device_t self, device_t child)
|
|
|
|
{
|
|
|
|
struct uipaq_softc *sc = device_private(self);
|
|
|
|
|
|
|
|
KASSERT(sc->sc_subdev == child);
|
|
|
|
sc->sc_subdev = NULL;
|
|
|
|
}
|
|
|
|
|
2020-01-07 09:42:26 +03:00
|
|
|
static int
|
2008-02-18 08:24:24 +03:00
|
|
|
uipaq_detach(device_t self, int flags)
|
2005-07-18 15:36:46 +04:00
|
|
|
{
|
2008-02-18 08:24:24 +03:00
|
|
|
struct uipaq_softc *sc = device_private(self);
|
2005-07-18 15:36:46 +04:00
|
|
|
int rv = 0;
|
|
|
|
|
|
|
|
DPRINTF(("uipaq_detach: sc=%p flags=%d\n", sc, flags));
|
2019-05-09 05:43:35 +03:00
|
|
|
|
|
|
|
sc->sc_dying = true;
|
|
|
|
|
|
|
|
if (sc->sc_subdev != NULL) {
|
2005-07-18 15:36:46 +04:00
|
|
|
rv |= config_detach(sc->sc_subdev, flags);
|
2019-05-09 05:43:35 +03:00
|
|
|
sc->sc_subdev = NULL;
|
|
|
|
}
|
2019-09-14 15:46:00 +03:00
|
|
|
if (sc->sc_udev != NULL)
|
|
|
|
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
|
|
|
|
sc->sc_dev);
|
2005-07-18 15:36:46 +04:00
|
|
|
|
2016-04-23 13:15:27 +03:00
|
|
|
return rv;
|
2005-07-18 15:36:46 +04:00
|
|
|
}
|