summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorjbm <jbm@cvs.openbsd.org>2001-02-20 23:53:28 +0000
committerjbm <jbm@cvs.openbsd.org>2001-02-20 23:53:28 +0000
commit463d20e1a2747e6e4f67804a07c023e768311f3c (patch)
tree990394d59981b1f68f87ce16a9fb6af801da8529 /sys/arch
parent44f3af757835f18033deec7834c749be3bb92d2e (diff)
Import of wsmouse-compatible lms and mms drivers from NetBSD.
Remove creation of non-wsmouse device in MAKEDEV (/dev/lms{0,1}, /dev/mms{0,1} /dev/psm0, /dev/pms0). Remove cdevsw[] entries for the devices above, as new mouse protocols are only accessible trough /dev/wsmouse. aaron@ ok.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/i386/i386/conf.c10
-rw-r--r--sys/arch/i386/isa/lms.c259
-rw-r--r--sys/arch/i386/isa/mms.c253
3 files changed, 518 insertions, 4 deletions
diff --git a/sys/arch/i386/i386/conf.c b/sys/arch/i386/i386/conf.c
index 73ba65edcca..06876d3835b 100644
--- a/sys/arch/i386/i386/conf.c
+++ b/sys/arch/i386/i386/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.63 2001/01/30 00:00:31 aaron Exp $ */
+/* $OpenBSD: conf.c,v 1.64 2001/02/20 23:53:26 jbm Exp $ */
/* $NetBSD: conf.c,v 1.75 1996/05/03 19:40:20 christos Exp $ */
/*
@@ -163,12 +163,14 @@ cdev_decl(pcmcia);
#endif
#include "spkr.h"
cdev_decl(spkr);
+#if 0 /* old (non-wsmouse) drivers */
#include "mms.h"
cdev_decl(mms);
#include "lms.h"
cdev_decl(lms);
#include "opms.h"
cdev_decl(pms);
+#endif
#include "cy.h"
cdev_decl(cy);
cdev_decl(mcd);
@@ -276,9 +278,9 @@ struct cdevsw cdevsw[] =
cdev_lkm_dummy(), /* 32 */
cdev_lkm_dummy(), /* 33 */
cdev_lkm_dummy(), /* 34 */
- cdev_mouse_init(NMMS,mms), /* 35: Microsoft mouse */
- cdev_mouse_init(NLMS,lms), /* 36: Logitech mouse */
- cdev_mousewr_init(NOPMS,pms), /* 37: Extended PS/2 mouse */
+ cdev_notdef(), /* 35: Microsoft mouse */
+ cdev_notdef(), /* 36: Logitech mouse */
+ cdev_notdef(), /* 37: Extended PS/2 mouse */
cdev_tty_init(NCY,cy), /* 38: Cyclom serial port */
cdev_disk_init(NMCD,mcd), /* 39: Mitsumi CD-ROM */
cdev_bpftun_init(NTUN,tun), /* 40: network tunnel */
diff --git a/sys/arch/i386/isa/lms.c b/sys/arch/i386/isa/lms.c
new file mode 100644
index 00000000000..b47c709c486
--- /dev/null
+++ b/sys/arch/i386/isa/lms.c
@@ -0,0 +1,259 @@
+/* $OpenBSD */
+/* $NetBSD: lms.c,v 1.38 2000/01/08 02:57:25 takemura Exp $ */
+
+/*-
+ * Copyright (c) 1993, 1994 Charles M. Hannum.
+ * Copyright (c) 1992, 1993 Erik Forsberg.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``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 I 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.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/ioctl.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/isa/isavar.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsmousevar.h>
+
+#define LMS_DATA 0 /* offset for data port, read-only */
+#define LMS_SIGN 1 /* offset for signature port, read-write */
+#define LMS_INTR 2 /* offset for interrupt port, read-only */
+#define LMS_CNTRL 2 /* offset for control port, write-only */
+#define LMS_CONFIG 3 /* for configuration port, read-write */
+#define LMS_NPORTS 4
+
+struct lms_softc { /* driver status information */
+ struct device sc_dev;
+ void *sc_ih;
+
+ bus_space_tag_t sc_iot; /* bus i/o space identifier */
+ bus_space_handle_t sc_ioh; /* bus i/o handle */
+
+ int sc_enabled; /* device is open */
+ int oldbuttons; /* mouse button status */
+
+ struct device *sc_wsmousedev;
+};
+
+int lmsprobe __P((struct device *, void *, void *));
+void lmsattach __P((struct device *, struct device *, void *));
+int lmsintr __P((void *));
+
+struct cfattach lms_ca = {
+ sizeof(struct lms_softc), lmsprobe, lmsattach
+};
+
+int lms_enable __P((void *));
+int lms_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
+void lms_disable __P((void *));
+
+const struct wsmouse_accessops lms_accessops = {
+ lms_enable,
+ lms_ioctl,
+ lms_disable,
+};
+
+int
+lmsprobe(parent, match, aux)
+ struct device *parent;
+ void *match;
+ void *aux;
+{
+ struct isa_attach_args *ia = aux;
+ bus_space_tag_t iot = ia->ia_iot;
+ bus_space_handle_t ioh;
+ int rv;
+
+ /* Disallow wildcarded i/o base. */
+ if (ia->ia_iobase == IOBASEUNK)
+ return 0;
+
+ /* Map the i/o space. */
+ if (bus_space_map(iot, ia->ia_iobase, LMS_NPORTS, 0, &ioh))
+ return 0;
+
+ rv = 0;
+
+ /* Configure and check for port present. */
+ bus_space_write_1(iot, ioh, LMS_CONFIG, 0x91);
+ delay(10);
+ bus_space_write_1(iot, ioh, LMS_SIGN, 0x0c);
+ delay(10);
+ if (bus_space_read_1(iot, ioh, LMS_SIGN) != 0x0c)
+ goto out;
+ bus_space_write_1(iot, ioh, LMS_SIGN, 0x50);
+ delay(10);
+ if (bus_space_read_1(iot, ioh, LMS_SIGN) != 0x50)
+ goto out;
+
+ /* Disable interrupts. */
+ bus_space_write_1(iot, ioh, LMS_CNTRL, 0x10);
+
+ rv = 1;
+ ia->ia_iosize = LMS_NPORTS;
+ ia->ia_msize = 0;
+
+out:
+ bus_space_unmap(iot, ioh, LMS_NPORTS);
+ return rv;
+}
+
+void
+lmsattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct lms_softc *sc = (void *)self;
+ struct isa_attach_args *ia = aux;
+ bus_space_tag_t iot = ia->ia_iot;
+ bus_space_handle_t ioh;
+ struct wsmousedev_attach_args a;
+
+ printf("\n");
+
+ if (bus_space_map(iot, ia->ia_iobase, LMS_NPORTS, 0, &ioh)) {
+ printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
+ return;
+ }
+
+ /* Other initialization was done by lmsprobe. */
+ sc->sc_iot = iot;
+ sc->sc_ioh = ioh;
+ sc->sc_enabled = 0;
+
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_PULSE,
+ IPL_TTY, lmsintr, sc, sc->sc_dev.dv_xname);
+
+ a.accessops = &lms_accessops;
+ a.accesscookie = sc;
+
+ /*
+ * Attach the wsmouse, saving a handle to it.
+ * Note that we don't need to check this pointer against NULL
+ * here or in psmintr, because if this fails lms_enable() will
+ * never be called, so lmsintr() will never be called.
+ */
+ sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
+}
+
+int
+lms_enable(v)
+ void *v;
+{
+ struct lms_softc *sc = v;
+
+ if (sc->sc_enabled)
+ return EBUSY;
+
+ sc->sc_enabled = 1;
+ sc->oldbuttons = 0;
+
+ /* Enable interrupts. */
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, LMS_CNTRL, 0);
+
+ return 0;
+}
+
+void
+lms_disable(v)
+ void *v;
+{
+ struct lms_softc *sc = v;
+
+ /* Disable interrupts. */
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, LMS_CNTRL, 0x10);
+
+ sc->sc_enabled = 0;
+}
+
+int
+lms_ioctl(v, cmd, data, flag, p)
+ void *v;
+ u_long cmd;
+ caddr_t data;
+ int flag;
+ struct proc *p;
+{
+#if 0
+ struct lms_softc *sc = v;
+#endif
+
+ switch (cmd) {
+ case WSMOUSEIO_GTYPE:
+ *(u_int *)data = WSMOUSE_TYPE_LMS;
+ return (0);
+ }
+ return (-1);
+}
+
+int
+lmsintr(arg)
+ void *arg;
+{
+ struct lms_softc *sc = arg;
+ bus_space_tag_t iot = sc->sc_iot;
+ bus_space_handle_t ioh = sc->sc_ioh;
+ u_char hi, lo;
+ signed char dx, dy;
+ u_int buttons;
+ int changed;
+
+ if (!sc->sc_enabled)
+ /* Interrupts are not expected. */
+ return 0;
+
+ bus_space_write_1(iot, ioh, LMS_CNTRL, 0xab);
+ hi = bus_space_read_1(iot, ioh, LMS_DATA);
+ bus_space_write_1(iot, ioh, LMS_CNTRL, 0x90);
+ lo = bus_space_read_1(iot, ioh, LMS_DATA);
+ dx = ((hi & 0x0f) << 4) | (lo & 0x0f);
+ /* Bounding at -127 avoids a bug in XFree86. */
+ dx = (dx == -128) ? -127 : dx;
+
+ bus_space_write_1(iot, ioh, LMS_CNTRL, 0xf0);
+ hi = bus_space_read_1(iot, ioh, LMS_DATA);
+ bus_space_write_1(iot, ioh, LMS_CNTRL, 0xd0);
+ lo = bus_space_read_1(iot, ioh, LMS_DATA);
+ dy = ((hi & 0x0f) << 4) | (lo & 0x0f);
+ dy = (dy == -128) ? 127 : -dy;
+
+ bus_space_write_1(iot, ioh, LMS_CNTRL, 0);
+
+ buttons = ((hi & 0x80) ? 0 : 0x1) |
+ ((hi & 0x40) ? 0 : 0x2) |
+ ((hi & 0x20) ? 0 : 0x4);
+ changed = (buttons ^ sc->oldbuttons);
+ sc->oldbuttons = buttons;
+
+ if (dx || dy || changed)
+ wsmouse_input(sc->sc_wsmousedev,
+ buttons, dx, dy, 0, WSMOUSE_INPUT_DELTA);
+
+ return -1;
+}
+
+struct cfdriver lms_cd = {
+ NULL, "lms", DV_DULL
+};
diff --git a/sys/arch/i386/isa/mms.c b/sys/arch/i386/isa/mms.c
new file mode 100644
index 00000000000..41e8b6b435e
--- /dev/null
+++ b/sys/arch/i386/isa/mms.c
@@ -0,0 +1,253 @@
+/* $OpenBSD: mms.c,v 1.14 2001/02/20 23:53:27 jbm Exp $ */
+/* $NetBSD: mms.c,v 1.35 2000/01/08 02:57:25 takemura Exp $ */
+
+/*-
+ * Copyright (c) 1993, 1994 Charles M. Hannum.
+ * Copyright (c) 1992, 1993 Erik Forsberg.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``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 I 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.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/ioctl.h>
+#include <sys/device.h>
+
+#include <machine/intr.h>
+#include <machine/bus.h>
+
+#include <dev/isa/isavar.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsmousevar.h>
+
+#define MMS_ADDR 0 /* offset for register select */
+#define MMS_DATA 1 /* offset for InPort data */
+#define MMS_IDENT 2 /* offset for identification register */
+#define MMS_NPORTS 4
+
+struct mms_softc { /* driver status information */
+ struct device sc_dev;
+ void *sc_ih;
+
+ bus_space_tag_t sc_iot;
+ bus_space_handle_t sc_ioh;
+
+ int sc_enabled; /* device is open */
+
+ struct device *sc_wsmousedev;
+};
+
+int mmsprobe __P((struct device *, void *, void *));
+void mmsattach __P((struct device *, struct device *, void *));
+int mmsintr __P((void *));
+
+struct cfattach mms_ca = {
+ sizeof(struct mms_softc), mmsprobe, mmsattach
+};
+
+int mms_enable __P((void *));
+int mms_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
+void mms_disable __P((void *));
+
+const struct wsmouse_accessops mms_accessops = {
+ mms_enable,
+ mms_ioctl,
+ mms_disable,
+};
+
+int
+mmsprobe(parent, match, aux)
+ struct device *parent;
+ void *match;
+ void *aux;
+{
+ struct isa_attach_args *ia = aux;
+ bus_space_tag_t iot = ia->ia_iot;
+ bus_space_handle_t ioh;
+ int rv;
+
+ /* Disallow wildcarded i/o address. */
+ if (ia->ia_iobase == IOBASEUNK)
+ return 0;
+
+ /* Map the i/o space. */
+ if (bus_space_map(iot, ia->ia_iobase, MMS_NPORTS, 0, &ioh))
+ return 0;
+
+ rv = 0;
+
+ /* Read identification register to see if present */
+ if (bus_space_read_1(iot, ioh, MMS_IDENT) != 0xde)
+ goto out;
+
+ /* Seems it was there; reset. */
+ bus_space_write_1(iot, ioh, MMS_ADDR, 0x87);
+
+ rv = 1;
+ ia->ia_iosize = MMS_NPORTS;
+ ia->ia_msize = 0;
+
+out:
+ bus_space_unmap(iot, ioh, MMS_NPORTS);
+ return rv;
+}
+
+void
+mmsattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct mms_softc *sc = (void *)self;
+ struct isa_attach_args *ia = aux;
+ bus_space_tag_t iot = ia->ia_iot;
+ bus_space_handle_t ioh;
+ struct wsmousedev_attach_args a;
+
+ printf("\n");
+
+ if (bus_space_map(iot, ia->ia_iobase, MMS_NPORTS, 0, &ioh)) {
+ printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
+ return;
+ }
+
+ /* Other initialization was done by mmsprobe. */
+ sc->sc_iot = iot;
+ sc->sc_ioh = ioh;
+ sc->sc_enabled = 0;
+
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_PULSE,
+ IPL_TTY, mmsintr, sc, sc->sc_dev.dv_xname);
+
+ a.accessops = &mms_accessops;
+ a.accesscookie = sc;
+
+ /*
+ * Attach the wsmouse, saving a handle to it.
+ * Note that we don't need to check this pointer against NULL
+ * here or in psmintr, because if this fails lms_enable() will
+ * never be called, so lmsintr() will never be called.
+ */
+ sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
+}
+
+int
+mms_enable(v)
+ void *v;
+{
+ struct mms_softc *sc = v;
+
+ if (sc->sc_enabled)
+ return EBUSY;
+
+ sc->sc_enabled = 1;
+
+ /* Enable interrupts. */
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, MMS_ADDR, 0x07);
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, MMS_DATA, 0x09);
+
+ return 0;
+}
+
+void
+mms_disable(v)
+ void *v;
+{
+ struct mms_softc *sc = v;
+
+ /* Disable interrupts. */
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, MMS_ADDR, 0x87);
+
+ sc->sc_enabled = 0;
+}
+
+int
+mms_ioctl(v, cmd, data, flag, p)
+ void *v;
+ u_long cmd;
+ caddr_t data;
+ int flag;
+ struct proc *p;
+{
+#if 0
+ struct mms_softc *sc = v;
+#endif
+
+ switch (cmd) {
+ case WSMOUSEIO_GTYPE:
+ *(u_int *)data = WSMOUSE_TYPE_MMS;
+ return (0);
+ }
+ return (-1);
+}
+
+int
+mmsintr(arg)
+ void *arg;
+{
+ struct mms_softc *sc = arg;
+ bus_space_tag_t iot = sc->sc_iot;
+ bus_space_handle_t ioh = sc->sc_ioh;
+ u_char status;
+ signed char dx, dy;
+ u_int buttons;
+ int changed;
+
+ if (!sc->sc_enabled)
+ /* Interrupts are not expected. */
+ return 0;
+
+ /* Freeze InPort registers (disabling interrupts). */
+ bus_space_write_1(iot, ioh, MMS_ADDR, 0x07);
+ bus_space_write_1(iot, ioh, MMS_DATA, 0x29);
+
+ bus_space_write_1(iot, ioh, MMS_ADDR, 0x00);
+ status = bus_space_read_1(iot, ioh, MMS_DATA);
+
+ if (status & 0x40) {
+ bus_space_write_1(iot, ioh, MMS_ADDR, 1);
+ dx = bus_space_read_1(iot, ioh, MMS_DATA);
+ /* Bounding at -127 avoids a bug in XFree86. */
+ dx = (dx == -128) ? -127 : dx;
+
+ bus_space_write_1(iot, ioh, MMS_ADDR, 2);
+ dy = bus_space_read_1(iot, ioh, MMS_DATA);
+ dy = (dy == -128) ? 127 : -dy;
+ } else
+ dx = dy = 0;
+
+ /* Unfreeze InPort registers (reenabling interrupts). */
+ bus_space_write_1(iot, ioh, MMS_ADDR, 0x07);
+ bus_space_write_1(iot, ioh, MMS_DATA, 0x09);
+
+ buttons = ((status & 0x04) ? 0x1 : 0) |
+ ((status & 0x02) ? 0x2 : 0) |
+ ((status & 0x01) ? 0x4 : 0);
+ changed = status & 0x38;
+
+ if (dx || dy || changed)
+ wsmouse_input(sc->sc_wsmousedev,
+ buttons, dx, dy, 0, WSMOUSE_INPUT_DELTA);
+
+ return -1;
+}
+
+struct cfdriver mms_cd = {
+ NULL, "mms", DV_DULL
+};