Deleted Added
full compact
a10_gpio.c (266152) a10_gpio.c (266274)
1/*-
2 * Copyright (c) 2013 Ganbold Tsagaankhuu <ganbold@gmail.com>
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>
1/*-
2 * Copyright (c) 2013 Ganbold Tsagaankhuu <ganbold@gmail.com>
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: stable/10/sys/arm/allwinner/a10_gpio.c 266152 2014-05-15 16:11:06Z ian $");
30__FBSDID("$FreeBSD: stable/10/sys/arm/allwinner/a10_gpio.c 266274 2014-05-16 23:27:18Z ian $");
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>

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

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"
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>

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

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"
55
56/*
57 * A10 have 9 banks of gpio.
58 * 32 pins per bank:
59 * PA0 - PA17 | PB0 - PB23 | PC0 - PC24
60 * PD0 - PD27 | PE0 - PE31 | PF0 - PF5
61 * PG0 - PG9 | PH0 - PH27 | PI0 - PI12
62 */

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

97#define A10_GPIO_GP_INT_CFG1 0x204
98#define A10_GPIO_GP_INT_CFG2 0x208
99#define A10_GPIO_GP_INT_CFG3 0x20c
100
101#define A10_GPIO_GP_INT_CTL 0x210
102#define A10_GPIO_GP_INT_STA 0x214
103#define A10_GPIO_GP_INT_DEB 0x218
104
56
57/*
58 * A10 have 9 banks of gpio.
59 * 32 pins per bank:
60 * PA0 - PA17 | PB0 - PB23 | PC0 - PC24
61 * PD0 - PD27 | PE0 - PE31 | PF0 - PF5
62 * PG0 - PG9 | PH0 - PH27 | PI0 - PI12
63 */

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

98#define A10_GPIO_GP_INT_CFG1 0x204
99#define A10_GPIO_GP_INT_CFG2 0x208
100#define A10_GPIO_GP_INT_CFG3 0x20c
101
102#define A10_GPIO_GP_INT_CTL 0x210
103#define A10_GPIO_GP_INT_STA 0x214
104#define A10_GPIO_GP_INT_DEB 0x218
105
106static struct a10_gpio_softc *a10_gpio_sc;
107
105#define A10_GPIO_WRITE(_sc, _off, _val) \
106 bus_space_write_4(_sc->sc_bst, _sc->sc_bsh, _off, _val)
107#define A10_GPIO_READ(_sc, _off) \
108 bus_space_read_4(_sc->sc_bst, _sc->sc_bsh, _off)
109
110static uint32_t
111a10_gpio_get_function(struct a10_gpio_softc *sc, uint32_t pin)
112{

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

468 sc->sc_gpio_pins[i].gp_pin = i;
469 sc->sc_gpio_pins[i].gp_caps = A10_GPIO_DEFAULT_CAPS;
470 sc->sc_gpio_pins[i].gp_flags = a10_gpio_func_flag(func);
471 }
472 sc->sc_gpio_npins = i;
473
474 device_add_child(dev, "gpioc", device_get_unit(dev));
475 device_add_child(dev, "gpiobus", device_get_unit(dev));
108#define A10_GPIO_WRITE(_sc, _off, _val) \
109 bus_space_write_4(_sc->sc_bst, _sc->sc_bsh, _off, _val)
110#define A10_GPIO_READ(_sc, _off) \
111 bus_space_read_4(_sc->sc_bst, _sc->sc_bsh, _off)
112
113static uint32_t
114a10_gpio_get_function(struct a10_gpio_softc *sc, uint32_t pin)
115{

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

471 sc->sc_gpio_pins[i].gp_pin = i;
472 sc->sc_gpio_pins[i].gp_caps = A10_GPIO_DEFAULT_CAPS;
473 sc->sc_gpio_pins[i].gp_flags = a10_gpio_func_flag(func);
474 }
475 sc->sc_gpio_npins = i;
476
477 device_add_child(dev, "gpioc", device_get_unit(dev));
478 device_add_child(dev, "gpiobus", device_get_unit(dev));
479
480 a10_gpio_sc = sc;
481
476 return (bus_generic_attach(dev));
477
478fail:
479 if (sc->sc_irq_res)
480 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res);
481 if (sc->sc_mem_res)
482 bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
483 return (ENXIO);

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

513
514static driver_t a10_gpio_driver = {
515 "gpio",
516 a10_gpio_methods,
517 sizeof(struct a10_gpio_softc),
518};
519
520DRIVER_MODULE(a10_gpio, simplebus, a10_gpio_driver, a10_gpio_devclass, 0, 0);
482 return (bus_generic_attach(dev));
483
484fail:
485 if (sc->sc_irq_res)
486 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res);
487 if (sc->sc_mem_res)
488 bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
489 return (ENXIO);

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

519
520static driver_t a10_gpio_driver = {
521 "gpio",
522 a10_gpio_methods,
523 sizeof(struct a10_gpio_softc),
524};
525
526DRIVER_MODULE(a10_gpio, simplebus, a10_gpio_driver, a10_gpio_devclass, 0, 0);
527
528int
529a10_emac_gpio_config(uint32_t pin)
530{
531 struct a10_gpio_softc *sc = a10_gpio_sc;
532
533 if (sc == NULL)
534 return (ENXIO);
535
536 /* Configure pin mux settings for MII. */
537 A10_GPIO_LOCK(sc);
538 a10_gpio_set_function(sc, pin, A10_GPIO_PULLDOWN);
539 A10_GPIO_UNLOCK(sc);
540
541 return (0);
542}