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>
MFC after:	2 weeks
This commit is contained in:
Emmanuel Vadot 2020-04-11 15:52:07 +00:00
parent 19602a3869
commit d0c51fc4ac
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=359806

View File

@ -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 *)&reg, 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 *)&reg, 1);
/* Toggle pmic_pwr_enable to shutdown the PMIC. */
am335x_rtc_pmic_pwr_toggle();
}