1 /* $NetBSD: cpc_mainbus.c,v 1.2 2007/10/17 19:54:19 garbled 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 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #include <sys/cdefs.h> 40 __KERNEL_RCSID(0, "$NetBSD: cpc_mainbus.c,v 1.2 2007/10/17 19:54:19 garbled Exp $"); 41 42 #include <sys/param.h> 43 #include <sys/extent.h> 44 #include <sys/device.h> 45 #include <sys/malloc.h> 46 #include <sys/systm.h> 47 48 #include <machine/bus.h> 49 #include "locators.h" 50 51 #include <dev/pci/pcivar.h> 52 #include <dev/pci/pcireg.h> 53 #include <dev/pci/pciconf.h> 54 55 #include <dev/ic/cpc700reg.h> 56 #include <dev/ic/cpc700var.h> 57 #include <dev/ic/cpc700uic.h> 58 59 #include <machine/pmppc.h> 60 #include <arch/evbppc/pmppc/dev/mainbus.h> 61 62 struct genppc_pci_chipset *genppc_pct; 63 64 void 65 cpc_attach(struct device *self, pci_chipset_tag_t pc, bus_space_tag_t mem, 66 bus_space_tag_t pciio, bus_dma_tag_t tag, int attachpci, 67 uint freq); 68 69 static int cpc_mainbus_match(struct device *, struct cfdata *, void *); 70 static void cpc_mainbus_attach(struct device *, struct device *, void *); 71 72 CFATTACH_DECL(cpc_mainbus, sizeof(struct device), 73 cpc_mainbus_match, cpc_mainbus_attach, NULL, NULL); 74 75 int 76 cpc_mainbus_match(struct device *parent, struct cfdata *cf, void *aux) 77 { 78 struct mainbus_attach_args *maa = aux; 79 80 return (strcmp(maa->mb_name, "cpc") == 0); 81 } 82 83 void 84 cpc_mainbus_attach(struct device *parent, struct device *self, void *aux) 85 { 86 struct genppc_pci_chipset_businfo *pbi; 87 88 genppc_pct = malloc(sizeof(struct genppc_pci_chipset), M_DEVBUF, 89 M_NOWAIT); 90 pmppc_pci_get_chipset_tag(genppc_pct); 91 pbi = malloc(sizeof(struct genppc_pci_chipset_businfo), 92 M_DEVBUF, M_NOWAIT); 93 KASSERT(pbi != NULL); 94 pbi->pbi_properties = prop_dictionary_create(); 95 KASSERT(pbi->pbi_properties != NULL); 96 SIMPLEQ_INIT(&genppc_pct->pc_pbi); 97 SIMPLEQ_INSERT_TAIL(&genppc_pct->pc_pbi, pbi, next); 98 99 cpc_attach(self, genppc_pct, &pmppc_mem_tag, &pmppc_pci_io_tag, 100 &pci_bus_dma_tag, a_config.a_is_monarch, 101 a_config.a_bus_freq); 102 103 if (!a_config.a_is_monarch) 104 printf("%s: not Monarch, pci not attached\n", self->dv_xname); 105 } 106