* [PATCH] clocksource: sh_cmt: use CMTOUT_IE only when supported
@ 2021-03-05 13:28 Wolfram Sang
2021-03-08 8:35 ` Geert Uytterhoeven
2021-03-08 12:04 ` Niklas Söderlund
0 siblings, 2 replies; 4+ messages in thread
From: Wolfram Sang @ 2021-03-05 13:28 UTC (permalink / raw)
To: linux-renesas-soc
Cc: linux-kernel, Daniel Lezcano, Niklas Söderlund,
Wolfram Sang, Phong Hoang
CMTOUT_IE is only supported for older SoCs. Newer SoCs shall not set
this bit. So, add a version check.
Reported-by: Phong Hoang <phong.hoang.wz@renesas.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Confirmed with datasheets and could successfully repeat Niklas' CMT
tests on an R-Car M3N based Salvator-XS.
drivers/clocksource/sh_cmt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index c98f8851fd68..3b53c6cb1da9 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -143,6 +143,7 @@ struct sh_cmt_device {
#define SH_CMT32_CMCSR_SSIE (1 << 10)
#define SH_CMT32_CMCSR_CMS (1 << 9)
#define SH_CMT32_CMCSR_CMM (1 << 8)
+/* CMTOUT_IE only for SH_CMT_32BIT and SH_CMT_48BIT */
#define SH_CMT32_CMCSR_CMTOUT_IE (1 << 7)
#define SH_CMT32_CMCSR_CMR_NONE (0 << 4)
#define SH_CMT32_CMCSR_CMR_DMA (1 << 4)
@@ -339,8 +340,9 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch)
sh_cmt_write_cmcsr(ch, SH_CMT16_CMCSR_CMIE |
SH_CMT16_CMCSR_CKS512);
} else {
- sh_cmt_write_cmcsr(ch, SH_CMT32_CMCSR_CMM |
- SH_CMT32_CMCSR_CMTOUT_IE |
+ u32 cmtout = ch->cmt->info->model <= SH_CMT_48BIT ?
+ SH_CMT32_CMCSR_CMTOUT_IE : 0;
+ sh_cmt_write_cmcsr(ch, cmtout | SH_CMT32_CMCSR_CMM |
SH_CMT32_CMCSR_CMR_IRQ |
SH_CMT32_CMCSR_CKS_RCLK8);
}
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] clocksource: sh_cmt: use CMTOUT_IE only when supported
2021-03-05 13:28 [PATCH] clocksource: sh_cmt: use CMTOUT_IE only when supported Wolfram Sang
@ 2021-03-08 8:35 ` Geert Uytterhoeven
2021-03-09 9:35 ` Wolfram Sang
2021-03-08 12:04 ` Niklas Söderlund
1 sibling, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2021-03-08 8:35 UTC (permalink / raw)
To: Wolfram Sang, Phong Hoang
Cc: Linux-Renesas, Linux Kernel Mailing List, Daniel Lezcano,
Niklas Söderlund
Hi Wolfram, Phong-san,
On Fri, Mar 5, 2021 at 2:30 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> CMTOUT_IE is only supported for older SoCs. Newer SoCs shall not set
> this bit. So, add a version check.
>
> Reported-by: Phong Hoang <phong.hoang.wz@renesas.com>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Thanks for your patch!
As R-Car Gen2/3 indeed don't have this bit:
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
But given my comments below, I think it would make sense to change the
one-line summary to e.g. "clocksource: sh_cmt: R-Car Gen2/Gen3 do not
have CMTOUT_IE".
> --- a/drivers/clocksource/sh_cmt.c
> +++ b/drivers/clocksource/sh_cmt.c
> @@ -143,6 +143,7 @@ struct sh_cmt_device {
> #define SH_CMT32_CMCSR_SSIE (1 << 10)
> #define SH_CMT32_CMCSR_CMS (1 << 9)
> #define SH_CMT32_CMCSR_CMM (1 << 8)
> +/* CMTOUT_IE only for SH_CMT_32BIT and SH_CMT_48BIT */
> #define SH_CMT32_CMCSR_CMTOUT_IE (1 << 7)
> #define SH_CMT32_CMCSR_CMR_NONE (0 << 4)
> #define SH_CMT32_CMCSR_CMR_DMA (1 << 4)
> @@ -339,8 +340,9 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch)
> sh_cmt_write_cmcsr(ch, SH_CMT16_CMCSR_CMIE |
> SH_CMT16_CMCSR_CKS512);
> } else {
> - sh_cmt_write_cmcsr(ch, SH_CMT32_CMCSR_CMM |
> - SH_CMT32_CMCSR_CMTOUT_IE |
> + u32 cmtout = ch->cmt->info->model <= SH_CMT_48BIT ?
> + SH_CMT32_CMCSR_CMTOUT_IE : 0;
> + sh_cmt_write_cmcsr(ch, cmtout | SH_CMT32_CMCSR_CMM |
> SH_CMT32_CMCSR_CMR_IRQ |
> SH_CMT32_CMCSR_CKS_RCLK8);
> }
Note that this bit is still set for all "32-bit" and all other "48-bit"
variants:
SH_CMT_32BIT:
sh7720: CMTOUT_IE supported
sh7343/7366: no docs
sh7722/sh7723: limited docs, but "Supports canceling of the standby
state in U-standby mode."
sh7724: CMTOUT_IE supported
SH_CMT_48BIT:
sh73a0/r8a7740: CMTOUT_IE supported on channels 1/2/3, not on 0/4/5
So even not all older models support this bit.
Probably this bit should only be set when the timer is configured as a
wake-up source. But that is out-of-scope for this patch.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clocksource: sh_cmt: use CMTOUT_IE only when supported
2021-03-05 13:28 [PATCH] clocksource: sh_cmt: use CMTOUT_IE only when supported Wolfram Sang
2021-03-08 8:35 ` Geert Uytterhoeven
@ 2021-03-08 12:04 ` Niklas Söderlund
1 sibling, 0 replies; 4+ messages in thread
From: Niklas Söderlund @ 2021-03-08 12:04 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-renesas-soc, linux-kernel, Daniel Lezcano, Phong Hoang
Hi Wolfram,
Thanks for your patch.
On 2021-03-05 14:28:59 +0100, Wolfram Sang wrote:
> CMTOUT_IE is only supported for older SoCs. Newer SoCs shall not set
> this bit. So, add a version check.
>
> Reported-by: Phong Hoang <phong.hoang.wz@renesas.com>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
>
> Confirmed with datasheets and could successfully repeat Niklas' CMT
> tests on an R-Car M3N based Salvator-XS.
>
> drivers/clocksource/sh_cmt.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
> index c98f8851fd68..3b53c6cb1da9 100644
> --- a/drivers/clocksource/sh_cmt.c
> +++ b/drivers/clocksource/sh_cmt.c
> @@ -143,6 +143,7 @@ struct sh_cmt_device {
> #define SH_CMT32_CMCSR_SSIE (1 << 10)
> #define SH_CMT32_CMCSR_CMS (1 << 9)
> #define SH_CMT32_CMCSR_CMM (1 << 8)
> +/* CMTOUT_IE only for SH_CMT_32BIT and SH_CMT_48BIT */
> #define SH_CMT32_CMCSR_CMTOUT_IE (1 << 7)
> #define SH_CMT32_CMCSR_CMR_NONE (0 << 4)
> #define SH_CMT32_CMCSR_CMR_DMA (1 << 4)
> @@ -339,8 +340,9 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch)
> sh_cmt_write_cmcsr(ch, SH_CMT16_CMCSR_CMIE |
> SH_CMT16_CMCSR_CKS512);
> } else {
> - sh_cmt_write_cmcsr(ch, SH_CMT32_CMCSR_CMM |
> - SH_CMT32_CMCSR_CMTOUT_IE |
> + u32 cmtout = ch->cmt->info->model <= SH_CMT_48BIT ?
> + SH_CMT32_CMCSR_CMTOUT_IE : 0;
> + sh_cmt_write_cmcsr(ch, cmtout | SH_CMT32_CMCSR_CMM |
> SH_CMT32_CMCSR_CMR_IRQ |
> SH_CMT32_CMCSR_CKS_RCLK8);
> }
> --
> 2.29.2
>
--
Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clocksource: sh_cmt: use CMTOUT_IE only when supported
2021-03-08 8:35 ` Geert Uytterhoeven
@ 2021-03-09 9:35 ` Wolfram Sang
0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2021-03-09 9:35 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Phong Hoang, Linux-Renesas, Linux Kernel Mailing List,
Daniel Lezcano, Niklas Söderlund
[-- Attachment #1: Type: text/plain, Size: 503 bytes --]
> But given my comments below, I think it would make sense to change the
> one-line summary to e.g. "clocksource: sh_cmt: R-Car Gen2/Gen3 do not
> have CMTOUT_IE".
Makes sense. I will resend.
> SH_CMT_48BIT:
> sh73a0/r8a7740: CMTOUT_IE supported on channels 1/2/3, not on 0/4/5
Oh, I didn't spot this, sorry!
> So even not all older models support this bit.
> Probably this bit should only be set when the timer is configured as a
> wake-up source. But that is out-of-scope for this patch.
Ack.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-09 9:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 13:28 [PATCH] clocksource: sh_cmt: use CMTOUT_IE only when supported Wolfram Sang
2021-03-08 8:35 ` Geert Uytterhoeven
2021-03-09 9:35 ` Wolfram Sang
2021-03-08 12:04 ` Niklas Söderlund
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).