1 /* $NetBSD: cpc_mainbus.c,v 1.2 2007/10/17 19:54:19 garbled Exp $ */
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net) at Sandburst Corp.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: cpc_mainbus.c,v 1.2 2007/10/17 19:54:19 garbled Exp $");
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>
41 #include <machine/bus.h>
44 #include <dev/pci/pcivar.h>
45 #include <dev/pci/pcireg.h>
46 #include <dev/pci/pciconf.h>
48 #include <dev/ic/cpc700reg.h>
49 #include <dev/ic/cpc700var.h>
50 #include <dev/ic/cpc700uic.h>
52 #include <machine/pmppc.h>
53 #include <arch/evbppc/pmppc/dev/mainbus.h>
55 struct genppc_pci_chipset
*genppc_pct
;
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
,
62 static int cpc_mainbus_match(struct device
*, struct cfdata
*, void *);
63 static void cpc_mainbus_attach(struct device
*, struct device
*, void *);
65 CFATTACH_DECL(cpc_mainbus
, sizeof(struct device
),
66 cpc_mainbus_match
, cpc_mainbus_attach
, NULL
, NULL
);
69 cpc_mainbus_match(struct device
*parent
, struct cfdata
*cf
, void *aux
)
71 struct mainbus_attach_args
*maa
= aux
;
73 return (strcmp(maa
->mb_name
, "cpc") == 0);
77 cpc_mainbus_attach(struct device
*parent
, struct device
*self
, void *aux
)
79 struct genppc_pci_chipset_businfo
*pbi
;
81 genppc_pct
= malloc(sizeof(struct genppc_pci_chipset
), M_DEVBUF
,
83 pmppc_pci_get_chipset_tag(genppc_pct
);
84 pbi
= malloc(sizeof(struct genppc_pci_chipset_businfo
),
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
);
92 cpc_attach(self
, genppc_pct
, &pmppc_mem_tag
, &pmppc_pci_io_tag
,
93 &pci_bus_dma_tag
, a_config
.a_is_monarch
,
96 if (!a_config
.a_is_monarch
)
97 printf("%s: not Monarch, pci not attached\n", self
->dv_xname
);