summaryrefslogtreecommitdiffstats
path: root/drivers/staging/hikey9xx
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-08-17 09:10:44 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-08-18 16:15:25 +0200
commit12ca3b20dbd42c9c35b0499754317bdc2fc533d0 (patch)
treeb5a503b06f6955a878115527dae702d7c9e2afba /drivers/staging/hikey9xx
parent0e0473c8387b656bce8a3f6fe38fed7e1bb2761d (diff)
staging: regulator: hi6421v600-regulator: port it to upstream
The driver was originally written for Kernel 4.9. It needs to be ported to upstream: - Got rid of timeval; - Removed a bogus dependency; - Did cleanups at the header file. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/9e34400d2cc15ef501a8478f69a95c9abc5c4d8d.1597647359.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/hikey9xx')
-rw-r--r--drivers/staging/hikey9xx/hi6421v600-regulator.c34
1 files changed, 5 insertions, 29 deletions
diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c
index 7bc0ae27b110..904cb64b1dcd 100644
--- a/drivers/staging/hikey9xx/hi6421v600-regulator.c
+++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c
@@ -49,7 +49,6 @@ struct hisi_regulator_register_info {
struct hisi_regulator {
const char *name;
struct hisi_regulator_register_info register_info;
- struct timeval last_off_time;
u32 off_on_delay;
u32 eco_uA;
struct regulator_desc rdesc;
@@ -57,8 +56,6 @@ struct hisi_regulator {
};
static DEFINE_MUTEX(enable_mutex);
-struct timeval last_enabled;
-
static inline struct hisi_pmic *rdev_to_pmic(struct regulator_dev *dev)
{
@@ -72,27 +69,6 @@ static inline struct hisi_pmic *rdev_to_pmic(struct regulator_dev *dev)
/* helper function to ensure when it returns it is at least 'delay_us'
* microseconds after 'since'.
*/
-static void ensured_time_after(struct timeval since, u32 delay_us)
-{
- struct timeval now;
- u64 elapsed_ns64, delay_ns64;
- u32 actual_us32;
-
- delay_ns64 = delay_us * NSEC_PER_USEC;
- do_gettimeofday(&now);
- elapsed_ns64 = timeval_to_ns(&now) - timeval_to_ns(&since);
- if (delay_ns64 > elapsed_ns64) {
- actual_us32 = ((u32)(delay_ns64 - elapsed_ns64) /
- NSEC_PER_USEC);
- if (actual_us32 >= 1000) {
- mdelay(actual_us32 / 1000); /*lint !e647 */
- udelay(actual_us32 % 1000);
- } else if (actual_us32 > 0) {
- udelay(actual_us32);
- }
- }
- return;
-}
static int hisi_regulator_is_enabled(struct regulator_dev *dev)
{
@@ -113,13 +89,16 @@ static int hisi_regulator_enable(struct regulator_dev *dev)
struct hisi_pmic *pmic = rdev_to_pmic(dev);
/* keep a distance of off_on_delay from last time disabled */
- ensured_time_after(sreg->last_off_time, sreg->off_on_delay);
+ usleep_range(sreg->off_on_delay, sreg->off_on_delay + 1000);
pr_debug("<[%s]: off_on_delay=%dus>\n", __func__, sreg->off_on_delay);
/* cannot enable more than one regulator at one time */
mutex_lock(&enable_mutex);
- ensured_time_after(last_enabled, HISI_REGS_ENA_PROTECT_TIME);
+ usleep_range(HISI_REGS_ENA_PROTECT_TIME,
+ HISI_REGS_ENA_PROTECT_TIME + 1000);
+
+
/* set enable register */
hisi_pmic_rmw(pmic, sreg->register_info.ctrl_reg,
@@ -128,7 +107,6 @@ static int hisi_regulator_enable(struct regulator_dev *dev)
pr_debug("<[%s]: ctrl_reg=0x%x,enable_mask=0x%x>\n", __func__, sreg->register_info.ctrl_reg,\
sreg->register_info.enable_mask);
- do_gettimeofday(&last_enabled);
mutex_unlock(&enable_mutex);
return 0;
@@ -143,8 +121,6 @@ static int hisi_regulator_disable(struct regulator_dev *dev)
hisi_pmic_rmw(pmic, sreg->register_info.ctrl_reg,
sreg->register_info.enable_mask, 0);
- do_gettimeofday(&sreg->last_off_time);
-
return 0;
}