soc: imx: gpcv2: Make use of regmap_read_poll_timeout()
Replace explicit polling loop with a call to regmap_read_poll_timeout() to avoid code repetition. Also fix misspelled "failed" while at it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Lucas Stach <l.stach@pengutronix.de> Cc: Chris Healy <cphealy@gmail.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Shawn Guo <shawnguo@kernel.org>
This commit is contained in:
Родитель
9e98c678c2
Коммит
8217a7a2c7
|
@ -136,8 +136,8 @@ static int imx_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd,
|
||||||
GPC_PU_PGC_SW_PUP_REQ : GPC_PU_PGC_SW_PDN_REQ;
|
GPC_PU_PGC_SW_PUP_REQ : GPC_PU_PGC_SW_PDN_REQ;
|
||||||
const bool enable_power_control = !on;
|
const bool enable_power_control = !on;
|
||||||
const bool has_regulator = !IS_ERR(domain->regulator);
|
const bool has_regulator = !IS_ERR(domain->regulator);
|
||||||
unsigned long deadline;
|
|
||||||
int i, ret = 0;
|
int i, ret = 0;
|
||||||
|
u32 pxx_req;
|
||||||
|
|
||||||
regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING,
|
regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING,
|
||||||
domain->bits.map, domain->bits.map);
|
domain->bits.map, domain->bits.map);
|
||||||
|
@ -169,30 +169,19 @@ static int imx_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd,
|
||||||
* As per "5.5.9.4 Example Code 4" in IMX7DRM.pdf wait
|
* As per "5.5.9.4 Example Code 4" in IMX7DRM.pdf wait
|
||||||
* for PUP_REQ/PDN_REQ bit to be cleared
|
* for PUP_REQ/PDN_REQ bit to be cleared
|
||||||
*/
|
*/
|
||||||
deadline = jiffies + msecs_to_jiffies(1);
|
ret = regmap_read_poll_timeout(domain->regmap, offset, pxx_req,
|
||||||
while (true) {
|
!(pxx_req & domain->bits.pxx),
|
||||||
u32 pxx_req;
|
0, USEC_PER_MSEC);
|
||||||
|
if (ret) {
|
||||||
regmap_read(domain->regmap, offset, &pxx_req);
|
dev_err(domain->dev, "failed to command PGC\n");
|
||||||
|
/*
|
||||||
if (!(pxx_req & domain->bits.pxx))
|
* If we were in a process of enabling a
|
||||||
break;
|
* domain and failed we might as well disable
|
||||||
|
* the regulator we just enabled. And if it
|
||||||
if (time_after(jiffies, deadline)) {
|
* was the opposite situation and we failed to
|
||||||
dev_err(domain->dev, "falied to command PGC\n");
|
* power down -- keep the regulator on
|
||||||
ret = -ETIMEDOUT;
|
*/
|
||||||
/*
|
on = !on;
|
||||||
* If we were in a process of enabling a
|
|
||||||
* domain and failed we might as well disable
|
|
||||||
* the regulator we just enabled. And if it
|
|
||||||
* was the opposite situation and we failed to
|
|
||||||
* power down -- keep the regulator on
|
|
||||||
*/
|
|
||||||
on = !on;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
cpu_relax();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enable_power_control)
|
if (enable_power_control)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче