gpiobus.c (297199) | gpiobus.c (298738) |
---|---|
1/*- 2 * Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/gpio/gpiobus.c 297199 2016-03-22 22:25:08Z jhibbits $"); | 28__FBSDID("$FreeBSD: head/sys/dev/gpio/gpiobus.c 298738 2016-04-28 12:03:22Z mmel $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bus.h> 33#include <sys/gpio.h> | 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bus.h> 33#include <sys/gpio.h> |
34#include <sys/intr.h> |
|
34#include <sys/kernel.h> 35#include <sys/malloc.h> 36#include <sys/module.h> 37 38#include <dev/gpio/gpiobusvar.h> 39 40#include "gpiobus_if.h" 41 --- 25 unchanged lines hidden (view full) --- 67static void gpiobus_release_bus(device_t, device_t); 68static int gpiobus_pin_setflags(device_t, device_t, uint32_t, uint32_t); 69static int gpiobus_pin_getflags(device_t, device_t, uint32_t, uint32_t*); 70static int gpiobus_pin_getcaps(device_t, device_t, uint32_t, uint32_t*); 71static int gpiobus_pin_set(device_t, device_t, uint32_t, unsigned int); 72static int gpiobus_pin_get(device_t, device_t, uint32_t, unsigned int*); 73static int gpiobus_pin_toggle(device_t, device_t, uint32_t); 74 | 35#include <sys/kernel.h> 36#include <sys/malloc.h> 37#include <sys/module.h> 38 39#include <dev/gpio/gpiobusvar.h> 40 41#include "gpiobus_if.h" 42 --- 25 unchanged lines hidden (view full) --- 68static void gpiobus_release_bus(device_t, device_t); 69static int gpiobus_pin_setflags(device_t, device_t, uint32_t, uint32_t); 70static int gpiobus_pin_getflags(device_t, device_t, uint32_t, uint32_t*); 71static int gpiobus_pin_getcaps(device_t, device_t, uint32_t, uint32_t*); 72static int gpiobus_pin_set(device_t, device_t, uint32_t, unsigned int); 73static int gpiobus_pin_get(device_t, device_t, uint32_t, unsigned int*); 74static int gpiobus_pin_toggle(device_t, device_t, uint32_t); 75 |
76/* 77 * XXX -> Move me to better place - gpio_subr.c? 78 * Also, this function must be changed when interrupt configuration 79 * data will be moved into struct resource. 80 */ 81#ifdef INTRNG 82struct resource * 83gpio_alloc_intr_resource(device_t consumer_dev, int *rid, u_int alloc_flags, 84 gpio_pin_t pin, uint32_t intr_mode) 85{ 86 u_int irqnum; 87 88 /* 89 * Allocate new fictitious interrupt number and store configuration 90 * into it. 91 */ 92 irqnum = intr_gpio_map_irq(pin->dev, pin->pin, pin->flags, intr_mode); 93 if (irqnum == 0xFFFFFFFF) 94 return (NULL); 95 96 return (bus_alloc_resource(consumer_dev, SYS_RES_IRQ, rid, 97 irqnum, irqnum, 1, alloc_flags)); 98} 99#endif 100 |
|
75int 76gpio_check_flags(uint32_t caps, uint32_t flags) 77{ 78 79 /* Check for unwanted flags. */ 80 if ((flags & caps) == 0 || (flags & caps) != flags) 81 return (EINVAL); 82 /* Cannot mix input/output together. */ --- 709 unchanged lines hidden --- | 101int 102gpio_check_flags(uint32_t caps, uint32_t flags) 103{ 104 105 /* Check for unwanted flags. */ 106 if ((flags & caps) == 0 || (flags & caps) != flags) 107 return (EINVAL); 108 /* Cannot mix input/output together. */ --- 709 unchanged lines hidden --- |