realtek: remove hardcoded sys-led configurations
[openwrt/staging/aparcar.git] / target / linux / realtek / files-5.10 / arch / mips / rtl838x / setup.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Setup for the Realtek RTL838X SoC:
4 * Memory, Timer and Serial
5 *
6 * Copyright (C) 2020 B. Koblitz
7 * based on the original BSP by
8 * Copyright (C) 2006-2012 Tony Wu (tonywu@realtek.com)
9 *
10 */
11
12 #include <linux/console.h>
13 #include <linux/init.h>
14 #include <linux/clkdev.h>
15 #include <linux/clk-provider.h>
16 #include <linux/delay.h>
17 #include <linux/of_fdt.h>
18 #include <linux/irqchip.h>
19
20 #include <asm/addrspace.h>
21 #include <asm/io.h>
22 #include <asm/bootinfo.h>
23 #include <asm/time.h>
24 #include <asm/prom.h>
25 #include <asm/smp-ops.h>
26
27 #include "mach-rtl83xx.h"
28
29 extern struct rtl83xx_soc_info soc_info;
30
31 void __init plat_mem_setup(void)
32 {
33 void *dtb;
34
35 set_io_port_base(KSEG1);
36
37 if (fw_passed_dtb) /* UHI interface */
38 dtb = (void *)fw_passed_dtb;
39 else if (&__dtb_start[0] != &__dtb_end[0])
40 dtb = (void *)__dtb_start;
41 else
42 panic("no dtb found");
43
44 /*
45 * Load the devicetree. This causes the chosen node to be
46 * parsed resulting in our memory appearing
47 */
48 __dt_setup_arch(dtb);
49 }
50
51 void __init plat_time_init(void)
52 {
53 struct device_node *np;
54 u32 freq = 500000000;
55
56 of_clk_init(NULL);
57 timer_probe();
58
59 np = of_find_node_by_name(NULL, "cpus");
60 if (!np) {
61 pr_err("Missing 'cpus' DT node, using default frequency.");
62 } else {
63 if (of_property_read_u32(np, "frequency", &freq) < 0)
64 pr_err("No 'frequency' property in DT, using default.");
65 else
66 pr_info("CPU frequency from device tree: %dMHz", freq / 1000000);
67 of_node_put(np);
68 }
69
70 mips_hpt_frequency = freq / 2;
71 }
72
73 void __init arch_init_irq(void)
74 {
75 irqchip_init();
76 }