1139825Simp/*-
286231Stmm * Copyright (c) 1999, 2000 Matthew R. Green
3219567Smarius * All rights reserved.
4219567Smarius *
5219567Smarius * Redistribution and use in source and binary forms, with or without
6219567Smarius * modification, are permitted provided that the following conditions
7219567Smarius * are met:
8219567Smarius * 1. Redistributions of source code must retain the above copyright
9219567Smarius *    notice, this list of conditions and the following disclaimer.
10219567Smarius * 2. Redistributions in binary form must reproduce the above copyright
11219567Smarius *    notice, this list of conditions and the following disclaimer in the
12219567Smarius *    documentation and/or other materials provided with the distribution.
13219567Smarius * 3. The name of the author may not be used to endorse or promote products
14219567Smarius *    derived from this software without specific prior written permission.
15219567Smarius *
16219567Smarius * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17219567Smarius * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18219567Smarius * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19219567Smarius * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20219567Smarius * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21219567Smarius * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22219567Smarius * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23219567Smarius * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24219567Smarius * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25219567Smarius * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26219567Smarius * SUCH DAMAGE.
27219567Smarius */
28219567Smarius
29219567Smarius/*-
30219567Smarius * Copyright (c) 1998, 1999 Eduardo E. Horvath
31117119Stmm * Copyright (c) 2001, 2003 by Thomas Moestl <tmm@FreeBSD.org>
3286231Stmm * All rights reserved.
3386231Stmm *
3486231Stmm * Redistribution and use in source and binary forms, with or without
3586231Stmm * modification, are permitted provided that the following conditions
3686231Stmm * are met:
3786231Stmm * 1. Redistributions of source code must retain the above copyright
3886231Stmm *    notice, this list of conditions and the following disclaimer.
3986231Stmm * 2. Redistributions in binary form must reproduce the above copyright
4086231Stmm *    notice, this list of conditions and the following disclaimer in the
4186231Stmm *    documentation and/or other materials provided with the distribution.
4286231Stmm * 3. The name of the author may not be used to endorse or promote products
4386231Stmm *    derived from this software without specific prior written permission.
4486231Stmm *
4586231Stmm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
4686231Stmm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
4786231Stmm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
4886231Stmm * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
4986231Stmm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
5086231Stmm * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
5186231Stmm * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
5286231Stmm * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5386231Stmm * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5486231Stmm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5586231Stmm * SUCH DAMAGE.
5686231Stmm *
57219567Smarius *	from: NetBSD: psychoreg.h,v 1.14 2008/05/30 02:29:37 mrg Exp
5886231Stmm *
5986231Stmm * $FreeBSD$
6086231Stmm */
6186231Stmm
6286231Stmm#ifndef _SPARC64_PCI_OFW_PCI_H_
63182020Smarius#define	_SPARC64_PCI_OFW_PCI_H_
6486231Stmm
65186128Snwhitehorn#include <dev/ofw/ofw_bus_subr.h>
66106555Stmm
67220038Smarius#include "ofw_pci_if.h"
68220038Smarius
69153061Smariustypedef uint32_t ofw_pci_intr_t;
70117119Stmm
7186231Stmm/* PCI range child spaces. XXX: are these MI? */
72153061Smarius#define	OFW_PCI_CS_CONFIG	0x00
73182020Smarius#define	OFW_PCI_CS_IO		0x01
74153061Smarius#define	OFW_PCI_CS_MEM32	0x02
75153061Smarius#define	OFW_PCI_CS_MEM64	0x03
7686231Stmm
77197164Smarius/* OFW device types */
78197164Smarius#define	OFW_TYPE_PCI		"pci"
79197164Smarius#define	OFW_TYPE_PCIE		"pciex"
80197164Smarius
81200918Smariusstruct ofw_pci_msi_addr_ranges {
82200918Smarius	uint32_t	addr32_hi;
83200918Smarius	uint32_t	addr32_lo;
84200918Smarius	uint32_t	addr32_sz;
85200918Smarius	uint32_t	addr64_hi;
86200918Smarius	uint32_t	addr64_lo;
87200918Smarius	uint32_t	addr64_sz;
88200918Smarius};
89200918Smarius
90200918Smarius#define	OFW_PCI_MSI_ADDR_RANGE_32(r) \
91200918Smarius	(((uint64_t)(r)->addr32_hi << 32) | (uint64_t)(r)->addr32_lo)
92200918Smarius#define	OFW_PCI_MSI_ADDR_RANGE_64(r) \
93200918Smarius	(((uint64_t)(r)->addr64_hi << 32) | (uint64_t)(r)->addr64_lo)
94200918Smarius
95200918Smariusstruct ofw_pci_msi_eq_to_devino {
96200918Smarius	uint32_t	eq_first;
97200918Smarius	uint32_t	eq_count;
98200918Smarius	uint32_t	devino_first;
99200918Smarius};
100200918Smarius
101200918Smariusstruct ofw_pci_msi_ranges {
102200918Smarius	uint32_t	first;
103200918Smarius	uint32_t	count;
104200918Smarius};
105200918Smarius
106153061Smariusstruct ofw_pci_ranges {
107153061Smarius	uint32_t	cspace;
108153061Smarius	uint32_t	child_hi;
109153061Smarius	uint32_t	child_lo;
110153061Smarius	uint32_t	phys_hi;
111153061Smarius	uint32_t	phys_lo;
112153061Smarius	uint32_t	size_hi;
113153061Smarius	uint32_t	size_lo;
114153061Smarius};
115117119Stmm
116153061Smarius#define	OFW_PCI_RANGE_CHILD(r) \
117153061Smarius	(((uint64_t)(r)->child_hi << 32) | (uint64_t)(r)->child_lo)
118153061Smarius#define	OFW_PCI_RANGE_PHYS(r) \
119153061Smarius	(((uint64_t)(r)->phys_hi << 32) | (uint64_t)(r)->phys_lo)
120153061Smarius#define	OFW_PCI_RANGE_SIZE(r) \
121153061Smarius	(((uint64_t)(r)->size_hi << 32) | (uint64_t)(r)->size_lo)
122153061Smarius#define	OFW_PCI_RANGE_CS(r)	(((r)->cspace >> 24) & 0x03)
123153061Smarius
124182020Smarius/* default values */
125182020Smarius#define	OFW_PCI_LATENCY	64
126182020Smarius
12786231Stmm#endif /* ! _SPARC64_PCI_OFW_PCI_H_ */
128