All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] clk-pwm: show duty cycle in debugfs
@ 2019-05-25 18:42 Martin Blumenstingl
  2019-05-25 18:42 ` [PATCH 1/1] clk: pwm: implement the .get_duty_cycle callback Martin Blumenstingl
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Blumenstingl @ 2019-05-25 18:42 UTC (permalink / raw)
  To: linux-clk, mturquette, sboyd; +Cc: linux-kernel, Martin Blumenstingl

This is a patch that I had lying around in my tree for a while. I was
planning to use it back when I was debugging CPU clock issues on
Meson8b a while ago but it turned out that PWM was not related to that.

Feel free to apply or drop this patch, depending on whether it might or
might not be useful for anyone.

I have successfully tested it with the 32.768kHz LPO clock for the SDIO
wifi chipset on my Khadas VIM (Amlogic Meson GXL SoC):
  wifi32k  [...]  32768  [...]  50000


Martin Blumenstingl (1):
  clk: pwm: implement the .get_duty_cycle callback

 drivers/clk/clk-pwm.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] clk: pwm: implement the .get_duty_cycle callback
  2019-05-25 18:42 [PATCH 0/1] clk-pwm: show duty cycle in debugfs Martin Blumenstingl
@ 2019-05-25 18:42 ` Martin Blumenstingl
  2019-06-06 18:38   ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Blumenstingl @ 2019-05-25 18:42 UTC (permalink / raw)
  To: linux-clk, mturquette, sboyd; +Cc: linux-kernel, Martin Blumenstingl

Commit 9fba738a53dda2 ("clk: add duty cycle support") added support for
getting and setting the duty cycle of a clock. This implements the
get_duty_cycle callback for PWM based clocks so the duty cycle is shown
in the debugfs output (/sys/kernel/debug/clk/clk_summary).

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/clk/clk-pwm.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/clk/clk-pwm.c b/drivers/clk/clk-pwm.c
index 02b472a1f9b0..c0cd6a0ff7f8 100644
--- a/drivers/clk/clk-pwm.c
+++ b/drivers/clk/clk-pwm.c
@@ -47,10 +47,24 @@ static unsigned long clk_pwm_recalc_rate(struct clk_hw *hw,
 	return clk_pwm->fixed_rate;
 }
 
+static int clk_pwm_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)
+{
+	struct clk_pwm *clk_pwm = to_clk_pwm(hw);
+	struct pwm_state state;
+
+	pwm_get_state(clk_pwm->pwm, &state);
+
+	duty->num = state.duty_cycle;
+	duty->den = state.period;
+
+	return 0;
+}
+
 static const struct clk_ops clk_pwm_ops = {
 	.prepare = clk_pwm_prepare,
 	.unprepare = clk_pwm_unprepare,
 	.recalc_rate = clk_pwm_recalc_rate,
+	.get_duty_cycle = clk_pwm_get_duty_cycle,
 };
 
 static int clk_pwm_probe(struct platform_device *pdev)
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] clk: pwm: implement the .get_duty_cycle callback
  2019-05-25 18:42 ` [PATCH 1/1] clk: pwm: implement the .get_duty_cycle callback Martin Blumenstingl
@ 2019-06-06 18:38   ` Stephen Boyd
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2019-06-06 18:38 UTC (permalink / raw)
  To: Martin Blumenstingl, linux-clk, mturquette
  Cc: linux-kernel, Martin Blumenstingl

Quoting Martin Blumenstingl (2019-05-25 11:42:53)
> Commit 9fba738a53dda2 ("clk: add duty cycle support") added support for
> getting and setting the duty cycle of a clock. This implements the
> get_duty_cycle callback for PWM based clocks so the duty cycle is shown
> in the debugfs output (/sys/kernel/debug/clk/clk_summary).
> 
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---

Seems ok to me. I'm not sure how useful it will be if pwm has debugfs
that can be read too, but I'm not too worried about it.

Applied to clk-next


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-06 18:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-25 18:42 [PATCH 0/1] clk-pwm: show duty cycle in debugfs Martin Blumenstingl
2019-05-25 18:42 ` [PATCH 1/1] clk: pwm: implement the .get_duty_cycle callback Martin Blumenstingl
2019-06-06 18:38   ` Stephen Boyd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.