UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Explorer
Explorer
4,464 Views
Registered: ‎02-17-2017

How to change and verify the zynq processors operating frequency?

Dear Xilinx Community,

 

I am using zynq 7000 processor, could you please let me know how can I verify that the current operating frequency at which zynq is running from linux userspace??

 

And also could you please let me know how this can be changed to different operating frequencies and verified from the linux userspace at which the zynq processor is running?

 

Kindly do the needful as early as possible

 

Awaiting for your replies

Many Thanks in advance

0 Kudos
15 Replies
Moderator
Moderator
4,445 Views
Registered: ‎12-04-2016

Re: How to change and verify the zynq processors operating frequency?

Hi

 

Can you please check the below sysfs entry for current operating frequency on zynq:

cat  /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

 

If you are not seeing this entry, then probably you dont have cpufreq support. To add this support in the linux kernel, I would request you to go through the below wiki link:

http://www.wiki.xilinx.com/Zynq-7000+AP+SoC+Low+Power+Techniques+part+5+-+Linux+Application+Control+of+Processing+System+-+Frequency+Scaling+%26+More+Tech+Tip

 

 

Once this support is enabled, you should see the current frequency in sysfs.

To change frequency, follow this way :

echo <selected_CPU_speed> > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed

 

 

Best Regards

Shabbir

 

 

0 Kudos
Explorer
Explorer
3,683 Views
Registered: ‎02-17-2017

Re: How to change and verify the zynq processors operating frequency?

Dear Shabbir,

 

I am not able to get this entry in xlinx linux kernel 4.6.0, even though I have the following enabled, I have attached the .config for your reference

 

I have even the following enabled

 

 CONFIG_SYSFS_DEPRECATED

 

#
# CPU Frequency scaling
#
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_GOV_COMMON=y
CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_STAT_DETAILS=y
# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y
# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y

 

Could you please help me how to check the current cpu freq at which it is running? How can this be verified in linux kernel 4.6.0

 

logs:

 

# ls -ltr /sys/devices/system/cpu/cpu0/
total 0
-rw-r--r--    1 root     root          4096 Jan 11 10:55 uevent
drwxr-xr-x    2 root     root             0 Jan 11 10:55 topology
lrwxrwxrwx    1 root     root             0 Jan 11 10:55 subsystem -> ../../../../bus/cpu
drwxr-xr-x    2 root     root             0 Jan 11 10:55 power
lrwxrwxrwx    1 root     root             0 Jan 11 10:55 of_node -> ../../../../firmware/devicetree/base/cpus/cpu@0
drwxr-xr-x    2 root     root             0 Jan 11 10:55 hotplug
drwxr-xr-x    4 root     root             0 Jan 11 10:55 cpuidle
# ls -ltr /sys/devices/system/cpu/cpu0/of_node/
bus-handle         d-cache-line-size  device_type        i-cache-size       name
compatible         d-cache-size       i-cache-line-size  interrupt-handle   reg
# ls -ltr /sys/devices/system/cpu/cpu0/subsystem/
devices/           drivers/           drivers_autoprobe  drivers_probe      uevent
# ls -ltr /sys/devices/system/cpu/cpu0/subsystem/devices/cpu
cpu0/  cpu1/
# ls -ltr /sys/devices/system/cpu/cpu0/subsystem/devices/cpu0/
cpuidle/    hotplug/    of_node/    power/      subsystem/  topology/   uevent
# ls -ltr /sys/devices/system/cpu/cpu0/subsystem/devices/cpu0/power/
autosuspend_delay_ms    control                 runtime_active_time     runtime_status          runtime_suspended_time
# ls -ltr /sys/devices/system/cpu/cpu0/subsystem/devices/cpu0/hotplug/
state   target

 

0 Kudos
Adventurer
Adventurer
3,677 Views
Registered: ‎12-02-2014

Re: How to change and verify the zynq processors operating frequency?

I think you need "CONFIG_CPUFREQ_DT" enabled

0 Kudos
Explorer
Explorer
3,665 Views
Registered: ‎02-17-2017

Re: How to change and verify the zynq processors operating frequency?

Even after Enabling CONFIG_CPUFREQ_DT, I am unable to find the below entry

 

cat  /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

 

 

logs:

# cat  /sys/devices/system/cpu/cpu0/
cpuidle/    of_node/    subsystem/  uevent
hotplug/    power/      topology/
# cat  /sys/devices/system/cpu/
cpu0/       cpuidle/    kernel_max  possible    uevent
cpu1/       hotplug/    offline     power/
cpufreq/    isolated    online      present
# cat  /sys/devices/system/cpu/cpu
cpu0/     cpu1/     cpufreq/  cpuidle/
# cat  /sys/devices/system/cpu/cpu
cpu0/     cpu1/     cpufreq/  cpuidle/
# cat  /sys/devices/system/cpu/cpufreq
cat: read error: Is a directory
# cd  /sys/devices/system/cpu/cpufreq/
# ls

 

0 Kudos
Adventurer
Adventurer
3,657 Views
Registered: ‎12-02-2014

Re: How to change and verify the zynq processors operating frequency?

can you post the output of the following 2 commands from linux:

 

dmesg | grep -in cpu

 

and 

 

dmesg | grep -in freq

 

 

0 Kudos
Explorer
Explorer
3,654 Views
Registered: ‎02-17-2017

Re: How to change and verify the zynq processors operating frequency?

# dmesg | grep -in cpu

1:CPU0: thread -1, cpu 0, socket 0, mpidr 80000000

3:CPU1: thread -1, cpu 1, socket 0, mpidr 80000001

4:Brought up 2 CPUs

6:CPU: All CPU(s) started in SVC mode.

13:cpuidle: using governor menu

65:WARNING: CPU: 0 PID: 1 at drivers/spi/spidev.c:720 spidev_probe+0x18c/0x1d0

67:CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.6.0-xilinx-22286-g2152fc6-dirty #0

99:WARNING: CPU: 0 PID: 1 at drivers/spi/spidev.c:720 spidev_probe+0x18c/0x1d0

101:CPU: 0 PID: 1 Comm: swapper/0 Tainted: G        W       4.6.0-xilinx-22286-g2152fc6-dirty #0

134:WARNING: CPU: 0 PID: 1 at drivers/spi/spidev.c:720 spidev_probe+0x18c/0x1d0

136:CPU: 0 PID: 1 Comm: swapper/0 Tainted: G        W       4.6.0-xilinx-22286-g2152fc6-dirty #0

178:cpu cpu0: failed to get clock: -2

179:cpufreq-dt: probe of cpufreq-dt.0 failed with error -2

180:Xilinx Zynq CpuIdle Driver started

# dmesg | grep -in freq

179:cpufreq-dt: probe of cpufreq-dt.0 failed with error -2

#

0 Kudos
Adventurer
Adventurer
3,646 Views
Registered: ‎12-02-2014

Re: How to change and verify the zynq processors operating frequency?

This is for sure your problem:

 

178:cpu cpu0: failed to get clock: -2

179:cpufreq-dt: probe of cpufreq-dt.0 failed with error -2

180:Xilinx Zynq CpuIdle Driver started

# dmesg | grep -in freq

179:cpufreq-dt: probe of cpufreq-dt.0 failed with error -2

 

 

Now, please make sure that in your device tree, cpu0 has reg = <0>; and cpu1 has reg = <1>;

0 Kudos
Explorer
Explorer
3,565 Views
Registered: ‎02-17-2017

Re: How to change and verify the zynq processors operating frequency?

1. Could you please let me know how this can be verified using devmem, may I know what is the register base address for the same instead of using echo and cat??

Could you please provide with an example, inorder how to change the cpu freq using devmem with an example?

 

2. The below is my DT configuration , please let me kno if I am missing anything or doing wrong?

 

    cpus {
        #address-cells = <1>;
        #size-cells = <0>;
        ps7_cortexa9_0: cpu@0 {
            bus-handle = <&ps7_axi_interconnect_0>;
            compatible = "arm,cortex-a9";
            d-cache-line-size = <0x20>;
            d-cache-size = <0x8000>;
            device_type = "cpu";
            i-cache-line-size = <0x20>;
            i-cache-size = <0x8000>;
            interrupt-handle = <&ps7_scugic_0>;
            reg = <0x0>;
        } ;
        ps7_cortexa9_1: cpu@1 {
            bus-handle = <&ps7_axi_interconnect_0>;
            compatible = "arm,cortex-a9";
            d-cache-line-size = <0x20>;
            d-cache-size = <0x8000>;
            device_type = "cpu";
            i-cache-line-size = <0x20>;
            i-cache-size = <0x8000>;
            interrupt-handle = <&ps7_scugic_0>;
            reg = <0x1>;
        } ;
    } ;

 

Kindly do the needful as early as possible

 

Many Thanks in advance

0 Kudos
Adventurer
Adventurer
3,551 Views
Registered: ‎12-02-2014

Re: How to change and verify the zynq processors operating frequency?

You're missing the entry for 'clocks', like:

 

	cpus {
		#address-cells = <1>;
		#size-cells = <0>;
		ps7_cortexa9_0: cpu@0 {
			bus-handle = <&ps7_axi_interconnect_0>;
			clock-latency = <1000>;
			clocks = <&clkc 3>;
			compatible = "arm,cortex-a9";
			device_type = "cpu";
			interrupt-handle = <&ps7_scugic_0>;
			operating-points = <
				/* kHz    uV */
				666667  1000000
				333334  1000000
				222223  1000000
			>;
		} ;
		ps7_cortexa9_1: cpu@1 {
			bus-handle = <&ps7_axi_interconnect_0>;
			clock-latency = <1000>;
			clocks = <&clkc 3>;
			compatible = "arm,cortex-a9";
			device_type = "cpu";
			interrupt-handle = <&ps7_scugic_0>;
			operating-points = <
				/* kHz    uV */
				666667  1000000
				333334  1000000
				222223  1000000
			>;
		} ;
	} ;
0 Kudos
Explorer
Explorer
2,743 Views
Registered: ‎02-17-2017

Re: How to change and verify the zynq processors operating frequency?

Thanks a lot for your quick responses jdefields and you are very supportive

 

1. I will verify by adding those entries in Dt and keep you posted as you suggested once again thanks a lot for your prompt responses,

 

Meanwhile, I jus wanted to check what si the default cpu freq at which Zynq is runnning, could you please help me how this can be verified using register read/write using devmem?

 

 

Many many Thanks in advance,

 

0 Kudos
Explorer
Explorer
2,741 Views
Registered: ‎02-17-2017

Re: How to change and verify the zynq processors operating frequency?

After changing the entries as above, kernel is failing to come up

 

U-Boot 2013.04-00028-gf445610 (Mar 20 2017 - 17:45:46)

I2C: ready
DRAM: 512 MiB
WARNING: Caches not enabled
NAND: 512 MiB
MMC: zynq_sdhci: 0
SF: Detected S25FL512S_256K with page size 64 KiB, total 64 MiB
*** Warning - bad CRC, using default environment

In: serial
Out: serial
Err: serial
Net: Gem.e000b000
Hit any key to stop autoboot: 0
Copying Linux from SD to RAM...
Device: zynq_sdhci
Manufacturer ID: 82
OEM: 4a54
Name: NCard
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 3.7 GiB
Bus Width: 4-bit
reading uImage
3555120 bytes read in 685 ms (4.9 MiB/s)
reading devicetree.dtb
9904 bytes read in 16 ms (604.5 KiB/s)
reading uramdisk.image.gz
8552124 bytes read in 1618 ms (5 MiB/s)
## Booting kernel from Legacy Image at 03000000 ...
Image Name: Linux-4.6.0-xilinx-22286-g2152fc
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3555056 Bytes = 3.4 MiB
Load Address: 00008000
Entry Point: 00008000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 02000000 ...
Image Name:
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 8552060 Bytes = 8.2 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
## Flattened Device Tree blob at 02a00000
Booting using the fdt blob at 0x02a00000
Loading Kernel Image ... OK
OK
Loading Ramdisk to 1f30e000, end 1fb35e7c ... OK
Loading Device Tree to 1f308000, end 1f30d6af ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
init/main.c:477 set_task_stack_end_magic(&init_task);
init/main.c:479 smp_setup_processor_id();
Booting Linux on physical CPU 0x0
init/main.c:481 debug_objects_early_init();
init/main.c:487 boot_init_stack_canary();
init/main.c:490 cgroup_init_early();
init/main.c:493 local_irq_disable();
init/main.c:495 early_boot_irqs_disabled = true;
init/main.c:504 boot_cpu_init();
init/main.c:506 page_address_init();
Linux version 4.6.0-xilinx-22286-g2152fc6-dirty (n008@n008-ThinkPad-L460) (gcc version 4.9.1 (Sourcery CodeBench Lite 2014.11-30) ) #0 SMP PREEMPT Wed Aug 2 16:11:38 CEST 2017
init/main.c:510 setup_arch(&command_line);
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: PTG Mars ZX3
bootconsole [earlycon0] enabled
Memory policy: Data cache writealloc
init/main.c:512 mm_init_owner(&init_mm, &init_task);
init/main.c:516 setup_command_line(command_line);
init/main.c:518 setup_nr_cpu_ids();
init/main.c:520 setup_per_cpu_areas();
percpu: Embedded 12 pages/cpu @dfbd5000 s19584 r8192 d21376 u49152
init/main.c:522 smp_prepare_boot_cpu();
init/main.c:524 build_all_zonelists(NULL, NULL);
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048
init/main.c:526 page_alloc_init();
Kernel command line: console=ttyPS0,115200n8 root=/dev/ram rw ip=:::::eth0:off earlyprintk
init/main.c:541 setup_log_buf(0);
init/main.c:543 pidhash_init();
PID hash table entries: 2048 (order: 1, 8192 bytes)
init/main.c:545 vfs_caches_init_early();
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
init/main.c:547 sort_main_extable();
init/main.c:549 trap_init();
init/main.c:551 mm_init();
Memory: 502608K/524288K available (5283K kernel code, 235K rwdata, 1640K rodata, 1024K init, 189K bss, 21680K reserved, 0K cma-reserved, 0K highmem)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
vmalloc : 0xe0800000 - 0xff800000 ( 496 MB)
lowmem : 0xc0000000 - 0xe0000000 ( 512 MB)
pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
.text : 0xc0008000 - 0xc07c2d44 (7916 kB)
.init : 0xc0800000 - 0xc0900000 (1024 kB)
.data : 0xc0900000 - 0xc093ae78 ( 236 kB)
.bss : 0xc093ae78 - 0xc096a620 ( 190 kB)
init/main.c:570 idr_init_cache();
init/main.c:574 rcu_init();
Preemptible hierarchical RCU implementation.
Build-time adjustment of leaf fanout to 32.
RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=2
init/main.c:576 radix_tree_init();
init/main.c:579 early_irq_init();
NR_IRQS:16 nr_irqs:16 16
init/main.c:581 init_IRQ();
zynq_early_efuse_init: no efuse node found
------------[ cut here ]------------
Kernel BUG at c0809160 [verbose debug info unavailable]
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.6.0-xilinx-22286-g2152fc6-dirty #0
Hardware name: Xilinx Zynq Platform
task: c0905a00 ti: c0900000 task.ti: c0900000
PC is at zynq_early_efuse_init+0x48/0x7c
LR is at zynq_early_efuse_init+0x48/0x7c
pc : [<c0809160>] lr : [<c0809160>] psr: 200f00d3
sp : c0901fa8 ip : 00000000 fp : 00000000
r10: 00000000 r9 : dfffcd00 r8 : c082ca30
r7 : c0902400 r6 : ffffffff r5 : c093ae80 r4 : 00000000
r3 : 00000001 r2 : 00000001 r1 : 600f00d3 r0 : 0000002a
Flags: nzCv IRQs off FIQs off Mode SVC_32 ISA ARM Segment none
Control: 18c5387d Table: 0000404a DAC: 00000051
Process swapper/0 (pid: 0, stack limit = 0xc0900210)
Stack: (0xc0901fa8 to 0xc0902000)
1fa0: c082ca20 c08090ac c082ca20 c08035a8 00000000 c0800bb0
1fc0: ffffffff ffffffff 00000000 c0800690 00000000 c082ca30 00000000 c093b114
1fe0: c0902480 c082ca2c c0906c2c 0000406a 413fc090 0000807c 00000000 00000000
[<c0809160>] (zynq_early_efuse_init) from [<c08090ac>] (zynq_irq_init+0x8/0x14)
[<c08090ac>] (zynq_irq_init) from [<c08035a8>] (init_IRQ+0x28/0x88)
[<c08035a8>] (init_IRQ) from [<c0800bb0>] (start_kernel+0x2dc/0x688)
[<c0800bb0>] (start_kernel) from [<0000807c>] (0x807c)
Code: 1a000003 e59f002c e59f102c ebe5ff0b (e7f001f2)
---[ end trace cb88537fdc8fa200 ]---
Kernel panic - not syncing: Attempted to kill the idle task!
---[ end Kernel panic - not syncing: Attempted to kill the idle task!

0 Kudos
Adventurer
Adventurer
2,739 Views
Registered: ‎12-02-2014

Re: How to change and verify the zynq processors operating frequency?

Looks like other device tree issues.  There's an efuse driver on zynq, which it looks like you have some issue with.  Please make sure you are generating the same device tree versions as uboot version/kernel version/vivado/etc.

0 Kudos
Explorer
Explorer
2,732 Views
Registered: ‎02-17-2017

Re: How to change and verify the zynq processors operating frequency?

Is it possible ot verify using devmem ?? I jus wanted to check what is the default cpu freq at which Zynq is runnning, could you please help me how this can be verified using register read/write using devmem?

0 Kudos
Explorer
Explorer
2,721 Views
Registered: ‎02-17-2017

Re: How to change and verify the zynq processors operating frequency?

Could you please let me know, Is it possible to verify using devmem , I checked in TRM, I didnt find any registers as such, but still am not sure that whether am I missing anything while searching in TRM??

 

0 Kudos
Explorer
Explorer
2,711 Views
Registered: ‎02-17-2017

Re: How to change and verify the zynq processors operating frequency?

could you please confirm ,whether that below is the register for reading cpu freq

 

devmem 0xF8000100??

 

Please correct me if I am wrong

0 Kudos