^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Based on reduced version of METAG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/reboot.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/memblock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/of_fdt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/mach_desc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #ifdef CONFIG_SERIAL_EARLYCON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static unsigned int __initdata arc_base_baud;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) unsigned int __init arc_early_base_baud(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) return arc_base_baud/16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static void __init arc_set_early_base_baud(unsigned long dt_root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if (of_flat_dt_is_compatible(dt_root, "abilis,arc-tb10x"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) arc_base_baud = 166666666; /* Fixed 166.6MHz clk (TB10x) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) else if (of_flat_dt_is_compatible(dt_root, "snps,arc-sdp") ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) of_flat_dt_is_compatible(dt_root, "snps,hsdk"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) arc_base_baud = 33333333; /* Fixed 33MHz clk (AXS10x & HSDK) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) arc_base_baud = 50000000; /* Fixed default 50MHz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define arc_set_early_base_baud(dt_root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static const void * __init arch_get_next_mach(const char *const **match)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static const struct machine_desc *mdesc = __arch_info_begin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) const struct machine_desc *m = mdesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) if (m >= __arch_info_end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) mdesc++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *match = m->dt_compat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * setup_machine_fdt - Machine setup when an dtb was passed to the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * @dt: virtual address pointer to dt blob
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * If a dtb was passed to the kernel, then use it to choose the correct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * machine_desc and to setup the system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) const struct machine_desc * __init setup_machine_fdt(void *dt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) const struct machine_desc *mdesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) unsigned long dt_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) if (!early_init_dt_scan(dt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) if (!mdesc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) machine_halt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) dt_root = of_get_flat_dt_root();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) arc_set_early_base_baud(dt_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) return mdesc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }