1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2014 NVIDIA Corporation
6 #ifndef __SOC_TEGRA_MC_H__
7 #define __SOC_TEGRA_MC_H__
9 #include <linux/bits.h>
10 #include <linux/debugfs.h>
11 #include <linux/err.h>
12 #include <linux/interconnect-provider.h>
13 #include <linux/reset-controller.h>
14 #include <linux/types.h>
20 struct tegra_mc_timing {
26 struct tegra_mc_client {
30 * For Tegra210 and earlier, this is the SWGROUP ID used for IOVA translations in the
31 * Tegra SMMU, whereas on Tegra186 and later this is the ID used to override the ARM SMMU
32 * stream ID used for IOVA translations for the given memory client.
39 unsigned int fifo_size;
42 /* Tegra SMMU enable (Tegra210 and earlier) */
48 /* latency allowance */
56 /* stream ID overrides (Tegra186 and later) */
58 unsigned int override;
59 unsigned int security;
64 struct tegra_smmu_swgroup {
70 struct tegra_smmu_group_soc {
72 const unsigned int *swgroups;
73 unsigned int num_swgroups;
76 struct tegra_smmu_soc {
77 const struct tegra_mc_client *clients;
78 unsigned int num_clients;
80 const struct tegra_smmu_swgroup *swgroups;
81 unsigned int num_swgroups;
83 const struct tegra_smmu_group_soc *groups;
84 unsigned int num_groups;
86 bool supports_round_robin_arbitration;
87 bool supports_request_limit;
89 unsigned int num_tlb_lines;
90 unsigned int num_asids;
97 #ifdef CONFIG_TEGRA_IOMMU_SMMU
98 struct tegra_smmu *tegra_smmu_probe(struct device *dev,
99 const struct tegra_smmu_soc *soc,
100 struct tegra_mc *mc);
101 void tegra_smmu_remove(struct tegra_smmu *smmu);
103 static inline struct tegra_smmu *
104 tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc,
110 static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
115 #ifdef CONFIG_TEGRA_IOMMU_GART
116 struct gart_device *tegra_gart_probe(struct device *dev, struct tegra_mc *mc);
117 int tegra_gart_suspend(struct gart_device *gart);
118 int tegra_gart_resume(struct gart_device *gart);
120 static inline struct gart_device *
121 tegra_gart_probe(struct device *dev, struct tegra_mc *mc)
123 return ERR_PTR(-ENODEV);
126 static inline int tegra_gart_suspend(struct gart_device *gart)
131 static inline int tegra_gart_resume(struct gart_device *gart)
137 struct tegra_mc_reset {
140 unsigned int control;
146 struct tegra_mc_reset_ops {
147 int (*hotreset_assert)(struct tegra_mc *mc,
148 const struct tegra_mc_reset *rst);
149 int (*hotreset_deassert)(struct tegra_mc *mc,
150 const struct tegra_mc_reset *rst);
151 int (*block_dma)(struct tegra_mc *mc,
152 const struct tegra_mc_reset *rst);
153 bool (*dma_idling)(struct tegra_mc *mc,
154 const struct tegra_mc_reset *rst);
155 int (*unblock_dma)(struct tegra_mc *mc,
156 const struct tegra_mc_reset *rst);
157 int (*reset_status)(struct tegra_mc *mc,
158 const struct tegra_mc_reset *rst);
161 #define TEGRA_MC_ICC_TAG_DEFAULT 0
162 #define TEGRA_MC_ICC_TAG_ISO BIT(0)
164 struct tegra_mc_icc_ops {
165 int (*set)(struct icc_node *src, struct icc_node *dst);
166 int (*aggregate)(struct icc_node *node, u32 tag, u32 avg_bw,
167 u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
168 struct icc_node_data *(*xlate_extended)(struct of_phandle_args *spec,
172 struct tegra_mc_ops {
173 int (*init)(struct tegra_mc *mc);
174 int (*suspend)(struct tegra_mc *mc);
175 int (*resume)(struct tegra_mc *mc);
178 struct tegra_mc_soc {
179 const struct tegra_mc_client *clients;
180 unsigned int num_clients;
182 const unsigned long *emem_regs;
183 unsigned int num_emem_regs;
185 unsigned int num_address_bits;
186 unsigned int atom_size;
190 const struct tegra_smmu_soc *smmu;
194 const struct tegra_mc_reset_ops *reset_ops;
195 const struct tegra_mc_reset *resets;
196 unsigned int num_resets;
198 const struct tegra_mc_icc_ops *icc_ops;
199 const struct tegra_mc_ops *ops;
204 struct tegra_smmu *smmu;
205 struct gart_device *gart;
210 const struct tegra_mc_soc *soc;
213 struct tegra_mc_timing *timings;
214 unsigned int num_timings;
216 struct reset_controller_dev reset;
218 struct icc_provider provider;
227 int tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
228 unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
230 #ifdef CONFIG_TEGRA_MC
231 struct tegra_mc *devm_tegra_memory_controller_get(struct device *dev);
233 static inline struct tegra_mc *
234 devm_tegra_memory_controller_get(struct device *dev)
236 return ERR_PTR(-ENODEV);
240 #endif /* __SOC_TEGRA_MC_H__ */