From 8d5e4428abcdf2ccaf3e4b3747f4393aa44f492d Mon Sep 17 00:00:00 2001 From: Dave Gerlach Date: Wed, 27 Oct 2021 12:24:37 -0500 Subject: [PATCH] power: domain: ti: Extend use of PTCMD and PTSTAT registers for high PDs 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 --- drivers/power/domain/ti-power-domain.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/power/domain/ti-power-domain.c b/drivers/power/domain/ti-power-domain.c index dfbd75878d..e86370e833 100644 --- a/drivers/power/domain/ti-power-domain.c +++ b/drivers/power/domain/ti-power-domain.c @@ -2,7 +2,7 @@ /* * Texas Instruments power domain driver * - * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2020-2021 Texas Instruments Incorporated - http://www.ti.com/ * Tero Kristo */ @@ -15,7 +15,9 @@ #include #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 @@ -114,11 +116,18 @@ 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 i = PD_TIMEOUT; + if (pd->id > 31) { + pdoffset = 32; + ptstatreg = PSC_PTSTAT_H; + } + while (i) { - ptstat = psc_read(pd->psc, PSC_PTSTAT); - if (!(ptstat & BIT(pd->id))) + ptstat = psc_read(pd->psc, ptstatreg); + if (!(ptstat & BIT(pd->id - pdoffset))) return 0; i--; } @@ -131,7 +140,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)