1998-05-23 01:14:40 +04:00
|
|
|
/* $NetBSD: tc_subr.c,v 1.21 1998/05/22 21:14:40 thorpej Exp $ */
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1996 The Board of Trustees of The Leland Stanford
|
|
|
|
* Junior University. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose and without
|
|
|
|
* fee is hereby granted, provided that the above copyright
|
|
|
|
* notice appear in all copies. Stanford University
|
|
|
|
* makes no representations about the suitability of this
|
|
|
|
* software for any purpose. It is provided "as is" without
|
|
|
|
* express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
1997-11-08 10:15:35 +03:00
|
|
|
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
1998-05-23 01:14:40 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: tc_subr.c,v 1.21 1998/05/22 21:14:40 thorpej Exp $");
|
1997-11-08 10:15:35 +03:00
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
1998-05-23 01:14:40 +04:00
|
|
|
#include <sys/systm.h>
|
1996-02-28 01:28:08 +03:00
|
|
|
#include <sys/device.h>
|
|
|
|
#include <dev/cons.h>
|
1998-05-23 01:14:40 +04:00
|
|
|
|
1996-02-28 01:28:08 +03:00
|
|
|
#include <machine/autoconf.h>
|
1998-04-19 11:59:13 +04:00
|
|
|
#include <machine/sysconf.h>
|
1996-02-28 01:28:08 +03:00
|
|
|
|
1998-05-23 01:14:40 +04:00
|
|
|
#define _PMAX_BUS_DMA_PRIVATE
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
#include <dev/tc/tcvar.h>
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
#include <pmax/pmax/pmaxtype.h>
|
1996-02-28 01:28:08 +03:00
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
#ifndef NULL
|
|
|
|
#define NULL 0
|
|
|
|
#endif
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TurboChannel autoconfiguration declarations and tables for DECstations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <pmax/pmax/pmaxtype.h>
|
|
|
|
#include <pmax/pmax/asic.h>
|
|
|
|
|
|
|
|
#include <pmax/pmax/turbochannel.h>
|
|
|
|
|
1997-05-24 13:17:24 +04:00
|
|
|
#include <machine/fbio.h>
|
|
|
|
#include <machine/fbvar.h>
|
|
|
|
#include <pmax/dev/cfbvar.h>
|
|
|
|
#include <pmax/dev/mfbvar.h>
|
|
|
|
#include <pmax/dev/sfbvar.h>
|
|
|
|
#include <pmax/dev/xcfbvar.h>
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
/*
|
|
|
|
* Which system models were configured?
|
|
|
|
*/
|
1998-03-25 09:22:19 +03:00
|
|
|
#include "opt_dec_3max.h"
|
|
|
|
#include "opt_dec_3min.h"
|
|
|
|
#include "opt_dec_3maxplus.h"
|
|
|
|
#include "opt_dec_maxine.h"
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
/*
|
|
|
|
* Which TC framebuffers were drivers configured for?
|
|
|
|
* Used for configuring a console device.
|
|
|
|
*/
|
1997-05-24 13:17:24 +04:00
|
|
|
#include "cfb.h"
|
|
|
|
#include "mfb.h"
|
|
|
|
#include "sfb.h"
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
#ifdef notyet
|
|
|
|
#include "px.h"
|
|
|
|
#include "pxg.h"
|
|
|
|
#endif
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
/*
|
1998-04-19 11:59:13 +04:00
|
|
|
* Tables for table-driven TC and console configuration.
|
1996-02-28 01:28:08 +03:00
|
|
|
*/
|
1998-04-19 11:59:13 +04:00
|
|
|
struct fbinfo;
|
|
|
|
struct tcfbsw {
|
1998-04-20 06:46:59 +04:00
|
|
|
const char fbsw_name[TC_ROM_LLEN+1];
|
1998-04-19 11:59:13 +04:00
|
|
|
int (*fbsw_initfn) __P((struct fbinfo*, char*, int, int));
|
1996-02-28 01:28:08 +03:00
|
|
|
};
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
#define tcfbsw_entry(tcname, initfn) { tcname, initfn }
|
1996-02-28 01:28:08 +03:00
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
const struct tcfbsw tcfbsw[] = {
|
1996-02-28 01:28:08 +03:00
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
#if NMFB > 0
|
1998-04-20 06:46:59 +04:00
|
|
|
tcfbsw_entry("PMAG-AA ", mfbinit),
|
1998-04-19 11:59:13 +04:00
|
|
|
#endif
|
1996-02-28 01:28:08 +03:00
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
#if NSFB > 0
|
|
|
|
tcfbsw_entry("PMAGB-BA", sfbinit),
|
|
|
|
#endif
|
1996-02-28 01:28:08 +03:00
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
#if NCFB > 0
|
|
|
|
tcfbsw_entry("PMAG-BA ", cfbinit),
|
|
|
|
#endif
|
1998-04-20 06:46:59 +04:00
|
|
|
|
|
|
|
#if NPX > 0
|
|
|
|
tcfbsw_entry("PMAG-CA", pxinit),
|
|
|
|
tcfbsw_entry("PMAG-C ", pxinit),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NPXG > 0
|
|
|
|
tcfbsw_entry("PMAG-DA", pxginit),
|
|
|
|
tcfbsw_entry("PMAG-E ", pxginit),
|
|
|
|
tcfbsw_entry("PMAG-F ", pxginit),
|
|
|
|
tcfbsw_entry("PMAG-FA", pxginit),
|
|
|
|
#endif
|
1996-02-28 01:28:08 +03:00
|
|
|
};
|
1998-04-19 11:59:13 +04:00
|
|
|
const int ntcfbsw = sizeof(tcfbsw) / sizeof(tcfbsw[0]);
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
1998-04-19 11:59:13 +04:00
|
|
|
* Find a tc graphcis console device.
|
1996-02-28 01:28:08 +03:00
|
|
|
*/
|
1998-04-19 11:59:13 +04:00
|
|
|
extern int tc_findconsole __P((int prom_slot));
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
/*
|
|
|
|
* Local forward declarations
|
|
|
|
*/
|
|
|
|
extern struct tcbus_attach_args * cpu_tcdesc __P ((int systype));
|
1996-02-28 01:28:08 +03:00
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
static int tc_consprobeslot __P((tc_addr_t slotaddr));
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
/*
|
|
|
|
* DECstation tc implementations dont' have a tcasic to handle interrupts,
|
|
|
|
* and the mapping to CPU interrupt lines is model-dpeendent.
|
|
|
|
* We have to pass TC interrupt establish/disestablish requests up to
|
|
|
|
* motherboard-specific code.
|
|
|
|
*/
|
|
|
|
void tc_ds_intr_establish __P((struct device *, void *, tc_intrlevel_t,
|
|
|
|
intr_handler_t handler, intr_arg_t arg));
|
|
|
|
void tc_ds_intr_disestablish __P((struct device *dev, void *cookie));
|
1996-02-28 01:28:08 +03:00
|
|
|
|
1998-05-23 01:14:40 +04:00
|
|
|
bus_dma_tag_t tc_ds_get_dma_tag __P((int));
|
1996-02-28 01:28:08 +03:00
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
/* XXX*/
|
|
|
|
typedef int (*tc_handler_t) __P((void *intr_arg));
|
|
|
|
extern void (*tc_enable_interrupt) __P ((u_int slotno, tc_handler_t,
|
|
|
|
void *intr_arg, int on));
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
/*
|
1998-04-19 11:59:13 +04:00
|
|
|
* Map from systype code to a tcbus_attach_args struct.
|
|
|
|
* XXX make table-driven.
|
1996-02-28 01:28:08 +03:00
|
|
|
*/
|
|
|
|
struct tcbus_attach_args *
|
|
|
|
cpu_tcdesc(cpu)
|
|
|
|
int cpu;
|
|
|
|
{
|
1998-04-19 11:59:13 +04:00
|
|
|
switch (cpu) {
|
|
|
|
|
1998-03-25 09:22:19 +03:00
|
|
|
#ifdef DEC_3MAXPLUS
|
1998-04-19 11:59:13 +04:00
|
|
|
case DS_3MAXPLUS: {
|
|
|
|
extern struct tcbus_attach_args kn03_tc_desc[];
|
|
|
|
|
|
|
|
return &kn03_tc_desc[0];
|
|
|
|
}
|
1998-03-25 09:22:19 +03:00
|
|
|
#endif /* DEC_3MAXPLUS */
|
1998-04-19 11:59:13 +04:00
|
|
|
|
1998-03-25 09:22:19 +03:00
|
|
|
#ifdef DEC_3MAX
|
1998-04-19 11:59:13 +04:00
|
|
|
case DS_3MAX: {
|
|
|
|
extern struct tcbus_attach_args kn02_tc_desc[];
|
|
|
|
return &kn02_tc_desc[0];
|
|
|
|
}
|
1998-03-25 09:22:19 +03:00
|
|
|
#endif /* DEC_3MAX */
|
1998-04-19 11:59:13 +04:00
|
|
|
|
1998-03-25 09:22:19 +03:00
|
|
|
#ifdef DEC_3MIN
|
1998-04-19 11:59:13 +04:00
|
|
|
case DS_3MIN: {
|
|
|
|
extern struct tcbus_attach_args kmin_tc_desc[];
|
|
|
|
return &kmin_tc_desc[0];
|
|
|
|
}
|
1998-03-25 09:22:19 +03:00
|
|
|
#endif /*DEC_3MIN*/
|
1998-04-19 11:59:13 +04:00
|
|
|
|
1998-03-25 09:22:19 +03:00
|
|
|
#ifdef DEC_MAXINE
|
1998-04-19 11:59:13 +04:00
|
|
|
case DS_MAXINE: {
|
|
|
|
extern struct tcbus_attach_args xine_tc_desc[];
|
|
|
|
return xine_tc_desc;
|
|
|
|
}
|
1998-03-25 09:22:19 +03:00
|
|
|
#endif /*DEC_MAXINE*/
|
1998-04-19 11:59:13 +04:00
|
|
|
|
|
|
|
default:
|
1996-02-28 01:28:08 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
1998-04-19 11:59:13 +04:00
|
|
|
printf("tcattach: systype %d, no turbochannel\n", cpu);
|
1996-02-28 01:28:08 +03:00
|
|
|
return NULL;
|
1998-04-19 11:59:13 +04:00
|
|
|
#endif /*DIAGNOSTIC*/
|
|
|
|
panic("cpu_tc: system type 0x%x, no TurboChannel configured\n",
|
|
|
|
cpu);
|
1996-02-28 01:28:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
|
1996-02-28 01:28:08 +03:00
|
|
|
/*
|
|
|
|
* We have a TurboChannel bus. Configure it.
|
|
|
|
*/
|
|
|
|
void
|
1998-03-25 09:22:19 +03:00
|
|
|
config_tcbus(parent, systype, printfn)
|
1996-02-28 01:28:08 +03:00
|
|
|
struct device *parent;
|
1998-03-25 09:22:19 +03:00
|
|
|
int systype;
|
1996-08-28 01:53:46 +04:00
|
|
|
int printfn __P((void *, const char *));
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
{
|
|
|
|
struct tcbus_attach_args tcb;
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
struct tcbus_attach_args * tcbus = cpu_tcdesc(systype);
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
if (tcbus == NULL) {
|
1996-10-13 07:39:27 +04:00
|
|
|
printf("no TurboChannel configuration info for this machine\n");
|
1996-02-28 01:28:08 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up important CPU/chipset information.
|
|
|
|
*/
|
|
|
|
tcb.tba_busname = tcbus->tba_busname;
|
1998-05-23 01:14:40 +04:00
|
|
|
tcb.tba_memt = 0; /* XXX ignored for now */
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
tcb.tba_speed = tcbus->tba_speed;
|
|
|
|
tcb.tba_nslots = tcbus->tba_nslots;
|
|
|
|
tcb.tba_slots = tcbus->tba_slots;
|
|
|
|
|
|
|
|
tcb.tba_nbuiltins = tcbus->tba_nbuiltins;
|
|
|
|
tcb.tba_builtins = tcbus->tba_builtins;
|
1998-04-19 11:59:13 +04:00
|
|
|
tcb.tba_intr_establish = tc_ds_intr_establish;
|
|
|
|
tcb.tba_intr_disestablish = tc_ds_intr_disestablish;
|
1998-05-23 01:14:40 +04:00
|
|
|
tcb.tba_get_dma_tag = tc_ds_get_dma_tag;
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
config_found(parent, (struct confargs*)&tcb, printfn);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1998-04-19 11:59:13 +04:00
|
|
|
* Establish an interrupt handler.
|
|
|
|
* For both TC and IOCTL asic, we must upcall to motherboard-specific
|
|
|
|
* interrupt-hanlder functions, in case we need to recompute masks for
|
|
|
|
* CPU interrupt lines.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
tc_ds_intr_establish(dev, cookie, level, handler, val)
|
|
|
|
struct device *dev;
|
|
|
|
void *cookie;
|
|
|
|
tc_intrlevel_t level;
|
|
|
|
intr_handler_t handler;
|
|
|
|
void *val;
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (tc_enable_interrupt == NULL)
|
|
|
|
panic("tc_intr_establish: tc_enable not set\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("tc_intr_establish: slot %d level %d handler %p sc %p on\n",
|
|
|
|
(int) cookie, (int) level, handler, val);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable the interrupt from tc (or ioctl asic) slot with NetBSD/pmax
|
|
|
|
* sw-convention name ``cookie'' on this CPU.
|
|
|
|
* XXX store the level somewhere for selective enabling of
|
|
|
|
* interrupts from TC option slots.
|
|
|
|
*/
|
|
|
|
(*tc_enable_interrupt) ((int)cookie, handler, val, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tc_ds_intr_disestablish(dev, arg)
|
|
|
|
struct device *dev;
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
/*(*tc_enable_interrupt) (ca->ca_slot, handler, 0);*/
|
|
|
|
printf("cannot dis-establish IOASIC interrupts\n");
|
|
|
|
}
|
1998-05-23 01:14:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the DMA tag for use by the specified TurboChannel slot.
|
|
|
|
*/
|
|
|
|
bus_dma_tag_t
|
|
|
|
tc_ds_get_dma_tag(slot)
|
|
|
|
int slot;
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All DECstations use the default DMA tag.
|
|
|
|
*/
|
|
|
|
return (&pmax_default_bus_dma_tag);
|
|
|
|
}
|
1998-04-19 11:59:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Console initialization --
|
1996-02-28 01:28:08 +03:00
|
|
|
* Called before autoconfiguration, to find a system console.
|
1998-04-19 11:59:13 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1996-02-28 01:28:08 +03:00
|
|
|
* Probe the turbochannel for a framebuffer option card, starting at
|
|
|
|
* the preferred slot and then scanning all slots. Configure the first
|
|
|
|
* supported framebuffer device found, if any, as the console, and
|
|
|
|
* return 1 if found.
|
1998-04-19 11:59:13 +04:00
|
|
|
* XXX knows about internals of TurboChannel bus autoconfig descriptor,
|
|
|
|
* which needs to be fixed badly.
|
1996-02-28 01:28:08 +03:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
tc_findconsole(preferred_slot)
|
|
|
|
int preferred_slot;
|
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
struct tcbus_attach_args *tc_desc;
|
1996-02-28 01:28:08 +03:00
|
|
|
|
|
|
|
/* First, try the slot configured as console in NVRAM. */
|
|
|
|
/* if (consprobeslot(preferred_slot)) return (1); */
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
if ((tc_desc = cpu_tcdesc(systype)) == NULL)
|
1996-02-28 01:28:08 +03:00
|
|
|
return 0;
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
/*
|
|
|
|
* Try to configure each turbochannel option or builtin framebuffer.
|
|
|
|
*/
|
|
|
|
for (slot = 0; slot < tc_desc->tba_nslots; slot++) {
|
|
|
|
if (tc_consprobeslot(tc_desc->tba_slots[slot].tcs_addr))
|
1996-02-28 01:28:08 +03:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look in a single TC option slot to see if it contains a possible
|
|
|
|
* framebuffer console device.
|
1998-04-19 11:59:13 +04:00
|
|
|
*
|
1996-02-28 01:28:08 +03:00
|
|
|
* Configure only the framebuffers for which driver are configured
|
|
|
|
* into the kernel. If a suitable framebuffer is found, initialize
|
|
|
|
* it, and set up glass-tty emulation.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
tc_consprobeslot(tc_slotaddr)
|
|
|
|
tc_addr_t tc_slotaddr;
|
|
|
|
{
|
|
|
|
|
|
|
|
void *slotaddr = (void *) tc_slotaddr;
|
1998-04-19 11:59:13 +04:00
|
|
|
char name[20];
|
|
|
|
int i;
|
1996-02-28 01:28:08 +03:00
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
/*
|
|
|
|
* check specified TC slot address
|
|
|
|
*/
|
1996-02-28 01:28:08 +03:00
|
|
|
if (tc_badaddr(slotaddr))
|
|
|
|
return (0);
|
|
|
|
|
1998-04-19 11:59:13 +04:00
|
|
|
/* check slot matches name */
|
1996-05-29 10:29:02 +04:00
|
|
|
if (tc_checkslot(tc_slotaddr, name) == 0)
|
1996-02-28 01:28:08 +03:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We found an device in the given slot. Now see if it's a
|
|
|
|
* framebuffer for which we have a driver.
|
|
|
|
*/
|
1998-04-19 11:59:13 +04:00
|
|
|
for (i = 0; i < ntcfbsw; i++) {
|
|
|
|
if (tcfbsw[i].fbsw_initfn == 0)
|
|
|
|
break;
|
|
|
|
if (strcmp(name, tcfbsw[i].fbsw_name) == 0) {
|
1998-04-20 06:46:59 +04:00
|
|
|
if (tcfbsw[i].fbsw_initfn(NULL, slotaddr, 0, 1))
|
1998-04-19 11:59:13 +04:00
|
|
|
return (1);
|
|
|
|
}
|
1996-02-28 01:28:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|