Skip to content

Commit 7946920

Browse files
cyndisthierryreding
authored andcommitted
memory: tegra: Add API for retrieving carveout bounds
On Tegra234 NVDEC firmware is loaded from a secure carveout, where it has been loaded by a bootloader. When booting NVDEC, we need to tell it the address of this firmware, which we can determine by checking the starting address of the carveout. As such, add an MC API to query the bounds of carveouts, and add related information on Tegra234. Signed-off-by: Mikko Perttunen <[email protected]> Acked-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 17c2984 commit 7946920

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

drivers/memory/tegra/mc.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,31 @@ int tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev)
107107
}
108108
EXPORT_SYMBOL_GPL(tegra_mc_probe_device);
109109

110+
int tegra_mc_get_carveout_info(struct tegra_mc *mc, unsigned int id,
111+
phys_addr_t *base, u64 *size)
112+
{
113+
u32 offset;
114+
115+
if (id < 1 || id >= mc->soc->num_carveouts)
116+
return -EINVAL;
117+
118+
if (id < 6)
119+
offset = 0xc0c + 0x50 * (id - 1);
120+
else
121+
offset = 0x2004 + 0x50 * (id - 6);
122+
123+
*base = mc_ch_readl(mc, MC_BROADCAST_CHANNEL, offset + 0x0);
124+
#ifdef CONFIG_PHYS_ADDR_T_64BIT
125+
*base |= (phys_addr_t)mc_ch_readl(mc, MC_BROADCAST_CHANNEL, offset + 0x4) << 32;
126+
#endif
127+
128+
if (size)
129+
*size = mc_ch_readl(mc, MC_BROADCAST_CHANNEL, offset + 0x8) << 17;
130+
131+
return 0;
132+
}
133+
EXPORT_SYMBOL_GPL(tegra_mc_get_carveout_info);
134+
110135
static int tegra_mc_block_dma_common(struct tegra_mc *mc,
111136
const struct tegra_mc_reset *rst)
112137
{

drivers/memory/tegra/tegra234.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,9 @@ const struct tegra_mc_soc tegra234_mc_soc = {
187187
.ops = &tegra186_mc_ops,
188188
.ch_intmask = 0x0000ff00,
189189
.global_intstatus_channel_shift = 8,
190+
/*
191+
* Additionally, there are lite carveouts but those are not currently
192+
* supported.
193+
*/
194+
.num_carveouts = 32,
190195
};

include/soc/tegra/mc.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ struct tegra_mc_soc {
193193
unsigned int num_address_bits;
194194
unsigned int atom_size;
195195

196+
unsigned int num_carveouts;
197+
196198
u16 client_id_mask;
197199
u8 num_channels;
198200

@@ -244,6 +246,8 @@ unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
244246
#ifdef CONFIG_TEGRA_MC
245247
struct tegra_mc *devm_tegra_memory_controller_get(struct device *dev);
246248
int tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev);
249+
int tegra_mc_get_carveout_info(struct tegra_mc *mc, unsigned int id,
250+
phys_addr_t *base, u64 *size);
247251
#else
248252
static inline struct tegra_mc *
249253
devm_tegra_memory_controller_get(struct device *dev)
@@ -256,6 +260,13 @@ tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev)
256260
{
257261
return -ENODEV;
258262
}
263+
264+
static inline int
265+
tegra_mc_get_carveout_info(struct tegra_mc *mc, unsigned int id,
266+
phys_addr_t *base, u64 *size)
267+
{
268+
return -ENODEV;
269+
}
259270
#endif
260271

261272
#endif /* __SOC_TEGRA_MC_H__ */

0 commit comments

Comments
 (0)