ixp425.c revision 1.6 1 /* $NetBSD: ixp425.c,v 1.6 2003/10/08 14:55:04 scw Exp $ */
2
3 /*
4 * Copyright (c) 2003
5 * Ichiro FUKUHARA <ichiro (at) ichiro.org>.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Ichiro FUKUHARA.
19 * 4. The name of the company nor the name of the author may be used to
20 * endorse or promote products derived from this software without specific
21 * prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: ixp425.c,v 1.6 2003/10/08 14:55:04 scw Exp $");
38
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/device.h>
42 #include <uvm/uvm.h>
43
44 #include <machine/bus.h>
45
46 #include <arm/xscale/ixp425reg.h>
47 #include <arm/xscale/ixp425var.h>
48
49 int ixp425_pcibus_print(void *, const char *);
50 struct ixp425_softc *ixp425_softc;
51
52 void
53 ixp425_attach(struct ixp425_softc *sc)
54 {
55 struct pcibus_attach_args pba;
56
57 sc->sc_iot = &ixp425_bs_tag;
58
59 ixp425_softc = sc;
60
61 printf("\n");
62
63 /*
64 * Mapping for PCI CSR
65 */
66 if (bus_space_map(sc->sc_iot, IXP425_PCI_HWBASE, IXP425_PCI_SIZE,
67 0, &sc->sc_pci_ioh))
68 panic("%s: unable to map PCI registers", sc->sc_dev.dv_xname);
69
70 /*
71 * Mapping for GPIO Registers
72 */
73 if (bus_space_map(sc->sc_iot, IXP425_GPIO_HWBASE, IXP425_GPIO_SIZE,
74 0, &sc->sc_gpio_ioh))
75 panic("%s: unable to map GPIO registers", sc->sc_dev.dv_xname);
76
77 /*
78 * Invoke the board-specific PCI initialization code
79 */
80 ixp425_md_pci_init(sc);
81
82 /*
83 * Generic initialization of the PCI chipset.
84 */
85 ixp425_pci_init(sc);
86
87 /*
88 * Initialize the DMA tags.
89 */
90 ixp425_pci_dma_init(sc);
91
92 /*
93 * Attach the PCI bus.
94 */
95 pba.pba_busname = "pci";
96 pba.pba_pc = &sc->ia_pci_chipset;
97 pba.pba_iot = &sc->sc_pci_iot;
98 pba.pba_memt = &sc->sc_pci_memt;
99 pba.pba_dmat = &sc->ia_pci_dmat;
100 pba.pba_bus = 0; /* bus number = 0 */
101 pba.pba_bridgetag = NULL;
102 pba.pba_intrswiz = 0; /* XXX */
103 pba.pba_intrtag = 0;
104 pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
105 PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY |
106 PCI_FLAGS_MWI_OKAY;
107 (void) config_found(&sc->sc_dev, &pba, ixp425_pcibus_print);
108 }
109
110 int
111 ixp425_pcibus_print(void *aux, const char *pnp)
112 {
113 struct pcibus_attach_args *pba = aux;
114
115 if (pnp)
116 aprint_normal("%s at %s", pba->pba_busname, pnp);
117
118 aprint_normal(" bus %d", pba->pba_bus);
119
120 return (UNCONF);
121 }
122