1 // SPDX-License-Identifier: GPL-2.0-only
3 * Setup for the Realtek RTL838X SoC:
4 * Memory, Timer and Serial
6 * Copyright (C) 2020 B. Koblitz
7 * based on the original BSP by
8 * Copyright (C) 2006-2012 Tony Wu (tonywu@realtek.com)
12 #include <linux/console.h>
13 #include <linux/init.h>
14 #include <linux/clkdev.h>
15 #include <linux/clk-provider.h>
16 #include <linux/clk.h>
17 #include <linux/delay.h>
18 #include <linux/of_fdt.h>
19 #include <linux/irqchip.h>
21 #include <asm/addrspace.h>
23 #include <asm/bootinfo.h>
26 #include <asm/smp-ops.h>
28 #include "mach-rtl83xx.h"
30 extern struct rtl83xx_soc_info soc_info
;
32 void __init
plat_mem_setup(void)
36 set_io_port_base(KSEG1
);
40 panic("no dtb found");
43 * Load the devicetree. This causes the chosen node to be
44 * parsed resulting in our memory appearing
49 void plat_time_init_fallback(void)
51 struct device_node
*np
;
54 np
= of_find_node_by_name(NULL
, "cpus");
56 pr_err("Missing 'cpus' DT node, using default frequency.");
58 if (of_property_read_u32(np
, "frequency", &freq
) < 0)
59 pr_err("No 'frequency' property in DT, using default.");
61 pr_info("CPU frequency from device tree: %dMHz", freq
/ 1000000);
64 mips_hpt_frequency
= freq
/ 2;
67 void __init
plat_time_init(void)
70 * Initialization routine resembles generic MIPS plat_time_init() with
71 * lazy error handling. The final fallback is only needed until we have
72 * converted all device trees to new clock syntax.
74 struct device_node
*np
;
79 mips_hpt_frequency
= 0;
80 np
= of_get_cpu_node(0, NULL
);
82 pr_err("Failed to get CPU node\n");
84 clk
= of_clk_get(np
, 0);
86 pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk
));
88 mips_hpt_frequency
= clk_get_rate(clk
) / 2;
93 if (!mips_hpt_frequency
)
94 plat_time_init_fallback();
99 void __init
arch_init_irq(void)