summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2004-11-22 18:49:06 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2004-11-22 18:49:06 +0000
commitef151676286d120c8c8783a4afe273722ef16590 (patch)
tree6881bd8934cf5537e12ebfc67aa15ce94c49caa6 /sys/dev/usb
parente7ad7c2065e591b266d4b0613c8fcbe9be00eaae (diff)
firmware loading for kue(4), tested for me by dhartmei
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/files.usb4
-rw-r--r--sys/dev/usb/if_kue.c37
-rw-r--r--sys/dev/usb/if_kuevar.h42
3 files changed, 68 insertions, 15 deletions
diff --git a/sys/dev/usb/files.usb b/sys/dev/usb/files.usb
index 150223f59e9..30f43564f22 100644
--- a/sys/dev/usb/files.usb
+++ b/sys/dev/usb/files.usb
@@ -1,4 +1,4 @@
-# $OpenBSD: files.usb,v 1.40 2004/11/17 14:13:47 deraadt Exp $
+# $OpenBSD: files.usb,v 1.41 2004/11/22 18:49:05 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.
@@ -136,7 +136,7 @@ attach cue at uhub
file dev/usb/if_cue.c cue
# Kawasaki LSI KL5KUSB101B
-device kue: ether, ifnet, ifmedia
+device kue: ether, ifnet, ifmedia, firmload
attach kue at uhub
file dev/usb/if_kue.c kue
diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c
index 7aea22ebdc5..38ea5483930 100644
--- a/sys/dev/usb/if_kue.c
+++ b/sys/dev/usb/if_kue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_kue.c,v 1.29 2004/11/10 10:14:48 grange Exp $ */
+/* $OpenBSD: if_kue.c,v 1.30 2004/11/22 18:49:05 deraadt Exp $ */
/* $NetBSD: if_kue.c,v 1.50 2002/07/16 22:00:31 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -132,12 +132,7 @@
#include <dev/usb/usbdevs.h>
#include <dev/usb/if_kuereg.h>
-
-#if defined(__OpenBSD__)
-#include <dev/microcode/kue/kue_fw.h>
-#else
-#include <dev/usb/kue_fw.h>
-#endif
+#include <dev/usb/if_kuevar.h>
#ifdef KUE_DEBUG
#define DPRINTF(x) do { if (kuedebug) logprintf x; } while (0)
@@ -253,6 +248,9 @@ kue_load_fw(struct kue_softc *sc)
{
usb_device_descriptor_t dd;
usbd_status err;
+ struct kue_firmware *fw;
+ u_char *buf;
+ size_t buflen;
DPRINTFN(1,("%s: %s: enter\n", USBDEVNAME(sc->kue_dev), __func__));
@@ -278,6 +276,14 @@ kue_load_fw(struct kue_softc *sc)
return (0);
}
+ err = loadfirmware("kue", &buf, &buflen);
+ if (err) {
+ printf("%s: failed loadfirmware of file %s: errno %d\n",
+ USBDEVNAME(sc->kue_dev), "kue", err);
+ return (err);
+ }
+ fw = (struct kue_firmware *)buf;
+
printf("%s: cold boot, downloading firmware\n",
USBDEVNAME(sc->kue_dev));
@@ -285,34 +291,39 @@ kue_load_fw(struct kue_softc *sc)
DPRINTFN(1,("%s: kue_load_fw: download code_seg\n",
USBDEVNAME(sc->kue_dev)));
err = kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SEND_SCAN,
- 0, (void *)kue_code_seg, sizeof(kue_code_seg));
+ 0, (void *)&fw->data[0], fw->codeseglen);
if (err) {
printf("%s: failed to load code segment: %s\n",
USBDEVNAME(sc->kue_dev), usbd_errstr(err));
- return (EIO);
+ free(buf, M_DEVBUF);
+ return (EIO);
}
/* Load fixup segment */
DPRINTFN(1,("%s: kue_load_fw: download fix_seg\n",
USBDEVNAME(sc->kue_dev)));
err = kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SEND_SCAN,
- 0, (void *)kue_fix_seg, sizeof(kue_fix_seg));
+ 0, (void *)&fw->data[fw->codeseglen], fw->fixseglen);
if (err) {
printf("%s: failed to load fixup segment: %s\n",
USBDEVNAME(sc->kue_dev), usbd_errstr(err));
- return (EIO);
+ free(buf, M_DEVBUF);
+ return (EIO);
}
/* Send trigger command. */
DPRINTFN(1,("%s: kue_load_fw: download trig_seg\n",
USBDEVNAME(sc->kue_dev)));
err = kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SEND_SCAN,
- 0, (void *)kue_trig_seg, sizeof(kue_trig_seg));
+ 0, (void *)&fw->data[fw->codeseglen + fw->fixseglen],
+ fw->trigseglen);
if (err) {
printf("%s: failed to load trigger segment: %s\n",
USBDEVNAME(sc->kue_dev), usbd_errstr(err));
- return (EIO);
+ free(buf, M_DEVBUF);
+ return (EIO);
}
+ free(buf, M_DEVBUF);
usbd_delay_ms(sc->kue_udev, 10);
diff --git a/sys/dev/usb/if_kuevar.h b/sys/dev/usb/if_kuevar.h
new file mode 100644
index 00000000000..a7028d28038
--- /dev/null
+++ b/sys/dev/usb/if_kuevar.h
@@ -0,0 +1,42 @@
+/* $OpenBSD: if_kuevar.h,v 1.1 2004/11/22 18:49:05 deraadt Exp $ */
+/* $NetBSD: if_kuereg.h,v 1.11 2001/01/21 02:35:31 augustss Exp $ */
+/*
+ * Copyright (c) 1997, 1998, 1999, 2000
+ * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Bill Paul.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/dev/usb/if_kuereg.h,v 1.2 2000/01/06 07:39:07 wpaul Exp $
+ */
+
+struct kue_firmware {
+ int codeseglen;
+ int fixseglen;
+ int trigseglen;
+ u_char data[4];
+};