pcmb.c revision 1.13
11.13Sthorpej/*	$NetBSD: pcmb.c,v 1.13 2006/02/19 14:59:23 thorpej 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.3Slukem
431.3Slukem#include <sys/cdefs.h>
441.13Sthorpej__KERNEL_RCSID(0, "$NetBSD: pcmb.c,v 1.13 2006/02/19 14:59:23 thorpej Exp $");
451.1Sjdolecek
461.1Sjdolecek#include <sys/types.h>
471.1Sjdolecek#include <sys/param.h>
481.1Sjdolecek#include <sys/systm.h>
491.1Sjdolecek#include <sys/device.h>
501.1Sjdolecek
511.1Sjdolecek#include <machine/bus.h>
521.1Sjdolecek
531.1Sjdolecek#include <dev/mca/mcavar.h>
541.1Sjdolecek
551.1Sjdolecek#include <dev/pci/pcivar.h>
561.1Sjdolecek#include <dev/pci/pcireg.h>
571.1Sjdolecek
581.1Sjdolecek#include <dev/pci/pcidevs.h>
591.1Sjdolecek
601.1Sjdolecek#include "mca.h"
611.1Sjdolecek
621.11Sperryint	pcmbmatch(struct device *, struct cfdata *, void *);
631.11Sperryvoid	pcmbattach(struct device *, struct device *, void *);
641.1Sjdolecek
651.6SthorpejCFATTACH_DECL(pcmb, sizeof(struct device),
661.6Sthorpej    pcmbmatch, pcmbattach, NULL, NULL);
671.1Sjdolecek
681.11Sperryvoid	pcmb_callback(struct device *);
691.1Sjdolecek
701.1Sjdolecekint
711.11Sperrypcmbmatch(struct device *parent, struct cfdata *match, void *aux)
721.1Sjdolecek{
731.1Sjdolecek	struct pci_attach_args *pa = aux;
741.1Sjdolecek
751.1Sjdolecek	/*
761.2Sjdolecek	 * Match anything which claims to be PCI-MCA bridge.
771.1Sjdolecek	 */
781.2Sjdolecek	if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE
791.2Sjdolecek	    && PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_BRIDGE_MC)
801.2Sjdolecek		return (1);
811.1Sjdolecek
821.1Sjdolecek	return (0);
831.1Sjdolecek}
841.1Sjdolecek
851.1Sjdolecekvoid
861.11Sperrypcmbattach(struct device *parent, struct device *self, void *aux)
871.1Sjdolecek{
881.1Sjdolecek	struct pci_attach_args *pa = aux;
891.1Sjdolecek	char devinfo[256];
901.1Sjdolecek
911.13Sthorpej	aprint_naive("\n");
921.13Sthorpej	aprint_normal("\n");
931.1Sjdolecek
941.1Sjdolecek	/*
951.1Sjdolecek	 * Just print out a description and defer configuration
961.1Sjdolecek	 * until all PCI devices have been attached.
971.1Sjdolecek	 */
981.9Sitojun	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
991.13Sthorpej	aprint_normal("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo,
1001.1Sjdolecek	    PCI_REVISION(pa->pa_class));
1011.1Sjdolecek
1021.1Sjdolecek	config_defer(self, pcmb_callback);
1031.1Sjdolecek}
1041.1Sjdolecek
1051.1Sjdolecekvoid
1061.11Sperrypcmb_callback(struct device *self)
1071.1Sjdolecek{
1081.10Sdrochner	struct mcabus_attach_args ma;
1091.1Sjdolecek
1101.1Sjdolecek	/*
1111.1Sjdolecek	 * Attach MCA bus behind this bridge.
1121.1Sjdolecek	 */
1131.10Sdrochner	ma.mba_iot = X86_BUS_SPACE_IO;
1141.10Sdrochner	ma.mba_memt = X86_BUS_SPACE_MEM;
1151.1Sjdolecek#if NMCA > 0
1161.10Sdrochner	ma.mba_dmat = &mca_bus_dma_tag;
1171.1Sjdolecek#endif
1181.10Sdrochner	ma.mba_mc = NULL;
1191.10Sdrochner	ma.mba_bus = 0;
1201.10Sdrochner	config_found_ia(self, "mcabus", &ma, mcabusprint);
1211.1Sjdolecek}
122