Add a primitive driver for the PC-ish Programmable Peripheral Interface
and PC-ish keyboard controller. (Actually, on alphas, the built-in PPI (in the SIO) appears to be a lobotomized version of the original, but i'd not call that a bad thing.) This driver should eventually handle all speaker tone requests and keyboard commands, but for now it just maps the relevant ports and passes them on to the keyboard and mouse drivers, which are now its children (rather than children of ISA).
This commit is contained in:
parent
8c007e0e48
commit
d35047f37b
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pckbd.c,v 1.12 1996/11/19 05:23:07 cgd Exp $ */
|
||||
/* $NetBSD: pckbd.c,v 1.13 1996/11/25 03:26:33 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
|
||||
|
@ -61,10 +61,22 @@
|
|||
#include <alpha/isa/spkrreg.h>
|
||||
#include <alpha/isa/timerreg.h>
|
||||
#include <machine/wsconsio.h>
|
||||
#include <alpha/isa/pcppivar.h>
|
||||
|
||||
#include <alpha/wscons/wsconsvar.h>
|
||||
#include "wscons.h"
|
||||
|
||||
#undef KBDATAP
|
||||
#undef KBOUTP
|
||||
#undef KBSTATP
|
||||
#undef KBCMDP
|
||||
#undef PITAUX_PORT
|
||||
#define KBDATAP 0x0 /* kbd data port (I) */
|
||||
#define KBOUTP 0x0 /* kbd data port (O) */
|
||||
#define KBSTATP 0x4 /* kbd controller status port (I) */
|
||||
#define KBCMDP 0x4 /* kbd controller port (O) */
|
||||
#define PITAUX_PORT 0x1 /* port B of PPI */
|
||||
|
||||
static volatile u_char ack, nak; /* Don't ask. */
|
||||
static u_char async, kernel, polling; /* Really, you don't want to know. */
|
||||
static u_char lock_state = 0x00, /* all off */
|
||||
|
@ -75,12 +87,8 @@ static u_char lock_state = 0x00, /* all off */
|
|||
bus_space_tag_t pckbd_iot;
|
||||
isa_chipset_tag_t pckbd_ic;
|
||||
|
||||
bus_space_handle_t pckbd_data_ioh;
|
||||
#define pckbd_out_ioh pckbd_data_ioh
|
||||
bus_space_handle_t pckbd_status_ioh;
|
||||
#define pckbd_cmd_ioh pckbd_status_ioh
|
||||
bus_space_handle_t pckbd_ioh;
|
||||
bus_space_handle_t pckbd_timer_ioh;
|
||||
bus_space_handle_t pckbd_pitaux_ioh;
|
||||
bus_space_handle_t pckbd_delay_ioh;
|
||||
|
||||
struct pckbd_softc {
|
||||
|
@ -159,7 +167,7 @@ kbd_wait_output()
|
|||
u_int i;
|
||||
|
||||
for (i = 100000; i; i--)
|
||||
if ((bus_space_read_1(pckbd_iot, pckbd_status_ioh, 0) & KBS_IBF)
|
||||
if ((bus_space_read_1(pckbd_iot, pckbd_ioh, KBSTATP) & KBS_IBF)
|
||||
== 0) {
|
||||
KBD_DELAY;
|
||||
return 1;
|
||||
|
@ -173,7 +181,7 @@ kbd_wait_input()
|
|||
u_int i;
|
||||
|
||||
for (i = 100000; i; i--)
|
||||
if ((bus_space_read_1(pckbd_iot, pckbd_status_ioh, 0) & KBS_DIB)
|
||||
if ((bus_space_read_1(pckbd_iot, pckbd_ioh, KBSTATP) & KBS_DIB)
|
||||
!= 0) {
|
||||
KBD_DELAY;
|
||||
return 1;
|
||||
|
@ -187,11 +195,11 @@ kbd_flush_input()
|
|||
u_int i;
|
||||
|
||||
for (i = 10; i; i--) {
|
||||
if ((bus_space_read_1(pckbd_iot, pckbd_status_ioh, 0) & KBS_DIB)
|
||||
if ((bus_space_read_1(pckbd_iot, pckbd_ioh, KBSTATP) & KBS_DIB)
|
||||
== 0)
|
||||
return;
|
||||
KBD_DELAY;
|
||||
(void) bus_space_read_1(pckbd_iot, pckbd_data_ioh, 0);
|
||||
(void) bus_space_read_1(pckbd_iot, pckbd_ioh, KBDATAP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,10 +213,10 @@ kbc_get8042cmd()
|
|||
|
||||
if (!kbd_wait_output())
|
||||
return -1;
|
||||
bus_space_write_1(pckbd_iot, pckbd_cmd_ioh, 0, K_RDCMDBYTE);
|
||||
bus_space_write_1(pckbd_iot, pckbd_ioh, KBCMDP, K_RDCMDBYTE);
|
||||
if (!kbd_wait_input())
|
||||
return -1;
|
||||
return bus_space_read_1(pckbd_iot, pckbd_data_ioh, 0);
|
||||
return bus_space_read_1(pckbd_iot, pckbd_ioh, KBDATAP);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -222,10 +230,10 @@ kbc_put8042cmd(val)
|
|||
|
||||
if (!kbd_wait_output())
|
||||
return 0;
|
||||
bus_space_write_1(pckbd_iot, pckbd_cmd_ioh, 0, K_LDCMDBYTE);
|
||||
bus_space_write_1(pckbd_iot, pckbd_ioh, KBCMDP, K_LDCMDBYTE);
|
||||
if (!kbd_wait_output())
|
||||
return 0;
|
||||
bus_space_write_1(pckbd_iot, pckbd_out_ioh, 0, val);
|
||||
bus_space_write_1(pckbd_iot, pckbd_ioh, KBOUTP, val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -244,16 +252,16 @@ kbd_cmd(val, polling)
|
|||
if (!kbd_wait_output())
|
||||
return 0;
|
||||
ack = nak = 0;
|
||||
bus_space_write_1(pckbd_iot, pckbd_out_ioh, 0, val);
|
||||
bus_space_write_1(pckbd_iot, pckbd_ioh, KBOUTP, val);
|
||||
if (polling)
|
||||
for (i = 100000; i; i--) {
|
||||
if (bus_space_read_1(pckbd_iot,
|
||||
pckbd_status_ioh, 0) & KBS_DIB) {
|
||||
pckbd_ioh, KBSTATP) & KBS_DIB) {
|
||||
register u_char c;
|
||||
|
||||
KBD_DELAY;
|
||||
c = bus_space_read_1(pckbd_iot,
|
||||
pckbd_data_ioh, 0);
|
||||
pckbd_ioh, KBDATAP);
|
||||
if (c == KBR_ACK || c == KBR_ECHO) {
|
||||
ack = 1;
|
||||
return 1;
|
||||
|
@ -271,7 +279,7 @@ kbd_cmd(val, polling)
|
|||
else
|
||||
for (i = 100000; i; i--) {
|
||||
(void) bus_space_read_1(pckbd_iot,
|
||||
pckbd_status_ioh, 0);
|
||||
pckbd_ioh, KBSTATP);
|
||||
if (ack)
|
||||
return 1;
|
||||
if (nak)
|
||||
|
@ -291,26 +299,27 @@ pckbdprobe(parent, match, aux)
|
|||
struct device *parent;
|
||||
void *match, *aux;
|
||||
{
|
||||
struct isa_attach_args *ia = aux;
|
||||
u_int i;
|
||||
struct pcppi_attach_args *pa = aux;
|
||||
u_int i, rv;
|
||||
|
||||
pckbd_iot = ia->ia_iot;
|
||||
pckbd_ic = ia->ia_ic;
|
||||
|
||||
if (bus_space_map(pckbd_iot, KBDATAP, 1, 0, &pckbd_data_ioh) ||
|
||||
bus_space_map(pckbd_iot, KBSTATP, 1, 0, &pckbd_status_ioh) ||
|
||||
bus_space_map(pckbd_iot, IO_TIMER1, 4, 0, &pckbd_timer_ioh) ||
|
||||
bus_space_map(pckbd_iot, PITAUX_PORT, 1, 0, &pckbd_pitaux_ioh))
|
||||
if (pa->pa_slot != PCPPI_KBD_SLOT)
|
||||
return 0;
|
||||
|
||||
pckbd_delay_ioh = ia->ia_delaybah;
|
||||
rv = 0;
|
||||
|
||||
pckbd_iot = pa->pa_iot;
|
||||
pckbd_ic = pa->pa_ic;
|
||||
pckbd_ioh = pa->pa_ioh;
|
||||
pckbd_timer_ioh = pa->pa_pit_ioh;
|
||||
pckbd_delay_ioh = pa->pa_delaybah;
|
||||
|
||||
/* Enable interrupts and keyboard, etc. */
|
||||
if (!kbc_put8042cmd(CMDBYTE)) {
|
||||
printf("pcprobe: command error\n");
|
||||
return 0;
|
||||
goto lose;
|
||||
}
|
||||
|
||||
rv = 1; /* from here one out, we let it succeed */
|
||||
#if 1
|
||||
/* Flush any garbage. */
|
||||
kbd_flush_input();
|
||||
|
@ -320,12 +329,12 @@ pckbdprobe(parent, match, aux)
|
|||
goto lose;
|
||||
}
|
||||
for (i = 600000; i; i--)
|
||||
if ((bus_space_read_1(pckbd_iot, pckbd_status_ioh, 0) & KBS_DIB)
|
||||
if ((bus_space_read_1(pckbd_iot, pckbd_ioh, KBSTATP) & KBS_DIB)
|
||||
!= 0) {
|
||||
KBD_DELAY;
|
||||
break;
|
||||
}
|
||||
if (i == 0 || bus_space_read_1(pckbd_iot, pckbd_data_ioh, 0)
|
||||
if (i == 0 || bus_space_read_1(pckbd_iot, pckbd_ioh, KBDATAP)
|
||||
!= KBR_RSTDONE) {
|
||||
printf("pcprobe: reset error %d\n", 2);
|
||||
goto lose;
|
||||
|
@ -376,9 +385,7 @@ lose:
|
|||
*/
|
||||
#endif
|
||||
|
||||
ia->ia_iobase = 16;
|
||||
ia->ia_iosize = 0;
|
||||
return 1;
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -387,21 +394,16 @@ pckbdattach(parent, self, aux)
|
|||
void *aux;
|
||||
{
|
||||
struct pckbd_softc *sc = (void *)self;
|
||||
struct isa_attach_args *ia = aux;
|
||||
struct pcppi_attach_args *pa = aux;
|
||||
|
||||
pckbd_iot = ia->ia_iot;
|
||||
pckbd_ic = ia->ia_ic;
|
||||
pckbd_iot = pa->pa_iot;
|
||||
pckbd_ic = pa->pa_ic;
|
||||
pckbd_ioh = pa->pa_ioh;
|
||||
pckbd_timer_ioh = pa->pa_pit_ioh;
|
||||
pckbd_delay_ioh = pa->pa_delaybah;
|
||||
|
||||
if (bus_space_map(pckbd_iot, KBDATAP, 1, 0, &pckbd_data_ioh) ||
|
||||
bus_space_map(pckbd_iot, KBSTATP, 1, 0, &pckbd_status_ioh) ||
|
||||
bus_space_map(pckbd_iot, IO_TIMER1, 4, 0, &pckbd_timer_ioh) ||
|
||||
bus_space_map(pckbd_iot, PITAUX_PORT, 1, 0, &pckbd_pitaux_ioh))
|
||||
panic("pckbdattach couldn't map");
|
||||
|
||||
pckbd_delay_ioh = ia->ia_delaybah;
|
||||
|
||||
sc->sc_ih = isa_intr_establish(pckbd_ic, ia->ia_irq, IST_EDGE,
|
||||
IPL_TTY, pckbdintr, sc);
|
||||
sc->sc_ih = isa_intr_establish(pckbd_ic, 1, IST_EDGE, IPL_TTY,
|
||||
pckbdintr, sc);
|
||||
|
||||
sc->sc_bellactive = sc->sc_bellpitch = 0;
|
||||
|
||||
|
@ -425,13 +427,13 @@ pckbdintr(arg)
|
|||
u_char data;
|
||||
static u_char last;
|
||||
|
||||
if ((bus_space_read_1(pckbd_iot, pckbd_status_ioh, 0) & KBS_DIB) == 0)
|
||||
if ((bus_space_read_1(pckbd_iot, pckbd_ioh, KBSTATP) & KBS_DIB) == 0)
|
||||
return 0;
|
||||
if (polling)
|
||||
return 1;
|
||||
do {
|
||||
KBD_DELAY;
|
||||
data = bus_space_read_1(pckbd_iot, pckbd_data_ioh, 0);
|
||||
data = bus_space_read_1(pckbd_iot, pckbd_ioh, KBDATAP);
|
||||
|
||||
switch (data) {
|
||||
case KBR_ACK:
|
||||
|
@ -450,7 +452,7 @@ pckbdintr(arg)
|
|||
#endif
|
||||
break;
|
||||
}
|
||||
} while (bus_space_read_1(pckbd_iot, pckbd_status_ioh, 0) & KBS_DIB);
|
||||
} while (bus_space_read_1(pckbd_iot, pckbd_ioh, KBSTATP) & KBS_DIB);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -861,12 +863,12 @@ pckbd_cngetc(dev)
|
|||
|
||||
do {
|
||||
/* wait for byte */
|
||||
while ((bus_space_read_1(pckbd_iot, pckbd_status_ioh, 0) & KBS_DIB)
|
||||
while ((bus_space_read_1(pckbd_iot, pckbd_ioh, KBSTATP) & KBS_DIB)
|
||||
== 0)
|
||||
KBD_DELAY;
|
||||
KBD_DELAY;
|
||||
|
||||
data = bus_space_read_1(pckbd_iot, pckbd_data_ioh, 0);
|
||||
data = bus_space_read_1(pckbd_iot, pckbd_ioh, KBDATAP);
|
||||
|
||||
if (data == KBR_ACK) {
|
||||
ack = 1;
|
||||
|
@ -945,8 +947,8 @@ pckbd_bell(dev, wbd)
|
|||
bus_space_write_1(pckbd_iot, pckbd_timer_ioh, TIMER_CNTR2,
|
||||
TIMER_DIV(pitch) / 256);
|
||||
/* enable speaker */
|
||||
bus_space_write_1(pckbd_iot, pckbd_pitaux_ioh, 0,
|
||||
bus_space_read_1(pckbd_iot, pckbd_pitaux_ioh, 0) |
|
||||
bus_space_write_1(pckbd_iot, pckbd_ioh, PITAUX_PORT,
|
||||
bus_space_read_1(pckbd_iot, pckbd_ioh, PITAUX_PORT) |
|
||||
PIT_SPKR);
|
||||
splx(s);
|
||||
}
|
||||
|
@ -964,8 +966,8 @@ pckbd_bell_stop(arg)
|
|||
|
||||
/* disable bell */
|
||||
s = splhigh();
|
||||
bus_space_write_1(pckbd_iot, pckbd_pitaux_ioh, 0,
|
||||
bus_space_read_1(pckbd_iot, pckbd_pitaux_ioh, 0) & ~PIT_SPKR);
|
||||
bus_space_write_1(pckbd_iot, pckbd_ioh, PITAUX_PORT,
|
||||
bus_space_read_1(pckbd_iot, pckbd_ioh, PITAUX_PORT) & ~PIT_SPKR);
|
||||
sc->sc_bellactive = 0;
|
||||
splx(s);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,183 @@
|
|||
/* $NetBSD: pcppi.c,v 1.1 1996/11/25 03:26:36 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/malloc.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/isa/isareg.h>
|
||||
#include <dev/isa/isavar.h>
|
||||
#include <alpha/isa/pcppivar.h>
|
||||
|
||||
struct pcppi_softc {
|
||||
struct device sc_dv;
|
||||
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_pit1_ioh, sc_ppi_ioh;
|
||||
};
|
||||
|
||||
int pcppi_match __P((struct device *, void *, void *));
|
||||
void pcppi_attach __P((struct device *, struct device *, void *));
|
||||
|
||||
struct cfattach pcppi_ca = {
|
||||
sizeof(struct pcppi_softc), pcppi_match, pcppi_attach,
|
||||
};
|
||||
|
||||
struct cfdriver pcppi_cd = {
|
||||
NULL, "pcppi", DV_DULL,
|
||||
};
|
||||
|
||||
int pcppiprint __P((void *, const char *));
|
||||
|
||||
int
|
||||
pcppi_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
void *match, *aux;
|
||||
{
|
||||
struct isa_attach_args *ia = aux;
|
||||
bus_space_handle_t ppi_ioh, pit1_ioh;
|
||||
int have_pit1, have_ppi, rv;
|
||||
u_int8_t v, nv;
|
||||
|
||||
/* If values are hardwired to something that they can't be, punt. */
|
||||
if (ia->ia_iobase != IOBASEUNK || /* ia->ia_iosize != 0 || XXX isa.c */
|
||||
ia->ia_maddr != MADDRUNK || ia->ia_msize != 0 ||
|
||||
ia->ia_irq != IRQUNK || ia->ia_drq != DRQUNK)
|
||||
return (0);
|
||||
|
||||
rv = 0;
|
||||
have_pit1 = have_ppi = 0;
|
||||
|
||||
if (bus_space_map(ia->ia_iot, 0x40, 4, 0, &pit1_ioh)) /* XXX */
|
||||
goto lose;
|
||||
have_pit1 = 1;
|
||||
if (bus_space_map(ia->ia_iot, 0x60, 4, 0, &ppi_ioh)) /* XXX */
|
||||
goto lose;
|
||||
have_ppi = 1;
|
||||
|
||||
/*
|
||||
* Check for existence of PPI. Realistically, this is either going to
|
||||
* be here or nothing is going to be here.
|
||||
*
|
||||
* We don't want to have any chance of changing speaker output (which
|
||||
* this test might, if it crashes in the middle, or something;
|
||||
* normally it's be to quick to produce anthing audible), but
|
||||
* many "combo chip" mock-PPI's don't seem to support the top bit
|
||||
* of Port B as a settable bit. The bottom bit has to be settable,
|
||||
* since the speaker driver hardware still uses it.
|
||||
*/
|
||||
v = bus_space_read_1(ia->ia_iot, ppi_ioh, 1); /* XXX */
|
||||
bus_space_write_1(ia->ia_iot, ppi_ioh, 1, v ^ 0x01); /* XXX */
|
||||
nv = bus_space_read_1(ia->ia_iot, ppi_ioh, 1); /* XXX */
|
||||
if (((nv ^ v) & 0x01) == 0x01)
|
||||
rv = 1;
|
||||
bus_space_write_1(ia->ia_iot, ppi_ioh, 1, v); /* XXX */
|
||||
nv = bus_space_read_1(ia->ia_iot, ppi_ioh, 1); /* XXX */
|
||||
if (((nv ^ v) & 0x01) != 0x00)
|
||||
rv = 0;
|
||||
|
||||
/*
|
||||
* We assume that the programmable interval timer is there.
|
||||
*/
|
||||
|
||||
lose:
|
||||
if (have_pit1)
|
||||
bus_space_unmap(ia->ia_iot, pit1_ioh, 4);
|
||||
if (have_ppi)
|
||||
bus_space_unmap(ia->ia_iot, ppi_ioh, 4);
|
||||
if (rv) {
|
||||
ia->ia_iobase = 0x60;
|
||||
ia->ia_iosize = 0x5;
|
||||
ia->ia_msize = 0x0;
|
||||
}
|
||||
return (rv);
|
||||
}
|
||||
|
||||
void
|
||||
pcppi_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct pcppi_softc *sc = (struct pcppi_softc *)self;
|
||||
struct isa_attach_args *ia = aux;
|
||||
struct pcppi_attach_args pa;
|
||||
bus_space_tag_t iot;
|
||||
|
||||
sc->sc_iot = iot = ia->ia_iot;
|
||||
if (bus_space_map(iot, 0x40, 4, 0, &sc->sc_pit1_ioh) || /*XXX*/
|
||||
bus_space_map(iot, 0x60, 5, 0, &sc->sc_ppi_ioh)) /*XXX*/
|
||||
panic("pcppi_attach: couldn't map");
|
||||
|
||||
printf("\n");
|
||||
|
||||
pa.pa_slot = PCPPI_KBD_SLOT;
|
||||
pa.pa_iot = iot; /* XXX */
|
||||
pa.pa_ioh = sc->sc_ppi_ioh; /* XXX */
|
||||
pa.pa_pit_ioh = sc->sc_pit1_ioh; /* XXX */
|
||||
pa.pa_delaybah = ia->ia_delaybah; /* XXX */
|
||||
pa.pa_ic = ia->ia_ic; /* XXX */
|
||||
config_found(self, &pa, pcppiprint);
|
||||
|
||||
/* XXX SHOULD ONLY ATTACH IF SOMETHING IS THERE */
|
||||
pa.pa_slot = PCPPI_AUX_SLOT;
|
||||
pa.pa_iot = iot; /* XXX */
|
||||
pa.pa_ioh = sc->sc_ppi_ioh; /* XXX */
|
||||
pa.pa_pit_ioh = sc->sc_pit1_ioh; /* XXX */
|
||||
pa.pa_delaybah = ia->ia_delaybah; /* XXX */
|
||||
pa.pa_ic = ia->ia_ic; /* XXX */
|
||||
config_found(self, &pa, pcppiprint);
|
||||
}
|
||||
|
||||
int
|
||||
pcppiprint(aux, pnp)
|
||||
void *aux;
|
||||
const char *pnp;
|
||||
{
|
||||
struct pcppi_attach_args *pa = aux;
|
||||
const char *type;
|
||||
|
||||
switch (pa->pa_slot) {
|
||||
case PCPPI_KBD_SLOT:
|
||||
type = "pckbd";
|
||||
break;
|
||||
case PCPPI_AUX_SLOT:
|
||||
type = "pms";
|
||||
break;
|
||||
default:
|
||||
panic("pcppiprint: bad slot");
|
||||
}
|
||||
|
||||
if (pnp)
|
||||
printf("%s at %s", type, pnp);
|
||||
return (UNCONF);
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/* $NetBSD: pcppivar.h,v 1.1 1996/11/25 03:26:37 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
struct pcppi_attach_args {
|
||||
unsigned int pa_slot;
|
||||
/* XXX should have a device type number */
|
||||
/* XXX should have a cookie to be passed to callbacks */
|
||||
|
||||
/* XXX THESE DO NOT BELONG */
|
||||
bus_space_tag_t pa_iot;
|
||||
bus_space_handle_t pa_ioh;
|
||||
bus_space_handle_t pa_pit_ioh;
|
||||
bus_space_handle_t pa_delaybah;
|
||||
isa_chipset_tag_t pa_ic;
|
||||
};
|
||||
|
||||
#define PCPPI_KBD_SLOT 0
|
||||
#define PCPPI_AUX_SLOT 1
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pms.c,v 1.5 1996/11/13 21:13:23 cgd Exp $ */
|
||||
/* $NetBSD: pms.c,v 1.6 1996/11/25 03:26:38 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 Charles Hannum.
|
||||
|
@ -31,11 +31,6 @@
|
|||
* may result in dropped characters and/or corrupted mouse events.
|
||||
*/
|
||||
|
||||
#include "pms.h"
|
||||
#if NPMS > 1
|
||||
#error Only one PS/2 style mouse may be configured into your system.
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -52,11 +47,11 @@
|
|||
#include <machine/intr.h>
|
||||
#include <dev/isa/isavar.h>
|
||||
#include <alpha/wscons/wsconsvar.h>
|
||||
#include <alpha/isa/pcppivar.h>
|
||||
|
||||
#define PMS_DATA 0x60 /* offset for data port, read-write */
|
||||
#define PMS_CNTRL 0x64 /* offset for control port, write-only */
|
||||
#define PMS_STATUS 0x64 /* offset for status port, read-only */
|
||||
#define PMS_NPORTS 8
|
||||
#define PMS_DATA 0x0 /* offset for data port, read-write */
|
||||
#define PMS_CNTRL 0x4 /* offset for control port, write-only */
|
||||
#define PMS_STATUS 0x4 /* offset for status port, read-only */
|
||||
|
||||
/* status bits */
|
||||
#define PMS_OBUF_FULL 0x01
|
||||
|
@ -98,10 +93,8 @@ struct pms_softc { /* driver status information */
|
|||
};
|
||||
|
||||
bus_space_tag_t pms_iot;
|
||||
bus_space_handle_t pms_ioh;
|
||||
isa_chipset_tag_t pms_ic;
|
||||
bus_space_handle_t pms_cntrl_ioh;
|
||||
#define pms_status_ioh pms_cntrl_ioh
|
||||
bus_space_handle_t pms_data_ioh;
|
||||
|
||||
int pmsprobe __P((struct device *, void *, void *));
|
||||
void pmsattach __P((struct device *, struct device *, void *));
|
||||
|
@ -135,12 +128,12 @@ pms_flush()
|
|||
{
|
||||
u_char c;
|
||||
|
||||
while ((c = bus_space_read_1(pms_iot, pms_status_ioh, 0) & 0x03) != 0)
|
||||
while ((c = bus_space_read_1(pms_iot, pms_ioh, PMS_STATUS) & 0x03) != 0)
|
||||
if ((c & PMS_OBUF_FULL) == PMS_OBUF_FULL) {
|
||||
/* XXX - delay is needed to prevent some keyboards from
|
||||
wedging when the system boots */
|
||||
delay(6);
|
||||
(void) bus_space_read_1(pms_iot, pms_data_ioh, 0);
|
||||
(void) bus_space_read_1(pms_iot, pms_ioh, PMS_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,9 +143,9 @@ pms_dev_cmd(value)
|
|||
{
|
||||
|
||||
pms_flush();
|
||||
bus_space_write_1(pms_iot, pms_cntrl_ioh, 0, 0xd4);
|
||||
bus_space_write_1(pms_iot, pms_ioh, PMS_CNTRL, 0xd4);
|
||||
pms_flush();
|
||||
bus_space_write_1(pms_iot, pms_data_ioh, 0, value);
|
||||
bus_space_write_1(pms_iot, pms_ioh, PMS_DATA, value);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -161,7 +154,7 @@ pms_aux_cmd(value)
|
|||
{
|
||||
|
||||
pms_flush();
|
||||
bus_space_write_1(pms_iot, pms_cntrl_ioh, 0, value);
|
||||
bus_space_write_1(pms_iot, pms_ioh, PMS_CNTRL, value);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -170,9 +163,9 @@ pms_pit_cmd(value)
|
|||
{
|
||||
|
||||
pms_flush();
|
||||
bus_space_write_1(pms_iot, pms_cntrl_ioh, 0, 0x60);
|
||||
bus_space_write_1(pms_iot, pms_ioh, PMS_CNTRL, 0x60);
|
||||
pms_flush();
|
||||
bus_space_write_1(pms_iot, pms_data_ioh, 0, value);
|
||||
bus_space_write_1(pms_iot, pms_ioh, PMS_DATA, value);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -180,28 +173,23 @@ pmsprobe(parent, match, aux)
|
|||
struct device *parent;
|
||||
void *match, *aux;
|
||||
{
|
||||
struct isa_attach_args *ia = aux;
|
||||
struct pcppi_attach_args *pa = aux;
|
||||
u_char x;
|
||||
|
||||
pms_iot = ia->ia_iot;
|
||||
|
||||
if (ia->ia_iobase != 0x60)
|
||||
if (pa->pa_slot != PCPPI_AUX_SLOT)
|
||||
return 0;
|
||||
|
||||
if (bus_space_map(pms_iot, PMS_DATA, 1, 0, &pms_data_ioh) ||
|
||||
bus_space_map(pms_iot, PMS_CNTRL, 1, 0, &pms_cntrl_ioh))
|
||||
return 0;
|
||||
pms_iot = pa->pa_iot;
|
||||
pms_ioh = pa->pa_ioh;
|
||||
|
||||
pms_dev_cmd(PMS_RESET);
|
||||
pms_aux_cmd(PMS_AUX_TEST);
|
||||
delay(1000);
|
||||
x = bus_space_read_1(pms_iot, pms_data_ioh, 0);
|
||||
x = bus_space_read_1(pms_iot, pms_ioh, PMS_DATA);
|
||||
pms_pit_cmd(PMS_INT_DISABLE);
|
||||
if (x & 0x04)
|
||||
return 0;
|
||||
|
||||
ia->ia_iosize = PMS_NPORTS;
|
||||
ia->ia_msize = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -211,16 +199,11 @@ pmsattach(parent, self, aux)
|
|||
void *aux;
|
||||
{
|
||||
struct pms_softc *sc = (void *)self;
|
||||
struct isa_attach_args *ia = aux;
|
||||
struct pcppi_attach_args *pa = aux;
|
||||
|
||||
pms_iot = ia->ia_iot;
|
||||
pms_ic = ia->ia_ic;
|
||||
|
||||
if (bus_space_map(pms_iot, PMS_DATA, 1, 0, &pms_data_ioh) ||
|
||||
bus_space_map(pms_iot, PMS_CNTRL, 1, 0, &pms_cntrl_ioh)) {
|
||||
printf(": can't map I/O ports!\n");
|
||||
return;
|
||||
}
|
||||
pms_iot = pa->pa_iot;
|
||||
pms_ioh = pa->pa_ioh;
|
||||
pms_ic = pa->pa_ic;
|
||||
|
||||
msattach(self, &pms_mdev_spec);
|
||||
|
||||
|
@ -229,7 +212,7 @@ pmsattach(parent, self, aux)
|
|||
/* Other initialization was done by pmsprobe. */
|
||||
sc->sc_state = 0;
|
||||
|
||||
sc->sc_ih = isa_intr_establish(pms_ic, ia->ia_irq, IST_EDGE, IPL_TTY,
|
||||
sc->sc_ih = isa_intr_establish(pms_ic, 12, IST_EDGE, IPL_TTY,
|
||||
pmsintr, sc);
|
||||
}
|
||||
|
||||
|
@ -302,20 +285,20 @@ pmsintr(arg)
|
|||
switch (state) {
|
||||
|
||||
case 0:
|
||||
buttons = bus_space_read_1(pms_iot, pms_data_ioh, 0);
|
||||
buttons = bus_space_read_1(pms_iot, pms_ioh, PMS_DATA);
|
||||
if ((buttons & 0xc0) == 0)
|
||||
++state;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
dx = bus_space_read_1(pms_iot, pms_data_ioh, 0);
|
||||
dx = bus_space_read_1(pms_iot, pms_ioh, PMS_DATA);
|
||||
/* Bounding at -127 avoids a bug in XFree86. */
|
||||
dx = (dx == -128) ? -127 : dx;
|
||||
++state;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
dy = bus_space_read_1(pms_iot, pms_data_ioh, 0);
|
||||
dy = bus_space_read_1(pms_iot, pms_ioh, PMS_DATA);
|
||||
dy = (dy == -128) ? -127 : dy;
|
||||
state = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue