1*b87210faStsutsui /* $NetBSD: pci.c,v 1.2 2008/05/14 13:29:28 tsutsui Exp $ */
28b1c40bcStsutsui
3*b87210faStsutsui /*-
48b1c40bcStsutsui * Copyright (c) 2008 Izumi Tsutsui. All rights reserved.
58b1c40bcStsutsui *
68b1c40bcStsutsui * Redistribution and use in source and binary forms, with or without
78b1c40bcStsutsui * modification, are permitted provided that the following conditions
88b1c40bcStsutsui * are met:
98b1c40bcStsutsui * 1. Redistributions of source code must retain the above copyright
108b1c40bcStsutsui * notice, this list of conditions and the following disclaimer.
118b1c40bcStsutsui * 2. Redistributions in binary form must reproduce the above copyright
128b1c40bcStsutsui * notice, this list of conditions and the following disclaimer in the
138b1c40bcStsutsui * documentation and/or other materials provided with the distribution.
148b1c40bcStsutsui *
158b1c40bcStsutsui * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
168b1c40bcStsutsui * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
178b1c40bcStsutsui * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
188b1c40bcStsutsui * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
198b1c40bcStsutsui * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
208b1c40bcStsutsui * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
218b1c40bcStsutsui * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
228b1c40bcStsutsui * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
238b1c40bcStsutsui * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
248b1c40bcStsutsui * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
258b1c40bcStsutsui */
268b1c40bcStsutsui
278b1c40bcStsutsui #include <sys/param.h>
288b1c40bcStsutsui
298b1c40bcStsutsui #include <lib/libsa/stand.h>
308b1c40bcStsutsui #include <lib/libkern/libkern.h>
318b1c40bcStsutsui
328b1c40bcStsutsui #include <mips/cpuregs.h>
338b1c40bcStsutsui #include <cobalt/dev/gtreg.h>
348b1c40bcStsutsui
358b1c40bcStsutsui #include "boot.h"
368b1c40bcStsutsui
378b1c40bcStsutsui #define GT_BASE 0x14000000
388b1c40bcStsutsui
398b1c40bcStsutsui uint32_t
pcicfgread(uint32_t tag,uint32_t off)408b1c40bcStsutsui pcicfgread(uint32_t tag, uint32_t off)
418b1c40bcStsutsui {
428b1c40bcStsutsui uint32_t reg;
438b1c40bcStsutsui volatile uint32_t *pcicfg_addr, *pcicfg_data;
448b1c40bcStsutsui
458b1c40bcStsutsui pcicfg_addr = (uint32_t *)MIPS_PHYS_TO_KSEG1(GT_BASE + GT_PCICFG_ADDR);
468b1c40bcStsutsui pcicfg_data = (uint32_t *)MIPS_PHYS_TO_KSEG1(GT_BASE + GT_PCICFG_DATA);
478b1c40bcStsutsui
488b1c40bcStsutsui *pcicfg_addr = PCICFG_ENABLE | tag | (off & ~3U);
498b1c40bcStsutsui reg = *pcicfg_data;
508b1c40bcStsutsui *pcicfg_addr = 0;
518b1c40bcStsutsui
528b1c40bcStsutsui return reg;
538b1c40bcStsutsui }
54