^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2020 Western Digital Corporation or its affiliates.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2020 Google, Inc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef _ASM_RISCV_SOC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define _ASM_RISCV_SOC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define SOC_EARLY_INIT_DECLARE(name, compat, fn) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static const struct of_device_id __soc_early_init__##name \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) __used __section("__soc_early_init_table") \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) = { .compatible = compat, .data = fn }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) void soc_early_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) extern unsigned long __soc_early_init_table_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) extern unsigned long __soc_early_init_table_end;
^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) * Allows Linux to provide a device tree, which is necessary for SOCs that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * don't provide a useful one on their own.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct soc_builtin_dtb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) unsigned long vendor_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned long arch_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) unsigned long imp_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) void *(*dtb_func)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * The argument name must specify a valid DTS file name without the dts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * extension.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define SOC_BUILTIN_DTB_DECLARE(name, vendor, arch, impl) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) extern void *__dtb_##name##_begin; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static __init __used \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) void *__soc_builtin_dtb_f__##name(void) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) return (void *)&__dtb_##name##_begin; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static const struct soc_builtin_dtb __soc_builtin_dtb__##name \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) __used __section("__soc_builtin_dtb_table") = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) .vendor_id = vendor, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) .arch_id = arch, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) .imp_id = impl, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) .dtb_func = __soc_builtin_dtb_f__##name, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) extern unsigned long __soc_builtin_dtb_table_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) extern unsigned long __soc_builtin_dtb_table_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) void *soc_lookup_builtin_dtb(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #endif