apecs.c revision 1.20
1/* $NetBSD: apecs.c,v 1.20 1997/04/07 06:36:38 cgd Exp $ */
2
3/*
4 * Copyright (c) 1995, 1996 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 <machine/options.h>		/* Pull in config options headers */
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/malloc.h>
36#include <sys/device.h>
37#include <vm/vm.h>
38
39#include <machine/autoconf.h>
40#include <machine/rpb.h>
41
42#include <dev/isa/isareg.h>
43#include <dev/isa/isavar.h>
44
45#include <dev/pci/pcireg.h>
46#include <dev/pci/pcivar.h>
47#include <alpha/pci/apecsreg.h>
48#include <alpha/pci/apecsvar.h>
49#ifdef DEC_2100_A50
50#include <alpha/pci/pci_2100_a50.h>
51#endif
52
53int	apecsmatch __P((struct device *, struct cfdata *, void *));
54void	apecsattach __P((struct device *, struct device *, void *));
55
56struct cfattach apecs_ca = {
57	sizeof(struct apecs_softc), apecsmatch, apecsattach,
58};
59
60struct cfdriver apecs_cd = {
61	NULL, "apecs", DV_DULL,
62};
63
64static int	apecsprint __P((void *, const char *pnp));
65
66/* There can be only one. */
67int apecsfound;
68struct apecs_config apecs_configuration;
69
70int
71apecsmatch(parent, match, aux)
72	struct device *parent;
73	struct cfdata *match;
74	void *aux;
75{
76	struct confargs *ca = aux;
77
78	/* Make sure that we're looking for an APECS. */
79	if (strcmp(ca->ca_name, apecs_cd.cd_name) != 0)
80		return (0);
81
82	if (apecsfound)
83		return (0);
84
85	return (1);
86}
87
88/*
89 * Set up the chipset's function pointers.
90 */
91void
92apecs_init(acp, mallocsafe)
93	struct apecs_config *acp;
94	int mallocsafe;
95{
96	acp->ac_comanche_pass2 =
97	    (REGVAL(COMANCHE_ED) & COMANCHE_ED_PASS2) != 0;
98	acp->ac_memwidth =
99	    (REGVAL(COMANCHE_GCR) & COMANCHE_GCR_WIDEMEM) != 0 ? 128 : 64;
100	acp->ac_epic_pass2 =
101	    (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0;
102
103	acp->ac_haxr1 = REGVAL(EPIC_HAXR1);
104	acp->ac_haxr2 = REGVAL(EPIC_HAXR2);
105
106	/*
107	 * Can't set up SGMAP data here; can be called before malloc().
108	 * XXX THIS COMMENT NO LONGER MAKES SENSE.
109	 */
110
111	if (!acp->ac_initted) {
112		/* don't do these twice since they set up extents */
113		acp->ac_iot = apecs_bus_io_init(acp);
114		acp->ac_memt = apecs_bus_mem_init(acp);
115	}
116	acp->ac_mallocsafe = mallocsafe;
117
118	apecs_pci_init(&acp->ac_pc, acp);
119
120	/* Turn off DMA window enables in PCI Base Reg 1. */
121	REGVAL(EPIC_PCI_BASE_1) = 0;
122	alpha_mb();
123
124	/* XXX SGMAP? */
125
126	/* XXX XXX BEGIN XXX XXX */
127	{							/* XXX */
128		extern vm_offset_t alpha_XXX_dmamap_or;		/* XXX */
129		alpha_XXX_dmamap_or = 0x40000000;		/* XXX */
130	}							/* XXX */
131	/* XXX XXX END XXX XXX */
132
133	acp->ac_initted = 1;
134}
135
136void
137apecsattach(parent, self, aux)
138	struct device *parent, *self;
139	void *aux;
140{
141	struct apecs_softc *sc = (struct apecs_softc *)self;
142	struct apecs_config *acp;
143	struct pcibus_attach_args pba;
144
145	/* note that we've attached the chipset; can't have 2 APECSes. */
146	apecsfound = 1;
147
148	/*
149	 * set up the chipset's info; done once at console init time
150	 * (maybe), but doesn't hurt to do twice.
151	 */
152	acp = sc->sc_acp = &apecs_configuration;
153	apecs_init(acp, 1);
154
155	/* XXX SGMAP FOO */
156
157	printf(": DECchip %s Core Logic chipset\n",
158	    acp->ac_memwidth == 128 ? "21072" : "21071");
159	printf("%s: DC21071-CA pass %d, %d-bit memory bus\n",
160	    self->dv_xname, acp->ac_comanche_pass2 ? 2 : 1, acp->ac_memwidth);
161	printf("%s: DC21071-DA pass %d\n", self->dv_xname,
162	    acp->ac_epic_pass2 ? 2 : 1);
163	/* XXX print bcache size */
164
165	if (!acp->ac_epic_pass2)
166		printf("WARNING: 21071-DA NOT PASS2... NO BETS...\n");
167
168	switch (hwrpb->rpb_type) {
169#ifdef DEC_2100_A50
170	case ST_DEC_2100_A50:
171		pci_2100_a50_pickintr(acp);
172		break;
173#endif
174
175	default:
176		panic("apecsattach: shouldn't be here, really...");
177	}
178
179	pba.pba_busname = "pci";
180	pba.pba_iot = acp->ac_iot;
181	pba.pba_memt = acp->ac_memt;
182	pba.pba_pc = &acp->ac_pc;
183	pba.pba_bus = 0;
184	config_found(self, &pba, apecsprint);
185}
186
187static int
188apecsprint(aux, pnp)
189	void *aux;
190	const char *pnp;
191{
192	register struct pcibus_attach_args *pba = aux;
193
194	/* only PCIs can attach to APECSes; easy. */
195	if (pnp)
196		printf("%s at %s", pba->pba_busname, pnp);
197	printf(" bus %d", pba->pba_bus);
198	return (UNCONF);
199}
200