blob: 1ab2813273cd1cf7d0116ca3d64b08de18013304 [file] [log] [blame]
Thierry Reding89184652014-04-16 09:24:44 +02001/*
2 * Copyright (C) 2014 NVIDIA Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef __SOC_TEGRA_MC_H__
10#define __SOC_TEGRA_MC_H__
11
12#include <linux/types.h>
13
14struct clk;
15struct device;
16struct page;
17
18struct tegra_smmu_enable {
19 unsigned int reg;
20 unsigned int bit;
21};
22
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +010023struct tegra_mc_timing {
24 unsigned long rate;
25
26 u32 *emem_data;
27};
28
Thierry Reding89184652014-04-16 09:24:44 +020029/* latency allowance */
30struct tegra_mc_la {
31 unsigned int reg;
32 unsigned int shift;
33 unsigned int mask;
34 unsigned int def;
35};
36
37struct tegra_mc_client {
38 unsigned int id;
39 const char *name;
40 unsigned int swgroup;
41
42 unsigned int fifo_size;
43
44 struct tegra_smmu_enable smmu;
45 struct tegra_mc_la la;
46};
47
48struct tegra_smmu_swgroup {
Thierry Redinge660df02015-01-23 09:45:35 +010049 const char *name;
Thierry Reding89184652014-04-16 09:24:44 +020050 unsigned int swgroup;
51 unsigned int reg;
52};
53
54struct tegra_smmu_ops {
55 void (*flush_dcache)(struct page *page, unsigned long offset,
56 size_t size);
57};
58
59struct tegra_smmu_soc {
60 const struct tegra_mc_client *clients;
61 unsigned int num_clients;
62
63 const struct tegra_smmu_swgroup *swgroups;
64 unsigned int num_swgroups;
65
66 bool supports_round_robin_arbitration;
67 bool supports_request_limit;
68
69 unsigned int num_asids;
70
71 const struct tegra_smmu_ops *ops;
72};
73
74struct tegra_mc;
75struct tegra_smmu;
76
77#ifdef CONFIG_TEGRA_IOMMU_SMMU
78struct tegra_smmu *tegra_smmu_probe(struct device *dev,
79 const struct tegra_smmu_soc *soc,
80 struct tegra_mc *mc);
Thierry Redingd1313e72015-01-23 09:49:25 +010081void tegra_smmu_remove(struct tegra_smmu *smmu);
Thierry Reding89184652014-04-16 09:24:44 +020082#else
83static inline struct tegra_smmu *
84tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc,
85 struct tegra_mc *mc)
86{
87 return NULL;
88}
Thierry Redingd1313e72015-01-23 09:49:25 +010089
90static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
91{
92}
Thierry Reding89184652014-04-16 09:24:44 +020093#endif
94
95struct tegra_mc_soc {
96 const struct tegra_mc_client *clients;
97 unsigned int num_clients;
98
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +010099 const unsigned long *emem_regs;
Thierry Reding89184652014-04-16 09:24:44 +0200100 unsigned int num_emem_regs;
101
102 unsigned int num_address_bits;
103 unsigned int atom_size;
104
105 const struct tegra_smmu_soc *smmu;
106};
107
108struct tegra_mc {
109 struct device *dev;
110 struct tegra_smmu *smmu;
111 void __iomem *regs;
112 struct clk *clk;
113 int irq;
114
115 const struct tegra_mc_soc *soc;
116 unsigned long tick;
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +0100117
118 struct tegra_mc_timing *timings;
119 unsigned int num_timings;
Thierry Reding89184652014-04-16 09:24:44 +0200120};
121
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +0100122void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
123unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
124
Thierry Reding89184652014-04-16 09:24:44 +0200125#endif /* __SOC_TEGRA_MC_H__ */