aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/soc/imx
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-02-19 21:14:29 -0500
committerShawn Guo <shawnguo@kernel.org>2019-03-19 04:47:09 -0400
commit8217a7a2c76259ff1f2623b60c3bcede052cdb49 (patch)
treeb9f9344326c0d1e17b1111f39fc773427e66ad3c /drivers/soc/imx
parent9e98c678c2d6ae3a17cb2de55d17f69dddaa231b (diff)
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>
Diffstat (limited to 'drivers/soc/imx')
-rw-r--r--drivers/soc/imx/gpcv2.c39
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)