Skip to content

Commit 1c67294

Browse files
committed
soc/tegra: pmc: Pass struct tegra_pmc to tegra_powergate_state()
By using the generic read_poll_timeout() instead of readx_poll_timeout() we can pass additional parameters, which allows us to pass an additional PMC context structure and avoid relying on a global variable for this. Signed-off-by: Thierry Reding <treding@nvidia.com>
1 parent f59dbd0 commit 1c67294

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

drivers/soc/tegra/pmc.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -546,12 +546,7 @@ static void tegra_pmc_scratch_writel(struct tegra_pmc *pmc, u32 value,
546546
writel(value, pmc->scratch + offset);
547547
}
548548

549-
/*
550-
* TODO Figure out a way to call this with the struct tegra_pmc * passed in.
551-
* This currently doesn't work because readx_poll_timeout() can only operate
552-
* on functions that take a single argument.
553-
*/
554-
static inline bool tegra_powergate_state(int id)
549+
static inline bool tegra_powergate_state(struct tegra_pmc *pmc, int id)
555550
{
556551
if (id == TEGRA_POWERGATE_3D && pmc->soc->has_gpu_clamps)
557552
return (tegra_pmc_readl(pmc, GPU_RG_CNTRL) & 0x1) == 0;
@@ -603,8 +598,9 @@ static int tegra20_powergate_set(struct tegra_pmc *pmc, unsigned int id,
603598
tegra_pmc_writel(pmc, PWRGATE_TOGGLE_START | id, PWRGATE_TOGGLE);
604599

605600
/* wait for PMC to execute the command */
606-
ret = readx_poll_timeout(tegra_powergate_state, id, status,
607-
status == new_state, 1, 10);
601+
ret = read_poll_timeout(tegra_powergate_state, status,
602+
status == new_state, 1, 10, false,
603+
pmc, id);
608604
} while (ret == -ETIMEDOUT && retries--);
609605

610606
return ret;
@@ -636,8 +632,9 @@ static int tegra114_powergate_set(struct tegra_pmc *pmc, unsigned int id,
636632
return err;
637633

638634
/* wait for PMC to execute the command */
639-
err = readx_poll_timeout(tegra_powergate_state, id, status,
640-
status == new_state, 10, 100000);
635+
err = read_poll_timeout(tegra_powergate_state, status,
636+
status == new_state, 10, 100000, false,
637+
pmc, id);
641638
if (err)
642639
return err;
643640

@@ -660,7 +657,7 @@ static int tegra_powergate_set(struct tegra_pmc *pmc, unsigned int id,
660657

661658
mutex_lock(&pmc->powergates_lock);
662659

663-
if (tegra_powergate_state(id) == new_state) {
660+
if (tegra_powergate_state(pmc, id) == new_state) {
664661
mutex_unlock(&pmc->powergates_lock);
665662
return 0;
666663
}
@@ -981,7 +978,7 @@ static int tegra_powergate_is_powered(struct tegra_pmc *pmc, unsigned int id)
981978
if (!tegra_powergate_is_valid(pmc, id))
982979
return -EINVAL;
983980

984-
return tegra_powergate_state(id);
981+
return tegra_powergate_state(pmc, id);
985982
}
986983

987984
/**

0 commit comments

Comments
 (0)