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/irq.h>
14 #include <linux/reset-controller.h>
15 #include <linux/types.h>
21 struct tegra_mc_timing {
27 struct tegra_mc_client {
31 * For Tegra210 and earlier, this is the SWGROUP ID used for IOVA translations in the
32 * Tegra SMMU, whereas on Tegra186 and later this is the ID used to override the ARM SMMU
33 * stream ID used for IOVA translations for the given memory client.
40 unsigned int fifo_size;
43 /* Tegra SMMU enable (Tegra210 and earlier) */
49 /* latency allowance */
57 /* stream ID overrides (Tegra186 and later) */
59 unsigned int override;
60 unsigned int security;
65 struct tegra_smmu_swgroup {
71 struct tegra_smmu_group_soc {
73 const unsigned int *swgroups;
74 unsigned int num_swgroups;
77 struct tegra_smmu_soc {
78 const struct tegra_mc_client *clients;
79 unsigned int num_clients;
81 const struct tegra_smmu_swgroup *swgroups;
82 unsigned int num_swgroups;
84 const struct tegra_smmu_group_soc *groups;
85 unsigned int num_groups;
87 bool supports_round_robin_arbitration;
88 bool supports_request_limit;
90 unsigned int num_tlb_lines;
91 unsigned int num_asids;
98 #ifdef CONFIG_TEGRA_IOMMU_SMMU
99 struct tegra_smmu *tegra_smmu_probe(struct device *dev,
100 const struct tegra_smmu_soc *soc,
101 struct tegra_mc *mc);
102 void tegra_smmu_remove(struct tegra_smmu *smmu);
104 static inline struct tegra_smmu *
105 tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc,
111 static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
116 #ifdef CONFIG_TEGRA_IOMMU_GART
117 struct gart_device *tegra_gart_probe(struct device *dev, struct tegra_mc *mc);
118 int tegra_gart_suspend(struct gart_device *gart);
119 int tegra_gart_resume(struct gart_device *gart);
121 static inline struct gart_device *
122 tegra_gart_probe(struct device *dev, struct tegra_mc *mc)
124 return ERR_PTR(-ENODEV);
127 static inline int tegra_gart_suspend(struct gart_device *gart)
132 static inline int tegra_gart_resume(struct gart_device *gart)
138 struct tegra_mc_reset {
141 unsigned int control;
147 struct 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);
162 #define TEGRA_MC_ICC_TAG_DEFAULT 0
163 #define TEGRA_MC_ICC_TAG_ISO BIT(0)
165 struct 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,
173 struct tegra_mc_ops {
175 * @probe: Callback to set up SoC-specific bits of the memory controller. This is called
176 * after basic, common set up that is done by the SoC-agnostic bits.
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);
186 struct tegra_mc_soc {
187 const struct tegra_mc_client *clients;
188 unsigned int num_clients;
190 const unsigned long *emem_regs;
191 unsigned int num_emem_regs;
193 unsigned int num_address_bits;
194 unsigned int atom_size;
198 const struct tegra_smmu_soc *smmu;
202 const struct tegra_mc_reset_ops *reset_ops;
203 const struct tegra_mc_reset *resets;
204 unsigned int num_resets;
206 const struct tegra_mc_icc_ops *icc_ops;
207 const struct tegra_mc_ops *ops;
212 struct tegra_smmu *smmu;
213 struct gart_device *gart;
218 const struct tegra_mc_soc *soc;
221 struct tegra_mc_timing *timings;
222 unsigned int num_timings;
224 struct reset_controller_dev reset;
226 struct icc_provider provider;
235 int tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
236 unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
238 #ifdef CONFIG_TEGRA_MC
239 struct tegra_mc *devm_tegra_memory_controller_get(struct device *dev);
241 static inline struct tegra_mc *
242 devm_tegra_memory_controller_get(struct device *dev)
244 return ERR_PTR(-ENODEV);
248 int tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev);
250 #endif /* __SOC_TEGRA_MC_H__ */