xref: /netbsd-src/sys/dev/marvell/gtdevbusvar.h (revision a748aedcb5b3b2e2c40b4d23f725330e2ae9ef88)
1*a748aedcSkiyohara /*	$NetBSD: gtdevbusvar.h,v 1.1 2010/04/28 13:51:56 kiyohara Exp $	*/
2*a748aedcSkiyohara /*
3*a748aedcSkiyohara  * Copyright (c) 2009 KIYOHARA Takashi
4*a748aedcSkiyohara  * All rights reserved.
5*a748aedcSkiyohara  *
6*a748aedcSkiyohara  * Redistribution and use in source and binary forms, with or without
7*a748aedcSkiyohara  * modification, are permitted provided that the following conditions
8*a748aedcSkiyohara  * are met:
9*a748aedcSkiyohara  * 1. Redistributions of source code must retain the above copyright
10*a748aedcSkiyohara  *    notice, this list of conditions and the following disclaimer.
11*a748aedcSkiyohara  * 2. Redistributions in binary form must reproduce the above copyright
12*a748aedcSkiyohara  *    notice, this list of conditions and the following disclaimer in the
13*a748aedcSkiyohara  *    documentation and/or other materials provided with the distribution.
14*a748aedcSkiyohara  *
15*a748aedcSkiyohara  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*a748aedcSkiyohara  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17*a748aedcSkiyohara  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18*a748aedcSkiyohara  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19*a748aedcSkiyohara  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20*a748aedcSkiyohara  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21*a748aedcSkiyohara  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22*a748aedcSkiyohara  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23*a748aedcSkiyohara  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24*a748aedcSkiyohara  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25*a748aedcSkiyohara  * POSSIBILITY OF SUCH DAMAGE.
26*a748aedcSkiyohara  */
27*a748aedcSkiyohara #ifndef _GTDEVBUSVAR_H_
28*a748aedcSkiyohara #define _GTDEVBUSVAR_H_
29*a748aedcSkiyohara 
30*a748aedcSkiyohara static __inline int
gt_devbus_addr(device_t gt,int unit,uint32_t * ldp,uint32_t * hdp)31*a748aedcSkiyohara gt_devbus_addr(device_t gt, int unit, uint32_t *ldp, uint32_t *hdp)
32*a748aedcSkiyohara {
33*a748aedcSkiyohara 	static const struct {
34*a748aedcSkiyohara 		bus_addr_t low_decode;
35*a748aedcSkiyohara 		bus_addr_t high_decode;
36*a748aedcSkiyohara 	} obio_info[5] = {
37*a748aedcSkiyohara 		{ GT_CS0_Low_Decode, GT_CS0_High_Decode, },
38*a748aedcSkiyohara 		{ GT_CS1_Low_Decode, GT_CS1_High_Decode, },
39*a748aedcSkiyohara 		{ GT_CS2_Low_Decode, GT_CS2_High_Decode, },
40*a748aedcSkiyohara 		{ GT_CS3_Low_Decode, GT_CS3_High_Decode, },
41*a748aedcSkiyohara 		{ GT_BootCS_Low_Decode, GT_BootCS_High_Decode, },
42*a748aedcSkiyohara 	};
43*a748aedcSkiyohara 	struct gt_softc *sc = device_private(gt);
44*a748aedcSkiyohara 
45*a748aedcSkiyohara 	if (unit >= __arraycount(obio_info))
46*a748aedcSkiyohara 		return -1;
47*a748aedcSkiyohara 
48*a748aedcSkiyohara 	*ldp = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
49*a748aedcSkiyohara 	    obio_info[unit].low_decode);
50*a748aedcSkiyohara 	*hdp = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
51*a748aedcSkiyohara 	    obio_info[unit].high_decode);
52*a748aedcSkiyohara 	return 0;
53*a748aedcSkiyohara }
54*a748aedcSkiyohara 
55*a748aedcSkiyohara #endif	/* _GTDEVBUSVAR_H_ */
56