1 | /* $NetBSD: uyap.c,v 1.21 2016/07/14 04:19:27 msaitoh Exp $ */ |
2 | |
3 | /* |
4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. |
5 | * All rights reserved. |
6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Lennart Augustsson <lennart@augustsson.net>. |
9 | * |
10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions |
12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. |
18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ |
31 | |
32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: uyap.c,v 1.21 2016/07/14 04:19:27 msaitoh Exp $" ); |
34 | |
35 | #include <sys/param.h> |
36 | #include <sys/systm.h> |
37 | #include <sys/kernel.h> |
38 | #include <sys/device.h> |
39 | #include <sys/conf.h> |
40 | |
41 | #include <dev/usb/usb.h> |
42 | #include <dev/usb/usbdi.h> |
43 | #include <dev/usb/usbdevs.h> |
44 | |
45 | #include <dev/usb/ezload.h> |
46 | |
47 | const struct ezdata uyap_firmware[] = { |
48 | #include "dev/usb/uyap_firmware.h" |
49 | }; |
50 | const struct ezdata *uyap_firmwares[] = { uyap_firmware, NULL }; |
51 | |
52 | struct uyap_softc { |
53 | device_t sc_dev; /* base device */ |
54 | }; |
55 | |
56 | int uyap_match(device_t, cfdata_t, void *); |
57 | void uyap_attach(device_t, device_t, void *); |
58 | int uyap_detach(device_t, int); |
59 | int uyap_activate(device_t, enum devact); |
60 | extern struct cfdriver uyap_cd; |
61 | CFATTACH_DECL_NEW(uyap, sizeof(struct uyap_softc), uyap_match, uyap_attach, |
62 | uyap_detach, uyap_activate); |
63 | |
64 | int |
65 | uyap_match(device_t parent, cfdata_t match, void *aux) |
66 | { |
67 | struct usb_attach_arg *uaa = aux; |
68 | |
69 | /* Match the boot device. */ |
70 | if (uaa->uaa_vendor == USB_VENDOR_SILICONPORTALS && |
71 | uaa->uaa_product == USB_PRODUCT_SILICONPORTALS_YAPPH_NF) |
72 | return (UMATCH_VENDOR_PRODUCT); |
73 | |
74 | return (UMATCH_NONE); |
75 | } |
76 | |
77 | void |
78 | uyap_attach(device_t parent, device_t self, void *aux) |
79 | { |
80 | struct uyap_softc *sc = device_private(self); |
81 | struct usb_attach_arg *uaa = aux; |
82 | struct usbd_device *dev = uaa->uaa_device; |
83 | usbd_status err; |
84 | char *devinfop; |
85 | |
86 | sc->sc_dev = self; |
87 | |
88 | aprint_naive("\n" ); |
89 | aprint_normal("\n" ); |
90 | |
91 | devinfop = usbd_devinfo_alloc(dev, 0); |
92 | aprint_normal_dev(self, "%s\n" , devinfop); |
93 | usbd_devinfo_free(devinfop); |
94 | |
95 | aprint_verbose_dev(self, "downloading firmware\n" ); |
96 | |
97 | err = ezload_downloads_and_reset(dev, uyap_firmwares); |
98 | if (err) { |
99 | aprint_error_dev(self, "download ezdata error: %s\n" , |
100 | usbd_errstr(err)); |
101 | return; |
102 | } |
103 | |
104 | aprint_verbose_dev(self, |
105 | "firmware download complete, disconnecting.\n" ); |
106 | return; |
107 | } |
108 | |
109 | int |
110 | uyap_detach(device_t self, int flags) |
111 | { |
112 | #if 0 |
113 | struct uyap_softc *sc = device_private(self); |
114 | #endif |
115 | |
116 | return (0); |
117 | } |
118 | |
119 | int |
120 | uyap_activate(device_t self, enum devact act) |
121 | { |
122 | return 0; |
123 | } |
124 | |