summaryrefslogtreecommitdiff
path: root/sys/arch/armv7/imx
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2016-09-23 17:59:18 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2016-09-23 17:59:18 +0000
commit0200cb17a3d4fb5a75ede843a1c2baea61e9dc73 (patch)
tree832e129a5ad8143421be1c37766cfa690860739f /sys/arch/armv7/imx
parent493b812b9efe565243b12a40020c3aff61ad35dc (diff)
Attach imxocotp(4) using the fdt. Since this means that imxtemp(4) attaches
before imxocotp(4), delay reading the temperature sensor calibration information until after imxocotp(4) attaches.
Diffstat (limited to 'sys/arch/armv7/imx')
-rw-r--r--sys/arch/armv7/imx/files.imx4
-rw-r--r--sys/arch/armv7/imx/imx.c3
-rw-r--r--sys/arch/armv7/imx/imxocotp.c39
-rw-r--r--sys/arch/armv7/imx/imxtemp.c11
4 files changed, 40 insertions, 17 deletions
diff --git a/sys/arch/armv7/imx/files.imx b/sys/arch/armv7/imx/files.imx
index 5af443b5c34..726797def5a 100644
--- a/sys/arch/armv7/imx/files.imx
+++ b/sys/arch/armv7/imx/files.imx
@@ -1,4 +1,4 @@
-# $OpenBSD: files.imx,v 1.18 2016/09/18 18:16:00 kettenis Exp $
+# $OpenBSD: files.imx,v 1.19 2016/09/23 17:59:17 kettenis Exp $
define imx {}
device imx: imx
@@ -29,7 +29,7 @@ attach imxdog at fdt
file arch/armv7/imx/imxdog.c imxdog
device imxocotp
-attach imxocotp at imx
+attach imxocotp at fdt
file arch/armv7/imx/imxocotp.c imxocotp
device imxgpio
diff --git a/sys/arch/armv7/imx/imx.c b/sys/arch/armv7/imx/imx.c
index 18f50774b03..1fc256b0aa2 100644
--- a/sys/arch/armv7/imx/imx.c
+++ b/sys/arch/armv7/imx/imx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imx.c,v 1.25 2016/09/18 18:16:00 kettenis Exp $ */
+/* $OpenBSD: imx.c,v 1.26 2016/09/23 17:59:17 kettenis Exp $ */
/*
* Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com>
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
@@ -38,7 +38,6 @@ struct cfdriver imx_cd = {
};
struct board_dev imx_devs[] = {
- { "imxocotp", 0 },
{ NULL, 0 }
};
diff --git a/sys/arch/armv7/imx/imxocotp.c b/sys/arch/armv7/imx/imxocotp.c
index e4cd7973223..b6d146f2cd8 100644
--- a/sys/arch/armv7/imx/imxocotp.c
+++ b/sys/arch/armv7/imx/imxocotp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxocotp.c,v 1.3 2016/08/14 19:08:44 kettenis Exp $ */
+/* $OpenBSD: imxocotp.c,v 1.4 2016/09/23 17:59:17 kettenis Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
@@ -23,12 +23,16 @@
#include <sys/evcount.h>
#include <sys/socket.h>
#include <sys/timeout.h>
+
#include <machine/intr.h>
#include <machine/bus.h>
+#include <machine/fdt.h>
-#include <armv7/armv7/armv7var.h>
#include <armv7/imx/imxocotpvar.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/fdt.h>
+
/* registers */
#define OCOTP_ANA0 0x4d0
#define OCOTP_ANA1 0x4e0
@@ -44,29 +48,40 @@ struct imxocotp_softc {
struct imxocotp_softc *imxocotp_sc;
-void imxocotp_attach(struct device *parent, struct device *self, void *args);
+int imxocotp_match(struct device *, void *, void *);
+void imxocotp_attach(struct device *, struct device *, void *);
struct cfattach imxocotp_ca = {
- sizeof (struct imxocotp_softc), NULL, imxocotp_attach
+ sizeof (struct imxocotp_softc), imxocotp_match, imxocotp_attach
};
struct cfdriver imxocotp_cd = {
NULL, "imxocotp", DV_DULL
};
+int
+imxocotp_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return OF_is_compatible(faa->fa_node, "fsl,imx6q-ocotp");
+}
+
void
-imxocotp_attach(struct device *parent, struct device *self, void *args)
+imxocotp_attach(struct device *parent, struct device *self, void *aux)
{
- struct armv7_attach_args *aa = args;
- struct imxocotp_softc *sc = (struct imxocotp_softc *) self;
+ struct imxocotp_softc *sc = (struct imxocotp_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("imxocotp_attach: bus_space_map failed!");
+ KASSERT(faa->fa_nreg >= 1);
+
+ 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");
imxocotp_sc = sc;
+ printf("\n");
}
void
diff --git a/sys/arch/armv7/imx/imxtemp.c b/sys/arch/armv7/imx/imxtemp.c
index 2f17c037089..67b9279bd24 100644
--- a/sys/arch/armv7/imx/imxtemp.c
+++ b/sys/arch/armv7/imx/imxtemp.c
@@ -97,6 +97,7 @@ struct cfdriver imxtemp_cd = {
NULL, "imxtemp", DV_DULL
};
+void imxtemp_calibration(struct device *);
int32_t imxtemp_calc_temp(struct imxtemp_softc *, uint32_t);
void imxtemp_refresh_sensors(void *);
void imxtemp_pickup_sensors(void *);
@@ -117,7 +118,6 @@ imxtemp_attach(struct device *parent, struct device *self, void *aux)
{
struct imxtemp_softc *sc = (struct imxtemp_softc *)self;
struct fdt_attach_args *faa = aux;
- uint32_t calibration;
if (faa->fa_nreg < 1)
return;
@@ -129,6 +129,15 @@ imxtemp_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
+ config_mountroot(self, imxtemp_calibration);
+}
+
+void
+imxtemp_calibration(struct device *self)
+{
+ struct imxtemp_softc *sc = (struct imxtemp_softc *)self;
+ uint32_t calibration;
+
calibration = imxocotp_get_temperature_calibration();
sc->sc_hot_count = (calibration >> OCOTP_ANA1_HOT_COUNT_SHIFT) &
OCOTP_ANA1_HOT_COUNT_MASK;