1 /* $NetBSD: cpc_mainbus.c,v 1.3 2008/04/28 20:23:17 martin Exp $ */ 2 3 /* 4 * Copyright (c) 2002 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Lennart Augustsson (lennart@augustsson.net) at Sandburst Corp. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include <sys/cdefs.h> 33 __KERNEL_RCSID(0, "$NetBSD: cpc_mainbus.c,v 1.3 2008/04/28 20:23:17 martin Exp $"); 34 35 #include <sys/param.h> 36 #include <sys/extent.h> 37 #include <sys/device.h> 38 #include <sys/malloc.h> 39 #include <sys/systm.h> 40 41 #include <machine/bus.h> 42 #include "locators.h" 43 44 #include <dev/pci/pcivar.h> 45 #include <dev/pci/pcireg.h> 46 #include <dev/pci/pciconf.h> 47 48 #include <dev/ic/cpc700reg.h> 49 #include <dev/ic/cpc700var.h> 50 #include <dev/ic/cpc700uic.h> 51 52 #include <machine/pmppc.h> 53 #include <arch/evbppc/pmppc/dev/mainbus.h> 54 55 struct genppc_pci_chipset *genppc_pct; 56 57 void 58 cpc_attach(struct device *self, pci_chipset_tag_t pc, bus_space_tag_t mem, 59 bus_space_tag_t pciio, bus_dma_tag_t tag, int attachpci, 60 uint freq); 61 62 static int cpc_mainbus_match(struct device *, struct cfdata *, void *); 63 static void cpc_mainbus_attach(struct device *, struct device *, void *); 64 65 CFATTACH_DECL(cpc_mainbus, sizeof(struct device), 66 cpc_mainbus_match, cpc_mainbus_attach, NULL, NULL); 67 68 int 69 cpc_mainbus_match(struct device *parent, struct cfdata *cf, void *aux) 70 { 71 struct mainbus_attach_args *maa = aux; 72 73 return (strcmp(maa->mb_name, "cpc") == 0); 74 } 75 76 void 77 cpc_mainbus_attach(struct device *parent, struct device *self, void *aux) 78 { 79 struct genppc_pci_chipset_businfo *pbi; 80 81 genppc_pct = malloc(sizeof(struct genppc_pci_chipset), M_DEVBUF, 82 M_NOWAIT); 83 pmppc_pci_get_chipset_tag(genppc_pct); 84 pbi = malloc(sizeof(struct genppc_pci_chipset_businfo), 85 M_DEVBUF, M_NOWAIT); 86 KASSERT(pbi != NULL); 87 pbi->pbi_properties = prop_dictionary_create(); 88 KASSERT(pbi->pbi_properties != NULL); 89 SIMPLEQ_INIT(&genppc_pct->pc_pbi); 90 SIMPLEQ_INSERT_TAIL(&genppc_pct->pc_pbi, pbi, next); 91 92 cpc_attach(self, genppc_pct, &pmppc_mem_tag, &pmppc_pci_io_tag, 93 &pci_bus_dma_tag, a_config.a_is_monarch, 94 a_config.a_bus_freq); 95 96 if (!a_config.a_is_monarch) 97 printf("%s: not Monarch, pci not attached\n", self->dv_xname); 98 } 99