mc.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. #ifndef __SOC_TEGRA_MC_H__
  9. #define __SOC_TEGRA_MC_H__
  10. #include <linux/reset-controller.h>
  11. #include <linux/types.h>
  12. struct clk;
  13. struct device;
  14. struct page;
  15. struct tegra_smmu_enable {
  16. unsigned int reg;
  17. unsigned int bit;
  18. };
  19. struct tegra_mc_timing {
  20. unsigned long rate;
  21. u32 *emem_data;
  22. };
  23. /* latency allowance */
  24. struct tegra_mc_la {
  25. unsigned int reg;
  26. unsigned int shift;
  27. unsigned int mask;
  28. unsigned int def;
  29. };
  30. struct tegra_mc_client {
  31. unsigned int id;
  32. const char *name;
  33. unsigned int swgroup;
  34. unsigned int fifo_size;
  35. struct tegra_smmu_enable smmu;
  36. struct tegra_mc_la la;
  37. };
  38. struct tegra_smmu_swgroup {
  39. const char *name;
  40. unsigned int swgroup;
  41. unsigned int reg;
  42. };
  43. struct tegra_smmu_group_soc {
  44. const char *name;
  45. const unsigned int *swgroups;
  46. unsigned int num_swgroups;
  47. };
  48. struct tegra_smmu_soc {
  49. const struct tegra_mc_client *clients;
  50. unsigned int num_clients;
  51. const struct tegra_smmu_swgroup *swgroups;
  52. unsigned int num_swgroups;
  53. const struct tegra_smmu_group_soc *groups;
  54. unsigned int num_groups;
  55. bool supports_round_robin_arbitration;
  56. bool supports_request_limit;
  57. unsigned int num_tlb_lines;
  58. unsigned int num_asids;
  59. };
  60. struct tegra_mc;
  61. struct tegra_smmu;
  62. #ifdef CONFIG_TEGRA_IOMMU_SMMU
  63. struct tegra_smmu *tegra_smmu_probe(struct device *dev,
  64. const struct tegra_smmu_soc *soc,
  65. struct tegra_mc *mc);
  66. void tegra_smmu_remove(struct tegra_smmu *smmu);
  67. #else
  68. static inline struct tegra_smmu *
  69. tegra_smmu_probe(struct device *dev, const struct tegra_smmu_soc *soc,
  70. struct tegra_mc *mc)
  71. {
  72. return NULL;
  73. }
  74. static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
  75. {
  76. }
  77. #endif
  78. struct tegra_mc_reset {
  79. const char *name;
  80. unsigned long id;
  81. unsigned int control;
  82. unsigned int status;
  83. unsigned int reset;
  84. unsigned int bit;
  85. };
  86. struct tegra_mc_reset_ops {
  87. int (*hotreset_assert)(struct tegra_mc *mc,
  88. const struct tegra_mc_reset *rst);
  89. int (*hotreset_deassert)(struct tegra_mc *mc,
  90. const struct tegra_mc_reset *rst);
  91. int (*block_dma)(struct tegra_mc *mc,
  92. const struct tegra_mc_reset *rst);
  93. bool (*dma_idling)(struct tegra_mc *mc,
  94. const struct tegra_mc_reset *rst);
  95. int (*unblock_dma)(struct tegra_mc *mc,
  96. const struct tegra_mc_reset *rst);
  97. int (*reset_status)(struct tegra_mc *mc,
  98. const struct tegra_mc_reset *rst);
  99. };
  100. struct tegra_mc_soc {
  101. const struct tegra_mc_client *clients;
  102. unsigned int num_clients;
  103. const unsigned long *emem_regs;
  104. unsigned int num_emem_regs;
  105. unsigned int num_address_bits;
  106. unsigned int atom_size;
  107. u8 client_id_mask;
  108. const struct tegra_smmu_soc *smmu;
  109. u32 intmask;
  110. const struct tegra_mc_reset_ops *reset_ops;
  111. const struct tegra_mc_reset *resets;
  112. unsigned int num_resets;
  113. };
  114. struct tegra_mc {
  115. struct device *dev;
  116. struct tegra_smmu *smmu;
  117. void __iomem *regs, *regs2;
  118. struct clk *clk;
  119. int irq;
  120. const struct tegra_mc_soc *soc;
  121. unsigned long tick;
  122. struct tegra_mc_timing *timings;
  123. unsigned int num_timings;
  124. struct reset_controller_dev reset;
  125. spinlock_t lock;
  126. };
  127. void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
  128. unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
  129. #endif /* __SOC_TEGRA_MC_H__ */