-/* $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>
*
#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 */
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();
-/* $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>
*
#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>
printf("\n");
- imxiomuxc_pinctrlbyname(faa->fa_node, "default");
+ pinctrl_byname(faa->fa_node, "default");
imxccm_enable_usboh3();
delay(1000);
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;
-/* $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>
#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 */
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);
-/* $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
*
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");
-/* $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>
*
#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 */
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);
-/* $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>
#include <armv7/imx/imxiomuxcvar.h>
#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_pinctrl.h>
/* registers */
#define IOMUXC_GPR1 0x004
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
{
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;
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;
-/* $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>
*
#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);
-/* $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>
*
#include <dev/cons.h>
-
#ifdef DDB
#include <ddb/db_var.h>
#endif
#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)
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);