Skip to content

Commit 2e23702

Browse files
xxkentabrodkin
authored andcommitted
ARCv3:DBG: Add debug feature to change clock frequency
For debug purpose now we can change clock frequency using a global variable glb_clock_freq in devtree.c This can be useful when we have timing violations in a bitfiles and need to reduce clock. In this case we don't need to regenerate old kernels, just changing glb_clock_freq in MDB. Steps to change: 1. Get clock variable address from vmlinux file readelf -s vmlinux | grep glb_clock_freq 33790: 85ed7484 4 OBJECT GLOBAL DEFAULT 16 glb_clock_freq 2. Load loader file in MDB 3. Substract 0x80000000 value from address 0x85ed7484-0x80000000 = 0x05ed7484 4. Change glb_clock_freq at address 0x05ed7484 evalq *(unsigned int *)0x05ed7484 = 20000000 (20MHz) 5. Run target
1 parent 7ce96f0 commit 2e23702

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

arch/arc/kernel/devtree.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
static unsigned int __initdata arc_base_baud;
1919

20+
volatile unsigned int glb_clock_freq = 50000000;
21+
2022
unsigned int __init arc_early_base_baud(void)
2123
{
2224
return arc_base_baud/16;
@@ -30,7 +32,7 @@ static void __init arc_set_early_base_baud(unsigned long dt_root)
3032
of_flat_dt_is_compatible(dt_root, "snps,hsdk"))
3133
arc_base_baud = 33333333; /* Fixed 33MHz clk (AXS10x & HSDK) */
3234
else
33-
arc_base_baud = 50000000; /* Fixed default 50MHz */
35+
arc_base_baud = glb_clock_freq; /* Fixed default 50MHz */
3436
}
3537
#else
3638
#define arc_set_early_base_baud(dt_root)

drivers/clk/clk-fixed-rate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/of.h>
1515
#include <linux/platform_device.h>
1616

17+
extern volatile unsigned int glb_clock_freq;
18+
1719
/*
1820
* DOC: basic fixed-rate clock that cannot gate
1921
*
@@ -148,6 +150,8 @@ static struct clk_hw *_of_fixed_clk_setup(struct device_node *node)
148150
if (of_property_read_u32(node, "clock-frequency", &rate))
149151
return ERR_PTR(-EIO);
150152

153+
rate = glb_clock_freq; // Let it be changeable in MDB during boot process.
154+
151155
of_property_read_u32(node, "clock-accuracy", &accuracy);
152156

153157
of_property_read_string(node, "clock-output-names", &clk_name);

drivers/tty/serial/8250/8250_of.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "8250.h"
2020

21+
extern volatile unsigned int glb_clock_freq;
22+
2123
struct of_serial_info {
2224
struct clk *clk;
2325
struct reset_control *rst;
@@ -61,6 +63,9 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
6163

6264
clk = clk_get_rate(info->clk);
6365
}
66+
67+
clk = glb_clock_freq; // Let it be changeable in MDB during boot process.
68+
6469
/* If current-speed was set, then try not to change it. */
6570
if (of_property_read_u32(np, "current-speed", &spd) == 0)
6671
port->custom_divisor = clk / (16 * spd);

0 commit comments

Comments
 (0)