[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7d64ea1d-b573-4a69-ba0c-4cbfab638c5e@starfivetech.com>
Date: Wed, 1 Nov 2023 10:22:44 +0800
From: William Qiu <william.qiu@...rfivetech.com>
To: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
CC: <devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-riscv@...ts.infradead.org>, <linux-pwm@...r.kernel.org>,
"Emil Renner Berthing" <kernel@...il.dk>,
Rob Herring <robh+dt@...nel.org>,
Thierry Reding <thierry.reding@...il.com>,
Philipp Zabel <p.zabel@...gutronix.de>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Hal Feng <hal.feng@...rfivetech.com>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>
Subject: Re: [PATCH v6 2/4] pwm: opencores: Add PWM driver support
On 2023/10/20 19:25, Uwe Kleine-König wrote:
>> + void __iomem *base = pwm->data->get_ch_base ?
>> + pwm->data->get_ch_base(pwm->regs, dev->hwpwm) : pwm->regs;
>> + u32 period_data, duty_data, ctrl_data;
>> +
>> + period_data = readl(REG_OCPWM_LRC(base));
>> + duty_data = readl(REG_OCPWM_HRC(base));
>> + ctrl_data = readl(REG_OCPWM_CTRL(base));
>> +
>> + state->period = DIV_ROUND_CLOSEST_ULL((u64)period_data * NSEC_PER_SEC, pwm->clk_rate);
>> + state->duty_cycle = DIV_ROUND_CLOSEST_ULL((u64)duty_data * NSEC_PER_SEC, pwm->clk_rate);
>
> Please test your driver with PWM_DEBUG enabled. The rounding is wrong
> here.
>
Hi Uwe,
The conclusion after checking is: when the period or duty_cycle value set
by the user is not divisible (1000000000/49.5M), there will be an error.
This error is due to hardware accuracy. So why is rounding is wrong?
rockchip also has a similar implementation drivers/pwm/ pwm-rockchip.c
Best regards,
William
Powered by blists - more mailing lists