public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] power: domain: ti: Extend use of PTCMD and PTSTAT registers for high PDs
@ 2022-04-02  1:02 Dave Gerlach
  2022-04-15 12:07 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Gerlach @ 2022-04-02  1:02 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot, Praneeth Bajjuri, Dave Gerlach

It is possible for power domain IDs to be great than 31. If this
happens, the PTCMD and PTSTAT registers must overflow into adjacent
corresponding PTCMD_H and PTSTAT_H registers for each. Update the driver
to account for this.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---
 drivers/power/domain/ti-power-domain.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/power/domain/ti-power-domain.c b/drivers/power/domain/ti-power-domain.c
index b45e9b824539..cf20acd1a322 100644
--- a/drivers/power/domain/ti-power-domain.c
+++ b/drivers/power/domain/ti-power-domain.c
@@ -16,7 +16,9 @@
 #include <linux/iopoll.h>
 
 #define PSC_PTCMD		0x120
+#define PSC_PTCMD_H		0x124
 #define PSC_PTSTAT		0x128
+#define PSC_PTSTAT_H		0x12C
 #define PSC_PDSTAT		0x200
 #define PSC_PDCTL		0x300
 #define PSC_MDSTAT		0x800
@@ -115,10 +117,17 @@ static int ti_power_domain_probe(struct udevice *dev)
 static int ti_pd_wait(struct ti_pd *pd)
 {
 	u32 ptstat;
+	u32 pdoffset = 0;
+	u32 ptstatreg = PSC_PTSTAT;
 	int ret;
 
-	ret = readl_poll_timeout(pd->psc->base + PSC_PTSTAT, ptstat,
-				 !(ptstat & BIT(pd->id)), PD_TIMEOUT);
+	if (pd->id > 31) {
+		pdoffset = 32;
+		ptstatreg = PSC_PTSTAT_H;
+	}
+
+	ret = readl_poll_timeout(pd->psc->base + ptstatreg, ptstat,
+				 !(ptstat & BIT(pd->id - pdoffset)), PD_TIMEOUT);
 
 	if (ret)
 		printf("%s: psc%d, pd%d failed to transition.\n", __func__,
@@ -129,7 +138,15 @@ static int ti_pd_wait(struct ti_pd *pd)
 
 static void ti_pd_transition(struct ti_pd *pd)
 {
-	psc_write(BIT(pd->id), pd->psc, PSC_PTCMD);
+	u32 pdoffset = 0;
+	u32 ptcmdreg = PSC_PTCMD;
+
+	if (pd->id > 31) {
+		pdoffset = 32;
+		ptcmdreg = PSC_PTCMD_H;
+	}
+
+	psc_write(BIT(pd->id - pdoffset), pd->psc, ptcmdreg);
 }
 
 u8 ti_pd_state(struct ti_pd *pd)
-- 
2.35.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] power: domain: ti: Extend use of PTCMD and PTSTAT registers for high PDs
  2022-04-02  1:02 [PATCH] power: domain: ti: Extend use of PTCMD and PTSTAT registers for high PDs Dave Gerlach
@ 2022-04-15 12:07 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2022-04-15 12:07 UTC (permalink / raw)
  To: Dave Gerlach; +Cc: u-boot, Praneeth Bajjuri

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

On Fri, Apr 01, 2022 at 08:02:48PM -0500, Dave Gerlach wrote:

> It is possible for power domain IDs to be great than 31. If this
> happens, the PTCMD and PTSTAT registers must overflow into adjacent
> corresponding PTCMD_H and PTSTAT_H registers for each. Update the driver
> to account for this.
> 
> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-15 12:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-02  1:02 [PATCH] power: domain: ti: Extend use of PTCMD and PTSTAT registers for high PDs Dave Gerlach
2022-04-15 12:07 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox