diff options
-rw-r--r-- | sys/arch/armv7/imx/if_fec.c | 3 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxgpio.c | 127 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxgpiovar.h | 32 |
3 files changed, 2 insertions, 160 deletions
diff --git a/sys/arch/armv7/imx/if_fec.c b/sys/arch/armv7/imx/if_fec.c index 4e52631a578..a075028b57d 100644 --- a/sys/arch/armv7/imx/if_fec.c +++ b/sys/arch/armv7/imx/if_fec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_fec.c,v 1.21 2018/03/11 17:58:52 kettenis Exp $ */ +/* $OpenBSD: if_fec.c,v 1.22 2018/03/30 19:26:38 patrick Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> * @@ -46,7 +46,6 @@ #include <armv7/armv7/armv7var.h> #include <armv7/imx/imxccmvar.h> -#include <armv7/imx/imxgpiovar.h> #include <dev/ofw/openfirm.h> #include <dev/ofw/ofw_gpio.h> diff --git a/sys/arch/armv7/imx/imxgpio.c b/sys/arch/armv7/imx/imxgpio.c index 69a7a2021f9..ad16fbb1c7b 100644 --- a/sys/arch/armv7/imx/imxgpio.c +++ b/sys/arch/armv7/imx/imxgpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxgpio.c,v 1.12 2017/06/22 11:34:51 tom Exp $ */ +/* $OpenBSD: imxgpio.c,v 1.13 2018/03/30 19:26:38 patrick Exp $ */ /* * Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org> * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> @@ -29,9 +29,6 @@ #include <machine/fdt.h> #include <machine/intr.h> -#include <armv7/armv7/armv7var.h> -#include <armv7/imx/imxgpiovar.h> - #include <dev/ofw/openfirm.h> #include <dev/ofw/ofw_gpio.h> #include <dev/ofw/fdt.h> @@ -72,20 +69,9 @@ struct imxgpio_softc { struct intrhand *sc_handlers[GPIO_NUM_PINS]; struct interrupt_controller sc_ic; - unsigned int (*sc_get_bit)(struct imxgpio_softc *sc, - unsigned int gpio); - void (*sc_set_bit)(struct imxgpio_softc *sc, - unsigned int gpio); - void (*sc_clear_bit)(struct imxgpio_softc *sc, - unsigned int gpio); - void (*sc_set_dir)(struct imxgpio_softc *sc, - unsigned int gpio, unsigned int dir); struct gpio_controller sc_gc; }; -#define GPIO_PIN_TO_INST(x) ((x) >> 5) -#define GPIO_PIN_TO_OFFSET(x) ((x) & 0x1f) - int imxgpio_match(struct device *, void *, void *); void imxgpio_attach(struct device *, struct device *, void *); @@ -99,12 +85,6 @@ void *imxgpio_intr_establish(void *, int *, int, int (*)(void *), void imxgpio_intr_disestablish(void *); void imxgpio_recalc_ipl(struct imxgpio_softc *); -unsigned int imxgpio_v6_get_bit(struct imxgpio_softc *, unsigned int); -void imxgpio_v6_set_bit(struct imxgpio_softc *, unsigned int); -void imxgpio_v6_clear_bit(struct imxgpio_softc *, unsigned int); -void imxgpio_v6_set_dir(struct imxgpio_softc *, unsigned int, unsigned int); -unsigned int imxgpio_v6_get_dir(struct imxgpio_softc *, unsigned int); - struct cfattach imxgpio_ca = { sizeof (struct imxgpio_softc), imxgpio_match, imxgpio_attach @@ -144,11 +124,6 @@ imxgpio_attach(struct device *parent, struct device *self, void *aux) sc->sc_gc.gc_set_pin = imxgpio_set_pin; gpio_controller_register(&sc->sc_gc); - sc->sc_get_bit = imxgpio_v6_get_bit; - sc->sc_set_bit = imxgpio_v6_set_bit; - sc->sc_clear_bit = imxgpio_v6_clear_bit; - sc->sc_set_dir = imxgpio_v6_set_dir; - sc->sc_ipl = IPL_NONE; bus_space_write_4(sc->sc_iot, sc->sc_ioh, GPIO_IMR, 0); bus_space_write_4(sc->sc_iot, sc->sc_ioh, GPIO_ISR, ~0); @@ -220,106 +195,6 @@ imxgpio_set_pin(void *cookie, uint32_t *cells, int val) bus_space_write_4(sc->sc_iot, sc->sc_ioh, GPIO_DR, reg); } -unsigned int -imxgpio_get_bit(unsigned int gpio) -{ - struct imxgpio_softc *sc = imxgpio_cd.cd_devs[GPIO_PIN_TO_INST(gpio)]; - - return sc->sc_get_bit(sc, gpio); - -} - -void -imxgpio_set_bit(unsigned int gpio) -{ - struct imxgpio_softc *sc = imxgpio_cd.cd_devs[GPIO_PIN_TO_INST(gpio)]; - - sc->sc_set_bit(sc, gpio); -} - -void -imxgpio_clear_bit(unsigned int gpio) -{ - struct imxgpio_softc *sc = imxgpio_cd.cd_devs[GPIO_PIN_TO_INST(gpio)]; - - sc->sc_clear_bit(sc, gpio); -} -void -imxgpio_set_dir(unsigned int gpio, unsigned int dir) -{ - struct imxgpio_softc *sc = imxgpio_cd.cd_devs[GPIO_PIN_TO_INST(gpio)]; - - sc->sc_set_dir(sc, gpio, dir); -} - -unsigned int -imxgpio_v6_get_bit(struct imxgpio_softc *sc, unsigned int gpio) -{ - u_int32_t val; - - val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, GPIO_DR); - - return (val >> GPIO_PIN_TO_OFFSET(gpio)) & 0x1; -} - -void -imxgpio_v6_set_bit(struct imxgpio_softc *sc, unsigned int gpio) -{ - u_int32_t val; - - val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, GPIO_DR); - - bus_space_write_4(sc->sc_iot, sc->sc_ioh, GPIO_DR, - val | (1 << GPIO_PIN_TO_OFFSET(gpio))); -} - -void -imxgpio_v6_clear_bit(struct imxgpio_softc *sc, unsigned int gpio) -{ - u_int32_t val; - - val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, GPIO_DR); - - bus_space_write_4(sc->sc_iot, sc->sc_ioh, GPIO_DR, - val & ~(1 << GPIO_PIN_TO_OFFSET(gpio))); -} - -void -imxgpio_v6_set_dir(struct imxgpio_softc *sc, unsigned int gpio, unsigned int dir) -{ - int s; - u_int32_t val; - - s = splhigh(); - - val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, GPIO_GDIR); - if (dir == IMXGPIO_DIR_OUT) - val |= 1 << GPIO_PIN_TO_OFFSET(gpio); - else - val &= ~(1 << GPIO_PIN_TO_OFFSET(gpio)); - bus_space_write_4(sc->sc_iot, sc->sc_ioh, GPIO_GDIR, val); - - splx(s); -} - -unsigned int -imxgpio_v6_get_dir(struct imxgpio_softc *sc, unsigned int gpio) -{ - int s; - u_int32_t val; - - s = splhigh(); - - val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, GPIO_GDIR); - if (val & (1 << GPIO_PIN_TO_OFFSET(gpio))) - val = IMXGPIO_DIR_OUT; - else - val = IMXGPIO_DIR_IN; - - splx(s); - return val; -} - int imxgpio_intr(void *cookie) { diff --git a/sys/arch/armv7/imx/imxgpiovar.h b/sys/arch/armv7/imx/imxgpiovar.h deleted file mode 100644 index b9b59aab56c..00000000000 --- a/sys/arch/armv7/imx/imxgpiovar.h +++ /dev/null @@ -1,32 +0,0 @@ -/* $OpenBSD: imxgpiovar.h,v 1.2 2016/08/06 18:12:13 patrick Exp $ */ -/* - * Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org> - * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef IMXGPIOVAR_H -#define IMXGPIOVAR_H - -#define IMXGPIO_DIR_IN 0 -#define IMXGPIO_DIR_OUT 1 - -unsigned int imxgpio_get_function(unsigned int gpio, unsigned int fn); -void imxgpio_set_function(unsigned int gpio, unsigned int fn); -unsigned int imxgpio_get_bit(unsigned int gpio); -void imxgpio_set_bit(unsigned int gpio); -void imxgpio_clear_bit(unsigned int gpio); -void imxgpio_set_dir(unsigned int gpio, unsigned int dir); - -#endif /* IMXGPIOVAR_H */ |