diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-11-27 11:38:44 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-11-27 11:38:44 +0000 |
commit | 594cb8f3e164d3f8f1aa49b7f185f547af78dc9e (patch) | |
tree | 12df46afe57c2469e6e83ea46968422296651d51 | |
parent | 7ffe24902c1ca3c8e10918b6a643face1a4e63d6 (diff) |
smallest usb driver ever: enable config on the Blackberry which prevents
usb from idling, thus it can get enough power to charge in all cases
-rw-r--r-- | share/man/man4/Makefile | 6 | ||||
-rw-r--r-- | share/man/man4/uberry.4 | 39 | ||||
-rw-r--r-- | share/man/man4/usb.4 | 4 | ||||
-rw-r--r-- | sys/dev/usb/files.usb | 7 | ||||
-rw-r--r-- | sys/dev/usb/uberry.c | 108 |
5 files changed, 159 insertions, 5 deletions
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 491b6b28b6e..a8d96695ca8 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.394 2006/11/26 22:49:24 uwe Exp $ +# $OpenBSD: Makefile,v 1.395 2006/11/27 11:38:43 deraadt Exp $ MAN= aac.4 ac97.4 acphy.4 acpi.4 acx.4 \ adc.4 addcom.4 admcts.4 admlc.4 admtemp.4 \ @@ -41,8 +41,8 @@ MAN= aac.4 ac97.4 acphy.4 acpi.4 acx.4 \ speaker.4 sppp.4 sqphy.4 ss.4 st.4 ste.4 stge.4 sti.4 stp.4 sv.4 \ systrace.4 tcic.4 tcp.4 termios.4 ti.4 tl.4 \ tlphy.4 tqphy.4 trm.4 trunk.4 tsl.4 tty.4 tun.4 twe.4 txp.4 \ - txphy.4 uaudio.4 uark.4 uath.4 ubsa.4 ubsec.4 ubt.4 ucom.4 ucycom.4 \ - udav.4 udcf.4 udp.4 udsbr.4 \ + txphy.4 uaudio.4 uark.4 uath.4 uberry.4 ubsa.4 ubsec.4 ubt.4 \ + ucom.4 ucycom.4 udav.4 udcf.4 udp.4 udsbr.4 \ ueagle.4 uftdi.4 ugen.4 uhci.4 uhid.4 uhidev.4 uipaq.4 uk.4 ukbd.4 \ ukphy.4 ulpt.4 umass.4 umct.4 umidi.4 umodem.4 ums.4 umsm.4 \ unix.4 uow.4 upl.4 uplcom.4 urio.4 url.4 urlphy.4 usb.4 usbf.4 \ diff --git a/share/man/man4/uberry.4 b/share/man/man4/uberry.4 new file mode 100644 index 00000000000..045a73adeb2 --- /dev/null +++ b/share/man/man4/uberry.4 @@ -0,0 +1,39 @@ +.\" $OpenBSD: uberry.4,v 1.1 2006/11/27 11:38:43 deraadt Exp $ +.\" +.\" Copyright (c) 2005 Theo de Raadt <deraadt@openbsd.org> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd November 27, 2006 +.Dt UBERRY 4 +.Os +.Sh NAME +.Nm uberry +.Nd Research In Motion Blackberry support +.Sh SYNOPSIS +.Cd "uberry* at uhub?" +.Sh DESCRIPTION +The +.Nm +driver provides the most minimal support for the USB-connected +Research In Motion Blackberry devices, permitting them to be +charged and powered from a USB port. +.Sh SEE ALSO +.Xr uhub 4 , +.Xr usb 4 +.Sh HISTORY +The +.Nm +driver +first appeared in +.Ox 4.1 . diff --git a/share/man/man4/usb.4 b/share/man/man4/usb.4 index 8814be53eea..6490bb856a1 100644 --- a/share/man/man4/usb.4 +++ b/share/man/man4/usb.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: usb.4,v 1.81 2006/11/16 22:18:18 deraadt Exp $ +.\" $OpenBSD: usb.4,v 1.82 2006/11/27 11:38:43 deraadt Exp $ .\" $NetBSD: usb.4,v 1.15 1999/07/29 14:20:32 augustss Exp $ .\" .\" Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -222,6 +222,8 @@ mouse devices .El .Ss Miscellaneous devices .Bl -tag -width 12n -offset ind -compact +.It Xr uberry 4 +Research In Motion Blackberry .It Xr udcf 4 Gude ADS Expert mouseCLOCK DCF77/HBG time signal station receiver .It Xr ugen 4 diff --git a/sys/dev/usb/files.usb b/sys/dev/usb/files.usb index 38f7a403e72..6bc0fb3d06b 100644 --- a/sys/dev/usb/files.usb +++ b/sys/dev/usb/files.usb @@ -1,4 +1,4 @@ -# $OpenBSD: files.usb,v 1.66 2006/11/25 18:10:29 uwe Exp $ +# $OpenBSD: files.usb,v 1.67 2006/11/27 11:38:43 deraadt Exp $ # $NetBSD: files.usb,v 1.16 2000/02/14 20:29:54 augustss Exp $ # # Config file and device description for machine-independent USB code. @@ -294,3 +294,8 @@ file dev/usb/if_uath.c uath device uow: onewirebus attach uow at uhub file dev/usb/uow.c uow + +# Research In Motion Blackberry +device uberry {} +attach uberry at uhub +file dev/usb/uberry.c uberry diff --git a/sys/dev/usb/uberry.c b/sys/dev/usb/uberry.c new file mode 100644 index 00000000000..4c0b8d6d369 --- /dev/null +++ b/sys/dev/usb/uberry.c @@ -0,0 +1,108 @@ +/* $OpenBSD: uberry.c,v 1.1 2006/11/27 11:38:43 deraadt Exp $ */ + +/*- + * Copyright (c) 2006 Theo de Raadt <deraadt@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <sys/sockio.h> +#include <sys/sysctl.h> +#include <sys/mbuf.h> +#include <sys/kernel.h> +#include <sys/socket.h> +#include <sys/systm.h> +#include <sys/malloc.h> +#include <sys/timeout.h> +#include <sys/conf.h> +#include <sys/device.h> + +#include <machine/bus.h> +#include <machine/endian.h> +#include <machine/intr.h> + +#include <dev/usb/usb.h> +#include <dev/usb/usbdi.h> +#include <dev/usb/usbdi_util.h> +#include <dev/usb/usbdevs.h> + +struct uberry_softc { + USBBASEDEVICE sc_dev; + usbd_device_handle sc_udev; + usbd_interface_handle sc_iface; +}; + +#define UBERRY_CONFIG_NO 0 + +Static struct usb_devno const uberry_devices[] = { + { USB_VENDOR_RIM, USB_PRODUCT_RIM_BLACKBERRY }, + { 0, 0 } +}; + +USB_DECLARE_DRIVER(uberry); + +USB_MATCH(uberry) +{ + USB_MATCH_START(uberry, uaa); + + if (uaa->iface != NULL) + return UMATCH_NONE; + + return (usb_lookup(uberry_devices, uaa->vendor, uaa->product) != NULL) ? + UMATCH_VENDOR_PRODUCT : UMATCH_NONE; +} + +USB_ATTACH(uberry) +{ + USB_ATTACH_START(uberry, sc, uaa); + char *devinfop; + + sc->sc_udev = uaa->device; + + devinfop = usbd_devinfo_alloc(uaa->device, 0); + USB_ATTACH_SETUP; + printf("%s: %s\n", USBDEVNAME(sc->sc_dev), devinfop); + usbd_devinfo_free(devinfop); + + /* Enable the device, then it cannot idle, and will charge */ + if (usbd_set_config_no(sc->sc_udev, UBERRY_CONFIG_NO, 1) != 0) { + printf("%s: could not set configuration no\n", + USBDEVNAME(sc->sc_dev)); + USB_ATTACH_ERROR_RETURN; + } + printf("%s: Charging enabled\n", USBDEVNAME(sc->sc_dev)); + + usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, + USBDEV(sc->sc_dev)); + + USB_ATTACH_SUCCESS_RETURN; +} + +USB_DETACH(uberry) +{ + return 0; +} + +Static int +uberry_activate(device_ptr_t self, enum devact act) +{ + switch (act) { + case DVACT_ACTIVATE: + break; + + case DVACT_DEACTIVATE: + break; + } + return 0; +} |