1 /* $NetBSD: a12c.c,v 1.20 2009/03/14 15:35:59 dsl Exp $ */
3 /* [Notice revision 2.2]
4 * Copyright (c) 1997, 1998 Avalon Computer Systems, Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright and
13 * author notice, this list of conditions, and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of Avalon Computer Systems, Inc. nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 * 4. This copyright will be assigned to The NetBSD Foundation on
21 * 1/1/2000 unless these terms (including possibly the assignment
22 * date) are updated in writing by Avalon prior to the latest specified
25 * THIS SOFTWARE IS PROVIDED BY AVALON COMPUTER SYSTEMS, INC. AND CONTRIBUTORS
26 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AVALON OR THE CONTRIBUTORS
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
38 #include "opt_avalon_a12.h" /* Config options headers */
39 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
41 __KERNEL_RCSID(0, "$NetBSD: a12c.c,v 1.20 2009/03/14 15:35:59 dsl Exp $");
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/kernel.h>
46 #include <sys/malloc.h>
47 #include <sys/device.h>
49 #include <uvm/uvm_extern.h>
51 #include <machine/autoconf.h>
52 #include <machine/rpb.h>
54 #include <dev/isa/isareg.h>
55 #include <dev/isa/isavar.h>
56 #include <dev/pci/pcireg.h>
57 #include <dev/pci/pcivar.h>
59 #include <alpha/alpha/clockvar.h>
61 #include <alpha/pci/a12creg.h>
62 #include <alpha/pci/a12cvar.h>
63 #include <alpha/pci/pci_a12.h>
65 #define A12C() /* Generate ctags(1) key */
67 int a12cmatch(struct device
*, struct cfdata
*, void *);
68 void a12cattach(struct device
*, struct device
*, void *);
70 CFATTACH_DECL(a12c
, sizeof(struct a12c_softc
),
71 a12cmatch
, a12cattach
, NULL
, NULL
);
73 extern struct cfdriver a12c_cd
;
75 static const struct clocktime zeroct
;
77 static void noclock_init(struct device
*);
78 static void noclock_get(struct device
*, time_t, struct clocktime
*);
79 static void noclock_set(struct device
*, struct clocktime
*);
81 static const struct clockfns noclock_fns
= {
82 noclock_init
, noclock_get
, noclock_set
85 /* There can be only one. */
88 struct a12c_config a12c_configuration
;
91 a12cmatch(struct device
*parent
, struct cfdata
*match
, void *aux
)
93 struct mainbus_attach_args
*ma
= aux
;
95 return cputype
== ST_AVALON_A12
96 && strcmp(ma
->ma_name
, a12c_cd
.cd_name
) == 0
101 a12c_init(struct a12c_config
*ccp
, int mallocsafe
)
103 if (!ccp
->ac_initted
) {
104 /* someday these may allocate memory, do once only */
107 ccp
->ac_memt
= a12c_bus_mem_init(ccp
);
109 ccp
->ac_mallocsafe
= mallocsafe
;
111 a12c_pci_init(&ccp
->ac_pc
, ccp
);
119 a12cattach(struct device
*parent
, struct device
*self
, void *aux
)
121 struct a12c_softc
*sc
= (struct a12c_softc
*)self
;
122 struct a12c_config
*ccp
;
123 struct pcibus_attach_args pba
;
125 /* note that we've attached the chipset; can't have 2 A12Cs. */
129 * set up the chipset's info; done once at console init time
130 * (maybe), but we must do it here as well to take care of things
131 * that need to use memory allocation.
133 ccp
= sc
->sc_ccp
= &a12c_configuration
;
136 /* XXX print chipset information */
137 printf(": driver %s over logic %x\n", "$Revision: 1.21 $",
138 A12_ALL_EXTRACT(REGVAL(A12_VERS
)));
140 pci_a12_pickintr(ccp
);
141 clockattach(noclock_init
, NULL
); /* XXX? */
143 memset(&pba
, 0, sizeof(pba
));
145 pba
.pba_memt
= ccp
->ac_memt
;
146 pba
.pba_dmat
= &ccp
->ac_dmat_direct
;
147 pba
.pba_dmat64
= NULL
;
148 pba
.pba_pc
= &ccp
->ac_pc
;
150 pba
.pba_bridgetag
= NULL
;
151 pba
.pba_flags
= PCI_FLAGS_MEM_ENABLED
|
152 PCI_FLAGS_MRL_OKAY
| PCI_FLAGS_MRM_OKAY
| PCI_FLAGS_MWI_OKAY
;
154 config_found_ia(self
, "pcibus", &pba
, pcibusprint
);
157 config_found_ia(self
, "a12c_xb", &pba
, NULL
);
160 config_found_ia(self
, "a12c_a12dc", &pba
, NULL
);
163 static void noclock_init(void (*)(void *), void *)