1135669Scognet/*	$NetBSD: i80321var.h,v 1.8 2003/10/06 16:06:06 thorpej Exp $	*/
2135669Scognet
3139735Simp/*-
4135669Scognet * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
5135669Scognet * All rights reserved.
6135669Scognet *
7135669Scognet * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8135669Scognet *
9135669Scognet * Redistribution and use in source and binary forms, with or without
10135669Scognet * modification, are permitted provided that the following conditions
11135669Scognet * are met:
12135669Scognet * 1. Redistributions of source code must retain the above copyright
13135669Scognet *    notice, this list of conditions and the following disclaimer.
14135669Scognet * 2. Redistributions in binary form must reproduce the above copyright
15135669Scognet *    notice, this list of conditions and the following disclaimer in the
16135669Scognet *    documentation and/or other materials provided with the distribution.
17135669Scognet * 3. All advertising materials mentioning features or use of this software
18135669Scognet *    must display the following acknowledgement:
19135669Scognet *	This product includes software developed for the NetBSD Project by
20135669Scognet *	Wasabi Systems, Inc.
21135669Scognet * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22135669Scognet *    or promote products derived from this software without specific prior
23135669Scognet *    written permission.
24135669Scognet *
25135669Scognet * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26135669Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27135669Scognet * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28135669Scognet * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29135669Scognet * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30135669Scognet * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31135669Scognet * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32135669Scognet * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33135669Scognet * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34135669Scognet * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35135669Scognet * POSSIBILITY OF SUCH DAMAGE.
36135669Scognet *
37135669Scognet * $FreeBSD$
38135669Scognet *
39135669Scognet */
40135669Scognet
41135669Scognet#ifndef _ARM_XSCALE_I80321VAR_H_
42135669Scognet#define	_ARM_XSCALE_I80321VAR_H_
43135669Scognet
44135669Scognet#include <sys/queue.h>
45135669Scognet#include <dev/pci/pcivar.h>
46150552Scognet#include <sys/rman.h>
47135669Scognet
48135669Scognetextern struct bus_space i80321_bs_tag;
49135669Scognet
50135669Scognetstruct i80321_softc {
51135669Scognet	device_t 		dev;
52135669Scognet	bus_space_tag_t 	sc_st;
53135669Scognet	bus_space_handle_t	sc_sh;
54135669Scognet	/* Handles for the various subregions. */
55135669Scognet	bus_space_handle_t 	sc_atu_sh;
56135669Scognet	bus_space_handle_t 	sc_mcu_sh;
57135669Scognet	int			sc_is_host;
58135669Scognet
59135669Scognet	/*
60135669Scognet	 * We expect the board-specific front-end to have already mapped
61135669Scognet	 * the PCI I/O space .. it is only 64K, and I/O mappings tend to
62135669Scognet	 * be smaller than a page size, so it's generally more efficient
63135669Scognet	 * to map them all into virtual space in one fell swoop.
64135669Scognet	 */
65135669Scognet	vm_offset_t		sc_iow_vaddr;		/* I/O window vaddr */
66135669Scognet
67135669Scognet	/*
68135669Scognet	 * Variables that define the Inbound windows.  The base address of
69135669Scognet	 * 0-2 are configured by a host via BARs.  The xlate variable
70135669Scognet	 * defines the start of the local address space that it maps to.
71135669Scognet	 * The size variable defines the byte size.
72135669Scognet	 *
73135669Scognet	 * The first 3 windows are for incoming PCI memory read/write
74135669Scognet	 * cycles from a host.  The 4th window, not configured by the
75135669Scognet	 * host (as it outside the normal BAR range) is the inbound
76135669Scognet	 * window for PCI devices controlled by the i80321.
77135669Scognet	 */
78135669Scognet	struct {
79135669Scognet		uint32_t iwin_base_hi;
80135669Scognet		uint32_t iwin_base_lo;
81135669Scognet		uint32_t iwin_xlate;
82135669Scognet		uint32_t iwin_size;
83135669Scognet	} sc_iwin[4];
84135669Scognet
85135669Scognet	/*
86135669Scognet	 * Variables that define the Outbound windows.
87135669Scognet	 */
88135669Scognet	struct {
89135669Scognet		uint32_t owin_xlate_lo;
90135669Scognet		uint32_t owin_xlate_hi;
91135669Scognet	} sc_owin[2];
92135669Scognet
93135669Scognet	/*
94135669Scognet	 * This is the PCI address that the Outbound I/O
95135669Scognet	 * window maps to.
96135669Scognet	 */
97135669Scognet	uint32_t		sc_ioout_xlate;
98135669Scognet
99135669Scognet	/* Bus space, DMA, and PCI tags for the PCI bus (private devices). */
100135669Scognet	struct bus_space 	sc_pci_iot;
101135669Scognet	struct bus_space 	sc_pci_memt;
102135669Scognet
103135669Scognet	/* GPIO state */
104135669Scognet	uint8_t sc_gpio_dir;    /* GPIO pin direction (1 == output) */
105135669Scognet	uint8_t sc_gpio_val;    /* GPIO output pin value */
106150552Scognet	struct rman sc_irq_rman;
107135669Scognet
108135669Scognet};
109161592Scognet
110161592Scognet
111161592Scognetstruct i80321_pci_softc {
112161592Scognet	device_t 		sc_dev;
113161592Scognet	bus_space_tag_t 	sc_st;
114161592Scognet	bus_space_handle_t 	sc_atu_sh;
115161592Scognet	bus_space_tag_t		sc_pciio;
116161592Scognet	bus_space_tag_t		sc_pcimem;
117161592Scognet	int			sc_busno;
118161592Scognet	struct rman		sc_mem_rman;
119161592Scognet	struct rman		sc_io_rman;
120161592Scognet	struct rman		sc_irq_rman;
121161592Scognet	uint32_t		sc_mem;
122161592Scognet	uint32_t		sc_io;
123161592Scognet};
124161592Scognet
125135669Scognetvoid	i80321_sdram_bounds(bus_space_tag_t, bus_space_handle_t,
126135669Scognet	    vm_paddr_t *, vm_size_t *);
127135669Scognet
128135669Scognetvoid	i80321_attach(struct i80321_softc *);
129135669Scognetvoid	i80321_calibrate_delay(void);
130135669Scognet
131135669Scognetvoid	i80321_bs_init(bus_space_tag_t, void *);
132135669Scognetvoid	i80321_io_bs_init(bus_space_tag_t, void *);
133135669Scognetvoid	i80321_mem_bs_init(bus_space_tag_t, void *);
134161592Scognetextern int machdep_pci_route_interrupt(device_t pcib, device_t dev, int pin);
135135669Scognet
136161592Scognet
137135669Scognet#endif /* _ARM_XSCALE_I80321VAR_H_ */
138