xref: /linux/include/soc/tegra/mc.h (revision 1c74d5c0de0c2cc29fef97a19251da2ad6f579bd)
189184651SThierry Reding /*
289184651SThierry Reding  * Copyright (C) 2014 NVIDIA Corporation
389184651SThierry Reding  *
489184651SThierry Reding  * This program is free software; you can redistribute it and/or modify
589184651SThierry Reding  * it under the terms of the GNU General Public License version 2 as
689184651SThierry Reding  * published by the Free Software Foundation.
789184651SThierry Reding  */
889184651SThierry Reding 
989184651SThierry Reding #ifndef __SOC_TEGRA_MC_H__
1089184651SThierry Reding #define __SOC_TEGRA_MC_H__
1189184651SThierry Reding 
1289184651SThierry Reding #include <linux/types.h>
1389184651SThierry Reding 
1489184651SThierry Reding struct clk;
1589184651SThierry Reding struct device;
1689184651SThierry Reding struct page;
1789184651SThierry Reding 
1889184651SThierry Reding struct tegra_smmu_enable {
1989184651SThierry Reding 	unsigned int reg;
2089184651SThierry Reding 	unsigned int bit;
2189184651SThierry Reding };
2289184651SThierry Reding 
233d9dd6fdSMikko Perttunen struct tegra_mc_timing {
243d9dd6fdSMikko Perttunen 	unsigned long rate;
253d9dd6fdSMikko Perttunen 
263d9dd6fdSMikko Perttunen 	u32 *emem_data;
273d9dd6fdSMikko Perttunen };
283d9dd6fdSMikko Perttunen 
2989184651SThierry Reding /* latency allowance */
3089184651SThierry Reding struct tegra_mc_la {
3189184651SThierry Reding 	unsigned int reg;
3289184651SThierry Reding 	unsigned int shift;
3389184651SThierry Reding 	unsigned int mask;
3489184651SThierry Reding 	unsigned int def;
3589184651SThierry Reding };
3689184651SThierry Reding 
3789184651SThierry Reding struct tegra_mc_client {
3889184651SThierry Reding 	unsigned int id;
3989184651SThierry Reding 	const char *name;
4089184651SThierry Reding 	unsigned int swgroup;
4189184651SThierry Reding 
4289184651SThierry Reding 	unsigned int fifo_size;
4389184651SThierry Reding 
4489184651SThierry Reding 	struct tegra_smmu_enable smmu;
4589184651SThierry Reding 	struct tegra_mc_la la;
4689184651SThierry Reding };
4789184651SThierry Reding 
4889184651SThierry Reding struct tegra_smmu_swgroup {
49e660df07SThierry Reding 	const char *name;
5089184651SThierry Reding 	unsigned int swgroup;
5189184651SThierry Reding 	unsigned int reg;
5289184651SThierry Reding };
5389184651SThierry Reding 
542a8102dfSThierry Reding struct tegra_smmu_group_soc {
552a8102dfSThierry Reding 	const char *name;
562a8102dfSThierry Reding 	const unsigned int *swgroups;
572a8102dfSThierry Reding 	unsigned int num_swgroups;
582a8102dfSThierry Reding };
592a8102dfSThierry Reding 
6089184651SThierry Reding struct tegra_smmu_soc {
6189184651SThierry Reding 	const struct tegra_mc_client *clients;
6289184651SThierry Reding 	unsigned int num_clients;
6389184651SThierry Reding 
6489184651SThierry Reding 	const struct tegra_smmu_swgroup *swgroups;
6589184651SThierry Reding 	unsigned int num_swgroups;
6689184651SThierry Reding 
672a8102dfSThierry Reding 	const struct tegra_smmu_group_soc *groups;
682a8102dfSThierry Reding 	unsigned int num_groups;
692a8102dfSThierry Reding 
7089184651SThierry Reding 	bool supports_round_robin_arbitration;
7189184651SThierry Reding 	bool supports_request_limit;
7289184651SThierry Reding 
7311cec15bSThierry Reding 	unsigned int num_tlb_lines;
7489184651SThierry Reding 	unsigned int num_asids;
7589184651SThierry Reding };
7689184651SThierry Reding 
7789184651SThierry Reding struct tegra_mc;
7889184651SThierry Reding struct tegra_smmu;
7989184651SThierry Reding 
8089184651SThierry Reding #ifdef CONFIG_TEGRA_IOMMU_SMMU
8189184651SThierry Reding struct tegra_smmu *tegra_smmu_probe(struct device *dev,
8289184651SThierry Reding 				    const struct tegra_smmu_soc *soc,
8389184651SThierry Reding 				    struct tegra_mc *mc);
84d1313e78SThierry Reding void tegra_smmu_remove(struct tegra_smmu *smmu);
8589184651SThierry Reding #else
8689184651SThierry Reding static inline struct tegra_smmu *
8789184651SThierry Reding tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc,
8889184651SThierry Reding 		 struct tegra_mc *mc)
8989184651SThierry Reding {
9089184651SThierry Reding 	return NULL;
9189184651SThierry Reding }
92d1313e78SThierry Reding 
93d1313e78SThierry Reding static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
94d1313e78SThierry Reding {
95d1313e78SThierry Reding }
9689184651SThierry Reding #endif
9789184651SThierry Reding 
9889184651SThierry Reding struct tegra_mc_soc {
9989184651SThierry Reding 	const struct tegra_mc_client *clients;
10089184651SThierry Reding 	unsigned int num_clients;
10189184651SThierry Reding 
1023d9dd6fdSMikko Perttunen 	const unsigned long *emem_regs;
10389184651SThierry Reding 	unsigned int num_emem_regs;
10489184651SThierry Reding 
10589184651SThierry Reding 	unsigned int num_address_bits;
10689184651SThierry Reding 	unsigned int atom_size;
10789184651SThierry Reding 
1083c01cf3bSPaul Walmsley 	u8 client_id_mask;
1093c01cf3bSPaul Walmsley 
11089184651SThierry Reding 	const struct tegra_smmu_soc *smmu;
111*1c74d5c0SDmitry Osipenko 
112*1c74d5c0SDmitry Osipenko 	u32 intmask;
11389184651SThierry Reding };
11489184651SThierry Reding 
11589184651SThierry Reding struct tegra_mc {
11689184651SThierry Reding 	struct device *dev;
11789184651SThierry Reding 	struct tegra_smmu *smmu;
11889184651SThierry Reding 	void __iomem *regs;
11989184651SThierry Reding 	struct clk *clk;
12089184651SThierry Reding 	int irq;
12189184651SThierry Reding 
12289184651SThierry Reding 	const struct tegra_mc_soc *soc;
12389184651SThierry Reding 	unsigned long tick;
1243d9dd6fdSMikko Perttunen 
1253d9dd6fdSMikko Perttunen 	struct tegra_mc_timing *timings;
1263d9dd6fdSMikko Perttunen 	unsigned int num_timings;
12789184651SThierry Reding };
12889184651SThierry Reding 
1293d9dd6fdSMikko Perttunen void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
1303d9dd6fdSMikko Perttunen unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
1313d9dd6fdSMikko Perttunen 
13289184651SThierry Reding #endif /* __SOC_TEGRA_MC_H__ */
133