This source file includes following definitions.
- uyap_match
- uyap_attachhook
- uyap_attach
- uyap_detach
- uyap_activate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
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
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 }