From: kettenis Date: Sat, 13 Aug 2016 11:08:58 +0000 (+0000) Subject: Use regulalator API instead of private functions. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8f5ac42c673a088e68a5511a59b76da36f214b4e;p=openbsd Use regulalator API instead of private functions. --- 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 * @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -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 * Copyright (c) 2006 Uwe Stuehler @@ -38,6 +38,7 @@ #include #include #include +#include #include /* 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); @@ -458,35 +458,6 @@ err: 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) { @@ -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);