mc.h 2.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * Copyright (C) 2014 NVIDIA Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef __SOC_TEGRA_MC_H__
#define __SOC_TEGRA_MC_H__

#include <linux/types.h>

struct clk;
struct device;
struct page;

struct tegra_smmu_enable {
	unsigned int reg;
	unsigned int bit;
};

23 24 25 26 27 28
struct tegra_mc_timing {
	unsigned long rate;

	u32 *emem_data;
};

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
/* latency allowance */
struct tegra_mc_la {
	unsigned int reg;
	unsigned int shift;
	unsigned int mask;
	unsigned int def;
};

struct tegra_mc_client {
	unsigned int id;
	const char *name;
	unsigned int swgroup;

	unsigned int fifo_size;

	struct tegra_smmu_enable smmu;
	struct tegra_mc_la la;
};

struct tegra_smmu_swgroup {
49
	const char *name;
50 51 52 53
	unsigned int swgroup;
	unsigned int reg;
};

54 55 56 57 58 59
struct tegra_smmu_group_soc {
	const char *name;
	const unsigned int *swgroups;
	unsigned int num_swgroups;
};

60 61 62 63 64 65 66
struct tegra_smmu_soc {
	const struct tegra_mc_client *clients;
	unsigned int num_clients;

	const struct tegra_smmu_swgroup *swgroups;
	unsigned int num_swgroups;

67 68 69
	const struct tegra_smmu_group_soc *groups;
	unsigned int num_groups;

70 71 72
	bool supports_round_robin_arbitration;
	bool supports_request_limit;

73
	unsigned int num_tlb_lines;
74 75 76 77 78 79 80 81 82 83
	unsigned int num_asids;
};

struct tegra_mc;
struct tegra_smmu;

#ifdef CONFIG_TEGRA_IOMMU_SMMU
struct tegra_smmu *tegra_smmu_probe(struct device *dev,
				    const struct tegra_smmu_soc *soc,
				    struct tegra_mc *mc);
84
void tegra_smmu_remove(struct tegra_smmu *smmu);
85 86 87 88 89 90 91
#else
static inline struct tegra_smmu *
tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc,
		 struct tegra_mc *mc)
{
	return NULL;
}
92 93 94 95

static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
{
}
96 97 98 99 100 101
#endif

struct tegra_mc_soc {
	const struct tegra_mc_client *clients;
	unsigned int num_clients;

102
	const unsigned long *emem_regs;
103 104 105 106 107
	unsigned int num_emem_regs;

	unsigned int num_address_bits;
	unsigned int atom_size;

108 109
	u8 client_id_mask;

110
	const struct tegra_smmu_soc *smmu;
111 112

	u32 intmask;
113 114 115 116 117
};

struct tegra_mc {
	struct device *dev;
	struct tegra_smmu *smmu;
118
	void __iomem *regs, *regs2;
119 120 121 122 123
	struct clk *clk;
	int irq;

	const struct tegra_mc_soc *soc;
	unsigned long tick;
124 125 126

	struct tegra_mc_timing *timings;
	unsigned int num_timings;
127 128
};

129 130 131
void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);

132
#endif /* __SOC_TEGRA_MC_H__ */