summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2016-08-06 17:18:39 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2016-08-06 17:18:39 +0000
commitfeb47056e5aeae3928e9f97c2a63c951d1ee2aa9 (patch)
tree3ec12f8c21c8165e3867f01e95a9d78c414ef4fd /sys/arch
parent1687f8ff00d9d5a969865bcdfb7d469e4ab24389 (diff)
Switch imx over to the generic pinctrl API.
ok patrick@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/armv7/imx/if_fec.c6
-rw-r--r--sys/arch/armv7/imx/imxehci.c8
-rw-r--r--sys/arch/armv7/imx/imxesdhc.c7
-rw-r--r--sys/arch/armv7/imx/imxgpc.c3
-rw-r--r--sys/arch/armv7/imx/imxiic.c6
-rw-r--r--sys/arch/armv7/imx/imxiomuxc.c67
-rw-r--r--sys/arch/armv7/imx/imxiomuxcvar.h5
-rw-r--r--sys/arch/armv7/imx/imxuart.c8
8 files changed, 34 insertions, 76 deletions
diff --git a/sys/arch/armv7/imx/if_fec.c b/sys/arch/armv7/imx/if_fec.c
index 5ff8702c7ca..d15b789dade 100644
--- a/sys/arch/armv7/imx/if_fec.c
+++ b/sys/arch/armv7/imx/if_fec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_fec.c,v 1.14 2016/08/06 04:03:20 jsg Exp $ */
+/* $OpenBSD: if_fec.c,v 1.15 2016/08/06 17:18:38 kettenis Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
@@ -47,10 +47,10 @@
#include <armv7/armv7/armv7var.h>
#include <armv7/imx/imxccmvar.h>
#include <armv7/imx/imxgpiovar.h>
-#include <armv7/imx/imxiomuxcvar.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_gpio.h>
+#include <dev/ofw/ofw_pinctrl.h>
#include <dev/ofw/fdt.h>
/* configuration registers */
@@ -298,7 +298,7 @@ fec_attach(struct device *parent, struct device *self, void *aux)
sc->sc_dma_tag = faa->fa_dmat;
- imxiomuxc_pinctrlbyname(faa->fa_node, "default");
+ pinctrl_byname(faa->fa_node, "default");
/* power it up */
imxccm_enable_enet();
diff --git a/sys/arch/armv7/imx/imxehci.c b/sys/arch/armv7/imx/imxehci.c
index 29d1bf3e2db..26e09fee39d 100644
--- a/sys/arch/armv7/imx/imxehci.c
+++ b/sys/arch/armv7/imx/imxehci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxehci.c,v 1.15 2016/08/04 15:52:52 kettenis Exp $ */
+/* $OpenBSD: imxehci.c,v 1.16 2016/08/06 17:18:38 kettenis Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
@@ -33,10 +33,10 @@
#include <armv7/armv7/armv7var.h>
#include <armv7/imx/imxccmvar.h>
-#include <armv7/imx/imxiomuxcvar.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_gpio.h>
+#include <dev/ofw/ofw_pinctrl.h>
#include <dev/ofw/fdt.h>
#include <dev/usb/ehcireg.h>
@@ -172,7 +172,7 @@ imxehci_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
- imxiomuxc_pinctrlbyname(faa->fa_node, "default");
+ pinctrl_byname(faa->fa_node, "default");
imxccm_enable_usboh3();
delay(1000);
@@ -325,7 +325,7 @@ imxehci_enable_vbus(uint32_t phandle)
if (!OF_is_compatible(node, "regulator-fixed"))
return;
- imxiomuxc_pinctrlbyname(node, "default");
+ pinctrl_byname(node, "default");
if (OF_getproplen(node, "enable-active-high") == 0)
active = 1;
diff --git a/sys/arch/armv7/imx/imxesdhc.c b/sys/arch/armv7/imx/imxesdhc.c
index 20ee004055b..5d58dd5b6a5 100644
--- a/sys/arch/armv7/imx/imxesdhc.c
+++ b/sys/arch/armv7/imx/imxesdhc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxesdhc.c,v 1.27 2016/08/04 15:52:52 kettenis Exp $ */
+/* $OpenBSD: imxesdhc.c,v 1.28 2016/08/06 17:18:38 kettenis Exp $ */
/*
* Copyright (c) 2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -34,11 +34,10 @@
#include <armv7/armv7/armv7var.h>
#include <armv7/imx/imxccmvar.h>
-#include <armv7/imx/imxgpiovar.h>
-#include <armv7/imx/imxiomuxcvar.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_gpio.h>
+#include <dev/ofw/ofw_pinctrl.h>
#include <dev/ofw/fdt.h>
/* registers */
@@ -310,7 +309,7 @@ imxesdhc_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
- imxiomuxc_pinctrlbyname(faa->fa_node, "default");
+ pinctrl_byname(faa->fa_node, "default");
sc->sc_ih = arm_intr_establish_fdt(faa->fa_node, IPL_SDMMC,
imxesdhc_intr, sc, sc->sc_dev.dv_xname);
diff --git a/sys/arch/armv7/imx/imxgpc.c b/sys/arch/armv7/imx/imxgpc.c
index 27559b322ab..1205a0629ab 100644
--- a/sys/arch/armv7/imx/imxgpc.c
+++ b/sys/arch/armv7/imx/imxgpc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxgpc.c,v 1.1 2016/08/04 14:31:50 kettenis Exp $ */
+/* $OpenBSD: imxgpc.c,v 1.2 2016/08/06 17:18:38 kettenis Exp $ */
/*
* Copyright (c) 2016 Mark Kettenis
*
@@ -56,6 +56,7 @@ imxgpc_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ic.ic_node = faa->fa_node;
sc->sc_ic.ic_cookie = &sc->sc_ic;
sc->sc_ic.ic_establish = arm_intr_parent_establish_fdt;
+ sc->sc_ic.ic_disestablish = arm_intr_parent_disestablish_fdt;
arm_intr_register_fdt(&sc->sc_ic);
printf("\n");
diff --git a/sys/arch/armv7/imx/imxiic.c b/sys/arch/armv7/imx/imxiic.c
index c08261d6b4c..951fb45c54a 100644
--- a/sys/arch/armv7/imx/imxiic.c
+++ b/sys/arch/armv7/imx/imxiic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxiic.c,v 1.10 2016/08/04 15:52:52 kettenis Exp $ */
+/* $OpenBSD: imxiic.c,v 1.11 2016/08/06 17:18:38 kettenis Exp $ */
/*
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
*
@@ -25,11 +25,11 @@
#include <machine/fdt.h>
#include <armv7/armv7/armv7var.h>
-#include <armv7/imx/imxiomuxcvar.h>
#include <armv7/imx/imxccmvar.h>
#include <armv7/imx/imxiicvar.h>
#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_pinctrl.h>
#include <dev/ofw/fdt.h>
/* registers */
@@ -135,7 +135,7 @@ imxiic_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
/* set iomux pins */
- imxiomuxc_pinctrlbyname(faa->fa_node, "default");
+ pinctrl_byname(faa->fa_node, "default");
/* set speed to 100kHz */
imxiic_setspeed(sc, 100);
diff --git a/sys/arch/armv7/imx/imxiomuxc.c b/sys/arch/armv7/imx/imxiomuxc.c
index ae41029a700..00858535914 100644
--- a/sys/arch/armv7/imx/imxiomuxc.c
+++ b/sys/arch/armv7/imx/imxiomuxc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxiomuxc.c,v 1.5 2016/07/10 20:53:04 patrick Exp $ */
+/* $OpenBSD: imxiomuxc.c,v 1.6 2016/08/06 17:18:38 kettenis Exp $ */
/*
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
* Copyright (c) 2016 Mark Kettenis <kettenis@openbsd.org>
@@ -32,6 +32,7 @@
#include <armv7/imx/imxiomuxcvar.h>
#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_pinctrl.h>
/* registers */
#define IOMUXC_GPR1 0x004
@@ -116,7 +117,7 @@ struct imxiomuxc_softc {
struct imxiomuxc_softc *imxiomuxc_sc;
void imxiomuxc_attach(struct device *parent, struct device *self, void *args);
-int imxiomuxc_pinctrl(uint32_t);
+int imxiomuxc_pinctrl(uint32_t, void *);
struct cfattach imxiomuxc_ca = {
sizeof (struct imxiomuxc_softc), NULL, imxiomuxc_attach
@@ -131,69 +132,26 @@ imxiomuxc_attach(struct device *parent, struct device *self, void *args)
{
struct armv7_attach_args *aa = args;
struct imxiomuxc_softc *sc = (struct imxiomuxc_softc *) self;
+ int node;
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!");
+ node = OF_finddevice("/dev/soc/iomuxc@020e0000");
+ if (node != -1)
+ pinctrl_register(node, imxiomuxc_pinctrl, sc);
+
printf("\n");
imxiomuxc_sc = sc;
}
int
-imxiomuxc_pinctrlbyid(int node, int id)
-{
- char pinctrl[32];
- uint32_t *phandles;
- int len, i;
-
- snprintf(pinctrl, sizeof(pinctrl), "pinctrl-%d", id);
- len = OF_getproplen(node, pinctrl);
- if (len <= 0)
- return -1;
-
- phandles = malloc(len, M_TEMP, M_WAITOK);
- OF_getpropintarray(node, pinctrl, phandles, len);
- for (i = 0; i < len / sizeof(uint32_t); i++)
- imxiomuxc_pinctrl(phandles[i]);
- free(phandles, M_TEMP, len);
- return 0;
-}
-
-int
-imxiomuxc_pinctrlbyname(int node, const char *config)
-{
- char *names;
- char *name;
- char *end;
- int id = 0;
- int len;
-
- len = OF_getproplen(node, "pinctrl-names");
- if (len <= 0)
- return -1;
-
- names = malloc(len, M_TEMP, M_WAITOK);
- OF_getprop(node, "pinctrl-names", names, len);
- end = names + len;
- name = names;
- while (name < end) {
- if (strcmp(name, config) == 0) {
- free(names, M_TEMP, len);
- return imxiomuxc_pinctrlbyid(node, id);
- }
- name += strlen(name) + 1;
- id++;
- }
- free(names, M_TEMP, len);
- return -1;
-}
-
-int
-imxiomuxc_pinctrl(uint32_t phandle)
+imxiomuxc_pinctrl(uint32_t phandle, void *cookie)
{
- struct imxiomuxc_softc *sc = imxiomuxc_sc;
+ struct imxiomuxc_softc *sc = cookie;
+ char name[31];
uint32_t *pins;
int npins;
int node;
@@ -204,6 +162,9 @@ imxiomuxc_pinctrl(uint32_t phandle)
if (node == 0)
return -1;
+ OF_getprop(node, "name", name, sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
len = OF_getproplen(node, "fsl,pins");
if (len <= 0)
return -1;
diff --git a/sys/arch/armv7/imx/imxiomuxcvar.h b/sys/arch/armv7/imx/imxiomuxcvar.h
index ba12f0ad43a..321dd8eff90 100644
--- a/sys/arch/armv7/imx/imxiomuxcvar.h
+++ b/sys/arch/armv7/imx/imxiomuxcvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxiomuxcvar.h,v 1.2 2016/07/10 11:46:28 kettenis Exp $ */
+/* $OpenBSD: imxiomuxcvar.h,v 1.3 2016/08/06 17:18:38 kettenis Exp $ */
/*
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
*
@@ -18,9 +18,6 @@
#ifndef IMXIOMUXCVAR_H
#define IMXIOMUXCVAR_H
-int imxiomuxc_pinctrlbyid(int node, int id);
-int imxiomuxc_pinctrlbyname(int node, const char *);
-
void imxiomuxc_enable_sata(void);
void imxiomuxc_enable_pcie(void);
void imxiomuxc_pcie_refclk(int);
diff --git a/sys/arch/armv7/imx/imxuart.c b/sys/arch/armv7/imx/imxuart.c
index abc57318ed6..ba4a857270a 100644
--- a/sys/arch/armv7/imx/imxuart.c
+++ b/sys/arch/armv7/imx/imxuart.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxuart.c,v 1.11 2016/08/04 15:52:52 kettenis Exp $ */
+/* $OpenBSD: imxuart.c,v 1.12 2016/08/06 17:18:38 kettenis Exp $ */
/*
* Copyright (c) 2005 Dale Rahn <drahn@motorola.com>
*
@@ -31,7 +31,6 @@
#include <dev/cons.h>
-
#ifdef DDB
#include <ddb/db_var.h>
#endif
@@ -46,8 +45,9 @@
#include <armv7/imx/imxccmvar.h>
#include <armv7/imx/imxiomuxcvar.h>
-#include <dev/ofw/fdt.h>
#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_pinctrl.h>
+#include <dev/ofw/fdt.h>
#define DEVUNIT(x) (minor(x) & 0x7f)
#define DEVCUA(x) (minor(x) & 0x80)
@@ -167,7 +167,7 @@ imxuart_attach(struct device *parent, struct device *self, void *aux)
if (faa->fa_nreg < 1)
return;
- imxiomuxc_pinctrlbyname(faa->fa_node, "default");
+ pinctrl_byname(faa->fa_node, "default");
sc->sc_irq = arm_intr_establish_fdt(faa->fa_node, IPL_TTY,
imxuart_intr, sc, sc->sc_dev.dv_xname);