lkml.org 
[lkml]   [2022]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 7/8] pwm: dwc: add snps,pwm-number to limit pwm count
Date
Add snps,pwm-number property to indicate if the block does not have
all 8 of the PWM blocks.

Not sure if this should be a general PWM property consider optional
for all PWM types, so have added a specific one here (there is only
one other controller with a property for PWM count at the moment)

Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
---
drivers/pwm/pwm-dwc.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c
index 5c319d0e3d52..5edfb8f8acbf 100644
--- a/drivers/pwm/pwm-dwc.c
+++ b/drivers/pwm/pwm-dwc.c
@@ -328,12 +328,20 @@ static int dwc_pwm_plat_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct dwc_pwm *dwc;
+ u32 nr_pwm;
int ret;

dwc = dwc_pwm_alloc(dev);
if (!dwc)
return -ENOMEM;

+ if (!device_property_read_u32(dev, "snps,pwm-number", &nr_pwm)) {
+ if (nr_pwm > DWC_TIMERS_TOTAL)
+ dev_err(dev, "too many PWMs specified (%d)\n", nr_pwm);
+ else
+ dwc->chip.npwm = nr_pwm;
+ }
+
dwc->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(dwc->base))
return dev_err_probe(dev, PTR_ERR(dwc->base),
--
2.35.1
\
 
 \ /
  Last update: 2022-08-05 18:52    [W:0.275 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site