rpmsg_platform.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2016 Freescale Semiconductor, Inc.
  3. * Copyright 2016-2022 NXP
  4. * All rights reserved.
  5. *
  6. *
  7. * SPDX-License-Identifier: BSD-3-Clause
  8. */
  9. #ifndef RPMSG_PLATFORM_H_
  10. #define RPMSG_PLATFORM_H_
  11. #include <stdint.h>
  12. /*
  13. * No need to align the VRING as defined in Linux because imxrt1160 is not intended
  14. * to run the Linux
  15. */
  16. #ifndef VRING_ALIGN
  17. #define VRING_ALIGN (0x10U)
  18. #endif
  19. /* contains pool of descriptors and two circular buffers */
  20. #ifndef VRING_SIZE
  21. /* set VRING_SIZE based on number of used buffers as calculated in vring_init */
  22. #define VRING_DESC_SIZE (((RL_BUFFER_COUNT * sizeof(struct vring_desc)) + VRING_ALIGN - 1UL) & ~(VRING_ALIGN - 1UL))
  23. #define VRING_AVAIL_SIZE \
  24. (((sizeof(struct vring_avail) + (RL_BUFFER_COUNT * sizeof(uint16_t)) + sizeof(uint16_t)) + VRING_ALIGN - 1UL) & \
  25. ~(VRING_ALIGN - 1UL))
  26. #define VRING_USED_SIZE \
  27. (((sizeof(struct vring_used) + (RL_BUFFER_COUNT * sizeof(struct vring_used_elem)) + sizeof(uint16_t)) + \
  28. VRING_ALIGN - 1UL) & \
  29. ~(VRING_ALIGN - 1UL))
  30. #define VRING_SIZE (VRING_DESC_SIZE + VRING_AVAIL_SIZE + VRING_USED_SIZE)
  31. #endif
  32. /* define shared memory space for VRINGS per one channel */
  33. #define RL_VRING_OVERHEAD (2UL * VRING_SIZE)
  34. #define RL_GET_VQ_ID(link_id, queue_id) (((queue_id)&0x1U) | (((link_id) << 1U) & 0xFFFFFFFEU))
  35. #define RL_GET_LINK_ID(id) (((id)&0xFFFFFFFEU) >> 1U)
  36. #define RL_GET_Q_ID(id) ((id)&0x1U)
  37. #define RL_PLATFORM_IMXRT1160_M7_M4_LINK_ID (0U)
  38. #define RL_PLATFORM_HIGHEST_LINK_ID (0U)
  39. /* platform interrupt related functions */
  40. int32_t platform_init_interrupt(uint32_t vector_id, void *isr_data);
  41. int32_t platform_deinit_interrupt(uint32_t vector_id);
  42. int32_t platform_interrupt_enable(uint32_t vector_id);
  43. int32_t platform_interrupt_disable(uint32_t vector_id);
  44. int32_t platform_in_isr(void);
  45. void platform_notify(uint32_t vector_id);
  46. /* platform low-level time-delay (busy loop) */
  47. void platform_time_delay(uint32_t num_msec);
  48. /* platform memory functions */
  49. void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags);
  50. void platform_cache_all_flush_invalidate(void);
  51. void platform_cache_disable(void);
  52. uintptr_t platform_vatopa(void *addr);
  53. void *platform_patova(uintptr_t addr);
  54. /* platform init/deinit */
  55. int32_t platform_init(void);
  56. int32_t platform_deinit(void);
  57. #endif /* RPMSG_PLATFORM_H_ */