Deleted Added
sdiff udiff text old ( 277968 ) new ( 277996 )
full compact
1/*-
2 * Copyright (c) 2013 Ganbold Tsagaankhuu <ganbold@freebsd.org>
3 * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org>
4 * Copyright (c) 2012 Luiz Otavio O Souza.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 */
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/arm/allwinner/a10_gpio.c 277968 2015-01-31 12:17:07Z loos $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/bus.h>
35
36#include <sys/kernel.h>
37#include <sys/module.h>
38#include <sys/rman.h>

--- 4 unchanged lines hidden (view full) ---

43#include <machine/bus.h>
44#include <machine/cpu.h>
45#include <machine/cpufunc.h>
46#include <machine/resource.h>
47#include <machine/fdt.h>
48#include <machine/intr.h>
49
50#include <dev/fdt/fdt_common.h>
51#include <dev/ofw/ofw_bus.h>
52#include <dev/ofw/ofw_bus_subr.h>
53
54#include "gpio_if.h"
55#include "a10_gpio.h"
56
57/*
58 * A10 have 9 banks of gpio.

--- 11 unchanged lines hidden (view full) ---

70#define A10_GPIO_PULLUP 1
71#define A10_GPIO_PULLDOWN 2
72
73#define A10_GPIO_INPUT 0
74#define A10_GPIO_OUTPUT 1
75
76struct a10_gpio_softc {
77 device_t sc_dev;
78 struct mtx sc_mtx;
79 struct resource * sc_mem_res;
80 struct resource * sc_irq_res;
81 bus_space_tag_t sc_bst;
82 bus_space_handle_t sc_bsh;
83 void * sc_intrhand;
84 int sc_gpio_npins;
85 struct gpio_pin sc_gpio_pins[A10_GPIO_PINS];

--- 126 unchanged lines hidden (view full) ---

212 a10_gpio_set_pud(sc, pin->gp_pin, A10_GPIO_PULLDOWN);
213 }
214 } else
215 a10_gpio_set_pud(sc, pin->gp_pin, A10_GPIO_NONE);
216
217 A10_GPIO_UNLOCK(sc);
218}
219
220static int
221a10_gpio_pin_max(device_t dev, int *maxpin)
222{
223
224 *maxpin = A10_GPIO_PINS - 1;
225 return (0);
226}
227

--- 225 unchanged lines hidden (view full) ---

453 snprintf(sc->sc_gpio_pins[i].gp_name, GPIOMAXNAME,
454 "pin %d", i);
455 func = a10_gpio_get_function(sc, i);
456 sc->sc_gpio_pins[i].gp_pin = i;
457 sc->sc_gpio_pins[i].gp_caps = A10_GPIO_DEFAULT_CAPS;
458 sc->sc_gpio_pins[i].gp_flags = a10_gpio_func_flag(func);
459 }
460 sc->sc_gpio_npins = i;
461
462 device_add_child(dev, "gpioc", -1);
463 device_add_child(dev, "gpiobus", -1);
464
465 a10_gpio_sc = sc;
466
467 return (bus_generic_attach(dev));
468
469fail:
470 if (sc->sc_irq_res)
471 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res);
472 if (sc->sc_mem_res)
473 bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
474 mtx_destroy(&sc->sc_mtx);
475

--- 9 unchanged lines hidden (view full) ---

485
486static device_method_t a10_gpio_methods[] = {
487 /* Device interface */
488 DEVMETHOD(device_probe, a10_gpio_probe),
489 DEVMETHOD(device_attach, a10_gpio_attach),
490 DEVMETHOD(device_detach, a10_gpio_detach),
491
492 /* GPIO protocol */
493 DEVMETHOD(gpio_pin_max, a10_gpio_pin_max),
494 DEVMETHOD(gpio_pin_getname, a10_gpio_pin_getname),
495 DEVMETHOD(gpio_pin_getflags, a10_gpio_pin_getflags),
496 DEVMETHOD(gpio_pin_getcaps, a10_gpio_pin_getcaps),
497 DEVMETHOD(gpio_pin_setflags, a10_gpio_pin_setflags),
498 DEVMETHOD(gpio_pin_get, a10_gpio_pin_get),
499 DEVMETHOD(gpio_pin_set, a10_gpio_pin_set),
500 DEVMETHOD(gpio_pin_toggle, a10_gpio_pin_toggle),

--- 29 unchanged lines hidden ---