adreno_a6xx_rgmu.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __ADRENO_A6XX_RGMU_H
  7. #define __ADRENO_A6XX_RGMU_H
  8. #define RGMU_AO_IRQ_FENCE_ERR BIT(3)
  9. #define RGMU_AO_IRQ_MASK RGMU_AO_IRQ_FENCE_ERR
  10. #define RGMU_OOB_IRQ_ERR_MSG BIT(24)
  11. #define RGMU_OOB_IRQ_ACK_MASK GENMASK(23, 16)
  12. #define RGMU_OOB_IRQ_ERR_MSG_MASK GENMASK(31, 24)
  13. #define RGMU_OOB_IRQ_MASK RGMU_OOB_IRQ_ERR_MSG_MASK
  14. #define MAX_RGMU_CLKS 8
  15. enum {
  16. /* @RGMU_PRIV_FIRST_BOOT_DONE: The very first ggpu boot is done */
  17. RGMU_PRIV_FIRST_BOOT_DONE,
  18. /* @RGMU_PRIV_GPU_STARTED: GPU has been started */
  19. RGMU_PRIV_GPU_STARTED,
  20. /* @RGMU_PRIV_PM_SUSPEND: The rgmu driver is suspended */
  21. RGMU_PRIV_PM_SUSPEND,
  22. };
  23. /**
  24. * struct a6xx_rgmu_device - rGMU device structure
  25. * @ver: RGMU firmware version
  26. * @rgmu_interrupt_num: RGMU interrupt number
  27. * @oob_interrupt_num: number of RGMU asserted OOB interrupt
  28. * @fw_hostptr: Buffer which holds the RGMU firmware
  29. * @fw_size: Size of RGMU firmware buffer
  30. * @clks: RGMU clocks including the GPU
  31. * @gpu_clk: Pointer to GPU core clock
  32. * @rgmu_clk: Pointer to rgmu clock
  33. * @flags: RGMU flags
  34. * @idle_level: Minimal GPU idle power level
  35. * @fault_count: RGMU fault count
  36. */
  37. struct a6xx_rgmu_device {
  38. u32 ver;
  39. struct platform_device *pdev;
  40. unsigned int rgmu_interrupt_num;
  41. unsigned int oob_interrupt_num;
  42. unsigned int *fw_hostptr;
  43. uint32_t fw_size;
  44. struct clk_bulk_data *clks;
  45. /** @num_clks: Number of clocks in @clks */
  46. int num_clks;
  47. struct clk *gpu_clk;
  48. struct clk *rgmu_clk;
  49. unsigned int idle_level;
  50. unsigned int fault_count;
  51. /** @flags: rgmu internal flags */
  52. unsigned long flags;
  53. /** @num_oob_perfcntr: Number of active oob_perfcntr requests */
  54. u32 num_oob_perfcntr;
  55. };
  56. /**
  57. * a6xx_rgmu_device_probe - Probe a6xx rgmu resources
  58. * @pdev: Pointer to the platform device
  59. * @chipid: Chipid of the target
  60. * @gpucore: Pointer to the gpucore
  61. *
  62. * The target specific probe function for rgmu based a6xx targets.
  63. */
  64. int a6xx_rgmu_device_probe(struct platform_device *pdev,
  65. u32 chipid, const struct adreno_gpu_core *gpucore);
  66. /**
  67. * a6xx_rgmu_reset - Reset and restart the rgmu
  68. * @adreno_dev: Pointer to the adreno device
  69. *
  70. * Return: 0 on success or negative error on failure
  71. */
  72. int a6xx_rgmu_reset(struct adreno_device *adreno_dev);
  73. /**
  74. * a6xx_rgmu_snapshot - Take snapshot for rgmu based targets
  75. * @adreno_dev: Pointer to the adreno device
  76. * @snapshot: Pointer to the snapshot
  77. *
  78. * This function halts rgmu execution if we hit a rgmu
  79. * fault. And then, it takes rgmu and gpu snapshot.
  80. */
  81. void a6xx_rgmu_snapshot(struct adreno_device *adreno_dev,
  82. struct kgsl_snapshot *snapshot);
  83. /**
  84. * a6xx_rgmu_add_to_minidump - Register a6xx_device with va minidump
  85. * @adreno_dev: Pointer to the adreno device
  86. */
  87. int a6xx_rgmu_add_to_minidump(struct adreno_device *adreno_dev);
  88. /**
  89. * a6xx_rgmu_gx_is_on() - Check if GX is on using pwr status register
  90. * @adreno_dev: Pointer to the adreno device
  91. *
  92. * This check should only be performed if the keepalive bit is set or it
  93. * can be guaranteed that the power state of the GPU will remain unchanged
  94. */
  95. bool a6xx_rgmu_gx_is_on(struct adreno_device *adreno_dev);
  96. #endif