blob: db5bfdf589b483abe6da3894d6a6a52a37340f5a [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
Dmitry Osipenko20e92462018-04-13 14:33:49 +030012#include <linux/reset-controller.h>
Thierry Reding89184652014-04-16 09:24:44 +020013#include <linux/types.h>
14
15struct clk;
16struct device;
17struct page;
18
19struct tegra_smmu_enable {
20 unsigned int reg;
21 unsigned int bit;
22};
23
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +010024struct tegra_mc_timing {
25 unsigned long rate;
26
27 u32 *emem_data;
28};
29
Thierry Reding89184652014-04-16 09:24:44 +020030/* latency allowance */
31struct tegra_mc_la {
32 unsigned int reg;
33 unsigned int shift;
34 unsigned int mask;
35 unsigned int def;
36};
37
38struct tegra_mc_client {
39 unsigned int id;
40 const char *name;
41 unsigned int swgroup;
42
43 unsigned int fifo_size;
44
45 struct tegra_smmu_enable smmu;
46 struct tegra_mc_la la;
47};
48
49struct tegra_smmu_swgroup {
Thierry Redinge660df02015-01-23 09:45:35 +010050 const char *name;
Thierry Reding89184652014-04-16 09:24:44 +020051 unsigned int swgroup;
52 unsigned int reg;
53};
54
Thierry Reding2a8102d2017-10-12 16:29:19 +020055struct tegra_smmu_group_soc {
56 const char *name;
57 const unsigned int *swgroups;
58 unsigned int num_swgroups;
59};
60
Thierry Reding89184652014-04-16 09:24:44 +020061struct tegra_smmu_soc {
62 const struct tegra_mc_client *clients;
63 unsigned int num_clients;
64
65 const struct tegra_smmu_swgroup *swgroups;
66 unsigned int num_swgroups;
67
Thierry Reding2a8102d2017-10-12 16:29:19 +020068 const struct tegra_smmu_group_soc *groups;
69 unsigned int num_groups;
70
Thierry Reding89184652014-04-16 09:24:44 +020071 bool supports_round_robin_arbitration;
72 bool supports_request_limit;
73
Thierry Reding11cec152015-08-06 14:20:31 +020074 unsigned int num_tlb_lines;
Thierry Reding89184652014-04-16 09:24:44 +020075 unsigned int num_asids;
Thierry Reding89184652014-04-16 09:24:44 +020076};
77
78struct tegra_mc;
79struct tegra_smmu;
80
81#ifdef CONFIG_TEGRA_IOMMU_SMMU
82struct tegra_smmu *tegra_smmu_probe(struct device *dev,
83 const struct tegra_smmu_soc *soc,
84 struct tegra_mc *mc);
Thierry Redingd1313e72015-01-23 09:49:25 +010085void tegra_smmu_remove(struct tegra_smmu *smmu);
Thierry Reding89184652014-04-16 09:24:44 +020086#else
87static inline struct tegra_smmu *
88tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc,
89 struct tegra_mc *mc)
90{
91 return NULL;
92}
Thierry Redingd1313e72015-01-23 09:49:25 +010093
94static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
95{
96}
Thierry Reding89184652014-04-16 09:24:44 +020097#endif
98
Dmitry Osipenko20e92462018-04-13 14:33:49 +030099struct tegra_mc_reset {
100 const char *name;
101 unsigned long id;
102 unsigned int control;
103 unsigned int status;
104 unsigned int reset;
105 unsigned int bit;
106};
107
108struct tegra_mc_reset_ops {
109 int (*hotreset_assert)(struct tegra_mc *mc,
110 const struct tegra_mc_reset *rst);
111 int (*hotreset_deassert)(struct tegra_mc *mc,
112 const struct tegra_mc_reset *rst);
113 int (*block_dma)(struct tegra_mc *mc,
114 const struct tegra_mc_reset *rst);
115 bool (*dma_idling)(struct tegra_mc *mc,
116 const struct tegra_mc_reset *rst);
117 int (*unblock_dma)(struct tegra_mc *mc,
118 const struct tegra_mc_reset *rst);
119 int (*reset_status)(struct tegra_mc *mc,
120 const struct tegra_mc_reset *rst);
121};
122
Thierry Reding89184652014-04-16 09:24:44 +0200123struct tegra_mc_soc {
124 const struct tegra_mc_client *clients;
125 unsigned int num_clients;
126
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +0100127 const unsigned long *emem_regs;
Thierry Reding89184652014-04-16 09:24:44 +0200128 unsigned int num_emem_regs;
129
130 unsigned int num_address_bits;
131 unsigned int atom_size;
132
Paul Walmsley3c01cf32015-06-04 19:33:48 +0000133 u8 client_id_mask;
134
Thierry Reding89184652014-04-16 09:24:44 +0200135 const struct tegra_smmu_soc *smmu;
Dmitry Osipenko1c74d5c2018-04-09 22:28:29 +0300136
137 u32 intmask;
Dmitry Osipenko20e92462018-04-13 14:33:49 +0300138
139 const struct tegra_mc_reset_ops *reset_ops;
140 const struct tegra_mc_reset *resets;
141 unsigned int num_resets;
Thierry Reding89184652014-04-16 09:24:44 +0200142};
143
144struct tegra_mc {
145 struct device *dev;
146 struct tegra_smmu *smmu;
Dmitry Osipenko96efa112018-12-12 23:38:52 +0300147 void __iomem *regs;
Thierry Reding89184652014-04-16 09:24:44 +0200148 struct clk *clk;
149 int irq;
150
151 const struct tegra_mc_soc *soc;
152 unsigned long tick;
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +0100153
154 struct tegra_mc_timing *timings;
155 unsigned int num_timings;
Dmitry Osipenko20e92462018-04-13 14:33:49 +0300156
157 struct reset_controller_dev reset;
158
159 spinlock_t lock;
Thierry Reding89184652014-04-16 09:24:44 +0200160};
161
Mikko Perttunen3d9dd6f2015-03-12 15:48:02 +0100162void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
163unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
164
Thierry Reding89184652014-04-16 09:24:44 +0200165#endif /* __SOC_TEGRA_MC_H__ */