diff -x CVS -rNdu freebsd7_sys_vanilla/conf/files freebsd7_sys_uberry/conf/files --- freebsd7_sys_vanilla/conf/files 2007-09-23 22:19:51.000000000 +0200 +++ freebsd7_sys_uberry/conf/files 2007-09-23 21:43:07.000000000 +0200 @@ -1112,6 +1112,7 @@ dev/usb/sl811hs.c optional slhci dev/usb/slhci_pccard.c optional slhci pccard dev/usb/uark.c optional uark +dev/usb/uberry.c optional uberry dev/usb/ubsa.c optional ubsa dev/usb/ubser.c optional ubser dev/usb/ucom.c optional ucom diff -x CVS -rNdu freebsd7_sys_vanilla/dev/usb/uberry.c freebsd7_sys_uberry/dev/usb/uberry.c --- freebsd7_sys_vanilla/dev/usb/uberry.c 1970-01-01 01:00:00.000000000 +0100 +++ freebsd7_sys_uberry/dev/usb/uberry.c 2007-09-23 22:09:57.000000000 +0200 @@ -0,0 +1,157 @@ +/* $OpenBSD: uberry.c,v 1.10 2007/06/14 10:11:15 mbalmer Exp $ */ + +/*- + * Copyright (c) 2006 Theo de Raadt + * + * 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. + */ + +/* + * 2007/7/30 added support for the new devices 8800 and 8100 Pearl (Kirk Davis) + * 2007/7/26 Initial port from OpenBSD to FreeBSD and cleanup (Kirk Davis) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "usbdevs.h" + +struct uberry_softc { + USBBASEDEVICE sc_dev; + usbd_device_handle sc_udev; + usbd_interface_handle sc_iface; + struct cdev *sc_dev_t; +}; + +#define UBERRY_CONFIG_NO 1 + +struct usb_devno const uberry_devices[] = { + { USB_VENDOR_RIM, USB_PRODUCT_RIM_BLACKBERRY }, + { USB_VENDOR_RIM, USB_PRODUCT_RIM_PEARL } +}; + +static void do_charge(struct uberry_softc *sc); +static void pearl_mode(struct uberry_softc *sc); + +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 devinfo[1024]; + + sc->sc_udev = uaa->device; + usb_device_descriptor_t *dd; + + usbd_devinfo(sc->sc_udev, 0, devinfo); + + USB_ATTACH_SETUP; + + dd = usbd_get_device_descriptor(uaa->device); + + printf("\n%s: %s\n", USBDEVNAME(sc->sc_dev), devinfo); + if ( UGETW(dd->idProduct) == USB_PRODUCT_RIM_PEARL ) { + (void) do_charge(sc); + printf("%s: Charging enabled\n", USBDEVNAME(sc->sc_dev)); + pearl_mode(sc); + } else { + + (void) do_charge(sc); + printf("%s: Charging enabled\n", USBDEVNAME(sc->sc_dev)); + } + + /* 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; + } + + usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, + USBDEV(sc->sc_dev)); + USB_ATTACH_SUCCESS_RETURN; +} + +USB_DETACH(uberry) +{ + USB_DETACH_START(uberry, sc); + + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, + USBDEV(sc->sc_dev)); + + return (0); +} + +void +pearl_mode(struct uberry_softc *sc) +{ + usb_device_request_t req; + char buffer[256]; + + req.bmRequestType = UT_READ_VENDOR_DEVICE; + req.bRequest = 0xa9; + USETW(req.wValue, 1); + USETW(req.wIndex, 1); + USETW(req.wLength, 2); + (void) usbd_do_request(sc->sc_udev, &req, &buffer); +} + +void +do_charge(struct uberry_softc *sc) +{ + usb_device_request_t req; + char buffer[256]; + + req.bmRequestType = UT_READ_VENDOR_DEVICE; + req.bRequest = 0xa5; + USETW(req.wValue, 0); + USETW(req.wIndex, 1); + USETW(req.wLength, 2); + (void) usbd_do_request(sc->sc_udev, &req, &buffer); + + req.bmRequestType = UT_WRITE_VENDOR_DEVICE; + req.bRequest = 0xa2; + USETW(req.wValue, 0); + USETW(req.wIndex, 1); + USETW(req.wLength, 0); + (void) usbd_do_request(sc->sc_udev, &req, &buffer); +} + +DRIVER_MODULE(uberry, uhub, uberry_driver, uberry_devclass, usbd_driver_load, 0); diff -x CVS -rNdu freebsd7_sys_vanilla/dev/usb/usbdevs freebsd7_sys_uberry/dev/usb/usbdevs --- freebsd7_sys_vanilla/dev/usb/usbdevs 2007-09-23 22:20:03.000000000 +0200 +++ freebsd7_sys_uberry/dev/usb/usbdevs 2007-09-23 21:45:20.000000000 +0200 @@ -1931,6 +1931,10 @@ /* Green House and CompUSA OEM this part */ product REALTEK USBKR100 0x8150 USBKR100 USB Ethernet +/* Research In Motion products */ +product RIM BLACKBERRY 0x0001 Blackberry +product RIM PEARL 0x0006 Blackberry pearl + /* Roland products */ product ROLAND UM1 0x0009 UM-1 MIDI I/F product ROLAND UM880N 0x0014 EDIROL UM-880 MIDI I/F (native) diff -x CVS -rNdu freebsd7_sys_vanilla/modules/Makefile freebsd7_sys_uberry/modules/Makefile --- freebsd7_sys_vanilla/modules/Makefile 2007-09-23 22:20:11.000000000 +0200 +++ freebsd7_sys_uberry/modules/Makefile 2007-09-23 21:45:56.000000000 +0200 @@ -287,6 +287,7 @@ ural \ urio \ usb \ + uberry \ uscanner \ utopia \ uvisor \ diff -x CVS -rNdu freebsd7_sys_vanilla/modules/uberry/Makefile freebsd7_sys_uberry/modules/uberry/Makefile --- freebsd7_sys_vanilla/modules/uberry/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ freebsd7_sys_uberry/modules/uberry/Makefile 2007-09-23 21:47:06.000000000 +0200 @@ -0,0 +1,6 @@ +.PATH: ${.CURDIR}/../../dev/usb + +KMOD= uberry +SRCS= uberry.c opt_usb.h device_if.h bus_if.h usbdevs.h + +.include