1
2
3
4#ifndef _A6XX_GMU_H_
5#define _A6XX_GMU_H_
6
7#include <linux/interrupt.h>
8#include "msm_drv.h"
9#include "a6xx_hfi.h"
10
11struct a6xx_gmu_bo {
12 void *virt;
13 size_t size;
14 u64 iova;
15 struct page **pages;
16};
17
18
19
20
21
22
23
24#define GMU_WARM_BOOT 0
25
26
27#define GMU_COLD_BOOT 1
28
29
30#define GMU_RESET 2
31
32
33
34
35
36
37
38#define GMU_IDLE_STATE_ACTIVE 0
39
40
41#define GMU_IDLE_STATE_SPTP 2
42
43
44#define GMU_IDLE_STATE_IFPC 3
45
46struct a6xx_gmu {
47 struct device *dev;
48
49 void * __iomem mmio;
50 void * __iomem pdc_mmio;
51
52 int hfi_irq;
53 int gmu_irq;
54
55 struct regulator *gx;
56
57 struct iommu_domain *domain;
58 u64 uncached_iova_base;
59
60 int idle_level;
61
62 struct a6xx_gmu_bo *hfi;
63 struct a6xx_gmu_bo *debug;
64
65 int nr_clocks;
66 struct clk_bulk_data *clocks;
67 struct clk *core_clk;
68
69 int nr_gpu_freqs;
70 unsigned long gpu_freqs[16];
71 u32 gx_arc_votes[16];
72
73 int nr_gmu_freqs;
74 unsigned long gmu_freqs[4];
75 u32 cx_arc_votes[4];
76
77 struct a6xx_hfi_queue queues[2];
78
79 struct tasklet_struct hfi_tasklet;
80};
81
82static inline u32 gmu_read(struct a6xx_gmu *gmu, u32 offset)
83{
84 return msm_readl(gmu->mmio + (offset << 2));
85}
86
87static inline void gmu_write(struct a6xx_gmu *gmu, u32 offset, u32 value)
88{
89 return msm_writel(value, gmu->mmio + (offset << 2));
90}
91
92static inline void pdc_write(struct a6xx_gmu *gmu, u32 offset, u32 value)
93{
94 return msm_writel(value, gmu->pdc_mmio + (offset << 2));
95}
96
97static inline void gmu_rmw(struct a6xx_gmu *gmu, u32 reg, u32 mask, u32 or)
98{
99 u32 val = gmu_read(gmu, reg);
100
101 val &= ~mask;
102
103 gmu_write(gmu, reg, val | or);
104}
105
106#define gmu_poll_timeout(gmu, addr, val, cond, interval, timeout) \
107 readl_poll_timeout((gmu)->mmio + ((addr) << 2), val, cond, \
108 interval, timeout)
109
110
111
112
113
114
115
116
117
118
119
120
121enum a6xx_gmu_oob_state {
122 GMU_OOB_BOOT_SLUMBER = 0,
123 GMU_OOB_GPU_SET,
124 GMU_OOB_DCVS_SET,
125};
126
127
128
129
130
131
132
133
134
135
136#define GMU_OOB_BOOT_SLUMBER_REQUEST 22
137#define GMU_OOB_BOOT_SLUMBER_ACK 30
138#define GMU_OOB_BOOT_SLUMBER_CLEAR 30
139
140
141
142
143#define GMU_OOB_DCVS_REQUEST 23
144#define GMU_OOB_DCVS_ACK 31
145#define GMU_OOB_DCVS_CLEAR 31
146
147
148
149
150
151#define GMU_OOB_GPU_SET_REQUEST 16
152#define GMU_OOB_GPU_SET_ACK 24
153#define GMU_OOB_GPU_SET_CLEAR 24
154
155
156void a6xx_hfi_init(struct a6xx_gmu *gmu);
157int a6xx_hfi_start(struct a6xx_gmu *gmu, int boot_state);
158void a6xx_hfi_stop(struct a6xx_gmu *gmu);
159
160void a6xx_hfi_task(unsigned long data);
161
162#endif
163