All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Nicolas Ferre <nicolas.ferre@atmel.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>,
	Stephen Boyd <sboyd@codeaurora.org>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
	Michael Turquette <mturquette@baylibre.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>
Subject: [PATCH v5 07/13] ARM: at91: pm: find and remap the pmc
Date: Wed, 27 Jan 2016 17:17:05 +0100	[thread overview]
Message-ID: <1453911425-30090-1-git-send-email-alexandre.belloni@free-electrons.com> (raw)
In-Reply-To: <1453911072-23608-8-git-send-email-alexandre.belloni@free-electrons.com>

To avoid relying on at91_pmc_read(), find the pmc node and remap it
locally.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---

Changes in v5:
 - properly use __initconst

 arch/arm/mach-at91/pm.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index db32bf846cef..8923efbfa7fa 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -35,6 +35,8 @@
 #include "generic.h"
 #include "pm.h"
 
+static void __iomem *pmc;
+
 /*
  * FIXME: this is needed to communicate between the pinctrl driver and
  * the PM implementation in the machine. Possibly part of the PM
@@ -87,7 +89,7 @@ static int at91_pm_verify_clocks(void)
 	unsigned long scsr;
 	int i;
 
-	scsr = at91_pmc_read(AT91_PMC_SCSR);
+	scsr = readl(pmc + AT91_PMC_SCSR);
 
 	/* USB must not be using PLLB */
 	if ((scsr & at91_pm_data.uhp_udp_mask) != 0) {
@@ -101,8 +103,7 @@ static int at91_pm_verify_clocks(void)
 
 		if ((scsr & (AT91_PMC_PCK0 << i)) == 0)
 			continue;
-
-		css = at91_pmc_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
+		css = readl(pmc + AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
 		if (css != AT91_PMC_CSS_SLOW) {
 			pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css);
 			return 0;
@@ -145,8 +146,8 @@ static void at91_pm_suspend(suspend_state_t state)
 	flush_cache_all();
 	outer_disable();
 
-	at91_suspend_sram_fn(at91_pmc_base, at91_ramc_base[0],
-				at91_ramc_base[1], pm_data);
+	at91_suspend_sram_fn(pmc, at91_ramc_base[0],
+			     at91_ramc_base[1], pm_data);
 
 	outer_resume();
 }
@@ -399,13 +400,33 @@ static void __init at91_pm_sram_init(void)
 			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
 }
 
+static const struct of_device_id atmel_pmc_ids[] __initconst = {
+	{ .compatible = "atmel,at91rm9200-pmc"  },
+	{ .compatible = "atmel,at91sam9260-pmc" },
+	{ .compatible = "atmel,at91sam9g45-pmc" },
+	{ .compatible = "atmel,at91sam9n12-pmc" },
+	{ .compatible = "atmel,at91sam9x5-pmc" },
+	{ .compatible = "atmel,sama5d3-pmc" },
+	{ .compatible = "atmel,sama5d2-pmc" },
+	{ /* sentinel */ },
+};
+
 static void __init at91_pm_init(void)
 {
-	at91_pm_sram_init();
+	struct device_node *pmc_np;
 
 	if (at91_cpuidle_device.dev.platform_data)
 		platform_device_register(&at91_cpuidle_device);
 
+	pmc_np = of_find_matching_node(NULL, atmel_pmc_ids);
+	pmc = of_iomap(pmc_np, 0);
+	if (!pmc) {
+		pr_err("AT91: PM not supported, PMC not found\n");
+		return;
+	}
+
+	at91_pm_sram_init();
+
 	if (at91_suspend_sram_fn)
 		suspend_set_ops(&at91_pm_ops);
 	else
-- 
2.5.0

WARNING: multiple messages have this Message-ID (diff)
From: alexandre.belloni@free-electrons.com (Alexandre Belloni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 07/13] ARM: at91: pm: find and remap the pmc
Date: Wed, 27 Jan 2016 17:17:05 +0100	[thread overview]
Message-ID: <1453911425-30090-1-git-send-email-alexandre.belloni@free-electrons.com> (raw)
In-Reply-To: <1453911072-23608-8-git-send-email-alexandre.belloni@free-electrons.com>

To avoid relying on at91_pmc_read(), find the pmc node and remap it
locally.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---

Changes in v5:
 - properly use __initconst

 arch/arm/mach-at91/pm.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index db32bf846cef..8923efbfa7fa 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -35,6 +35,8 @@
 #include "generic.h"
 #include "pm.h"
 
+static void __iomem *pmc;
+
 /*
  * FIXME: this is needed to communicate between the pinctrl driver and
  * the PM implementation in the machine. Possibly part of the PM
@@ -87,7 +89,7 @@ static int at91_pm_verify_clocks(void)
 	unsigned long scsr;
 	int i;
 
-	scsr = at91_pmc_read(AT91_PMC_SCSR);
+	scsr = readl(pmc + AT91_PMC_SCSR);
 
 	/* USB must not be using PLLB */
 	if ((scsr & at91_pm_data.uhp_udp_mask) != 0) {
@@ -101,8 +103,7 @@ static int at91_pm_verify_clocks(void)
 
 		if ((scsr & (AT91_PMC_PCK0 << i)) == 0)
 			continue;
-
-		css = at91_pmc_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
+		css = readl(pmc + AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
 		if (css != AT91_PMC_CSS_SLOW) {
 			pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css);
 			return 0;
@@ -145,8 +146,8 @@ static void at91_pm_suspend(suspend_state_t state)
 	flush_cache_all();
 	outer_disable();
 
-	at91_suspend_sram_fn(at91_pmc_base, at91_ramc_base[0],
-				at91_ramc_base[1], pm_data);
+	at91_suspend_sram_fn(pmc, at91_ramc_base[0],
+			     at91_ramc_base[1], pm_data);
 
 	outer_resume();
 }
@@ -399,13 +400,33 @@ static void __init at91_pm_sram_init(void)
 			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
 }
 
+static const struct of_device_id atmel_pmc_ids[] __initconst = {
+	{ .compatible = "atmel,at91rm9200-pmc"  },
+	{ .compatible = "atmel,at91sam9260-pmc" },
+	{ .compatible = "atmel,at91sam9g45-pmc" },
+	{ .compatible = "atmel,at91sam9n12-pmc" },
+	{ .compatible = "atmel,at91sam9x5-pmc" },
+	{ .compatible = "atmel,sama5d3-pmc" },
+	{ .compatible = "atmel,sama5d2-pmc" },
+	{ /* sentinel */ },
+};
+
 static void __init at91_pm_init(void)
 {
-	at91_pm_sram_init();
+	struct device_node *pmc_np;
 
 	if (at91_cpuidle_device.dev.platform_data)
 		platform_device_register(&at91_cpuidle_device);
 
+	pmc_np = of_find_matching_node(NULL, atmel_pmc_ids);
+	pmc = of_iomap(pmc_np, 0);
+	if (!pmc) {
+		pr_err("AT91: PM not supported, PMC not found\n");
+		return;
+	}
+
+	at91_pm_sram_init();
+
 	if (at91_suspend_sram_fn)
 		suspend_set_ops(&at91_pm_ops);
 	else
-- 
2.5.0

  reply	other threads:[~2016-01-27 16:21 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-27 16:10 [PATCH v4 00/13] ARM: at91: PMC driver rework Alexandre Belloni
2016-01-27 16:10 ` Alexandre Belloni
2016-01-27 16:11 ` [PATCH v4 01/13] clk: at91: make use of syscon to share PMC registers in several drivers Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-27 16:11 ` [PATCH v4 02/13] clk: at91: make use of syscon/regmap internally Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-28  8:31   ` Stephen Boyd
2016-01-28  8:31     ` Stephen Boyd
2016-01-27 16:11 ` [PATCH v4 03/13] clk: at91: remove IRQ handling and use polling Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-28  8:31   ` Stephen Boyd
2016-01-28  8:31     ` Stephen Boyd
2016-01-27 16:11 ` [PATCH v4 04/13] clk: at91: pmc: merge at91_pmc_init in atmel_pmc_probe Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-27 16:11 ` [PATCH v4 05/13] clk: at91: pmc: move pmc structures to C file Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-27 16:11 ` [PATCH v4 06/13] ARM: at91: pm: simply call at91_pm_init Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-27 16:11 ` [PATCH v4 07/13] ARM: at91: pm: find and remap the pmc Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-27 16:17   ` Alexandre Belloni [this message]
2016-01-27 16:17     ` [PATCH v5 " Alexandre Belloni
2016-01-27 17:55   ` [PATCH v4 " kbuild test robot
2016-01-27 17:55     ` kbuild test robot
2016-01-28  8:33   ` Stephen Boyd
2016-01-28  8:33     ` Stephen Boyd
2016-01-28  8:38     ` Alexandre Belloni
2016-01-28  8:38       ` Alexandre Belloni
2016-01-27 16:11 ` [PATCH v4 08/13] ARM: at91: pm: move idle functions to pm.c Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-27 16:11 ` [PATCH v4 09/13] ARM: at91: remove useless includes and function prototypes Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-27 16:11 ` [PATCH v4 10/13] usb: gadget: atmel: access the PMC using regmap Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-27 16:11 ` [PATCH v4 11/13] clk: at91: pmc: drop at91_pmc_base Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-27 16:11 ` [PATCH v4 12/13] clk: at91: pmc: remove useless capacities handling Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-28  8:30   ` Stephen Boyd
2016-01-28  8:30     ` Stephen Boyd
2016-01-27 16:11 ` [PATCH v4 13/13] clk: at91: remove useless includes Alexandre Belloni
2016-01-27 16:11   ` Alexandre Belloni
2016-01-28  8:30   ` Stephen Boyd
2016-01-28  8:30     ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453911425-30090-1-git-send-email-alexandre.belloni@free-electrons.com \
    --to=alexandre.belloni@free-electrons.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=nicolas.ferre@atmel.com \
    --cc=plagnioj@jcrosoft.com \
    --cc=sboyd@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.