blob: d6c3190ec852edd2c9e52c535703c2e429e52089 [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
Thierry Reding89184652014-04-16 09:24:44 +020054struct tegra_smmu_soc {
55 const struct tegra_mc_client *clients;
56 unsigned int num_clients;
57
58 const struct tegra_smmu_swgroup *swgroups;
59 unsigned int num_swgroups;
60
61 bool supports_round_robin_arbitration;
62 bool supports_request_limit;
63
64 unsigned int num_asids;
Thierry Reding89184652014-04-16 09:24:44 +020065};
66
67struct tegra_mc;
68struct tegra_smmu;
69
70#ifdef CONFIG_TEGRA_IOMMU_SMMU
71struct tegra_smmu *tegra_smmu_probe(struct device *dev,
72 const struct tegra_smmu_soc *soc,
73 struct tegra_mc *mc);
Thierry Redingd1313e72015-01-23 09:49:25 +010074void tegra_smmu_remove(struct tegra_smmu *smmu);
Thierry Reding89184652014-04-16 09:24:44 +020075#else
76static inline struct tegra_smmu *
77tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc,
78 struct tegra_mc *mc)
79{
80 return NULL;
81}
Thierry Redingd1313e72015-01-23 09:49:25 +010082
83static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
84{
85}
Thierry Reding89184652014-04-16 09:24:44 +020086#endif
87
88struct tegra_mc_soc {
89 const struct tegra_mc_client *clients;
90 unsigned int num_clients;
91
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +010092 const unsigned long *emem_regs;
Thierry Reding89184652014-04-16 09:24:44 +020093 unsigned int num_emem_regs;
94
95 unsigned int num_address_bits;
96 unsigned int atom_size;
97
98 const struct tegra_smmu_soc *smmu;
99};
100
101struct tegra_mc {
102 struct device *dev;
103 struct tegra_smmu *smmu;
104 void __iomem *regs;
105 struct clk *clk;
106 int irq;
107
108 const struct tegra_mc_soc *soc;
109 unsigned long tick;
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +0100110
111 struct tegra_mc_timing *timings;
112 unsigned int num_timings;
Thierry Reding89184652014-04-16 09:24:44 +0200113};
114
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +0100115void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
116unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
117
Thierry Reding89184652014-04-16 09:24:44 +0200118#endif /* __SOC_TEGRA_MC_H__ */