1 // SPDX-License-Identifier: GPL-2.0-only
3 // Copyright (C) 2019 Socionext Inc.
4 // Author: Masahiro Yamada <yamada.masahiro@socionext.com>
8 #include <fdt_support.h>
10 #include <linux/libfdt.h>
11 #include <linux/sizes.h>
12 #include <asm/global_data.h>
14 #include "base-address.h"
15 #include "sc64-regs.h"
19 * Dummy initializers are needed to allocate these to .data section instead of
20 * .bss section. The .bss section is unusable before relocation because the
21 * .bss section and DT share the same address. Without the initializers,
24 void __iomem *sc_base = (void *)0xdeadbeef;
25 void __iomem *sg_base = (void *)0xdeadbeef;
27 static u64 uniphier_base_address_get(const char *compat_tail)
29 DECLARE_GLOBAL_DATA_PTR;
30 const void *fdt = gd->fdt_blob;
34 for (offset = fdt_next_node(fdt, 0, NULL);
36 offset = fdt_next_node(fdt, offset, NULL)) {
38 (str = fdt_stringlist_get(fdt, offset, "compatible", i, &len));
40 if (!memcmp(compat_tail,
41 str + len - strlen(compat_tail),
43 return fdt_get_base_address(fdt, offset);
50 int uniphier_base_address_init(void)
54 base = uniphier_base_address_get("-soc-glue");
55 if (base == OF_BAD_ADDR)
58 sg_base = ioremap(base, SZ_8K);
60 base = uniphier_base_address_get("-sysctrl");
61 if (base == OF_BAD_ADDR)
64 sc_base = ioremap(base, SZ_64K);