diff options
-rw-r--r-- | sbin/wsconsctl/util.c | 5 | ||||
-rw-r--r-- | share/man/man4/man4.sparc/Makefile | 4 | ||||
-rw-r--r-- | share/man/man4/man4.sparc/zs.4 | 11 | ||||
-rw-r--r-- | share/man/man4/man4.sparc64/Makefile | 6 | ||||
-rw-r--r-- | share/man/man4/man4.sparc64/comkbd.4 | 5 | ||||
-rw-r--r-- | share/man/man4/man4.sparc64/comms.4 | 36 | ||||
-rw-r--r-- | share/man/man4/man4.sparc64/ebus.4 | 6 | ||||
-rw-r--r-- | share/man/man4/man4.sparc64/zs.4 | 11 | ||||
-rw-r--r-- | sys/arch/sparc/conf/GENERIC | 7 | ||||
-rw-r--r-- | sys/arch/sparc/conf/SUN4 | 7 | ||||
-rw-r--r-- | sys/arch/sparc/conf/SUN4C | 7 | ||||
-rw-r--r-- | sys/arch/sparc/conf/SUN4M | 7 | ||||
-rw-r--r-- | sys/arch/sparc/conf/files.sparc | 4 | ||||
-rw-r--r-- | sys/arch/sparc64/conf/GENERIC | 6 | ||||
-rw-r--r-- | sys/arch/sparc64/conf/files.sparc64 | 17 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/comms_ebus.c | 379 | ||||
-rw-r--r-- | sys/dev/sun/files.sun | 10 | ||||
-rw-r--r-- | sys/dev/sun/sunms.c | 241 | ||||
-rw-r--r-- | sys/dev/sun/sunmsvar.h | 63 | ||||
-rw-r--r-- | sys/dev/sun/z8530ms.c | 473 | ||||
-rw-r--r-- | sys/dev/wscons/wsconsio.h | 3 |
21 files changed, 1279 insertions, 29 deletions
diff --git a/sbin/wsconsctl/util.c b/sbin/wsconsctl/util.c index 090b897884f..29b418da8d5 100644 --- a/sbin/wsconsctl/util.c +++ b/sbin/wsconsctl/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.41 2009/05/09 20:34:25 mglocker Exp $ */ +/* $OpenBSD: util.c,v 1.42 2009/05/20 18:22:30 miod Exp $ */ /* $NetBSD: util.c,v 1.8 2000/03/14 08:11:53 sato Exp $ */ /*- @@ -82,7 +82,8 @@ static const struct nameint mstype_tab[] = { { WSMOUSE_TYPE_ADB, "adb" }, { WSMOUSE_TYPE_HIL, "hil" }, { WSMOUSE_TYPE_LUNA, "luna" }, - { WSMOUSE_TYPE_DOMAIN, "domain" } + { WSMOUSE_TYPE_DOMAIN, "domain" }, + { WSMOUSE_TYPE_SUN, "sun" } }; static const struct nameint dpytype_tab[] = { diff --git a/share/man/man4/man4.sparc/Makefile b/share/man/man4/man4.sparc/Makefile index 226c9c8099e..7534f5f17ef 100644 --- a/share/man/man4/man4.sparc/Makefile +++ b/share/man/man4/man4.sparc/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.42 2005/03/09 18:58:52 miod Exp $ +# $OpenBSD: Makefile,v 1.43 2009/05/20 18:22:32 miod Exp $ # from: @(#)Makefile 8.2 (Berkeley) 2/16/94 MAN= agten.4 audioamd.4 audiocs.4 autoconf.4 auxreg.4 be.4 bpp.4 bwtwo.4 \ @@ -12,7 +12,7 @@ MLINKS= clock.4 oclock.4 \ le.4 lebuffer.4 le.4 ledma.4 \ mem.4 kmem.4 \ pninek.4 btcham.4 \ - zs.4 zskbd.4 zs.4 zstty.4 + zs.4 zskbd.4 zs.4 zsms.4 zs.4 zstty.4 MANSUBDIR=sparc diff --git a/share/man/man4/man4.sparc/zs.4 b/share/man/man4/man4.sparc/zs.4 index 124643e1774..8d95d87ba68 100644 --- a/share/man/man4/man4.sparc/zs.4 +++ b/share/man/man4/man4.sparc/zs.4 @@ -1,10 +1,10 @@ -.\" $OpenBSD: zs.4,v 1.19 2007/05/31 19:19:56 jmc Exp $ +.\" $OpenBSD: zs.4,v 1.20 2009/05/20 18:22:32 miod Exp $ .\" .\" Copyright (c) 1998, 2002 The OpenBSD Project .\" All rights reserved. .\" .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: May 20 2009 $ .Dt ZS 4 sparc .Os .Sh NAME @@ -23,6 +23,8 @@ .Cd "zstty* at zs?" .Cd "zskbd* at zs?" .Cd "wskbd* at zskbd?" +.Cd "zsms* at zs?" +.Cd "wsmouse* at zsms?" .Cd "option SUNKBD_LAYOUT=XXX" .Cd "option SUNKBD5_LAYOUT=XXX" .Sh DESCRIPTION @@ -41,6 +43,10 @@ The .Nm zskbd devices connect keyboard devices to the generic keyboard driver .Nm wskbd . +The +.Nm zsms +devices connect mice to the generic mouse driver +.Nm wsmouse . The remaining additional .Nm zs interfaces provide RS-423 @@ -154,6 +160,7 @@ option SUNKBD5_LAYOUT="KB_DE" .Xr intro 4 , .Xr tty 4 , .Xr wskbd 4 , +.Xr wsmouse 4 , .Xr wsconsctl 8 .Sh HISTORY The diff --git a/share/man/man4/man4.sparc64/Makefile b/share/man/man4/man4.sparc64/Makefile index 074c3f203af..a46d4360cfe 100644 --- a/share/man/man4/man4.sparc64/Makefile +++ b/share/man/man4/man4.sparc64/Makefile @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile,v 1.72 2009/05/12 18:01:08 kettenis Exp $ +# $OpenBSD: Makefile,v 1.73 2009/05/20 18:22:32 miod Exp $ MAN= agten.4 apio.4 asio.4 audioce.4 audiocs.4 autoconf.4 auxio.4 \ bbc.4 be.4 beeper.4 bpp.4 bwtwo.4 cbus.4 central.4 cgsix.4 cgthree.4 \ - cgtwelve.4 clkbrd.4 clock.4 cmp.4 comkbd.4 core.4 creator.4 \ + cgtwelve.4 clkbrd.4 clock.4 cmp.4 comkbd.4 comms.4 core.4 creator.4 \ ebus.4 ecadc.4 environ.4 esp.4 fhc.4 ifb.4 intro.4 le.4 led.4 \ magma.4 mem.4 mgx.4 openprom.4 \ pcons.4 pmc.4 power.4 ppm.4 prtc.4 psycho.4 pyro.4 qe.4 qec.4 \ @@ -17,7 +17,7 @@ MLINKS= beeper.4 beep.4 \ mem.4 kmem.4 \ sab.4 sabtty.4 \ vcc.4 vcctty.4 \ - zs.4 zstty.4 zs.4 zskbd.4 + zs.4 zskbd.4 zs.4 zsms.4 zs.4 zstty.4 MANSUBDIR=sparc64 .include <bsd.prog.mk> diff --git a/share/man/man4/man4.sparc64/comkbd.4 b/share/man/man4/man4.sparc64/comkbd.4 index f8cb974476c..8637cb0119f 100644 --- a/share/man/man4/man4.sparc64/comkbd.4 +++ b/share/man/man4/man4.sparc64/comkbd.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: comkbd.4,v 1.7 2007/05/31 19:19:57 jmc Exp $ +.\" $OpenBSD: comkbd.4,v 1.8 2009/05/20 18:22:32 miod Exp $ .\" .\" Copyright (c) 2002 Jason L. Wright (jason@thought.net) .\" All rights reserved. @@ -24,7 +24,7 @@ .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: May 20 2009 $ .Dt COMKBD 4 sparc64 .Os .Sh NAME @@ -44,6 +44,7 @@ UART (normally supported by the driver). .Sh SEE ALSO .Xr com 4 , +.Xr comms 4 , .Xr ebus 4 , .Xr intro 4 , .Xr wskbd 4 diff --git a/share/man/man4/man4.sparc64/comms.4 b/share/man/man4/man4.sparc64/comms.4 new file mode 100644 index 00000000000..d0627798985 --- /dev/null +++ b/share/man/man4/man4.sparc64/comms.4 @@ -0,0 +1,36 @@ +.\" $OpenBSD: comms.4,v 1.1 2009/05/20 18:22:32 miod Exp $ +.\" +.\" Copyright (c) 2009 Miodrag Vallat. +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.Dd $Mdocdate: May 20 2009 $ +.Dt COMMS 4 sparc64 +.Os +.Sh NAME +.Nm comms +.Nd serial mouse driver +.Sh SYNOPSIS +.Cd "comms* at ebus?" +.Cd "wsmouse* at comms?" +.Sh DESCRIPTION +The +.Nm +driver provides support for Sun serial mice, connected to +.Nm comkbd +serial keyboards. +.Sh SEE ALSO +.Xr com 4 , +.Xr comkbd 4 , +.Xr ebus 4 , +.Xr intro 4 , +.Xr wsmouse 4 diff --git a/share/man/man4/man4.sparc64/ebus.4 b/share/man/man4/man4.sparc64/ebus.4 index 78ce3a9ba9b..37ba99eef18 100644 --- a/share/man/man4/man4.sparc64/ebus.4 +++ b/share/man/man4/man4.sparc64/ebus.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ebus.4,v 1.18 2009/02/19 11:14:54 jmc Exp $ +.\" $OpenBSD: ebus.4,v 1.19 2009/05/20 18:22:32 miod Exp $ .\" $NetBSD: ebus.4,v 1.3 2002/03/13 21:42:20 wiz Exp $ .\" .\" Copyright (c) 1999 Matthew R. Green @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: February 19 2009 $ +.Dd $Mdocdate: May 20 2009 $ .Dt EBUS 4 sparc64 .Os .Sh NAME @@ -71,6 +71,8 @@ Real-time clock serial communications interface .It Xr comkbd 4 serial keyboard driver +.It Xr comms 4 +serial mouse driver .It Xr led 4 SPARC64 LED driver .It Xr lpt 4 diff --git a/share/man/man4/man4.sparc64/zs.4 b/share/man/man4/man4.sparc64/zs.4 index 42f9bb8d612..7aefe4a75f3 100644 --- a/share/man/man4/man4.sparc64/zs.4 +++ b/share/man/man4/man4.sparc64/zs.4 @@ -1,10 +1,10 @@ -.\" $OpenBSD: zs.4,v 1.14 2007/05/31 19:19:57 jmc Exp $ +.\" $OpenBSD: zs.4,v 1.15 2009/05/20 18:22:32 miod Exp $ .\" .\" Copyright (c) 1998, 2002 The OpenBSD Project .\" All rights reserved. .\" .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: May 20 2009 $ .Dt ZS 4 sparc64 .Os .Sh NAME @@ -16,6 +16,8 @@ .Cd "zstty* at zs?" .Cd "zskbd* at zs?" .Cd "wskbd* at zskbd?" +.Cd "zsms* at zs?" +.Cd "wsmouse* at zsms?" .Cd "option SUNKBD_LAYOUT=XXX" .Cd "option SUNKBD5_LAYOUT=XXX" .Sh DESCRIPTION @@ -34,6 +36,10 @@ The .Nm zskbd devices connect keyboard devices to the generic keyboard driver .Nm wskbd . +The +.Nm zsms +devices connect mice to the generic mouse driver +.Nm wsmouse . The remaining additional .Nm zs interfaces provide RS-423 @@ -149,6 +155,7 @@ option SUNKBD5_LAYOUT="KB_DE" .Xr sbus 4 , .Xr tty 4 , .Xr wskbd 4 , +.Xr wsmouse 4 , .Xr wsconsctl 8 .Sh HISTORY The diff --git a/sys/arch/sparc/conf/GENERIC b/sys/arch/sparc/conf/GENERIC index 61bc21022b1..376630791b2 100644 --- a/sys/arch/sparc/conf/GENERIC +++ b/sys/arch/sparc/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.90 2007/05/29 09:54:03 sobrado Exp $ +# $OpenBSD: GENERIC,v 1.91 2009/05/20 18:22:32 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -32,6 +32,7 @@ option PROCFS # /proc option WSEMUL_SUN # provide sun terminal emulation; required option WSEMUL_NO_VT100 # do not provide vt100 terminal emulation +option WSDISPLAY_COMPAT_RAWKBD # provide raw scancodes; needed for X11 # Generic swap; second partition of root disk or network. config bsd swap generic @@ -108,6 +109,8 @@ zs2 at obio0 addr 0xe0000000 level 12 # sun4/300 zstty* at zs? zskbd* at zs? wskbd* at zskbd? +zsms* at zs? +wsmouse* at zsms? # Magma serial/parallel port devices magma* at sbus? # magma serial cards @@ -371,3 +374,5 @@ fd* at fdc0 # the drive itself # Prestoserve NVRAM #presto* at sbus? + +pseudo-device wsmux 2 # mouse & keyboard multiplexor diff --git a/sys/arch/sparc/conf/SUN4 b/sys/arch/sparc/conf/SUN4 index 5f56dcad435..90177bf8e3e 100644 --- a/sys/arch/sparc/conf/SUN4 +++ b/sys/arch/sparc/conf/SUN4 @@ -1,4 +1,4 @@ -# $OpenBSD: SUN4,v 1.35 2006/12/10 16:14:20 miod Exp $ +# $OpenBSD: SUN4,v 1.36 2009/05/20 18:22:32 miod Exp $ # $NetBSD: GENERIC,v 1.28.2.1 1996/07/02 23:55:22 jtc Exp $ # Machine architecture; required by config(8) @@ -17,6 +17,7 @@ option PROCFS # /proc option WSEMUL_SUN # provide sun terminal emulation; required option WSEMUL_NO_VT100 # do not provide vt100 terminal emulation +option WSDISPLAY_COMPAT_RAWKBD # provide raw scancodes; needed for X11 maxusers 16 # estimated number of users @@ -67,6 +68,8 @@ zs2 at obio0 addr 0xe0000000 level 12 # sun4/300 zstty* at zs? zskbd* at zs? wskbd* at zskbd? +zsms* at zs? +wsmouse* at zsms? # # Note the flags on the esp entries below, that work around @@ -172,3 +175,5 @@ cd* at scsibus? # SCSI CD-ROMs ch* at scsibus? # SCSI changer devices ss* at scsibus? # SCSI scanners uk* at scsibus? # unknown SCSI devices + +pseudo-device wsmux 2 # mouse & keyboard multiplexor diff --git a/sys/arch/sparc/conf/SUN4C b/sys/arch/sparc/conf/SUN4C index dc29de7ebb7..2eab1f04d60 100644 --- a/sys/arch/sparc/conf/SUN4C +++ b/sys/arch/sparc/conf/SUN4C @@ -1,4 +1,4 @@ -# $OpenBSD: SUN4C,v 1.58 2008/01/06 21:15:23 miod Exp $ +# $OpenBSD: SUN4C,v 1.59 2009/05/20 18:22:33 miod Exp $ # $NetBSD: GENERIC,v 1.48 1997/08/23 19:19:01 mjacob Exp $ # Machine architecture; required by config(8) @@ -20,6 +20,7 @@ option PROCFS # /proc option WSEMUL_SUN # provide sun terminal emulation; required option WSEMUL_NO_VT100 # do not provide vt100 terminal emulation +option WSDISPLAY_COMPAT_RAWKBD # provide raw scancodes; needed for X11 maxusers 18 # estimated number of users @@ -56,6 +57,8 @@ zs1 at mainbus0 # sun4c zstty* at zs? zskbd* at zs? wskbd* at zskbd? +zsms* at zs? +wsmouse* at zsms? # Magma serial/parallel port devices magma* at sbus? # magma serial cards @@ -188,3 +191,5 @@ uk* at scsibus? # unknown SCSI devices # Floppy controller and drive found on SPARCstations. fdc0 at mainbus0 # sun4c controller fd* at fdc0 # the drive itself + +pseudo-device wsmux 2 # mouse & keyboard multiplexor diff --git a/sys/arch/sparc/conf/SUN4M b/sys/arch/sparc/conf/SUN4M index 28a6ea0038c..a13f8662a06 100644 --- a/sys/arch/sparc/conf/SUN4M +++ b/sys/arch/sparc/conf/SUN4M @@ -1,4 +1,4 @@ -# $OpenBSD: SUN4M,v 1.73 2007/05/29 09:54:03 sobrado Exp $ +# $OpenBSD: SUN4M,v 1.74 2009/05/20 18:22:33 miod Exp $ # $NetBSD: GENERIC,v 1.28.2.1 1996/07/02 23:55:22 jtc Exp $ # Machine architecture; required by config(8) @@ -22,6 +22,7 @@ option PROCFS # /proc option WSEMUL_SUN # provide sun terminal emulation; required option WSEMUL_NO_VT100 # do not provide vt100 terminal emulation +option WSDISPLAY_COMPAT_RAWKBD # provide raw scancodes; needed for X11 maxusers 32 # estimated number of users @@ -69,6 +70,8 @@ zs1 at obio0 # sun4m zstty* at zs? zskbd* at zs? wskbd* at zskbd? +zsms* at zs? +wsmouse* at zsms? # Magma serial/parallel port devices magma* at sbus? # magma serial cards @@ -243,3 +246,5 @@ uk* at scsibus? # unknown SCSI devices # Floppy controller and drive found on SPARCstations. fdc0 at obio0 # sun4m controller fd* at fdc0 # the drive itself + +pseudo-device wsmux 2 # mouse & keyboard multiplexor diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc index 6aff30d6fe9..659808ec82e 100644 --- a/sys/arch/sparc/conf/files.sparc +++ b/sys/arch/sparc/conf/files.sparc @@ -1,4 +1,4 @@ -# $OpenBSD: files.sparc,v 1.82 2009/04/15 06:54:44 oga Exp $ +# $OpenBSD: files.sparc,v 1.83 2009/05/20 18:22:33 miod Exp $ # $NetBSD: files.sparc,v 1.44 1997/08/31 21:29:16 pk Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 @@ -90,7 +90,7 @@ attach zstty at zs file arch/sparc/dev/z8530tty.c zstty needs-flag file arch/sparc/dev/zs_kgdb.c kgdb -device zskbd: tty, wskbddev, sunkbd +device zskbd: wskbddev, sunkbd attach zskbd at zs file arch/sparc/dev/z8530kbd.c zskbd needs-flag diff --git a/sys/arch/sparc64/conf/GENERIC b/sys/arch/sparc64/conf/GENERIC index 70466853657..f954f7a8b07 100644 --- a/sys/arch/sparc64/conf/GENERIC +++ b/sys/arch/sparc64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.235 2009/05/10 13:33:32 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.236 2009/05/20 18:22:33 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -283,6 +283,8 @@ sabtty* at sab? com* at ebus? comkbd* at ebus? wskbd* at comkbd? mux 1 +comms* at ebus? +wsmouse* at comms? mux 0 # Z8530 based serial ports zs* at sbus? @@ -290,6 +292,8 @@ zs* at fhc? zstty* at zs? zskbd* at zs? wskbd* at zskbd? mux 1 +zsms* at zs? +wsmouse* at zsms? mux 0 # i8042 based serial ports (PS/2 ports) pckbc* at ebus? # controller diff --git a/sys/arch/sparc64/conf/files.sparc64 b/sys/arch/sparc64/conf/files.sparc64 index 6d32e0c4bb4..0d0dd627471 100644 --- a/sys/arch/sparc64/conf/files.sparc64 +++ b/sys/arch/sparc64/conf/files.sparc64 @@ -1,4 +1,4 @@ -# $OpenBSD: files.sparc64,v 1.122 2009/05/16 10:53:06 kettenis Exp $ +# $OpenBSD: files.sparc64,v 1.123 2009/05/20 18:22:33 miod Exp $ # $NetBSD: files.sparc64,v 1.50 2001/08/10 20:53:50 eeh Exp $ # maxpartitions must be first item in files.${ARCH} @@ -80,6 +80,9 @@ include "dev/ata/files.ata" include "dev/pckbc/files.pckbc" include "dev/pcmcia/files.pcmcia" +# Needs to be declared before including files.sun +device zs {[channel = -1]} + # Sun specific files include "../../../dev/sun/files.sun" @@ -240,14 +243,18 @@ file arch/sparc64/dev/com_ebus.c com_ebus attach pckbc at ebus with pckbc_ebus file arch/sparc64/dev/pckbc_ebus.c pckbc_ebus -device comkbd: tty, wskbddev, sunkbd +device comkbd: wskbddev, sunkbd attach comkbd at ebus file arch/sparc64/dev/comkbd_ebus.c comkbd +device comms: wsmousedev, sunms +attach comms at ebus +file arch/sparc64/dev/comms_ebus.c comms + attach lpt at ebus with lpt_ebus file arch/sparc64/dev/lpt_ebus.c lpt_ebus -device zs {[channel = -1]} +#device zs {[channel = -1]} attach zs at sbus with zs_sbus attach zs at fhc with zs_fhc file arch/sparc64/dev/zs.c zs needs-flag @@ -258,9 +265,9 @@ device zstty: tty attach zstty at zs file arch/sparc64/dev/z8530tty.c zstty needs-flag -device zskbd: tty, wskbddev, sunkbd +device zskbd: wskbddev, sunkbd attach zskbd at zs -file arch/sparc64/dev/z8530kbd.c zskbd needs-flag +file arch/sparc64/dev/z8530kbd.c zskbd # Floppy drive device fdc {} diff --git a/sys/arch/sparc64/dev/comms_ebus.c b/sys/arch/sparc64/dev/comms_ebus.c new file mode 100644 index 00000000000..0b9a9e59381 --- /dev/null +++ b/sys/arch/sparc64/dev/comms_ebus.c @@ -0,0 +1,379 @@ +/* $OpenBSD: comms_ebus.c,v 1.1 2009/05/20 18:22:33 miod Exp $ */ + +/* + * Copyright (c) 2009 Miodrag Vallat. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +/* + * Copyright (c) 2002 Jason L. Wright (jason@thought.net) + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + * + * Effort sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F30602-01-2-0537. + * + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/conf.h> +#include <sys/device.h> +#include <sys/ioctl.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/syslog.h> +#include <sys/tty.h> + +#include <machine/bus.h> +#include <machine/autoconf.h> +#include <machine/openfirm.h> + +#include <sparc64/dev/ebusreg.h> +#include <sparc64/dev/ebusvar.h> + +#include <dev/wscons/wsconsio.h> +#include <dev/wscons/wsmousevar.h> + +#include <dev/sun/sunmsvar.h> + +#include <dev/ic/comreg.h> +#include <dev/ic/comvar.h> +#include <dev/ic/ns16550reg.h> +#define com_lcr com_cfcr + +#include <dev/cons.h> + +/* should match com_ebus.c */ +#define BAUD_BASE (1843200) + +#define COMMS_RX_RING 64 + +struct comms_softc { + struct sunms_softc sc_base; + + u_int sc_ier; + + bus_space_tag_t sc_iot; /* bus tag */ + bus_space_handle_t sc_ioh; /* bus handle */ + void *sc_ih, *sc_si; /* interrupt vectors */ + + u_int sc_rxcnt; + u_int8_t sc_rxbuf[COMMS_RX_RING]; + u_int8_t *sc_rxbeg, *sc_rxend, *sc_rxget, *sc_rxput; +}; + +#define COM_WRITE(sc,r,v) \ + bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh, (r), (v)) +#define COM_READ(sc,r) \ + bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, (r)) + +/* + * autoconf glue. + */ + +int comms_match(struct device *, void *, void *); +void comms_attach(struct device *, struct device *, void *); + +const struct cfattach comms_ca = { + sizeof(struct comms_softc), comms_match, comms_attach +}; + +struct cfdriver comms_cd = { + NULL, "comms", DV_DULL +}; + +/* + * wsmouse accessops. + */ + +void comms_disable(void *); +int comms_enable(void *); + +const struct wsmouse_accessops comms_accessops = { + comms_enable, + sunms_ioctl, + comms_disable +}; + +/* + * com glue. + */ + +int comms_hardintr(void *); +int comms_ismouse(int); +void comms_softintr(void *); +void comms_speed_change(void *, uint); + +/* + * autoconf glue. + */ + +static const char *comms_names[] = { + "su", + "su_pnp", + NULL +}; + +int +comms_ismouse(int node) +{ + if (OF_getproplen(node, "mouse") == 0) + return 10; + return 0; +} + +int +comms_match(struct device *parent, void *match, void *aux) +{ + struct ebus_attach_args *ea = aux; + int i; + + for (i = 0; comms_names[i]; i++) + if (strcmp(ea->ea_name, comms_names[i]) == 0) + return comms_ismouse(ea->ea_node); + + if (strcmp(ea->ea_name, "serial") == 0) { + char compat[80]; + + if ((i = OF_getproplen(ea->ea_node, "compatible")) && + OF_getprop(ea->ea_node, "compatible", compat, + sizeof(compat)) == i) { + if (strcmp(compat, "su16550") == 0 || + strcmp(compat, "su") == 0) + return comms_ismouse(ea->ea_node); + } + } + return 0; +} + +void +comms_attach(struct device *parent, struct device *self, void *aux) +{ + struct comms_softc *sc = (void *)self; + struct ebus_attach_args *ea = aux; + + sc->sc_iot = ea->ea_memtag; + + sc->sc_rxget = sc->sc_rxput = sc->sc_rxbeg = sc->sc_rxbuf; + sc->sc_rxend = sc->sc_rxbuf + COMMS_RX_RING; + sc->sc_rxcnt = 0; + + /* we really want IPL_TTY here. */ + sc->sc_si = softintr_establish(IPL_TTY, comms_softintr, sc); + if (sc->sc_si == NULL) { + printf(": can't get soft intr\n"); + return; + } + + /* Use prom address if available, otherwise map it. */ + if (ea->ea_nvaddrs && bus_space_map(ea->ea_memtag, ea->ea_vaddrs[0], 0, + BUS_SPACE_MAP_PROMADDRESS, &sc->sc_ioh) == 0) { + sc->sc_iot = ea->ea_memtag; + } else if (ebus_bus_map(ea->ea_memtag, 0, + EBUS_PADDR_FROM_REG(&ea->ea_regs[0]), + ea->ea_regs[0].size, 0, 0, &sc->sc_ioh) == 0) { + sc->sc_iot = ea->ea_memtag; + } else if (ebus_bus_map(ea->ea_iotag, 0, + EBUS_PADDR_FROM_REG(&ea->ea_regs[0]), + ea->ea_regs[0].size, 0, 0, &sc->sc_ioh) == 0) { + sc->sc_iot = ea->ea_iotag; + } else { + printf(": can't map register space\n"); + return; + } + + sc->sc_ih = bus_intr_establish(sc->sc_iot, + ea->ea_intrs[0], IPL_TTY, 0, comms_hardintr, sc, self->dv_xname); + if (sc->sc_ih == NULL) { + printf(": can't get hard intr\n"); + return; + } + + /* Initialize hardware. */ + sc->sc_ier = 0; + comms_speed_change(sc, INIT_SPEED); + + sc->sc_base.sc_speed_change = comms_speed_change; + + sunms_attach(&sc->sc_base, &comms_accessops); +} + +/* + * wsmouse accessops. + */ + +void +comms_disable(void *v) +{ + struct comms_softc *sc = v; + int s; + + s = spltty(); + sc->sc_ier = 0; + COM_WRITE(sc, com_ier, sc->sc_ier); + splx(s); +} + +int +comms_enable(void *v) +{ + struct comms_softc *sc = v; + int s; + + s = spltty(); + sc->sc_ier = IER_ERXRDY; + COM_WRITE(sc, com_ier, sc->sc_ier); + splx(s); +printf("%s\n", __func__); + + return 0; +} + +/* + * com glue. + */ + +void +comms_softintr(void *v) +{ + struct comms_softc *sc = v; + uint8_t c; + + /* + * If we have a baud rate change pending, do it now. + * This will reset the rx ring, so we can proceed safely. + */ + if (sc->sc_base.sc_state == STATE_RATE_CHANGE) { + sunms_speed_change(&sc->sc_base); + } + + /* + * Copy data from the receive ring, if any, to the event layer. + */ + while (sc->sc_rxcnt) { + c = *sc->sc_rxget; + if (++sc->sc_rxget == sc->sc_rxend) + sc->sc_rxget = sc->sc_rxbeg; + sc->sc_rxcnt--; + sunms_input(&sc->sc_base, c); + } +} + +int +comms_hardintr(void *v) +{ + struct comms_softc *sc = v; + u_int8_t iir, lsr, data; + int needsoft = 0; + + /* Nothing to do */ + iir = COM_READ(sc, com_iir); + if (ISSET(iir, IIR_NOPEND)) + return 0; + + for (;;) { + lsr = COM_READ(sc, com_lsr); + + if (ISSET(lsr, LSR_BI)) { + if (sc->sc_base.sc_state != STATE_RATE_CHANGE && + ++sc->sc_base.sc_brk > 1) { + sc->sc_base.sc_state = STATE_RATE_CHANGE; + needsoft = 1; +#ifdef DEBUG + printf("%s: break detected, changing speed\n", + sc->sc_base.sc_dev.dv_xname); +#endif + } + } + + if (ISSET(lsr, LSR_RXRDY)) { + needsoft = 1; + + do { + data = COM_READ(sc, com_data); + if (sc->sc_base.sc_state != STATE_RATE_CHANGE && + sc->sc_rxcnt != COMMS_RX_RING) { + *sc->sc_rxput = data; + if (++sc->sc_rxput == sc->sc_rxend) + sc->sc_rxput = sc->sc_rxbeg; + sc->sc_rxcnt++; + } + lsr = COM_READ(sc, com_lsr); + } while (ISSET(lsr, LSR_RXRDY)); + } + + iir = COM_READ(sc, com_iir); + if (ISSET(iir, IIR_NOPEND)) + break; + } + + if (needsoft) + softintr_schedule(sc->sc_si); + + return 1; +} + +/* + * Reinitialize the line to a different speed. Invoked at spltty(). + */ +void +comms_speed_change(void *v, uint bps) +{ + struct comms_softc *sc = v; + int ospeed; + + /* + * Eat everything on the line. + */ + while (ISSET(COM_READ(sc, com_lsr), LSR_RXRDY)) + COM_READ(sc, com_data); + + ospeed = comspeed(BAUD_BASE, bps); + + /* disable interrupts while the chip is reprogrammed */ + COM_WRITE(sc, com_ier, 0); + + COM_WRITE(sc, com_lcr, LCR_DLAB); + COM_WRITE(sc, com_dlbl, ospeed); + COM_WRITE(sc, com_dlbh, ospeed >> 8); + /* 8 data bits, no parity, 2 stop bits */ + COM_WRITE(sc, com_lcr, LCR_8BITS | LCR_PNONE | LCR_STOPB); + COM_READ(sc, com_iir); + + COM_WRITE(sc, com_mcr, MCR_IENABLE | MCR_DTR | MCR_RTS); + /* XXX do something about the FIFO? */ + + COM_WRITE(sc, com_ier, sc->sc_ier); +} diff --git a/sys/dev/sun/files.sun b/sys/dev/sun/files.sun index 6cf5f83f36f..e49ef25ca9b 100644 --- a/sys/dev/sun/files.sun +++ b/sys/dev/sun/files.sun @@ -1,4 +1,4 @@ -# $OpenBSD: files.sun,v 1.3 2005/05/14 15:25:20 miod Exp $ +# $OpenBSD: files.sun,v 1.4 2009/05/20 18:22:33 miod Exp $ # $NetBSD: files.sun,v 1.1 1996/05/29 21:54:34 pk Exp $ # # Configuration file for devices found on Sun machines. @@ -6,3 +6,11 @@ define sunkbd file dev/sun/sunkbd.c sunkbd file dev/sun/sunkbdmap.c sunkbd + +define sunms +file dev/sun/sunms.c sunms + +device zsms: wsmousedev, sunms +attach zsms at zs +file dev/sun/z8530ms.c zsms + diff --git a/sys/dev/sun/sunms.c b/sys/dev/sun/sunms.c new file mode 100644 index 00000000000..c0eb3a925f8 --- /dev/null +++ b/sys/dev/sun/sunms.c @@ -0,0 +1,241 @@ +/* $OpenBSD: sunms.c,v 1.1 2009/05/20 18:22:33 miod Exp $ */ + +/* + * Copyright (c) 2002, 2009, Miodrag Vallat + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +/* + * Common Sun mouse handling code. + * + * This code supports 3- and 5- byte Mouse Systems protocols, and speeds of + * 1200, 4800 and 9600 bps. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/conf.h> +#include <sys/device.h> +#include <sys/ioctl.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/time.h> +#include <sys/timeout.h> + +#include <dev/wscons/wsconsio.h> +#include <dev/wscons/wsmousevar.h> + +#include <dev/sun/sunmsvar.h> + +void +sunms_attach(struct sunms_softc *sc, const struct wsmouse_accessops *ao) +{ + struct wsmousedev_attach_args a; + + printf("\n"); + + /* Initialize state machine. */ + sc->sc_state = STATE_PROBING; + sc->sc_bps = INIT_SPEED; + timeout_set(&sc->sc_abort_tmo, sunms_abort_input, sc); + + /* + * Note that it doesn't matter if a long time elapses between this + * and the moment interrupts are enabled, as we either have the + * right speed, and will switch to decode state, or get a break + * or a framing error, causing an immediate speed change. + */ + getmicrotime(&sc->sc_lastbpschange); + + a.accessops = ao; + a.accesscookie = sc; + sc->sc_wsmousedev = config_found(&sc->sc_dev, &a, wsmousedevprint); +} + +int +sunms_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) +{ +#if 0 + struct sunms_softc *sc = v; +#endif + + switch (cmd) { + case WSMOUSEIO_GTYPE: + *(u_int *)data = WSMOUSE_TYPE_SUN; + break; + + default: + return -1; + } + + return 0; +} + +/* + * Reinitialize the line to a different speed. Invoked at spltty(). + */ +void +sunms_speed_change(struct sunms_softc *sc) +{ + uint bps; + + switch (sc->sc_bps) { + default: + case 9600: + bps = 4800; + break; + case 4800: + bps = 1200; + break; + case 1200: + bps = 9600; + break; + } + +#ifdef DEBUG + printf("%s: %d bps\n", sc->sc_dev.dv_xname, bps); +#endif + microtime(&sc->sc_lastbpschange); + + (*sc->sc_speed_change)(sc, bps); + sc->sc_state = STATE_PROBING; + sc->sc_bps = bps; + sc->sc_brk = 0; + timeout_del(&sc->sc_abort_tmo); +} + +/* + * Process actual mouse data. Invoked at spltty(). + */ +void +sunms_input(struct sunms_softc *sc, int c) +{ + struct timeval curtime; + + if (sc->sc_wsmousedev == NULL) + return; /* why bother */ + + if (sc->sc_state == STATE_RATE_CHANGE) + return; /* not ready yet */ + + /* + * If we have changed speed recently, ignore data for a few + * milliseconds to make sure that either we'll detect the speed + * is still not correct, or discard potential noise resulting + * from the speed change. + */ + if (sc->sc_state == STATE_PROBING) { + microtime(&curtime); + timersub(&curtime, &sc->sc_lastbpschange, &curtime); + if (curtime.tv_sec != 0 || + curtime.tv_usec >= 200 * 1000) { + sc->sc_state = STATE_DECODING; + sc->sc_byteno = -1; + } else + return; + } + + /* + * The Sun mice use either 3 byte or 5 byte packets. The + * first byte of each packet has the topmost bit set; + * however motion parts of the packet may have the topmost + * bit set too; so we only check for a first byte pattern + * when we are not currently processing a packet. + */ + if (sc->sc_byteno < 0) { + if (ISSET(c, 0x80) && !ISSET(c, 0x30)) + sc->sc_byteno = 0; + else + return; + } + + switch (sc->sc_byteno) { + case 0: + /* + * First packet has bit 7 set; bits 0-2 are button states, + * and bit 3 is set if it is a short (3 byte) packet. + * On the Tadpole SPARCbook, mice connected to the external + * connector will also have bit 6 set to allow it to be + * differenciated from the onboard pointer. + */ + sc->sc_pktlen = ISSET(c, 0x08) ? 3 : 5; + sc->sc_mb = 0; + if (!ISSET(c, 1 << 2)) /* left button */ + sc->sc_mb |= 1 << 0; + if (!ISSET(c, 1 << 1)) /* middle button */ + sc->sc_mb |= 1 << 1; + if (!ISSET(c, 1 << 0)) /* right button */ + sc->sc_mb |= 1 << 2; + sc->sc_byteno++; + + /* + * In case we do not receive the whole packet, we need + * to be able to reset sc_byteno. + * + * At 1200bps 8N2, a five byte packet will span 50 bits + * and thus will transmit in 1/24 second, or about 42ms. + * + * A reset timeout of 100ms will be more than enough. + */ + timeout_add_msec(&sc->sc_abort_tmo, 100); + + break; + case 1: + case 3: + /* + * Following bytes contain signed 7 bit X, then Y deltas. + * Short packets only have one set of deltas (and are + * thus usually used on 4800 baud mice). + */ + sc->sc_dx += (int8_t)c; + sc->sc_byteno++; + break; + case 2: + case 4: + sc->sc_dy += (int8_t)c; + sc->sc_byteno++; + break; + } + + if (sc->sc_byteno == sc->sc_pktlen) { + timeout_del(&sc->sc_abort_tmo); + sc->sc_byteno = -1; + wsmouse_input(sc->sc_wsmousedev, sc->sc_mb, + sc->sc_dx, sc->sc_dy, 0, 0, WSMOUSE_INPUT_DELTA); + sc->sc_dx = sc->sc_dy = 0; + } +} + +void +sunms_abort_input(void *v) +{ + struct sunms_softc *sc = v; + int s; + +#ifdef DEBUG + printf("aborting incomplete packet\n"); +#endif + s = spltty(); + sc->sc_byteno = -1; + splx(s); +} diff --git a/sys/dev/sun/sunmsvar.h b/sys/dev/sun/sunmsvar.h new file mode 100644 index 00000000000..e845cc7967e --- /dev/null +++ b/sys/dev/sun/sunmsvar.h @@ -0,0 +1,63 @@ +/* $OpenBSD: sunmsvar.h,v 1.1 2009/05/20 18:22:33 miod Exp $ */ + +/* + * Copyright (c) 2002, 2009, Miodrag Vallat + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +struct sunms_softc { + struct device sc_dev; + + /* + * State of input translator + */ + uint sc_state; /* current FSM state */ +#define STATE_RATE_CHANGE 0 /* baud rate change pending */ +#define STATE_PROBING 1 /* checking packets after speed change */ +#define STATE_DECODING 2 /* normal operation */ + uint sc_brk; /* breaks in a row */ + + int sc_pktlen; /* packet length */ + int sc_byteno; /* current packet position */ + int sc_mb; /* mouse button state */ + int sc_dx; /* delta-x */ + int sc_dy; /* delta-y */ + + uint sc_bps; /* current link speed */ + struct timeval sc_lastbpschange; + + struct timeout sc_abort_tmo; + + struct device *sc_wsmousedev; + + void (*sc_speed_change)(void *, uint); +}; + +#define INIT_SPEED 9600 + +void sunms_attach(struct sunms_softc *, const struct wsmouse_accessops *); +int sunms_ioctl(void *, u_long, caddr_t, int, struct proc *); + +void sunms_abort_input(void *); +void sunms_input(struct sunms_softc *, int c); +void sunms_speed_change(struct sunms_softc *); diff --git a/sys/dev/sun/z8530ms.c b/sys/dev/sun/z8530ms.c new file mode 100644 index 00000000000..c3e23c9d92d --- /dev/null +++ b/sys/dev/sun/z8530ms.c @@ -0,0 +1,473 @@ +/* $OpenBSD: z8530ms.c,v 1.1 2009/05/20 18:22:33 miod Exp $ */ +/* $NetBSD: ms.c,v 1.12 1997/07/17 01:17:47 jtk Exp $ */ + +/* + * Copyright (c) 2002, 2009, Miodrag Vallat + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + * + * + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * 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 University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. + * + * @(#)ms.c 8.1 (Berkeley) 6/11/93 + */ + +/* + * Zilog Z8530 Dual UART driver (mouse interface) + * + * This is the "slave" driver that will be attached to + * the "zsc" driver for a Sun mouse. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/conf.h> +#include <sys/device.h> +#include <sys/ioctl.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/syslog.h> + +#ifndef __sparc64__ /* until zs driver is unified... */ +#include <sparc/dev/z8530reg.h> +#else +#include <sparc64/dev/z8530reg.h> +#endif +#include <machine/z8530var.h> + +#include <dev/wscons/wsmousevar.h> +#include <dev/sun/sunmsvar.h> + +/* + * How many input characters we can buffer. + * Note: must be a power of two! + */ +#define MS_RX_RING_SIZE 256 +#define MS_RX_RING_MASK (MS_RX_RING_SIZE-1) + +struct zsms_softc { + struct sunms_softc sc_base; + struct zs_chanstate *sc_cs; + + /* Flags to communicate with zsms_softint() */ + volatile int sc_intr_flags; +#define INTR_RX_OVERRUN 0x01 +#define INTR_TX_EMPTY 0x02 +#define INTR_ST_CHECK 0x04 +#define INTR_BPS_CHANGE 0x08 + + /* + * The receive ring buffer. + */ + uint sc_rbget; /* ring buffer `get' index */ + volatile uint sc_rbput; /* ring buffer `put' index */ + uint16_t sc_rbuf[MS_RX_RING_SIZE]; /* rr1, data pairs */ +}; + +/* + * autoconf glue. + */ + +int zsms_match(struct device *, void *, void *); +void zsms_attach(struct device *, struct device *, void *); + +const struct cfattach zsms_ca = { + sizeof(struct zsms_softc), zsms_match, zsms_attach +}; + +struct cfdriver zsms_cd = { + NULL, "zsms", DV_DULL +}; + +/* + * wsmouse accessops. + */ + +void zsms_disable(void *); +int zsms_enable(void *); + +const struct wsmouse_accessops zsms_accessops = { + zsms_enable, + sunms_ioctl, + zsms_disable +}; + +/* + * zs glue. + */ + +void zsms_rxint(struct zs_chanstate *); +void zsms_softint(struct zs_chanstate *); +void zsms_stint(struct zs_chanstate *, int); +void zsms_txint(struct zs_chanstate *); + +struct zsops zsops_ms = { + zsms_rxint, /* receive char available */ + zsms_stint, /* external/status */ + zsms_txint, /* xmit buffer empty */ + zsms_softint /* process software interrupt */ +}; + +void zsms_speed_change(void *, uint); + +/* + * autoconf glue. + */ + +int +zsms_match(struct device *parent, void *vcf, void *aux) +{ + struct cfdata *cf = vcf; + struct zsc_attach_args *args = aux; + int rc; + + /* If we're not looking for a mouse, just exit */ + if (strcmp(args->type, "mouse") != 0) + return 0; + + rc = 10; + + /* Exact match is better than wildcard. */ + if (cf->cf_loc[ZSCCF_CHANNEL] == args->channel) + rc += 2; + + /* This driver accepts wildcard. */ + if (cf->cf_loc[ZSCCF_CHANNEL] == ZSCCF_CHANNEL_DEFAULT) + rc += 1; + + return rc; +} + +void +zsms_attach(struct device *parent, struct device *self, void *aux) +{ + struct zsc_softc *zsc = (struct zsc_softc *)parent; + struct zsms_softc *sc = (struct zsms_softc *)self; + struct zsc_attach_args *args = aux; + struct zs_chanstate *cs; + int channel; + int s; + + channel = args->channel; +#ifndef __sparc64__ /* until driver is unified... */ + cs = &zsc->zsc_cs[channel]; +#else + cs = zsc->zsc_cs[channel]; +#endif + cs->cs_private = sc; + cs->cs_ops = &zsops_ms; + sc->sc_cs = cs; + + /* Initialize hardware. */ + s = splzs(); + zs_write_reg(cs, 9, channel == 0 ? ZSWR9_A_RESET : ZSWR9_B_RESET); + /* disable interrupts until the mouse is enabled */ + CLR(cs->cs_preg[1], ZSWR1_RIE | ZSWR1_SIE | ZSWR1_TIE); + /* 8 data bits is already our default */ + /* no parity, 2 stop bits */ + CLR(cs->cs_preg[4], ZSWR4_SBMASK | ZSWR4_PARMASK); + SET(cs->cs_preg[4], ZSWR4_TWOSB); + (void)zs_set_speed(cs, INIT_SPEED); + zs_loadchannelregs(cs); + splx(s); + + sc->sc_base.sc_speed_change = zsms_speed_change; + + sunms_attach(&sc->sc_base, &zsms_accessops); +} + +/* + * wsmouse accessops. + */ + +void +zsms_disable(void *v) +{ + struct zsms_softc *sc = v; + struct zs_chanstate *cs = sc->sc_cs; + int s; + + s = splzs(); + /* disable RX and status change interrupts */ + CLR(cs->cs_preg[1], ZSWR1_RIE | ZSWR1_SIE); + zs_loadchannelregs(cs); + splx(s); +} + +int +zsms_enable(void *v) +{ + struct zsms_softc *sc = v; + struct zs_chanstate *cs = sc->sc_cs; + int s; + + s = splzs(); + /* enable RX and status change interrupts */ + SET(cs->cs_preg[1], ZSWR1_RIE | ZSWR1_SIE); + zs_loadchannelregs(cs); + splx(s); + + return 0; +} + +/* + * zs glue. + */ + +void +zsms_rxint(struct zs_chanstate *cs) +{ + struct zsms_softc *sc = cs->cs_private; + int put, put_next; + u_char rr0, rr1, c; + + put = sc->sc_rbput; + + for (;;) { + /* + * First read the status, because reading the received char + * destroys the status of this char. + */ + rr1 = zs_read_reg(cs, 1); + c = zs_read_data(cs); + + /* + * Note that we do not try to change speed upon encountering + * framing errors, as this is not as reliable as breaks. + */ + if (ISSET(rr1, ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) { + /* Clear the receive error. */ + zs_write_csr(cs, ZSWR0_RESET_ERRORS); + } + + if (sc->sc_base.sc_state != STATE_RATE_CHANGE) { + sc->sc_rbuf[put] = (c << 8) | rr1; + put_next = (put + 1) & MS_RX_RING_MASK; + + /* Would overrun if increment makes (put==get). */ + if (put_next == sc->sc_rbget) { + sc->sc_intr_flags |= INTR_RX_OVERRUN; + break; + } else { + /* OK, really increment. */ + put = put_next; + } + } + + rr0 = zs_read_csr(cs); + if (!ISSET(rr0, ZSRR0_RX_READY)) + break; + } + + /* Done reading. */ + sc->sc_rbput = put; + + cs->cs_softreq = 1; +} + +void +zsms_txint(struct zs_chanstate *cs) +{ + /* + * This function should never be invoked as we don't accept TX + * interrupts. If someone alters our configuration behind our + * back, just disable TX interrupts again. + */ + zs_write_csr(cs, ZSWR0_RESET_TXINT); + + /* disable tx interrupts */ + CLR(cs->cs_preg[1], ZSWR1_TIE); + zs_loadchannelregs(cs); +} + +void +zsms_stint(struct zs_chanstate *cs, int force) +{ + struct zsms_softc *sc = cs->cs_private; + uint8_t rr0, delta; + + rr0 = zs_read_csr(cs); + zs_write_csr(cs, ZSWR0_RESET_STATUS); + + /* + * A break can occur if the speed is not correct. + * However, we do not change speed until we get the second + * break, for switching speed when the mouse is unplugged + * will trigger a break and thus we'd loop changing speeds + * until the mouse is plugged again. + */ + if (!force && ISSET(rr0, ZSRR0_BREAK)) { + if (sc->sc_base.sc_state != STATE_RATE_CHANGE && + ++sc->sc_base.sc_brk > 1) { + sc->sc_intr_flags |= INTR_BPS_CHANGE; + sc->sc_base.sc_state = STATE_RATE_CHANGE; + cs->cs_softreq = 1; +#ifdef DEBUG + printf("%s: break detected, changing speed\n", + sc->sc_base.sc_dev.dv_xname); +#endif + } + } + + if (!force) + delta = rr0 ^ cs->cs_rr0; + else + delta = cs->cs_rr0_mask; + cs->cs_rr0 = rr0; + + if (ISSET(delta, cs->cs_rr0_mask)) { + SET(cs->cs_rr0_delta, delta); + + sc->sc_intr_flags |= INTR_ST_CHECK; + cs->cs_softreq = 1; + } +} + +void +zsms_softint(struct zs_chanstate *cs) +{ + struct zsms_softc *sc; + int get, c, s, s2; + int intr_flags; + u_short ring_data; + + sc = cs->cs_private; + + /* Atomically get and clear flags. */ + s = spltty(); + s2 = splzs(); + intr_flags = sc->sc_intr_flags; + sc->sc_intr_flags = 0; + /* Now lower to spltty for the rest. */ + splx(s2); + + /* + * If we have a baud rate change pending, do it now. + * This will reset the rx ring, so we can proceed safely. + */ + if (ISSET(intr_flags, INTR_BPS_CHANGE)) { + CLR(intr_flags, INTR_RX_OVERRUN); + sunms_speed_change(&sc->sc_base); + splx(s); + } + + /* + * Copy data from the receive ring, if any, to the event layer. + */ + get = sc->sc_rbget; + while (get != sc->sc_rbput) { + ring_data = sc->sc_rbuf[get]; + get = (get + 1) & MS_RX_RING_MASK; + + /* low byte of ring_data is rr1 */ + c = (ring_data >> 8) & 0xff; + + if (ring_data & ZSRR1_DO) + SET(intr_flags, INTR_RX_OVERRUN); + + /* Pass this up to the "middle" layer. */ + sunms_input(&sc->sc_base, c); + } + if (ISSET(intr_flags, INTR_RX_OVERRUN)) + log(LOG_ERR, "%s: input overrun\n", + sc->sc_base.sc_dev.dv_xname); + sc->sc_rbget = get; + + /* + * Status line change. Not expected except for break conditions. + */ + if (ISSET(intr_flags, INTR_ST_CHECK)) { + cs->cs_rr0_delta = 0; + } + + splx(s); +} + +/* + * Reinitialize the line to a different speed. Invoked at spltty(). + */ +void +zsms_speed_change(void *v, uint bps) +{ + struct zsms_softc *sc = v; + struct zs_chanstate *cs = sc->sc_cs; + uint8_t rr0; + int s; + + s = splzs(); + + /* + * Eat everything on the line. + */ + for (;;) { + rr0 = zs_read_csr(cs); + if (!ISSET(rr0, ZSRR0_RX_READY)) + break; + (void)zs_read_data(cs); + } + + (void)zs_set_speed(cs, sc->sc_base.sc_bps); + zs_loadchannelregs(cs); + zsms_stint(cs, 1); + + sc->sc_rbget = sc->sc_rbput = 0; + + splx(s); +} diff --git a/sys/dev/wscons/wsconsio.h b/sys/dev/wscons/wsconsio.h index 1f7b473cbd8..a553c00fe0c 100644 --- a/sys/dev/wscons/wsconsio.h +++ b/sys/dev/wscons/wsconsio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsconsio.h,v 1.51 2009/05/09 19:23:07 mglocker Exp $ */ +/* $OpenBSD: wsconsio.h,v 1.52 2009/05/20 18:22:33 miod Exp $ */ /* $NetBSD: wsconsio.h,v 1.74 2005/04/28 07:15:44 martin Exp $ */ /* @@ -205,6 +205,7 @@ struct wskbd_map_data { #define WSMOUSE_TYPE_LUNA 11 /* OMRON Luna */ #define WSMOUSE_TYPE_DOMAIN 12 /* Apollo Domain */ #define WSMOUSE_TYPE_BLUETOOTH 13 /* Bluetooth mouse */ +#define WSMOUSE_TYPE_SUN 14 /* SUN serial mouse */ /* Set resolution. Not applicable to all mouse types. */ #define WSMOUSEIO_SRES _IOW('W', 33, u_int) |