gpiovar.h revision 1.1 1 1.1 jmcneill /* $NetBSD: gpiovar.h,v 1.1 2005/09/27 02:34:02 jmcneill Exp $ */
2 1.1 jmcneill /* $OpenBSD: gpiovar.h,v 1.1 2004/06/03 18:08:00 grange Exp $ */
3 1.1 jmcneill /*
4 1.1 jmcneill * Copyright (c) 2004 Alexander Yurchenko <grange (at) openbsd.org>
5 1.1 jmcneill *
6 1.1 jmcneill * Permission to use, copy, modify, and distribute this software for any
7 1.1 jmcneill * purpose with or without fee is hereby granted, provided that the above
8 1.1 jmcneill * copyright notice and this permission notice appear in all copies.
9 1.1 jmcneill *
10 1.1 jmcneill * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 1.1 jmcneill * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 1.1 jmcneill * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 1.1 jmcneill * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 1.1 jmcneill * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 1.1 jmcneill * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 1.1 jmcneill * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 1.1 jmcneill */
18 1.1 jmcneill
19 1.1 jmcneill #ifndef _DEV_GPIO_GPIOVAR_H_
20 1.1 jmcneill #define _DEV_GPIO_GPIOVAR_H_
21 1.1 jmcneill
22 1.1 jmcneill /* GPIO controller description */
23 1.1 jmcneill typedef struct gpio_chipset_tag {
24 1.1 jmcneill void *gp_cookie;
25 1.1 jmcneill
26 1.1 jmcneill int (*gp_pin_read)(void *, int);
27 1.1 jmcneill void (*gp_pin_write)(void *, int, int);
28 1.1 jmcneill void (*gp_pin_ctl)(void *, int, int);
29 1.1 jmcneill } *gpio_chipset_tag_t;
30 1.1 jmcneill
31 1.1 jmcneill /* GPIO pin description */
32 1.1 jmcneill typedef struct gpio_pin {
33 1.1 jmcneill int pin_num; /* number */
34 1.1 jmcneill int pin_caps; /* capabilities */
35 1.1 jmcneill int pin_flags; /* current configuration */
36 1.1 jmcneill int pin_state; /* current state */
37 1.1 jmcneill } gpio_pin_t;
38 1.1 jmcneill
39 1.1 jmcneill /* Attach GPIO framework to the controller */
40 1.1 jmcneill struct gpiobus_attach_args {
41 1.1 jmcneill const char *gba_name; /* bus name */
42 1.1 jmcneill gpio_chipset_tag_t gba_gc; /* underlying controller */
43 1.1 jmcneill gpio_pin_t *gba_pins; /* pins array */
44 1.1 jmcneill int gba_npins; /* total number of pins */
45 1.1 jmcneill };
46 1.1 jmcneill
47 1.1 jmcneill int gpiobus_print(void *, const char *);
48 1.1 jmcneill
49 1.1 jmcneill /* GPIO framework private methods */
50 1.1 jmcneill #define gpiobus_pin_read(gc, pin) \
51 1.1 jmcneill ((gc)->gp_pin_read((gc)->gp_cookie, (pin)))
52 1.1 jmcneill #define gpiobus_pin_write(gc, pin, value) \
53 1.1 jmcneill ((gc)->gp_pin_write((gc)->gp_cookie, (pin), (value)))
54 1.1 jmcneill #define gpiobus_pin_ctl(gc, pin, flags) \
55 1.1 jmcneill ((gc)->gp_pin_ctl((gc)->gp_cookie, (pin), (flags)))
56 1.1 jmcneill
57 1.1 jmcneill
58 1.1 jmcneill /* Attach devices connected to the GPIO pins */
59 1.1 jmcneill struct gpio_attach_args {
60 1.1 jmcneill int ga_pin;
61 1.1 jmcneill u_int32_t ga_mask;
62 1.1 jmcneill };
63 1.1 jmcneill
64 1.1 jmcneill #endif /* !_DEV_GPIO_GPIOVAR_H_ */
65