/* $NetBSD: gt_mainbus.c,v 1.6 2020/11/21 17:48:26 thorpej Exp $ */
/*
* Copyright (c) 2010 KIYOHARA Takashi
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#if NGTPCI > 0
/* bus space map the I/O and Memory ranges of PCI unit 1(PCI bus) */
node = of_find_firstchild_byname(OF_finddevice("/"), "pci");
if (node != -1) {
gtpci1_io_bs_tag.pbs_flags =
_BUS_SPACE_LITTLE_ENDIAN | _BUS_SPACE_IO_TYPE;
gtpci1_io_bs_tag.pbs_base = 0x00000000;
if (ofwoea_map_space(RANGE_TYPE_PCI, RANGE_IO, node,
>pci1_io_bs_tag, "gtpci 1 io-space") != 0)
panic("Can't init gtpci 1 io tag");
gtpci1_mem_bs_tag.pbs_flags =
_BUS_SPACE_LITTLE_ENDIAN | _BUS_SPACE_MEM_TYPE;
gtpci1_mem_bs_tag.pbs_base = 0x00000000;
if (ofwoea_map_space(RANGE_TYPE_PCI, RANGE_MEM, node,
>pci1_mem_bs_tag, "gtpci 1 mem-space") != 0)
panic("Can't init gtpci 1 mem tag");
/* PCI bus number */
if (OF_getprop(node, "bus-range", busrange, sizeof(busrange)) !=
sizeof(busrange)) {
aprint_error(": PCI bus range failed\n");
return;
}
/* bus space map the I/O and Memory ranges of PCI unit 0(AGP bus) */
if (node != -1)
node = of_getnode_byname(OF_peer(node), "pci");
if (node != -1 && node != 0) {
gtpci0_io_bs_tag.pbs_flags =
_BUS_SPACE_LITTLE_ENDIAN | _BUS_SPACE_IO_TYPE;
gtpci0_io_bs_tag.pbs_base = 0x00000000;
if (ofwoea_map_space(RANGE_TYPE_PCI, RANGE_IO, node,
>pci0_io_bs_tag, "gtpci 0 io-space") != 0)
panic("Can't init gtpci 0 io tag");
gtpci0_mem_bs_tag.pbs_flags =
_BUS_SPACE_LITTLE_ENDIAN | _BUS_SPACE_MEM_TYPE;
gtpci0_mem_bs_tag.pbs_base = 0x00000000;
if (ofwoea_map_space(RANGE_TYPE_PCI, RANGE_MEM, node,
>pci0_mem_bs_tag, "gtpci 0 mem-space") != 0)
panic("Can't init gtpci 0 mem tag");
/* PCI bus number */
if (OF_getprop(node, "bus-range", busrange, sizeof(busrange)) !=
sizeof(busrange)) {
aprint_error(": AGP bus range failed\n");
return;
}