006-mfd-qcom_rpm-Handle-message-RAM-clock.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. From 3526403353c2a1b94c3181f900582626d23c339b Mon Sep 17 00:00:00 2001
  2. From: Linus Walleij <linus.walleij@linaro.org>
  3. Date: Thu, 18 Aug 2016 20:40:45 +0200
  4. Subject: mfd: qcom_rpm: Handle message RAM clock
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. The MSM8660, APQ8060, IPQ806x and MSM8960 have a GCC clock
  9. to the message RAM used by the RPM. This needs to be enabled
  10. for messages to pass through. This is a crude solution that
  11. simply prepare/enable at probe() and disable/unprepare
  12. at remove(). More elaborate PM is probably possible to
  13. add later.
  14. The construction uses IS_ERR() to gracefully handle the
  15. platforms that do not provide a message RAM clock. It will
  16. bail out of probe only if the clock is hitting a probe
  17. deferral situation.
  18. Of course this requires the proper device tree set-up:
  19. rpm: rpm@104000 {
  20. compatible = "qcom,rpm-msm8660";
  21. clocks = <&gcc RPM_MSG_RAM_H_CLK>;
  22. clock-names = "ram";
  23. ...
  24. };
  25. I have provided this in the MSM8660 device tree, and will
  26. provide patches for the other targets.
  27. Cc: Björn Andersson <bjorn.andersson@linaro.org>
  28. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  29. Signed-off-by: Lee Jones <lee.jones@linaro.org>
  30. ---
  31. drivers/mfd/qcom_rpm.c | 20 ++++++++++++++++++++
  32. 1 file changed, 20 insertions(+)
  33. --- a/drivers/mfd/qcom_rpm.c
  34. +++ b/drivers/mfd/qcom_rpm.c
  35. @@ -21,6 +21,7 @@
  36. #include <linux/mfd/qcom_rpm.h>
  37. #include <linux/mfd/syscon.h>
  38. #include <linux/regmap.h>
  39. +#include <linux/clk.h>
  40. #include <dt-bindings/mfd/qcom-rpm.h>
  41. @@ -48,6 +49,7 @@ struct qcom_rpm {
  42. struct regmap *ipc_regmap;
  43. unsigned ipc_offset;
  44. unsigned ipc_bit;
  45. + struct clk *ramclk;
  46. struct completion ack;
  47. struct mutex lock;
  48. @@ -503,6 +505,20 @@ static int qcom_rpm_probe(struct platfor
  49. mutex_init(&rpm->lock);
  50. init_completion(&rpm->ack);
  51. + /* Enable message RAM clock */
  52. + rpm->ramclk = devm_clk_get(&pdev->dev, "ram");
  53. + if (IS_ERR(rpm->ramclk)) {
  54. + ret = PTR_ERR(rpm->ramclk);
  55. + if (ret == -EPROBE_DEFER)
  56. + return ret;
  57. + /*
  58. + * Fall through in all other cases, as the clock is
  59. + * optional. (Does not exist on all platforms.)
  60. + */
  61. + rpm->ramclk = NULL;
  62. + }
  63. + clk_prepare_enable(rpm->ramclk); /* Accepts NULL */
  64. +
  65. irq_ack = platform_get_irq_byname(pdev, "ack");
  66. if (irq_ack < 0) {
  67. dev_err(&pdev->dev, "required ack interrupt missing\n");
  68. @@ -625,7 +641,11 @@ static int qcom_rpm_probe(struct platfor
  69. static int qcom_rpm_remove(struct platform_device *pdev)
  70. {
  71. + struct qcom_rpm *rpm = dev_get_drvdata(&pdev->dev);
  72. +
  73. of_platform_depopulate(&pdev->dev);
  74. + clk_disable_unprepare(rpm->ramclk);
  75. +
  76. return 0;
  77. }