msm_gpu.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __MSM_GPU_H__
  18. #define __MSM_GPU_H__
  19. #include <linux/clk.h>
  20. #include <linux/regulator/consumer.h>
  21. #include "msm_drv.h"
  22. #include "msm_ringbuffer.h"
  23. struct msm_gem_submit;
  24. /* So far, with hardware that I've seen to date, we can have:
  25. * + zero, one, or two z180 2d cores
  26. * + a3xx or a2xx 3d core, which share a common CP (the firmware
  27. * for the CP seems to implement some different PM4 packet types
  28. * but the basics of cmdstream submission are the same)
  29. *
  30. * Which means that the eventual complete "class" hierarchy, once
  31. * support for all past and present hw is in place, becomes:
  32. * + msm_gpu
  33. * + adreno_gpu
  34. * + a3xx_gpu
  35. * + a2xx_gpu
  36. * + z180_gpu
  37. */
  38. struct msm_gpu_funcs {
  39. int (*get_param)(struct msm_gpu *gpu, uint32_t param, uint64_t *value);
  40. int (*hw_init)(struct msm_gpu *gpu);
  41. int (*pm_suspend)(struct msm_gpu *gpu);
  42. int (*pm_resume)(struct msm_gpu *gpu);
  43. int (*submit)(struct msm_gpu *gpu, struct msm_gem_submit *submit,
  44. struct msm_file_private *ctx);
  45. void (*flush)(struct msm_gpu *gpu);
  46. void (*idle)(struct msm_gpu *gpu);
  47. irqreturn_t (*irq)(struct msm_gpu *irq);
  48. uint32_t (*last_fence)(struct msm_gpu *gpu);
  49. void (*destroy)(struct msm_gpu *gpu);
  50. #ifdef CONFIG_DEBUG_FS
  51. /* show GPU status in debugfs: */
  52. void (*show)(struct msm_gpu *gpu, struct seq_file *m);
  53. #endif
  54. };
  55. struct msm_gpu {
  56. const char *name;
  57. struct drm_device *dev;
  58. const struct msm_gpu_funcs *funcs;
  59. struct msm_ringbuffer *rb;
  60. uint32_t rb_iova;
  61. /* list of GEM active objects: */
  62. struct list_head active_list;
  63. /* worker for handling active-list retiring: */
  64. struct work_struct retire_work;
  65. void __iomem *mmio;
  66. int irq;
  67. struct iommu_domain *iommu;
  68. int id;
  69. /* Power Control: */
  70. struct regulator *gpu_reg, *gpu_cx;
  71. struct clk *ebi1_clk, *grp_clks[5];
  72. uint32_t fast_rate, slow_rate, bus_freq;
  73. uint32_t bsc;
  74. };
  75. static inline void gpu_write(struct msm_gpu *gpu, u32 reg, u32 data)
  76. {
  77. msm_writel(data, gpu->mmio + (reg << 2));
  78. }
  79. static inline u32 gpu_read(struct msm_gpu *gpu, u32 reg)
  80. {
  81. return msm_readl(gpu->mmio + (reg << 2));
  82. }
  83. int msm_gpu_pm_suspend(struct msm_gpu *gpu);
  84. int msm_gpu_pm_resume(struct msm_gpu *gpu);
  85. void msm_gpu_retire(struct msm_gpu *gpu);
  86. int msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
  87. struct msm_file_private *ctx);
  88. int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
  89. struct msm_gpu *gpu, const struct msm_gpu_funcs *funcs,
  90. const char *name, const char *ioname, const char *irqname, int ringsz);
  91. void msm_gpu_cleanup(struct msm_gpu *gpu);
  92. struct msm_gpu *a3xx_gpu_init(struct drm_device *dev);
  93. void __init a3xx_register(void);
  94. void __exit a3xx_unregister(void);
  95. #endif /* __MSM_GPU_H__ */