soc.h 1.6 KB

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