Account for changed bus attachment scheme.
This commit is contained in:
parent
be7f5a7031
commit
c99d62cc8a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bwtwo.c,v 1.35 1998/01/12 20:23:41 thorpej Exp $ */
|
||||
/* $NetBSD: bwtwo.c,v 1.36 1998/03/21 20:23:38 pk Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -112,20 +112,19 @@
|
|||
#include <sparc/dev/btreg.h>
|
||||
#include <sparc/dev/bwtworeg.h>
|
||||
#include <sparc/dev/sbusvar.h>
|
||||
#if defined(SUN4)
|
||||
#include <sparc/dev/pfourreg.h>
|
||||
#endif
|
||||
|
||||
/* per-display variables */
|
||||
struct bwtwo_softc {
|
||||
struct device sc_dev; /* base device */
|
||||
struct sbusdev sc_sd; /* sbus device */
|
||||
struct fbdevice sc_fb; /* frame buffer device */
|
||||
struct device sc_dev; /* base device */
|
||||
struct sbusdev sc_sd; /* sbus device */
|
||||
struct fbdevice sc_fb; /* frame buffer device */
|
||||
bus_space_tag_t sc_bustag;
|
||||
bus_type_t sc_btype; /* phys address description */
|
||||
bus_addr_t sc_paddr; /* for device mmap() */
|
||||
|
||||
volatile struct fbcontrol *sc_reg;/* control registers */
|
||||
struct rom_reg sc_phys; /* phys address description */
|
||||
int sc_bustype; /* type of bus we live on */
|
||||
int sc_pixeloffset; /* offset to framebuffer */
|
||||
#if defined(SUN4)
|
||||
int sc_pixeloffset; /* offset to framebuffer */
|
||||
/*
|
||||
* Additional overlay plane goo.
|
||||
*/
|
||||
|
@ -133,21 +132,36 @@ struct bwtwo_softc {
|
|||
#define BWO_NONE 0x00
|
||||
#define BWO_CGFOUR 0x01
|
||||
#define BWO_CGEIGHT 0x02
|
||||
#endif
|
||||
|
||||
/* Video status */
|
||||
int (*sc_get_video) __P((struct bwtwo_softc *));
|
||||
void (*sc_set_video) __P((struct bwtwo_softc *, int));
|
||||
};
|
||||
|
||||
/* autoconfiguration driver */
|
||||
static void bwtwoattach __P((struct device *, struct device *, void *));
|
||||
static int bwtwomatch __P((struct device *, struct cfdata *, void *));
|
||||
static void bwtwoattach_sbus __P((struct device *, struct device *, void *));
|
||||
static int bwtwomatch_sbus __P((struct device *, struct cfdata *, void *));
|
||||
static void bwtwoattach_obio __P((struct device *, struct device *, void *));
|
||||
static int bwtwomatch_obio __P((struct device *, struct cfdata *, void *));
|
||||
|
||||
static void bwtwoattach __P((struct bwtwo_softc *, char *, int, int));
|
||||
static void bwtwounblank __P((struct device *));
|
||||
static void bwtwo_set_video __P((struct bwtwo_softc *, int));
|
||||
static int bwtwo_get_video __P((struct bwtwo_softc *));
|
||||
static int bwtwo_get_video_sun4 __P((struct bwtwo_softc *));
|
||||
static void bwtwo_set_video_sun4 __P((struct bwtwo_softc *, int));
|
||||
static int bwtwo_get_video_sun4c __P((struct bwtwo_softc *));
|
||||
static void bwtwo_set_video_sun4c __P((struct bwtwo_softc *, int));
|
||||
static int bwtwo_pfour_probe __P((void *, void *));
|
||||
|
||||
|
||||
/* cdevsw prototypes */
|
||||
cdev_decl(bwtwo);
|
||||
|
||||
struct cfattach bwtwo_ca = {
|
||||
sizeof(struct bwtwo_softc), bwtwomatch, bwtwoattach
|
||||
struct cfattach bwtwo_sbus_ca = {
|
||||
sizeof(struct bwtwo_softc), bwtwomatch_sbus, bwtwoattach_sbus
|
||||
};
|
||||
|
||||
struct cfattach bwtwo_obio_ca = {
|
||||
sizeof(struct bwtwo_softc), bwtwomatch_obio, bwtwoattach_obio
|
||||
};
|
||||
|
||||
extern struct cfdriver bwtwo_cd;
|
||||
|
@ -166,55 +180,51 @@ extern struct tty *fbconstty;
|
|||
* Match a bwtwo.
|
||||
*/
|
||||
int
|
||||
bwtwomatch(parent, cf, aux)
|
||||
bwtwomatch_sbus(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
{
|
||||
struct confargs *ca = aux;
|
||||
struct romaux *ra = &ca->ca_ra;
|
||||
struct sbus_attach_args *sa = aux;
|
||||
|
||||
if (CPU_ISSUN4 && cf->cf_unit != 0)
|
||||
return (strcmp(cf->cf_driver->cd_name, sa->sa_name) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
bwtwomatch_obio(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
{
|
||||
union obio_attach_args *uoba = aux;
|
||||
struct obio4_attach_args *oba;
|
||||
|
||||
if (uoba->uoba_isobio4 == 0)
|
||||
return (0);
|
||||
|
||||
if (strcmp(cf->cf_driver->cd_name, ra->ra_name))
|
||||
return (0);
|
||||
oba = &uoba->uoba_oba4;
|
||||
return (obio_bus_probe(oba->oba_bustag, oba->oba_paddr,
|
||||
0, 4,
|
||||
bwtwo_pfour_probe, cf));
|
||||
}
|
||||
|
||||
/*
|
||||
* Mask out invalid flags from the user.
|
||||
*/
|
||||
cf->cf_flags &= FB_USERMASK;
|
||||
int
|
||||
bwtwo_pfour_probe(vaddr, arg)
|
||||
void *vaddr;
|
||||
void *arg;
|
||||
{
|
||||
struct cfdata *cf = arg;
|
||||
|
||||
if (ca->ca_bustype == BUS_SBUS)
|
||||
return(1);
|
||||
|
||||
/*
|
||||
* Make sure there's hardware there.
|
||||
*/
|
||||
if (probeget(ra->ra_vaddr, 4) == -1)
|
||||
return (0);
|
||||
|
||||
#if defined(SUN4)
|
||||
if (CPU_ISSUN4 && (ca->ca_bustype == BUS_OBIO)) {
|
||||
/*
|
||||
* Check for a pfour framebuffer.
|
||||
*/
|
||||
switch (fb_pfour_id(ra->ra_vaddr)) {
|
||||
case PFOUR_ID_BW:
|
||||
case PFOUR_ID_COLOR8P1: /* bwtwo in ... */
|
||||
case PFOUR_ID_COLOR24: /* ...overlay plane */
|
||||
cf->cf_flags |= FB_PFOUR;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case PFOUR_NOTPFOUR:
|
||||
return (1);
|
||||
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
switch (fb_pfour_id(vaddr)) {
|
||||
case PFOUR_ID_BW:
|
||||
case PFOUR_ID_COLOR8P1: /* bwtwo in ... */
|
||||
case PFOUR_ID_COLOR24: /* ...overlay plane */
|
||||
/* This is wrong; should be done in bwtwo_attach() */
|
||||
cf->cf_flags |= FB_PFOUR;
|
||||
/* FALLTHROUGH */
|
||||
case PFOUR_NOTPFOUR:
|
||||
return (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -222,120 +232,28 @@ bwtwomatch(parent, cf, aux)
|
|||
* Attach a display. We need to notice if it is the console, too.
|
||||
*/
|
||||
void
|
||||
bwtwoattach(parent, self, args)
|
||||
bwtwoattach_sbus(parent, self, args)
|
||||
struct device *parent, *self;
|
||||
void *args;
|
||||
{
|
||||
register struct bwtwo_softc *sc = (struct bwtwo_softc *)self;
|
||||
register struct confargs *ca = args;
|
||||
register int node = ca->ca_ra.ra_node, ramsize;
|
||||
struct bwtwo_softc *sc = (struct bwtwo_softc *)self;
|
||||
struct sbus_attach_args *sa = args;
|
||||
struct fbdevice *fb = &sc->sc_fb;
|
||||
int isconsole = 0;
|
||||
int sbus = 1;
|
||||
char *nam = NULL;
|
||||
bus_space_handle_t bh;
|
||||
int isconsole, node;
|
||||
char *name;
|
||||
extern struct tty *fbconstty;
|
||||
|
||||
node = sa->sa_node;
|
||||
|
||||
/* Remember cookies for bwtwo_mmap() */
|
||||
sc->sc_bustag = sa->sa_bustag;
|
||||
sc->sc_btype = (bus_type_t)sa->sa_slot;
|
||||
sc->sc_paddr = (bus_addr_t)sa->sa_offset;
|
||||
|
||||
fb->fb_driver = &bwtwofbdriver;
|
||||
fb->fb_device = &sc->sc_dev;
|
||||
fb->fb_type.fb_type = FBTYPE_SUN2BW;
|
||||
fb->fb_flags = sc->sc_dev.dv_cfdata->cf_flags;
|
||||
|
||||
/*
|
||||
* Map the control register.
|
||||
*/
|
||||
if (fb->fb_flags & FB_PFOUR) {
|
||||
fb->fb_pfour = (volatile u_int32_t *)
|
||||
mapiodev(ca->ca_ra.ra_reg, 0, sizeof(u_int32_t));
|
||||
sc->sc_reg = NULL;
|
||||
} else {
|
||||
sc->sc_reg = (volatile struct fbcontrol *)
|
||||
mapiodev(ca->ca_ra.ra_reg, BWREG_REG,
|
||||
sizeof(struct fbcontrol));
|
||||
fb->fb_pfour = NULL;
|
||||
}
|
||||
|
||||
/* Set up default pixel offset. May be changed below. */
|
||||
sc->sc_pixeloffset = BWREG_MEM;
|
||||
|
||||
switch (ca->ca_bustype) {
|
||||
case BUS_OBIO:
|
||||
if (CPU_ISSUN4M) /* 4m has framebuffer on obio */
|
||||
goto obp_name;
|
||||
|
||||
sbus = node = 0;
|
||||
#if defined(SUN4)
|
||||
if (fb->fb_flags & FB_PFOUR) {
|
||||
nam = "bwtwo/p4";
|
||||
/*
|
||||
* Notice if this is an overlay plane on a color
|
||||
* framebuffer. Note that PFOUR_COLOR_OFF_OVERLAY
|
||||
* is the same as PFOUR_BW_OFF, but we use the
|
||||
* different names anyway.
|
||||
*/
|
||||
switch (PFOUR_ID(*fb->fb_pfour)) {
|
||||
case PFOUR_ID_COLOR8P1:
|
||||
sc->sc_ovtype = BWO_CGFOUR;
|
||||
sc->sc_pixeloffset = PFOUR_COLOR_OFF_OVERLAY;
|
||||
break;
|
||||
|
||||
case PFOUR_ID_COLOR24:
|
||||
sc->sc_ovtype = BWO_CGEIGHT;
|
||||
sc->sc_pixeloffset = PFOUR_COLOR_OFF_OVERLAY;
|
||||
break;
|
||||
|
||||
default:
|
||||
sc->sc_ovtype = BWO_NONE;
|
||||
sc->sc_pixeloffset = PFOUR_BW_OFF;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
nam = "bwtwo";
|
||||
break;
|
||||
|
||||
case BUS_VME32:
|
||||
case BUS_VME16:
|
||||
sbus = node = 0;
|
||||
nam = "bwtwo";
|
||||
break;
|
||||
|
||||
case BUS_SBUS:
|
||||
obp_name:
|
||||
#if defined(SUN4C) || defined(SUN4M)
|
||||
nam = getpropstring(node, "model");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
sc->sc_phys = ca->ca_ra.ra_reg[0];
|
||||
sc->sc_bustype = ca->ca_bustype;
|
||||
|
||||
fb->fb_type.fb_depth = 1;
|
||||
fb_setsize(fb, fb->fb_type.fb_depth, 1152, 900, node, ca->ca_bustype);
|
||||
|
||||
ramsize = fb->fb_type.fb_height * fb->fb_linebytes;
|
||||
fb->fb_type.fb_cmsize = 0;
|
||||
fb->fb_type.fb_size = ramsize;
|
||||
printf(": %s, %d x %d", nam,
|
||||
fb->fb_type.fb_width, fb->fb_type.fb_height);
|
||||
|
||||
#if defined(SUN4)
|
||||
if (CPU_ISSUN4) {
|
||||
struct eeprom *eep = (struct eeprom *)eeprom_va;
|
||||
int constype = (fb->fb_flags & FB_PFOUR) ? EE_CONS_P4OPT :
|
||||
EE_CONS_BW;
|
||||
/*
|
||||
* Assume this is the console if there's no eeprom info
|
||||
* to be found.
|
||||
*/
|
||||
if (eep == NULL || eep->eeConsole == constype)
|
||||
isconsole = (fbconstty != NULL);
|
||||
else
|
||||
isconsole = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (CPU_ISSUN4COR4M)
|
||||
isconsole = node == fbnode && fbconstty != NULL;
|
||||
fb_setsize_obp(fb, fb->fb_type.fb_depth, 1152, 900, node);
|
||||
|
||||
/*
|
||||
* When the ROM has mapped in a bwtwo display, the address
|
||||
|
@ -343,19 +261,184 @@ bwtwoattach(parent, self, args)
|
|||
* registers ourselves. We only need the video RAM if we are
|
||||
* going to print characters via rconsole.
|
||||
*/
|
||||
if ((fb->fb_pixels = ca->ca_ra.ra_vaddr) == NULL && isconsole) {
|
||||
/* this probably cannot happen (on sun4c), but what the heck */
|
||||
fb->fb_pixels =
|
||||
mapiodev(ca->ca_ra.ra_reg, sc->sc_pixeloffset, ramsize);
|
||||
if (sbus_bus_map(sa->sa_bustag, sa->sa_slot,
|
||||
sa->sa_offset + BWREG_REG,
|
||||
sizeof(struct fbcontrol),
|
||||
BUS_SPACE_MAP_LINEAR,
|
||||
0, &bh) != 0) {
|
||||
printf("%s: cannot map control registers\n", self->dv_xname);
|
||||
return;
|
||||
}
|
||||
sc->sc_reg = (struct fbcontrol *)bh;
|
||||
fb->fb_pfour = NULL;
|
||||
|
||||
sc->sc_pixeloffset = BWREG_MEM;
|
||||
|
||||
isconsole = node == fbnode && fbconstty != NULL;
|
||||
name = getpropstring(node, "model");
|
||||
|
||||
/* Assume `bwtwo at sbus' only happens at sun4c's */
|
||||
sc->sc_get_video = bwtwo_get_video_sun4c;
|
||||
sc->sc_set_video = bwtwo_set_video_sun4c;
|
||||
|
||||
sc->sc_fb.fb_pixels = sa->sa_promvaddr;
|
||||
if (isconsole && sc->sc_fb.fb_pixels == NULL) {
|
||||
int ramsize = fb->fb_type.fb_height * fb->fb_linebytes;
|
||||
if (sbus_bus_map(sa->sa_bustag, sa->sa_slot,
|
||||
sa->sa_offset + sc->sc_pixeloffset,
|
||||
ramsize,
|
||||
BUS_SPACE_MAP_LINEAR,
|
||||
0, &bh) != 0) {
|
||||
printf("%s: cannot map pixels\n", self->dv_xname);
|
||||
return;
|
||||
}
|
||||
sc->sc_fb.fb_pixels = (char *)bh;
|
||||
}
|
||||
|
||||
sbus_establish(&sc->sc_sd, &sc->sc_dev);
|
||||
bwtwoattach(sc, name, isconsole, node == fbnode);
|
||||
}
|
||||
|
||||
void
|
||||
bwtwoattach_obio(parent, self, uax)
|
||||
struct device *parent, *self;
|
||||
void *uax;
|
||||
{
|
||||
struct bwtwo_softc *sc = (struct bwtwo_softc *)self;
|
||||
union obio_attach_args *uoba = uax;
|
||||
struct obio4_attach_args *oba;
|
||||
struct fbdevice *fb = &sc->sc_fb;
|
||||
struct eeprom *eep = (struct eeprom *)eeprom_va;
|
||||
bus_space_handle_t bh;
|
||||
int constype, isconsole;
|
||||
char *name;
|
||||
|
||||
if (uoba->uoba_isobio4 == 0) {
|
||||
bwtwoattach_sbus(parent, self, &uoba->uoba_sbus);
|
||||
return;
|
||||
}
|
||||
|
||||
oba = &uoba->uoba_oba4;
|
||||
|
||||
/* Remember cookies for bwtwo_mmap() */
|
||||
sc->sc_bustag = oba->oba_bustag;
|
||||
sc->sc_btype = (bus_type_t)0;
|
||||
sc->sc_paddr = (bus_addr_t)oba->oba_paddr;
|
||||
|
||||
fb->fb_flags = sc->sc_dev.dv_cfdata->cf_flags;
|
||||
fb->fb_type.fb_depth = 1;
|
||||
fb_setsize_eeprom(fb, fb->fb_type.fb_depth, 1152, 900);
|
||||
|
||||
constype = (fb->fb_flags & FB_PFOUR) ? EE_CONS_P4OPT : EE_CONS_BW;
|
||||
if (eep == NULL || eep->eeConsole == constype)
|
||||
isconsole = (fbconstty != NULL);
|
||||
else
|
||||
isconsole = 0;
|
||||
|
||||
if (fb->fb_flags & FB_PFOUR) {
|
||||
/*
|
||||
* Map the pfour control register.
|
||||
* Set pixel offset to appropriate overlay plane.
|
||||
*/
|
||||
name = "bwtwo/p4";
|
||||
|
||||
if (obio_bus_map(oba->oba_bustag,
|
||||
oba->oba_paddr,
|
||||
0,
|
||||
sizeof(u_int32_t),
|
||||
BUS_SPACE_MAP_LINEAR,
|
||||
0, &bh) != 0) {
|
||||
printf("%s: cannot map pfour register\n",
|
||||
self->dv_xname);
|
||||
return;
|
||||
}
|
||||
fb->fb_pfour = (u_int32_t *)bh;
|
||||
sc->sc_reg = NULL;
|
||||
|
||||
/*
|
||||
* Notice if this is an overlay plane on a color
|
||||
* framebuffer. Note that PFOUR_COLOR_OFF_OVERLAY
|
||||
* is the same as PFOUR_BW_OFF, but we use the
|
||||
* different names anyway.
|
||||
*/
|
||||
switch (PFOUR_ID(*fb->fb_pfour)) {
|
||||
case PFOUR_ID_COLOR8P1:
|
||||
sc->sc_ovtype = BWO_CGFOUR;
|
||||
sc->sc_pixeloffset = PFOUR_COLOR_OFF_OVERLAY;
|
||||
break;
|
||||
|
||||
case PFOUR_ID_COLOR24:
|
||||
sc->sc_ovtype = BWO_CGEIGHT;
|
||||
sc->sc_pixeloffset = PFOUR_COLOR_OFF_OVERLAY;
|
||||
break;
|
||||
|
||||
default:
|
||||
sc->sc_ovtype = BWO_NONE;
|
||||
sc->sc_pixeloffset = PFOUR_BW_OFF;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
/* A plain bwtwo */
|
||||
if (obio_bus_map(oba->oba_bustag,
|
||||
oba->oba_paddr,
|
||||
BWREG_REG,
|
||||
sizeof(struct fbcontrol),
|
||||
BUS_SPACE_MAP_LINEAR,
|
||||
0, &bh) != 0) {
|
||||
printf("%s: cannot map control registers\n",
|
||||
self->dv_xname);
|
||||
return;
|
||||
}
|
||||
sc->sc_reg = (struct fbcontrol *)bh;
|
||||
fb->fb_pfour = NULL;
|
||||
|
||||
name = "bwtwo";
|
||||
sc->sc_pixeloffset = BWREG_MEM;
|
||||
}
|
||||
sc->sc_get_video = bwtwo_get_video_sun4;
|
||||
sc->sc_set_video = bwtwo_set_video_sun4;
|
||||
|
||||
if (isconsole) {
|
||||
int ramsize = fb->fb_type.fb_height * fb->fb_linebytes;
|
||||
if (obio_bus_map(oba->oba_bustag, oba->oba_paddr,
|
||||
sc->sc_pixeloffset,
|
||||
ramsize,
|
||||
BUS_SPACE_MAP_LINEAR,
|
||||
0, &bh) != 0) {
|
||||
printf("%s: cannot map pixels\n", self->dv_xname);
|
||||
return;
|
||||
}
|
||||
sc->sc_fb.fb_pixels = (char *)bh;
|
||||
}
|
||||
|
||||
bwtwoattach(sc, name, isconsole, 1);
|
||||
}
|
||||
|
||||
void
|
||||
bwtwoattach(sc, name, isconsole, isfb)
|
||||
struct bwtwo_softc *sc;
|
||||
char *name;
|
||||
int isconsole;
|
||||
int isfb;
|
||||
{
|
||||
struct fbdevice *fb = &sc->sc_fb;
|
||||
|
||||
/* Fill in the remaining fbdevice values */
|
||||
fb->fb_driver = &bwtwofbdriver;
|
||||
fb->fb_device = &sc->sc_dev;
|
||||
fb->fb_type.fb_type = FBTYPE_SUN2BW;
|
||||
fb->fb_type.fb_cmsize = 0;
|
||||
fb->fb_type.fb_size = fb->fb_type.fb_height * fb->fb_linebytes;
|
||||
printf(": %s, %d x %d", name,
|
||||
fb->fb_type.fb_width, fb->fb_type.fb_height);
|
||||
|
||||
/* Insure video is enabled */
|
||||
bwtwo_set_video(sc, 1);
|
||||
sc->sc_set_video(sc, 1);
|
||||
|
||||
if (isconsole) {
|
||||
printf(" (console)\n");
|
||||
#ifdef RASTERCONSOLE
|
||||
#if defined(SUN4)
|
||||
/*
|
||||
* XXX rcons doesn't seem to work properly on the overlay
|
||||
* XXX plane. This is a temporary kludge until someone
|
||||
|
@ -363,18 +446,11 @@ bwtwoattach(parent, self, args)
|
|||
*/
|
||||
if ((fb->fb_flags & FB_PFOUR) == 0 ||
|
||||
(sc->sc_ovtype == BWO_NONE))
|
||||
#endif
|
||||
fbrcons_init(fb);
|
||||
#endif
|
||||
} else
|
||||
printf("\n");
|
||||
|
||||
#if defined(SUN4C) || defined(SUN4M)
|
||||
if (sbus)
|
||||
sbus_establish(&sc->sc_sd, &sc->sc_dev);
|
||||
#endif
|
||||
|
||||
#if defined(SUN4)
|
||||
if ((fb->fb_flags & FB_PFOUR) && (sc->sc_ovtype != BWO_NONE)) {
|
||||
char *ovnam;
|
||||
|
||||
|
@ -393,10 +469,8 @@ bwtwoattach(parent, self, args)
|
|||
}
|
||||
printf("%s: %s overlay plane\n", sc->sc_dev.dv_xname, ovnam);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (CPU_ISSUN4 || node == fbnode) {
|
||||
#if defined(SUN4)
|
||||
if (isfb) {
|
||||
/*
|
||||
* If we're on an overlay plane of a color framebuffer,
|
||||
* then we don't force the issue in fb_attach() because
|
||||
|
@ -407,11 +481,11 @@ bwtwoattach(parent, self, args)
|
|||
if ((fb->fb_flags & FB_PFOUR) && (sc->sc_ovtype != BWO_NONE ))
|
||||
fb_attach(fb, 0);
|
||||
else
|
||||
#endif
|
||||
fb_attach(fb, isconsole);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
bwtwoopen(dev, flags, mode, p)
|
||||
dev_t dev;
|
||||
|
@ -453,11 +527,11 @@ bwtwoioctl(dev, cmd, data, flags, p)
|
|||
break;
|
||||
|
||||
case FBIOGVIDEO:
|
||||
*(int *)data = bwtwo_get_video(sc);
|
||||
*(int *)data = sc->sc_get_video(sc);
|
||||
break;
|
||||
|
||||
case FBIOSVIDEO:
|
||||
bwtwo_set_video(sc, (*(int *)data));
|
||||
sc->sc_set_video(sc, (*(int *)data));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -472,7 +546,7 @@ bwtwounblank(dev)
|
|||
{
|
||||
struct bwtwo_softc *sc = (struct bwtwo_softc *)dev;
|
||||
|
||||
bwtwo_set_video(sc, 1);
|
||||
sc->sc_set_video(sc, 1);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -498,64 +572,69 @@ bwtwommap(dev, off, prot)
|
|||
|
||||
if (off & PGOFSET)
|
||||
panic("bwtwommap");
|
||||
|
||||
if ((unsigned)off >= sc->sc_fb.fb_type.fb_size)
|
||||
return (-1);
|
||||
/*
|
||||
* I turned on PMAP_NC here to disable the cache as I was
|
||||
* getting horribly broken behaviour with it on.
|
||||
*/
|
||||
return (REG2PHYS(&sc->sc_phys, sc->sc_pixeloffset + off) | PMAP_NC);
|
||||
|
||||
return (bus_space_mmap (sc->sc_bustag,
|
||||
sc->sc_btype,
|
||||
sc->sc_paddr + sc->sc_pixeloffset + off,
|
||||
BUS_SPACE_MAP_LINEAR));
|
||||
}
|
||||
|
||||
static int
|
||||
bwtwo_get_video(sc)
|
||||
bwtwo_get_video_sun4c(sc)
|
||||
struct bwtwo_softc *sc;
|
||||
{
|
||||
|
||||
#if defined(SUN4)
|
||||
if (CPU_ISSUN4 && (sc->sc_bustype == BUS_OBIO)) {
|
||||
if (sc->sc_fb.fb_flags & FB_PFOUR) {
|
||||
/*
|
||||
* This handles the overlay plane case, too.
|
||||
*/
|
||||
return (fb_pfour_get_video(&sc->sc_fb));
|
||||
} else
|
||||
return ((lduba(AC_SYSENABLE,
|
||||
ASI_CONTROL) & SYSEN_VIDEO) != 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ((sc->sc_reg->fbc_ctrl & FBC_VENAB) != 0);
|
||||
}
|
||||
|
||||
static int
|
||||
bwtwo_get_video_sun4(sc)
|
||||
struct bwtwo_softc *sc;
|
||||
{
|
||||
|
||||
if (sc->sc_fb.fb_flags & FB_PFOUR) {
|
||||
/*
|
||||
* This handles the overlay plane case, too.
|
||||
*/
|
||||
return (fb_pfour_get_video(&sc->sc_fb));
|
||||
} else
|
||||
return ((lduba(AC_SYSENABLE, ASI_CONTROL) & SYSEN_VIDEO) != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
bwtwo_set_video(sc, enable)
|
||||
bwtwo_set_video_sun4c(sc, enable)
|
||||
struct bwtwo_softc *sc;
|
||||
int enable;
|
||||
{
|
||||
|
||||
#if defined(SUN4)
|
||||
if (CPU_ISSUN4 && (sc->sc_bustype == BUS_OBIO)) {
|
||||
if (sc->sc_fb.fb_flags & FB_PFOUR) {
|
||||
/*
|
||||
* This handles the overlay plane case, too.
|
||||
*/
|
||||
fb_pfour_set_video(&sc->sc_fb, enable);
|
||||
return;
|
||||
}
|
||||
if (enable)
|
||||
stba(AC_SYSENABLE, ASI_CONTROL,
|
||||
lduba(AC_SYSENABLE, ASI_CONTROL) | SYSEN_VIDEO);
|
||||
else
|
||||
stba(AC_SYSENABLE, ASI_CONTROL,
|
||||
lduba(AC_SYSENABLE, ASI_CONTROL) & ~SYSEN_VIDEO);
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (enable)
|
||||
sc->sc_reg->fbc_ctrl |= FBC_VENAB;
|
||||
else
|
||||
sc->sc_reg->fbc_ctrl &= ~FBC_VENAB;
|
||||
}
|
||||
|
||||
static void
|
||||
bwtwo_set_video_sun4(sc, enable)
|
||||
struct bwtwo_softc *sc;
|
||||
int enable;
|
||||
{
|
||||
|
||||
if (sc->sc_fb.fb_flags & FB_PFOUR) {
|
||||
/*
|
||||
* This handles the overlay plane case, too.
|
||||
*/
|
||||
fb_pfour_set_video(&sc->sc_fb, enable);
|
||||
return;
|
||||
}
|
||||
if (enable)
|
||||
stba(AC_SYSENABLE, ASI_CONTROL,
|
||||
lduba(AC_SYSENABLE, ASI_CONTROL) | SYSEN_VIDEO);
|
||||
else
|
||||
stba(AC_SYSENABLE, ASI_CONTROL,
|
||||
lduba(AC_SYSENABLE, ASI_CONTROL) & ~SYSEN_VIDEO);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: zs.c,v 1.56 1998/01/21 05:54:39 mrg Exp $ */
|
||||
/* $NetBSD: zs.c,v 1.57 1998/03/21 20:24:11 pk Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
|
@ -168,16 +168,16 @@ struct zschan *
|
|||
zs_get_chan_addr(zs_unit, channel)
|
||||
int zs_unit, channel;
|
||||
{
|
||||
struct zsdevice *addr;
|
||||
struct zschan *zc;
|
||||
struct zsdevice *addr;
|
||||
struct zschan *zc;
|
||||
|
||||
if (zs_unit >= NZS)
|
||||
return NULL;
|
||||
return (NULL);
|
||||
addr = zsaddr[zs_unit];
|
||||
if (addr == NULL)
|
||||
addr = zsaddr[zs_unit] = findzs(zs_unit);
|
||||
if (addr == NULL)
|
||||
return NULL;
|
||||
return (NULL);
|
||||
if (channel == 0) {
|
||||
zc = &addr->zs_chan_a;
|
||||
} else {
|
||||
|
@ -192,12 +192,20 @@ zs_get_chan_addr(zs_unit, channel)
|
|||
****************************************************************/
|
||||
|
||||
/* Definition of the driver for autoconfig. */
|
||||
static int zs_match __P((struct device *, struct cfdata *, void *));
|
||||
static void zs_attach __P((struct device *, struct device *, void *));
|
||||
static int zs_match_mainbus __P((struct device *, struct cfdata *, void *));
|
||||
static int zs_match_obio __P((struct device *, struct cfdata *, void *));
|
||||
static void zs_attach_mainbus __P((struct device *, struct device *, void *));
|
||||
static void zs_attach_obio __P((struct device *, struct device *, void *));
|
||||
|
||||
static void zs_attach __P((struct zsc_softc *, int));
|
||||
static int zs_print __P((void *, const char *name));
|
||||
|
||||
struct cfattach zs_ca = {
|
||||
sizeof(struct zsc_softc), zs_match, zs_attach
|
||||
struct cfattach zs_mainbus_ca = {
|
||||
sizeof(struct zsc_softc), zs_match_mainbus, zs_attach_mainbus
|
||||
};
|
||||
|
||||
struct cfattach zs_obio_ca = {
|
||||
sizeof(struct zsc_softc), zs_match_obio, zs_attach_obio
|
||||
};
|
||||
|
||||
extern struct cfdriver zs_cd;
|
||||
|
@ -205,7 +213,6 @@ extern struct cfdriver zs_cd;
|
|||
/* Interrupt handlers. */
|
||||
static int zshard __P((void *));
|
||||
static int zssoft __P((void *));
|
||||
static struct intrhand levelhard = { zshard };
|
||||
static struct intrhand levelsoft = { zssoft };
|
||||
|
||||
static int zs_get_speed __P((struct zs_chanstate *));
|
||||
|
@ -215,23 +222,90 @@ static int zs_get_speed __P((struct zs_chanstate *));
|
|||
* Is the zs chip present?
|
||||
*/
|
||||
static int
|
||||
zs_match(parent, cf, aux)
|
||||
zs_match_mainbus(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
{
|
||||
struct confargs *ca = aux;
|
||||
struct romaux *ra = &ca->ca_ra;
|
||||
struct mainbus_attach_args *ma = aux;
|
||||
|
||||
if (strcmp(cf->cf_driver->cd_name, ra->ra_name))
|
||||
if (strcmp(cf->cf_driver->cd_name, ma->ma_name) != 0)
|
||||
return (0);
|
||||
if ((ca->ca_bustype == BUS_MAIN && !CPU_ISSUN4) ||
|
||||
(ca->ca_bustype == BUS_OBIO && CPU_ISSUN4M))
|
||||
return (getpropint(ra->ra_node, "slave", -2) == cf->cf_unit);
|
||||
ra->ra_len = NBPG;
|
||||
return (probeget(ra->ra_vaddr, 1) != -1);
|
||||
|
||||
return (getpropint(ma->ma_node, "slave", -2) == cf->cf_unit);
|
||||
}
|
||||
|
||||
static int
|
||||
zs_match_obio(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
{
|
||||
union obio_attach_args *uoba = aux;
|
||||
struct obio4_attach_args *oba;
|
||||
|
||||
if (uoba->uoba_isobio4 == 0) {
|
||||
struct sbus_attach_args *sa = &uoba->uoba_sbus;
|
||||
|
||||
if (strcmp(cf->cf_driver->cd_name, sa->sa_name) != 0)
|
||||
return (0);
|
||||
|
||||
return (getpropint(sa->sa_node, "slave", -2) == cf->cf_unit);
|
||||
}
|
||||
|
||||
oba = &uoba->uoba_oba4;
|
||||
return (obio_bus_probe(oba->oba_bustag, oba->oba_paddr,
|
||||
0, 1, NULL, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
zs_attach_mainbus(parent, self, aux)
|
||||
struct device *parent;
|
||||
struct device *self;
|
||||
void *aux;
|
||||
{
|
||||
struct zsc_softc *zsc = (void *) self;
|
||||
struct mainbus_attach_args *ma = aux;
|
||||
int zs_unit = zsc->zsc_dev.dv_unit;
|
||||
|
||||
zsc->zsc_bustag = ma->ma_bustag;
|
||||
zsc->zsc_dmatag = ma->ma_dmatag;
|
||||
|
||||
/* Use the mapping setup by the Sun PROM. */
|
||||
if (zsaddr[zs_unit] == NULL)
|
||||
zsaddr[zs_unit] = findzs(zs_unit);
|
||||
if ((void*)zsaddr[zs_unit] != ma->ma_promvaddr)
|
||||
panic("zsattach_mainbus");
|
||||
|
||||
zs_attach(zsc, ma->ma_pri);
|
||||
}
|
||||
|
||||
static void
|
||||
zs_attach_obio(parent, self, aux)
|
||||
struct device *parent;
|
||||
struct device *self;
|
||||
void *aux;
|
||||
{
|
||||
struct zsc_softc *zsc = (void *) self;
|
||||
union obio_attach_args *uoba = aux;
|
||||
int zs_unit = zsc->zsc_dev.dv_unit;
|
||||
|
||||
/* Use the mapping setup by the Sun PROM. */
|
||||
if (zsaddr[zs_unit] == NULL)
|
||||
zsaddr[zs_unit] = findzs(zs_unit);
|
||||
|
||||
if (uoba->uoba_isobio4 == 0) {
|
||||
struct sbus_attach_args *sa = &uoba->uoba_sbus;
|
||||
zsc->zsc_bustag = sa->sa_bustag;
|
||||
zsc->zsc_dmatag = sa->sa_dmatag;
|
||||
zs_attach(zsc, sa->sa_pri);
|
||||
} else {
|
||||
struct obio4_attach_args *oba = &uoba->uoba_oba4;
|
||||
zsc->zsc_bustag = oba->oba_bustag;
|
||||
zsc->zsc_dmatag = oba->oba_dmatag;
|
||||
zs_attach(zsc, oba->oba_pri);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Attach a found zs.
|
||||
*
|
||||
|
@ -239,39 +313,22 @@ zs_match(parent, cf, aux)
|
|||
* SOFT CARRIER, AND keyboard PROPERTY FOR KEYBOARD/MOUSE?
|
||||
*/
|
||||
static void
|
||||
zs_attach(parent, self, aux)
|
||||
struct device *parent;
|
||||
struct device *self;
|
||||
void *aux;
|
||||
zs_attach(zsc, pri)
|
||||
struct zsc_softc *zsc;
|
||||
int pri;
|
||||
{
|
||||
struct zsc_softc *zsc = (void *) self;
|
||||
struct confargs *ca = aux;
|
||||
struct romaux *ra = &ca->ca_ra;
|
||||
struct zsc_attach_args zsc_args;
|
||||
volatile struct zschan *zc;
|
||||
struct zs_chanstate *cs;
|
||||
int pri, s, zs_unit, channel;
|
||||
int s, zs_unit, channel;
|
||||
static int didintr, prevpri;
|
||||
|
||||
zs_unit = zsc->zsc_dev.dv_unit;
|
||||
|
||||
/* Use the mapping setup by the Sun PROM. */
|
||||
if (zsaddr[zs_unit] == NULL)
|
||||
zsaddr[zs_unit] = findzs(zs_unit);
|
||||
|
||||
if (ca->ca_bustype==BUS_MAIN)
|
||||
if ((void*)zsaddr[zs_unit] != ra->ra_vaddr)
|
||||
panic("zsattach");
|
||||
if (ra->ra_nintr != 1) {
|
||||
printf(": expected 1 interrupt, got %d\n", ra->ra_nintr);
|
||||
return;
|
||||
}
|
||||
pri = ra->ra_intr[0].int_pri;
|
||||
printf(" pri %d, softpri %d\n", pri, PIL_TTY);
|
||||
printf(" softpri %d\n", PIL_TTY);
|
||||
|
||||
/*
|
||||
* Initialize software state for each channel.
|
||||
*/
|
||||
zs_unit = zsc->zsc_dev.dv_unit;
|
||||
for (channel = 0; channel < 2; channel++) {
|
||||
zsc_args.channel = channel;
|
||||
zsc_args.hwflags = zs_hwflags[zs_unit][channel];
|
||||
|
@ -321,7 +378,7 @@ zs_attach(parent, self, aux)
|
|||
* Look for a child driver for this channel.
|
||||
* The child attach will setup the hardware.
|
||||
*/
|
||||
if (!config_found(self, (void *)&zsc_args, zs_print)) {
|
||||
if (!config_found(&zsc->zsc_dev, (void *)&zsc_args, zs_print)) {
|
||||
/* No sub-driver. Just reset it. */
|
||||
u_char reset = (channel == 0) ?
|
||||
ZSWR9_A_RESET : ZSWR9_B_RESET;
|
||||
|
@ -339,10 +396,11 @@ zs_attach(parent, self, aux)
|
|||
if (!didintr) {
|
||||
didintr = 1;
|
||||
prevpri = pri;
|
||||
intr_establish(pri, &levelhard);
|
||||
bus_intr_establish(zsc->zsc_bustag, pri, 0, zshard, NULL);
|
||||
intr_establish(PIL_TTY, &levelsoft);
|
||||
} else if (pri != prevpri)
|
||||
panic("broken zs interrupt scheme");
|
||||
|
||||
evcnt_attach(&zsc->zsc_dev, "intr", &zsc->zsc_intrcnt);
|
||||
|
||||
/*
|
||||
|
@ -384,7 +442,7 @@ zs_print(aux, name)
|
|||
if (args->channel != -1)
|
||||
printf(" channel %d", args->channel);
|
||||
|
||||
return UNCONF;
|
||||
return (UNCONF);
|
||||
}
|
||||
|
||||
static volatile int zssoftpending;
|
||||
|
@ -572,7 +630,7 @@ zs_read_reg(cs, reg)
|
|||
ZS_DELAY();
|
||||
val = *cs->cs_reg_csr;
|
||||
ZS_DELAY();
|
||||
return val;
|
||||
return (val);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -594,7 +652,7 @@ zs_read_csr(cs)
|
|||
|
||||
val = *cs->cs_reg_csr;
|
||||
ZS_DELAY();
|
||||
return val;
|
||||
return (val);
|
||||
}
|
||||
|
||||
void zs_write_csr(cs, val)
|
||||
|
@ -612,7 +670,7 @@ u_char zs_read_data(cs)
|
|||
|
||||
val = *cs->cs_reg_data;
|
||||
ZS_DELAY();
|
||||
return val;
|
||||
return (val);
|
||||
}
|
||||
|
||||
void zs_write_data(cs, val)
|
||||
|
|
Loading…
Reference in New Issue