1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * 4 * Copyright (C) 2010 John Crispin <john@phrozen.org> 5 */ 6 7#include <linux/export.h> 8#include <linux/clk.h> 9#include <linux/memblock.h> 10#include <linux/of_fdt.h> 11 12#include <asm/bootinfo.h> 13#include <asm/time.h> 14#include <asm/prom.h> 15 16#include <lantiq.h> 17 18#include "prom.h" 19#include "clk.h" 20 21/* access to the ebu needs to be locked between different drivers */ 22DEFINE_SPINLOCK(ebu_lock); 23EXPORT_SYMBOL_GPL(ebu_lock); 24 25/* 26 * this struct is filled by the soc specific detection code and holds 27 * information about the specific soc type, revision and name 28 */ 29static struct ltq_soc_info soc_info; 30 31const char *get_system_type(void) 32{ 33 return soc_info.sys_type; 34} 35 36int ltq_soc_type(void) 37{ 38 return soc_info.type; 39} 40 41void __init prom_free_prom_memory(void) 42{ 43} 44 45static void __init prom_init_cmdline(void) 46{ 47 int argc = fw_arg0; 48 char **argv = (char **) KSEG1ADDR(fw_arg1); 49 int i; 50 51 arcs_cmdline[0] = '\0'; 52 53 for (i = 0; i < argc; i++) { 54 char *p = (char *) KSEG1ADDR(argv[i]); 55 56 if (CPHYSADDR(p) && *p) { 57 strlcat(arcs_cmdline, p, sizeof(arcs_cmdline)); 58 strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline)); 59 } 60 } 61} 62 63void __init plat_mem_setup(void) 64{ 65 void *dtb; 66 67 ioport_resource.start = IOPORT_RESOURCE_START; 68 ioport_resource.end = IOPORT_RESOURCE_END; 69 iomem_resource.start = IOMEM_RESOURCE_START; 70 iomem_resource.end = IOMEM_RESOURCE_END; 71 72 set_io_port_base((unsigned long) KSEG1); 73 74 if (fw_passed_dtb) /* UHI interface */ 75 dtb = (void *)fw_passed_dtb; 76 else if (&__dtb_start != &__dtb_end) 77 dtb = (void *)__dtb_start; 78 else 79 panic("no dtb found"); 80 81 /* 82 * Load the devicetree. This causes the chosen node to be 83 * parsed resulting in our memory appearing 84 */ 85 __dt_setup_arch(dtb); 86} 87 88void __init device_tree_init(void) 89{ 90 unflatten_and_copy_device_tree(); 91} 92 93void __init prom_init(void) 94{ 95 /* call the soc specific detetcion code and get it to fill soc_info */ 96 ltq_soc_detect(&soc_info); 97 snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN - 1, "%s rev %s", 98 soc_info.name, soc_info.rev_type); 99 soc_info.sys_type[LTQ_SYS_TYPE_LEN - 1] = '\0'; 100 pr_info("SoC: %s\n", soc_info.sys_type); 101 prom_init_cmdline(); 102 103#if defined(CONFIG_MIPS_MT_SMP) 104 if (register_vsmp_smp_ops()) 105 panic("failed to register_vsmp_smp_ops()"); 106#endif 107} 108