diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-08-13 11:08:59 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-08-13 11:08:59 +0000 |
commit | 0bf647f06b80aa92957371ed246b712684a2b2e3 (patch) | |
tree | 487bdb2d9bf05602014978962d93ae8b01dea88b /sys/arch | |
parent | 996f5f1a5ffa0bdedab3502101a06bdc574b4a0d (diff) |
Use regulalator API instead of private functions.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/armv7/imx/imxehci.c | 36 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxesdhc.c | 35 |
2 files changed, 6 insertions, 65 deletions
diff --git a/sys/arch/armv7/imx/imxehci.c b/sys/arch/armv7/imx/imxehci.c index 26e09fee39d..89fe44d0edd 100644 --- a/sys/arch/armv7/imx/imxehci.c +++ b/sys/arch/armv7/imx/imxehci.c @@ -1,4 +1,4 @@ -/* $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> * @@ -37,6 +37,7 @@ #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> @@ -75,8 +76,6 @@ int imxehci_match(struct device *, void *, void *); 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; @@ -180,7 +179,7 @@ imxehci_attach(struct device *parent, struct device *self, void *aux) /* 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: @@ -310,32 +309,3 @@ imxehci_detach(struct device *self, int flags) 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); -} diff --git a/sys/arch/armv7/imx/imxesdhc.c b/sys/arch/armv7/imx/imxesdhc.c index a50ab69547c..b6ff3455aaa 100644 --- a/sys/arch/armv7/imx/imxesdhc.c +++ b/sys/arch/armv7/imx/imxesdhc.c @@ -1,4 +1,4 @@ -/* $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> @@ -38,6 +38,7 @@ #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 */ @@ -207,7 +208,6 @@ int imxesdhc_host_found(struct imxesdhc_softc *, bus_space_tag_t, 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); @@ -459,35 +459,6 @@ err: } 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) { uint32_t gpios[3]; @@ -698,7 +669,7 @@ imxesdhc_bus_power(sdmmc_chipset_handle_t sch, uint32_t ocr) /* 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); |