-# $OpenBSD: GENERIC,v 1.28 2016/07/09 12:32:50 kettenis Exp $
+# $OpenBSD: GENERIC,v 1.29 2016/07/10 14:01:10 kettenis Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
imxiomuxc* at imx? # iomux controller
imxdog* at fdt? # watchdog timer
imxocotp* at imx? # on-chip otp controller
-imxgpio* at imx? # user-visible GPIO pins?
+imxgpio* at fdt? # user-visible GPIO pins?
fec* at fdt? # Ethernet
imxuart* at fdt? # onboard uarts
imxiic* at fdt? # i2c
-/* $OpenBSD: imxgpio.c,v 1.7 2015/05/14 03:13:20 jsg Exp $ */
+/* $OpenBSD: imxgpio.c,v 1.8 2016/07/10 14:01:10 kettenis Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
#include <arm/cpufunc.h>
#include <machine/bus.h>
+#include <machine/fdt.h>
#include <machine/intr.h>
#include <armv7/armv7/armv7var.h>
#include <armv7/imx/imxgpiovar.h>
+#include <dev/ofw/openfirm.h>
+
/* iMX6 registers */
#define GPIO_DR 0x00
#define GPIO_GDIR 0x04
#define GPIO_PIN_TO_INST(x) ((x) >> 5)
#define GPIO_PIN_TO_OFFSET(x) ((x) & 0x1f)
-void imxgpio_attach(struct device *parent, struct device *self, void *args);
-void imxgpio_recalc_interrupts(struct imxgpio_softc *sc);
-int imxgpio_irq(void *);
-int imxgpio_irq_dummy(void *);
+int imxgpio_match(struct device *, void *, void *);
+void imxgpio_attach(struct device *, struct device *, void *);
unsigned int imxgpio_v6_get_bit(struct imxgpio_softc *, unsigned int);
void imxgpio_v6_set_bit(struct imxgpio_softc *, unsigned int);
struct cfattach imxgpio_ca = {
- sizeof (struct imxgpio_softc), NULL, imxgpio_attach
+ sizeof (struct imxgpio_softc), imxgpio_match, imxgpio_attach
};
struct cfdriver imxgpio_cd = {
NULL, "imxgpio", DV_DULL
};
+int
+imxgpio_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return OF_is_compatible(faa->fa_node, "fsl,imx35-gpio");
+}
+
void
-imxgpio_attach(struct device *parent, struct device *self, void *args)
+imxgpio_attach(struct device *parent, struct device *self, void *aux)
{
- struct armv7_attach_args *aa = args;
- struct imxgpio_softc *sc = (struct imxgpio_softc *) self;
+ struct imxgpio_softc *sc = (struct imxgpio_softc *)self;
+ struct fdt_attach_args *faa = aux;
+
+ if (faa->fa_nreg < 2)
+ return;
- sc->sc_iot = aa->aa_iot;
- if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr,
- aa->aa_dev->mem[0].size, 0, &sc->sc_ioh))
+ sc->sc_iot = faa->fa_iot;
+ if (bus_space_map(sc->sc_iot, faa->fa_reg[0],
+ faa->fa_reg[1], 0, &sc->sc_ioh))
panic("imxgpio_attach: bus_space_map failed!");
sc->sc_get_bit = imxgpio_v6_get_bit;