2019-06-04 16:11:33 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2013-01-21 05:02:01 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
|
|
|
|
* Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
|
2016-05-05 15:57:56 +08:00
|
|
|
* Copyright (C) 2013 John Crispin <john@phrozen.org>
|
2013-01-21 05:02:01 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/clk.h>
|
2021-05-17 08:54:17 +08:00
|
|
|
#include <linux/export.h>
|
2013-01-21 05:02:01 +08:00
|
|
|
#include <linux/init.h>
|
2013-04-13 21:15:51 +08:00
|
|
|
#include <linux/sizes.h>
|
2013-01-21 05:02:01 +08:00
|
|
|
#include <linux/of_fdt.h>
|
|
|
|
#include <linux/kernel.h>
|
2018-10-31 06:09:49 +08:00
|
|
|
#include <linux/memblock.h>
|
2013-01-21 05:02:01 +08:00
|
|
|
#include <linux/of_platform.h>
|
|
|
|
#include <linux/of_address.h>
|
|
|
|
|
|
|
|
#include <asm/reboot.h>
|
|
|
|
#include <asm/bootinfo.h>
|
|
|
|
#include <asm/addrspace.h>
|
2013-09-08 03:58:54 +08:00
|
|
|
#include <asm/prom.h>
|
2022-12-17 15:48:06 +08:00
|
|
|
#include <asm/mach-ralink/ralink_regs.h>
|
2013-01-21 05:02:01 +08:00
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
__iomem void *rt_sysc_membase;
|
|
|
|
__iomem void *rt_memc_membase;
|
2021-05-17 08:54:17 +08:00
|
|
|
EXPORT_SYMBOL_GPL(rt_sysc_membase);
|
2013-01-21 05:02:01 +08:00
|
|
|
|
|
|
|
__iomem void *plat_of_remap_node(const char *node)
|
|
|
|
{
|
|
|
|
struct resource res;
|
|
|
|
struct device_node *np;
|
|
|
|
|
|
|
|
np = of_find_compatible_node(NULL, NULL, node);
|
|
|
|
if (!np)
|
|
|
|
panic("Failed to find %s node", node);
|
|
|
|
|
|
|
|
if (of_address_to_resource(np, 0, &res))
|
|
|
|
panic("Failed to get resource for %s", node);
|
|
|
|
|
2022-06-17 11:39:29 +08:00
|
|
|
of_node_put(np);
|
|
|
|
|
2017-01-17 23:18:42 +08:00
|
|
|
if (!request_mem_region(res.start,
|
2013-01-21 05:02:01 +08:00
|
|
|
resource_size(&res),
|
2017-01-17 23:18:42 +08:00
|
|
|
res.name))
|
2013-01-21 05:02:01 +08:00
|
|
|
panic("Failed to request resources for %s", node);
|
|
|
|
|
2020-01-06 16:43:50 +08:00
|
|
|
return ioremap(res.start, resource_size(&res));
|
2013-01-21 05:02:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void __init plat_mem_setup(void)
|
|
|
|
{
|
2021-01-27 21:24:30 +08:00
|
|
|
void *dtb;
|
2016-12-13 18:46:41 +08:00
|
|
|
|
2013-01-21 05:02:01 +08:00
|
|
|
set_io_port_base(KSEG1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load the builtin devicetree. This causes the chosen node to be
|
2021-01-27 21:24:30 +08:00
|
|
|
* parsed resulting in our memory appearing.
|
2013-01-21 05:02:01 +08:00
|
|
|
*/
|
2021-01-27 21:24:30 +08:00
|
|
|
dtb = get_fdt();
|
2016-12-13 18:46:41 +08:00
|
|
|
__dt_setup_arch(dtb);
|
2013-04-13 21:15:51 +08:00
|
|
|
|
2021-12-15 23:01:02 +08:00
|
|
|
if (!early_init_dt_scan_memory())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (soc_info.mem_detect)
|
2021-03-27 13:38:40 +08:00
|
|
|
soc_info.mem_detect();
|
2014-10-09 04:40:02 +08:00
|
|
|
else if (soc_info.mem_size)
|
2020-10-09 20:14:46 +08:00
|
|
|
memblock_add(soc_info.mem_base, soc_info.mem_size * SZ_1M);
|
2013-04-13 21:15:51 +08:00
|
|
|
else
|
|
|
|
detect_memory_region(soc_info.mem_base,
|
|
|
|
soc_info.mem_size_min * SZ_1M,
|
|
|
|
soc_info.mem_size_max * SZ_1M);
|
2013-01-21 05:02:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init plat_of_setup(void)
|
|
|
|
{
|
2014-10-21 12:28:02 +08:00
|
|
|
__dt_register_buses(soc_info.compatible, "palmbus");
|
2013-01-21 05:02:01 +08:00
|
|
|
|
2014-10-21 12:28:02 +08:00
|
|
|
/* make sure that the reset controller is setup early */
|
2022-12-17 15:48:06 +08:00
|
|
|
if (ralink_soc != MT762X_SOC_MT7621AT)
|
|
|
|
ralink_rst_init();
|
2013-09-04 06:16:59 +08:00
|
|
|
|
2013-01-21 05:02:01 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
arch_initcall(plat_of_setup);
|