[BACK]Return to gpiovar.h CVS log [TXT][DIR] Up to [local] / sys / dev / gpio

Annotation of sys/dev/gpio/gpiovar.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: gpiovar.h,v 1.3 2006/01/14 12:33:49 grange Exp $      */
                      2:
                      3: /*
                      4:  * Copyright (c) 2004, 2006 Alexander Yurchenko <grange@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:        int     pin_mapped;             /* is mapped */
                     38: } gpio_pin_t;
                     39:
                     40: /* Attach GPIO framework to the controller */
                     41: struct gpiobus_attach_args {
                     42:        const char              *gba_name;      /* bus name */
                     43:        gpio_chipset_tag_t      gba_gc;         /* underlying controller */
                     44:        gpio_pin_t              *gba_pins;      /* pins array */
                     45:        int                     gba_npins;      /* total number of pins */
                     46: };
                     47:
                     48: int gpiobus_print(void *, const char *);
                     49:
                     50: /* GPIO framework private methods */
                     51: #define gpiobus_pin_read(gc, pin) \
                     52:     ((gc)->gp_pin_read((gc)->gp_cookie, (pin)))
                     53: #define gpiobus_pin_write(gc, pin, value) \
                     54:     ((gc)->gp_pin_write((gc)->gp_cookie, (pin), (value)))
                     55: #define gpiobus_pin_ctl(gc, pin, flags) \
                     56:     ((gc)->gp_pin_ctl((gc)->gp_cookie, (pin), (flags)))
                     57:
                     58: /* Attach devices connected to the GPIO pins */
                     59: struct gpio_attach_args {
                     60:        void *                  ga_gpio;
                     61:        int                     ga_offset;
                     62:        u_int32_t               ga_mask;
                     63: };
                     64:
                     65: /* GPIO pin map */
                     66: struct gpio_pinmap {
                     67:        int *   pm_map;                 /* pin map */
                     68:        int     pm_size;                /* map size */
                     69: };
                     70:
                     71: int    gpio_pin_map(void *, int, u_int32_t, struct gpio_pinmap *);
                     72: void   gpio_pin_unmap(void *, struct gpio_pinmap *);
                     73: int    gpio_pin_read(void *, struct gpio_pinmap *, int);
                     74: void   gpio_pin_write(void *, struct gpio_pinmap *, int, int);
                     75: void   gpio_pin_ctl(void *, struct gpio_pinmap *, int, int);
                     76: int    gpio_pin_caps(void *, struct gpio_pinmap *, int);
                     77:
                     78: int    gpio_npins(u_int32_t);
                     79:
                     80: #endif /* !_DEV_GPIO_GPIOVAR_H_ */

CVSweb