summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorAlexander Yurchenko <grange@cvs.openbsd.org>2006-09-27 16:29:57 +0000
committerAlexander Yurchenko <grange@cvs.openbsd.org>2006-09-27 16:29:57 +0000
commit55d78e12a83755768d7ceee102f29181370f9e1d (patch)
treeb3484abbda495d3963640f7e1cf5432e5affc411 /sys/dev
parent6c9546ab1a283af77bcfc0a3306f024094ed977f (diff)
Implement 1-wire byte read/write.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/uow.c31
-rw-r--r--sys/dev/usb/uowreg.h3
2 files changed, 32 insertions, 2 deletions
diff --git a/sys/dev/usb/uow.c b/sys/dev/usb/uow.c
index 7a5c0b2b4df..e0e5fad5dcb 100644
--- a/sys/dev/usb/uow.c
+++ b/sys/dev/usb/uow.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uow.c,v 1.5 2006/09/27 15:32:37 grange Exp $ */
+/* $OpenBSD: uow.c,v 1.6 2006/09/27 16:29:56 grange Exp $ */
/*
* Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org>
@@ -67,6 +67,8 @@ static const struct usb_devno uow_devs[] = {
Static int uow_ow_reset(void *);
Static int uow_ow_bit(void *, int);
+Static int uow_ow_read_byte(void *);
+Static void uow_ow_write_byte(void *, int);
Static int uow_cmd(struct uow_softc *, int, int);
Static void uow_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
@@ -180,6 +182,8 @@ USB_ATTACH(uow)
sc->sc_ow_bus.bus_cookie = sc;
sc->sc_ow_bus.bus_reset = uow_ow_reset;
sc->sc_ow_bus.bus_bit = uow_ow_bit;
+ sc->sc_ow_bus.bus_read_byte = uow_ow_read_byte;
+ sc->sc_ow_bus.bus_write_byte = uow_ow_write_byte;
bzero(&oba, sizeof(oba));
oba.oba_bus = &sc->sc_ow_bus;
@@ -279,6 +283,31 @@ uow_ow_bit(void *arg, int value)
}
Static int
+uow_ow_read_byte(void *arg)
+{
+ struct uow_softc *sc = arg;
+ u_int8_t data;
+
+ if (uow_cmd(sc, DS2490_COMM_BYTE_IO | DS2490_BIT_IM, 0xff) != 0)
+ return (-1);
+ if (uow_recv(sc, &data, sizeof(data)) != 0)
+ return (-1);
+
+ return (data);
+}
+
+Static void
+uow_ow_write_byte(void *arg, int value)
+{
+ struct uow_softc *sc = arg;
+ u_int8_t data;
+
+ if (uow_cmd(sc, DS2490_COMM_BYTE_IO | DS2490_BIT_IM, value) != 0)
+ return;
+ uow_recv(sc, &data, sizeof(data));
+}
+
+Static int
uow_cmd(struct uow_softc *sc, int cmd, int param)
{
usb_device_request_t req;
diff --git a/sys/dev/usb/uowreg.h b/sys/dev/usb/uowreg.h
index 57327d0efdd..5968ff517f3 100644
--- a/sys/dev/usb/uowreg.h
+++ b/sys/dev/usb/uowreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uowreg.h,v 1.1 2006/09/27 08:54:44 grange Exp $ */
+/* $OpenBSD: uowreg.h,v 1.2 2006/09/27 16:29:56 grange Exp $ */
/*
* Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org>
@@ -48,6 +48,7 @@
#define DS2490_COMM_PULSE 0x0030
#define DS2490_COMM_1WIRE_RESET 0x0042
#define DS2490_COMM_BIT_IO 0x0020
+#define DS2490_COMM_BYTE_IO 0x0052
/* Communication command embedded command parameter bits */
#define DS2490_BIT_IM (1 << 0)