msm_cvp_platform.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/debugfs.h>
  6. #include <linux/dma-mapping.h>
  7. #include <linux/init.h>
  8. #include <linux/ioctl.h>
  9. #include <linux/list.h>
  10. #include <linux/module.h>
  11. #include <linux/of_platform.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/slab.h>
  14. #include <linux/types.h>
  15. #include <linux/version.h>
  16. #include <linux/io.h>
  17. #include <linux/of_fdt.h>
  18. #include "msm_cvp_internal.h"
  19. #include "msm_cvp_debug.h"
  20. #define UBWC_CONFIG(mco, mlo, hbo, bslo, bso, rs, mc, ml, hbb, bsl, bsp) \
  21. { \
  22. .override_bit_info.max_channel_override = mco, \
  23. .override_bit_info.mal_length_override = mlo, \
  24. .override_bit_info.hb_override = hbo, \
  25. .override_bit_info.bank_swzl_level_override = bslo, \
  26. .override_bit_info.bank_spreading_override = bso, \
  27. .override_bit_info.reserved = rs, \
  28. .max_channels = mc, \
  29. .mal_length = ml, \
  30. .highest_bank_bit = hbb, \
  31. .bank_swzl_level = bsl, \
  32. .bank_spreading = bsp, \
  33. }
  34. static struct msm_cvp_common_data default_common_data[] = {
  35. {
  36. .key = "qcom,never-unload-fw",
  37. .value = 1,
  38. },
  39. };
  40. static struct msm_cvp_common_data sm8450_common_data[] = {
  41. {
  42. .key = "qcom,auto-pil",
  43. .value = 1,
  44. },
  45. {
  46. .key = "qcom,never-unload-fw",
  47. .value = 1,
  48. },
  49. {
  50. .key = "qcom,sw-power-collapse",
  51. .value = 1,
  52. },
  53. {
  54. .key = "qcom,domain-attr-non-fatal-faults",
  55. .value = 0,
  56. },
  57. {
  58. .key = "qcom,max-secure-instances",
  59. .value = 2, /*
  60. * As per design driver allows 3rd
  61. * instance as well since the secure
  62. * flags were updated later for the
  63. * current instance. Hence total
  64. * secure sessions would be
  65. * max-secure-instances + 1.
  66. */
  67. },
  68. {
  69. .key = "qcom,max-hw-load",
  70. .value = 3916800, /*
  71. * 1920x1088/256 MBs@480fps. It is less
  72. * any other usecases (ex:
  73. * 3840x2160@120fps, 4096x2160@96ps,
  74. * 7680x4320@30fps)
  75. */
  76. },
  77. {
  78. .key = "qcom,power-collapse-delay",
  79. .value = 3000,
  80. },
  81. {
  82. .key = "qcom,hw-resp-timeout",
  83. .value = 2000,
  84. },
  85. {
  86. .key = "qcom,dsp-resp-timeout",
  87. .value = 1000,
  88. },
  89. {
  90. .key = "qcom,debug-timeout",
  91. .value = 0,
  92. },
  93. {
  94. .key = "qcom,dsp-enabled",
  95. .value = 1,
  96. }
  97. };
  98. /* Default UBWC config for LPDDR5 */
  99. static struct msm_cvp_ubwc_config_data kona_ubwc_data[] = {
  100. UBWC_CONFIG(1, 1, 1, 0, 0, 0, 8, 32, 16, 0, 0),
  101. };
  102. static struct msm_cvp_platform_data default_data = {
  103. .common_data = default_common_data,
  104. .common_data_length = ARRAY_SIZE(default_common_data),
  105. .sku_version = 0,
  106. .vpu_ver = VPU_VERSION_5,
  107. .ubwc_config = 0x0,
  108. };
  109. static struct msm_cvp_platform_data sm8450_data = {
  110. .common_data = sm8450_common_data,
  111. .common_data_length = ARRAY_SIZE(sm8450_common_data),
  112. .sku_version = 0,
  113. .vpu_ver = VPU_VERSION_5,
  114. .ubwc_config = kona_ubwc_data,
  115. };
  116. static const struct of_device_id msm_cvp_dt_match[] = {
  117. {
  118. .compatible = "qcom,waipio-cvp",
  119. .data = &sm8450_data,
  120. },
  121. {},
  122. };
  123. MODULE_DEVICE_TABLE(of, msm_cvp_dt_match);
  124. void *cvp_get_drv_data(struct device *dev)
  125. {
  126. struct msm_cvp_platform_data *driver_data;
  127. const struct of_device_id *match;
  128. uint32_t ddr_type = DDR_TYPE_LPDDR5;
  129. driver_data = &default_data;
  130. if (!IS_ENABLED(CONFIG_OF) || !dev->of_node)
  131. goto exit;
  132. match = of_match_node(msm_cvp_dt_match, dev->of_node);
  133. if (!match)
  134. return NULL;
  135. driver_data = (struct msm_cvp_platform_data *)match->data;
  136. if (!strcmp(match->compatible, "qcom,waipio-cvp")) {
  137. ddr_type = of_fdt_get_ddrtype();
  138. if (ddr_type == -ENOENT) {
  139. dprintk(CVP_ERR,
  140. "Failed to get ddr type, use LPDDR5\n");
  141. }
  142. if (driver_data->ubwc_config &&
  143. (ddr_type == DDR_TYPE_LPDDR4 ||
  144. ddr_type == DDR_TYPE_LPDDR4X))
  145. driver_data->ubwc_config->highest_bank_bit = 15;
  146. dprintk(CVP_CORE, "DDR Type 0x%x hbb 0x%x\n",
  147. ddr_type, driver_data->ubwc_config ?
  148. driver_data->ubwc_config->highest_bank_bit : -1);
  149. }
  150. exit:
  151. return driver_data;
  152. }