Skip to content

Commit 450dd43

Browse files
committed
ARC: [DeviceTree] Convert some Kconfig items to runtime values
* mem size now runtime configured (prev CONFIG_ARC_PLAT_SDRAM_SIZE) * core cpu clk runtime configured (prev CONFIG_ARC_PLAT_CLK) Signed-off-by: Vineet Gupta <vgupta@synopsys.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Grant Likely <grant.likely@secretlab.ca>
1 parent 999159a commit 450dd43

6 files changed

Lines changed: 37 additions & 17 deletions

File tree

‎arch/arc/Kconfig‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,6 @@ source "arch/arc/plat-arcfpga/Kconfig"
249249

250250
#New platform adds here
251251

252-
config ARC_PLAT_CLK
253-
int "Clk speed in Hz"
254-
default "80000000"
255-
256252
config LINUX_LINK_BASE
257253
hex "Linux Link Address"
258254
default "0x80000000"
@@ -266,14 +262,6 @@ config LINUX_LINK_BASE
266262
Linux needs to be scooted a bit.
267263
If you don't know what the above means, leave this setting alone.
268264

269-
config ARC_PLAT_SDRAM_SIZE
270-
hex "SD RAM Size"
271-
default "0x10000000"
272-
help
273-
Implies the amount of SDRAM/DRAM Linux is going to claim/own.
274-
The actual memory itself could be larger than this number. But for
275-
all software purposes, this is the amt of memory.
276-
277265
endmenu # "Platform Board Configuration"
278266

279267
config ARC_STACK_NONEXEC

‎arch/arc/boot/dts/skeleton.dtsi‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313

1414
/ {
1515
compatible = "snps,arc";
16+
clock-frequency = <80000000>; /* 80 MHZ */
1617
#address-cells = <1>;
1718
#size-cells = <1>;
1819
chosen { };
1920
aliases { };
20-
memory { device_type = "memory"; reg = <0 0>; };
21+
memory {
22+
device_type = "memory";
23+
reg = <0x00000000 0x10000000>; /* 256M */
24+
};
2125
};

‎arch/arc/include/asm/clk.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ static inline unsigned long arc_get_core_freq(void)
1717
return core_freq;
1818
}
1919

20+
extern int arc_set_core_freq(unsigned long);
21+
2022
#endif

‎arch/arc/kernel/clk.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,14 @@
88

99
#include <asm/clk.h>
1010

11-
unsigned long core_freq = CONFIG_ARC_PLAT_CLK;
11+
unsigned long core_freq = 800000000;
12+
13+
/*
14+
* As of now we default to device-tree provided clock
15+
* In future we can determine this in early boot
16+
*/
17+
int arc_set_core_freq(unsigned long freq)
18+
{
19+
core_freq = freq;
20+
return 0;
21+
}

‎arch/arc/kernel/devtree.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/of.h>
1616
#include <linux/of_fdt.h>
1717
#include <asm/prom.h>
18+
#include <asm/clk.h>
1819

1920
/* called from unflatten_device_tree() to bootstrap devicetree itself */
2021
void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
@@ -34,7 +35,9 @@ int __init setup_machine_fdt(void *dt)
3435
struct boot_param_header *devtree = dt;
3536
unsigned long dt_root;
3637
char *model, *compat;
38+
void *clk;
3739
char manufacturer[16];
40+
unsigned long len;
3841

3942
/* check device tree validity */
4043
if (be32_to_cpu(devtree->magic) != OF_DT_HEADER)
@@ -60,5 +63,15 @@ int __init setup_machine_fdt(void *dt)
6063
/* Retrieve various information from the /chosen node */
6164
of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
6265

66+
/* Initialize {size,address}-cells info */
67+
of_scan_flat_dt(early_init_dt_scan_root, NULL);
68+
69+
/* Setup memory, calling early_init_dt_add_memory_arch */
70+
of_scan_flat_dt(early_init_dt_scan_memory, NULL);
71+
72+
clk = of_get_flat_dt_prop(dt_root, "clock-frequency", &len);
73+
if (clk)
74+
arc_set_core_freq(of_read_ulong(clk, len/4));
75+
6376
return 0;
6477
}

‎arch/arc/mm/init.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ char empty_zero_page[PAGE_SIZE] __aligned(PAGE_SIZE);
2525
EXPORT_SYMBOL(empty_zero_page);
2626

2727
/* Default tot mem from .config */
28-
static unsigned long arc_mem_sz = CONFIG_ARC_PLAT_SDRAM_SIZE;
28+
static unsigned long arc_mem_sz = 0x20000000; /* some default */
2929

3030
/* User can over-ride above with "mem=nnn[KkMm]" in cmdline */
3131
static int __init setup_mem_sz(char *str)
@@ -41,7 +41,8 @@ early_param("mem", setup_mem_sz);
4141

4242
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
4343
{
44-
pr_err("%s(%llx, %llx)\n", __func__, base, size);
44+
arc_mem_sz = size & PAGE_MASK;
45+
pr_info("Memory size set via devicetree %ldM\n", TO_MB(arc_mem_sz));
4546
}
4647

4748
/*
@@ -62,7 +63,9 @@ void __init setup_arch_memory(void)
6263

6364
/*
6465
* We do it here, so that memory is correctly instantiated
65-
* even if "mem=xxx" cmline over-ride is not given
66+
* even if "mem=xxx" cmline over-ride is given and/or
67+
* DT has memory node. Each causes an update to @arc_mem_sz
68+
* and we finally add memory one here
6669
*/
6770
memblock_add(CONFIG_LINUX_LINK_BASE, arc_mem_sz);
6871

0 commit comments

Comments
 (0)