2013-09-18 15:11:28

by Boris BREZILLON

[permalink] [raw]
Subject: [PATCH 0/2] pwm: atmel-tcb: config fixes

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


2013-09-18 15:31:25

by Boris BREZILLON

[permalink] [raw]
Subject: [PATCH 2/2] pwm: atmel-tcb: fix max time computation for slow clk source

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

2013-09-18 15:41:26

by Boris BREZILLON

[permalink] [raw]
Subject: [PATCH 1/2] pwm: atmel-tcb: add missing clk source config

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

2013-09-19 07:24:24

by Nicolas Ferre

[permalink] [raw]
Subject: Re: [PATCH 1/2] pwm: atmel-tcb: add missing clk source config

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

2013-09-19 07:24:56

by Nicolas Ferre

[permalink] [raw]
Subject: Re: [PATCH 2/2] pwm: atmel-tcb: fix max time computation for slow clk source

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

2013-09-19 12:07:36

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 0/2] pwm: atmel-tcb: config fixes

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


Attachments:
(No filename) (654.00 B)
(No filename) (836.00 B)
Download all attachments

2013-09-19 12:11:08

by Boris BREZILLON

[permalink] [raw]
Subject: Re: [PATCH 0/2] pwm: atmel-tcb: config fixes

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