Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+37 -17
-12
arch/arc/Kconfig
··· 249 249 250 250 #New platform adds here 251 251 252 - config ARC_PLAT_CLK 253 - int "Clk speed in Hz" 254 - default "80000000" 255 - 256 252 config LINUX_LINK_BASE 257 253 hex "Linux Link Address" 258 254 default "0x80000000" ··· 261 265 However some customers have peripherals mapped at this addr, so 262 266 Linux needs to be scooted a bit. 263 267 If you don't know what the above means, leave this setting alone. 264 - 265 - config ARC_PLAT_SDRAM_SIZE 266 - hex "SD RAM Size" 267 - default "0x10000000" 268 - help 269 - Implies the amount of SDRAM/DRAM Linux is going to claim/own. 270 - The actual memory itself could be larger than this number. But for 271 - all software purposes, this is the amt of memory. 272 268 273 269 endmenu # "Platform Board Configuration" 274 270
+5 -1
arch/arc/boot/dts/skeleton.dtsi
··· 13 13 14 14 / { 15 15 compatible = "snps,arc"; 16 + clock-frequency = <80000000>; /* 80 MHZ */ 16 17 #address-cells = <1>; 17 18 #size-cells = <1>; 18 19 chosen { }; 19 20 aliases { }; 20 - memory { device_type = "memory"; reg = <0 0>; }; 21 + memory { 22 + device_type = "memory"; 23 + reg = <0x00000000 0x10000000>; /* 256M */ 24 + }; 21 25 };
+2
arch/arc/include/asm/clk.h
··· 17 17 return core_freq; 18 18 } 19 19 20 + extern int arc_set_core_freq(unsigned long); 21 + 20 22 #endif
+11 -1
arch/arc/kernel/clk.c
··· 8 8 9 9 #include <asm/clk.h> 10 10 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 + }
+13
arch/arc/kernel/devtree.c
··· 15 15 #include <linux/of.h> 16 16 #include <linux/of_fdt.h> 17 17 #include <asm/prom.h> 18 + #include <asm/clk.h> 18 19 19 20 /* called from unflatten_device_tree() to bootstrap devicetree itself */ 20 21 void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) ··· 35 34 struct boot_param_header *devtree = dt; 36 35 unsigned long dt_root; 37 36 char *model, *compat; 37 + void *clk; 38 38 char manufacturer[16]; 39 + unsigned long len; 39 40 40 41 /* check device tree validity */ 41 42 if (be32_to_cpu(devtree->magic) != OF_DT_HEADER) ··· 62 59 63 60 /* Retrieve various information from the /chosen node */ 64 61 of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); 62 + 63 + /* Initialize {size,address}-cells info */ 64 + of_scan_flat_dt(early_init_dt_scan_root, NULL); 65 + 66 + /* Setup memory, calling early_init_dt_add_memory_arch */ 67 + of_scan_flat_dt(early_init_dt_scan_memory, NULL); 68 + 69 + clk = of_get_flat_dt_prop(dt_root, "clock-frequency", &len); 70 + if (clk) 71 + arc_set_core_freq(of_read_ulong(clk, len/4)); 65 72 66 73 return 0; 67 74 }
+6 -3
arch/arc/mm/init.c
··· 25 25 EXPORT_SYMBOL(empty_zero_page); 26 26 27 27 /* 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 */ 29 29 30 30 /* User can over-ride above with "mem=nnn[KkMm]" in cmdline */ 31 31 static int __init setup_mem_sz(char *str) ··· 41 41 42 42 void __init early_init_dt_add_memory_arch(u64 base, u64 size) 43 43 { 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)); 45 46 } 46 47 47 48 /* ··· 63 62 64 63 /* 65 64 * We do it here, so that memory is correctly instantiated 66 - * even if "mem=xxx" cmline over-ride is not given 65 + * even if "mem=xxx" cmline over-ride is given and/or 66 + * DT has memory node. Each causes an update to @arc_mem_sz 67 + * and we finally add memory one here 67 68 */ 68 69 memblock_add(CONFIG_LINUX_LINK_BASE, arc_mem_sz); 69 70