[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <hwnhz4yr6vzz3oav4gq7qptejjy3rdwff7iveawaxexf3tbngr@pnrxi6jkpw3k>
Date: Mon, 24 Mar 2025 12:40:39 +0100
From: Uwe Kleine-König <ukleinek@...nel.org>
To: Mubin Sayyed <mubin.sayyed@....com>
Cc: krzysztof.kozlowski+dt@...aro.org, daniel.lezcano@...aro.org,
tglx@...utronix.de, michal.simek@....com, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, linux-pwm@...r.kernel.org, git@....com
Subject: Re: [PATCH v4 2/3] clocksource: timer-cadence-ttc: Support TTC
device configured as PWM
On Wed, Jan 15, 2025 at 05:05:55PM +0530, Mubin Sayyed wrote:
> TTC device can act either as clocksource/clockevent or PWM generator,
> it would be decided by pwm-cells property. If pwm-cells property is
> present in TTC node, it would be treated as PWM device, and clocksource
> driver just calls probe function for PWM functionality, so that TTC
> device would be registered with PWM framework.
>
> Signed-off-by: Mubin Sayyed <mubin.sayyed@....com>
> ---
> Changes for v4:
> - In case of pwm-cells property call probe function for PWM
> feature instead of returning error.
> Changes for v3:
> - None
> Changes for v2:
> - Added comment regarding pwm-cells property
> ---
> drivers/clocksource/timer-cadence-ttc.c | 34 +++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-cadence-ttc.c
> index 2f33d4c40153..c5ecad9332c9 100644
> --- a/drivers/clocksource/timer-cadence-ttc.c
> +++ b/drivers/clocksource/timer-cadence-ttc.c
> @@ -35,6 +35,10 @@
> * obtained from device tree. The pre-scaler of 32 is used.
> */
>
> +struct ttc_timer_config {
> + bool is_pwm_mode;
> +};
> +
> /**
> * struct ttc_timer - This definition defines local timer structure
> *
> @@ -453,6 +457,7 @@ static int __init ttc_setup_clockevent(struct clk *clk,
>
> static int __init ttc_timer_probe(struct platform_device *pdev)
> {
> + struct ttc_timer_config *ttc_config;
> unsigned int irq;
> void __iomem *timer_baseaddr;
> struct clk *clk_cs, *clk_ce;
> @@ -461,6 +466,24 @@ static int __init ttc_timer_probe(struct platform_device *pdev)
> u32 timer_width = 16;
> struct device_node *timer = pdev->dev.of_node;
>
> + ttc_config = devm_kzalloc(&pdev->dev, sizeof(*ttc_config), GFP_KERNEL);
> + if (!ttc_config)
> + return -ENOMEM;
> +
> + /*
> + * If pwm-cells property is present in TTC node,
> + * it would be treated as PWM device.
> + */
> + if (of_property_read_bool(timer, "#pwm-cells")) {
> + #if defined(CONFIG_PWM_CADENCE)
> + ttc_config->is_pwm_mode = true;
> + return ttc_pwm_probe(pdev);
strange indention. Maybe use
if (IS_REACHABLE(CONFIG_PWM_CADENCE))
This is an unusal way to bind the PWM driver. I'd prefer creation of separate
device in the PWM case. I wonder if it can happen that ttc_pwm_probe() is
called during boot before pwm_init() completed. Or use an auxbus device
to distinguish between timer and pwm?
> + #else
> + return -ENODEV;
> + #endif
> + }
> + dev_set_drvdata(&pdev->dev, ttc_config);
> +
> if (initialized)
> return 0;
>
Best regards
Uwe
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists