145-power-reset-at91-sama5d2_shdwc-add-support-for-sama7.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. From f39f2312a68ec0843adba08f9c9182ffa5624190 Mon Sep 17 00:00:00 2001
  2. From: Claudiu Beznea <[email protected]>
  3. Date: Wed, 16 Dec 2020 14:57:33 +0200
  4. Subject: [PATCH 145/247] power: reset: at91-sama5d2_shdwc: add support for
  5. sama7g5
  6. Add support for SAMA7G5 by adding proper struct reg_config structure
  7. and since SAMA7G5 is not currently on LPDDR setups the commit also
  8. avoid the mapping of DDR controller.
  9. Signed-off-by: Claudiu Beznea <[email protected]>
  10. Signed-off-by: Sebastian Reichel <[email protected]>
  11. ---
  12. drivers/power/reset/at91-sama5d2_shdwc.c | 72 ++++++++++++++++++------
  13. 1 file changed, 54 insertions(+), 18 deletions(-)
  14. --- a/drivers/power/reset/at91-sama5d2_shdwc.c
  15. +++ b/drivers/power/reset/at91-sama5d2_shdwc.c
  16. @@ -78,9 +78,15 @@ struct pmc_reg_config {
  17. u8 mckr;
  18. };
  19. +struct ddrc_reg_config {
  20. + u32 type_offset;
  21. + u32 type_mask;
  22. +};
  23. +
  24. struct reg_config {
  25. struct shdwc_reg_config shdwc;
  26. struct pmc_reg_config pmc;
  27. + struct ddrc_reg_config ddrc;
  28. };
  29. struct shdwc {
  30. @@ -262,6 +268,10 @@ static const struct reg_config sama5d2_r
  31. .pmc = {
  32. .mckr = 0x30,
  33. },
  34. + .ddrc = {
  35. + .type_offset = AT91_DDRSDRC_MDR,
  36. + .type_mask = AT91_DDRSDRC_MD
  37. + },
  38. };
  39. static const struct reg_config sam9x60_reg_config = {
  40. @@ -275,6 +285,23 @@ static const struct reg_config sam9x60_r
  41. .pmc = {
  42. .mckr = 0x28,
  43. },
  44. + .ddrc = {
  45. + .type_offset = AT91_DDRSDRC_MDR,
  46. + .type_mask = AT91_DDRSDRC_MD
  47. + },
  48. +};
  49. +
  50. +static const struct reg_config sama7g5_reg_config = {
  51. + .shdwc = {
  52. + .wkup_pin_input = 0,
  53. + .mr_rtcwk_shift = 17,
  54. + .mr_rttwk_shift = 16,
  55. + .sr_rtcwk_shift = 5,
  56. + .sr_rttwk_shift = 4,
  57. + },
  58. + .pmc = {
  59. + .mckr = 0x28,
  60. + },
  61. };
  62. static const struct of_device_id at91_shdwc_of_match[] = {
  63. @@ -285,6 +312,10 @@ static const struct of_device_id at91_sh
  64. {
  65. .compatible = "microchip,sam9x60-shdwc",
  66. .data = &sam9x60_reg_config,
  67. + },
  68. + {
  69. + .compatible = "microchip,sama7g5-shdwc",
  70. + .data = &sama7g5_reg_config,
  71. }, {
  72. /*sentinel*/
  73. }
  74. @@ -294,6 +325,7 @@ MODULE_DEVICE_TABLE(of, at91_shdwc_of_ma
  75. static const struct of_device_id at91_pmc_ids[] = {
  76. { .compatible = "atmel,sama5d2-pmc" },
  77. { .compatible = "microchip,sam9x60-pmc" },
  78. + { .compatible = "microchip,sama7g5-pmc" },
  79. { /* Sentinel. */ }
  80. };
  81. @@ -355,30 +387,34 @@ static int __init at91_shdwc_probe(struc
  82. goto clk_disable;
  83. }
  84. - np = of_find_compatible_node(NULL, NULL, "atmel,sama5d3-ddramc");
  85. - if (!np) {
  86. - ret = -ENODEV;
  87. - goto unmap;
  88. - }
  89. + if (at91_shdwc->rcfg->ddrc.type_mask) {
  90. + np = of_find_compatible_node(NULL, NULL,
  91. + "atmel,sama5d3-ddramc");
  92. + if (!np) {
  93. + ret = -ENODEV;
  94. + goto unmap;
  95. + }
  96. - at91_shdwc->mpddrc_base = of_iomap(np, 0);
  97. - of_node_put(np);
  98. + at91_shdwc->mpddrc_base = of_iomap(np, 0);
  99. + of_node_put(np);
  100. - if (!at91_shdwc->mpddrc_base) {
  101. - ret = -ENOMEM;
  102. - goto unmap;
  103. + if (!at91_shdwc->mpddrc_base) {
  104. + ret = -ENOMEM;
  105. + goto unmap;
  106. + }
  107. +
  108. + ddr_type = readl(at91_shdwc->mpddrc_base +
  109. + at91_shdwc->rcfg->ddrc.type_offset) &
  110. + at91_shdwc->rcfg->ddrc.type_mask;
  111. + if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 &&
  112. + ddr_type != AT91_DDRSDRC_MD_LPDDR3) {
  113. + iounmap(at91_shdwc->mpddrc_base);
  114. + at91_shdwc->mpddrc_base = NULL;
  115. + }
  116. }
  117. pm_power_off = at91_poweroff;
  118. - ddr_type = readl(at91_shdwc->mpddrc_base + AT91_DDRSDRC_MDR) &
  119. - AT91_DDRSDRC_MD;
  120. - if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 &&
  121. - ddr_type != AT91_DDRSDRC_MD_LPDDR3) {
  122. - iounmap(at91_shdwc->mpddrc_base);
  123. - at91_shdwc->mpddrc_base = NULL;
  124. - }
  125. -
  126. return 0;
  127. unmap: