hpciovar.h revision 1.4 1 1.4 uch /* $NetBSD: hpciovar.h,v 1.4 2001/06/04 18:59:32 uch Exp $ */
2 1.1 takemura
3 1.1 takemura /*-
4 1.1 takemura * Copyright (c) 2001 TAKEMURA Shin.
5 1.1 takemura * All rights reserved.
6 1.1 takemura *
7 1.1 takemura * Redistribution and use in source and binary forms, with or without
8 1.1 takemura * modification, are permitted provided that the following conditions
9 1.1 takemura * are met:
10 1.1 takemura * 1. Redistributions of source code must retain the above copyright
11 1.1 takemura * notice, this list of conditions and the following disclaimer.
12 1.1 takemura * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 takemura * notice, this list of conditions and the following disclaimer in the
14 1.1 takemura * documentation and/or other materials provided with the distribution.
15 1.1 takemura * 3. Neither the name of the project nor the names of its contributors
16 1.1 takemura * may be used to endorse or promote products derived from this software
17 1.1 takemura * without specific prior written permission.
18 1.1 takemura *
19 1.1 takemura * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 1.1 takemura * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 1.1 takemura * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 1.1 takemura * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 1.1 takemura * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 1.1 takemura * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 1.1 takemura * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 1.1 takemura * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 1.1 takemura * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 1.1 takemura * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 1.1 takemura * SUCH DAMAGE.
30 1.1 takemura *
31 1.1 takemura */
32 1.1 takemura
33 1.1 takemura #ifndef _DEV_HPC_HPCIOVAR_H_
34 1.1 takemura #define _DEV_HPC_HPCIOVAR_H_
35 1.1 takemura
36 1.1 takemura struct hpcio_chip;
37 1.1 takemura typedef struct hpcio_chip *hpcio_chip_t;
38 1.1 takemura typedef void *hpcio_intr_handle_t;
39 1.1 takemura struct hpcio_chip {
40 1.1 takemura int hc_chipid;
41 1.1 takemura char *hc_name;
42 1.1 takemura void *hc_sc;
43 1.1 takemura int (*hc_portread)(hpcio_chip_t, int);
44 1.1 takemura void (*hc_portwrite)(hpcio_chip_t, int, int);
45 1.4 uch hpcio_intr_handle_t(*hc_intr_establish)(hpcio_chip_t, int, int,
46 1.4 uch int (*)(void *), void *);
47 1.1 takemura void (*hc_intr_disestablish)(hpcio_chip_t, hpcio_intr_handle_t);
48 1.1 takemura void (*hc_intr_clear)(hpcio_chip_t, hpcio_intr_handle_t);
49 1.3 takemura void (*hc_register_iochip)(hpcio_chip_t, hpcio_chip_t);
50 1.1 takemura void (*hc_update)(hpcio_chip_t);
51 1.1 takemura void (*hc_dump)(hpcio_chip_t);
52 1.1 takemura };
53 1.1 takemura
54 1.1 takemura struct hpcio_attach_args {
55 1.1 takemura char *haa_busname;
56 1.1 takemura void *haa_sc;
57 1.1 takemura hpcio_chip_t (*haa_getchip)(void*, int);
58 1.3 takemura bus_space_tag_t haa_iot; /* I/O space tag */
59 1.1 takemura };
60 1.2 takemura #define HPCIO_BUSNAME "hpcioif"
61 1.1 takemura
62 1.4 uch #define hpcio_portread(hc, port) \
63 1.1 takemura ((*(hc)->hc_portread)((hc), (port)))
64 1.4 uch #define hpcio_portwrite(hc, port, data) \
65 1.1 takemura ((*(hc)->hc_portwrite)((hc), (port), (data)))
66 1.4 uch #define hpcio_intr_establish(hc, port, mode, func, arg) \
67 1.1 takemura ((*(hc)->hc_intr_establish)((hc),(port),(mode),(func),(arg)))
68 1.4 uch #define hpcio_intr_disestablish(hc, handle) \
69 1.1 takemura ((*(hc)->hc_intr_disestablish)((hc), (handle)))
70 1.4 uch #define hpcio_intr_clear(hc, handle) \
71 1.1 takemura ((*(hc)->hc_intr_clear)((hc), (handle)))
72 1.4 uch #define hpcio_register_iochip(hc, iochip) \
73 1.3 takemura ((*(hc)->hc_register_iochip)((hc), (iochip)))
74 1.4 uch #define hpcio_update(hc) \
75 1.1 takemura ((*(hc)->hc_update)(hc))
76 1.4 uch #define hpcio_dump(hc) \
77 1.1 takemura ((*(hc)->hc_dump)(hc))
78 1.1 takemura
79 1.1 takemura /* interrupt trigger options. */
80 1.1 takemura #define HPCIO_INTR_EDGE (1<<0)
81 1.1 takemura #define HPCIO_INTR_LEVEL (0<<0)
82 1.1 takemura #define HPCIO_INTR_HOLD (1<<1)
83 1.1 takemura #define HPCIO_INTR_THROUGH (0<<1)
84 1.1 takemura #define HPCIO_INTR_HIGH (1<<2)
85 1.1 takemura #define HPCIO_INTR_LOW (0<<2)
86 1.1 takemura #define HPCIO_INTR_POSEDGE (1<<3)
87 1.1 takemura #define HPCIO_INTR_NEGEDGE (1<<4)
88 1.1 takemura
89 1.4 uch #define HPCIO_INTR_LEVEL_HIGH_HOLD \
90 1.1 takemura (HPCIO_INTR_LEVEL|HPCIO_INTR_HIGH|HPCIO_INTR_HOLD)
91 1.4 uch #define HPCIO_INTR_LEVEL_HIGH_THROUGH \
92 1.1 takemura (HPCIO_INTR_LEVEL|HPCIO_INTR_HIGH|HPCIO_INTR_THROUGH)
93 1.4 uch #define HPCIO_INTR_LEVEL_LOW_HOLD \
94 1.1 takemura (HPCIO_INTR_LEVEL|HPCIO_INTR_LOW|HPCIO_INTR_HOLD)
95 1.4 uch #define HPCIO_INTR_LEVEL_LOW_THROUGH \
96 1.1 takemura (HPCIO_INTR_LEVEL|HPCIO_INTR_LOW|HPCIO_INTR_THROUGH)
97 1.4 uch #define HPCIO_INTR_EDGE_HOLD \
98 1.1 takemura (HPCIO_INTR_EDGE|HPCIO_INTR_HOLD)
99 1.4 uch #define HPCIO_INTR_EDGE_THROUGH \
100 1.1 takemura (HPCIO_INTR_EDGE|HPCIO_INTR_THROUGH)
101 1.1 takemura
102 1.1 takemura #endif /* !_DEV_HPC_HPCIOVAR_H_ */
103