fdt_ipi_clint.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2020 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. */
  9. #include <sbi/sbi_error.h>
  10. #include <sbi_utils/fdt/fdt_helper.h>
  11. #include <sbi_utils/ipi/fdt_ipi.h>
  12. #include <sbi_utils/sys/clint.h>
  13. #define CLINT_IPI_MAX_NR 16
  14. static unsigned long clint_ipi_count = 0;
  15. static struct clint_data clint_ipi[CLINT_IPI_MAX_NR];
  16. static int ipi_clint_cold_init(void *fdt, int nodeoff,
  17. const struct fdt_match *match)
  18. {
  19. int rc;
  20. struct clint_data *ci;
  21. if (CLINT_IPI_MAX_NR <= clint_ipi_count)
  22. return SBI_ENOSPC;
  23. ci = &clint_ipi[clint_ipi_count++];
  24. rc = fdt_parse_clint_node(fdt, nodeoff, FALSE, ci);
  25. if (rc)
  26. return rc;
  27. return clint_cold_ipi_init(ci);
  28. }
  29. static const struct fdt_match ipi_clint_match[] = {
  30. { .compatible = "riscv,clint0" },
  31. { .compatible = "sifive,clint0" },
  32. { },
  33. };
  34. struct fdt_ipi fdt_ipi_clint = {
  35. .match_table = ipi_clint_match,
  36. .cold_init = ipi_clint_cold_init,
  37. .warm_init = clint_warm_ipi_init,
  38. .exit = NULL,
  39. };