Date: Fri, 19 Jun 2020 18:02:30 +0000 (UTC) From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r362398 - stable/12/sys/arm/ti/am335x Message-ID: <202006191802.05JI2Ug6050114@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: manu Date: Fri Jun 19 18:02:29 2020 New Revision: 362398 URL: https://svnweb.freebsd.org/changeset/base/362398 Log: MFC r359806: arm: am335x: Honor pmic option ti,pmic-shutdown-controller Honor ti,pmic-shutdown-controller option in DTS Tested on stable r359316 @ Sleep mode on custom hw, Power off on BBB and PB OFF bit [1] in status register control the pmic behaviour when PWR_EN pin is pulled low. On most AM335x hardware [beaglebone *] the desired behaviour are in fact power off due to some hardware designs - read more in the comments around pmic in sys/gnu/dts/arm/am335x-bone-common.dtsi This patch let the device-tree decide with ti,pmic-shutdown-controller[2] the state of off bit in status register. [1] 8.6.12 table 12 http://www.ti.com/lit/ds/symlink/tps65217.pdf [2] Documentation/devicetree/bindings/regulator/tps65217.txt PR: 245159 Submitted by: Oskar Holmlund <oskar.holmlund@ohdata.se> Modified: stable/12/sys/arm/ti/am335x/am335x_pmic.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/ti/am335x/am335x_pmic.c ============================================================================== --- stable/12/sys/arm/ti/am335x/am335x_pmic.c Fri Jun 19 18:00:20 2020 (r362397) +++ stable/12/sys/arm/ti/am335x/am335x_pmic.c Fri Jun 19 18:02:29 2020 (r362398) @@ -208,6 +208,7 @@ am335x_pmic_start(struct am335x_pmic_softc *sc) char name[20]; char pwr[4][11] = {"Battery", "USB", "AC", "USB and AC"}; int rv; + phandle_t node; dev = sc->sc_dev; am335x_pmic_read(dev, TPS65217_CHIPID_REG, (uint8_t *)&chipid_reg, 1); @@ -232,6 +233,16 @@ am335x_pmic_start(struct am335x_pmic_softc *sc) device_printf(dev, "%s powered by %s\n", name, pwr[status_reg.usbpwr | (status_reg.acpwr << 1)]); + /* Check devicetree for ti,pmic-shutdown-controller + * if present; PMIC will go to shutdown state on PWR_EN toggle + * if not present; PMIC will enter sleep state on PWR_EN toggle (default on reset) + */ + node = ofw_bus_get_node(dev); + if (OF_hasprop(node, "ti,pmic-shutdown-controller")) { + status_reg.off = 1; + am335x_pmic_write(dev, TPS65217_STATUS_REG, (uint8_t *)&status_reg, 1); + } + if (am335x_pmic_vo[0] != '\0') { for (vo = 0; vo < 4; vo++) { if (strcmp(tps65217_voreg_c[vo], am335x_pmic_vo) == 0) @@ -291,16 +302,9 @@ am335x_pmic_attach(device_t dev) static void am335x_pmic_shutdown(void *xdev, int howto) { - device_t dev; - struct tps65217_status_reg reg; - if (!(howto & RB_POWEROFF)) return; - dev = (device_t)xdev; - am335x_pmic_read(dev, TPS65217_STATUS_REG, (uint8_t *)®, 1); - /* Set the OFF bit on status register to start the shutdown sequence. */ - reg.off = 1; - am335x_pmic_write(dev, TPS65217_STATUS_REG, (uint8_t *)®, 1); + /* Toggle pmic_pwr_enable to shutdown the PMIC. */ am335x_rtc_pmic_pwr_toggle(); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006191802.05JI2Ug6050114>