Thread (10 messages) 10 messages, 4 authors, 2020-10-07

Re: [PATCH v4 2/4] leds: Add driver for Qualcomm LPG

From: Luca Weiss <hidden>
Date: 2020-10-07 09:46:32
Also in: linux-arm-msm, linux-leds, linux-pwm, lkml

Hi Bjorn,

On Mon Sep 28, 2020 at 8:15 PM, Bjorn Andersson wrote:
The Light Pulse Generator (LPG) is a PWM-block found in a wide range of
PMICs from Qualcomm. It can operate on fixed parameters or based on a
lookup-table, altering the duty cycle over time - which provides the
means for e.g. hardware assisted transitions of LED brightness.

Signed-off-by: Bjorn Andersson <redacted>
---

Changes since v3:
- Adopt multicolor model
- Simplified hw_pattern implementation

drivers/leds/Kconfig | 9 +
drivers/leds/Makefile | 1 +
drivers/leds/leds-qcom-lpg.c | 1213 ++++++++++++++++++++++++++++++++++
3 files changed, 1223 insertions(+)
create mode 100644 drivers/leds/leds-qcom-lpg.c
<snip>
+static int lpg_pwm_request(struct pwm_chip *chip, struct pwm_device
*pwm)
+{
+ struct lpg *lpg = container_of(chip, struct lpg, pwm);
+ struct lpg_channel *chan = &lpg->channels[pwm->hwpwm];
+
+ return chan->in_use ? -EBUSY : 0;
+}
+
+static int lpg_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+ const struct pwm_state *state)
+{
+ struct lpg *lpg = container_of(chip, struct lpg, pwm);
+ struct lpg_channel *chan = &lpg->channels[pwm->hwpwm];
+
+ lpg_calc_freq(chan, state->period / NSEC_PER_USEC);
+ lpg_calc_duty(chan, state->duty_cycle / NSEC_PER_USEC);
As written on IRC this has to be wrapped div_u64() to compile on arm32;
should also fix the buildbot failure.
+ chan->enabled = state->enabled;
+
+ lpg_apply(chan);
+
+ triled_set(lpg, chan->triled_mask, chan->enabled);
+
+ return 0;
+}
Other than that, this works great on msm8974-fairphone-fp2 (pm8941)
with reg 7 (red), 6 (green) & 5 (blue). Thanks for updating this
patchset!

Regards
Luca
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help