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