ocmem.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * The On Chip Memory (OCMEM) allocator allows various clients to allocate
  4. * memory from OCMEM based on performance, latency and power requirements.
  5. * This is typically used by the GPU, camera/video, and audio components on
  6. * some Snapdragon SoCs.
  7. *
  8. * Copyright (C) 2019 Brian Masney <[email protected]>
  9. * Copyright (C) 2015 Red Hat. Author: Rob Clark <[email protected]>
  10. */
  11. #include <linux/device.h>
  12. #include <linux/err.h>
  13. #ifndef __OCMEM_H__
  14. #define __OCMEM_H__
  15. enum ocmem_client {
  16. /* GMEM clients */
  17. OCMEM_GRAPHICS = 0x0,
  18. /*
  19. * TODO add more once ocmem_allocate() is clever enough to
  20. * deal with multiple clients.
  21. */
  22. OCMEM_CLIENT_MAX,
  23. };
  24. struct ocmem;
  25. struct ocmem_buf {
  26. unsigned long offset;
  27. unsigned long addr;
  28. unsigned long len;
  29. };
  30. #if IS_ENABLED(CONFIG_QCOM_OCMEM)
  31. struct ocmem *of_get_ocmem(struct device *dev);
  32. struct ocmem_buf *ocmem_allocate(struct ocmem *ocmem, enum ocmem_client client,
  33. unsigned long size);
  34. void ocmem_free(struct ocmem *ocmem, enum ocmem_client client,
  35. struct ocmem_buf *buf);
  36. #else /* IS_ENABLED(CONFIG_QCOM_OCMEM) */
  37. static inline struct ocmem *of_get_ocmem(struct device *dev)
  38. {
  39. return ERR_PTR(-ENODEV);
  40. }
  41. static inline struct ocmem_buf *ocmem_allocate(struct ocmem *ocmem,
  42. enum ocmem_client client,
  43. unsigned long size)
  44. {
  45. return ERR_PTR(-ENODEV);
  46. }
  47. static inline void ocmem_free(struct ocmem *ocmem, enum ocmem_client client,
  48. struct ocmem_buf *buf)
  49. {
  50. }
  51. #endif /* IS_ENABLED(CONFIG_QCOM_OCMEM) */
  52. #endif /* __OCMEM_H__ */