0031-soc-ti-pruss-Refactor-the-CFG-sub-module-init.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. From 0b81c5fbe821f75cf21be29afb9952a47ac40a50 Mon Sep 17 00:00:00 2001
  2. From: Suman Anna <s-anna@ti.com>
  3. Date: Sun, 31 Jan 2021 20:53:43 -0800
  4. Subject: [PATCH] soc: ti: pruss: Refactor the CFG sub-module init
  5. The CFG sub-module is not present on some earlier SoCs like the
  6. DA850/OMAPL-138 in the TI Davinci family. Refactor out the CFG
  7. sub-module parse and initialization logic into a separate function
  8. to make it easier to add logic for the PRUSS IP on the above legacy
  9. SoC families.
  10. Signed-off-by: Suman Anna <s-anna@ti.com>
  11. Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
  12. ---
  13. drivers/soc/ti/pruss.c | 91 +++++++++++++++++++++++-------------------
  14. 1 file changed, 50 insertions(+), 41 deletions(-)
  15. diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
  16. index dc94335fc351..afc8aae68035 100644
  17. --- a/drivers/soc/ti/pruss.c
  18. +++ b/drivers/soc/ti/pruss.c
  19. @@ -161,6 +161,53 @@ static struct regmap_config regmap_conf = {
  20. .reg_stride = 4,
  21. };
  22. +static int pruss_cfg_of_init(struct device *dev, struct pruss *pruss)
  23. +{
  24. + struct device_node *np = dev_of_node(dev);
  25. + struct device_node *child;
  26. + struct resource res;
  27. + int ret;
  28. +
  29. + child = of_get_child_by_name(np, "cfg");
  30. + if (!child) {
  31. + dev_err(dev, "%pOF is missing its 'cfg' node\n", child);
  32. + return -ENODEV;
  33. + }
  34. +
  35. + if (of_address_to_resource(child, 0, &res)) {
  36. + ret = -ENOMEM;
  37. + goto node_put;
  38. + }
  39. +
  40. + pruss->cfg_base = devm_ioremap(dev, res.start, resource_size(&res));
  41. + if (!pruss->cfg_base) {
  42. + ret = -ENOMEM;
  43. + goto node_put;
  44. + }
  45. +
  46. + regmap_conf.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", child,
  47. + (u64)res.start);
  48. + regmap_conf.max_register = resource_size(&res) - 4;
  49. +
  50. + pruss->cfg_regmap = devm_regmap_init_mmio(dev, pruss->cfg_base,
  51. + &regmap_conf);
  52. + kfree(regmap_conf.name);
  53. + if (IS_ERR(pruss->cfg_regmap)) {
  54. + dev_err(dev, "regmap_init_mmio failed for cfg, ret = %ld\n",
  55. + PTR_ERR(pruss->cfg_regmap));
  56. + ret = PTR_ERR(pruss->cfg_regmap);
  57. + goto node_put;
  58. + }
  59. +
  60. + ret = pruss_clk_init(pruss, child);
  61. + if (ret)
  62. + dev_err(dev, "pruss_clk_init failed, ret = %d\n", ret);
  63. +
  64. +node_put:
  65. + of_node_put(child);
  66. + return ret;
  67. +}
  68. +
  69. static int pruss_probe(struct platform_device *pdev)
  70. {
  71. struct device *dev = &pdev->dev;
  72. @@ -239,56 +286,18 @@ static int pruss_probe(struct platform_device *pdev)
  73. goto rpm_disable;
  74. }
  75. - child = of_get_child_by_name(np, "cfg");
  76. - if (!child) {
  77. - dev_err(dev, "%pOF is missing its 'cfg' node\n", child);
  78. - ret = -ENODEV;
  79. + ret = pruss_cfg_of_init(dev, pruss);
  80. + if (ret < 0)
  81. goto rpm_put;
  82. - }
  83. -
  84. - if (of_address_to_resource(child, 0, &res)) {
  85. - ret = -ENOMEM;
  86. - goto node_put;
  87. - }
  88. -
  89. - pruss->cfg_base = devm_ioremap(dev, res.start, resource_size(&res));
  90. - if (!pruss->cfg_base) {
  91. - ret = -ENOMEM;
  92. - goto node_put;
  93. - }
  94. -
  95. - regmap_conf.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", child,
  96. - (u64)res.start);
  97. - regmap_conf.max_register = resource_size(&res) - 4;
  98. -
  99. - pruss->cfg_regmap = devm_regmap_init_mmio(dev, pruss->cfg_base,
  100. - &regmap_conf);
  101. - kfree(regmap_conf.name);
  102. - if (IS_ERR(pruss->cfg_regmap)) {
  103. - dev_err(dev, "regmap_init_mmio failed for cfg, ret = %ld\n",
  104. - PTR_ERR(pruss->cfg_regmap));
  105. - ret = PTR_ERR(pruss->cfg_regmap);
  106. - goto node_put;
  107. - }
  108. -
  109. - ret = pruss_clk_init(pruss, child);
  110. - if (ret) {
  111. - dev_err(dev, "pruss_clk_init failed, ret = %d\n", ret);
  112. - goto node_put;
  113. - }
  114. ret = devm_of_platform_populate(dev);
  115. if (ret) {
  116. dev_err(dev, "failed to register child devices\n");
  117. - goto node_put;
  118. + goto rpm_put;
  119. }
  120. - of_node_put(child);
  121. -
  122. return 0;
  123. -node_put:
  124. - of_node_put(child);
  125. rpm_put:
  126. pm_runtime_put_sync(dev);
  127. rpm_disable: