18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2020 Western Digital Corporation or its affiliates. 48c2ecf20Sopenharmony_ci * Copyright (C) 2020 Google, Inc 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef _ASM_RISCV_SOC_H 88c2ecf20Sopenharmony_ci#define _ASM_RISCV_SOC_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/of.h> 118c2ecf20Sopenharmony_ci#include <linux/linkage.h> 128c2ecf20Sopenharmony_ci#include <linux/types.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define SOC_EARLY_INIT_DECLARE(name, compat, fn) \ 158c2ecf20Sopenharmony_ci static const struct of_device_id __soc_early_init__##name \ 168c2ecf20Sopenharmony_ci __used __section("__soc_early_init_table") \ 178c2ecf20Sopenharmony_ci = { .compatible = compat, .data = fn } 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_civoid soc_early_init(void); 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciextern unsigned long __soc_early_init_table_start; 228c2ecf20Sopenharmony_ciextern unsigned long __soc_early_init_table_end; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* 258c2ecf20Sopenharmony_ci * Allows Linux to provide a device tree, which is necessary for SOCs that 268c2ecf20Sopenharmony_ci * don't provide a useful one on their own. 278c2ecf20Sopenharmony_ci */ 288c2ecf20Sopenharmony_cistruct soc_builtin_dtb { 298c2ecf20Sopenharmony_ci unsigned long vendor_id; 308c2ecf20Sopenharmony_ci unsigned long arch_id; 318c2ecf20Sopenharmony_ci unsigned long imp_id; 328c2ecf20Sopenharmony_ci void *(*dtb_func)(void); 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* 368c2ecf20Sopenharmony_ci * The argument name must specify a valid DTS file name without the dts 378c2ecf20Sopenharmony_ci * extension. 388c2ecf20Sopenharmony_ci */ 398c2ecf20Sopenharmony_ci#define SOC_BUILTIN_DTB_DECLARE(name, vendor, arch, impl) \ 408c2ecf20Sopenharmony_ci extern void *__dtb_##name##_begin; \ 418c2ecf20Sopenharmony_ci \ 428c2ecf20Sopenharmony_ci static __init __used \ 438c2ecf20Sopenharmony_ci void *__soc_builtin_dtb_f__##name(void) \ 448c2ecf20Sopenharmony_ci { \ 458c2ecf20Sopenharmony_ci return (void *)&__dtb_##name##_begin; \ 468c2ecf20Sopenharmony_ci } \ 478c2ecf20Sopenharmony_ci \ 488c2ecf20Sopenharmony_ci static const struct soc_builtin_dtb __soc_builtin_dtb__##name \ 498c2ecf20Sopenharmony_ci __used __section("__soc_builtin_dtb_table") = \ 508c2ecf20Sopenharmony_ci { \ 518c2ecf20Sopenharmony_ci .vendor_id = vendor, \ 528c2ecf20Sopenharmony_ci .arch_id = arch, \ 538c2ecf20Sopenharmony_ci .imp_id = impl, \ 548c2ecf20Sopenharmony_ci .dtb_func = __soc_builtin_dtb_f__##name, \ 558c2ecf20Sopenharmony_ci } 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciextern unsigned long __soc_builtin_dtb_table_start; 588c2ecf20Sopenharmony_ciextern unsigned long __soc_builtin_dtb_table_end; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_civoid *soc_lookup_builtin_dtb(void); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#endif 63