summaryrefslogtreecommitdiff
path: root/sys/arch/armv7/imx
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2016-06-09 12:39:18 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2016-06-09 12:39:18 +0000
commit3a20ef833fcbb18f25755cb426341afe018a86b4 (patch)
tree60ab4c76ddc777a05ecea0f299d24458f1f91491 /sys/arch/armv7/imx
parentde127c414f5d22ccf38e4e8453e29924a30d67ad (diff)
Dynamically attach i.MX6 ahci(4) using the FDT.
ok jsg@
Diffstat (limited to 'sys/arch/armv7/imx')
-rw-r--r--sys/arch/armv7/imx/files.imx4
-rw-r--r--sys/arch/armv7/imx/imx.c9
-rw-r--r--sys/arch/armv7/imx/imxahci.c37
3 files changed, 30 insertions, 20 deletions
diff --git a/sys/arch/armv7/imx/files.imx b/sys/arch/armv7/imx/files.imx
index 90afe18f93d..5d0abd0097f 100644
--- a/sys/arch/armv7/imx/files.imx
+++ b/sys/arch/armv7/imx/files.imx
@@ -1,4 +1,4 @@
-# $OpenBSD: files.imx,v 1.6 2016/06/03 01:36:46 jsg Exp $
+# $OpenBSD: files.imx,v 1.7 2016/06/09 12:39:17 kettenis Exp $
define imx {}
device imx: imx
@@ -47,5 +47,5 @@ device imxesdhc: sdmmcbus
attach imxesdhc at imx
file arch/armv7/imx/imxesdhc.c imxesdhc
-attach ahci at imx with imxahci
+attach ahci at fdt with imxahci
file arch/armv7/imx/imxahci.c imxahci
diff --git a/sys/arch/armv7/imx/imx.c b/sys/arch/armv7/imx/imx.c
index 10f1606cc76..9ffb9a42822 100644
--- a/sys/arch/armv7/imx/imx.c
+++ b/sys/arch/armv7/imx/imx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imx.c,v 1.15 2016/06/04 18:09:16 jsg Exp $ */
+/* $OpenBSD: imx.c,v 1.16 2016/06/09 12:39:17 kettenis Exp $ */
/*
* Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com>
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
@@ -53,7 +53,6 @@ struct board_dev hummingboard_devs[] = {
{ "ehci", 0 },
{ "ehci", 1 },
{ "fec", 0 },
- { "ahci", 0 },
{ NULL, 0 }
};
@@ -74,7 +73,6 @@ struct board_dev sabrelite_devs[] = {
{ "imxesdhc", 3 },
{ "ehci", 0 },
{ "fec", 0 },
- { "ahci", 0 },
{ NULL, 0 }
};
@@ -97,7 +95,6 @@ struct board_dev sabresd_devs[] = {
{ "imxesdhc", 3 },
{ "ehci", 0 },
{ "fec", 0 },
- { "ahci", 0 },
{ NULL, 0 }
};
@@ -117,7 +114,6 @@ struct board_dev udoo_devs[] = {
{ "imxesdhc", 2 },
{ "ehci", 0 },
{ "fec", 0 },
- { "ahci", 0 },
{ NULL, 0 }
};
@@ -137,7 +133,6 @@ struct board_dev utilite_devs[] = {
{ "imxesdhc", 2 },
{ "ehci", 0 },
{ "fec", 0 },
- { "ahci", 0 },
{ NULL, 0 }
};
@@ -158,7 +153,6 @@ struct board_dev novena_devs[] = {
{ "imxesdhc", 2 },
{ "ehci", 0 },
{ "fec", 0 },
- { "ahci", 0 },
{ NULL, 0 }
};
@@ -179,7 +173,6 @@ struct board_dev wandboard_devs[] = {
{ "imxesdhc", 2 },
{ "imxesdhc", 0 },
{ "ehci", 0 },
- { "ahci", 0 }, /* only on quad, afaik. */
{ NULL, 0 }
};
diff --git a/sys/arch/armv7/imx/imxahci.c b/sys/arch/armv7/imx/imxahci.c
index 33a9467b3c0..06badf1aef6 100644
--- a/sys/arch/armv7/imx/imxahci.c
+++ b/sys/arch/armv7/imx/imxahci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxahci.c,v 1.3 2014/04/14 04:42:22 dlg Exp $ */
+/* $OpenBSD: imxahci.c,v 1.4 2016/06/09 12:39:17 kettenis Exp $ */
/*
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
*
@@ -24,6 +24,7 @@
#include <sys/queue.h>
#include <machine/bus.h>
+#include <machine/fdt.h>
#include <dev/ic/ahcireg.h>
#include <dev/ic/ahcivar.h>
@@ -32,6 +33,8 @@
#include <armv7/imx/imxccmvar.h>
#include <armv7/imx/imxiomuxcvar.h>
+#include <dev/ofw/openfirm.h>
+
/* registers */
#define SATA_CAP 0x000
#define SATA_GHC 0x004
@@ -72,6 +75,7 @@
#define SATA_GHC_HR (1 << 0)
#define SATA_P0PHYCR_TEST_PDDQ (1 << 20)
+int imxahci_match(struct device *, void *, void *);
void imxahci_attach(struct device *, struct device *, void *);
int imxahci_detach(struct device *, int);
int imxahci_activate(struct device *, int);
@@ -84,7 +88,7 @@ struct imxahci_softc {
struct cfattach imxahci_ca = {
sizeof(struct imxahci_softc),
- NULL,
+ imxahci_match,
imxahci_attach,
imxahci_detach,
imxahci_activate
@@ -94,23 +98,34 @@ struct cfdriver imxahci_cd = {
NULL, "ahci", DV_DULL
};
+int
+imxahci_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return OF_is_compatible(faa->fa_node, "fsl,imx6q-ahci");
+}
+
void
-imxahci_attach(struct device *parent, struct device *self, void *args)
+imxahci_attach(struct device *parent, struct device *self, void *aux)
{
- struct armv7_attach_args *aa = args;
struct imxahci_softc *imxsc = (struct imxahci_softc *) self;
struct ahci_softc *sc = &imxsc->sc;
+ struct fdt_attach_args *faa = aux;
uint32_t timeout = 0x100000;
- sc->sc_iot = aa->aa_iot;
- sc->sc_ios = aa->aa_dev->mem[0].size;
- sc->sc_dmat = aa->aa_dmat;
+ if (faa->fa_nreg < 2 || faa->fa_nintr < 3)
+ return;
- 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;
+ sc->sc_ios = faa->fa_reg[1];
+ sc->sc_dmat = faa->fa_dmat;
+
+ if (bus_space_map(sc->sc_iot, faa->fa_reg[0],
+ faa->fa_reg[1], 0, &sc->sc_ioh))
panic("imxahci_attach: bus_space_map failed!");
- sc->sc_ih = arm_intr_establish(aa->aa_dev->irq[0], IPL_BIO,
+ sc->sc_ih = arm_intr_establish(faa->fa_intr[1], IPL_BIO,
ahci_intr, sc, sc->sc_dev.dv_xname);
if (sc->sc_ih == NULL) {
printf(": unable to establish interrupt\n");
@@ -141,6 +156,8 @@ imxahci_attach(struct device *parent, struct device *self, void *args)
while (!(bus_space_read_4(sc->sc_iot, sc->sc_ioh, SATA_P0SSTS) & 0xF) && timeout--);
+ printf(":");
+
if (ahci_attach(sc) != 0) {
/* error printed by ahci_attach */
goto irq;