Initial commit of wsmouse driver for the IOMD quadratic mouse.
This commit is contained in:
parent
e0e3b230c1
commit
763e66f5de
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: RPC_WSCONS,v 1.3 2001/04/14 14:51:04 reinoud Exp $
|
||||
# $NetBSD: RPC_WSCONS,v 1.4 2001/04/14 19:22:43 reinoud Exp $
|
||||
#
|
||||
# RPC_WSCONS -- Full RiscPC config with wscons
|
||||
#
|
||||
|
@ -145,9 +145,6 @@ iomd0 at mainbus?
|
|||
# system clock via IOMD
|
||||
clock* at iomd?
|
||||
|
||||
# quadrature mouse via IOMD
|
||||
qms* at iomd?
|
||||
|
||||
# IIC bus device
|
||||
iic* at iomd?
|
||||
|
||||
|
@ -184,6 +181,9 @@ wsdisplay* at vidcvideo? console ? # display itself
|
|||
rpckbd* at iomd? # based on old `kbd' driver
|
||||
wskbd* at rpckbd? # wskbd on RiscPC keyboard
|
||||
|
||||
wsqms* at iomd? # ws quadmouse driver
|
||||
wsmouse* at wsqms? # wsmouse on ws quadmouse
|
||||
|
||||
pseudo-device wsmux 2 # why 2 ?
|
||||
|
||||
|
||||
|
@ -192,7 +192,8 @@ pseudo-device wsmux 2 # why 2 ?
|
|||
# vidcconsole PS2 mouse at IOMD
|
||||
#vidcconsole0 at vidc? # display + vt100 emulation
|
||||
#kbd* at iomd? # PS/2 keyboard for vidcconsole
|
||||
#opms* at iomd? # RiscPC mouse for vidcconsole
|
||||
#qms* at iomd? # RiscPC mouse for vidcconsole
|
||||
#opms* at iomd? # A7000/NC? mouse for vidcconsole
|
||||
|
||||
# generic VT console device
|
||||
#vt0 at vidc?
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.arm32,v 1.106 2001/04/05 20:31:50 bjh21 Exp $
|
||||
# $NetBSD: files.arm32,v 1.107 2001/04/14 19:22:43 reinoud Exp $
|
||||
#
|
||||
# First try for arm-specific configuration info
|
||||
#
|
||||
|
@ -141,6 +141,13 @@ file arch/arm32/dev/qms.c qms needs-flag
|
|||
attach qms at iomd with qms_iomd
|
||||
file arch/arm32/iomd/qms_iomd.c qms_iomd
|
||||
|
||||
# wscons quadmouse device
|
||||
device wsqms : wsmousedev
|
||||
file arch/arm32/dev/wsqms.c wsqms needs-flag
|
||||
|
||||
attach wsqms at iomd with wsqms_iomd
|
||||
file arch/arm32/iomd/wsqms_iomd.c wsqms_iomd
|
||||
|
||||
# attribute used to represent the "keyboard controller" on the shark
|
||||
# XXX should be a real device
|
||||
define spckbd { [irq = -1], [port = -1] }
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
/* $NetBSD: wsqms.c,v 1.1 2001/04/14 19:22:44 reinoud Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Reinoud Zandijk
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Reinoud Zandijk
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 THE FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* Quadratic mouse driver for the wscons as used in the IOMD but is in
|
||||
* principle more generic.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <sys/device.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/irqhandler.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wsksymdef.h>
|
||||
#include <dev/wscons/wsmousevar.h>
|
||||
|
||||
#include <arch/arm32/dev/wsqmsvar.h>
|
||||
|
||||
|
||||
/* Offsets of hardware registers */
|
||||
#define QMS_MOUSEX 0 /* 16 bits X register */
|
||||
#define QMS_MOUSEY 1 /* 16 bits Y register */
|
||||
#define QMS_BUTTONS 0 /* mouse buttons in bits 4,5,6 */
|
||||
|
||||
#define MAX_XYREG 4096
|
||||
|
||||
/* forward declarations */
|
||||
|
||||
static int wsqms_enable __P((void *cookie));
|
||||
static int wsqms_ioctl __P((void *cookie, u_long cmd, caddr_t data, int flag, struct proc *p));
|
||||
static void wsqms_disable __P((void *cookie));
|
||||
|
||||
|
||||
static struct wsmouse_accessops wsqms_accessops = {
|
||||
wsqms_enable, wsqms_ioctl, wsqms_disable
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
wsqms_attach(sc, self)
|
||||
struct wsqms_softc *sc;
|
||||
struct device *self;
|
||||
{
|
||||
struct wsmousedev_attach_args wsmouseargs;
|
||||
|
||||
/* set up wsmouse attach arguments */
|
||||
wsmouseargs.accessops = &wsqms_accessops;
|
||||
wsmouseargs.accesscookie = self;
|
||||
|
||||
printf("\n");
|
||||
|
||||
sc->sc_wsmousedev = config_found(self, &wsmouseargs, wsmousedevprint);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
wsqms_enable(cookie)
|
||||
void *cookie;
|
||||
{
|
||||
struct wsqms_softc *sc = cookie;
|
||||
|
||||
sc->sc_flags |= WSQMS_ENABLED;
|
||||
|
||||
/* enable interrupts */
|
||||
sc->sc_intenable(sc, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
wsqms_disable(cookie)
|
||||
void *cookie;
|
||||
{
|
||||
struct wsqms_softc *sc = cookie;
|
||||
|
||||
sc->sc_flags &= ~WSQMS_ENABLED;
|
||||
|
||||
/* disable interrupts */
|
||||
sc->sc_intenable(sc, 0);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
wsqms_ioctl(cookie, cmd, data, flag, p)
|
||||
void *cookie;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
switch (cmd) {
|
||||
case WSMOUSEIO_GTYPE:
|
||||
*(int *)data = WSMOUSE_TYPE_ARCHIMEDES;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* We can really put in the mouse XY as absolutes ? */
|
||||
int
|
||||
wsqms_intr(arg)
|
||||
void *arg;
|
||||
{
|
||||
struct wsqms_softc *sc = arg;
|
||||
int x, y, b;
|
||||
|
||||
x = bus_space_read_4(sc->sc_iot, sc->sc_ioh, QMS_MOUSEX) & 0xffff;
|
||||
y = bus_space_read_4(sc->sc_iot, sc->sc_ioh, QMS_MOUSEY) & 0xffff;
|
||||
b = bus_space_read_1(sc->sc_iot, sc->sc_butioh, QMS_BUTTONS) & 0x70;
|
||||
b >>= 4;
|
||||
if (x & 0x8000) x |= 0xffff0000;
|
||||
if (y & 0x8000) y |= 0xffff0000;
|
||||
|
||||
/* patch up the buttons */
|
||||
b = ~( ((b & 1)<<2) | (b & 2) | ((b & 4)>>2));
|
||||
|
||||
if ((x != sc->lastx) || (y != sc->lasty) || (b != sc->lastb)) {
|
||||
/* save old values */
|
||||
sc->lastx = x;
|
||||
sc->lasty = y;
|
||||
sc->lastb = b;
|
||||
|
||||
/* do we have to bound x and y ? => yes */
|
||||
if (x < -MAX_XYREG) x = -MAX_XYREG;
|
||||
if (x > MAX_XYREG) x = MAX_XYREG;
|
||||
if (y < -MAX_XYREG) y = -MAX_XYREG;
|
||||
if (y > MAX_XYREG) y = MAX_XYREG;
|
||||
|
||||
/* write the bounded values back */
|
||||
bus_space_write_4(sc->sc_iot, sc->sc_ioh, QMS_MOUSEX, x);
|
||||
bus_space_write_4(sc->sc_iot, sc->sc_ioh, QMS_MOUSEY, y);
|
||||
|
||||
wsmouse_input(sc->sc_wsmousedev, b, x, y, 0,
|
||||
WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y);
|
||||
};
|
||||
|
||||
return (0); /* pass on */
|
||||
}
|
||||
|
||||
|
||||
/* end of wsqms.c */
|
|
@ -0,0 +1,75 @@
|
|||
/* $NetBSD: wsqmsvar.h,v 1.1 2001/04/14 19:22:44 reinoud Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Reinoud Zandijk
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Reinoud Zandijk
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 THE FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* Quadratic mouse driver variable for the wscons as used in the IOMD but is in
|
||||
* principle more generic.
|
||||
*
|
||||
* wsqmsvar.h
|
||||
*/
|
||||
|
||||
|
||||
/* softc structure for the wsqms device */
|
||||
|
||||
struct wsqms_softc {
|
||||
struct device sc_device; /* remember our own device as attached */
|
||||
struct device *sc_wsmousedev; /* remember our wsmouse device... */
|
||||
|
||||
bus_space_tag_t sc_iot; /* bus tag */
|
||||
bus_space_handle_t sc_ioh; /* bus handle for XY */
|
||||
bus_space_handle_t sc_butioh; /* bus handle for buttons */
|
||||
|
||||
/* interupt handler switch function + goo */
|
||||
void (*sc_intenable) __P((struct wsqms_softc *, int));
|
||||
void *sc_ih; /* interrupt pointer */
|
||||
int sc_irqnum; /* IRQ number */
|
||||
|
||||
#define WSQMS_ENABLED 0x01
|
||||
int sc_flags;
|
||||
|
||||
int lastx;
|
||||
int lasty;
|
||||
int lastb;
|
||||
};
|
||||
|
||||
|
||||
/* function prototypes */
|
||||
extern void wsqms_attach __P((struct wsqms_softc *sc, struct device *));
|
||||
extern int wsqms_intr __P((void *arg));
|
||||
|
||||
|
||||
/* End of wsqmsvar.h */
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: iomd.c,v 1.9 2001/03/20 18:20:55 reinoud Exp $ */
|
||||
/* $NetBSD: iomd.c,v 1.10 2001/04/14 19:22:44 reinoud Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-1997 Mark Brinicombe.
|
||||
|
@ -294,7 +294,7 @@ iomdattach(parent, self, aux)
|
|||
break;
|
||||
#endif /* CPU_ARM7500 */
|
||||
case RPC600_IOMD_ID:
|
||||
/* Attach qms device */
|
||||
/* Attach (ws)qms device */
|
||||
|
||||
if (bus_space_subregion(iot, ioh, IOMD_MOUSEX, 8, &ia.ia_qms.qa_ioh))
|
||||
panic("%s: Cannot map qms registers\n", self->dv_xname);
|
||||
|
@ -305,6 +305,9 @@ iomdattach(parent, self, aux)
|
|||
ia.ia_qms.qa_iot = iot;
|
||||
ia.ia_qms.qa_irq = IRQ_VSYNC;
|
||||
config_found(self, &ia, iomdprint);
|
||||
|
||||
ia.ia_qms.qa_name = "wsqms";
|
||||
config_found(self, &ia, iomdprint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
/* $NetBSD: wsqms_iomd.c,v 1.1 2001/04/14 19:22:45 reinoud Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Reinoud Zandijk
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Reinoud Zandijk
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 THE FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* Quadratic mouse driver for the wscons as used in the IOMD; config glue...
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/tty.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/irqhandler.h>
|
||||
#include <arm32/dev/wsqmsvar.h>
|
||||
#include <arm32/iomd/iomdvar.h>
|
||||
|
||||
static int wsqms_iomd_probe __P((struct device *, struct cfdata *, void *));
|
||||
static void wsqms_iomd_attach __P((struct device *, struct device *, void *));
|
||||
static void wsqms_iomd_intenable __P((struct wsqms_softc *sc, int enable));
|
||||
|
||||
|
||||
struct cfattach wsqms_iomd_ca = {
|
||||
sizeof(struct wsqms_softc), wsqms_iomd_probe, wsqms_iomd_attach
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
wsqms_iomd_probe(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
{
|
||||
struct qms_attach_args *qa = aux;
|
||||
|
||||
if (strcmp(qa->qa_name, "wsqms") == 0)
|
||||
return(1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
wsqms_iomd_attach(parent, self, aux)
|
||||
struct device *parent;
|
||||
struct device *self;
|
||||
void *aux;
|
||||
{
|
||||
struct wsqms_softc *sc = (void *)self;
|
||||
struct qms_attach_args *qa = aux;
|
||||
|
||||
sc->sc_device = *self;
|
||||
|
||||
sc->sc_iot = qa->qa_iot;
|
||||
sc->sc_ioh = qa->qa_ioh;
|
||||
sc->sc_butioh = qa->qa_ioh_but;
|
||||
sc->sc_irqnum = qa->qa_irq;
|
||||
|
||||
sc->sc_intenable = wsqms_iomd_intenable;
|
||||
|
||||
wsqms_attach(sc, self);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
wsqms_iomd_intenable(sc, enable)
|
||||
struct wsqms_softc *sc;
|
||||
int enable;
|
||||
{
|
||||
if (enable) {
|
||||
sc->sc_ih = intr_claim(sc->sc_irqnum, IPL_TTY, "wsqms", wsqms_intr, sc);
|
||||
if (!sc->sc_ih)
|
||||
panic("%s: Cannot claim interrupt\n", sc->sc_device.dv_xname);
|
||||
} else {
|
||||
if (intr_release(sc->sc_ih) != 0)
|
||||
panic("%s: Cannot release IRQ\n", sc->sc_device.dv_xname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of wsqms_iomd.c */
|
Loading…
Reference in New Issue