blob: 44202ff897fd93a75e7bc7029d9733ffff2b20ec [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
Thierry Reding11cec152015-08-06 14:20:31 +020064 unsigned int num_tlb_lines;
Thierry Reding89184652014-04-16 09:24:44 +020065 unsigned int num_asids;
Thierry Reding89184652014-04-16 09:24:44 +020066};
67
68struct tegra_mc;
69struct tegra_smmu;
70
71#ifdef CONFIG_TEGRA_IOMMU_SMMU
72struct tegra_smmu *tegra_smmu_probe(struct device *dev,
73 const struct tegra_smmu_soc *soc,
74 struct tegra_mc *mc);
Thierry Redingd1313e72015-01-23 09:49:25 +010075void tegra_smmu_remove(struct tegra_smmu *smmu);
Thierry Reding89184652014-04-16 09:24:44 +020076#else
77static inline struct tegra_smmu *
78tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc,
79 struct tegra_mc *mc)
80{
81 return NULL;
82}
Thierry Redingd1313e72015-01-23 09:49:25 +010083
84static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
85{
86}
Thierry Reding89184652014-04-16 09:24:44 +020087#endif
88
89struct tegra_mc_soc {
90 const struct tegra_mc_client *clients;
91 unsigned int num_clients;
92
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +010093 const unsigned long *emem_regs;
Thierry Reding89184652014-04-16 09:24:44 +020094 unsigned int num_emem_regs;
95
96 unsigned int num_address_bits;
97 unsigned int atom_size;
98
Paul Walmsley3c01cf32015-06-04 19:33:48 +000099 u8 client_id_mask;
100
Thierry Reding89184652014-04-16 09:24:44 +0200101 const struct tegra_smmu_soc *smmu;
102};
103
104struct tegra_mc {
105 struct device *dev;
106 struct tegra_smmu *smmu;
107 void __iomem *regs;
108 struct clk *clk;
109 int irq;
110
111 const struct tegra_mc_soc *soc;
112 unsigned long tick;
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +0100113
114 struct tegra_mc_timing *timings;
115 unsigned int num_timings;
Thierry Reding89184652014-04-16 09:24:44 +0200116};
117
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +0100118void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
119unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
120
Thierry Reding89184652014-04-16 09:24:44 +0200121#endif /* __SOC_TEGRA_MC_H__ */