xref: /netbsd-src/sys/arch/arm/xscale/ixp425.c (revision c7fb772b85b2b5d4cfb282f868f454b4701534fd)
1 /*	$NetBSD: ixp425.c,v 1.18 2021/08/07 16:18:46 thorpej Exp $ */
2 
3 /*
4  * Copyright (c) 2003
5  *	Ichiro FUKUHARA <ichiro@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  *
17  * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
21  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 #include "pci.h"
31 
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: ixp425.c,v 1.18 2021/08/07 16:18:46 thorpej Exp $");
34 
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/device.h>
38 #include <uvm/uvm.h>
39 
40 #include <sys/bus.h>
41 
42 #include <arm/xscale/ixp425reg.h>
43 #include <arm/xscale/ixp425var.h>
44 
45 struct	ixp425_softc *ixp425_softc;
46 
47 void
ixp425_attach(device_t self)48 ixp425_attach(device_t self)
49 {
50 	struct ixp425_softc *sc = device_private(self);
51 #if NPCI > 0
52 	struct pcibus_attach_args pba;
53 #endif
54 
55 	sc->sc_dev = self;
56 	sc->sc_iot = &ixp425_bs_tag;
57 
58 	ixp425_softc = sc;
59 
60 	printf("\n");
61 
62 	/*
63 	 * Mapping for GPIO Registers
64 	 */
65 	if (bus_space_map(sc->sc_iot, IXP425_GPIO_HWBASE, IXP425_GPIO_SIZE,
66 			  0, &sc->sc_gpio_ioh))
67 		panic("%s: unable to map GPIO registers", device_xname(self));
68 
69 	if (bus_space_map(sc->sc_iot, IXP425_EXP_HWBASE, IXP425_EXP_SIZE,
70 			  0, &sc->sc_exp_ioh))
71 		panic("%s: unable to map Expansion Bus registers",
72 		    device_xname(self));
73 
74 #if NPCI > 0
75 	/*
76 	 * Mapping for PCI CSR
77 	 */
78 	if (bus_space_map(sc->sc_iot, IXP425_PCI_HWBASE, IXP425_PCI_SIZE,
79 			  0, &sc->sc_pci_ioh))
80 		panic("%s: unable to map PCI registers", device_xname(self));
81 
82 	/*
83 	 * Invoke the board-specific PCI initialization code
84 	 */
85 	ixp425_md_pci_init(sc);
86 
87 	/*
88 	 * Generic initialization of the PCI chipset.
89 	 */
90 	ixp425_pci_init(sc);
91 
92 	/*
93 	 * Initialize the DMA tags.
94 	 */
95 	ixp425_pci_dma_init(sc);
96 
97 	/*
98 	 * Attach the PCI bus.
99 	 */
100 	pba.pba_pc = &sc->ia_pci_chipset;
101 	pba.pba_iot = &sc->sc_pci_iot;
102 	pba.pba_memt = &sc->sc_pci_memt;
103 	pba.pba_dmat = &sc->ia_pci_dmat;
104 	pba.pba_bus = 0;	/* bus number = 0 */
105 	pba.pba_bridgetag = NULL;
106 	pba.pba_intrswiz = 0;	/* XXX */
107 	pba.pba_intrtag = 0;
108 	pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY |
109 			PCI_FLAGS_MRL_OKAY   | PCI_FLAGS_MRM_OKAY |
110 			PCI_FLAGS_MWI_OKAY;
111 	config_found(self, &pba, pcibusprint,
112 	    CFARGS(.iattr = "pcibus"));
113 #endif
114 }
115