1 From f39f2312a68ec0843adba08f9c9182ffa5624190 Mon Sep 17 00:00:00 2001
2 From: Claudiu Beznea <claudiu.beznea@microchip.com>
3 Date: Wed, 16 Dec 2020 14:57:33 +0200
4 Subject: [PATCH 145/247] power: reset: at91-sama5d2_shdwc: add support for
7 Add support for SAMA7G5 by adding proper struct reg_config structure
8 and since SAMA7G5 is not currently on LPDDR setups the commit also
9 avoid the mapping of DDR controller.
11 Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
12 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
14 drivers/power/reset/at91-sama5d2_shdwc.c | 72 ++++++++++++++++++------
15 1 file changed, 54 insertions(+), 18 deletions(-)
17 diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c
18 index d9cf91e5b06d..125e592af445 100644
19 --- a/drivers/power/reset/at91-sama5d2_shdwc.c
20 +++ b/drivers/power/reset/at91-sama5d2_shdwc.c
21 @@ -78,9 +78,15 @@ struct pmc_reg_config {
25 +struct ddrc_reg_config {
31 struct shdwc_reg_config shdwc;
32 struct pmc_reg_config pmc;
33 + struct ddrc_reg_config ddrc;
37 @@ -262,6 +268,10 @@ static const struct reg_config sama5d2_reg_config = {
42 + .type_offset = AT91_DDRSDRC_MDR,
43 + .type_mask = AT91_DDRSDRC_MD
47 static const struct reg_config sam9x60_reg_config = {
48 @@ -275,6 +285,23 @@ static const struct reg_config sam9x60_reg_config = {
53 + .type_offset = AT91_DDRSDRC_MDR,
54 + .type_mask = AT91_DDRSDRC_MD
58 +static const struct reg_config sama7g5_reg_config = {
60 + .wkup_pin_input = 0,
61 + .mr_rtcwk_shift = 17,
62 + .mr_rttwk_shift = 16,
63 + .sr_rtcwk_shift = 5,
64 + .sr_rttwk_shift = 4,
71 static const struct of_device_id at91_shdwc_of_match[] = {
72 @@ -285,6 +312,10 @@ static const struct of_device_id at91_shdwc_of_match[] = {
74 .compatible = "microchip,sam9x60-shdwc",
75 .data = &sam9x60_reg_config,
78 + .compatible = "microchip,sama7g5-shdwc",
79 + .data = &sama7g5_reg_config,
83 @@ -294,6 +325,7 @@ MODULE_DEVICE_TABLE(of, at91_shdwc_of_match);
84 static const struct of_device_id at91_pmc_ids[] = {
85 { .compatible = "atmel,sama5d2-pmc" },
86 { .compatible = "microchip,sam9x60-pmc" },
87 + { .compatible = "microchip,sama7g5-pmc" },
91 @@ -355,30 +387,34 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
95 - np = of_find_compatible_node(NULL, NULL, "atmel,sama5d3-ddramc");
100 + if (at91_shdwc->rcfg->ddrc.type_mask) {
101 + np = of_find_compatible_node(NULL, NULL,
102 + "atmel,sama5d3-ddramc");
108 - at91_shdwc->mpddrc_base = of_iomap(np, 0);
110 + at91_shdwc->mpddrc_base = of_iomap(np, 0);
113 - if (!at91_shdwc->mpddrc_base) {
116 + if (!at91_shdwc->mpddrc_base) {
121 + ddr_type = readl(at91_shdwc->mpddrc_base +
122 + at91_shdwc->rcfg->ddrc.type_offset) &
123 + at91_shdwc->rcfg->ddrc.type_mask;
124 + if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 &&
125 + ddr_type != AT91_DDRSDRC_MD_LPDDR3) {
126 + iounmap(at91_shdwc->mpddrc_base);
127 + at91_shdwc->mpddrc_base = NULL;
131 pm_power_off = at91_poweroff;
133 - ddr_type = readl(at91_shdwc->mpddrc_base + AT91_DDRSDRC_MDR) &
135 - if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 &&
136 - ddr_type != AT91_DDRSDRC_MD_LPDDR3) {
137 - iounmap(at91_shdwc->mpddrc_base);
138 - at91_shdwc->mpddrc_base = NULL;