xref: /linux/include/soc/tegra/mc.h (revision c7e1e3ccfbd153c890240a391f258efaedfa94d0)
1 /*
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 
14 struct clk;
15 struct device;
16 struct page;
17 
18 struct tegra_smmu_enable {
19 	unsigned int reg;
20 	unsigned int bit;
21 };
22 
23 struct tegra_mc_timing {
24 	unsigned long rate;
25 
26 	u32 *emem_data;
27 };
28 
29 /* latency allowance */
30 struct tegra_mc_la {
31 	unsigned int reg;
32 	unsigned int shift;
33 	unsigned int mask;
34 	unsigned int def;
35 };
36 
37 struct 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 
48 struct tegra_smmu_swgroup {
49 	const char *name;
50 	unsigned int swgroup;
51 	unsigned int reg;
52 };
53 
54 struct tegra_smmu_ops {
55 	void (*flush_dcache)(struct page *page, unsigned long offset,
56 			     size_t size);
57 };
58 
59 struct 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 
74 struct tegra_mc;
75 struct tegra_smmu;
76 
77 #ifdef CONFIG_TEGRA_IOMMU_SMMU
78 struct tegra_smmu *tegra_smmu_probe(struct device *dev,
79 				    const struct tegra_smmu_soc *soc,
80 				    struct tegra_mc *mc);
81 void tegra_smmu_remove(struct tegra_smmu *smmu);
82 #else
83 static inline struct tegra_smmu *
84 tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc,
85 		 struct tegra_mc *mc)
86 {
87 	return NULL;
88 }
89 
90 static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
91 {
92 }
93 #endif
94 
95 struct tegra_mc_soc {
96 	const struct tegra_mc_client *clients;
97 	unsigned int num_clients;
98 
99 	const unsigned long *emem_regs;
100 	unsigned int num_emem_regs;
101 
102 	unsigned int num_address_bits;
103 	unsigned int atom_size;
104 
105 	u8 client_id_mask;
106 
107 	const struct tegra_smmu_soc *smmu;
108 };
109 
110 struct tegra_mc {
111 	struct device *dev;
112 	struct tegra_smmu *smmu;
113 	void __iomem *regs;
114 	struct clk *clk;
115 	int irq;
116 
117 	const struct tegra_mc_soc *soc;
118 	unsigned long tick;
119 
120 	struct tegra_mc_timing *timings;
121 	unsigned int num_timings;
122 };
123 
124 void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
125 unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
126 
127 #endif /* __SOC_TEGRA_MC_H__ */
128