Hello,
This patch series fix 2 bugs regarding the pwm configuration:
- the clock source of the timer channel is never applied
- the maximum time that can be represented when using the slow clock may be
wrong if the tc block provide a 32 bits width counter
Best Regards,
Boris
Boris BREZILLON (2):
pwm: atmel-tcb: add missing clk source config
pwm: atmel-tcb: fix max time computation for slow clk source
drivers/pwm/pwm-atmel-tcb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--
1.7.9.5
Use the the tcb counter width to compute the maximum time that can be
represented using the slow clock source instead of the static 16 bit width.
Signed-off-by: Boris BREZILLON <[email protected]>
---
drivers/pwm/pwm-atmel-tcb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
index 0266969..f3dcd02 100644
--- a/drivers/pwm/pwm-atmel-tcb.c
+++ b/drivers/pwm/pwm-atmel-tcb.c
@@ -307,7 +307,7 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
i = slowclk;
rate = 32768;
min = div_u64(NSEC_PER_SEC, rate);
- max = min << 16;
+ max = min << tc->tcb_config->counter_width;
/* If period is too big return ERANGE error */
if (max < period_ns)
--
1.7.9.5
Clock source changes are never applied to the CMR register.
This may lead to wrong period/duty cycle configuration.
Signed-off-by: Boris BREZILLON <[email protected]>
---
drivers/pwm/pwm-atmel-tcb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
index ba6ce01..0266969 100644
--- a/drivers/pwm/pwm-atmel-tcb.c
+++ b/drivers/pwm/pwm-atmel-tcb.c
@@ -249,6 +249,8 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
}
}
+ cmr |= (tcbpwm->div & ATMEL_TC_TCCLKS);
+
__raw_writel(cmr, regs + ATMEL_TC_REG(group, CMR));
if (index == 0)
--
1.7.9.5
On 18/09/2013 17:06, Boris BREZILLON :
> Clock source changes are never applied to the CMR register.
> This may lead to wrong period/duty cycle configuration.
>
> Signed-off-by: Boris BREZILLON <[email protected]>
Acked-by: Nicolas Ferre <[email protected]>
> ---
> drivers/pwm/pwm-atmel-tcb.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
> index ba6ce01..0266969 100644
> --- a/drivers/pwm/pwm-atmel-tcb.c
> +++ b/drivers/pwm/pwm-atmel-tcb.c
> @@ -249,6 +249,8 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
> }
> }
>
> + cmr |= (tcbpwm->div & ATMEL_TC_TCCLKS);
> +
> __raw_writel(cmr, regs + ATMEL_TC_REG(group, CMR));
>
> if (index == 0)
>
--
Nicolas Ferre
On 18/09/2013 17:06, Boris BREZILLON :
> Use the the tcb counter width to compute the maximum time that can be
> represented using the slow clock source instead of the static 16 bit width.
>
> Signed-off-by: Boris BREZILLON <[email protected]>
Acked-by: Nicolas Ferre <[email protected]>
> ---
> drivers/pwm/pwm-atmel-tcb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
> index 0266969..f3dcd02 100644
> --- a/drivers/pwm/pwm-atmel-tcb.c
> +++ b/drivers/pwm/pwm-atmel-tcb.c
> @@ -307,7 +307,7 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> i = slowclk;
> rate = 32768;
> min = div_u64(NSEC_PER_SEC, rate);
> - max = min << 16;
> + max = min << tc->tcb_config->counter_width;
>
> /* If period is too big return ERANGE error */
> if (max < period_ns)
>
--
Nicolas Ferre
On Wed, Sep 18, 2013 at 05:05:20PM +0200, Boris BREZILLON wrote:
> Hello,
>
> This patch series fix 2 bugs regarding the pwm configuration:
> - the clock source of the timer channel is never applied
> - the maximum time that can be represented when using the slow clock may be
> wrong if the tc block provide a 32 bits width counter
>
> Best Regards,
>
> Boris
>
> Boris BREZILLON (2):
> pwm: atmel-tcb: add missing clk source config
> pwm: atmel-tcb: fix max time computation for slow clk source
>
> drivers/pwm/pwm-atmel-tcb.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Both applied, with Nicolas' Acked-by.
Thierry
On 19/09/2013 14:06, Thierry Reding wrote:
> On Wed, Sep 18, 2013 at 05:05:20PM +0200, Boris BREZILLON wrote:
>> Hello,
>>
>> This patch series fix 2 bugs regarding the pwm configuration:
>> - the clock source of the timer channel is never applied
>> - the maximum time that can be represented when using the slow clock may be
>> wrong if the tc block provide a 32 bits width counter
>>
>> Best Regards,
>>
>> Boris
>>
>> Boris BREZILLON (2):
>> pwm: atmel-tcb: add missing clk source config
>> pwm: atmel-tcb: fix max time computation for slow clk source
>>
>> drivers/pwm/pwm-atmel-tcb.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
> Both applied, with Nicolas' Acked-by.
>
> Thierry
Thanks.
Regards,
Boris