This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] AM5728:使用高分辨率计时器作为时钟源

Guru**** 2827545 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1624537/am5728-using-high-resolution-timer-as-clock-source

器件型号: AM5728

使用 SDK 11 (ti-processor-sdk-linux-rt-am57xx-evm-11_01_02_01-linux-x86-Install.bin)、AM57xx-EVM、kernel 6.12。

我看到/sys/devices/system/clocksource/clocksource0/available_clocksource 仅显示 32k_counter。

我需要更高的分辨率。 如何将一些计时器定义为时钟源?

谢谢您、

Michael

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Michael、

    请参阅以下常见问题解答是否对您有用: https://ete.ti.com/f/791/t/1561212

    -Josue

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你好 Josue、

    此常见问题解答只提示了如何从 32k_counter 切换到 dmtimer/timer12。 但是、此计时器以 32k 频率运行。 如何使用以 192M 运行的计时器?

    谢谢您、

    Michael

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Michael、

    我制作了以下补丁、现在可以看到以下计时器作为我的时钟源:

    cat /sys/devices/system/clocksource/clocksource0/available_clocksource
    dmtimer 
    root@am57xx-evm:~# cat /sys/devices/system/clocksource/clocksource0/current_clocksource  
    dmtimer
    able via sysfs":~# cat /sys/devices/system/clocksource/clocksource0/clocksource0/rating 2>/dev/null || echo "Rating not avaia
    Rating not available via sysfs
    root@am57xx-evm:~# dmesg | grep -i "clocksource"
    [    0.000000] TI gptimer clocksource: always-on /ocp/interconnect@4ae00000/segment@10000/target-module@8000
    [    0.000000] clocksource: dmtimer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 58295017589499 ns
    [    0.153663] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
    [    0.284511] clocksource: Switched to clocksource dmtimer
    root@am57xx-evm:~#   dmesg | grep "20000000 Hz"
    [    0.000305] TI gptimer clockevent: always-on 20000000 Hz at /ocp/interconnect@48000000/segment@0/target-module@32000
    [    0.001769] TI gptimer percpu-dmtimer: 20000000 Hz at /ocp/interconnect@48800000/segment@0/target-module@2c000
    [    0.002043] TI gptimer percpu-dmtimer: 20000000 Hz at /ocp/interconnect@48800000/segment@0/target-module@2e000
    root@am57xx-evm:~# echo "Testing timestamp resolution..."
    Testing timestamp resolution...
    root@am57xx-evm:~# for i in 1 2 3; do date +%s.%N; done
    1748554770.446655919
    1748554770.450865033
    1748554770.455165649
    root@am57xx-evm:~# 

    补丁:

    diff --git a/arch/arm/boot/dts/ti/omap/am57xx-beagle-x15-common.dtsi b/arch/arm/boot/dts/ti/omap/am57xx-beagle-x15-common.dtsi
    index f08a1c54c..ebcdb2344 100644
    --- a/arch/arm/boot/dts/ti/omap/am57xx-beagle-x15-common.dtsi
    +++ b/arch/arm/boot/dts/ti/omap/am57xx-beagle-x15-common.dtsi
    @@ -10,6 +10,7 @@
     #include "dra74-ipu-dsp-common.dtsi"
     #include <dt-bindings/gpio/gpio.h>
     #include <dt-bindings/interrupt-controller/irq.h>
    +#include <dt-bindings/clock/dra7.h>
     
     / {
            compatible = "ti,am572x-beagle-x15", "ti,am5728", "ti,dra742", "ti,dra74", "ti,dra7";
    @@ -646,4 +647,20 @@ &pruss2_mdio {
            status = "disabled";
     };
     
    +/* Configure timer2 as high-resolution clocksource */
    +&timer2_target {
    +       ti,no-reset-on-init;
    +       ti,no-idle;
    +};
    +
    +&timer2 {
    +       ti,timer-alwon;
    +       assigned-clocks = <&l4per_clkctrl DRA7_L4PER_TIMER2_CLKCTRL 24>;
    +       assigned-clock-parents = <&timer_sys_clk_div>;
    +};
    +
    +&counter32k {
    +       status = "disabled";
    +};
    +
     #include "dra7-ipu-common-early-boot.dtsi"
    diff --git a/arch/arm/boot/dts/ti/omap/dra7-l4.dtsi b/arch/arm/boot/dts/ti/omap/dra7-l4.dtsi
    index 57efd480a..1aac31941 100644
    --- a/arch/arm/boot/dts/ti/omap/dra7-l4.dtsi
    +++ b/arch/arm/boot/dts/ti/omap/dra7-l4.dtsi
    @@ -1171,7 +1171,7 @@ uart3: serial@0 {
                            };
                    };
     
    -               target-module@32000 {                   /* 0x48032000, ap 5 3e.0 */
    +               timer2_target: target-module@32000 {                    /* 0x48032000, ap 5 3e.0 */
                            compatible = "ti,sysc-omap4-timer", "ti,sysc";
                            reg = <0x32000 0x4>,
                                  <0x32010 0x4>;

    此致、

    Josue

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你好 Josue、

    如何将 dmtimer 更改为 192MHz 而不是 20MHz?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Michael、

    您是否已确认 AM572x 中有一个 192MHz 计时器可用?

    是否没有冲突?

    -Josue

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    # cat /sys/kernel/debug/clk/clk_summary | grep 192000000
    DPLL_PER_M2x2_ck 1 5 0 192000000 0 50000 Y 无设备 NO_CONNECTION_id
    l3init-clkctrl:0008:24 0 1 0 192000000 0 50000 Y 无设备_clk_get_from_provider
    l3init-clkctrl:0008:25 0 1 0 192000000 0 50000 Y 无设备_clk_get_from_provider
    l3init-clkctrl:0008:0 0 1 0 192000000 0 50000 N 4809c000.mmc fck
    l3init-clkctrl:0010:24 0 1 0 192000000 0 50000 Y 无设备_clk_get_from_provider
    l3init-clkctrl:0010:25 0 1 0 192000000 0 50000 Y 无设备_clk_get_from_provider
    l3init-clkctrl:0010:0 0 0 1 0 192000000 0 50000 N 480b4000.mmc 闪存
    DPLL_per_h12x2_ck 1 1 0 192000000 0 50000 Y 器件无 NO_CONNECTION_id
    dss-clkctrl:0000:8 2 3 0 192000000 0 50000 Y 58040000.target-module dss_clk
    dss-clkctrl:0000:0 1 0 192000000 0 50000 Y 58000000.target-module fck

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Michael、

    如需更多信息、请阅读 TRM: 22.2 通用计时器

    2.2.1 通用计时器概述 该器件具有 16 个 GP 计时器:TIMER1 至 TIMER16。 •Timer1(1ms 节拍):其事件捕获引脚连接到 32KHz 时钟、可用于测量系统时 钟输入并在 19.2、20 或 27MHz 中检测其频率。 它包含 为操作系统 •TIMER2 和 TIMER10 生成精确节拍中断的特定函数:(1ms 节拍计时器):它们包含 为操作系统生成精确节拍中断的特定函数 。每个计时器(TIMER12 除外)都可以由系统时钟 (19.2、20 或 27MHz) 或 32kHz 时钟计时。 在电源、复位和时钟管理 (PRCM) 模块 级选择时钟源。 TIMER12 只能由内部振荡器(片上振荡器)计时。 有关更多信息 、请参阅第 3.6.3.1 节“ PRM 时钟源“

    可布线的最高频率是 20Mhz 信号。 至少在 TI EVM 上是如此。

    您可能会在计时器的多路复用器上拉其他分辨率略高的时钟、
    0x8:选择 VIDEO1_DIV_CLK 0x9:选择 VIDEO2_DIV _CLK 0xA:选择 HDMI_DIV _CLK、但这不是完全受支持的、您必须自行尝试。

    我在上面展示了如何进行这些更改、如果遇到问题、请随时发布任何其他问题。

    此致、

    -Josue