syscon.h 987 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-02-25 GuEe-GUI the first version
  9. */
  10. #ifndef __SYSCON_H__
  11. #define __SYSCON_H__
  12. #include <drivers/ofw.h>
  13. struct rt_syscon
  14. {
  15. rt_list_t list;
  16. struct rt_ofw_node *np;
  17. void *iomem_base;
  18. rt_size_t iomem_size;
  19. struct rt_spinlock rw_lock;
  20. };
  21. rt_err_t rt_syscon_read(struct rt_syscon *syscon, rt_off_t offset, rt_uint32_t *out_val);
  22. rt_err_t rt_syscon_write(struct rt_syscon *syscon, rt_off_t offset, rt_uint32_t val);
  23. rt_err_t rt_syscon_update_bits(struct rt_syscon *syscon, rt_off_t offset, rt_uint32_t mask, rt_uint32_t val);
  24. struct rt_syscon *rt_syscon_find_by_ofw_node(struct rt_ofw_node *np);
  25. struct rt_syscon *rt_syscon_find_by_ofw_compatible(const char *compatible);
  26. struct rt_syscon *rt_syscon_find_by_ofw_phandle(struct rt_ofw_node *np, const char *propname);
  27. #endif /* __SYSCON_H__ */