From owner-svn-src-all@freebsd.org Fri Jun 19 18:02:30 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7B73C334D73; Fri, 19 Jun 2020 18:02:30 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49pRTy2dw8z4bJy; Fri, 19 Jun 2020 18:02:30 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3BE301F1F8; Fri, 19 Jun 2020 18:02:30 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05JI2UYY050115; Fri, 19 Jun 2020 18:02:30 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05JI2Ug6050114; Fri, 19 Jun 2020 18:02:30 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202006191802.05JI2Ug6050114@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 19 Jun 2020 18:02:30 +0000 (UTC) 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 X-SVN-Group: stable-12 X-SVN-Commit-Author: manu X-SVN-Commit-Paths: stable/12/sys/arm/ti/am335x X-SVN-Commit-Revision: 362398 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jun 2020 18:02:30 -0000 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 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(); }