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 23*3d9dd6fdSMikko Perttunen struct tegra_mc_timing { 24*3d9dd6fdSMikko Perttunen unsigned long rate; 25*3d9dd6fdSMikko Perttunen 26*3d9dd6fdSMikko Perttunen u32 *emem_data; 27*3d9dd6fdSMikko Perttunen }; 28*3d9dd6fdSMikko 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 { 4989184651SThierry Reding unsigned int swgroup; 5089184651SThierry Reding unsigned int reg; 5189184651SThierry Reding }; 5289184651SThierry Reding 5389184651SThierry Reding struct tegra_smmu_ops { 5489184651SThierry Reding void (*flush_dcache)(struct page *page, unsigned long offset, 5589184651SThierry Reding size_t size); 5689184651SThierry Reding }; 5789184651SThierry Reding 5889184651SThierry Reding struct tegra_smmu_soc { 5989184651SThierry Reding const struct tegra_mc_client *clients; 6089184651SThierry Reding unsigned int num_clients; 6189184651SThierry Reding 6289184651SThierry Reding const struct tegra_smmu_swgroup *swgroups; 6389184651SThierry Reding unsigned int num_swgroups; 6489184651SThierry Reding 6589184651SThierry Reding bool supports_round_robin_arbitration; 6689184651SThierry Reding bool supports_request_limit; 6789184651SThierry Reding 6889184651SThierry Reding unsigned int num_asids; 6989184651SThierry Reding 7089184651SThierry Reding const struct tegra_smmu_ops *ops; 7189184651SThierry Reding }; 7289184651SThierry Reding 7389184651SThierry Reding struct tegra_mc; 7489184651SThierry Reding struct tegra_smmu; 7589184651SThierry Reding 7689184651SThierry Reding #ifdef CONFIG_TEGRA_IOMMU_SMMU 7789184651SThierry Reding struct tegra_smmu *tegra_smmu_probe(struct device *dev, 7889184651SThierry Reding const struct tegra_smmu_soc *soc, 7989184651SThierry Reding struct tegra_mc *mc); 8089184651SThierry Reding #else 8189184651SThierry Reding static inline struct tegra_smmu * 8289184651SThierry Reding tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc, 8389184651SThierry Reding struct tegra_mc *mc) 8489184651SThierry Reding { 8589184651SThierry Reding return NULL; 8689184651SThierry Reding } 8789184651SThierry Reding #endif 8889184651SThierry Reding 8989184651SThierry Reding struct tegra_mc_soc { 9089184651SThierry Reding const struct tegra_mc_client *clients; 9189184651SThierry Reding unsigned int num_clients; 9289184651SThierry Reding 93*3d9dd6fdSMikko Perttunen const unsigned long *emem_regs; 9489184651SThierry Reding unsigned int num_emem_regs; 9589184651SThierry Reding 9689184651SThierry Reding unsigned int num_address_bits; 9789184651SThierry Reding unsigned int atom_size; 9889184651SThierry Reding 9989184651SThierry Reding const struct tegra_smmu_soc *smmu; 10089184651SThierry Reding }; 10189184651SThierry Reding 10289184651SThierry Reding struct tegra_mc { 10389184651SThierry Reding struct device *dev; 10489184651SThierry Reding struct tegra_smmu *smmu; 10589184651SThierry Reding void __iomem *regs; 10689184651SThierry Reding struct clk *clk; 10789184651SThierry Reding int irq; 10889184651SThierry Reding 10989184651SThierry Reding const struct tegra_mc_soc *soc; 11089184651SThierry Reding unsigned long tick; 111*3d9dd6fdSMikko Perttunen 112*3d9dd6fdSMikko Perttunen struct tegra_mc_timing *timings; 113*3d9dd6fdSMikko Perttunen unsigned int num_timings; 11489184651SThierry Reding }; 11589184651SThierry Reding 116*3d9dd6fdSMikko Perttunen void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate); 117*3d9dd6fdSMikko Perttunen unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc); 118*3d9dd6fdSMikko Perttunen 11989184651SThierry Reding #endif /* __SOC_TEGRA_MC_H__ */ 120