Deleted Added
sdiff udiff text old ( 277882 ) new ( 277996 )
full compact
1/*-
2 * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org>
3 * Copyright (c) 2009, Luiz Otavio O Souza.
4 * Copyright (c) 2010, Andrew Thompson <thompsa@FreeBSD.org>
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

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

27 * SUCH DAMAGE.
28 */
29
30/*
31 * GPIO driver for Gateworks Avilia
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/arm/xscale/ixp425/avila_gpio.c 277882 2015-01-29 18:08:50Z loos $");
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/bus.h>
40
41#include <sys/kernel.h>
42#include <sys/module.h>
43#include <sys/rman.h>
44#include <sys/lock.h>
45#include <sys/mutex.h>
46#include <sys/gpio.h>
47
48#include <machine/bus.h>
49#include <machine/resource.h>
50#include <arm/xscale/ixp425/ixp425reg.h>
51#include <arm/xscale/ixp425/ixp425var.h>
52
53#include "gpio_if.h"
54
55#define GPIO_SET_BITS(sc, reg, bits) \
56 GPIO_CONF_WRITE_4(sc, reg, GPIO_CONF_READ_4(sc, (reg)) | (bits))
57
58#define GPIO_CLEAR_BITS(sc, reg, bits) \
59 GPIO_CONF_WRITE_4(sc, reg, GPIO_CONF_READ_4(sc, (reg)) & ~(bits))
60
61struct avila_gpio_softc {
62 device_t sc_dev;
63 bus_space_tag_t sc_iot;
64 bus_space_handle_t sc_gpio_ioh;
65 uint32_t sc_valid;
66 struct gpio_pin sc_pins[IXP4XX_GPIO_PINS];
67};
68
69struct avila_gpio_pin {
70 const char *name;

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

111 */
112static int avila_gpio_probe(device_t dev);
113static int avila_gpio_attach(device_t dev);
114static int avila_gpio_detach(device_t dev);
115
116/*
117 * GPIO interface
118 */
119static int avila_gpio_pin_max(device_t dev, int *maxpin);
120static int avila_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps);
121static int avila_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t
122 *flags);
123static int avila_gpio_pin_getname(device_t dev, uint32_t pin, char *name);
124static int avila_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags);
125static int avila_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value);
126static int avila_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val);

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

157 else {
158 pin->gp_flags |= GPIO_PIN_INPUT;
159 GPIO_SET_BITS(sc, IXP425_GPIO_GPOER, mask);
160 }
161 IXP4XX_GPIO_UNLOCK();
162 }
163}
164
165static int
166avila_gpio_pin_max(device_t dev, int *maxpin)
167{
168
169 *maxpin = IXP4XX_GPIO_PINS - 1;
170 return (0);
171}
172

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

305
306 strncpy(sc->sc_pins[p->pin].gp_name, p->name, GPIOMAXNAME);
307 sc->sc_pins[p->pin].gp_pin = p->pin;
308 sc->sc_pins[p->pin].gp_caps = p->caps;
309 sc->sc_pins[p->pin].gp_flags = avila_gpio_pin_flags(sc, p->pin);
310 sc->sc_valid |= 1 << p->pin;
311 }
312
313 device_add_child(dev, "gpioc", -1);
314 device_add_child(dev, "gpiobus", -1);
315
316 return (bus_generic_attach(dev));
317#undef N
318}
319
320static int
321avila_gpio_detach(device_t dev)
322{
323
324 bus_generic_detach(dev);
325
326 return(0);
327}
328
329static device_method_t gpio_avila_methods[] = {
330 DEVMETHOD(device_probe, avila_gpio_probe),
331 DEVMETHOD(device_attach, avila_gpio_attach),
332 DEVMETHOD(device_detach, avila_gpio_detach),
333
334 /* GPIO protocol */
335 DEVMETHOD(gpio_pin_max, avila_gpio_pin_max),
336 DEVMETHOD(gpio_pin_getname, avila_gpio_pin_getname),
337 DEVMETHOD(gpio_pin_getflags, avila_gpio_pin_getflags),
338 DEVMETHOD(gpio_pin_getcaps, avila_gpio_pin_getcaps),
339 DEVMETHOD(gpio_pin_setflags, avila_gpio_pin_setflags),
340 DEVMETHOD(gpio_pin_get, avila_gpio_pin_get),
341 DEVMETHOD(gpio_pin_set, avila_gpio_pin_set),
342 DEVMETHOD(gpio_pin_toggle, avila_gpio_pin_toggle),

--- 12 unchanged lines hidden ---