summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2016-06-09 15:38:30 +0000
committerkettenis <kettenis@openbsd.org>2016-06-09 15:38:30 +0000
commitbdb9b44f0f5134835d5fc8effb77a765af01b9bf (patch)
tree8534980c33a7725e49341545a086a7bce7312312
parentAdd SGMII support and PHY addresses for 8-port EdgeRouters. This makes (diff)
downloadwireguard-openbsd-bdb9b44f0f5134835d5fc8effb77a765af01b9bf.tar.xz
wireguard-openbsd-bdb9b44f0f5134835d5fc8effb77a765af01b9bf.zip
Dynamically attach imxesdhc(4) using the FDT.
ok jsg@
-rw-r--r--sys/arch/armv7/conf/GENERIC4
-rw-r--r--sys/arch/armv7/imx/files.imx4
-rw-r--r--sys/arch/armv7/imx/imx.c14
-rw-r--r--sys/arch/armv7/imx/imxesdhc.c53
4 files changed, 37 insertions, 38 deletions
diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC
index bfb20208a7b..32f5568f4bc 100644
--- a/sys/arch/armv7/conf/GENERIC
+++ b/sys/arch/armv7/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.15 2016/06/09 12:39:17 kettenis Exp $
+# $OpenBSD: GENERIC,v 1.16 2016/06/09 15:38:30 kettenis Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -49,7 +49,7 @@ fec* at imx? # Ethernet
imxuart* at imx? # onboard uarts
imxiic* at fdt? # i2c
iic* at imxiic?
-imxesdhc* at imx? # SDHC controller
+imxesdhc* at fdt? # SDHC controller
sdmmc* at imxesdhc? # SD/MMC bus
ahci* at fdt? # AHCI/SATA
ehci* at imx? # EHCI (shim)
diff --git a/sys/arch/armv7/imx/files.imx b/sys/arch/armv7/imx/files.imx
index 5d0abd0097f..f2a85f299a4 100644
--- a/sys/arch/armv7/imx/files.imx
+++ b/sys/arch/armv7/imx/files.imx
@@ -1,4 +1,4 @@
-# $OpenBSD: files.imx,v 1.7 2016/06/09 12:39:17 kettenis Exp $
+# $OpenBSD: files.imx,v 1.8 2016/06/09 15:38:30 kettenis Exp $
define imx {}
device imx: imx
@@ -44,7 +44,7 @@ attach ehci at imx with imxehci
file arch/armv7/imx/imxehci.c imxehci
device imxesdhc: sdmmcbus
-attach imxesdhc at imx
+attach imxesdhc at fdt
file arch/armv7/imx/imxesdhc.c imxesdhc
attach ahci at fdt with imxahci
diff --git a/sys/arch/armv7/imx/imx.c b/sys/arch/armv7/imx/imx.c
index 9ffb9a42822..d7c710c8184 100644
--- a/sys/arch/armv7/imx/imx.c
+++ b/sys/arch/armv7/imx/imx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imx.c,v 1.16 2016/06/09 12:39:17 kettenis Exp $ */
+/* $OpenBSD: imx.c,v 1.17 2016/06/09 15:38:30 kettenis Exp $ */
/*
* Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com>
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
@@ -49,7 +49,6 @@ struct board_dev hummingboard_devs[] = {
{ "imxgpio", 4 },
{ "imxgpio", 5 },
{ "imxgpio", 6 },
- { "imxesdhc", 1 },
{ "ehci", 0 },
{ "ehci", 1 },
{ "fec", 0 },
@@ -69,8 +68,6 @@ struct board_dev sabrelite_devs[] = {
{ "imxgpio", 4 },
{ "imxgpio", 5 },
{ "imxgpio", 6 },
- { "imxesdhc", 2 },
- { "imxesdhc", 3 },
{ "ehci", 0 },
{ "fec", 0 },
{ NULL, 0 }
@@ -90,9 +87,6 @@ struct board_dev sabresd_devs[] = {
{ "imxgpio", 4 },
{ "imxgpio", 5 },
{ "imxgpio", 6 },
- { "imxesdhc", 1 },
- { "imxesdhc", 2 },
- { "imxesdhc", 3 },
{ "ehci", 0 },
{ "fec", 0 },
{ NULL, 0 }
@@ -111,7 +105,6 @@ struct board_dev udoo_devs[] = {
{ "imxgpio", 4 },
{ "imxgpio", 5 },
{ "imxgpio", 6 },
- { "imxesdhc", 2 },
{ "ehci", 0 },
{ "fec", 0 },
{ NULL, 0 }
@@ -130,7 +123,6 @@ struct board_dev utilite_devs[] = {
{ "imxgpio", 4 },
{ "imxgpio", 5 },
{ "imxgpio", 6 },
- { "imxesdhc", 2 },
{ "ehci", 0 },
{ "fec", 0 },
{ NULL, 0 }
@@ -149,8 +141,6 @@ struct board_dev novena_devs[] = {
{ "imxgpio", 4 },
{ "imxgpio", 5 },
{ "imxgpio", 6 },
- { "imxesdhc", 1 },
- { "imxesdhc", 2 },
{ "ehci", 0 },
{ "fec", 0 },
{ NULL, 0 }
@@ -170,8 +160,6 @@ struct board_dev wandboard_devs[] = {
{ "imxgpio", 5 },
{ "imxgpio", 6 },
{ "fec", 0 },
- { "imxesdhc", 2 },
- { "imxesdhc", 0 },
{ "ehci", 0 },
{ NULL, 0 }
};
diff --git a/sys/arch/armv7/imx/imxesdhc.c b/sys/arch/armv7/imx/imxesdhc.c
index 8701974633a..53288c5701b 100644
--- a/sys/arch/armv7/imx/imxesdhc.c
+++ b/sys/arch/armv7/imx/imxesdhc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxesdhc.c,v 1.20 2016/05/19 09:54:18 jsg Exp $ */
+/* $OpenBSD: imxesdhc.c,v 1.21 2016/06/09 15:38:30 kettenis Exp $ */
/*
* Copyright (c) 2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -27,6 +27,7 @@
#include <sys/malloc.h>
#include <sys/systm.h>
#include <machine/bus.h>
+#include <machine/fdt.h>
#include <dev/sdmmc/sdmmcchip.h>
#include <dev/sdmmc/sdmmcvar.h>
@@ -35,6 +36,8 @@
#include <armv7/imx/imxccmvar.h>
#include <armv7/imx/imxgpiovar.h>
+#include <dev/ofw/openfirm.h>
+
/* registers */
#define SDHC_DS_ADDR 0x00
#define SDHC_BLK_ATT 0x04
@@ -164,9 +167,8 @@ struct sdhc_adma2_descriptor32 {
} __packed;
-void imxesdhc_attach(struct device *parent, struct device *self, void *args);
-
-#include <machine/bus.h>
+int imxesdhc_match(struct device *, void *, void *);
+void imxesdhc_attach(struct device *, struct device *, void *);
struct imxesdhc_softc {
struct device sc_dev;
@@ -270,30 +272,39 @@ struct cfdriver imxesdhc_cd = {
};
struct cfattach imxesdhc_ca = {
- sizeof(struct imxesdhc_softc), NULL, imxesdhc_attach
+ sizeof(struct imxesdhc_softc), imxesdhc_match, imxesdhc_attach
};
+int
+imxesdhc_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return OF_is_compatible(faa->fa_node, "fsl,imx6q-usdhc");
+}
+
void
-imxesdhc_attach(struct device *parent, struct device *self, void *args)
+imxesdhc_attach(struct device *parent, struct device *self, void *aux)
{
- struct imxesdhc_softc *sc = (struct imxesdhc_softc *) self;
- struct armv7_attach_args *aa = args;
- struct sdmmcbus_attach_args saa;
- int error = 1;
- uint32_t caps;
-
- sc->unit = aa->aa_dev->unit;
- sc->sc_dmat = aa->aa_dmat;
- 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))
+ struct imxesdhc_softc *sc = (struct imxesdhc_softc *) self;
+ struct fdt_attach_args *faa = aux;
+ struct sdmmcbus_attach_args saa;
+ int error = 1;
+ uint32_t caps;
+
+ if (faa->fa_nreg < 2 || faa->fa_nintr < 3)
+ return;
+
+ sc->unit = (faa->fa_reg[0] & 0xc000) >> 14;
+ sc->sc_dmat = faa->fa_dmat;
+ 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("imxesdhc_attach: bus_space_map failed!");
printf("\n");
- /* XXX DMA channels? */
-
- sc->sc_ih = arm_intr_establish(aa->aa_dev->irq[0], IPL_SDMMC,
+ sc->sc_ih = arm_intr_establish(faa->fa_intr[1], IPL_SDMMC,
imxesdhc_intr, sc, sc->sc_dev.dv_xname);
/*
@@ -312,7 +323,7 @@ imxesdhc_attach(struct device *parent, struct device *self, void *args)
/*
* Determine the base clock frequency. (2.2.24)
*/
- sc->clkbase = imxccm_get_usdhx(aa->aa_dev->unit + 1);
+ sc->clkbase = imxccm_get_usdhx(sc->unit + 1);
printf("%s: %d MHz base clock\n", DEVNAME(sc), sc->clkbase / 1000);