[BACK]Return to uyap.c CVS log [TXT][DIR] Up to [local] / sys / dev / usb

Annotation of sys/dev/usb/uyap.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: uyap.c,v 1.14 2007/06/14 10:11:16 mbalmer Exp $ */
        !             2: /*     $NetBSD: uyap.c,v 1.6 2002/07/11 21:14:37 augustss Exp $        */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 2000 The NetBSD Foundation, Inc.
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * This code is derived from software contributed to The NetBSD Foundation
        !             9:  * by  Lennart Augustsson <lennart@augustsson.net>.
        !            10:  *
        !            11:  * Redistribution and use in source and binary forms, with or without
        !            12:  * modification, are permitted provided that the following conditions
        !            13:  * are met:
        !            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.
        !            19:  * 3. All advertising materials mentioning features or use of this software
        !            20:  *    must display the following acknowledgement:
        !            21:  *        This product includes software developed by the NetBSD
        !            22:  *        Foundation, Inc. and its contributors.
        !            23:  * 4. Neither the name of The NetBSD Foundation nor the names of its
        !            24:  *    contributors may be used to endorse or promote products derived
        !            25:  *    from this software without specific prior written permission.
        !            26:  *
        !            27:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
        !            28:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            29:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            30:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
        !            31:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            32:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            33:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            34:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            35:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            36:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            37:  * POSSIBILITY OF SUCH DAMAGE.
        !            38:  */
        !            39:
        !            40: #include <sys/param.h>
        !            41: #include <sys/systm.h>
        !            42: #include <sys/kernel.h>
        !            43: #include <sys/device.h>
        !            44: #include <sys/conf.h>
        !            45: #include <sys/tty.h>
        !            46:
        !            47: #include <dev/usb/usb.h>
        !            48: #include <dev/usb/usbdi.h>
        !            49: #include <dev/usb/usbdevs.h>
        !            50:
        !            51: #include <dev/usb/ezload.h>
        !            52:
        !            53: struct uyap_softc {
        !            54:        struct device           sc_dev;         /* base device */
        !            55:        usbd_device_handle      sc_udev;
        !            56: };
        !            57:
        !            58: int uyap_match(struct device *, void *, void *);
        !            59: void uyap_attach(struct device *, struct device *, void *);
        !            60: int uyap_detach(struct device *, int);
        !            61: int uyap_activate(struct device *, enum devact);
        !            62:
        !            63: struct cfdriver uyap_cd = {
        !            64:        NULL, "uyap", DV_DULL
        !            65: };
        !            66:
        !            67: const struct cfattach uyap_ca = {
        !            68:        sizeof(struct uyap_softc),
        !            69:        uyap_match,
        !            70:        uyap_attach,
        !            71:        uyap_detach,
        !            72:        uyap_activate,
        !            73: };
        !            74: void uyap_attachhook(void *);
        !            75:
        !            76: int
        !            77: uyap_match(struct device *parent, void *match, void *aux)
        !            78: {
        !            79:        struct usb_attach_arg *uaa = aux;
        !            80:
        !            81:        if (uaa->iface != NULL)
        !            82:                return (UMATCH_NONE);
        !            83:
        !            84:        /* Match the boot device. */
        !            85:        if (uaa->vendor == USB_VENDOR_SILICONPORTALS &&
        !            86:            uaa->product == USB_PRODUCT_SILICONPORTALS_YAPPH_NF)
        !            87:                return (UMATCH_VENDOR_PRODUCT);
        !            88:
        !            89:        return (UMATCH_NONE);
        !            90: }
        !            91:
        !            92: void
        !            93: uyap_attachhook(void *xsc)
        !            94: {
        !            95:        char *firmwares[] = { "uyap", NULL };
        !            96:        struct uyap_softc *sc = xsc;
        !            97:        int err;
        !            98:
        !            99:        err = ezload_downloads_and_reset(sc->sc_udev, firmwares);
        !           100:        if (err) {
        !           101:                printf("%s: download ezdata format firmware error: %s\n",
        !           102:                    sc->sc_dev.dv_xname, usbd_errstr(err));
        !           103:                return;
        !           104:        }
        !           105:
        !           106:        printf("%s: firmware download complete, disconnecting.\n",
        !           107:            sc->sc_dev.dv_xname);
        !           108: }
        !           109:
        !           110: void
        !           111: uyap_attach(struct device *parent, struct device *self, void *aux)
        !           112: {
        !           113:        struct uyap_softc *sc = (struct uyap_softc *)self;
        !           114:        struct usb_attach_arg *uaa = aux;
        !           115:        usbd_device_handle dev = uaa->device;
        !           116:        char *devinfop;
        !           117:
        !           118:        devinfop = usbd_devinfo_alloc(dev, 0);
        !           119:        printf("\n%s: %s\n", sc->sc_dev.dv_xname, devinfop);
        !           120:        usbd_devinfo_free(devinfop);
        !           121:
        !           122:        printf("%s: downloading firmware\n", sc->sc_dev.dv_xname);
        !           123:
        !           124:        sc->sc_udev = dev;
        !           125:        if (rootvp == NULL)
        !           126:                mountroothook_establish(uyap_attachhook, sc);
        !           127:        else
        !           128:                uyap_attachhook(sc);
        !           129: }
        !           130:
        !           131: int
        !           132: uyap_detach(struct device *self, int flags)
        !           133: {
        !           134:        return (0);
        !           135: }
        !           136:
        !           137: int
        !           138: uyap_activate(struct device *self, enum devact act)
        !           139: {
        !           140:        return 0;
        !           141: }

CVSweb