mbox series

[v7,0/3] Timer support for ARM Tegra

Message ID 20230127071312.13844-1-clamor95@gmail.com
Headers show
Series Timer support for ARM Tegra | expand

Message

Svyatoslav Ryhel Jan. 27, 2023, 7:13 a.m. UTC
- ARM: tegra: remap clock_osc_freq for all Tegra family
Enum clock_osc_freq was designed to use only with T20.
This patch remaps it to use additional frequencies, added in
T30+ SoC while maintaining backwards compatibility with T20.

- drivers: timer: add timer driver for ARMv7 based Tegra devices
Add timer support for T20/T30/T114/T124 and T210 based devices.
Driver is based on DM, has device tree support and can be
used on SPL and early boot stage.

Arm64 Tegra (apart T210) according to comment in tegra-common.h use
architected timer.

- ARM: tegra: include timer as default option
Enable TIMER as default option for all Tegra devices and
enable TEGRA_TIMER for TEGRA_ARMV7_COMMON and TEGRA210.
Additionally enable SPL_TIMER if build as SPL part and
drop deprecated configs from common header.

P. S. I have no arm64 Tegra and according to comment in 
tegra-common.h
Use the Tegra US timer on ARMv7, but the architected timer on ARMv8.

---
Changeog from V6
 - use clk_m as timer calibration clock (this should properly fix T210)
 - enable timer for T210

Changed from v5:
 - added paz00 tester

Changed from v4:
 - added comments

Changed from v3:
 - removed BOOTSTAGE ifdefs
 - use early timer on boot stage unconditionally
---
Svyatoslav Ryhel (3):
  ARM: tegra: remap clock_osc_freq for all Tegra family
  drivers: timer: add driver for ARMv7 based Tegra devices and T210
  ARM: tegra: include timer as default option

 arch/arm/Kconfig                        |   1 +
 arch/arm/include/asm/arch-tegra/clock.h |   9 +-
 arch/arm/mach-tegra/Kconfig             |   3 +
 arch/arm/mach-tegra/clock.c             |  17 +++-
 arch/arm/mach-tegra/cpu.c               |  70 ++++++++++---
 arch/arm/mach-tegra/tegra114/clock.c    |  13 +--
 arch/arm/mach-tegra/tegra124/clock.c    |  13 +--
 arch/arm/mach-tegra/tegra20/clock.c     |   4 +-
 arch/arm/mach-tegra/tegra210/clock.c    |  22 +---
 arch/arm/mach-tegra/tegra30/clock.c     |  10 +-
 drivers/timer/Kconfig                   |   8 ++
 drivers/timer/Makefile                  |   1 +
 drivers/timer/tegra-timer.c             | 130 ++++++++++++++++++++++++
 drivers/usb/host/ehci-tegra.c           |  46 +++++++--
 include/configs/tegra-common.h          |   6 --
 15 files changed, 274 insertions(+), 79 deletions(-)
 create mode 100644 drivers/timer/tegra-timer.c

Comments

Thierry Reding Jan. 27, 2023, 5:15 p.m. UTC | #1
On Fri, Jan 27, 2023 at 09:13:09AM +0200, Svyatoslav Ryhel wrote:
> - ARM: tegra: remap clock_osc_freq for all Tegra family
> Enum clock_osc_freq was designed to use only with T20.
> This patch remaps it to use additional frequencies, added in
> T30+ SoC while maintaining backwards compatibility with T20.
> 
> - drivers: timer: add timer driver for ARMv7 based Tegra devices
> Add timer support for T20/T30/T114/T124 and T210 based devices.
> Driver is based on DM, has device tree support and can be
> used on SPL and early boot stage.
> 
> Arm64 Tegra (apart T210) according to comment in tegra-common.h use
> architected timer.
> 
> - ARM: tegra: include timer as default option
> Enable TIMER as default option for all Tegra devices and
> enable TEGRA_TIMER for TEGRA_ARMV7_COMMON and TEGRA210.
> Additionally enable SPL_TIMER if build as SPL part and
> drop deprecated configs from common header.
> 
> P. S. I have no arm64 Tegra and according to comment in 
> tegra-common.h
> Use the Tegra US timer on ARMv7, but the architected timer on ARMv8.
> 
> ---
> Changeog from V6
>  - use clk_m as timer calibration clock (this should properly fix T210)
>  - enable timer for T210
> 
> Changed from v5:
>  - added paz00 tester
> 
> Changed from v4:
>  - added comments
> 
> Changed from v3:
>  - removed BOOTSTAGE ifdefs
>  - use early timer on boot stage unconditionally
> ---
> Svyatoslav Ryhel (3):
>   ARM: tegra: remap clock_osc_freq for all Tegra family
>   drivers: timer: add driver for ARMv7 based Tegra devices and T210
>   ARM: tegra: include timer as default option
> 
>  arch/arm/Kconfig                        |   1 +
>  arch/arm/include/asm/arch-tegra/clock.h |   9 +-
>  arch/arm/mach-tegra/Kconfig             |   3 +
>  arch/arm/mach-tegra/clock.c             |  17 +++-
>  arch/arm/mach-tegra/cpu.c               |  70 ++++++++++---
>  arch/arm/mach-tegra/tegra114/clock.c    |  13 +--
>  arch/arm/mach-tegra/tegra124/clock.c    |  13 +--
>  arch/arm/mach-tegra/tegra20/clock.c     |   4 +-
>  arch/arm/mach-tegra/tegra210/clock.c    |  22 +---
>  arch/arm/mach-tegra/tegra30/clock.c     |  10 +-
>  drivers/timer/Kconfig                   |   8 ++
>  drivers/timer/Makefile                  |   1 +
>  drivers/timer/tegra-timer.c             | 130 ++++++++++++++++++++++++
>  drivers/usb/host/ehci-tegra.c           |  46 +++++++--
>  include/configs/tegra-common.h          |   6 --
>  15 files changed, 274 insertions(+), 79 deletions(-)
>  create mode 100644 drivers/timer/tegra-timer.c

Ugh... turns out I had completely messed up the testing on Tegra186 and
it wasn't working at all. The problem is that the selection of the TIMER
symbol for all of Tegra causes the driver model to be used, but there is
no DM driver for the architected timer that's used on Tegra186.

The quickest fix would be to do this:

--- >8 ---
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index b50eec5b8c9b..05c8ce0e08dd 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -56,7 +56,6 @@ config TEGRA_COMMON
 	select MISC
 	select OF_CONTROL
 	select SPI
-	select TIMER
 	imply CMD_DM
 	imply CRC32_VERIFY
 
@@ -83,6 +82,7 @@ config TEGRA_ARMV7_COMMON
 	select TEGRA_PINCTRL
 	select TEGRA_PMC
 	select TEGRA_TIMER
+	select TIMER
 
 config TEGRA_ARMV8_COMMON
 	bool "Tegra 64-bit common options"
@@ -137,6 +137,7 @@ config TEGRA210
 	select TEGRA_PMC
 	select TEGRA_PMC_SECURE
 	select TEGRA_TIMER
+	select TIMER
 
 config TEGRA186
 	bool "Tegra186 family"
--- >8 ---

So basically make TIMER selected on everything except Tegra186, so that
on Tegra186 things are basically unmodified.

Thierry
Svyatoslav Ryhel Jan. 27, 2023, 8:27 p.m. UTC | #2
On 1/27/23 19:15, Thierry Reding wrote:
> On Fri, Jan 27, 2023 at 09:13:09AM +0200, Svyatoslav Ryhel wrote:
>> - ARM: tegra: remap clock_osc_freq for all Tegra family
>> Enum clock_osc_freq was designed to use only with T20.
>> This patch remaps it to use additional frequencies, added in
>> T30+ SoC while maintaining backwards compatibility with T20.
>>
>> - drivers: timer: add timer driver for ARMv7 based Tegra devices
>> Add timer support for T20/T30/T114/T124 and T210 based devices.
>> Driver is based on DM, has device tree support and can be
>> used on SPL and early boot stage.
>>
>> Arm64 Tegra (apart T210) according to comment in tegra-common.h use
>> architected timer.
>>
>> - ARM: tegra: include timer as default option
>> Enable TIMER as default option for all Tegra devices and
>> enable TEGRA_TIMER for TEGRA_ARMV7_COMMON and TEGRA210.
>> Additionally enable SPL_TIMER if build as SPL part and
>> drop deprecated configs from common header.
>>
>> P. S. I have no arm64 Tegra and according to comment in
>> tegra-common.h
>> Use the Tegra US timer on ARMv7, but the architected timer on ARMv8.
>>
>> ---
>> Changeog from V6
>>   - use clk_m as timer calibration clock (this should properly fix T210)
>>   - enable timer for T210
>>
>> Changed from v5:
>>   - added paz00 tester
>>
>> Changed from v4:
>>   - added comments
>>
>> Changed from v3:
>>   - removed BOOTSTAGE ifdefs
>>   - use early timer on boot stage unconditionally
>> ---
>> Svyatoslav Ryhel (3):
>>    ARM: tegra: remap clock_osc_freq for all Tegra family
>>    drivers: timer: add driver for ARMv7 based Tegra devices and T210
>>    ARM: tegra: include timer as default option
>>
>>   arch/arm/Kconfig                        |   1 +
>>   arch/arm/include/asm/arch-tegra/clock.h |   9 +-
>>   arch/arm/mach-tegra/Kconfig             |   3 +
>>   arch/arm/mach-tegra/clock.c             |  17 +++-
>>   arch/arm/mach-tegra/cpu.c               |  70 ++++++++++---
>>   arch/arm/mach-tegra/tegra114/clock.c    |  13 +--
>>   arch/arm/mach-tegra/tegra124/clock.c    |  13 +--
>>   arch/arm/mach-tegra/tegra20/clock.c     |   4 +-
>>   arch/arm/mach-tegra/tegra210/clock.c    |  22 +---
>>   arch/arm/mach-tegra/tegra30/clock.c     |  10 +-
>>   drivers/timer/Kconfig                   |   8 ++
>>   drivers/timer/Makefile                  |   1 +
>>   drivers/timer/tegra-timer.c             | 130 ++++++++++++++++++++++++
>>   drivers/usb/host/ehci-tegra.c           |  46 +++++++--
>>   include/configs/tegra-common.h          |   6 --
>>   15 files changed, 274 insertions(+), 79 deletions(-)
>>   create mode 100644 drivers/timer/tegra-timer.c
> Ugh... turns out I had completely messed up the testing on Tegra186 and
> it wasn't working at all. The problem is that the selection of the TIMER
> symbol for all of Tegra causes the driver model to be used, but there is
> no DM driver for the architected timer that's used on Tegra186.
>
> The quickest fix would be to do this:
>
> --- >8 ---
> diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
> index b50eec5b8c9b..05c8ce0e08dd 100644
> --- a/arch/arm/mach-tegra/Kconfig
> +++ b/arch/arm/mach-tegra/Kconfig
> @@ -56,7 +56,6 @@ config TEGRA_COMMON
>   	select MISC
>   	select OF_CONTROL
>   	select SPI
> -	select TIMER
>   	imply CMD_DM
>   	imply CRC32_VERIFY
>   
> @@ -83,6 +82,7 @@ config TEGRA_ARMV7_COMMON
>   	select TEGRA_PINCTRL
>   	select TEGRA_PMC
>   	select TEGRA_TIMER
> +	select TIMER
>   
>   config TEGRA_ARMV8_COMMON
>   	bool "Tegra 64-bit common options"
> @@ -137,6 +137,7 @@ config TEGRA210
>   	select TEGRA_PMC
>   	select TEGRA_PMC_SECURE
>   	select TEGRA_TIMER
> +	select TIMER
>   
>   config TEGRA186
>   	bool "Tegra186 family"
> --- >8 ---
>
> So basically make TIMER selected on everything except Tegra186, so that
> on Tegra186 things are basically unmodified.

I can propose to include 'select TIMER' directly into TEGRA_TIMER config 
option. This will eliminate need of including it into mach-tegra Kconfigs.

BTW, may you check current patch set on T124 and T210 if those work 
properly. My T30 devices work fine and same as before after switch to 
clk_m as timer calibration clock.

Best Regards, Svyatoslav R.

> Thierry
Thierry Reding Jan. 31, 2023, 3:16 p.m. UTC | #3
On Fri, Jan 27, 2023 at 10:27:57PM +0200, Svyatoslav R. wrote:
> On 1/27/23 19:15, Thierry Reding wrote:
> > On Fri, Jan 27, 2023 at 09:13:09AM +0200, Svyatoslav Ryhel wrote:
> > > - ARM: tegra: remap clock_osc_freq for all Tegra family
> > > Enum clock_osc_freq was designed to use only with T20.
> > > This patch remaps it to use additional frequencies, added in
> > > T30+ SoC while maintaining backwards compatibility with T20.
> > > 
> > > - drivers: timer: add timer driver for ARMv7 based Tegra devices
> > > Add timer support for T20/T30/T114/T124 and T210 based devices.
> > > Driver is based on DM, has device tree support and can be
> > > used on SPL and early boot stage.
> > > 
> > > Arm64 Tegra (apart T210) according to comment in tegra-common.h use
> > > architected timer.
> > > 
> > > - ARM: tegra: include timer as default option
> > > Enable TIMER as default option for all Tegra devices and
> > > enable TEGRA_TIMER for TEGRA_ARMV7_COMMON and TEGRA210.
> > > Additionally enable SPL_TIMER if build as SPL part and
> > > drop deprecated configs from common header.
> > > 
> > > P. S. I have no arm64 Tegra and according to comment in
> > > tegra-common.h
> > > Use the Tegra US timer on ARMv7, but the architected timer on ARMv8.
> > > 
> > > ---
> > > Changeog from V6
> > >   - use clk_m as timer calibration clock (this should properly fix T210)
> > >   - enable timer for T210
> > > 
> > > Changed from v5:
> > >   - added paz00 tester
> > > 
> > > Changed from v4:
> > >   - added comments
> > > 
> > > Changed from v3:
> > >   - removed BOOTSTAGE ifdefs
> > >   - use early timer on boot stage unconditionally
> > > ---
> > > Svyatoslav Ryhel (3):
> > >    ARM: tegra: remap clock_osc_freq for all Tegra family
> > >    drivers: timer: add driver for ARMv7 based Tegra devices and T210
> > >    ARM: tegra: include timer as default option
> > > 
> > >   arch/arm/Kconfig                        |   1 +
> > >   arch/arm/include/asm/arch-tegra/clock.h |   9 +-
> > >   arch/arm/mach-tegra/Kconfig             |   3 +
> > >   arch/arm/mach-tegra/clock.c             |  17 +++-
> > >   arch/arm/mach-tegra/cpu.c               |  70 ++++++++++---
> > >   arch/arm/mach-tegra/tegra114/clock.c    |  13 +--
> > >   arch/arm/mach-tegra/tegra124/clock.c    |  13 +--
> > >   arch/arm/mach-tegra/tegra20/clock.c     |   4 +-
> > >   arch/arm/mach-tegra/tegra210/clock.c    |  22 +---
> > >   arch/arm/mach-tegra/tegra30/clock.c     |  10 +-
> > >   drivers/timer/Kconfig                   |   8 ++
> > >   drivers/timer/Makefile                  |   1 +
> > >   drivers/timer/tegra-timer.c             | 130 ++++++++++++++++++++++++
> > >   drivers/usb/host/ehci-tegra.c           |  46 +++++++--
> > >   include/configs/tegra-common.h          |   6 --
> > >   15 files changed, 274 insertions(+), 79 deletions(-)
> > >   create mode 100644 drivers/timer/tegra-timer.c
> > Ugh... turns out I had completely messed up the testing on Tegra186 and
> > it wasn't working at all. The problem is that the selection of the TIMER
> > symbol for all of Tegra causes the driver model to be used, but there is
> > no DM driver for the architected timer that's used on Tegra186.
> > 
> > The quickest fix would be to do this:
> > 
> > --- >8 ---
> > diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
> > index b50eec5b8c9b..05c8ce0e08dd 100644
> > --- a/arch/arm/mach-tegra/Kconfig
> > +++ b/arch/arm/mach-tegra/Kconfig
> > @@ -56,7 +56,6 @@ config TEGRA_COMMON
> >   	select MISC
> >   	select OF_CONTROL
> >   	select SPI
> > -	select TIMER
> >   	imply CMD_DM
> >   	imply CRC32_VERIFY
> > @@ -83,6 +82,7 @@ config TEGRA_ARMV7_COMMON
> >   	select TEGRA_PINCTRL
> >   	select TEGRA_PMC
> >   	select TEGRA_TIMER
> > +	select TIMER
> >   config TEGRA_ARMV8_COMMON
> >   	bool "Tegra 64-bit common options"
> > @@ -137,6 +137,7 @@ config TEGRA210
> >   	select TEGRA_PMC
> >   	select TEGRA_PMC_SECURE
> >   	select TEGRA_TIMER
> > +	select TIMER
> >   config TEGRA186
> >   	bool "Tegra186 family"
> > --- >8 ---
> > 
> > So basically make TIMER selected on everything except Tegra186, so that
> > on Tegra186 things are basically unmodified.
> 
> I can propose to include 'select TIMER' directly into TEGRA_TIMER config
> option. This will eliminate need of including it into mach-tegra Kconfigs.

TEGRA_TIMER itself depends on TIMER, which is a more correct dependency
given how that's all structured.

> BTW, may you check current patch set on T124 and T210 if those work
> properly. My T30 devices work fine and same as before after switch to clk_m
> as timer calibration clock.

With the above on top, the series works fine on Tegra124, Tegra210 and
Tegra186.

Thierry
Svyatoslav Ryhel Jan. 31, 2023, 3:24 p.m. UTC | #4
Thanks. In this case we should stick with clk_m use and add TIMER
config into non-T186 places of mach-tegra Kconfig. That should be it.

вт, 31 січ. 2023 р. о 17:17 Thierry Reding <thierry.reding@gmail.com> пише:
>
> On Fri, Jan 27, 2023 at 10:27:57PM +0200, Svyatoslav R. wrote:
> > On 1/27/23 19:15, Thierry Reding wrote:
> > > On Fri, Jan 27, 2023 at 09:13:09AM +0200, Svyatoslav Ryhel wrote:
> > > > - ARM: tegra: remap clock_osc_freq for all Tegra family
> > > > Enum clock_osc_freq was designed to use only with T20.
> > > > This patch remaps it to use additional frequencies, added in
> > > > T30+ SoC while maintaining backwards compatibility with T20.
> > > >
> > > > - drivers: timer: add timer driver for ARMv7 based Tegra devices
> > > > Add timer support for T20/T30/T114/T124 and T210 based devices.
> > > > Driver is based on DM, has device tree support and can be
> > > > used on SPL and early boot stage.
> > > >
> > > > Arm64 Tegra (apart T210) according to comment in tegra-common.h use
> > > > architected timer.
> > > >
> > > > - ARM: tegra: include timer as default option
> > > > Enable TIMER as default option for all Tegra devices and
> > > > enable TEGRA_TIMER for TEGRA_ARMV7_COMMON and TEGRA210.
> > > > Additionally enable SPL_TIMER if build as SPL part and
> > > > drop deprecated configs from common header.
> > > >
> > > > P. S. I have no arm64 Tegra and according to comment in
> > > > tegra-common.h
> > > > Use the Tegra US timer on ARMv7, but the architected timer on ARMv8.
> > > >
> > > > ---
> > > > Changeog from V6
> > > >   - use clk_m as timer calibration clock (this should properly fix T210)
> > > >   - enable timer for T210
> > > >
> > > > Changed from v5:
> > > >   - added paz00 tester
> > > >
> > > > Changed from v4:
> > > >   - added comments
> > > >
> > > > Changed from v3:
> > > >   - removed BOOTSTAGE ifdefs
> > > >   - use early timer on boot stage unconditionally
> > > > ---
> > > > Svyatoslav Ryhel (3):
> > > >    ARM: tegra: remap clock_osc_freq for all Tegra family
> > > >    drivers: timer: add driver for ARMv7 based Tegra devices and T210
> > > >    ARM: tegra: include timer as default option
> > > >
> > > >   arch/arm/Kconfig                        |   1 +
> > > >   arch/arm/include/asm/arch-tegra/clock.h |   9 +-
> > > >   arch/arm/mach-tegra/Kconfig             |   3 +
> > > >   arch/arm/mach-tegra/clock.c             |  17 +++-
> > > >   arch/arm/mach-tegra/cpu.c               |  70 ++++++++++---
> > > >   arch/arm/mach-tegra/tegra114/clock.c    |  13 +--
> > > >   arch/arm/mach-tegra/tegra124/clock.c    |  13 +--
> > > >   arch/arm/mach-tegra/tegra20/clock.c     |   4 +-
> > > >   arch/arm/mach-tegra/tegra210/clock.c    |  22 +---
> > > >   arch/arm/mach-tegra/tegra30/clock.c     |  10 +-
> > > >   drivers/timer/Kconfig                   |   8 ++
> > > >   drivers/timer/Makefile                  |   1 +
> > > >   drivers/timer/tegra-timer.c             | 130 ++++++++++++++++++++++++
> > > >   drivers/usb/host/ehci-tegra.c           |  46 +++++++--
> > > >   include/configs/tegra-common.h          |   6 --
> > > >   15 files changed, 274 insertions(+), 79 deletions(-)
> > > >   create mode 100644 drivers/timer/tegra-timer.c
> > > Ugh... turns out I had completely messed up the testing on Tegra186 and
> > > it wasn't working at all. The problem is that the selection of the TIMER
> > > symbol for all of Tegra causes the driver model to be used, but there is
> > > no DM driver for the architected timer that's used on Tegra186.
> > >
> > > The quickest fix would be to do this:
> > >
> > > --- >8 ---
> > > diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
> > > index b50eec5b8c9b..05c8ce0e08dd 100644
> > > --- a/arch/arm/mach-tegra/Kconfig
> > > +++ b/arch/arm/mach-tegra/Kconfig
> > > @@ -56,7 +56,6 @@ config TEGRA_COMMON
> > >     select MISC
> > >     select OF_CONTROL
> > >     select SPI
> > > -   select TIMER
> > >     imply CMD_DM
> > >     imply CRC32_VERIFY
> > > @@ -83,6 +82,7 @@ config TEGRA_ARMV7_COMMON
> > >     select TEGRA_PINCTRL
> > >     select TEGRA_PMC
> > >     select TEGRA_TIMER
> > > +   select TIMER
> > >   config TEGRA_ARMV8_COMMON
> > >     bool "Tegra 64-bit common options"
> > > @@ -137,6 +137,7 @@ config TEGRA210
> > >     select TEGRA_PMC
> > >     select TEGRA_PMC_SECURE
> > >     select TEGRA_TIMER
> > > +   select TIMER
> > >   config TEGRA186
> > >     bool "Tegra186 family"
> > > --- >8 ---
> > >
> > > So basically make TIMER selected on everything except Tegra186, so that
> > > on Tegra186 things are basically unmodified.
> >
> > I can propose to include 'select TIMER' directly into TEGRA_TIMER config
> > option. This will eliminate need of including it into mach-tegra Kconfigs.
>
> TEGRA_TIMER itself depends on TIMER, which is a more correct dependency
> given how that's all structured.
>
> > BTW, may you check current patch set on T124 and T210 if those work
> > properly. My T30 devices work fine and same as before after switch to clk_m
> > as timer calibration clock.
>
> With the above on top, the series works fine on Tegra124, Tegra210 and
> Tegra186.
>
> Thierry
Svyatoslav Ryhel Jan. 31, 2023, 3:26 p.m. UTC | #5
Yes, it works perfectly fine on the T20/T30/T124/T186 and T210, T114
board no one has on hand. Timer enabling has to be adjusted as Thierry
suggested.

вт, 31 січ. 2023 р. о 17:18 Tom Warren <TWarren@nvidia.com> пише:
>
> Has this been tested yet? I want to get it into the next PR, and I need a tested-by for V7 before I can do that.
>
> Thanks,
>
> Tom
>
> -----Original Message-----
> From: Svyatoslav R. <clamor95@gmail.com>
> Sent: Friday, January 27, 2023 1:28 PM
> To: Thierry Reding <thierry.reding@gmail.com>
> Cc: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>; Tom Warren <twarren@nvidia.com>; Marek Vasut <marex@denx.de>; Maxim Schwalm <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Jonas Schwöbel <jonasschwoebel@yahoo.de>; Agneli <poczt@protonmail.ch>; Heinrich Schuchardt <xypron.glpk@gmx.de>; Michal Simek <michal.simek@amd.com>; Stefan Roese <sr@denx.de>; Eugen Hristev <eugen.hristev@microchip.com>; Michael Walle <michael@walle.cc>; Simon Glass <sjg@chromium.org>; Jim Liu <jim.t90615@gmail.com>; William Zhang <william.zhang@broadcom.com>; Rick Chen <rick@andestech.com>; Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>; Andre Przywara <andre.przywara@arm.com>; Jaehoon Chung <jh80.chung@samsung.com>; u-boot@lists.denx.de
> Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra
>
> External email: Use caution opening links or attachments
>
>
> On 1/27/23 19:15, Thierry Reding wrote:
> > On Fri, Jan 27, 2023 at 09:13:09AM +0200, Svyatoslav Ryhel wrote:
> >> - ARM: tegra: remap clock_osc_freq for all Tegra family Enum
> >> clock_osc_freq was designed to use only with T20.
> >> This patch remaps it to use additional frequencies, added in
> >> T30+ SoC while maintaining backwards compatibility with T20.
> >>
> >> - drivers: timer: add timer driver for ARMv7 based Tegra devices Add
> >> timer support for T20/T30/T114/T124 and T210 based devices.
> >> Driver is based on DM, has device tree support and can be used on SPL
> >> and early boot stage.
> >>
> >> Arm64 Tegra (apart T210) according to comment in tegra-common.h use
> >> architected timer.
> >>
> >> - ARM: tegra: include timer as default option Enable TIMER as default
> >> option for all Tegra devices and enable TEGRA_TIMER for
> >> TEGRA_ARMV7_COMMON and TEGRA210.
> >> Additionally enable SPL_TIMER if build as SPL part and drop
> >> deprecated configs from common header.
> >>
> >> P. S. I have no arm64 Tegra and according to comment in
> >> tegra-common.h Use the Tegra US timer on ARMv7, but the architected
> >> timer on ARMv8.
> >>
> >> ---
> >> Changeog from V6
> >>   - use clk_m as timer calibration clock (this should properly fix T210)
> >>   - enable timer for T210
> >>
> >> Changed from v5:
> >>   - added paz00 tester
> >>
> >> Changed from v4:
> >>   - added comments
> >>
> >> Changed from v3:
> >>   - removed BOOTSTAGE ifdefs
> >>   - use early timer on boot stage unconditionally
> >> ---
> >> Svyatoslav Ryhel (3):
> >>    ARM: tegra: remap clock_osc_freq for all Tegra family
> >>    drivers: timer: add driver for ARMv7 based Tegra devices and T210
> >>    ARM: tegra: include timer as default option
> >>
> >>   arch/arm/Kconfig                        |   1 +
> >>   arch/arm/include/asm/arch-tegra/clock.h |   9 +-
> >>   arch/arm/mach-tegra/Kconfig             |   3 +
> >>   arch/arm/mach-tegra/clock.c             |  17 +++-
> >>   arch/arm/mach-tegra/cpu.c               |  70 ++++++++++---
> >>   arch/arm/mach-tegra/tegra114/clock.c    |  13 +--
> >>   arch/arm/mach-tegra/tegra124/clock.c    |  13 +--
> >>   arch/arm/mach-tegra/tegra20/clock.c     |   4 +-
> >>   arch/arm/mach-tegra/tegra210/clock.c    |  22 +---
> >>   arch/arm/mach-tegra/tegra30/clock.c     |  10 +-
> >>   drivers/timer/Kconfig                   |   8 ++
> >>   drivers/timer/Makefile                  |   1 +
> >>   drivers/timer/tegra-timer.c             | 130 ++++++++++++++++++++++++
> >>   drivers/usb/host/ehci-tegra.c           |  46 +++++++--
> >>   include/configs/tegra-common.h          |   6 --
> >>   15 files changed, 274 insertions(+), 79 deletions(-)
> >>   create mode 100644 drivers/timer/tegra-timer.c
> > Ugh... turns out I had completely messed up the testing on Tegra186
> > and it wasn't working at all. The problem is that the selection of the
> > TIMER symbol for all of Tegra causes the driver model to be used, but
> > there is no DM driver for the architected timer that's used on Tegra186.
> >
> > The quickest fix would be to do this:
> >
> > --- >8 ---
> > diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
> > index b50eec5b8c9b..05c8ce0e08dd 100644
> > --- a/arch/arm/mach-tegra/Kconfig
> > +++ b/arch/arm/mach-tegra/Kconfig
> > @@ -56,7 +56,6 @@ config TEGRA_COMMON
> >       select MISC
> >       select OF_CONTROL
> >       select SPI
> > -     select TIMER
> >       imply CMD_DM
> >       imply CRC32_VERIFY
> >
> > @@ -83,6 +82,7 @@ config TEGRA_ARMV7_COMMON
> >       select TEGRA_PINCTRL
> >       select TEGRA_PMC
> >       select TEGRA_TIMER
> > +     select TIMER
> >
> >   config TEGRA_ARMV8_COMMON
> >       bool "Tegra 64-bit common options"
> > @@ -137,6 +137,7 @@ config TEGRA210
> >       select TEGRA_PMC
> >       select TEGRA_PMC_SECURE
> >       select TEGRA_TIMER
> > +     select TIMER
> >
> >   config TEGRA186
> >       bool "Tegra186 family"
> > --- >8 ---
> >
> > So basically make TIMER selected on everything except Tegra186, so
> > that on Tegra186 things are basically unmodified.
>
> I can propose to include 'select TIMER' directly into TEGRA_TIMER config option. This will eliminate need of including it into mach-tegra Kconfigs.
>
> BTW, may you check current patch set on T124 and T210 if those work properly. My T30 devices work fine and same as before after switch to clk_m as timer calibration clock.
>
> Best Regards, Svyatoslav R.
>
> > Thierry
Svyatoslav Ryhel Jan. 31, 2023, 9:53 p.m. UTC | #6
I will upload v8 tomorrow once I have some time.

Yes, Timer series should go first since some clock related commits of
"General Tegra improvements" may conflict. Those are not direct
dependencies but rather changed code overlaps.

Thanks

Best Regards.
Svyatoslav R.

вт, 31 січ. 2023 р. о 22:27 Tom Warren <TWarren@nvidia.com> пише:
>
> OK, I'll wait for your v8 with the adjusted timer enabling.
>
> Does this series need to go in first before your recent 16-patch series "General Tegra improvements"? i.e. are there any dependencies?
>
> Tom
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Tuesday, January 31, 2023 8:26 AM
> To: Tom Warren <TWarren@nvidia.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>; Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>; Marek Vasut <marex@denx.de>; Maxim Schwalm <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Jonas Schwöbel <jonasschwoebel@yahoo.de>; Agneli <poczt@protonmail.ch>; Heinrich Schuchardt <xypron.glpk@gmx.de>; Michal Simek <michal.simek@amd.com>; Stefan Roese <sr@denx.de>; Eugen Hristev <eugen.hristev@microchip.com>; Michael Walle <michael@walle.cc>; Simon Glass <sjg@chromium.org>; Jim Liu <jim.t90615@gmail.com>; William Zhang <william.zhang@broadcom.com>; Rick Chen <rick@andestech.com>; Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>; Andre Przywara <andre.przywara@arm.com>; Jaehoon Chung <jh80.chung@samsung.com>; u-boot@lists.denx.de
> Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra
>
> External email: Use caution opening links or attachments
>
>
> Yes, it works perfectly fine on the T20/T30/T124/T186 and T210, T114 board no one has on hand. Timer enabling has to be adjusted as Thierry suggested.
>
> вт, 31 січ. 2023 р. о 17:18 Tom Warren <TWarren@nvidia.com> пише:
> >
> > Has this been tested yet? I want to get it into the next PR, and I need a tested-by for V7 before I can do that.
> >
> > Thanks,
> >
> > Tom
> >
> > -----Original Message-----
> > From: Svyatoslav R. <clamor95@gmail.com>
> > Sent: Friday, January 27, 2023 1:28 PM
> > To: Thierry Reding <thierry.reding@gmail.com>
> > Cc: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>; Tom Warren
> > <twarren@nvidia.com>; Marek Vasut <marex@denx.de>; Maxim Schwalm
> > <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Jonas
> > Schwöbel <jonasschwoebel@yahoo.de>; Agneli <poczt@protonmail.ch>;
> > Heinrich Schuchardt <xypron.glpk@gmx.de>; Michal Simek
> > <michal.simek@amd.com>; Stefan Roese <sr@denx.de>; Eugen Hristev
> > <eugen.hristev@microchip.com>; Michael Walle <michael@walle.cc>; Simon
> > Glass <sjg@chromium.org>; Jim Liu <jim.t90615@gmail.com>; William
> > Zhang <william.zhang@broadcom.com>; Rick Chen <rick@andestech.com>;
> > Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>; Andre
> > Przywara <andre.przywara@arm.com>; Jaehoon Chung
> > <jh80.chung@samsung.com>; u-boot@lists.denx.de
> > Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra
> >
> > External email: Use caution opening links or attachments
> >
> >
> > On 1/27/23 19:15, Thierry Reding wrote:
> > > On Fri, Jan 27, 2023 at 09:13:09AM +0200, Svyatoslav Ryhel wrote:
> > >> - ARM: tegra: remap clock_osc_freq for all Tegra family Enum
> > >> clock_osc_freq was designed to use only with T20.
> > >> This patch remaps it to use additional frequencies, added in
> > >> T30+ SoC while maintaining backwards compatibility with T20.
> > >>
> > >> - drivers: timer: add timer driver for ARMv7 based Tegra devices
> > >> Add timer support for T20/T30/T114/T124 and T210 based devices.
> > >> Driver is based on DM, has device tree support and can be used on
> > >> SPL and early boot stage.
> > >>
> > >> Arm64 Tegra (apart T210) according to comment in tegra-common.h use
> > >> architected timer.
> > >>
> > >> - ARM: tegra: include timer as default option Enable TIMER as
> > >> default option for all Tegra devices and enable TEGRA_TIMER for
> > >> TEGRA_ARMV7_COMMON and TEGRA210.
> > >> Additionally enable SPL_TIMER if build as SPL part and drop
> > >> deprecated configs from common header.
> > >>
> > >> P. S. I have no arm64 Tegra and according to comment in
> > >> tegra-common.h Use the Tegra US timer on ARMv7, but the architected
> > >> timer on ARMv8.
> > >>
> > >> ---
> > >> Changeog from V6
> > >>   - use clk_m as timer calibration clock (this should properly fix T210)
> > >>   - enable timer for T210
> > >>
> > >> Changed from v5:
> > >>   - added paz00 tester
> > >>
> > >> Changed from v4:
> > >>   - added comments
> > >>
> > >> Changed from v3:
> > >>   - removed BOOTSTAGE ifdefs
> > >>   - use early timer on boot stage unconditionally
> > >> ---
> > >> Svyatoslav Ryhel (3):
> > >>    ARM: tegra: remap clock_osc_freq for all Tegra family
> > >>    drivers: timer: add driver for ARMv7 based Tegra devices and T210
> > >>    ARM: tegra: include timer as default option
> > >>
> > >>   arch/arm/Kconfig                        |   1 +
> > >>   arch/arm/include/asm/arch-tegra/clock.h |   9 +-
> > >>   arch/arm/mach-tegra/Kconfig             |   3 +
> > >>   arch/arm/mach-tegra/clock.c             |  17 +++-
> > >>   arch/arm/mach-tegra/cpu.c               |  70 ++++++++++---
> > >>   arch/arm/mach-tegra/tegra114/clock.c    |  13 +--
> > >>   arch/arm/mach-tegra/tegra124/clock.c    |  13 +--
> > >>   arch/arm/mach-tegra/tegra20/clock.c     |   4 +-
> > >>   arch/arm/mach-tegra/tegra210/clock.c    |  22 +---
> > >>   arch/arm/mach-tegra/tegra30/clock.c     |  10 +-
> > >>   drivers/timer/Kconfig                   |   8 ++
> > >>   drivers/timer/Makefile                  |   1 +
> > >>   drivers/timer/tegra-timer.c             | 130 ++++++++++++++++++++++++
> > >>   drivers/usb/host/ehci-tegra.c           |  46 +++++++--
> > >>   include/configs/tegra-common.h          |   6 --
> > >>   15 files changed, 274 insertions(+), 79 deletions(-)
> > >>   create mode 100644 drivers/timer/tegra-timer.c
> > > Ugh... turns out I had completely messed up the testing on Tegra186
> > > and it wasn't working at all. The problem is that the selection of
> > > the TIMER symbol for all of Tegra causes the driver model to be
> > > used, but there is no DM driver for the architected timer that's used on Tegra186.
> > >
> > > The quickest fix would be to do this:
> > >
> > > --- >8 ---
> > > diff --git a/arch/arm/mach-tegra/Kconfig
> > > b/arch/arm/mach-tegra/Kconfig index b50eec5b8c9b..05c8ce0e08dd
> > > 100644
> > > --- a/arch/arm/mach-tegra/Kconfig
> > > +++ b/arch/arm/mach-tegra/Kconfig
> > > @@ -56,7 +56,6 @@ config TEGRA_COMMON
> > >       select MISC
> > >       select OF_CONTROL
> > >       select SPI
> > > -     select TIMER
> > >       imply CMD_DM
> > >       imply CRC32_VERIFY
> > >
> > > @@ -83,6 +82,7 @@ config TEGRA_ARMV7_COMMON
> > >       select TEGRA_PINCTRL
> > >       select TEGRA_PMC
> > >       select TEGRA_TIMER
> > > +     select TIMER
> > >
> > >   config TEGRA_ARMV8_COMMON
> > >       bool "Tegra 64-bit common options"
> > > @@ -137,6 +137,7 @@ config TEGRA210
> > >       select TEGRA_PMC
> > >       select TEGRA_PMC_SECURE
> > >       select TEGRA_TIMER
> > > +     select TIMER
> > >
> > >   config TEGRA186
> > >       bool "Tegra186 family"
> > > --- >8 ---
> > >
> > > So basically make TIMER selected on everything except Tegra186, so
> > > that on Tegra186 things are basically unmodified.
> >
> > I can propose to include 'select TIMER' directly into TEGRA_TIMER config option. This will eliminate need of including it into mach-tegra Kconfigs.
> >
> > BTW, may you check current patch set on T124 and T210 if those work properly. My T30 devices work fine and same as before after switch to clk_m as timer calibration clock.
> >
> > Best Regards, Svyatoslav R.
> >
> > > Thierry
Svyatoslav Ryhel Feb. 1, 2023, 8:58 a.m. UTC | #7
Greetings! This should be it. May you add
Tested-by: Thierry Reding <treding@nvidia.com> # T30, T124, T210
into
drivers: timer: add driver for ARMv7 based Tegra devices and T210
once applying patches? Thanks

вт, 31 січ. 2023 р. о 22:27 Tom Warren <TWarren@nvidia.com> пише:
>
> OK, I'll wait for your v8 with the adjusted timer enabling.
>
> Does this series need to go in first before your recent 16-patch series "General Tegra improvements"? i.e. are there any dependencies?
>
> Tom
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Tuesday, January 31, 2023 8:26 AM
> To: Tom Warren <TWarren@nvidia.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>; Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>; Marek Vasut <marex@denx.de>; Maxim Schwalm <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Jonas Schwöbel <jonasschwoebel@yahoo.de>; Agneli <poczt@protonmail.ch>; Heinrich Schuchardt <xypron.glpk@gmx.de>; Michal Simek <michal.simek@amd.com>; Stefan Roese <sr@denx.de>; Eugen Hristev <eugen.hristev@microchip.com>; Michael Walle <michael@walle.cc>; Simon Glass <sjg@chromium.org>; Jim Liu <jim.t90615@gmail.com>; William Zhang <william.zhang@broadcom.com>; Rick Chen <rick@andestech.com>; Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>; Andre Przywara <andre.przywara@arm.com>; Jaehoon Chung <jh80.chung@samsung.com>; u-boot@lists.denx.de
> Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra
>
> External email: Use caution opening links or attachments
>
>
> Yes, it works perfectly fine on the T20/T30/T124/T186 and T210, T114 board no one has on hand. Timer enabling has to be adjusted as Thierry suggested.
>
> вт, 31 січ. 2023 р. о 17:18 Tom Warren <TWarren@nvidia.com> пише:
> >
> > Has this been tested yet? I want to get it into the next PR, and I need a tested-by for V7 before I can do that.
> >
> > Thanks,
> >
> > Tom
> >
> > -----Original Message-----
> > From: Svyatoslav R. <clamor95@gmail.com>
> > Sent: Friday, January 27, 2023 1:28 PM
> > To: Thierry Reding <thierry.reding@gmail.com>
> > Cc: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>; Tom Warren
> > <twarren@nvidia.com>; Marek Vasut <marex@denx.de>; Maxim Schwalm
> > <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Jonas
> > Schwöbel <jonasschwoebel@yahoo.de>; Agneli <poczt@protonmail.ch>;
> > Heinrich Schuchardt <xypron.glpk@gmx.de>; Michal Simek
> > <michal.simek@amd.com>; Stefan Roese <sr@denx.de>; Eugen Hristev
> > <eugen.hristev@microchip.com>; Michael Walle <michael@walle.cc>; Simon
> > Glass <sjg@chromium.org>; Jim Liu <jim.t90615@gmail.com>; William
> > Zhang <william.zhang@broadcom.com>; Rick Chen <rick@andestech.com>;
> > Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>; Andre
> > Przywara <andre.przywara@arm.com>; Jaehoon Chung
> > <jh80.chung@samsung.com>; u-boot@lists.denx.de
> > Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra
> >
> > External email: Use caution opening links or attachments
> >
> >
> > On 1/27/23 19:15, Thierry Reding wrote:
> > > On Fri, Jan 27, 2023 at 09:13:09AM +0200, Svyatoslav Ryhel wrote:
> > >> - ARM: tegra: remap clock_osc_freq for all Tegra family Enum
> > >> clock_osc_freq was designed to use only with T20.
> > >> This patch remaps it to use additional frequencies, added in
> > >> T30+ SoC while maintaining backwards compatibility with T20.
> > >>
> > >> - drivers: timer: add timer driver for ARMv7 based Tegra devices
> > >> Add timer support for T20/T30/T114/T124 and T210 based devices.
> > >> Driver is based on DM, has device tree support and can be used on
> > >> SPL and early boot stage.
> > >>
> > >> Arm64 Tegra (apart T210) according to comment in tegra-common.h use
> > >> architected timer.
> > >>
> > >> - ARM: tegra: include timer as default option Enable TIMER as
> > >> default option for all Tegra devices and enable TEGRA_TIMER for
> > >> TEGRA_ARMV7_COMMON and TEGRA210.
> > >> Additionally enable SPL_TIMER if build as SPL part and drop
> > >> deprecated configs from common header.
> > >>
> > >> P. S. I have no arm64 Tegra and according to comment in
> > >> tegra-common.h Use the Tegra US timer on ARMv7, but the architected
> > >> timer on ARMv8.
> > >>
> > >> ---
> > >> Changeog from V6
> > >>   - use clk_m as timer calibration clock (this should properly fix T210)
> > >>   - enable timer for T210
> > >>
> > >> Changed from v5:
> > >>   - added paz00 tester
> > >>
> > >> Changed from v4:
> > >>   - added comments
> > >>
> > >> Changed from v3:
> > >>   - removed BOOTSTAGE ifdefs
> > >>   - use early timer on boot stage unconditionally
> > >> ---
> > >> Svyatoslav Ryhel (3):
> > >>    ARM: tegra: remap clock_osc_freq for all Tegra family
> > >>    drivers: timer: add driver for ARMv7 based Tegra devices and T210
> > >>    ARM: tegra: include timer as default option
> > >>
> > >>   arch/arm/Kconfig                        |   1 +
> > >>   arch/arm/include/asm/arch-tegra/clock.h |   9 +-
> > >>   arch/arm/mach-tegra/Kconfig             |   3 +
> > >>   arch/arm/mach-tegra/clock.c             |  17 +++-
> > >>   arch/arm/mach-tegra/cpu.c               |  70 ++++++++++---
> > >>   arch/arm/mach-tegra/tegra114/clock.c    |  13 +--
> > >>   arch/arm/mach-tegra/tegra124/clock.c    |  13 +--
> > >>   arch/arm/mach-tegra/tegra20/clock.c     |   4 +-
> > >>   arch/arm/mach-tegra/tegra210/clock.c    |  22 +---
> > >>   arch/arm/mach-tegra/tegra30/clock.c     |  10 +-
> > >>   drivers/timer/Kconfig                   |   8 ++
> > >>   drivers/timer/Makefile                  |   1 +
> > >>   drivers/timer/tegra-timer.c             | 130 ++++++++++++++++++++++++
> > >>   drivers/usb/host/ehci-tegra.c           |  46 +++++++--
> > >>   include/configs/tegra-common.h          |   6 --
> > >>   15 files changed, 274 insertions(+), 79 deletions(-)
> > >>   create mode 100644 drivers/timer/tegra-timer.c
> > > Ugh... turns out I had completely messed up the testing on Tegra186
> > > and it wasn't working at all. The problem is that the selection of
> > > the TIMER symbol for all of Tegra causes the driver model to be
> > > used, but there is no DM driver for the architected timer that's used on Tegra186.
> > >
> > > The quickest fix would be to do this:
> > >
> > > --- >8 ---
> > > diff --git a/arch/arm/mach-tegra/Kconfig
> > > b/arch/arm/mach-tegra/Kconfig index b50eec5b8c9b..05c8ce0e08dd
> > > 100644
> > > --- a/arch/arm/mach-tegra/Kconfig
> > > +++ b/arch/arm/mach-tegra/Kconfig
> > > @@ -56,7 +56,6 @@ config TEGRA_COMMON
> > >       select MISC
> > >       select OF_CONTROL
> > >       select SPI
> > > -     select TIMER
> > >       imply CMD_DM
> > >       imply CRC32_VERIFY
> > >
> > > @@ -83,6 +82,7 @@ config TEGRA_ARMV7_COMMON
> > >       select TEGRA_PINCTRL
> > >       select TEGRA_PMC
> > >       select TEGRA_TIMER
> > > +     select TIMER
> > >
> > >   config TEGRA_ARMV8_COMMON
> > >       bool "Tegra 64-bit common options"
> > > @@ -137,6 +137,7 @@ config TEGRA210
> > >       select TEGRA_PMC
> > >       select TEGRA_PMC_SECURE
> > >       select TEGRA_TIMER
> > > +     select TIMER
> > >
> > >   config TEGRA186
> > >       bool "Tegra186 family"
> > > --- >8 ---
> > >
> > > So basically make TIMER selected on everything except Tegra186, so
> > > that on Tegra186 things are basically unmodified.
> >
> > I can propose to include 'select TIMER' directly into TEGRA_TIMER config option. This will eliminate need of including it into mach-tegra Kconfigs.
> >
> > BTW, may you check current patch set on T124 and T210 if those work properly. My T30 devices work fine and same as before after switch to clk_m as timer calibration clock.
> >
> > Best Regards, Svyatoslav R.
> >
> > > Thierry
Svyatoslav Ryhel Feb. 2, 2023, 6:02 p.m. UTC | #8
Hm, you are correct. Patchset I have sent was based on u-boot/master
without timer patches. Now, since those are merged, I need to adjust
them a bit. It is not a big issue since I have some more optimisations
to be added anyway. I will send an updated version within an hour if
nothing interferes.

Thanks.
Best Regards.
Svyatoslav R.

чт, 2 лют. 2023 р. о 19:54 Tom Warren <TWarren@nvidia.com> пише:
>
> I've merged your 3 timer patches w/TOT u-boot-tegra, and sent a PR to Tom Rini.
>
> However, your v1 16-patch series here does no apply cleanly on top of the new u-boot-tegra/master (fast-forwarded to u-boot/master TOT, and then with your 3 timer patches applied on top). PTAL, git am error spew below:
>
> git am -s --whitespace=strip /home/tom/Downloads/bundle-23280-Svyatoslav-16-v1.mbox
> Applying: tegra30: clock: add EXTPERIPH
> Applying: ARM: t20/t30: swap host1x and disp1 clock parents
> Applying: ARM: tegra: clock: add clk_id_to_pll_id helper
> Applying: ARM: tegra: clock: add clock_decode_pair helper
> Applying: ARM: tegra30: add PLLD to pll setup
> error: patch failed: arch/arm/mach-tegra/clock.c:791
> error: arch/arm/mach-tegra/clock.c: patch does not apply
> Patch failed at 0005 ARM: tegra30: add PLLD to pll setup
> The copy of the patch that failed is found in:
>    /home/tom/denx/uboot-tegra/.git/rebase-apply/patch
> When you have resolved this problem, run "git am --resolved".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
>
> Tom
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Tuesday, January 31, 2023 2:53 PM
> To: Tom Warren <TWarren@nvidia.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>; Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>; Marek Vasut <marex@denx.de>; Maxim Schwalm <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Jonas Schwöbel <jonasschwoebel@yahoo.de>; Agneli <poczt@protonmail.ch>; Heinrich Schuchardt <xypron.glpk@gmx.de>; Michal Simek <michal.simek@amd.com>; Stefan Roese <sr@denx.de>; Eugen Hristev <eugen.hristev@microchip.com>; Michael Walle <michael@walle.cc>; Simon Glass <sjg@chromium.org>; Jim Liu <jim.t90615@gmail.com>; William Zhang <william.zhang@broadcom.com>; Rick Chen <rick@andestech.com>; Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>; Andre Przywara <andre.przywara@arm.com>; Jaehoon Chung <jh80.chung@samsung.com>; u-boot@lists.denx.de
> Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra
>
> External email: Use caution opening links or attachments
>
>
> I will upload v8 tomorrow once I have some time.
>
> Yes, Timer series should go first since some clock related commits of "General Tegra improvements" may conflict. Those are not direct dependencies but rather changed code overlaps.
>
> Thanks
>
> Best Regards.
> Svyatoslav R.
>
> вт, 31 січ. 2023 р. о 22:27 Tom Warren <TWarren@nvidia.com> пише:
> >
> > OK, I'll wait for your v8 with the adjusted timer enabling.
> >
> > Does this series need to go in first before your recent 16-patch series "General Tegra improvements"? i.e. are there any dependencies?
> >
> > Tom
> > -----Original Message-----
> > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > Sent: Tuesday, January 31, 2023 8:26 AM
> > To: Tom Warren <TWarren@nvidia.com>
> > Cc: Thierry Reding <thierry.reding@gmail.com>; Rayagonda Kokatanur
> > <rayagonda.kokatanur@broadcom.com>; Marek Vasut <marex@denx.de>; Maxim
> > Schwalm <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>;
> > Jonas Schwöbel <jonasschwoebel@yahoo.de>; Agneli
> > <poczt@protonmail.ch>; Heinrich Schuchardt <xypron.glpk@gmx.de>;
> > Michal Simek <michal.simek@amd.com>; Stefan Roese <sr@denx.de>; Eugen
> > Hristev <eugen.hristev@microchip.com>; Michael Walle
> > <michael@walle.cc>; Simon Glass <sjg@chromium.org>; Jim Liu
> > <jim.t90615@gmail.com>; William Zhang <william.zhang@broadcom.com>;
> > Rick Chen <rick@andestech.com>; Stefan Herbrechtsmeier
> > <stefan.herbrechtsmeier@weidmueller.com>; Andre Przywara
> > <andre.przywara@arm.com>; Jaehoon Chung <jh80.chung@samsung.com>;
> > u-boot@lists.denx.de
> > Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra
> >
> > External email: Use caution opening links or attachments
> >
> >
> > Yes, it works perfectly fine on the T20/T30/T124/T186 and T210, T114 board no one has on hand. Timer enabling has to be adjusted as Thierry suggested.
> >
> > вт, 31 січ. 2023 р. о 17:18 Tom Warren <TWarren@nvidia.com> пише:
> > >
> > > Has this been tested yet? I want to get it into the next PR, and I need a tested-by for V7 before I can do that.
> > >
> > > Thanks,
> > >
> > > Tom
> > >
> > > -----Original Message-----
> > > From: Svyatoslav R. <clamor95@gmail.com>
> > > Sent: Friday, January 27, 2023 1:28 PM
> > > To: Thierry Reding <thierry.reding@gmail.com>
> > > Cc: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>; Tom
> > > Warren <twarren@nvidia.com>; Marek Vasut <marex@denx.de>; Maxim
> > > Schwalm <maxim.schwalm@gmail.com>; Dmitry Osipenko
> > > <digetx@gmail.com>; Jonas Schwöbel <jonasschwoebel@yahoo.de>; Agneli
> > > <poczt@protonmail.ch>; Heinrich Schuchardt <xypron.glpk@gmx.de>;
> > > Michal Simek <michal.simek@amd.com>; Stefan Roese <sr@denx.de>;
> > > Eugen Hristev <eugen.hristev@microchip.com>; Michael Walle
> > > <michael@walle.cc>; Simon Glass <sjg@chromium.org>; Jim Liu
> > > <jim.t90615@gmail.com>; William Zhang <william.zhang@broadcom.com>;
> > > Rick Chen <rick@andestech.com>; Stefan Herbrechtsmeier
> > > <stefan.herbrechtsmeier@weidmueller.com>; Andre Przywara
> > > <andre.przywara@arm.com>; Jaehoon Chung <jh80.chung@samsung.com>;
> > > u-boot@lists.denx.de
> > > Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > On 1/27/23 19:15, Thierry Reding wrote:
> > > > On Fri, Jan 27, 2023 at 09:13:09AM +0200, Svyatoslav Ryhel wrote:
> > > >> - ARM: tegra: remap clock_osc_freq for all Tegra family Enum
> > > >> clock_osc_freq was designed to use only with T20.
> > > >> This patch remaps it to use additional frequencies, added in
> > > >> T30+ SoC while maintaining backwards compatibility with T20.
> > > >>
> > > >> - drivers: timer: add timer driver for ARMv7 based Tegra devices
> > > >> Add timer support for T20/T30/T114/T124 and T210 based devices.
> > > >> Driver is based on DM, has device tree support and can be used on
> > > >> SPL and early boot stage.
> > > >>
> > > >> Arm64 Tegra (apart T210) according to comment in tegra-common.h
> > > >> use architected timer.
> > > >>
> > > >> - ARM: tegra: include timer as default option Enable TIMER as
> > > >> default option for all Tegra devices and enable TEGRA_TIMER for
> > > >> TEGRA_ARMV7_COMMON and TEGRA210.
> > > >> Additionally enable SPL_TIMER if build as SPL part and drop
> > > >> deprecated configs from common header.
> > > >>
> > > >> P. S. I have no arm64 Tegra and according to comment in
> > > >> tegra-common.h Use the Tegra US timer on ARMv7, but the
> > > >> architected timer on ARMv8.
> > > >>
> > > >> ---
> > > >> Changeog from V6
> > > >>   - use clk_m as timer calibration clock (this should properly fix T210)
> > > >>   - enable timer for T210
> > > >>
> > > >> Changed from v5:
> > > >>   - added paz00 tester
> > > >>
> > > >> Changed from v4:
> > > >>   - added comments
> > > >>
> > > >> Changed from v3:
> > > >>   - removed BOOTSTAGE ifdefs
> > > >>   - use early timer on boot stage unconditionally
> > > >> ---
> > > >> Svyatoslav Ryhel (3):
> > > >>    ARM: tegra: remap clock_osc_freq for all Tegra family
> > > >>    drivers: timer: add driver for ARMv7 based Tegra devices and T210
> > > >>    ARM: tegra: include timer as default option
> > > >>
> > > >>   arch/arm/Kconfig                        |   1 +
> > > >>   arch/arm/include/asm/arch-tegra/clock.h |   9 +-
> > > >>   arch/arm/mach-tegra/Kconfig             |   3 +
> > > >>   arch/arm/mach-tegra/clock.c             |  17 +++-
> > > >>   arch/arm/mach-tegra/cpu.c               |  70 ++++++++++---
> > > >>   arch/arm/mach-tegra/tegra114/clock.c    |  13 +--
> > > >>   arch/arm/mach-tegra/tegra124/clock.c    |  13 +--
> > > >>   arch/arm/mach-tegra/tegra20/clock.c     |   4 +-
> > > >>   arch/arm/mach-tegra/tegra210/clock.c    |  22 +---
> > > >>   arch/arm/mach-tegra/tegra30/clock.c     |  10 +-
> > > >>   drivers/timer/Kconfig                   |   8 ++
> > > >>   drivers/timer/Makefile                  |   1 +
> > > >>   drivers/timer/tegra-timer.c             | 130 ++++++++++++++++++++++++
> > > >>   drivers/usb/host/ehci-tegra.c           |  46 +++++++--
> > > >>   include/configs/tegra-common.h          |   6 --
> > > >>   15 files changed, 274 insertions(+), 79 deletions(-)
> > > >>   create mode 100644 drivers/timer/tegra-timer.c
> > > > Ugh... turns out I had completely messed up the testing on
> > > > Tegra186 and it wasn't working at all. The problem is that the
> > > > selection of the TIMER symbol for all of Tegra causes the driver
> > > > model to be used, but there is no DM driver for the architected timer that's used on Tegra186.
> > > >
> > > > The quickest fix would be to do this:
> > > >
> > > > --- >8 ---
> > > > diff --git a/arch/arm/mach-tegra/Kconfig
> > > > b/arch/arm/mach-tegra/Kconfig index b50eec5b8c9b..05c8ce0e08dd
> > > > 100644
> > > > --- a/arch/arm/mach-tegra/Kconfig
> > > > +++ b/arch/arm/mach-tegra/Kconfig
> > > > @@ -56,7 +56,6 @@ config TEGRA_COMMON
> > > >       select MISC
> > > >       select OF_CONTROL
> > > >       select SPI
> > > > -     select TIMER
> > > >       imply CMD_DM
> > > >       imply CRC32_VERIFY
> > > >
> > > > @@ -83,6 +82,7 @@ config TEGRA_ARMV7_COMMON
> > > >       select TEGRA_PINCTRL
> > > >       select TEGRA_PMC
> > > >       select TEGRA_TIMER
> > > > +     select TIMER
> > > >
> > > >   config TEGRA_ARMV8_COMMON
> > > >       bool "Tegra 64-bit common options"
> > > > @@ -137,6 +137,7 @@ config TEGRA210
> > > >       select TEGRA_PMC
> > > >       select TEGRA_PMC_SECURE
> > > >       select TEGRA_TIMER
> > > > +     select TIMER
> > > >
> > > >   config TEGRA186
> > > >       bool "Tegra186 family"
> > > > --- >8 ---
> > > >
> > > > So basically make TIMER selected on everything except Tegra186, so
> > > > that on Tegra186 things are basically unmodified.
> > >
> > > I can propose to include 'select TIMER' directly into TEGRA_TIMER config option. This will eliminate need of including it into mach-tegra Kconfigs.
> > >
> > > BTW, may you check current patch set on T124 and T210 if those work properly. My T30 devices work fine and same as before after switch to clk_m as timer calibration clock.
> > >
> > > Best Regards, Svyatoslav R.
> > >
> > > > Thierry