1998-06-08 10:55:54 +04:00
|
|
|
/* $NetBSD: eisa.c,v 1.21 1998/06/08 07:04:46 thorpej Exp $ */
|
1996-02-27 03:20:54 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1995, 1996 Christopher G. Demetriou
|
|
|
|
* 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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Christopher G. Demetriou
|
|
|
|
* for the NetBSD Project.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* EISA Bus device
|
|
|
|
*
|
|
|
|
* Makes sure an EISA bus is present, and finds and attaches devices
|
|
|
|
* living on it.
|
|
|
|
*/
|
|
|
|
|
1997-09-13 12:48:59 +04:00
|
|
|
#include "opt_eisaverbose.h"
|
|
|
|
|
1996-02-27 03:20:54 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
1996-03-08 23:39:32 +03:00
|
|
|
#include <machine/bus.h>
|
|
|
|
|
1996-02-27 03:20:54 +03:00
|
|
|
#include <dev/eisa/eisareg.h>
|
|
|
|
#include <dev/eisa/eisavar.h>
|
|
|
|
#include <dev/eisa/eisadevs.h>
|
|
|
|
|
1996-12-05 04:25:23 +03:00
|
|
|
int eisamatch __P((struct device *, struct cfdata *, void *));
|
1996-02-27 03:20:54 +03:00
|
|
|
void eisaattach __P((struct device *, struct device *, void *));
|
|
|
|
|
1996-03-17 03:43:52 +03:00
|
|
|
struct cfattach eisa_ca = {
|
|
|
|
sizeof(struct device), eisamatch, eisaattach
|
|
|
|
};
|
|
|
|
|
1996-12-05 04:25:23 +03:00
|
|
|
int eisasubmatch __P((struct device *, struct cfdata *, void *));
|
1996-08-28 01:53:46 +04:00
|
|
|
int eisaprint __P((void *, const char *));
|
1996-02-27 03:20:54 +03:00
|
|
|
void eisa_devinfo __P((const char *, char *));
|
|
|
|
|
|
|
|
int
|
1996-12-05 04:25:23 +03:00
|
|
|
eisamatch(parent, cf, aux)
|
1996-04-06 06:04:00 +04:00
|
|
|
struct device *parent;
|
1996-12-05 04:25:23 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
1996-02-27 03:20:54 +03:00
|
|
|
{
|
|
|
|
struct eisabus_attach_args *eba = aux;
|
|
|
|
|
|
|
|
if (strcmp(eba->eba_busname, cf->cf_driver->cd_name))
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
/* XXX check other indicators */
|
|
|
|
|
1996-04-06 06:04:00 +04:00
|
|
|
return (1);
|
1996-02-27 03:20:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-28 00:48:52 +03:00
|
|
|
eisaprint(aux, pnp)
|
1996-02-27 03:20:54 +03:00
|
|
|
void *aux;
|
1996-08-28 01:53:46 +04:00
|
|
|
const char *pnp;
|
1996-02-27 03:20:54 +03:00
|
|
|
{
|
|
|
|
register struct eisa_attach_args *ea = aux;
|
1996-02-28 00:48:52 +03:00
|
|
|
char devinfo[256];
|
1996-02-27 03:20:54 +03:00
|
|
|
|
1996-02-28 00:48:52 +03:00
|
|
|
if (pnp) {
|
|
|
|
eisa_devinfo(ea->ea_idstring, devinfo);
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s at %s", devinfo, pnp);
|
1996-02-28 00:48:52 +03:00
|
|
|
}
|
1996-10-13 05:37:04 +04:00
|
|
|
printf(" slot %d", ea->ea_slot);
|
1996-02-27 03:20:54 +03:00
|
|
|
return (UNCONF);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-12-05 04:25:23 +03:00
|
|
|
eisasubmatch(parent, cf, aux)
|
1996-02-27 03:20:54 +03:00
|
|
|
struct device *parent;
|
1996-12-05 04:25:23 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
1996-02-27 03:20:54 +03:00
|
|
|
{
|
|
|
|
struct eisa_attach_args *ea = aux;
|
|
|
|
|
|
|
|
if (cf->eisacf_slot != EISA_UNKNOWN_SLOT &&
|
|
|
|
cf->eisacf_slot != ea->ea_slot)
|
|
|
|
return 0;
|
1996-12-05 04:25:23 +03:00
|
|
|
return ((*cf->cf_attach->ca_match)(parent, cf, aux));
|
1996-02-27 03:20:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eisaattach(parent, self, aux)
|
1996-04-06 06:04:00 +04:00
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
1996-02-27 03:20:54 +03:00
|
|
|
{
|
1996-03-08 23:39:32 +03:00
|
|
|
struct eisabus_attach_args *eba = aux;
|
1996-10-22 02:24:37 +04:00
|
|
|
bus_space_tag_t iot, memt;
|
1997-06-07 03:30:02 +04:00
|
|
|
bus_dma_tag_t dmat;
|
1996-04-10 02:46:11 +04:00
|
|
|
eisa_chipset_tag_t ec;
|
|
|
|
int slot, maxnslots;
|
1996-02-27 03:20:54 +03:00
|
|
|
|
1996-04-10 02:46:11 +04:00
|
|
|
eisa_attach_hook(parent, self, eba);
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("\n");
|
1996-02-27 03:20:54 +03:00
|
|
|
|
1996-10-22 02:24:37 +04:00
|
|
|
iot = eba->eba_iot;
|
|
|
|
memt = eba->eba_memt;
|
1996-04-10 02:46:11 +04:00
|
|
|
ec = eba->eba_ec;
|
1997-06-07 03:30:02 +04:00
|
|
|
dmat = eba->eba_dmat;
|
1996-03-08 23:39:32 +03:00
|
|
|
|
1996-02-27 03:20:54 +03:00
|
|
|
/*
|
|
|
|
* Search for and attach subdevices.
|
|
|
|
*
|
|
|
|
* Slot 0 is the "motherboard" slot, and the code attaching
|
|
|
|
* the EISA bus should have already attached an ISA bus there.
|
|
|
|
*/
|
1996-04-10 02:46:11 +04:00
|
|
|
maxnslots = eisa_maxslots(ec);
|
|
|
|
for (slot = 1; slot < maxnslots; slot++) {
|
1996-02-27 03:20:54 +03:00
|
|
|
struct eisa_attach_args ea;
|
|
|
|
u_int slotaddr;
|
1996-10-22 02:24:37 +04:00
|
|
|
bus_space_handle_t slotioh;
|
1996-02-27 03:20:54 +03:00
|
|
|
int i;
|
|
|
|
|
1996-10-22 02:24:37 +04:00
|
|
|
ea.ea_iot = iot;
|
|
|
|
ea.ea_memt = memt;
|
1996-04-10 02:46:11 +04:00
|
|
|
ea.ea_ec = ec;
|
1997-06-07 03:30:02 +04:00
|
|
|
ea.ea_dmat = dmat;
|
1996-02-27 03:20:54 +03:00
|
|
|
ea.ea_slot = slot;
|
|
|
|
slotaddr = EISA_SLOT_ADDR(slot);
|
|
|
|
|
1996-03-08 23:39:32 +03:00
|
|
|
/*
|
|
|
|
* Get a mapping for the whole slot-specific address
|
|
|
|
* space. If we can't, assume nothing's there but warn
|
|
|
|
* about it.
|
|
|
|
*/
|
1996-10-22 02:24:37 +04:00
|
|
|
if (bus_space_map(iot, slotaddr, EISA_SLOT_SIZE, 0, &slotioh)) {
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: can't map I/O space for slot %d\n",
|
1996-03-31 03:08:29 +04:00
|
|
|
self->dv_xname, slot);
|
1996-03-08 23:39:32 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1996-02-27 03:20:54 +03:00
|
|
|
/* Get the vendor ID bytes */
|
|
|
|
for (i = 0; i < EISA_NVIDREGS; i++)
|
1996-10-22 02:24:37 +04:00
|
|
|
ea.ea_vid[i] = bus_space_read_1(iot, slotioh,
|
1996-03-08 23:39:32 +03:00
|
|
|
EISA_SLOTOFF_VID + i);
|
1996-02-27 03:20:54 +03:00
|
|
|
|
|
|
|
/* Check for device existence */
|
|
|
|
if (EISA_VENDID_NODEV(ea.ea_vid)) {
|
|
|
|
#if 0
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("no device at %s slot %d\n", self->dv_xname,
|
1996-02-27 03:20:54 +03:00
|
|
|
slot);
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("\t(0x%x, 0x%x)\n", ea.ea_vid[0],
|
1996-02-27 03:20:54 +03:00
|
|
|
ea.ea_vid[1]);
|
|
|
|
#endif
|
1996-10-22 02:24:37 +04:00
|
|
|
bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
|
1996-02-27 03:20:54 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* And check that the firmware didn't biff something badly */
|
|
|
|
if (EISA_VENDID_IDDELAY(ea.ea_vid)) {
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s slot %d not configured by BIOS?\n",
|
1996-02-27 03:20:54 +03:00
|
|
|
self->dv_xname, slot);
|
1996-10-22 02:24:37 +04:00
|
|
|
bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
|
1996-02-27 03:20:54 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the product ID bytes */
|
|
|
|
for (i = 0; i < EISA_NPIDREGS; i++)
|
1996-10-22 02:24:37 +04:00
|
|
|
ea.ea_pid[i] = bus_space_read_1(iot, slotioh,
|
1996-03-08 23:39:32 +03:00
|
|
|
EISA_SLOTOFF_PID + i);
|
1996-02-27 03:20:54 +03:00
|
|
|
|
|
|
|
/* Create the ID string from the vendor and product IDs */
|
|
|
|
ea.ea_idstring[0] = EISA_VENDID_0(ea.ea_vid);
|
|
|
|
ea.ea_idstring[1] = EISA_VENDID_1(ea.ea_vid);
|
|
|
|
ea.ea_idstring[2] = EISA_VENDID_2(ea.ea_vid);
|
|
|
|
ea.ea_idstring[3] = EISA_PRODID_0(ea.ea_pid);
|
|
|
|
ea.ea_idstring[4] = EISA_PRODID_1(ea.ea_pid);
|
|
|
|
ea.ea_idstring[5] = EISA_PRODID_2(ea.ea_pid);
|
|
|
|
ea.ea_idstring[6] = EISA_PRODID_3(ea.ea_pid);
|
|
|
|
ea.ea_idstring[7] = '\0'; /* sanity */
|
|
|
|
|
1996-03-08 23:39:32 +03:00
|
|
|
/* We no longer need the I/O handle; free it. */
|
1996-10-22 02:24:37 +04:00
|
|
|
bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
|
1996-03-08 23:39:32 +03:00
|
|
|
|
1996-02-28 00:48:52 +03:00
|
|
|
/* Attach matching device. */
|
|
|
|
config_found_sm(self, &ea, eisaprint, eisasubmatch);
|
1996-02-27 03:20:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef EISAVERBOSE
|
1996-04-06 06:04:00 +04:00
|
|
|
/*
|
1996-02-27 03:20:54 +03:00
|
|
|
* Descriptions of of known vendors and devices ("products").
|
1996-04-06 06:04:00 +04:00
|
|
|
*/
|
1996-02-27 03:20:54 +03:00
|
|
|
struct eisa_knowndev {
|
|
|
|
int flags;
|
|
|
|
const char *id, *name;
|
1996-04-06 06:04:00 +04:00
|
|
|
};
|
|
|
|
#define EISA_KNOWNDEV_NOPROD 0x01 /* match on vendor only */
|
1996-02-27 03:20:54 +03:00
|
|
|
|
|
|
|
#include <dev/eisa/eisadevs_data.h>
|
|
|
|
#endif /* EISAVERBOSE */
|
|
|
|
|
|
|
|
void
|
|
|
|
eisa_devinfo(id, cp)
|
|
|
|
const char *id;
|
|
|
|
char *cp;
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
int onlyvendor;
|
|
|
|
#ifdef EISAVERBOSE
|
|
|
|
struct eisa_knowndev *edp;
|
|
|
|
int match;
|
1996-03-02 05:44:25 +03:00
|
|
|
const char *unmatched = "unknown ";
|
1996-03-02 04:09:37 +03:00
|
|
|
#else
|
|
|
|
const char *unmatched = "";
|
1996-02-27 03:20:54 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
onlyvendor = 0;
|
|
|
|
name = NULL;
|
|
|
|
|
|
|
|
#ifdef EISAVERBOSE
|
|
|
|
/* find the device in the table, if possible. */
|
|
|
|
edp = eisa_knowndevs;
|
|
|
|
while (edp->id != NULL) {
|
|
|
|
/* check this entry for a match */
|
|
|
|
if ((edp->flags & EISA_KNOWNDEV_NOPROD) != 0)
|
|
|
|
match = !strncmp(edp->id, id, 3);
|
|
|
|
else
|
|
|
|
match = !strcmp(edp->id, id);
|
|
|
|
if (match) {
|
|
|
|
name = edp->name;
|
|
|
|
onlyvendor = (edp->flags & EISA_KNOWNDEV_NOPROD) != 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
edp++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (name == NULL)
|
1996-10-13 05:37:04 +04:00
|
|
|
cp += sprintf(cp, "%sdevice %s", unmatched, id);
|
1996-03-02 04:09:37 +03:00
|
|
|
else if (onlyvendor) /* never if not EISAVERBOSE */
|
1996-10-13 05:37:04 +04:00
|
|
|
cp += sprintf(cp, "unknown %s device %s", name, id);
|
1996-02-27 03:20:54 +03:00
|
|
|
else
|
1996-10-13 05:37:04 +04:00
|
|
|
cp += sprintf(cp, "%s", name);
|
1996-02-27 03:20:54 +03:00
|
|
|
}
|