xref: /netbsd-src/sys/arch/arm/xscale/ixp425.c (revision c7fb772b85b2b5d4cfb282f868f454b4701534fd)
1*c7fb772bSthorpej /*	$NetBSD: ixp425.c,v 1.18 2021/08/07 16:18:46 thorpej Exp $ */
200eb02e3Sichiro 
300eb02e3Sichiro /*
400eb02e3Sichiro  * Copyright (c) 2003
500eb02e3Sichiro  *	Ichiro FUKUHARA <ichiro@ichiro.org>.
600eb02e3Sichiro  * All rights reserved.
700eb02e3Sichiro  *
800eb02e3Sichiro  * Redistribution and use in source and binary forms, with or without
900eb02e3Sichiro  * modification, are permitted provided that the following conditions
1000eb02e3Sichiro  * are met:
1100eb02e3Sichiro  * 1. Redistributions of source code must retain the above copyright
1200eb02e3Sichiro  *    notice, this list of conditions and the following disclaimer.
1300eb02e3Sichiro  * 2. Redistributions in binary form must reproduce the above copyright
1400eb02e3Sichiro  *    notice, this list of conditions and the following disclaimer in the
1500eb02e3Sichiro  *    documentation and/or other materials provided with the distribution.
1600eb02e3Sichiro  *
1700eb02e3Sichiro  * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
1800eb02e3Sichiro  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1900eb02e3Sichiro  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2000eb02e3Sichiro  * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
2100eb02e3Sichiro  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2200eb02e3Sichiro  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2300eb02e3Sichiro  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2400eb02e3Sichiro  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2500eb02e3Sichiro  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2600eb02e3Sichiro  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2700eb02e3Sichiro  * SUCH DAMAGE.
2800eb02e3Sichiro  */
2900eb02e3Sichiro 
3050a765e4Smsaitoh #include "pci.h"
3150a765e4Smsaitoh 
3200eb02e3Sichiro #include <sys/cdefs.h>
33*c7fb772bSthorpej __KERNEL_RCSID(0, "$NetBSD: ixp425.c,v 1.18 2021/08/07 16:18:46 thorpej Exp $");
3400eb02e3Sichiro 
3500eb02e3Sichiro #include <sys/param.h>
3600eb02e3Sichiro #include <sys/systm.h>
3700eb02e3Sichiro #include <sys/device.h>
3800eb02e3Sichiro #include <uvm/uvm.h>
3900eb02e3Sichiro 
40ed9977b1Sdyoung #include <sys/bus.h>
4100eb02e3Sichiro 
4200eb02e3Sichiro #include <arm/xscale/ixp425reg.h>
4300eb02e3Sichiro #include <arm/xscale/ixp425var.h>
4400eb02e3Sichiro 
45663ccee1Sichiro struct	ixp425_softc *ixp425_softc;
4600eb02e3Sichiro 
4700eb02e3Sichiro void
ixp425_attach(device_t self)48a2b8c7fbSmsaitoh ixp425_attach(device_t self)
4900eb02e3Sichiro {
50a2b8c7fbSmsaitoh 	struct ixp425_softc *sc = device_private(self);
5150a765e4Smsaitoh #if NPCI > 0
52663ccee1Sichiro 	struct pcibus_attach_args pba;
5350a765e4Smsaitoh #endif
54663ccee1Sichiro 
55a2b8c7fbSmsaitoh 	sc->sc_dev = self;
56663ccee1Sichiro 	sc->sc_iot = &ixp425_bs_tag;
57663ccee1Sichiro 
5800eb02e3Sichiro 	ixp425_softc = sc;
5900eb02e3Sichiro 
6000eb02e3Sichiro 	printf("\n");
6138e0b1c5Sichiro 
6238e0b1c5Sichiro 	/*
63663ccee1Sichiro 	 * Mapping for GPIO Registers
64663ccee1Sichiro 	 */
65663ccee1Sichiro 	if (bus_space_map(sc->sc_iot, IXP425_GPIO_HWBASE, IXP425_GPIO_SIZE,
66663ccee1Sichiro 			  0, &sc->sc_gpio_ioh))
67a2b8c7fbSmsaitoh 		panic("%s: unable to map GPIO registers", device_xname(self));
6838e0b1c5Sichiro 
69bdea1361Sscw 	if (bus_space_map(sc->sc_iot, IXP425_EXP_HWBASE, IXP425_EXP_SIZE,
70bdea1361Sscw 			  0, &sc->sc_exp_ioh))
71bdea1361Sscw 		panic("%s: unable to map Expansion Bus registers",
72a2b8c7fbSmsaitoh 		    device_xname(self));
73bdea1361Sscw 
7450a765e4Smsaitoh #if NPCI > 0
7550a765e4Smsaitoh 	/*
7650a765e4Smsaitoh 	 * Mapping for PCI CSR
7750a765e4Smsaitoh 	 */
7850a765e4Smsaitoh 	if (bus_space_map(sc->sc_iot, IXP425_PCI_HWBASE, IXP425_PCI_SIZE,
7950a765e4Smsaitoh 			  0, &sc->sc_pci_ioh))
80a2b8c7fbSmsaitoh 		panic("%s: unable to map PCI registers", device_xname(self));
8150a765e4Smsaitoh 
82663ccee1Sichiro 	/*
83fb2c5211Sscw 	 * Invoke the board-specific PCI initialization code
84663ccee1Sichiro 	 */
85fb2c5211Sscw 	ixp425_md_pci_init(sc);
86663ccee1Sichiro 
87663ccee1Sichiro 	/*
88fb2c5211Sscw 	 * Generic initialization of the PCI chipset.
89663ccee1Sichiro 	 */
90fb2c5211Sscw 	ixp425_pci_init(sc);
9100eb02e3Sichiro 
9238e0b1c5Sichiro 	/*
9338e0b1c5Sichiro 	 * Initialize the DMA tags.
9438e0b1c5Sichiro 	 */
9538e0b1c5Sichiro 	ixp425_pci_dma_init(sc);
9638e0b1c5Sichiro 
9738e0b1c5Sichiro 	/*
9838e0b1c5Sichiro 	 * Attach the PCI bus.
9938e0b1c5Sichiro 	 */
10038e0b1c5Sichiro 	pba.pba_pc = &sc->ia_pci_chipset;
101663ccee1Sichiro 	pba.pba_iot = &sc->sc_pci_iot;
102663ccee1Sichiro 	pba.pba_memt = &sc->sc_pci_memt;
10338e0b1c5Sichiro 	pba.pba_dmat = &sc->ia_pci_dmat;
10438e0b1c5Sichiro 	pba.pba_bus = 0;	/* bus number = 0 */
105663ccee1Sichiro 	pba.pba_bridgetag = NULL;
10638e0b1c5Sichiro 	pba.pba_intrswiz = 0;	/* XXX */
10738e0b1c5Sichiro 	pba.pba_intrtag = 0;
108a6b2b839Sdyoung 	pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY |
10938e0b1c5Sichiro 			PCI_FLAGS_MRL_OKAY   | PCI_FLAGS_MRM_OKAY |
11038e0b1c5Sichiro 			PCI_FLAGS_MWI_OKAY;
1112685996bSthorpej 	config_found(self, &pba, pcibusprint,
112*c7fb772bSthorpej 	    CFARGS(.iattr = "pcibus"));
11350a765e4Smsaitoh #endif
11400eb02e3Sichiro }
115