Thierry Reding | 8918465 | 2014-04-16 09:24:44 +0200 | [diff] [blame] | 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 | |
Mikko Perttunen | 3d9dd6f | 2015-03-12 15:48:02 +0100 | [diff] [blame] | 23 | struct tegra_mc_timing { |
| 24 | unsigned long rate; |
| 25 | |
| 26 | u32 *emem_data; |
| 27 | }; |
| 28 | |
Thierry Reding | 8918465 | 2014-04-16 09:24:44 +0200 | [diff] [blame] | 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 { |
Thierry Reding | e660df0 | 2015-01-23 09:45:35 +0100 | [diff] [blame] | 49 | const char *name; |
Thierry Reding | 8918465 | 2014-04-16 09:24:44 +0200 | [diff] [blame] | 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); |
Thierry Reding | d1313e7 | 2015-01-23 09:49:25 +0100 | [diff] [blame] | 81 | void tegra_smmu_remove(struct tegra_smmu *smmu); |
Thierry Reding | 8918465 | 2014-04-16 09:24:44 +0200 | [diff] [blame] | 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 | } |
Thierry Reding | d1313e7 | 2015-01-23 09:49:25 +0100 | [diff] [blame] | 89 | |
| 90 | static inline void tegra_smmu_remove(struct tegra_smmu *smmu) |
| 91 | { |
| 92 | } |
Thierry Reding | 8918465 | 2014-04-16 09:24:44 +0200 | [diff] [blame] | 93 | #endif |
| 94 | |
| 95 | struct tegra_mc_soc { |
| 96 | const struct tegra_mc_client *clients; |
| 97 | unsigned int num_clients; |
| 98 | |
Mikko Perttunen | 3d9dd6f | 2015-03-12 15:48:02 +0100 | [diff] [blame] | 99 | const unsigned long *emem_regs; |
Thierry Reding | 8918465 | 2014-04-16 09:24:44 +0200 | [diff] [blame] | 100 | 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 | |
| 108 | struct 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 Perttunen | 3d9dd6f | 2015-03-12 15:48:02 +0100 | [diff] [blame] | 117 | |
| 118 | struct tegra_mc_timing *timings; |
| 119 | unsigned int num_timings; |
Thierry Reding | 8918465 | 2014-04-16 09:24:44 +0200 | [diff] [blame] | 120 | }; |
| 121 | |
Mikko Perttunen | 3d9dd6f | 2015-03-12 15:48:02 +0100 | [diff] [blame] | 122 | void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate); |
| 123 | unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc); |
| 124 | |
Thierry Reding | 8918465 | 2014-04-16 09:24:44 +0200 | [diff] [blame] | 125 | #endif /* __SOC_TEGRA_MC_H__ */ |