Advertisement
Guest User

Untitled

a guest
May 6th, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.25 KB | None | 0 0
  1. diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
  2. index acce9d02dba0..9641769c64d1 100644
  3. --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
  4. +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
  5. @@ -29,13 +29,34 @@ static int panfrost_devfreq_target(struct device *dev, unsigned long *freq,
  6. u32 flags)
  7. {
  8. struct dev_pm_opp *opp;
  9. + struct panfrost_device *pfdev = dev_get_drvdata(dev);
  10. + int ret, err;
  11. + char needs_reparenting = pfdev->mtk_clk_mux != NULL;
  12.  
  13. opp = devfreq_recommended_opp(dev, freq, flags);
  14. if (IS_ERR(opp))
  15. return PTR_ERR(opp);
  16. dev_pm_opp_put(opp);
  17.  
  18. - return dev_pm_opp_set_rate(dev, *freq);
  19. + if (needs_reparenting) {
  20. + err = clk_set_parent(pfdev->mtk_clk_mux, pfdev->mtk_clk_sub);
  21. + if (err) {
  22. + DRM_DEV_ERROR(dev, "Failed to select sub clock source\n");
  23. + return err;
  24. + }
  25. + }
  26. +
  27. + ret = dev_pm_opp_set_rate(dev, *freq);
  28. +
  29. + if (needs_reparenting) {
  30. + err = clk_set_parent(pfdev->mtk_clk_mux, pfdev->mtk_clk_parent);
  31. + if (err) {
  32. + DRM_DEV_ERROR(dev, "Failed to select main clock source\n");
  33. + return err;
  34. + }
  35. + }
  36. +
  37. + return ret;
  38. }
  39.  
  40. static void panfrost_devfreq_reset(struct panfrost_devfreq *pfdevfreq)
  41. @@ -91,16 +112,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
  42. struct devfreq *devfreq;
  43. struct opp_table *opp_table;
  44. struct thermal_cooling_device *cooling;
  45. - struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq;
  46. -
  47. - if (pfdev->comp->num_supplies > 1) {
  48. - /*
  49. - * GPUs with more than 1 supply require platform-specific handling:
  50. - * continue without devfreq
  51. - */
  52. - DRM_DEV_INFO(dev, "More than 1 supply is not supported yet\n");
  53. - return 0;
  54. - }
  55. + struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq;
  56.  
  57. opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names,
  58. pfdev->comp->num_supplies);
  59. diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
  60. index a2a09c51eed7..b77d738c7fb8 100644
  61. --- a/drivers/gpu/drm/panfrost/panfrost_device.c
  62. +++ b/drivers/gpu/drm/panfrost/panfrost_device.c
  63. @@ -67,6 +67,32 @@ static int panfrost_clk_init(struct panfrost_device *pfdev)
  64. goto disable_clock;
  65. }
  66.  
  67. + pfdev->mtk_clk_mux = devm_clk_get_optional(pfdev->dev, "clk_mux");
  68. + if (pfdev->mtk_clk_mux) {
  69. + if (IS_ERR(pfdev->mtk_clk_mux)) {
  70. + dev_err(pfdev->dev, "get clk_mux failed %ld\n",
  71. + PTR_ERR(pfdev->mtk_clk_mux));
  72. + err = PTR_ERR(pfdev->mtk_clk_mux);
  73. + goto disable_clock;
  74. + }
  75. +
  76. + pfdev->mtk_clk_parent = devm_clk_get(pfdev->dev, "clk_main_parent");
  77. + if (IS_ERR(pfdev->mtk_clk_parent)) {
  78. + dev_err(pfdev->dev, "get clk_main_parent failed %ld\n",
  79. + PTR_ERR(pfdev->mtk_clk_parent));
  80. + err = PTR_ERR(pfdev->mtk_clk_parent);
  81. + goto disable_clock;
  82. + }
  83. +
  84. + pfdev->mtk_clk_sub = devm_clk_get(pfdev->dev, "clk_sub_parent");
  85. + if (IS_ERR(pfdev->mtk_clk_sub)) {
  86. + dev_err(pfdev->dev, "get clk_sub_parent failed %ld\n",
  87. + PTR_ERR(pfdev->mtk_clk_sub));
  88. + err = PTR_ERR(pfdev->mtk_clk_sub);
  89. + goto disable_clock;
  90. + }
  91. + }
  92. +
  93. return 0;
  94.  
  95. disable_clock:
  96. diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h
  97. index 8b2cdb8c701d..410b6099fea9 100644
  98. --- a/drivers/gpu/drm/panfrost/panfrost_device.h
  99. +++ b/drivers/gpu/drm/panfrost/panfrost_device.h
  100. @@ -84,6 +84,9 @@ struct panfrost_device {
  101. void __iomem *iomem;
  102. struct clk *clock;
  103. struct clk *bus_clock;
  104. + struct clk *mtk_clk_mux;
  105. + struct clk *mtk_clk_parent;
  106. + struct clk *mtk_clk_sub;
  107. struct regulator_bulk_data *regulators;
  108. struct reset_control *rstc;
  109. /* pm_domains for devices with more than one. */
  110. diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
  111. index 458ef2a97818..ced06ca501a6 100644
  112. --- a/drivers/gpu/drm/panfrost/panfrost_drv.c
  113. +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
  114. @@ -634,7 +634,8 @@ static const struct panfrost_compatible amlogic_data = {
  115. .vendor_quirk = panfrost_gpu_amlogic_quirk,
  116. };
  117.  
  118. -const char * const mediatek_mt8183_supplies[] = { "mali", "sram" };
  119. +// const char * const mediatek_mt8183_supplies[] = { "mali", "sram" };
  120. +const char * const mediatek_mt8183_supplies[] = { "mali", "mali_sram" };
  121. const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" };
  122. static const struct panfrost_compatible mediatek_mt8183_data = {
  123. .num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies),
  124. @@ -660,6 +661,7 @@ static const struct of_device_id dt_match[] = {
  125. { .compatible = "arm,mali-t880-CHROMIUM", .data = &default_data, },
  126. { .compatible = "arm,mali-bifrost-CHROMIUM", .data = &default_data, },
  127. { .compatible = "mediatek,mt8183-mali-CHROMIUM", .data = &mediatek_mt8183_data },
  128. + { .compatible = "mediatek,mt8183-mali\0arm,mali-bifrost", .data = &mediatek_mt8183_data },
  129. {}
  130. };
  131. MODULE_DEVICE_TABLE(of, dt_match);
  132. diff --git a/drivers/opp/core.c b/drivers/opp/core.c
  133. index 65df3a106cf5..a3534dd83a00 100644
  134. --- a/drivers/opp/core.c
  135. +++ b/drivers/opp/core.c
  136. @@ -784,18 +784,15 @@ static int _generic_set_opp_regulator(struct opp_table *opp_table,
  137. struct regulator *reg = opp_table->regulators[0];
  138. struct dev_pm_opp *old_opp = opp_table->current_opp;
  139. int ret;
  140. -
  141. - /* This function only supports single regulator per device */
  142. - if (WARN_ON(opp_table->regulator_count > 1)) {
  143. - dev_err(dev, "multiple regulators are not supported\n");
  144. - return -EINVAL;
  145. - }
  146. + unsigned i;
  147.  
  148. /* Scaling up? Scale voltage before frequency */
  149. if (!scaling_down) {
  150. - ret = _set_opp_voltage(dev, reg, opp->supplies);
  151. - if (ret)
  152. - goto restore_voltage;
  153. + for (i = 0; i < opp_table->regulator_count; i++) {
  154. + ret = _set_opp_voltage(dev, opp_table->regulators[i], &opp->supplies[i]);
  155. + if (ret)
  156. + goto restore_voltage;
  157. + }
  158. }
  159.  
  160. /* Change frequency */
  161. @@ -805,9 +802,11 @@ static int _generic_set_opp_regulator(struct opp_table *opp_table,
  162.  
  163. /* Scaling down? Scale voltage after frequency */
  164. if (scaling_down) {
  165. - ret = _set_opp_voltage(dev, reg, opp->supplies);
  166. - if (ret)
  167. - goto restore_freq;
  168. + for (i = 0; i < opp_table->regulator_count; i++) {
  169. + ret = _set_opp_voltage(dev, opp_table->regulators[i], &opp->supplies[i]);
  170. + if (ret)
  171. + goto restore_freq;
  172. + }
  173. }
  174.  
  175. /*
  176. --
  177.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement