gpiobusvar.h revision 213277
1213237Sgonzo/*- 2213237Sgonzo * Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org> 3213237Sgonzo * All rights reserved. 4213237Sgonzo * 5213237Sgonzo * Redistribution and use in source and binary forms, with or without 6213237Sgonzo * modification, are permitted provided that the following conditions 7213237Sgonzo * are met: 8213237Sgonzo * 1. Redistributions of source code must retain the above copyright 9213237Sgonzo * notice, this list of conditions and the following disclaimer. 10213237Sgonzo * 2. Redistributions in binary form must reproduce the above copyright 11213237Sgonzo * notice, this list of conditions and the following disclaimer in the 12213237Sgonzo * documentation and/or other materials provided with the distribution. 13213237Sgonzo * 14213277Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15213277Sgonzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16213277Sgonzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17213277Sgonzo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18213277Sgonzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19213277Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20213277Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21213277Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22213277Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23213277Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24213277Sgonzo * SUCH DAMAGE. 25213237Sgonzo * 26213237Sgonzo * $FreeBSD: head/sys/dev/gpio/gpiobusvar.h 213277 2010-09-29 20:53:33Z gonzo $ 27213237Sgonzo * 28213237Sgonzo */ 29213237Sgonzo 30213237Sgonzo#ifndef __GPIOBUS_H__ 31213237Sgonzo#define __GPIOBUS_H__ 32213237Sgonzo 33213237Sgonzo#include <sys/param.h> 34213237Sgonzo#include <sys/lock.h> 35213237Sgonzo#include <sys/mutex.h> 36213237Sgonzo 37213237Sgonzo#define GPIOBUS_IVAR(d) (struct gpiobus_ivar *) device_get_ivars(d) 38213237Sgonzo#define GPIOBUS_SOFTC(d) (struct gpiobus_softc *) device_get_softc(d) 39213237Sgonzo 40213237Sgonzostruct gpiobus_softc 41213237Sgonzo{ 42213237Sgonzo struct mtx sc_mtx; /* bus mutex */ 43213237Sgonzo device_t sc_busdev; /* bus device */ 44213237Sgonzo device_t sc_owner; /* bus owner */ 45213237Sgonzo device_t sc_dev; /* driver device */ 46213237Sgonzo int sc_npins; /* total pins on bus */ 47213237Sgonzo int *sc_pins_mapped; /* mark mapped pins */ 48213237Sgonzo}; 49213237Sgonzo 50213237Sgonzo 51213237Sgonzostruct gpiobus_ivar 52213237Sgonzo{ 53213237Sgonzo uint32_t npins; /* pins total */ 54213237Sgonzo uint32_t *pins; /* pins map */ 55213237Sgonzo}; 56213237Sgonzo 57213237Sgonzo#endif /* __GPIOBUS_H__ */ 58