apecs.c revision 1.6
1/*	$NetBSD: apecs.c,v 1.6 1996/04/12 04:38:33 cgd Exp $	*/
2
3/*
4 * Copyright (c) 1995 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Chris G. Demetriou
8 *
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22 *  School of Computer Science
23 *  Carnegie Mellon University
24 *  Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
28 */
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/kernel.h>
33#include <sys/malloc.h>
34#include <sys/device.h>
35#include <vm/vm.h>
36
37#include <machine/autoconf.h>
38#include <machine/rpb.h>
39
40#include <dev/isa/isareg.h>
41#include <dev/isa/isavar.h>
42
43#include <dev/pci/pcireg.h>
44#include <dev/pci/pcivar.h>
45#include <alpha/pci/apecsreg.h>
46#include <alpha/pci/apecsvar.h>
47#include <alpha/pci/pci_2100_a50.h>
48
49int	apecsmatch __P((struct device *, void *, void *));
50void	apecsattach __P((struct device *, struct device *, void *));
51
52struct cfattach apecs_ca = {
53	sizeof(struct apecs_softc), apecsmatch, apecsattach,
54};
55
56struct cfdriver apecs_cd = {
57	NULL, "apecs", DV_DULL,
58};
59
60static int	apecsprint __P((void *, char *pnp));
61
62/* There can be only one. */
63int apecsfound;
64struct apecs_config apecs_configuration;
65
66int
67apecsmatch(parent, match, aux)
68	struct device *parent;
69	void *match, *aux;
70{
71	struct cfdata *cf = match;
72	struct confargs *ca = aux;
73
74	/* Make sure that we're looking for an APECS. */
75	if (strcmp(ca->ca_name, apecs_cd.cd_name) != 0)
76		return (0);
77
78	if (apecsfound)
79		return (0);
80
81	return (1);
82}
83
84/*
85 * Set up the chipset's function pointers.
86 */
87void
88apecs_init(acp)
89	struct apecs_config *acp;
90{
91
92	acp->ac_comanche_pass2 =
93	    (REGVAL(COMANCHE_ED) & COMANCHE_ED_PASS2) != 0;
94	acp->ac_memwidth =
95	    (REGVAL(COMANCHE_GCR) & COMANCHE_GCR_WIDEMEM) != 0 ? 128 : 64;
96	acp->ac_epic_pass2 =
97	    (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0;
98
99	/*
100	 * Can't set up SGMAP data here; can be called before malloc().
101	 */
102
103	apecs_lca_bus_io_init(&acp->ac_bc, acp);
104	apecs_lca_bus_mem_init(&acp->ac_bc, acp);
105	apecs_pci_init(&acp->ac_pc, acp);
106
107	/* Turn off DMA window enables in PCI Base Reg 1. */
108	REGVAL(EPIC_PCI_BASE_1) = 0;
109	wbflush();
110
111	/* XXX SGMAP? */
112}
113
114void
115apecsattach(parent, self, aux)
116	struct device *parent, *self;
117	void *aux;
118{
119	struct apecs_softc *sc = (struct apecs_softc *)self;
120	struct apecs_config *acp;
121	struct pcibus_attach_args pba;
122
123	/* note that we've attached the chipset; can't have 2 APECSes. */
124	apecsfound = 1;
125
126	/*
127	 * set up the chipset's info; done once at console init time
128	 * (maybe), but doesn't hurt to do twice.
129	 */
130	acp = sc->sc_acp = &apecs_configuration;
131	apecs_init(acp);
132
133	/* XXX SGMAP FOO */
134
135	printf(": DECchip %s Core Logic chipset\n",
136	    acp->ac_memwidth == 128 ? "21072" : "21071");
137	printf("%s: DC21071-CA pass %d, %d-bit memory bus\n",
138	    self->dv_xname, acp->ac_comanche_pass2 ? 2 : 1, acp->ac_memwidth);
139	printf("%s: DC21071-DA pass %d\n", self->dv_xname,
140	    acp->ac_epic_pass2 ? 2 : 1);
141	/* XXX print bcache size */
142
143	if (!acp->ac_epic_pass2)
144		printf("WARNING: 21071-DA NOT PASS2... NO BETS...\n");
145
146	switch (hwrpb->rpb_type) {
147#if defined(DEC_2100_A50)
148	case ST_DEC_2100_A50:
149		pci_2100_a50_pickintr(acp);
150		break;
151#endif
152	default:
153		panic("apecsattach: shouldn't be here, really...");
154	}
155
156	pba.pba_busname = "pci";
157	pba.pba_bc = &acp->ac_bc;
158	pba.pba_pc = &acp->ac_pc;
159	pba.pba_bus = 0;
160	config_found(self, &pba, apecsprint);
161}
162
163static int
164apecsprint(aux, pnp)
165	void *aux;
166	char *pnp;
167{
168        register struct pcibus_attach_args *pba = aux;
169
170	/* only PCIs can attach to APECSes; easy. */
171	if (pnp)
172		printf("%s at %s", pba->pba_busname, pnp);
173	printf(" bus %d", pba->pba_bus);
174	return (UNCONF);
175}
176