dpu_hw_blk.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _DPU_HW_BLK_H
  13. #define _DPU_HW_BLK_H
  14. #include <linux/types.h>
  15. #include <linux/list.h>
  16. #include <linux/atomic.h>
  17. struct dpu_hw_blk;
  18. /**
  19. * struct dpu_hw_blk_ops - common hardware block operations
  20. * @start: start operation on first get
  21. * @stop: stop operation on last put
  22. */
  23. struct dpu_hw_blk_ops {
  24. int (*start)(struct dpu_hw_blk *);
  25. void (*stop)(struct dpu_hw_blk *);
  26. };
  27. /**
  28. * struct dpu_hw_blk - definition of hardware block object
  29. * @list: list of hardware blocks
  30. * @type: hardware block type
  31. * @id: instance id
  32. * @refcount: reference/usage count
  33. */
  34. struct dpu_hw_blk {
  35. struct list_head list;
  36. u32 type;
  37. int id;
  38. atomic_t refcount;
  39. struct dpu_hw_blk_ops ops;
  40. };
  41. int dpu_hw_blk_init(struct dpu_hw_blk *hw_blk, u32 type, int id,
  42. struct dpu_hw_blk_ops *ops);
  43. void dpu_hw_blk_destroy(struct dpu_hw_blk *hw_blk);
  44. struct dpu_hw_blk *dpu_hw_blk_get(struct dpu_hw_blk *hw_blk, u32 type, int id);
  45. void dpu_hw_blk_put(struct dpu_hw_blk *hw_blk);
  46. #endif /*_DPU_HW_BLK_H */