fdt_helper.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // SPDX-License-Identifier: BSD-2-Clause
  2. /*
  3. * fdt_helper.h - Flat Device Tree parsing helper routines
  4. * Implement helper routines to parse FDT nodes on top of
  5. * libfdt for OpenSBI usage
  6. *
  7. * Copyright (C) 2020 Bin Meng <bmeng.cn@gmail.com>
  8. */
  9. #ifndef __FDT_HELPER_H__
  10. #define __FDT_HELPER_H__
  11. #include <sbi/sbi_types.h>
  12. struct fdt_match {
  13. const char *compatible;
  14. void *data;
  15. };
  16. struct platform_uart_data {
  17. unsigned long addr;
  18. unsigned long freq;
  19. unsigned long baud;
  20. unsigned long reg_shift;
  21. unsigned long reg_io_width;
  22. };
  23. const struct fdt_match *fdt_match_node(void *fdt, int nodeoff,
  24. const struct fdt_match *match_table);
  25. int fdt_find_match(void *fdt, int startoff,
  26. const struct fdt_match *match_table,
  27. const struct fdt_match **out_match);
  28. int fdt_get_node_addr_size(void *fdt, int node, unsigned long *addr,
  29. unsigned long *size);
  30. int fdt_parse_hart_id(void *fdt, int cpu_offset, u32 *hartid);
  31. int fdt_parse_max_hart_id(void *fdt, u32 *max_hartid);
  32. int fdt_parse_shakti_uart_node(void *fdt, int nodeoffset,
  33. struct platform_uart_data *uart);
  34. int fdt_parse_sifive_uart_node(void *fdt, int nodeoffset,
  35. struct platform_uart_data *uart);
  36. int fdt_parse_uart8250_node(void *fdt, int nodeoffset,
  37. struct platform_uart_data *uart);
  38. int fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,
  39. const char *compatible);
  40. struct plic_data;
  41. int fdt_parse_plic_node(void *fdt, int nodeoffset, struct plic_data *plic);
  42. int fdt_parse_plic(void *fdt, struct plic_data *plic, const char *compat);
  43. struct clint_data;
  44. int fdt_parse_clint_node(void *fdt, int nodeoffset, bool for_timer,
  45. struct clint_data *clint);
  46. int fdt_parse_compat_addr(void *fdt, unsigned long *addr,
  47. const char *compatible);
  48. #endif /* __FDT_HELPER_H__ */