fdt_serial_htif.c 914 B

1234567891011121314151617181920212223242526272829303132333435363738
  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_utils/fdt/fdt_helper.h>
  10. #include <sbi_utils/serial/fdt_serial.h>
  11. #include <sbi_utils/sys/htif.h>
  12. static const struct fdt_match serial_htif_match[] = {
  13. { .compatible = "ucb,htif0" },
  14. { },
  15. };
  16. static int serial_htif_init(void *fdt, int nodeoff,
  17. const struct fdt_match *match)
  18. {
  19. bool custom = false;
  20. uint64_t fromhost_addr = 0, tohost_addr = 0;
  21. if (!fdt_get_node_addr_size(fdt, nodeoff, 0, &fromhost_addr, NULL)) {
  22. custom = true;
  23. tohost_addr = fromhost_addr + sizeof(uint64_t);
  24. }
  25. fdt_get_node_addr_size(fdt, nodeoff, 1, &tohost_addr, NULL);
  26. return htif_serial_init(custom, fromhost_addr, tohost_addr);
  27. }
  28. struct fdt_serial fdt_serial_htif = {
  29. .match_table = serial_htif_match,
  30. .init = serial_htif_init
  31. };