Date: Thu, 16 Jan 2020 19:59:00 +0000 (UTC) From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356799 - head/sys/arm/allwinner Message-ID: <202001161959.00GJx00I083449@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: manu Date: Thu Jan 16 19:59:00 2020 New Revision: 356799 URL: https://svnweb.freebsd.org/changeset/base/356799 Log: axp8xx: Add a regnode_init method This method will set the desired voltaged based on values in the DTS. It will not enable the regulator, this is the job of either a consumer or regnode_set_constraint SYSINIT if the regulator is boot_on or always_on. MFC after: 2 weeks Modified: head/sys/arm/allwinner/axp81x.c Modified: head/sys/arm/allwinner/axp81x.c ============================================================================== --- head/sys/arm/allwinner/axp81x.c Thu Jan 16 19:57:38 2020 (r356798) +++ head/sys/arm/allwinner/axp81x.c Thu Jan 16 19:59:00 2020 (r356799) @@ -710,6 +710,8 @@ struct axp8xx_softc { #define AXP_LOCK(sc) mtx_lock(&(sc)->mtx) #define AXP_UNLOCK(sc) mtx_unlock(&(sc)->mtx) +static int axp8xx_regnode_set_voltage(struct regnode *regnode, int min_uvolt, + int max_uvolt, int *udelay); static int axp8xx_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size) @@ -754,6 +756,31 @@ axp8xx_write(device_t dev, uint8_t reg, uint8_t val) } static int +axp8xx_regnode_init(struct regnode *regnode) +{ + struct axp8xx_reg_sc *sc; + struct regnode_std_param *param; + int rv, udelay; + + sc = regnode_get_softc(regnode); + param = regnode_get_stdparam(regnode); + if (param->min_uvolt == 0) + return (0); + + /* + * Set the regulator at the correct voltage + * Do not enable it, this is will be done either by a + * consumer or by regnode_set_constraint if boot_on is true + */ + rv = axp8xx_regnode_set_voltage(regnode, param->min_uvolt, + param->max_uvolt, &udelay); + if (rv != 0) + DELAY(udelay); + + return (rv); +} + +static int axp8xx_regnode_enable(struct regnode *regnode, bool enable, int *udelay) { struct axp8xx_reg_sc *sc; @@ -870,6 +897,7 @@ axp8xx_regnode_get_voltage(struct regnode *regnode, in static regnode_method_t axp8xx_regnode_methods[] = { /* Regulator interface */ + REGNODEMETHOD(regnode_init, axp8xx_regnode_init), REGNODEMETHOD(regnode_enable, axp8xx_regnode_enable), REGNODEMETHOD(regnode_set_voltage, axp8xx_regnode_set_voltage), REGNODEMETHOD(regnode_get_voltage, axp8xx_regnode_get_voltage),
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001161959.00GJx00I083449>