xref: /netbsd-src/sys/arch/evbarm/lubbock/lubbock_var.h (revision fea15f47f1e4285fa837c2053145c1d2ec423dce)
1 /*	$NetBSD: lubbock_var.h,v 1.3 2011/07/01 20:42:37 dyoung Exp $ */
2 
3 /*
4  * Copyright (c) 2002, 2003  Genetec Corporation.  All rights reserved.
5  * Written by Hiroyuki Bessho for Genetec Corporation.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of Genetec Corporation may not be used to endorse or
16  *    promote products derived from this software without specific prior
17  *    written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _EVBARM_LUBBOCK_VAR_H
33 #define _EVBARM_LUBBOCK_VAR_H
34 
35 #include <sys/conf.h>
36 #include <sys/device.h>
37 
38 #include <sys/bus.h>
39 #include <evbarm/lubbock/lubbock_reg.h>
40 
41 
42 /*
43  * Lubbock on-board IO bus
44  */
45 #define N_OBIO_IRQ  8
46 
47 struct obio_softc {
48 	device_t sc_dev;
49 	bus_space_tag_t sc_iot;
50 	bus_space_handle_t sc_obioreg_ioh;
51 	void	*sc_ih;		/* interrupt handler for obio on pxaip */
52 	void	*sc_si;		/* software interrupt handler */
53 	int	sc_intr;
54 	int	sc_obio_intr_mask;
55 	int	sc_obio_intr_pending;
56 	int	sc_ipl;		/* Max ipl among sub interrupts */
57 	struct obio_handler {
58 		int	(* func)(void *);
59 		void	*arg;
60 		int	level;
61 	} sc_handler[N_OBIO_IRQ];
62 };
63 
64 typedef void *obio_chipset_tag_t;
65 
66 struct obio_attach_args {
67 	obio_chipset_tag_t	oba_sc;
68 	bus_space_tag_t		oba_iot; 	/* Bus tag */
69 	bus_addr_t		oba_addr;	/* i/o address  */
70 	int			oba_intr;
71 };
72 
73 /* on-board hex LED */
74 void hex_led_blank( uint32_t value, int blank );
75 #define hex_led(value) ioreg_write( LUBBOCK_OBIO_VBASE+LUBBOCK_HEXLED, (value) )
76 #define hex_led_p(value) ioreg_write( LUBBOCK_OBIO_PBASE+LUBBOCK_HEXLED, (value) )
77 
78 #define d_led(value) ioreg16_write( LUBBOCK_OBIO_VBASE+LUBBOCK_LEDCTL, (value) )
79 
80 /*
81  * IRQ handler
82  */
83 void *obio_intr_establish(struct obio_softc *, int, int, int (*)(void *), void *);
84 void obio_intr_disestablish(void *);
85 
86 #define obio_read(offset)  ioreg_read(LUBBOCK_OBIO_VBASE+(offset))
87 #define obio_write(offset,value)  \
88 	ioreg_write(LUBBOCK_OBIO_VBASE+(offset), (value))
89 
90 
91 #define obio16_read(offset)  ioreg16_read(LUBBOCK_OBIO_VBASE+(offset))
92 #define obio16_write(offset,value)  \
93 	ioreg16_write(LUBBOCK_OBIO_VBASE+(offset), (value))
94 
95 #define obio8_read(offset)  ioreg8_read(LUBBOCK_OBIO_VBASE+(offset))
96 #define obio8_write(offset,value)  \
97 	ioreg8_write(LUBBOCK_OBIO_VBASE+(offset), (value))
98 
99 
100 #endif /* _EVBARM_LUBBOCK_VAR_H */
101