summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2016-09-18 18:16:01 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2016-09-18 18:16:01 +0000
commitf453c1f21ac58c8b4a898a97b4c5f3e2c56593e1 (patch)
treed4894cc09802ac62a8fe516442c332abd24f625f /sys
parentc98bd521864a46a6aadbe119dd29660193496f28 (diff)
Convert imxccm(4) and imxiomuxc(4) to attach using the fdt. Use the "early"
locator to attach them before other drivers that might need their services. ok patrick@, jsg@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/armv7/conf/GENERIC8
-rw-r--r--sys/arch/armv7/conf/RAMDISK8
-rw-r--r--sys/arch/armv7/imx/files.imx6
-rw-r--r--sys/arch/armv7/imx/imx.c4
-rw-r--r--sys/arch/armv7/imx/imxccm.c51
-rw-r--r--sys/arch/armv7/imx/imxiomuxc.c47
6 files changed, 77 insertions, 47 deletions
diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC
index c11ef0ebf5f..04df3bdcb4e 100644
--- a/sys/arch/armv7/conf/GENERIC
+++ b/sys/arch/armv7/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.54 2016/09/15 21:55:51 jsg Exp $
+# $OpenBSD: GENERIC,v 1.55 2016/09/18 18:16:00 kettenis Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -40,11 +40,11 @@ armliicc* at cortex?
# iMX
imx0 at mainbus? # iMX SoC
-imxccm* at imx? # clock control module
-imxiomuxc* at imx? # iomux controller
+imxocotp* at imx? # on-chip otp controller
+imxccm* at fdt? early 1 # clock control module
+imxiomuxc* at fdt? early 1 # iomux controller
imxgpc* at fdt? # power controller
imxdog* at fdt? # watchdog timer
-imxocotp* at imx? # on-chip otp controller
imxtemp* at fdt? # temperature monitor
imxgpio* at fdt? # user-visible GPIO pins?
fec* at fdt? # Ethernet
diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK
index b0a8e4a82d0..f2912e49883 100644
--- a/sys/arch/armv7/conf/RAMDISK
+++ b/sys/arch/armv7/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.49 2016/09/15 21:55:51 jsg Exp $
+# $OpenBSD: RAMDISK,v 1.50 2016/09/18 18:16:00 kettenis Exp $
machine armv7 arm
@@ -39,11 +39,11 @@ armliicc* at cortex?
# iMX
imx0 at mainbus? # iMX SoC
-imxccm* at imx? # clock control module
-imxiomuxc* at imx? # iomux controller
+imxocotp* at imx? # on-chip otp controller
+imxccm* at fdt? early 1 # clock control module
+imxiomuxc* at fdt? early 1 # iomux controller
imxgpc* at fdt? # power controller
imxdog* at fdt? # watchdog timer
-imxocotp* at imx? # on-chip otp controller
imxgpio* at fdt? # user-visible GPIO pins?
fec* at fdt? # Ethernet
imxuart* at fdt? # onboard uarts
diff --git a/sys/arch/armv7/imx/files.imx b/sys/arch/armv7/imx/files.imx
index 981efac9a0c..5af443b5c34 100644
--- a/sys/arch/armv7/imx/files.imx
+++ b/sys/arch/armv7/imx/files.imx
@@ -1,4 +1,4 @@
-# $OpenBSD: files.imx,v 1.17 2016/08/14 19:08:44 kettenis Exp $
+# $OpenBSD: files.imx,v 1.18 2016/09/18 18:16:00 kettenis Exp $
define imx {}
device imx: imx
@@ -13,11 +13,11 @@ attach imxuart at fdt
file arch/armv7/imx/imxuart.c imxuart
device imxccm
-attach imxccm at imx
+attach imxccm at fdt
file arch/armv7/imx/imxccm.c imxccm
device imxiomuxc
-attach imxiomuxc at imx
+attach imxiomuxc at fdt
file arch/armv7/imx/imxiomuxc.c imxiomuxc
device imxgpc
diff --git a/sys/arch/armv7/imx/imx.c b/sys/arch/armv7/imx/imx.c
index f6e4474800f..18f50774b03 100644
--- a/sys/arch/armv7/imx/imx.c
+++ b/sys/arch/armv7/imx/imx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imx.c,v 1.24 2016/07/22 13:40:39 jsg Exp $ */
+/* $OpenBSD: imx.c,v 1.25 2016/09/18 18:16:00 kettenis Exp $ */
/*
* Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com>
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
@@ -38,8 +38,6 @@ struct cfdriver imx_cd = {
};
struct board_dev imx_devs[] = {
- { "imxccm", 0 },
- { "imxiomuxc", 0 },
{ "imxocotp", 0 },
{ NULL, 0 }
};
diff --git a/sys/arch/armv7/imx/imxccm.c b/sys/arch/armv7/imx/imxccm.c
index 2035457c9f0..b65b182f55e 100644
--- a/sys/arch/armv7/imx/imxccm.c
+++ b/sys/arch/armv7/imx/imxccm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxccm.c,v 1.5 2015/05/30 08:09:19 jsg Exp $ */
+/* $OpenBSD: imxccm.c,v 1.6 2016/09/18 18:16:00 kettenis Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
@@ -24,9 +24,13 @@
#include <sys/evcount.h>
#include <sys/socket.h>
#include <sys/timeout.h>
+
#include <machine/intr.h>
#include <machine/bus.h>
-#include <armv7/armv7/armv7var.h>
+#include <machine/fdt.h>
+
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/fdt.h>
/* registers */
#define CCM_CCR 0x00
@@ -198,7 +202,17 @@ enum clocks {
struct imxccm_softc *imxccm_sc;
-void imxccm_attach(struct device *parent, struct device *self, void *args);
+int imxccm_match(struct device *, void *, void *);
+void imxccm_attach(struct device *parent, struct device *self, void *args);
+
+struct cfattach imxccm_ca = {
+ sizeof (struct imxccm_softc), imxccm_match, imxccm_attach
+};
+
+struct cfdriver imxccm_cd = {
+ NULL, "imxccm", DV_DULL
+};
+
int imxccm_cpuspeed(int *);
unsigned int imxccm_decode_pll(enum clocks, unsigned int);
unsigned int imxccm_get_pll2_pfd(unsigned int);
@@ -224,25 +238,30 @@ void imxccm_enable_enet(void);
void imxccm_enable_sata(void);
void imxccm_enable_pcie(void);
-struct cfattach imxccm_ca = {
- sizeof (struct imxccm_softc), NULL, imxccm_attach
-};
+int
+imxccm_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
-struct cfdriver imxccm_cd = {
- NULL, "imxccm", DV_DULL
-};
+ return (OF_is_compatible(faa->fa_node, "fsl,imx6q-ccm") ||
+ OF_is_compatible(faa->fa_node, "fsl,imx6sl-cmm") ||
+ OF_is_compatible(faa->fa_node, "fsl,imx6sx-cmm") ||
+ OF_is_compatible(faa->fa_node, "fsl,imx6ul-cmm"));
+}
void
-imxccm_attach(struct device *parent, struct device *self, void *args)
+imxccm_attach(struct device *parent, struct device *self, void *aux)
{
- struct armv7_attach_args *aa = args;
- struct imxccm_softc *sc = (struct imxccm_softc *) self;
+ struct imxccm_softc *sc = (struct imxccm_softc *)self;
+ struct fdt_attach_args *faa = aux;
+
+ KASSERT(faa->fa_nreg >= 1);
imxccm_sc = sc;
- 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))
- panic("imxccm_attach: bus_space_map failed!");
+ sc->sc_iot = faa->fa_iot;
+ if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
+ faa->fa_reg[0].size + 0x1000, 0, &sc->sc_ioh))
+ panic("%s: bus_space_map failed!", __func__);
printf(": imx6 rev 1.%d CPU freq: %d MHz",
HREAD4(sc, CCM_ANALOG_DIGPROG) & CCM_ANALOG_DIGPROG_MINOR_MASK,
diff --git a/sys/arch/armv7/imx/imxiomuxc.c b/sys/arch/armv7/imx/imxiomuxc.c
index 04e08edef78..03adb6e3a47 100644
--- a/sys/arch/armv7/imx/imxiomuxc.c
+++ b/sys/arch/armv7/imx/imxiomuxc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxiomuxc.c,v 1.7 2016/09/10 18:33:01 jsg Exp $ */
+/* $OpenBSD: imxiomuxc.c,v 1.8 2016/09/18 18:16:00 kettenis Exp $ */
/*
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
* Copyright (c) 2016 Mark Kettenis <kettenis@openbsd.org>
@@ -27,12 +27,13 @@
#include <machine/intr.h>
#include <machine/bus.h>
+#include <machine/fdt.h>
-#include <armv7/armv7/armv7var.h>
#include <armv7/imx/imxiomuxcvar.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_pinctrl.h>
+#include <dev/ofw/fdt.h>
/* registers */
#define IOMUXC_GPR1 0x004
@@ -116,35 +117,47 @@ struct imxiomuxc_softc {
struct imxiomuxc_softc *imxiomuxc_sc;
-void imxiomuxc_attach(struct device *parent, struct device *self, void *args);
-int imxiomuxc_pinctrl(uint32_t, void *);
+int imxiomuxc_match(struct device *, void *, void *);
+void imxiomuxc_attach(struct device *, struct device *, void *);
struct cfattach imxiomuxc_ca = {
- sizeof (struct imxiomuxc_softc), NULL, imxiomuxc_attach
+ sizeof (struct imxiomuxc_softc), imxiomuxc_match, imxiomuxc_attach
};
struct cfdriver imxiomuxc_cd = {
NULL, "imxiomuxc", DV_DULL
};
+int imxiomuxc_pinctrl(uint32_t, void *);
+
+int
+imxiomuxc_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return (OF_is_compatible(faa->fa_node, "fsl,imx6q-iomuxc") ||
+ OF_is_compatible(faa->fa_node, "fsl,imx6dl-iomuxc") ||
+ OF_is_compatible(faa->fa_node, "fsl,imx6sl-iomuxc") ||
+ OF_is_compatible(faa->fa_node, "fsl,imx6sx-iomuxc") ||
+ OF_is_compatible(faa->fa_node, "fsl,imx6ul-iomuxc"));
+}
+
void
-imxiomuxc_attach(struct device *parent, struct device *self, void *args)
+imxiomuxc_attach(struct device *parent, struct device *self, void *aux)
{
- struct armv7_attach_args *aa = args;
- struct imxiomuxc_softc *sc = (struct imxiomuxc_softc *) self;
- int node;
+ struct imxiomuxc_softc *sc = (struct imxiomuxc_softc *)self;
+ struct fdt_attach_args *faa = aux;
- 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))
- panic("imxiomuxc_attach: bus_space_map failed!");
+ KASSERT(faa->fa_nreg >= 1);
- node = OF_finddevice("/soc/aips-bus@02000000/iomuxc@020e0000");
- if (node != -1)
- pinctrl_register(node, imxiomuxc_pinctrl, sc);
+ sc->sc_iot = faa->fa_iot;
+ if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
+ faa->fa_reg[0].size, 0, &sc->sc_ioh))
+ panic("%s: bus_space_map failed!", __func__);
- printf("\n");
+ pinctrl_register(faa->fa_node, imxiomuxc_pinctrl, sc);
imxiomuxc_sc = sc;
+ printf("\n");
}
int