pcmb.c revision 1.1
11.1Sjdolecek/*	$NetBSD: pcmb.c,v 1.1 2001/03/25 09:54:10 jdolecek Exp $	*/
21.1Sjdolecek
31.1Sjdolecek/*-
41.1Sjdolecek * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
51.1Sjdolecek * All rights reserved.
61.1Sjdolecek *
71.1Sjdolecek * This code is derived from software contributed to The NetBSD Foundation
81.1Sjdolecek * by Jason R. Thorpe and Jaromir Dolecek.
91.1Sjdolecek *
101.1Sjdolecek * Redistribution and use in source and binary forms, with or without
111.1Sjdolecek * modification, are permitted provided that the following conditions
121.1Sjdolecek * are met:
131.1Sjdolecek * 1. Redistributions of source code must retain the above copyright
141.1Sjdolecek *    notice, this list of conditions and the following disclaimer.
151.1Sjdolecek * 2. Redistributions in binary form must reproduce the above copyright
161.1Sjdolecek *    notice, this list of conditions and the following disclaimer in the
171.1Sjdolecek *    documentation and/or other materials provided with the distribution.
181.1Sjdolecek * 3. All advertising materials mentioning features or use of this software
191.1Sjdolecek *    must display the following acknowledgement:
201.1Sjdolecek *        This product includes software developed by the NetBSD
211.1Sjdolecek *        Foundation, Inc. and its contributors.
221.1Sjdolecek * 4. Neither the name of The NetBSD Foundation nor the names of its
231.1Sjdolecek *    contributors may be used to endorse or promote products derived
241.1Sjdolecek *    from this software without specific prior written permission.
251.1Sjdolecek *
261.1Sjdolecek * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
271.1Sjdolecek * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
281.1Sjdolecek * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
291.1Sjdolecek * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
301.1Sjdolecek * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
311.1Sjdolecek * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
321.1Sjdolecek * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
331.1Sjdolecek * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
341.1Sjdolecek * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
351.1Sjdolecek * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
361.1Sjdolecek * POSSIBILITY OF SUCH DAMAGE.
371.1Sjdolecek */
381.1Sjdolecek
391.1Sjdolecek/*
401.1Sjdolecek * "Driver" for PCI-MCA Bridges.
411.1Sjdolecek */
421.1Sjdolecek
431.1Sjdolecek#include <sys/types.h>
441.1Sjdolecek#include <sys/param.h>
451.1Sjdolecek#include <sys/systm.h>
461.1Sjdolecek#include <sys/device.h>
471.1Sjdolecek
481.1Sjdolecek#include <machine/bus.h>
491.1Sjdolecek
501.1Sjdolecek#include <dev/mca/mcavar.h>
511.1Sjdolecek
521.1Sjdolecek#include <dev/pci/pcivar.h>
531.1Sjdolecek#include <dev/pci/pcireg.h>
541.1Sjdolecek
551.1Sjdolecek#include <dev/pci/pcidevs.h>
561.1Sjdolecek
571.1Sjdolecek#include "mca.h"
581.1Sjdolecek
591.1Sjdolecekint	pcmbmatch __P((struct device *, struct cfdata *, void *));
601.1Sjdolecekvoid	pcmbattach __P((struct device *, struct device *, void *));
611.1Sjdolecek
621.1Sjdolecekstruct cfattach pcmb_ca = {
631.1Sjdolecek	sizeof(struct device), pcmbmatch, pcmbattach
641.1Sjdolecek};
651.1Sjdolecek
661.1Sjdolecekvoid	pcmb_callback __P((struct device *));
671.1Sjdolecekint	pcmb_print __P((void *, const char *));
681.1Sjdolecek
691.1Sjdolecekunion pcmb_attach_args {
701.1Sjdolecek	const char *ma_name;			/* XXX should be common */
711.1Sjdolecek	struct mcabus_attach_args ma_mba;
721.1Sjdolecek};
731.1Sjdolecek
741.1Sjdolecekint
751.1Sjdolecekpcmbmatch(parent, match, aux)
761.1Sjdolecek	struct device *parent;
771.1Sjdolecek	struct cfdata *match;
781.1Sjdolecek	void *aux;
791.1Sjdolecek{
801.1Sjdolecek	struct pci_attach_args *pa = aux;
811.1Sjdolecek
821.1Sjdolecek	/*
831.1Sjdolecek	 * Match all known PCI-MCA bridges.
841.1Sjdolecek	 */
851.1Sjdolecek	switch (PCI_VENDOR(pa->pa_id)) {
861.1Sjdolecek	case PCI_VENDOR_IBM:
871.1Sjdolecek		switch (PCI_PRODUCT(pa->pa_id)) {
881.1Sjdolecek		case PCI_PRODUCT_IBM_MCABRIDGE:
891.1Sjdolecek		case PCI_PRODUCT_IBM_MCABRIDGE2:
901.1Sjdolecek			return (1);
911.1Sjdolecek		}
921.1Sjdolecek		break;
931.1Sjdolecek	}
941.1Sjdolecek
951.1Sjdolecek	return (0);
961.1Sjdolecek}
971.1Sjdolecek
981.1Sjdolecekvoid
991.1Sjdolecekpcmbattach(parent, self, aux)
1001.1Sjdolecek	struct device *parent, *self;
1011.1Sjdolecek	void *aux;
1021.1Sjdolecek{
1031.1Sjdolecek	struct pci_attach_args *pa = aux;
1041.1Sjdolecek	char devinfo[256];
1051.1Sjdolecek
1061.1Sjdolecek	printf("\n");
1071.1Sjdolecek
1081.1Sjdolecek	/*
1091.1Sjdolecek	 * Just print out a description and defer configuration
1101.1Sjdolecek	 * until all PCI devices have been attached.
1111.1Sjdolecek	 */
1121.1Sjdolecek	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
1131.1Sjdolecek	printf("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo,
1141.1Sjdolecek	    PCI_REVISION(pa->pa_class));
1151.1Sjdolecek
1161.1Sjdolecek	config_defer(self, pcmb_callback);
1171.1Sjdolecek}
1181.1Sjdolecek
1191.1Sjdolecekvoid
1201.1Sjdolecekpcmb_callback(self)
1211.1Sjdolecek	struct device *self;
1221.1Sjdolecek{
1231.1Sjdolecek	union pcmb_attach_args ma;
1241.1Sjdolecek
1251.1Sjdolecek	/*
1261.1Sjdolecek	 * Attach MCA bus behind this bridge.
1271.1Sjdolecek	 */
1281.1Sjdolecek	ma.ma_mba.mba_busname = "mca";
1291.1Sjdolecek	ma.ma_mba.mba_iot = I386_BUS_SPACE_IO;
1301.1Sjdolecek	ma.ma_mba.mba_memt = I386_BUS_SPACE_MEM;
1311.1Sjdolecek#if NMCA > 0
1321.1Sjdolecek	ma.ma_mba.mba_dmat = &mca_bus_dma_tag;
1331.1Sjdolecek#endif
1341.1Sjdolecek	ma.ma_mba.mba_mc = NULL;
1351.1Sjdolecek	ma.ma_mba.mba_bus = 0;
1361.1Sjdolecek	config_found(self, &ma.ma_mba, pcmb_print);
1371.1Sjdolecek}
1381.1Sjdolecek
1391.1Sjdolecekint
1401.1Sjdolecekpcmb_print(aux, pnp)
1411.1Sjdolecek	void *aux;
1421.1Sjdolecek	const char *pnp;
1431.1Sjdolecek{
1441.1Sjdolecek	union pcmb_attach_args *ma = aux;
1451.1Sjdolecek
1461.1Sjdolecek	if (pnp)
1471.1Sjdolecek		printf("%s at %s", ma->ma_name, pnp);
1481.1Sjdolecek	return (UNCONF);
1491.1Sjdolecek}
150