1994-03-23 04:25:53 +03:00
|
|
|
/*
|
|
|
|
* Multi-port serial card interrupt demuxing support.
|
|
|
|
* Roland McGrath 3/20/94
|
1994-03-23 06:55:24 +03:00
|
|
|
* The author disclaims copyright and places this file in the public domain.
|
1994-03-23 04:25:53 +03:00
|
|
|
*
|
1994-03-23 06:55:24 +03:00
|
|
|
* Modified by: Charles Hannum, 3/22/94
|
|
|
|
*
|
|
|
|
* $Id: ast.c,v 1.4 1994/03/23 03:55:24 cgd Exp $
|
1994-03-23 04:25:53 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ast.h"
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
1994-03-23 06:01:50 +03:00
|
|
|
#include <sys/device.h>
|
1994-03-23 04:25:53 +03:00
|
|
|
|
|
|
|
#include <machine/pio.h>
|
|
|
|
#include <i386/isa/isa_device.h>
|
|
|
|
|
|
|
|
int astprobe __P((struct isa_device *));
|
|
|
|
int astattach __P((struct isa_device *));
|
|
|
|
|
|
|
|
struct isa_driver astdriver = {
|
|
|
|
astprobe, astattach, "ast"
|
|
|
|
};
|
|
|
|
|
1994-03-23 06:01:50 +03:00
|
|
|
struct ast_softc {
|
|
|
|
struct device sc_dev;
|
|
|
|
u_short sc_iobase;
|
|
|
|
int sc_alive; /* Mask of slave units attached. */
|
|
|
|
int sc_slaves[8]; /* com device unit numbers. XXX - softc ptrs */
|
|
|
|
} ast_softc[NAST];
|
1994-03-23 04:25:53 +03:00
|
|
|
|
|
|
|
int
|
1994-03-23 06:01:50 +03:00
|
|
|
astprobe(dev)
|
|
|
|
struct isa_device *dev;
|
1994-03-23 04:25:53 +03:00
|
|
|
{
|
1994-03-23 06:01:50 +03:00
|
|
|
|
1994-03-23 04:25:53 +03:00
|
|
|
/*
|
|
|
|
* Do the normal com probe for the first UART and assume
|
|
|
|
* its presence means there is a multiport board there.
|
|
|
|
* XXX needs more robustness.
|
|
|
|
*/
|
1994-03-23 06:01:50 +03:00
|
|
|
return comprobe1(dev->id_iobase);
|
1994-03-23 04:25:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1994-03-23 06:01:50 +03:00
|
|
|
astattach(dev)
|
|
|
|
struct isa_device *dev;
|
1994-03-23 04:25:53 +03:00
|
|
|
{
|
1994-03-23 06:01:50 +03:00
|
|
|
struct ast_softc *sc = &ast_softc[dev->id_unit];
|
|
|
|
u_short iobase = dev->id_iobase;
|
1994-03-23 04:25:53 +03:00
|
|
|
unsigned int x;
|
1994-03-23 06:01:50 +03:00
|
|
|
|
|
|
|
/* XXX HACK */
|
|
|
|
sprintf(sc->sc_dev.dv_xname, "%s%d", astdriver.name, dev->id_unit);
|
|
|
|
sc->sc_dev.dv_unit = dev->id_unit;
|
|
|
|
|
|
|
|
sc->sc_iobase = iobase;
|
1994-03-23 04:25:53 +03:00
|
|
|
|
|
|
|
/*
|
1994-03-23 06:01:50 +03:00
|
|
|
* Enable the master interrupt.
|
1994-03-23 04:25:53 +03:00
|
|
|
*/
|
1994-03-23 06:01:50 +03:00
|
|
|
outb(iobase | 0x1f, 0x80);
|
|
|
|
x = inb(iobase | 0x1f);
|
1994-03-23 04:25:53 +03:00
|
|
|
/*
|
|
|
|
* My guess is this bitmask tells you how many ports are there.
|
|
|
|
* I only have a 4-port board to try (returns 0xf). --roland
|
1994-03-23 06:01:50 +03:00
|
|
|
*
|
|
|
|
* It's also not clear that it would be correct to rely on this, since
|
|
|
|
* there might be an interrupt pending on one of the ports, and thus
|
1994-03-23 06:04:32 +03:00
|
|
|
* its bit wouldn't be set. I think the AST protocol simply does not
|
|
|
|
* support more than 4 ports. - mycroft
|
1994-03-23 04:25:53 +03:00
|
|
|
*/
|
1994-03-23 06:01:50 +03:00
|
|
|
printf("%s: 0x%x\n", sc->sc_dev.dv_xname, x);
|
1994-03-23 04:25:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1994-03-23 06:01:50 +03:00
|
|
|
astslave(dev)
|
|
|
|
struct isa_device *dev;
|
1994-03-23 04:25:53 +03:00
|
|
|
{
|
1994-03-23 06:01:50 +03:00
|
|
|
struct ast_softc *sc = &ast_softc[dev->id_parent->id_unit];
|
1994-03-23 04:25:53 +03:00
|
|
|
|
1994-03-23 06:01:50 +03:00
|
|
|
sc->sc_slaves[dev->id_physid] = dev->id_unit;
|
|
|
|
sc->sc_alive |= 1 << dev->id_physid;
|
1994-03-23 04:25:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1994-03-23 06:01:50 +03:00
|
|
|
astintr(unit)
|
|
|
|
int unit;
|
1994-03-23 04:25:53 +03:00
|
|
|
{
|
1994-03-23 06:01:50 +03:00
|
|
|
struct ast_softc *sc = &ast_softc[unit];
|
|
|
|
u_short iobase = sc->sc_iobase;
|
|
|
|
int alive = sc->sc_alive;
|
1994-03-23 04:25:53 +03:00
|
|
|
int bits;
|
|
|
|
|
1994-03-23 06:01:50 +03:00
|
|
|
bits = inb(iobase | 0x1f) & alive;
|
|
|
|
if (bits == alive)
|
|
|
|
return 0;
|
|
|
|
|
1994-03-23 04:25:53 +03:00
|
|
|
do {
|
1994-03-23 06:01:50 +03:00
|
|
|
#define TRY(n) \
|
|
|
|
if ((bits & (1 << (n))) == 0) \
|
|
|
|
comintr(sc->sc_slaves[n]); /* XXX softc ptr */
|
|
|
|
TRY(0);
|
|
|
|
TRY(1);
|
|
|
|
TRY(2);
|
|
|
|
TRY(3);
|
1994-03-23 06:04:32 +03:00
|
|
|
#ifdef notdef
|
1994-03-23 06:01:50 +03:00
|
|
|
TRY(4);
|
|
|
|
TRY(5);
|
|
|
|
TRY(6);
|
|
|
|
TRY(7);
|
1994-03-23 06:04:32 +03:00
|
|
|
#endif
|
1994-03-23 06:01:50 +03:00
|
|
|
bits = inb(iobase | 0x1f) & alive;
|
1994-03-23 04:25:53 +03:00
|
|
|
} while (bits != alive);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|