* [PATCH 0/6] AT91 cleanup for 3.20 #2
@ 2015-01-12 21:23 Alexandre Belloni
2015-01-12 21:23 ` [PATCH 1/6] ARM: at91: pm: rework cpu detection Alexandre Belloni
` (5 more replies)
0 siblings, 6 replies; 16+ messages in thread
From: Alexandre Belloni @ 2015-01-12 21:23 UTC (permalink / raw)
To: linux-arm-kernel
This patch sets is based on AT91 cleanup for 3.20 #1
and depends on AT91 DT for 3.20 #1 because it uses the added SRAM nodes.
The first two patches rework the pm code to get rid of cpu_is_xxx (they will be
dropped soon) and use the SRAM from the genpool instead of relying on the remap
done by at91_init_sram.
Then the following patches get rid of at91_init_sram, taking .map_io for almost
all SoCs but the sama5d4 (more cleanups coming soon for that part).
The final patch moves at91rm9200_idle to clk/at91/pmc.c and allows to almost
empty arch/arm/mach-at91/at91rm9200.c (It is actually empty once "Atmel System
Timer cleanups" is applied).
Alexandre Belloni (6):
ARM: at91: pm: rework cpu detection
ARM: at91: pm: use the mmio-sram pool to access SRAM
ARM: at91: remove useless map_io
ARM: at91: sama5d4: remove useless call to at91_init_sram
ARM: at91: remove unused at91_init_sram
ARM: at91: move at91rm9200_idle() to clk/at91/pmc.c
arch/arm/mach-at91/Kconfig | 1 +
arch/arm/mach-at91/at91rm9200.c | 15 ------
arch/arm/mach-at91/at91sam9260.c | 27 -----------
arch/arm/mach-at91/at91sam9261.c | 9 ----
arch/arm/mach-at91/at91sam9263.c | 7 ---
arch/arm/mach-at91/at91sam9g45.c | 7 ---
arch/arm/mach-at91/at91sam9n12.c | 6 ---
arch/arm/mach-at91/at91sam9rl.c | 18 -------
arch/arm/mach-at91/at91sam9x5.c | 6 ---
arch/arm/mach-at91/generic.h | 3 +-
arch/arm/mach-at91/pm.c | 100 ++++++++++++++++++++++++++++++---------
arch/arm/mach-at91/sama5d3.c | 6 ---
arch/arm/mach-at91/sama5d4.c | 1 -
arch/arm/mach-at91/setup.c | 20 --------
drivers/clk/at91/pmc.c | 9 ++++
15 files changed, 89 insertions(+), 146 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/6] ARM: at91: pm: rework cpu detection
2015-01-12 21:23 [PATCH 0/6] AT91 cleanup for 3.20 #2 Alexandre Belloni
@ 2015-01-12 21:23 ` Alexandre Belloni
2015-01-14 19:14 ` Jean-Christophe PLAGNIOL-VILLARD
2015-01-12 21:23 ` [PATCH 2/6] ARM: at91: pm: use the mmio-sram pool to access SRAM Alexandre Belloni
` (4 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Alexandre Belloni @ 2015-01-12 21:23 UTC (permalink / raw)
To: linux-arm-kernel
Store SoC differences in a struct to remove cpu_is_* usage.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/mach-at91/pm.c | 54 ++++++++++++++++++++++++++++++-------------------
1 file changed, 33 insertions(+), 21 deletions(-)
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 9b15169a1c62..79aa793d1f00 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -17,6 +17,7 @@
#include <linux/interrupt.h>
#include <linux/sysfs.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/clk/at91_pmc.h>
@@ -32,6 +33,11 @@
#include "generic.h"
#include "pm.h"
+static struct {
+ unsigned long uhp_udp_mask;
+ int memctrl;
+} at91_pm_data;
+
static void (*at91_pm_standby)(void);
static int at91_pm_valid_state(suspend_state_t state)
@@ -71,17 +77,9 @@ static int at91_pm_verify_clocks(void)
scsr = at91_pmc_read(AT91_PMC_SCSR);
/* USB must not be using PLLB */
- if (cpu_is_at91rm9200()) {
- if ((scsr & (AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP)) != 0) {
- pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
- return 0;
- }
- } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263()
- || cpu_is_at91sam9g20() || cpu_is_at91sam9g10()) {
- if ((scsr & (AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP)) != 0) {
- pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
- return 0;
- }
+ if ((scsr & at91_pm_data.uhp_udp_mask) != 0) {
+ pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
+ return 0;
}
/* PCK0..PCK3 must be disabled, or configured to use clk32k */
@@ -149,18 +147,13 @@ static int at91_pm_enter(suspend_state_t state)
* turning off the main oscillator; reverse on wakeup.
*/
if (slow_clock) {
- int memctrl = AT91_MEMCTRL_SDRAMC;
-
- if (cpu_is_at91rm9200())
- memctrl = AT91_MEMCTRL_MC;
- else if (cpu_is_at91sam9g45())
- memctrl = AT91_MEMCTRL_DDRSDR;
#ifdef CONFIG_AT91_SLOW_CLOCK
/* copy slow_clock handler to SRAM, and call it */
memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
#endif
slow_clock(at91_pmc_base, at91_ramc_base[0],
- at91_ramc_base[1], memctrl);
+ at91_ramc_base[1],
+ at91_pm_data.memctrl);
break;
} else {
pr_info("AT91: PM - no slow clock mode enabled ...\n");
@@ -237,10 +230,29 @@ static int __init at91_pm_init(void)
pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : ""));
- /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
- if (cpu_is_at91rm9200())
+ at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
+
+ if (of_machine_is_compatible("atmel,at91rm9200")) {
+ /*
+ * AT91RM9200 SDRAM low-power mode cannot be used with
+ * self-refresh.
+ */
at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
-
+
+ at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP |
+ AT91RM9200_PMC_UDP;
+ at91_pm_data.memctrl = AT91_MEMCTRL_MC;
+ } else if (of_machine_is_compatible("atmel,at91sam9260") ||
+ of_machine_is_compatible("atmel,at91sam9g20") ||
+ of_machine_is_compatible("atmel,at91sam9261") ||
+ of_machine_is_compatible("atmel,at91sam9g10") ||
+ of_machine_is_compatible("atmel,at91sam9263")) {
+ at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP |
+ AT91SAM926x_PMC_UDP;
+ } else if (of_machine_is_compatible("atmel,at91sam9g45")) {
+ at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
+ }
+
if (at91_cpuidle_device.dev.platform_data)
platform_device_register(&at91_cpuidle_device);
--
2.1.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/6] ARM: at91: pm: use the mmio-sram pool to access SRAM
2015-01-12 21:23 [PATCH 0/6] AT91 cleanup for 3.20 #2 Alexandre Belloni
2015-01-12 21:23 ` [PATCH 1/6] ARM: at91: pm: rework cpu detection Alexandre Belloni
@ 2015-01-12 21:23 ` Alexandre Belloni
2015-01-15 8:53 ` Yang, Wenyou
2015-01-12 21:23 ` [PATCH 3/6] ARM: at91: remove useless map_io Alexandre Belloni
` (3 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Alexandre Belloni @ 2015-01-12 21:23 UTC (permalink / raw)
To: linux-arm-kernel
Now that the SRAM is part of a genpool, use it to allocate memory to use for the
slowclock implementation.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/mach-at91/Kconfig | 1 +
arch/arm/mach-at91/pm.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index cec0fb5d621a..b7dcef50db23 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -178,6 +178,7 @@ comment "AT91 Feature Selections"
config AT91_SLOW_CLOCK
bool "Suspend-to-RAM disables main oscillator"
+ select SRAM
depends on SUSPEND
help
Select this if you want Suspend-to-RAM to save the most power
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 79aa793d1f00..515791edcc60 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -14,10 +14,12 @@
#include <linux/suspend.h>
#include <linux/sched.h>
#include <linux/proc_fs.h>
+#include <linux/genalloc.h>
#include <linux/interrupt.h>
#include <linux/sysfs.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/clk/at91_pmc.h>
@@ -222,10 +224,52 @@ void at91_pm_set_standby(void (*at91_standby)(void))
}
}
+#ifdef CONFIG_AT91_SLOW_CLOCK
+static void __init at91_pm_sram_init(void)
+{
+ struct gen_pool *sram_pool;
+ phys_addr_t sram_pbase;
+ unsigned long sram_base;
+ struct device_node *node;
+ struct platform_device *pdev;
+
+ node = of_find_compatible_node(NULL, NULL, "mmio-sram");
+ if (!node) {
+ pr_warn("%s: failed to find sram node!\n", __func__);
+ return;
+ }
+
+ pdev = of_find_device_by_node(node);
+ if (!pdev) {
+ pr_warn("%s: failed to find sram device!\n", __func__);
+ goto put_node;
+ }
+
+ sram_pool = dev_get_gen_pool(&pdev->dev);
+ if (!sram_pool) {
+ pr_warn("%s: sram pool unavailable!\n", __func__);
+ goto put_node;
+ }
+
+ sram_base = gen_pool_alloc(sram_pool, at91_slow_clock_sz);
+ if (!sram_base) {
+ pr_warn("%s: unable to alloc ocram!\n", __func__);
+ goto put_node;
+ }
+
+ sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
+ slow_clock = __arm_ioremap_exec(sram_pbase, at91_slow_clock_sz, false);
+
+put_node:
+ of_node_put(node);
+}
+#endif
+
+
static int __init at91_pm_init(void)
{
#ifdef CONFIG_AT91_SLOW_CLOCK
- slow_clock = (void *) (AT91_IO_VIRT_BASE - at91_slow_clock_sz);
+ at91_pm_sram_init();
#endif
pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : ""));
--
2.1.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/6] ARM: at91: remove useless map_io
2015-01-12 21:23 [PATCH 0/6] AT91 cleanup for 3.20 #2 Alexandre Belloni
2015-01-12 21:23 ` [PATCH 1/6] ARM: at91: pm: rework cpu detection Alexandre Belloni
2015-01-12 21:23 ` [PATCH 2/6] ARM: at91: pm: use the mmio-sram pool to access SRAM Alexandre Belloni
@ 2015-01-12 21:23 ` Alexandre Belloni
2015-01-12 21:23 ` [PATCH 4/6] ARM: at91: sama5d4: remove useless call to at91_init_sram Alexandre Belloni
` (2 subsequent siblings)
5 siblings, 0 replies; 16+ messages in thread
From: Alexandre Belloni @ 2015-01-12 21:23 UTC (permalink / raw)
To: linux-arm-kernel
Now that the SRAM is initialized by the mmio-sram driver, .map_io is useless.
remove it.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/mach-at91/at91rm9200.c | 6 ------
arch/arm/mach-at91/at91sam9260.c | 27 ---------------------------
arch/arm/mach-at91/at91sam9261.c | 9 ---------
arch/arm/mach-at91/at91sam9263.c | 7 -------
arch/arm/mach-at91/at91sam9g45.c | 7 -------
arch/arm/mach-at91/at91sam9n12.c | 6 ------
arch/arm/mach-at91/at91sam9rl.c | 18 ------------------
arch/arm/mach-at91/at91sam9x5.c | 6 ------
arch/arm/mach-at91/sama5d3.c | 6 ------
9 files changed, 92 deletions(-)
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index b52916947535..fc7c26138037 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -42,11 +42,6 @@ static void at91rm9200_restart(enum reboot_mode reboot_mode, const char *cmd)
/* --------------------------------------------------------------------
* AT91RM9200 processor initialization
* -------------------------------------------------------------------- */
-static void __init at91rm9200_map_io(void)
-{
- /* Map peripherals */
- at91_init_sram(0, AT91RM9200_SRAM_BASE, AT91RM9200_SRAM_SIZE);
-}
static void __init at91rm9200_initialize(void)
{
@@ -56,6 +51,5 @@ static void __init at91rm9200_initialize(void)
AT91_SOC_START(at91rm9200)
- .map_io = at91rm9200_map_io,
.init = at91rm9200_initialize,
AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 34e2abe82ae4..ab9841c8b0d5 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -22,38 +22,11 @@
* AT91SAM9260 processor initialization
* -------------------------------------------------------------------- */
-static void __init at91sam9xe_map_io(void)
-{
- unsigned long sram_size;
-
- switch (at91_soc_initdata.cidr & AT91_CIDR_SRAMSIZ) {
- case AT91_CIDR_SRAMSIZ_32K:
- sram_size = 2 * SZ_16K;
- break;
- case AT91_CIDR_SRAMSIZ_16K:
- default:
- sram_size = SZ_16K;
- }
-
- at91_init_sram(0, AT91SAM9XE_SRAM_BASE, sram_size);
-}
-
-static void __init at91sam9260_map_io(void)
-{
- if (cpu_is_at91sam9xe())
- at91sam9xe_map_io();
- else if (cpu_is_at91sam9g20())
- at91_init_sram(0, AT91SAM9G20_SRAM_BASE, AT91SAM9G20_SRAM_SIZE);
- else
- at91_init_sram(0, AT91SAM9260_SRAM_BASE, AT91SAM9260_SRAM_SIZE);
-}
-
static void __init at91sam9260_initialize(void)
{
arm_pm_idle = at91sam9_idle;
}
AT91_SOC_START(at91sam9260)
- .map_io = at91sam9260_map_io,
.init = at91sam9260_initialize,
AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 47878b849975..2029096b93fa 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -21,20 +21,11 @@
* AT91SAM9261 processor initialization
* -------------------------------------------------------------------- */
-static void __init at91sam9261_map_io(void)
-{
- if (cpu_is_at91sam9g10())
- at91_init_sram(0, AT91SAM9G10_SRAM_BASE, AT91SAM9G10_SRAM_SIZE);
- else
- at91_init_sram(0, AT91SAM9261_SRAM_BASE, AT91SAM9261_SRAM_SIZE);
-}
-
static void __init at91sam9261_initialize(void)
{
arm_pm_idle = at91sam9_idle;
}
AT91_SOC_START(at91sam9261)
- .map_io = at91sam9261_map_io,
.init = at91sam9261_initialize,
AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index aabcb66145d0..1fe672a05513 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -20,18 +20,11 @@
* AT91SAM9263 processor initialization
* -------------------------------------------------------------------- */
-static void __init at91sam9263_map_io(void)
-{
- at91_init_sram(0, AT91SAM9263_SRAM0_BASE, AT91SAM9263_SRAM0_SIZE);
- at91_init_sram(1, AT91SAM9263_SRAM1_BASE, AT91SAM9263_SRAM1_SIZE);
-}
-
static void __init at91sam9263_initialize(void)
{
arm_pm_idle = at91sam9_idle;
}
AT91_SOC_START(at91sam9263)
- .map_io = at91sam9263_map_io,
.init = at91sam9263_initialize,
AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 000166777a8d..d0493df40a13 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -19,18 +19,11 @@
/* --------------------------------------------------------------------
* AT91SAM9G45 processor initialization
* -------------------------------------------------------------------- */
-
-static void __init at91sam9g45_map_io(void)
-{
- at91_init_sram(0, AT91SAM9G45_SRAM_BASE, AT91SAM9G45_SRAM_SIZE);
-}
-
static void __init at91sam9g45_initialize(void)
{
arm_pm_idle = at91sam9_idle;
}
AT91_SOC_START(at91sam9g45)
- .map_io = at91sam9g45_map_io,
.init = at91sam9g45_initialize,
AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
index 0135f868ea4f..b5ea69a3eaf6 100644
--- a/arch/arm/mach-at91/at91sam9n12.c
+++ b/arch/arm/mach-at91/at91sam9n12.c
@@ -16,11 +16,5 @@
* AT91SAM9N12 processor initialization
* -------------------------------------------------------------------- */
-static void __init at91sam9n12_map_io(void)
-{
- at91_init_sram(0, AT91SAM9N12_SRAM_BASE, AT91SAM9N12_SRAM_SIZE);
-}
-
AT91_SOC_START(at91sam9n12)
- .map_io = at91sam9n12_map_io,
AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index 1babfb27694a..33acae30bb0b 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -21,29 +21,11 @@
* AT91SAM9RL processor initialization
* -------------------------------------------------------------------- */
-static void __init at91sam9rl_map_io(void)
-{
- unsigned long sram_size;
-
- switch (at91_soc_initdata.cidr & AT91_CIDR_SRAMSIZ) {
- case AT91_CIDR_SRAMSIZ_32K:
- sram_size = 2 * SZ_16K;
- break;
- case AT91_CIDR_SRAMSIZ_16K:
- default:
- sram_size = SZ_16K;
- }
-
- /* Map SRAM */
- at91_init_sram(0, AT91SAM9RL_SRAM_BASE, sram_size);
-}
-
static void __init at91sam9rl_initialize(void)
{
arm_pm_idle = at91sam9_idle;
}
AT91_SOC_START(at91sam9rl)
- .map_io = at91sam9rl_map_io,
.init = at91sam9rl_initialize,
AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index aa17520ccb0a..7b60a529db01 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -16,11 +16,5 @@
* AT91SAM9x5 processor initialization
* -------------------------------------------------------------------- */
-static void __init at91sam9x5_map_io(void)
-{
- at91_init_sram(0, AT91SAM9X5_SRAM_BASE, AT91SAM9X5_SRAM_SIZE);
-}
-
AT91_SOC_START(at91sam9x5)
- .map_io = at91sam9x5_map_io,
AT91_SOC_END
diff --git a/arch/arm/mach-at91/sama5d3.c b/arch/arm/mach-at91/sama5d3.c
index ae58feada72b..b7c64ca7107f 100644
--- a/arch/arm/mach-at91/sama5d3.c
+++ b/arch/arm/mach-at91/sama5d3.c
@@ -25,11 +25,5 @@
* AT91SAM9x5 processor initialization
* -------------------------------------------------------------------- */
-static void __init sama5d3_map_io(void)
-{
- at91_init_sram(0, SAMA5D3_SRAM_BASE, SAMA5D3_SRAM_SIZE);
-}
-
AT91_SOC_START(sama5d3)
- .map_io = sama5d3_map_io,
AT91_SOC_END
--
2.1.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/6] ARM: at91: sama5d4: remove useless call to at91_init_sram
2015-01-12 21:23 [PATCH 0/6] AT91 cleanup for 3.20 #2 Alexandre Belloni
` (2 preceding siblings ...)
2015-01-12 21:23 ` [PATCH 3/6] ARM: at91: remove useless map_io Alexandre Belloni
@ 2015-01-12 21:23 ` Alexandre Belloni
2015-01-12 21:23 ` [PATCH 5/6] ARM: at91: remove unused at91_init_sram Alexandre Belloni
2015-01-12 21:23 ` [PATCH 6/6] ARM: at91: move at91rm9200_idle() to clk/at91/pmc.c Alexandre Belloni
5 siblings, 0 replies; 16+ messages in thread
From: Alexandre Belloni @ 2015-01-12 21:23 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/mach-at91/sama5d4.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/arch/arm/mach-at91/sama5d4.c b/arch/arm/mach-at91/sama5d4.c
index 7638509639f4..fa127fb79221 100644
--- a/arch/arm/mach-at91/sama5d4.c
+++ b/arch/arm/mach-at91/sama5d4.c
@@ -56,7 +56,6 @@ static struct map_desc at91_io_desc[] __initdata = {
static void __init sama5d4_map_io(void)
{
iotable_init(at91_io_desc, ARRAY_SIZE(at91_io_desc));
- at91_init_sram(0, SAMA5D4_NS_SRAM_BASE, SAMA5D4_NS_SRAM_SIZE);
}
AT91_SOC_START(sama5d4)
--
2.1.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 5/6] ARM: at91: remove unused at91_init_sram
2015-01-12 21:23 [PATCH 0/6] AT91 cleanup for 3.20 #2 Alexandre Belloni
` (3 preceding siblings ...)
2015-01-12 21:23 ` [PATCH 4/6] ARM: at91: sama5d4: remove useless call to at91_init_sram Alexandre Belloni
@ 2015-01-12 21:23 ` Alexandre Belloni
2015-01-12 21:23 ` [PATCH 6/6] ARM: at91: move at91rm9200_idle() to clk/at91/pmc.c Alexandre Belloni
5 siblings, 0 replies; 16+ messages in thread
From: Alexandre Belloni @ 2015-01-12 21:23 UTC (permalink / raw)
To: linux-arm-kernel
SRAM initialization is now done through the mmio-sram driver and
at91_init_sram() is not called anymore, remove it.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/mach-at91/generic.h | 2 --
arch/arm/mach-at91/setup.c | 20 --------------------
2 files changed, 22 deletions(-)
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index 54f3837a0a4d..18d5547f11d5 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -17,8 +17,6 @@
/* Map io */
extern void __init at91_map_io(void);
extern void __init at91_alt_map_io(void);
-extern void __init at91_init_sram(int bank, unsigned long base,
- unsigned int length);
/* Processors */
extern void __init at91_dt_initialize(void);
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index e3c21b458bb8..4c184285d38f 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -34,26 +34,6 @@ EXPORT_SYMBOL(at91_soc_initdata);
void __iomem *at91_ramc_base[2];
EXPORT_SYMBOL_GPL(at91_ramc_base);
-static struct map_desc sram_desc[2] __initdata;
-
-void __init at91_init_sram(int bank, unsigned long base, unsigned int length)
-{
- struct map_desc *desc = &sram_desc[bank];
-
- desc->virtual = (unsigned long)AT91_IO_VIRT_BASE - length;
- if (bank > 0)
- desc->virtual -= sram_desc[bank - 1].length;
-
- desc->pfn = __phys_to_pfn(base);
- desc->length = length;
- desc->type = MT_MEMORY_RWX_NONCACHED;
-
- pr_info("sram at 0x%lx of 0x%x mapped at 0x%lx\n",
- base, length, desc->virtual);
-
- iotable_init(desc, 1);
-}
-
static struct map_desc at91_io_desc __initdata __maybe_unused = {
.virtual = (unsigned long)AT91_VA_BASE_SYS,
.pfn = __phys_to_pfn(AT91_BASE_SYS),
--
2.1.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 6/6] ARM: at91: move at91rm9200_idle() to clk/at91/pmc.c
2015-01-12 21:23 [PATCH 0/6] AT91 cleanup for 3.20 #2 Alexandre Belloni
` (4 preceding siblings ...)
2015-01-12 21:23 ` [PATCH 5/6] ARM: at91: remove unused at91_init_sram Alexandre Belloni
@ 2015-01-12 21:23 ` Alexandre Belloni
2015-01-12 22:57 ` Mike Turquette
2015-01-13 9:25 ` Boris Brezillon
5 siblings, 2 replies; 16+ messages in thread
From: Alexandre Belloni @ 2015-01-12 21:23 UTC (permalink / raw)
To: linux-arm-kernel
Move at91rm9200_idle() along with at91sam9_idle() in clk/at91/pmc.c.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
Cc: Mike Turquette <mturquette@linaro.org>
Mike, Boris,
I guess that one can go through the at91 tree unless you have any objections.
arch/arm/mach-at91/at91rm9200.c | 9 ---------
arch/arm/mach-at91/generic.h | 1 +
drivers/clk/at91/pmc.c | 9 +++++++++
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index fc7c26138037..3be1963f5c56 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -21,14 +21,6 @@
#include "soc.h"
#include "generic.h"
-static void at91rm9200_idle(void)
-{
- /*
- * Disable the processor clock. The processor will be automatically
- * re-enabled by an interrupt or by a reset.
- */
- at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
-}
static void at91rm9200_restart(enum reboot_mode reboot_mode, const char *cmd)
{
@@ -49,7 +41,6 @@ static void __init at91rm9200_initialize(void)
arm_pm_restart = at91rm9200_restart;
}
-
AT91_SOC_START(at91rm9200)
.init = at91rm9200_initialize,
AT91_SOC_END
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index 18d5547f11d5..c4aa21fb765f 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -25,6 +25,7 @@ extern void __init at91_dt_initialize(void);
extern void at91rm9200_timer_init(void);
/* idle */
+extern void at91rm9200_idle(void);
extern void at91sam9_idle(void);
/* Matrix */
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 386999b4f8eb..f07c8152e5cc 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -27,6 +27,15 @@
void __iomem *at91_pmc_base;
EXPORT_SYMBOL_GPL(at91_pmc_base);
+void at91rm9200_idle(void)
+{
+ /*
+ * Disable the processor clock. The processor will be automatically
+ * re-enabled by an interrupt or by a reset.
+ */
+ at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
+}
+
void at91sam9_idle(void)
{
at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
--
2.1.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 6/6] ARM: at91: move at91rm9200_idle() to clk/at91/pmc.c
2015-01-12 21:23 ` [PATCH 6/6] ARM: at91: move at91rm9200_idle() to clk/at91/pmc.c Alexandre Belloni
@ 2015-01-12 22:57 ` Mike Turquette
2015-01-13 9:25 ` Boris Brezillon
1 sibling, 0 replies; 16+ messages in thread
From: Mike Turquette @ 2015-01-12 22:57 UTC (permalink / raw)
To: linux-arm-kernel
Quoting Alexandre Belloni (2015-01-12 13:23:45)
> Move at91rm9200_idle() along with at91sam9_idle() in clk/at91/pmc.c.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> Cc: Mike Turquette <mturquette@linaro.org>
Acked-by: Michael Turquette <mturquette@linaro.org>
>
> Mike, Boris,
> I guess that one can go through the at91 tree unless you have any objections.
>
> arch/arm/mach-at91/at91rm9200.c | 9 ---------
> arch/arm/mach-at91/generic.h | 1 +
> drivers/clk/at91/pmc.c | 9 +++++++++
> 3 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
> index fc7c26138037..3be1963f5c56 100644
> --- a/arch/arm/mach-at91/at91rm9200.c
> +++ b/arch/arm/mach-at91/at91rm9200.c
> @@ -21,14 +21,6 @@
> #include "soc.h"
> #include "generic.h"
>
> -static void at91rm9200_idle(void)
> -{
> - /*
> - * Disable the processor clock. The processor will be automatically
> - * re-enabled by an interrupt or by a reset.
> - */
> - at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
> -}
>
> static void at91rm9200_restart(enum reboot_mode reboot_mode, const char *cmd)
> {
> @@ -49,7 +41,6 @@ static void __init at91rm9200_initialize(void)
> arm_pm_restart = at91rm9200_restart;
> }
>
> -
> AT91_SOC_START(at91rm9200)
> .init = at91rm9200_initialize,
> AT91_SOC_END
> diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
> index 18d5547f11d5..c4aa21fb765f 100644
> --- a/arch/arm/mach-at91/generic.h
> +++ b/arch/arm/mach-at91/generic.h
> @@ -25,6 +25,7 @@ extern void __init at91_dt_initialize(void);
> extern void at91rm9200_timer_init(void);
>
> /* idle */
> +extern void at91rm9200_idle(void);
> extern void at91sam9_idle(void);
>
> /* Matrix */
> diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
> index 386999b4f8eb..f07c8152e5cc 100644
> --- a/drivers/clk/at91/pmc.c
> +++ b/drivers/clk/at91/pmc.c
> @@ -27,6 +27,15 @@
> void __iomem *at91_pmc_base;
> EXPORT_SYMBOL_GPL(at91_pmc_base);
>
> +void at91rm9200_idle(void)
> +{
> + /*
> + * Disable the processor clock. The processor will be automatically
> + * re-enabled by an interrupt or by a reset.
> + */
> + at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
> +}
> +
> void at91sam9_idle(void)
> {
> at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
> --
> 2.1.0
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/6] ARM: at91: move at91rm9200_idle() to clk/at91/pmc.c
2015-01-12 21:23 ` [PATCH 6/6] ARM: at91: move at91rm9200_idle() to clk/at91/pmc.c Alexandre Belloni
2015-01-12 22:57 ` Mike Turquette
@ 2015-01-13 9:25 ` Boris Brezillon
1 sibling, 0 replies; 16+ messages in thread
From: Boris Brezillon @ 2015-01-13 9:25 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 12 Jan 2015 22:23:45 +0100
Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:
> Move at91rm9200_idle() along with at91sam9_idle() in clk/at91/pmc.c.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> Cc: Mike Turquette <mturquette@linaro.org>
>
> Mike, Boris,
> I guess that one can go through the at91 tree unless you have any objections.
I'm fine with that too.
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/6] ARM: at91: pm: rework cpu detection
2015-01-12 21:23 ` [PATCH 1/6] ARM: at91: pm: rework cpu detection Alexandre Belloni
@ 2015-01-14 19:14 ` Jean-Christophe PLAGNIOL-VILLARD
2015-01-14 20:21 ` Boris Brezillon
0 siblings, 1 reply; 16+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-14 19:14 UTC (permalink / raw)
To: linux-arm-kernel
On 22:23 Mon 12 Jan , Alexandre Belloni wrote:
> Store SoC differences in a struct to remove cpu_is_* usage.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> arch/arm/mach-at91/pm.c | 54 ++++++++++++++++++++++++++++++-------------------
> 1 file changed, 33 insertions(+), 21 deletions(-)
>
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 9b15169a1c62..79aa793d1f00 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -17,6 +17,7 @@
> #include <linux/interrupt.h>
> #include <linux/sysfs.h>
> #include <linux/module.h>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/io.h>
> #include <linux/clk/at91_pmc.h>
> @@ -32,6 +33,11 @@
> #include "generic.h"
> #include "pm.h"
>
> +static struct {
> + unsigned long uhp_udp_mask;
> + int memctrl;
> +} at91_pm_data;
> +
> static void (*at91_pm_standby)(void);
>
> static int at91_pm_valid_state(suspend_state_t state)
> @@ -71,17 +77,9 @@ static int at91_pm_verify_clocks(void)
> scsr = at91_pmc_read(AT91_PMC_SCSR);
>
> /* USB must not be using PLLB */
> - if (cpu_is_at91rm9200()) {
> - if ((scsr & (AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP)) != 0) {
> - pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
> - return 0;
> - }
> - } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263()
> - || cpu_is_at91sam9g20() || cpu_is_at91sam9g10()) {
> - if ((scsr & (AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP)) != 0) {
> - pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
> - return 0;
> - }
> + if ((scsr & at91_pm_data.uhp_udp_mask) != 0) {
> + pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
> + return 0;
> }
>
> /* PCK0..PCK3 must be disabled, or configured to use clk32k */
> @@ -149,18 +147,13 @@ static int at91_pm_enter(suspend_state_t state)
> * turning off the main oscillator; reverse on wakeup.
> */
> if (slow_clock) {
> - int memctrl = AT91_MEMCTRL_SDRAMC;
> -
> - if (cpu_is_at91rm9200())
> - memctrl = AT91_MEMCTRL_MC;
> - else if (cpu_is_at91sam9g45())
> - memctrl = AT91_MEMCTRL_DDRSDR;
> #ifdef CONFIG_AT91_SLOW_CLOCK
> /* copy slow_clock handler to SRAM, and call it */
> memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
> #endif
> slow_clock(at91_pmc_base, at91_ramc_base[0],
> - at91_ramc_base[1], memctrl);
> + at91_ramc_base[1],
> + at91_pm_data.memctrl);
> break;
> } else {
> pr_info("AT91: PM - no slow clock mode enabled ...\n");
> @@ -237,10 +230,29 @@ static int __init at91_pm_init(void)
>
> pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : ""));
>
> - /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
> - if (cpu_is_at91rm9200())
> + at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
> +
> + if (of_machine_is_compatible("atmel,at91rm9200")) {
> + /*
> + * AT91RM9200 SDRAM low-power mode cannot be used with
> + * self-refresh.
> + */
> at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
> -
> +
> + at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP |
> + AT91RM9200_PMC_UDP;
> + at91_pm_data.memctrl = AT91_MEMCTRL_MC;
> + } else if (of_machine_is_compatible("atmel,at91sam9260") ||
> + of_machine_is_compatible("atmel,at91sam9g20") ||
> + of_machine_is_compatible("atmel,at91sam9261") ||
> + of_machine_is_compatible("atmel,at91sam9g10") ||
> + of_machine_is_compatible("atmel,at91sam9263")) {
nack here
you switch for runtime information from the SOC register store in ram to DT
DT is great but I do prefer to rely on the SoC register here as the whole was
also to check that the is correct
wihich is way slower
Best Regards,
J.
> + at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP |
> + AT91SAM926x_PMC_UDP;
> + } else if (of_machine_is_compatible("atmel,at91sam9g45")) {
> + at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
> + }
> +
> if (at91_cpuidle_device.dev.platform_data)
> platform_device_register(&at91_cpuidle_device);
>
> --
> 2.1.0
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/6] ARM: at91: pm: rework cpu detection
2015-01-14 19:14 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2015-01-14 20:21 ` Boris Brezillon
2015-01-14 20:37 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 1 reply; 16+ messages in thread
From: Boris Brezillon @ 2015-01-14 20:21 UTC (permalink / raw)
To: linux-arm-kernel
Hi Jean-Christophe,
On Wed, 14 Jan 2015 20:14:12 +0100
Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:
> On 22:23 Mon 12 Jan , Alexandre Belloni wrote:
> > Store SoC differences in a struct to remove cpu_is_* usage.
> >
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > ---
> > arch/arm/mach-at91/pm.c | 54 ++++++++++++++++++++++++++++++-------------------
> > 1 file changed, 33 insertions(+), 21 deletions(-)
> >
> > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> > index 9b15169a1c62..79aa793d1f00 100644
> > --- a/arch/arm/mach-at91/pm.c
> > +++ b/arch/arm/mach-at91/pm.c
> > @@ -17,6 +17,7 @@
> > #include <linux/interrupt.h>
> > #include <linux/sysfs.h>
> > #include <linux/module.h>
> > +#include <linux/of.h>
> > #include <linux/platform_device.h>
> > #include <linux/io.h>
> > #include <linux/clk/at91_pmc.h>
> > @@ -32,6 +33,11 @@
> > #include "generic.h"
> > #include "pm.h"
> >
> > +static struct {
> > + unsigned long uhp_udp_mask;
> > + int memctrl;
> > +} at91_pm_data;
> > +
> > static void (*at91_pm_standby)(void);
> >
> > static int at91_pm_valid_state(suspend_state_t state)
> > @@ -71,17 +77,9 @@ static int at91_pm_verify_clocks(void)
> > scsr = at91_pmc_read(AT91_PMC_SCSR);
> >
> > /* USB must not be using PLLB */
> > - if (cpu_is_at91rm9200()) {
> > - if ((scsr & (AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP)) != 0) {
> > - pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
> > - return 0;
> > - }
> > - } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263()
> > - || cpu_is_at91sam9g20() || cpu_is_at91sam9g10()) {
> > - if ((scsr & (AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP)) != 0) {
> > - pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
> > - return 0;
> > - }
> > + if ((scsr & at91_pm_data.uhp_udp_mask) != 0) {
> > + pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
> > + return 0;
> > }
> >
> > /* PCK0..PCK3 must be disabled, or configured to use clk32k */
> > @@ -149,18 +147,13 @@ static int at91_pm_enter(suspend_state_t state)
> > * turning off the main oscillator; reverse on wakeup.
> > */
> > if (slow_clock) {
> > - int memctrl = AT91_MEMCTRL_SDRAMC;
> > -
> > - if (cpu_is_at91rm9200())
> > - memctrl = AT91_MEMCTRL_MC;
> > - else if (cpu_is_at91sam9g45())
> > - memctrl = AT91_MEMCTRL_DDRSDR;
> > #ifdef CONFIG_AT91_SLOW_CLOCK
> > /* copy slow_clock handler to SRAM, and call it */
> > memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
> > #endif
> > slow_clock(at91_pmc_base, at91_ramc_base[0],
> > - at91_ramc_base[1], memctrl);
> > + at91_ramc_base[1],
> > + at91_pm_data.memctrl);
> > break;
> > } else {
> > pr_info("AT91: PM - no slow clock mode enabled ...\n");
> > @@ -237,10 +230,29 @@ static int __init at91_pm_init(void)
> >
> > pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : ""));
> >
> > - /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
> > - if (cpu_is_at91rm9200())
> > + at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
> > +
> > + if (of_machine_is_compatible("atmel,at91rm9200")) {
> > + /*
> > + * AT91RM9200 SDRAM low-power mode cannot be used with
> > + * self-refresh.
> > + */
> > at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
> > -
> > +
> > + at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP |
> > + AT91RM9200_PMC_UDP;
> > + at91_pm_data.memctrl = AT91_MEMCTRL_MC;
> > + } else if (of_machine_is_compatible("atmel,at91sam9260") ||
> > + of_machine_is_compatible("atmel,at91sam9g20") ||
> > + of_machine_is_compatible("atmel,at91sam9261") ||
> > + of_machine_is_compatible("atmel,at91sam9g10") ||
> > + of_machine_is_compatible("atmel,at91sam9263")) {
> nack here
>
> you switch for runtime information from the SOC register store in ram to DT
>
> DT is great but I do prefer to rely on the SoC register here as the whole was
> also to check that the is correct
Well, cpu_is_xxx macros are defined in a mach specific header, and we're
currently trying to enable multi platform support.
>
> wihich is way slower
Hmm, this SoC detection has been move from the suspend path (where, as
you stated, speed is a real concern) to the pm init function (which is
only called once at startup), and I doubt the boot time penalty will
even be noticeable...
Best Regards,
Boris
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/6] ARM: at91: pm: rework cpu detection
2015-01-14 20:21 ` Boris Brezillon
@ 2015-01-14 20:37 ` Jean-Christophe PLAGNIOL-VILLARD
2015-01-14 21:07 ` Alexandre Belloni
0 siblings, 1 reply; 16+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-14 20:37 UTC (permalink / raw)
To: linux-arm-kernel
> On Jan 15, 2015, at 4:21 AM, Boris Brezillon <boris.brezillon@free-electrons.com> wrote:
>
> Hi Jean-Christophe,
>
> On Wed, 14 Jan 2015 20:14:12 +0100
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:
>
>> On 22:23 Mon 12 Jan , Alexandre Belloni wrote:
>>> Store SoC differences in a struct to remove cpu_is_* usage.
>>>
>>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>>> ---
>>> arch/arm/mach-at91/pm.c | 54 ++++++++++++++++++++++++++++++-------------------
>>> 1 file changed, 33 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
>>> index 9b15169a1c62..79aa793d1f00 100644
>>> --- a/arch/arm/mach-at91/pm.c
>>> +++ b/arch/arm/mach-at91/pm.c
>>> @@ -17,6 +17,7 @@
>>> #include <linux/interrupt.h>
>>> #include <linux/sysfs.h>
>>> #include <linux/module.h>
>>> +#include <linux/of.h>
>>> #include <linux/platform_device.h>
>>> #include <linux/io.h>
>>> #include <linux/clk/at91_pmc.h>
>>> @@ -32,6 +33,11 @@
>>> #include "generic.h"
>>> #include "pm.h"
>>>
>>> +static struct {
>>> + unsigned long uhp_udp_mask;
>>> + int memctrl;
>>> +} at91_pm_data;
>>> +
>>> static void (*at91_pm_standby)(void);
>>>
>>> static int at91_pm_valid_state(suspend_state_t state)
>>> @@ -71,17 +77,9 @@ static int at91_pm_verify_clocks(void)
>>> scsr = at91_pmc_read(AT91_PMC_SCSR);
>>>
>>> /* USB must not be using PLLB */
>>> - if (cpu_is_at91rm9200()) {
>>> - if ((scsr & (AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP)) != 0) {
>>> - pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
>>> - return 0;
>>> - }
>>> - } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263()
>>> - || cpu_is_at91sam9g20() || cpu_is_at91sam9g10()) {
>>> - if ((scsr & (AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP)) != 0) {
>>> - pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
>>> - return 0;
>>> - }
>>> + if ((scsr & at91_pm_data.uhp_udp_mask) != 0) {
>>> + pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
>>> + return 0;
>>> }
>>>
>>> /* PCK0..PCK3 must be disabled, or configured to use clk32k */
>>> @@ -149,18 +147,13 @@ static int at91_pm_enter(suspend_state_t state)
>>> * turning off the main oscillator; reverse on wakeup.
>>> */
>>> if (slow_clock) {
>>> - int memctrl = AT91_MEMCTRL_SDRAMC;
>>> -
>>> - if (cpu_is_at91rm9200())
>>> - memctrl = AT91_MEMCTRL_MC;
>>> - else if (cpu_is_at91sam9g45())
>>> - memctrl = AT91_MEMCTRL_DDRSDR;
>>> #ifdef CONFIG_AT91_SLOW_CLOCK
>>> /* copy slow_clock handler to SRAM, and call it */
>>> memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
>>> #endif
>>> slow_clock(at91_pmc_base, at91_ramc_base[0],
>>> - at91_ramc_base[1], memctrl);
>>> + at91_ramc_base[1],
>>> + at91_pm_data.memctrl);
>>> break;
>>> } else {
>>> pr_info("AT91: PM - no slow clock mode enabled ...\n");
>>> @@ -237,10 +230,29 @@ static int __init at91_pm_init(void)
>>>
>>> pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : ""));
>>>
>>> - /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
>>> - if (cpu_is_at91rm9200())
>>> + at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
>>> +
>>> + if (of_machine_is_compatible("atmel,at91rm9200")) {
>>> + /*
>>> + * AT91RM9200 SDRAM low-power mode cannot be used with
>>> + * self-refresh.
>>> + */
>>> at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
>>> -
>>> +
>>> + at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP |
>>> + AT91RM9200_PMC_UDP;
>>> + at91_pm_data.memctrl = AT91_MEMCTRL_MC;
>>> + } else if (of_machine_is_compatible("atmel,at91sam9260") ||
>>> + of_machine_is_compatible("atmel,at91sam9g20") ||
>>> + of_machine_is_compatible("atmel,at91sam9261") ||
>>> + of_machine_is_compatible("atmel,at91sam9g10") ||
>>> + of_machine_is_compatible("atmel,at91sam9263")) {
>> nack here
>>
>> you switch for runtime information from the SOC register store in ram to DT
>>
>> DT is great but I do prefer to rely on the SoC register here as the whole was
>> also to check that the is correct
>
> Well, cpu_is_xxx macros are defined in a mach specific header, and we're
> currently trying to enable multi platform support.
Yes does not mean we can not move this, use the REAL hardware detected cpu is better
as you can check that the DT is valid for this SoC and also have fixup for a specific
SoC version without having to have x DT per SoC
>
>>
>> wihich is way slower
>
> Hmm, this SoC detection has been move from the suspend path (where, as
> you stated, speed is a real concern) to the pm init function (which is
> only called once at startup), and I doubt the boot time penalty will
> even be noticeable?
except if your table is boot as quick as possible avoid useless string compare is always a good choice
IIRC we had in the past RFC to have the drivers compatible compare switch to HASH
for this purpose too
Best Regards,
J.
>
> Best Regards,
>
> Boris
>
>
> --
> Boris Brezillon, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/6] ARM: at91: pm: rework cpu detection
2015-01-14 20:37 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2015-01-14 21:07 ` Alexandre Belloni
2015-01-14 22:12 ` Arnd Bergmann
0 siblings, 1 reply; 16+ messages in thread
From: Alexandre Belloni @ 2015-01-14 21:07 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
(Adding Arnd in Cc)
On 15/01/2015 at 04:37:14 +0800, Jean-Christophe PLAGNIOL-VILLARD wrote :
> >>> - /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
> >>> - if (cpu_is_at91rm9200())
> >>> + at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
> >>> +
> >>> + if (of_machine_is_compatible("atmel,at91rm9200")) {
> >>> + /*
> >>> + * AT91RM9200 SDRAM low-power mode cannot be used with
> >>> + * self-refresh.
> >>> + */
> >>> at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
> >>> -
> >>> +
> >>> + at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP |
> >>> + AT91RM9200_PMC_UDP;
> >>> + at91_pm_data.memctrl = AT91_MEMCTRL_MC;
> >>> + } else if (of_machine_is_compatible("atmel,at91sam9260") ||
> >>> + of_machine_is_compatible("atmel,at91sam9g20") ||
> >>> + of_machine_is_compatible("atmel,at91sam9261") ||
> >>> + of_machine_is_compatible("atmel,at91sam9g10") ||
> >>> + of_machine_is_compatible("atmel,at91sam9263")) {
> >> nack here
> >>
> >> you switch for runtime information from the SOC register store in ram to DT
> >>
> >> DT is great but I do prefer to rely on the SoC register here as the whole was
> >> also to check that the is correct
> >
> > Well, cpu_is_xxx macros are defined in a mach specific header, and we're
> > currently trying to enable multi platform support.
>
> Yes does not mean we can not move this, use the REAL hardware detected cpu is better
> as you can check that the DT is valid for this SoC and also have fixup for a specific
> SoC version without having to have x DT per SoC
>
> >
> >>
> >> wihich is way slower
> >
> > Hmm, this SoC detection has been move from the suspend path (where, as
> > you stated, speed is a real concern) to the pm init function (which is
> > only called once at startup), and I doubt the boot time penalty will
> > even be noticeable?
>
> except if your table is boot as quick as possible avoid useless string compare is always a good choice
>
> IIRC we had in the past RFC to have the drivers compatible compare switch to HASH
> for this purpose too
>
Following a discussion with Arnd, the whole SoC detection will be remove
which will be completely faster than mapping the dbgu registers.
Also, the of_machine_is_compatible are supposed to be removed soon,
waiting for the pm code to be reworked. What is done here is to allow us
to go forward with switching to multiplatform and cleaning up the
mach-at91 directory.
I have follow up patches coming up and they already remove some of the
of_machine_is_compatible.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/6] ARM: at91: pm: rework cpu detection
2015-01-14 21:07 ` Alexandre Belloni
@ 2015-01-14 22:12 ` Arnd Bergmann
0 siblings, 0 replies; 16+ messages in thread
From: Arnd Bergmann @ 2015-01-14 22:12 UTC (permalink / raw)
To: linux-arm-kernel
On Wednesday 14 January 2015 22:07:34 Alexandre Belloni wrote:
> Hi,
>
> (Adding Arnd in Cc)
>
> On 15/01/2015 at 04:37:14 +0800, Jean-Christophe PLAGNIOL-VILLARD wrote :
> > >>> - /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
> > >>> - if (cpu_is_at91rm9200())
> > >>> + at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
> > >>> +
> > >>> + if (of_machine_is_compatible("atmel,at91rm9200")) {
> > >>> + /*
> > >>> + * AT91RM9200 SDRAM low-power mode cannot be used with
> > >>> + * self-refresh.
> > >>> + */
> > >>> at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
> > >>> -
> > >>> +
> > >>> + at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP |
> > >>> + AT91RM9200_PMC_UDP;
> > >>> + at91_pm_data.memctrl = AT91_MEMCTRL_MC;
> > >>> + } else if (of_machine_is_compatible("atmel,at91sam9260") ||
> > >>> + of_machine_is_compatible("atmel,at91sam9g20") ||
> > >>> + of_machine_is_compatible("atmel,at91sam9261") ||
> > >>> + of_machine_is_compatible("atmel,at91sam9g10") ||
> > >>> + of_machine_is_compatible("atmel,at91sam9263")) {
> > >> nack here
> > >>
> > >> you switch for runtime information from the SOC register store in ram to DT
> > >>
> > >> DT is great but I do prefer to rely on the SoC register here as the whole was
> > >> also to check that the is correct
> > >
> > > Well, cpu_is_xxx macros are defined in a mach specific header, and we're
> > > currently trying to enable multi platform support.
> >
> > Yes does not mean we can not move this, use the REAL hardware detected cpu is better
> > as you can check that the DT is valid for this SoC and also have fixup for a specific
> > SoC version without having to have x DT per SoC
We should definitely be able to confine the SoC detection to at91sam9 though,
because in the three other cases (rm9200, sama5d3, sama5d4), we already have
separate machine descriptors and don't need to do any detection.
> > >> wihich is way slower
> > >
> > > Hmm, this SoC detection has been move from the suspend path (where, as
> > > you stated, speed is a real concern) to the pm init function (which is
> > > only called once at startup), and I doubt the boot time penalty will
> > > even be noticeable?
> >
> > except if your table is boot as quick as possible avoid useless string compare is always a good choice
> >
> > IIRC we had in the past RFC to have the drivers compatible compare switch to HASH
> > for this purpose too
> >
>
> Following a discussion with Arnd, the whole SoC detection will be remove
> which will be completely faster than mapping the dbgu registers.
>
> Also, the of_machine_is_compatible are supposed to be removed soon,
> waiting for the pm code to be reworked. What is done here is to allow us
> to go forward with switching to multiplatform and cleaning up the
> mach-at91 directory.
>
> I have follow up patches coming up and they already remove some of the
> of_machine_is_compatible.
As you have already confined the of_machine_is_compatible() checks
to one top-level function, and we have found that this function
should not be an unconditional arch_initcall, I think the easiest
way forward is to split at91_pm_init into multiple functions,
one per case you need to handle, and then use a machine_descriptor
with a list of compatible strings to match it.
I think that just means we need an extra machine descriptor to
handle the at91sam9g45, but that will get folded again over time.
Arnd
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/6] ARM: at91: pm: use the mmio-sram pool to access SRAM
2015-01-12 21:23 ` [PATCH 2/6] ARM: at91: pm: use the mmio-sram pool to access SRAM Alexandre Belloni
@ 2015-01-15 8:53 ` Yang, Wenyou
2015-01-15 9:14 ` Alexandre Belloni
0 siblings, 1 reply; 16+ messages in thread
From: Yang, Wenyou @ 2015-01-15 8:53 UTC (permalink / raw)
To: linux-arm-kernel
Hi Alexandre
> -----Original Message-----
> From: linux-arm-kernel [mailto:linux-arm-kernel-bounces at lists.infradead.org] On
> Behalf Of Alexandre Belloni
> Sent: Tuesday, January 13, 2015 5:24 AM
> To: Ferre, Nicolas
> Cc: Boris Brezillon; Alexandre Belloni; Jean-Christophe Plagniol-Villard; linux-
> kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org
> Subject: [PATCH 2/6] ARM: at91: pm: use the mmio-sram pool to access SRAM
>
> Now that the SRAM is part of a genpool, use it to allocate memory to use for the
> slowclock implementation.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> arch/arm/mach-at91/Kconfig | 1 +
> arch/arm/mach-at91/pm.c | 46
> +++++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index
> cec0fb5d621a..b7dcef50db23 100644
> --- a/arch/arm/mach-at91/Kconfig
> +++ b/arch/arm/mach-at91/Kconfig
> @@ -178,6 +178,7 @@ comment "AT91 Feature Selections"
>
> config AT91_SLOW_CLOCK
> bool "Suspend-to-RAM disables main oscillator"
> + select SRAM
Can we move it under config ARCH_AT91 or other place?
It may be used for other purposes, more than pm. I thinks
> depends on SUSPEND
> help
> Select this if you want Suspend-to-RAM to save the most power diff --git
> a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index
> 79aa793d1f00..515791edcc60 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -14,10 +14,12 @@
> #include <linux/suspend.h>
> #include <linux/sched.h>
> #include <linux/proc_fs.h>
> +#include <linux/genalloc.h>
> #include <linux/interrupt.h>
> #include <linux/sysfs.h>
> #include <linux/module.h>
> #include <linux/of.h>
> +#include <linux/of_platform.h>
> #include <linux/platform_device.h>
> #include <linux/io.h>
> #include <linux/clk/at91_pmc.h>
> @@ -222,10 +224,52 @@ void at91_pm_set_standby(void (*at91_standby)(void))
> }
> }
>
> +#ifdef CONFIG_AT91_SLOW_CLOCK
> +static void __init at91_pm_sram_init(void) {
> + struct gen_pool *sram_pool;
> + phys_addr_t sram_pbase;
> + unsigned long sram_base;
> + struct device_node *node;
> + struct platform_device *pdev;
> +
> + node = of_find_compatible_node(NULL, NULL, "mmio-sram");
> + if (!node) {
> + pr_warn("%s: failed to find sram node!\n", __func__);
> + return;
> + }
> +
> + pdev = of_find_device_by_node(node);
> + if (!pdev) {
> + pr_warn("%s: failed to find sram device!\n", __func__);
> + goto put_node;
> + }
> +
> + sram_pool = dev_get_gen_pool(&pdev->dev);
> + if (!sram_pool) {
> + pr_warn("%s: sram pool unavailable!\n", __func__);
> + goto put_node;
> + }
> +
> + sram_base = gen_pool_alloc(sram_pool, at91_slow_clock_sz);
> + if (!sram_base) {
> + pr_warn("%s: unable to alloc ocram!\n", __func__);
> + goto put_node;
> + }
> +
> + sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
> + slow_clock = __arm_ioremap_exec(sram_pbase, at91_slow_clock_sz,
> +false);
> +
> +put_node:
> + of_node_put(node);
> +}
> +#endif
> +
> +
> static int __init at91_pm_init(void)
> {
> #ifdef CONFIG_AT91_SLOW_CLOCK
> - slow_clock = (void *) (AT91_IO_VIRT_BASE - at91_slow_clock_sz);
> + at91_pm_sram_init();
> #endif
>
> pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock
> mode)" : ""));
> --
> 2.1.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Best Regards,
Wenyou Yang
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/6] ARM: at91: pm: use the mmio-sram pool to access SRAM
2015-01-15 8:53 ` Yang, Wenyou
@ 2015-01-15 9:14 ` Alexandre Belloni
0 siblings, 0 replies; 16+ messages in thread
From: Alexandre Belloni @ 2015-01-15 9:14 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
Thank you for your review.
On 15/01/2015 at 08:53:54 +0000, Yang, Wenyou wrote :
> > config AT91_SLOW_CLOCK
> > bool "Suspend-to-RAM disables main oscillator"
> > + select SRAM
> Can we move it under config ARCH_AT91 or other place?
>
> It may be used for other purposes, more than pm. I thinks
>
I believe it is better if every SRAM user selects SRAM so that when you
don't have any of those, it is not automatically selected and it reduces
the kernel size.
Regards,
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2015-01-15 9:14 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-12 21:23 [PATCH 0/6] AT91 cleanup for 3.20 #2 Alexandre Belloni
2015-01-12 21:23 ` [PATCH 1/6] ARM: at91: pm: rework cpu detection Alexandre Belloni
2015-01-14 19:14 ` Jean-Christophe PLAGNIOL-VILLARD
2015-01-14 20:21 ` Boris Brezillon
2015-01-14 20:37 ` Jean-Christophe PLAGNIOL-VILLARD
2015-01-14 21:07 ` Alexandre Belloni
2015-01-14 22:12 ` Arnd Bergmann
2015-01-12 21:23 ` [PATCH 2/6] ARM: at91: pm: use the mmio-sram pool to access SRAM Alexandre Belloni
2015-01-15 8:53 ` Yang, Wenyou
2015-01-15 9:14 ` Alexandre Belloni
2015-01-12 21:23 ` [PATCH 3/6] ARM: at91: remove useless map_io Alexandre Belloni
2015-01-12 21:23 ` [PATCH 4/6] ARM: at91: sama5d4: remove useless call to at91_init_sram Alexandre Belloni
2015-01-12 21:23 ` [PATCH 5/6] ARM: at91: remove unused at91_init_sram Alexandre Belloni
2015-01-12 21:23 ` [PATCH 6/6] ARM: at91: move at91rm9200_idle() to clk/at91/pmc.c Alexandre Belloni
2015-01-12 22:57 ` Mike Turquette
2015-01-13 9:25 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).