-/* $OpenBSD: imxehci.c,v 1.16 2016/08/06 17:18:38 kettenis Exp $ */
+/* $OpenBSD: imxehci.c,v 1.17 2016/08/13 11:08:58 kettenis Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_gpio.h>
#include <dev/ofw/ofw_pinctrl.h>
+#include <dev/ofw/ofw_regulator.h>
#include <dev/ofw/fdt.h>
#include <dev/usb/ehcireg.h>
void imxehci_attach(struct device *, struct device *, void *);
int imxehci_detach(struct device *, int);
-void imxehci_enable_vbus(uint32_t);
-
struct imxehci_softc {
struct ehci_softc sc;
void *sc_ih;
/* enable usb bus power */
vbus = OF_getpropint(faa->fa_node, "vbus-supply", 0);
if (vbus)
- imxehci_enable_vbus(vbus);
+ regulator_enable(vbus);
switch (misc[1]) {
case 0:
return (0);
}
-
-void
-imxehci_enable_vbus(uint32_t phandle)
-{
- uint32_t gpio[3];
- int active;
- int node;
-
- node = OF_getnodebyphandle(phandle);
- if (node == 0)
- return;
-
- if (!OF_is_compatible(node, "regulator-fixed"))
- return;
-
- pinctrl_byname(node, "default");
-
- if (OF_getproplen(node, "enable-active-high") == 0)
- active = 1;
- else
- active = 0;
-
- if (OF_getpropintarray(node, "gpio", gpio,
- sizeof(gpio)) != sizeof(gpio))
- return;
-
- gpio_controller_config_pin(gpio, GPIO_CONFIG_OUTPUT);
- gpio_controller_set_pin(gpio, active);
-}
-/* $OpenBSD: imxesdhc.c,v 1.29 2016/08/08 10:10:56 kettenis Exp $ */
+/* $OpenBSD: imxesdhc.c,v 1.30 2016/08/13 11:08:58 kettenis Exp $ */
/*
* Copyright (c) 2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_gpio.h>
#include <dev/ofw/ofw_pinctrl.h>
+#include <dev/ofw/ofw_regulator.h>
#include <dev/ofw/fdt.h>
/* registers */
void imxesdhc_shutdown(void *);
int imxesdhc_intr(void *);
-void imxesdhc_enable_vbus(uint32_t);
void imxesdhc_clock_enable(uint32_t);
void imxesdhc_pwrseq_pre(uint32_t);
void imxesdhc_pwrseq_post(uint32_t);
return;
}
-void
-imxesdhc_enable_vbus(uint32_t phandle)
-{
- uint32_t gpio[3];
- int active;
- int node;
-
- node = OF_getnodebyphandle(phandle);
- if (node == 0)
- return;
-
- if (!OF_is_compatible(node, "regulator-fixed"))
- return;
-
- pinctrl_byname(node, "default");
-
- if (OF_getproplen(node, "enable-active-high") == 0)
- active = 1;
- else
- active = 0;
-
- if (OF_getpropintarray(node, "gpio", gpio,
- sizeof(gpio)) != sizeof(gpio))
- return;
-
- gpio_controller_config_pin(gpio, GPIO_CONFIG_OUTPUT);
- gpio_controller_set_pin(gpio, active);
-}
-
void
imxesdhc_clock_enable(uint32_t phandle)
{
/* enable mmc power */
if (sc->sc_vmmc && vdd > 0)
- imxesdhc_enable_vbus(sc->sc_vmmc);
+ regulator_enable(sc->sc_vmmc);
if (sc->sc_vdd == 0 && vdd > 0)
imxesdhc_pwrseq_post(sc->sc_pwrseq);