summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2006-07-19 19:51:02 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2006-07-19 19:51:02 +0000
commitec8ff5d977decf4853e73bd3f061a11a19005cea (patch)
tree6809ce3fc4aa434fe9aaf0f6284decf502a50d4c /sys
parent9d758314218905692d9e1ccc44ddbaf04b837c2d (diff)
write firmware 4 bytes at a time.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/if_rum.c35
-rw-r--r--sys/dev/usb/if_rumreg.h6
2 files changed, 14 insertions, 27 deletions
diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c
index ecf552d9018..3c58c258144 100644
--- a/sys/dev/usb/if_rum.c
+++ b/sys/dev/usb/if_rum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rum.c,v 1.23 2006/07/19 19:36:19 damien Exp $ */
+/* $OpenBSD: if_rum.c,v 1.24 2006/07/19 19:51:01 damien Exp $ */
/*-
* Copyright (c) 2005, 2006 Damien Bergamini <damien.bergamini@free.fr>
* Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
@@ -149,7 +149,6 @@ int rum_init(struct ifnet *);
void rum_stop(struct ifnet *, int);
int rum_load_microcode(struct rum_softc *,
const u_char *, size_t);
-int rum_firmware_run(struct rum_softc *sc);
int rum_led_write(struct rum_softc *, uint16_t, uint8_t);
void rum_attachhook(void *);
@@ -2031,14 +2030,19 @@ rum_led_write(struct rum_softc *sc, uint16_t reg, uint8_t strength)
}
int
-rum_firmware_run(struct rum_softc *sc)
+rum_load_microcode(struct rum_softc *sc, const u_char *ucode, size_t size)
{
usb_device_request_t req;
usbd_status error;
+ uint16_t reg = RT2573_MCU_CODE_BASE;
+
+ /* XXX would rum_write_multi(sc, ucode, size) work? */
+ for (; size >= 4; reg += 4, ucode += 4, size -= 4)
+ rum_write(sc, reg, UGETDW(ucode));
req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
- req.bRequest = RT2573_FIRMWARE_RUN;
- USETW(req.wValue, 0x8);
+ req.bRequest = RT2573_MCU_CNTL;
+ USETW(req.wValue, RT2573_MCU_RUN);
USETW(req.wIndex, 0);
USETW(req.wLength, 0);
@@ -2046,27 +2050,8 @@ rum_firmware_run(struct rum_softc *sc)
if (error != 0) {
printf("%s: could not run firmware: %s\n",
USBDEVNAME(sc->sc_dev), usbd_errstr(error));
- return (-1);
- }
- return (0);
-}
-
-int
-rum_load_microcode(struct rum_softc *sc, const u_char *ucode, size_t size)
-{
- size_t i;
-
- for (i = 0; i < size; i += 2) {
- rum_write(sc, RT2573_MCU_CODE_BASE + i,
- (ucode[i+1] << 8) | ucode[i]);
- }
- /* run the firmware */
- if (rum_firmware_run(sc) < 0) {
- return (-1);
}
- DELAY(1000);
-
- return (0);
+ return error;
}
int
diff --git a/sys/dev/usb/if_rumreg.h b/sys/dev/usb/if_rumreg.h
index 1896c5f26e3..429a6877a40 100644
--- a/sys/dev/usb/if_rumreg.h
+++ b/sys/dev/usb/if_rumreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rumreg.h,v 1.5 2006/07/19 19:07:36 damien Exp $ */
+/* $OpenBSD: if_rumreg.h,v 1.6 2006/07/19 19:51:01 damien Exp $ */
/*-
* Copyright (c) 2005, 2006 Damien Bergamini <damien.bergamini@free.fr>
* Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
@@ -19,7 +19,7 @@
#define RT2573_CONFIG_NO 1
#define RT2573_IFACE_INDEX 0
-#define RT2573_FIRMWARE_RUN 0x01
+#define RT2573_MCU_CNTL 0x01
#define RT2573_WRITE_MAC 0x02
#define RT2573_READ_MAC 0x03
#define RT2573_WRITE_MULTI_MAC 0x06
@@ -27,6 +27,8 @@
#define RT2573_READ_EEPROM 0x09
#define RT2573_WRITE_LED 0x0a
+#define RT2573_MCU_RUN (1 << 3)
+
#define RT2573_HOST_READY (1 << 2)
#define RT2573_RESET_ASIC (1 << 0)
#define RT2573_RESET_BBP (1 << 1)