From ed90ef941ab8537644fd37c91558a4e1f1705a66 Mon Sep 17 00:00:00 2001 From: Guru Das Srinagesh Date: Tue, 26 May 2020 17:56:41 -0700 Subject: [PATCH] pwm: qti-lpg: Read tick duration via device tree Tick duration defines the tick duration (in microseconds) for the clock that PPG uses which is used to program the ramp step duration for the pattern. If unspecified, the default value is 7800 us. Change-Id: I7cd96d74a39becffbf9a008610c0092ad2462446 Signed-off-by: Guru Das Srinagesh --- drivers/pwm/pwm-qti-lpg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-qti-lpg.c b/drivers/pwm/pwm-qti-lpg.c index f8f006e52a3f..fd55379083a7 100644 --- a/drivers/pwm/pwm-qti-lpg.c +++ b/drivers/pwm/pwm-qti-lpg.c @@ -173,6 +173,7 @@ struct qpnp_lpg_lut { enum ppg_num_nvmems nvmem_count; u32 reg_base; u32 *pattern; /* patterns in percentage */ + u32 ramp_step_tick_us; }; struct qpnp_lpg_channel { @@ -550,8 +551,8 @@ static int qpnp_lpg_set_sdam_ramp_config(struct qpnp_lpg_channel *lpg) return rc; } - /* Set ramp step duration, one WAIT_TICK is 7.8ms */ - val = (ramp->step_ms * 1000 / 7800) & 0xff; + /* Set ramp step duration, in ticks */ + val = (ramp->step_ms * 1000 / lpg->chip->lut->ramp_step_tick_us) & 0xff; if (val > 0) val--; addr = SDAM_REG_RAMP_STEP_DURATION; @@ -1549,6 +1550,7 @@ static int qpnp_lpg_get_nvmem_dt(struct qpnp_lpg_chip *chip) return rc; } +#define DEFAULT_TICK_DURATION_US 7800 static int qpnp_lpg_parse_dt(struct qpnp_lpg_chip *chip) { int rc = 0, i; @@ -1608,6 +1610,10 @@ static int qpnp_lpg_parse_dt(struct qpnp_lpg_chip *chip) return rc; } + chip->lut->ramp_step_tick_us = DEFAULT_TICK_DURATION_US; + of_property_read_u32(chip->dev->of_node, "qcom,tick-period-us", + &chip->lut->ramp_step_tick_us); + rc = qpnp_lpg_parse_pattern_dt(chip, SDAM_LUT_COUNT_MAX); if (rc < 0) { of_node_put(chip->pbs_dev_node);