How to use TC instead of PIT

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

pbugalski
Posts: 11
Joined: Thu Nov 29, 2018 4:28 pm

How to use TC instead of PIT

Tue Jun 11, 2019 4:05 pm

Hi,

I have a problem with SAMA5D27. I have to avoid using PIT, but I still need Linux working.
Is it possible to use TC0 or TC1 as a system tick source?

Best Regards,
Piotr Bugalski
blue_z
Location: USA
Posts: 1943
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to use TC instead of PIT

Tue Jun 11, 2019 10:46 pm

(Are you in a contest to use as few words as possible?)
The sama5_defconfig kernel configuration should already satisfy your (XY problem) requirement.
Confirm with commands to list the available clocksources:

Code: Select all

# cat /sys/devices/system/clocksource/clocksource0/available_clocksource 
and the clocksource in actual use:

Code: Select all

# cat /sys/devices/system/clocksource/clocksource0/current_clocksource 
Responses should be "tcb_clksrc pit jiffies" and "tcb_clksrc" respectively.

Regards
pbugalski
Posts: 11
Joined: Thu Nov 29, 2018 4:28 pm

Re: How to use TC instead of PIT

Tue Jun 11, 2019 11:40 pm

Ok, I'm sorry, I was trying to find some solution for a bit long so maybe I didn't explain everything as clear as I should.

Generally I'm trying to run Linux on SAMA5D28 in non-secure world using TrustZone. The problem is that PIT cannot be configured separately - according to datasheet it can be set as secure or non-secure peripheral, but it seems to be not truth and PIT seems to be connected with PMC and friends. So the only solution to keep PMC safe is to configure PIT as secure peripheral also, which means Linux has to run without touching PIT. Sounds easy as there are two other timers: TC0 and TC1, but it doesn't work.

My first and very naive approach was just to comment-out PIT in device-tree, unfortunately without success. It looks like TCx uses tcb driver, which is not working correctly without PIT or I just don't know how should I use it. Hence was my question:

I need to fully disable Linux access from PIT and keep system operational. How should I do it?

Best Regards,
Piotr
pbugalski
Posts: 11
Joined: Thu Nov 29, 2018 4:28 pm

Re: How to use TC instead of PIT

Tue Jun 11, 2019 11:56 pm

I have to apologize again - it was not the problem with PMC, but RTC. And in recent datasheet it's documented. I was testing that quite long time ago and I forgot details.

But generally problem is the same: PIT access has to be disabled.
blue_z
Location: USA
Posts: 1943
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to use TC instead of PIT

Wed Jun 12, 2019 2:56 am

pbugalski wrote: So the only solution to keep PMC safe is to configure PIT as secure peripheral also ...
I know nothing about Secure Boot, so I have no idea if that is a correct or even reasonable conclusion.

pbugalski wrote: Sounds easy as there are two other timers: TC0 and TC1, but it doesn't work.

My first and very naive approach was just to comment-out PIT in device-tree, unfortunately without success. It looks like TCx uses tcb driver, which is not working correctly without PIT
"Doesn't work", "without success", and "not working" are your two-word interpretation/conclusion of what actually happens.
You are not describing the events that actually occur.
Your summations are not useful.


pbugalski wrote: I need to fully disable Linux access from PIT and keep system operational. How should I do it?
You could try to replace the AT91 PIT hardware & driver with the generic "arm,armv7-timer", but I haven't verified that the Cortex-A5 of the SAMA5D2 does have a CPU timer.
Read Documentation/devicetree/bindings/arm/arch_timer.txt and the processor technical reference manual.

Regards
pbugalski
Posts: 11
Joined: Thu Nov 29, 2018 4:28 pm

Re: How to use TC instead of PIT

Wed Jun 12, 2019 8:26 am

Thank you for the answer.

Secure boot is not related to TrustZone. Both are important for security, but from technical point of view they are totally independent. You can think about TrustZone as very simply virtualization technology. Linux or other operating system is running on SoC with restricted resources: https://developer.arm.com/ip-products/s ... /trustzone
But I wrote about it only to tell a bit more about my problem, generally what I'm trying to do is just boot Linux without PIT access.

When PIT is removed from device-tree there is not even message on console, kernel stops at very early stage of boot.
With earlyprint enabled, last messages are:
timer_probe: no matching timers found
Console: colour dummy device 80x30
sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps every 21474836475000000ns
And the kernel hangs.

Using ARM timer sounds very promising, I'll try if it works.

Best Regards,
Piotr
nferre
Site Admin
Posts: 204
Joined: Wed Feb 14, 2007 11:17 am

Re: How to use TC instead of PIT

Wed Jun 12, 2019 2:12 pm

Hi,

Indeed, on current implementation, there is no way to completely remove the PIT for early stages of Linux boot process.
I don't think ARM timers would help: they are not implemented by default on C-A5 and on SAMA5D2.

There is a patch series accepted recently which will solve this issue. It will make the TC a source that can boot the SoC.
http://lists.infradead.org/pipermail/li ... 49117.html

You can certainly backport it to a pretty recent kernel and use it. It will be available in upcoming Linux 5.2 Mainline kernel and a future version of Linux4SAM.

Best regards,
Nicolas
pbugalski
Posts: 11
Joined: Thu Nov 29, 2018 4:28 pm

Re: How to use TC instead of PIT

Wed Jun 12, 2019 3:49 pm

Hi,

Thank you for the answer, this patch is exactly what I was looking for.
As you wrote SAMA5D28 seems to not have arm timer so using patched TC sounds promising.

Best Regards,
Piotr

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 5 guests