1
2
3
4
5
6#ifndef __SOC_TEGRA_MC_H__
7#define __SOC_TEGRA_MC_H__
8
9#include <linux/bits.h>
10#include <linux/debugfs.h>
11#include <linux/err.h>
12#include <linux/interconnect-provider.h>
13#include <linux/irq.h>
14#include <linux/reset-controller.h>
15#include <linux/types.h>
16
17struct clk;
18struct device;
19struct page;
20
21struct tegra_mc_timing {
22 unsigned long rate;
23
24 u32 *emem_data;
25};
26
27struct tegra_mc_client {
28 unsigned int id;
29 const char *name;
30
31
32
33
34
35 union {
36 unsigned int swgroup;
37 unsigned int sid;
38 };
39
40 unsigned int fifo_size;
41
42 struct {
43
44 struct {
45 unsigned int reg;
46 unsigned int bit;
47 } smmu;
48
49
50 struct {
51 unsigned int reg;
52 unsigned int shift;
53 unsigned int mask;
54 unsigned int def;
55 } la;
56
57
58 struct {
59 unsigned int override;
60 unsigned int security;
61 } sid;
62 } regs;
63};
64
65struct tegra_smmu_swgroup {
66 const char *name;
67 unsigned int swgroup;
68 unsigned int reg;
69};
70
71struct tegra_smmu_group_soc {
72 const char *name;
73 const unsigned int *swgroups;
74 unsigned int num_swgroups;
75};
76
77struct tegra_smmu_soc {
78 const struct tegra_mc_client *clients;
79 unsigned int num_clients;
80
81 const struct tegra_smmu_swgroup *swgroups;
82 unsigned int num_swgroups;
83
84 const struct tegra_smmu_group_soc *groups;
85 unsigned int num_groups;
86
87 bool supports_round_robin_arbitration;
88 bool supports_request_limit;
89
90 unsigned int num_tlb_lines;
91 unsigned int num_asids;
92};
93
94struct tegra_mc;
95struct tegra_smmu;
96struct gart_device;
97
98#ifdef CONFIG_TEGRA_IOMMU_SMMU
99struct tegra_smmu *tegra_smmu_probe(struct device *dev,
100 const struct tegra_smmu_soc *soc,
101 struct tegra_mc *mc);
102void tegra_smmu_remove(struct tegra_smmu *smmu);
103#else
104static inline struct tegra_smmu *
105tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc,
106 struct tegra_mc *mc)
107{
108 return NULL;
109}
110
111static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
112{
113}
114#endif
115
116#ifdef CONFIG_TEGRA_IOMMU_GART
117struct gart_device *tegra_gart_probe(struct device *dev, struct tegra_mc *mc);
118int tegra_gart_suspend(struct gart_device *gart);
119int tegra_gart_resume(struct gart_device *gart);
120#else
121static inline struct gart_device *
122tegra_gart_probe(struct device *dev, struct tegra_mc *mc)
123{
124 return ERR_PTR(-ENODEV);
125}
126
127static inline int tegra_gart_suspend(struct gart_device *gart)
128{
129 return -ENODEV;
130}
131
132static inline int tegra_gart_resume(struct gart_device *gart)
133{
134 return -ENODEV;
135}
136#endif
137
138struct tegra_mc_reset {
139 const char *name;
140 unsigned long id;
141 unsigned int control;
142 unsigned int status;
143 unsigned int reset;
144 unsigned int bit;
145};
146
147struct tegra_mc_reset_ops {
148 int (*hotreset_assert)(struct tegra_mc *mc,
149 const struct tegra_mc_reset *rst);
150 int (*hotreset_deassert)(struct tegra_mc *mc,
151 const struct tegra_mc_reset *rst);
152 int (*block_dma)(struct tegra_mc *mc,
153 const struct tegra_mc_reset *rst);
154 bool (*dma_idling)(struct tegra_mc *mc,
155 const struct tegra_mc_reset *rst);
156 int (*unblock_dma)(struct tegra_mc *mc,
157 const struct tegra_mc_reset *rst);
158 int (*reset_status)(struct tegra_mc *mc,
159 const struct tegra_mc_reset *rst);
160};
161
162#define TEGRA_MC_ICC_TAG_DEFAULT 0
163#define TEGRA_MC_ICC_TAG_ISO BIT(0)
164
165struct tegra_mc_icc_ops {
166 int (*set)(struct icc_node *src, struct icc_node *dst);
167 int (*aggregate)(struct icc_node *node, u32 tag, u32 avg_bw,
168 u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
169 struct icc_node_data *(*xlate_extended)(struct of_phandle_args *spec,
170 void *data);
171};
172
173struct tegra_mc_ops {
174
175
176
177
178 int (*probe)(struct tegra_mc *mc);
179 void (*remove)(struct tegra_mc *mc);
180 int (*suspend)(struct tegra_mc *mc);
181 int (*resume)(struct tegra_mc *mc);
182 irqreturn_t (*handle_irq)(int irq, void *data);
183 int (*probe_device)(struct tegra_mc *mc, struct device *dev);
184};
185
186struct tegra_mc_soc {
187 const struct tegra_mc_client *clients;
188 unsigned int num_clients;
189
190 const unsigned long *emem_regs;
191 unsigned int num_emem_regs;
192
193 unsigned int num_address_bits;
194 unsigned int atom_size;
195
196 u8 client_id_mask;
197
198 const struct tegra_smmu_soc *smmu;
199
200 u32 intmask;
201
202 const struct tegra_mc_reset_ops *reset_ops;
203 const struct tegra_mc_reset *resets;
204 unsigned int num_resets;
205
206 const struct tegra_mc_icc_ops *icc_ops;
207 const struct tegra_mc_ops *ops;
208};
209
210struct tegra_mc {
211 struct device *dev;
212 struct tegra_smmu *smmu;
213 struct gart_device *gart;
214 void __iomem *regs;
215 struct clk *clk;
216 int irq;
217
218 const struct tegra_mc_soc *soc;
219 unsigned long tick;
220
221 struct tegra_mc_timing *timings;
222 unsigned int num_timings;
223
224 struct reset_controller_dev reset;
225
226 struct icc_provider provider;
227
228 spinlock_t lock;
229
230 struct {
231 struct dentry *root;
232 } debugfs;
233};
234
235int tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
236unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
237
238#ifdef CONFIG_TEGRA_MC
239struct tegra_mc *devm_tegra_memory_controller_get(struct device *dev);
240int tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev);
241#else
242static inline struct tegra_mc *
243devm_tegra_memory_controller_get(struct device *dev)
244{
245 return ERR_PTR(-ENODEV);
246}
247
248static inline int
249tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev)
250{
251 return -ENODEV;
252}
253#endif
254
255#endif
256