diff options
| -rw-r--r-- | drivers/soc/imx/gpcv2.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c index 176f473127b6..e06bf12a1e4b 100644 --- a/drivers/soc/imx/gpcv2.c +++ b/drivers/soc/imx/gpcv2.c | |||
| @@ -136,8 +136,8 @@ static int imx_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd, | |||
| 136 | GPC_PU_PGC_SW_PUP_REQ : GPC_PU_PGC_SW_PDN_REQ; | 136 | GPC_PU_PGC_SW_PUP_REQ : GPC_PU_PGC_SW_PDN_REQ; |
| 137 | const bool enable_power_control = !on; | 137 | const bool enable_power_control = !on; |
| 138 | const bool has_regulator = !IS_ERR(domain->regulator); | 138 | const bool has_regulator = !IS_ERR(domain->regulator); |
| 139 | unsigned long deadline; | ||
| 140 | int i, ret = 0; | 139 | int i, ret = 0; |
| 140 | u32 pxx_req; | ||
| 141 | 141 | ||
| 142 | regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING, | 142 | regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING, |
| 143 | domain->bits.map, domain->bits.map); | 143 | domain->bits.map, domain->bits.map); |
| @@ -169,30 +169,19 @@ static int imx_gpc_pu_pgc_sw_pxx_req(struct generic_pm_domain *genpd, | |||
| 169 | * As per "5.5.9.4 Example Code 4" in IMX7DRM.pdf wait | 169 | * As per "5.5.9.4 Example Code 4" in IMX7DRM.pdf wait |
| 170 | * for PUP_REQ/PDN_REQ bit to be cleared | 170 | * for PUP_REQ/PDN_REQ bit to be cleared |
| 171 | */ | 171 | */ |
| 172 | deadline = jiffies + msecs_to_jiffies(1); | 172 | ret = regmap_read_poll_timeout(domain->regmap, offset, pxx_req, |
| 173 | while (true) { | 173 | !(pxx_req & domain->bits.pxx), |
| 174 | u32 pxx_req; | 174 | 0, USEC_PER_MSEC); |
| 175 | 175 | if (ret) { | |
| 176 | regmap_read(domain->regmap, offset, &pxx_req); | 176 | dev_err(domain->dev, "failed to command PGC\n"); |
| 177 | 177 | /* | |
| 178 | if (!(pxx_req & domain->bits.pxx)) | 178 | * If we were in a process of enabling a |
| 179 | break; | 179 | * domain and failed we might as well disable |
| 180 | 180 | * the regulator we just enabled. And if it | |
| 181 | if (time_after(jiffies, deadline)) { | 181 | * was the opposite situation and we failed to |
| 182 | dev_err(domain->dev, "falied to command PGC\n"); | 182 | * power down -- keep the regulator on |
| 183 | ret = -ETIMEDOUT; | 183 | */ |
| 184 | /* | 184 | on = !on; |
| 185 | * If we were in a process of enabling a | ||
| 186 | * domain and failed we might as well disable | ||
| 187 | * the regulator we just enabled. And if it | ||
| 188 | * was the opposite situation and we failed to | ||
| 189 | * power down -- keep the regulator on | ||
| 190 | */ | ||
| 191 | on = !on; | ||
| 192 | break; | ||
| 193 | } | ||
| 194 | |||
| 195 | cpu_relax(); | ||
| 196 | } | 185 | } |
| 197 | 186 | ||
| 198 | if (enable_power_control) | 187 | if (enable_power_control) |
