1 /* $NetBSD: intiovar.h,v 1.12 2006/07/19 18:25:40 tsutsui Exp $ */
4 * Copyright (c) 1996, 1998, 2001 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND 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 THE FOUNDATION OR CONTRIBUTORS
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.
33 * Autoconfiguration definitions and prototypes for the hp300
37 #include <machine/bus.h>
38 #include <machine/cpu.h>
40 #include <arch/hp300/dev/intioreg.h>
42 #define INTIO_MOD_LEN 8
45 * Arguments used to attach a device to the internal i/o space.
47 struct intio_attach_args
{
48 char ia_modname
[INTIO_MOD_LEN
]; /* module name */
49 bus_space_tag_t ia_bst
; /* bus space tag */
50 bus_addr_t ia_addr
; /* physical address */
51 bus_size_t ia_iobase
; /* intio iobase */
52 int ia_ipl
; /* interrupt priority level */
55 struct intio_builtins
{
56 const char *ib_modname
; /* module name */
57 bus_size_t ib_offset
; /* intio offset */
58 int ib_ipl
; /* interrupt priority level */
62 * Devices such as the HIL and RTC chips are wired in a consistent
63 * fashion. These routines provide a uniform mechanism for accessing
64 * the devices that are wired to the machine. Doesn't include
65 * memory-mapped devices such as framebuffers.
68 #define WAIT(bst,bsh) \
69 while (bus_space_read_1(bst,bsh,INTIO_DEV_3xx_STAT) \
71 #define DATAWAIT(bst,bsh) \
72 while (!(bus_space_read_1(bst, bsh, INTIO_DEV_3xx_STAT) \
73 & INTIO_DEV_DATA_READY))
76 intio_device_readcmd(bus_space_tag_t bst
, bus_space_handle_t bsh
, int cmd
,
83 bus_space_write_1(bst
, bsh
, INTIO_DEV_3xx_CMD
, cmd
);
87 status
= bus_space_read_1(bst
, bsh
, INTIO_DEV_3xx_STAT
);
88 *datap
= bus_space_read_1(bst
, bsh
, INTIO_DEV_3xx_DATA
);
89 } while (((status
>> INTIO_DEV_SRSHIFT
) & INTIO_DEV_SRMASK
)
90 != INTIO_DEV_SR_DATAAVAIL
);
95 intio_device_writecmd(bus_space_tag_t bst
, bus_space_handle_t bsh
,
96 int cmd
, uint8_t *datap
, int len
)
100 bus_space_write_1(bst
, bsh
, INTIO_DEV_3xx_CMD
, cmd
);
103 bus_space_write_1(bst
, bsh
, INTIO_DEV_3xx_DATA
, *datap
++);
109 intio_device_readstate(bus_space_tag_t bst
, bus_space_handle_t bsh
,
110 uint8_t *statusp
, uint8_t *datap
)
112 *statusp
= bus_space_read_1(bst
, bsh
, INTIO_DEV_3xx_STAT
);
113 *datap
= bus_space_read_1(bst
, bsh
, INTIO_DEV_3xx_DATA
);
119 #define INTIO_DEVSIZE 4096 /* large enough for all machines */
121 #define intio_intr_establish(func, arg, ipl, priority) \
122 intr_establish((func),(arg),(ipl),(priority))