1164426Ssam/*	$NetBSD: ixp425var.h,v 1.10 2006/04/10 03:36:03 simonb Exp $ */
2164426Ssam
3164426Ssam/*
4164426Ssam * Copyright (c) 2003
5164426Ssam *	Ichiro FUKUHARA <ichiro@ichiro.org>.
6164426Ssam * All rights reserved.
7164426Ssam *
8164426Ssam * Redistribution and use in source and binary forms, with or without
9164426Ssam * modification, are permitted provided that the following conditions
10164426Ssam * are met:
11164426Ssam * 1. Redistributions of source code must retain the above copyright
12164426Ssam *    notice, this list of conditions and the following disclaimer.
13164426Ssam * 2. Redistributions in binary form must reproduce the above copyright
14164426Ssam *    notice, this list of conditions and the following disclaimer in the
15164426Ssam *    documentation and/or other materials provided with the distribution.
16164426Ssam * 3. All advertising materials mentioning features or use of this software
17164426Ssam *    must display the following acknowledgement:
18164426Ssam *	This product includes software developed by Ichiro FUKUHARA.
19164426Ssam * 4. The name of the company nor the name of the author may be used to
20164426Ssam *    endorse or promote products derived from this software without specific
21164426Ssam *    prior written permission.
22164426Ssam *
23164426Ssam * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
24164426Ssam * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25164426Ssam * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26164426Ssam * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
27164426Ssam * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28164426Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29164426Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30164426Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31164426Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32164426Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33164426Ssam * SUCH DAMAGE.
34164426Ssam *
35164426Ssam * $FreeBSD: releng/10.2/sys/arm/xscale/ixp425/ixp425var.h 229125 2011-12-31 15:53:34Z marius $
36164426Ssam *
37164426Ssam */
38164426Ssam
39164426Ssam#ifndef _IXP425VAR_H_
40164426Ssam#define _IXP425VAR_H_
41164426Ssam
42164426Ssam#include <sys/conf.h>
43164426Ssam#include <sys/queue.h>
44164426Ssam
45164426Ssam#include <machine/bus.h>
46164426Ssam
47164426Ssam#include <sys/rman.h>
48164426Ssam
49186352Ssam/* NB: cputype is setup by set_cpufuncs */
50186418Ssam#define	cpu_is_ixp42x()	(cputype == CPU_ID_IXP425)
51186352Ssam#define	cpu_is_ixp43x()	(cputype == CPU_ID_IXP435)
52186352Ssam#define	cpu_is_ixp46x()	(cputype == CPU_ID_IXP465)
53186352Ssam
54164426Ssamstruct ixp425_softc {
55164426Ssam	device_t sc_dev;
56164426Ssam	bus_space_tag_t sc_iot;
57164426Ssam	bus_space_handle_t sc_gpio_ioh;
58164426Ssam	bus_space_handle_t sc_exp_ioh;
59164426Ssam
60164426Ssam	u_int32_t sc_intrmask;
61164426Ssam
62164426Ssam	struct rman sc_irq_rman;
63164426Ssam	struct rman sc_mem_rman;
64166064Scognet	bus_dma_tag_t sc_dmat;
65164426Ssam};
66164426Ssam
67194653Ssamvoid	ixp425_set_gpio(struct ixp425_softc *sc, int pin, int type);
68194653Ssam
69164426Ssamstruct ixppcib_softc {
70164426Ssam	device_t                sc_dev;
71164426Ssam
72164426Ssam	u_int                   sc_bus;
73164426Ssam
74164426Ssam	struct resource         *sc_csr;
75164426Ssam	struct resource         *sc_mem;
76164426Ssam
77164426Ssam	struct rman             sc_io_rman;
78164426Ssam	struct rman             sc_mem_rman;
79164426Ssam	struct rman             sc_irq_rman;
80164426Ssam
81164426Ssam	struct bus_space        sc_pci_memt;
82164426Ssam	struct bus_space        sc_pci_iot;
83166064Scognet	bus_dma_tag_t 		sc_dmat;
84164426Ssam};
85164426Ssam
86164426Ssam#define EXP_BUS_WRITE_4(sc, reg, data) \
87164426Ssam	bus_space_write_4(sc->sc_iot, sc->sc_exp_ioh, reg, data)
88164426Ssam#define EXP_BUS_READ_4(sc, reg) \
89164426Ssam	bus_space_read_4(sc->sc_iot, sc->sc_exp_ioh, reg)
90164426Ssam
91164426Ssam#define	GPIO_CONF_WRITE_4(sc, reg, data)	\
92164426Ssam	bus_space_write_4(sc->sc_iot, sc->sc_gpio_ioh, reg, data)
93164426Ssam#define	GPIO_CONF_READ_4(sc, reg) \
94164426Ssam	bus_space_read_4(sc->sc_iot, sc->sc_gpio_ioh, reg)
95215319Sthompsa#define	IXP4XX_GPIO_LOCK()	mtx_lock(&ixp425_gpio_mtx)
96215319Sthompsa#define	IXP4XX_GPIO_UNLOCK()	mtx_unlock(&ixp425_gpio_mtx)
97215319Sthompsaextern struct mtx ixp425_gpio_mtx;
98164426Ssam
99164426Ssamextern struct bus_space ixp425_bs_tag;
100164426Ssamextern struct bus_space ixp425_a4x_bs_tag;
101164426Ssam
102194670Ssamextern struct bus_space cambria_exp_bs_tag;
103194670Ssamvoid	cambria_exp_bus_init(struct ixp425_softc *);
104194670Ssam
105164426Ssamvoid	ixp425_io_bs_init(bus_space_tag_t, void *);
106164426Ssamvoid	ixp425_mem_bs_init(bus_space_tag_t, void *);
107164426Ssam
108164426Ssamuint32_t ixp425_sdram_size(void);
109186352Ssamuint32_t ixp435_ddram_size(void);
110186418Ssamuint32_t ixp4xx_read_feature_bits(void);
111194319Ssamvoid	ixp4xx_write_feature_bits(uint32_t);
112164426Ssam
113164426Ssamint	ixp425_md_route_interrupt(device_t, device_t, int);
114164426Ssamvoid	ixp425_md_attach(device_t);
115164426Ssam
116170109Sjhayint	getvbase(uint32_t, uint32_t, uint32_t *);
117170109Sjhay
118169952Ssamstruct ixp425_ivar {
119169952Ssam	uint32_t	addr;
120169952Ssam	int		irq;
121169952Ssam};
122169952Ssam#define	IXP425_IVAR(d)	((struct ixp425_ivar *) device_get_ivars(d))
123169952Ssam
124169952Ssamenum {
125169952Ssam	IXP425_IVAR_ADDR,		/* base physical address */
126169952Ssam	IXP425_IVAR_IRQ			/* irq/gpio pin assignment */
127169952Ssam};
128164426Ssam#endif /* _IXP425VAR_H_ */
129