From: "Clément Léger" <clement.leger@bootlin.com>
To: Russell King <linux@armlinux.org.uk>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Ludovic Desroches <ludovic.desroches@microchip.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Clément Léger" <clement.leger@bootlin.com>
Subject: [PATCH 2/4] ARM: at91: pm: move "atmel.pm_modes" parsing into a common file
Date: Tue, 22 Feb 2022 16:08:44 +0100 [thread overview]
Message-ID: <20220222150846.255307-3-clement.leger@bootlin.com> (raw)
In-Reply-To: <20220222150846.255307-1-clement.leger@bootlin.com>
In order to add secure suspend support, split out code that will be
reused to parse the boot argument "atmel.pm_modes".
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
arch/arm/mach-at91/Makefile | 2 +-
arch/arm/mach-at91/pm.c | 31 ++-------------------------
arch/arm/mach-at91/pm.h | 7 ++++++
arch/arm/mach-at91/pm_common.c | 39 ++++++++++++++++++++++++++++++++++
4 files changed, 49 insertions(+), 30 deletions(-)
create mode 100644 arch/arm/mach-at91/pm_common.c
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 0dcc37180588..23620ccf7ab6 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -12,7 +12,7 @@ obj-$(CONFIG_SOC_SAMA7) += sama7.o
obj-$(CONFIG_SOC_SAMV7) += samv7.o
# Power Management
-obj-$(CONFIG_ATMEL_PM) += pm.o pm_suspend.o
+obj-$(CONFIG_ATMEL_PM) += pm.o pm_suspend.o pm_common.o
ifeq ($(CONFIG_CPU_V7),y)
AFLAGS_pm_suspend.o := -march=armv7-a
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index dd6f4ce3f766..b575304ccf63 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -99,15 +99,6 @@ static struct at91_soc_pm soc_pm = {
},
};
-static const match_table_t pm_modes __initconst = {
- { AT91_PM_STANDBY, "standby" },
- { AT91_PM_ULP0, "ulp0" },
- { AT91_PM_ULP0_FAST, "ulp0-fast" },
- { AT91_PM_ULP1, "ulp1" },
- { AT91_PM_BACKUP, "backup" },
- { -1, NULL },
-};
-
#define at91_ramc_read(id, field) \
__raw_readl(soc_pm.data.ramc[id] + field)
@@ -1243,25 +1234,7 @@ void __init sama7_pm_init(void)
static int __init at91_pm_modes_select(char *str)
{
- char *s;
- substring_t args[MAX_OPT_ARGS];
- int standby, suspend;
-
- if (!str)
- return 0;
-
- s = strsep(&str, ",");
- standby = match_token(s, pm_modes, args);
- if (standby < 0)
- return 0;
-
- suspend = match_token(str, pm_modes, args);
- if (suspend < 0)
- return 0;
-
- soc_pm.data.standby_mode = standby;
- soc_pm.data.suspend_mode = suspend;
-
- return 0;
+ return at91_pm_common_modes_select(str, &soc_pm.data.standby_mode,
+ &soc_pm.data.suspend_mode);
}
early_param("atmel.pm_modes", at91_pm_modes_select);
diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
index 53bdc9000e44..e9f7f9841afd 100644
--- a/arch/arm/mach-at91/pm.h
+++ b/arch/arm/mach-at91/pm.h
@@ -40,6 +40,13 @@ struct at91_pm_data {
unsigned int pmc_mckr_offset;
unsigned int pmc_version;
};
+
+#include <linux/parser.h>
+
+extern const match_table_t pm_modes;
+
+int at91_pm_common_modes_select(char *str, int *standby_mode, int *suspend_mode);
+
#endif
#endif
diff --git a/arch/arm/mach-at91/pm_common.c b/arch/arm/mach-at91/pm_common.c
new file mode 100644
index 000000000000..45b74fb0a211
--- /dev/null
+++ b/arch/arm/mach-at91/pm_common.c
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <linux/kernel.h>
+#include <linux/parser.h>
+#include <linux/string.h>
+
+#include "pm.h"
+
+const match_table_t pm_modes __initconst = {
+ { AT91_PM_STANDBY, "standby" },
+ { AT91_PM_ULP0, "ulp0" },
+ { AT91_PM_ULP0_FAST, "ulp0-fast" },
+ { AT91_PM_ULP1, "ulp1" },
+ { AT91_PM_BACKUP, "backup" },
+ { -1, NULL },
+};
+
+int at91_pm_common_modes_select(char *str, int *standby_mode, int *suspend_mode)
+{
+ char *s;
+ substring_t args[MAX_OPT_ARGS];
+ int standby, suspend;
+
+ if (!str)
+ return 0;
+
+ s = strsep(&str, ",");
+ standby = match_token(s, pm_modes, args);
+ if (standby < 0)
+ return 0;
+
+ suspend = match_token(str, pm_modes, args);
+ if (suspend < 0)
+ return 0;
+
+ *standby_mode = standby;
+ *suspend_mode = suspend;
+
+ return 0;
+}
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-02-22 15:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 15:08 [PATCH 0/4] ARM: at91: add support for secure suspend on sama5d2 Clément Léger
2022-02-22 15:08 ` [PATCH 1/4] ARM: at91: add code to handle secure calls Clément Léger
2022-02-22 15:08 ` Clément Léger [this message]
2022-02-22 23:41 ` [PATCH 2/4] ARM: at91: pm: move "atmel.pm_modes" parsing into a common file kernel test robot
2022-02-22 15:08 ` [PATCH 3/4] ARM: at91: pm: add support for sama5d2 secure suspend Clément Léger
2022-02-23 5:50 ` kernel test robot
2022-02-23 9:15 ` kernel test robot
2022-02-23 9:30 ` Clément Léger
2022-02-22 15:08 ` [PATCH 4/4] ARM: at91: pm: fix defines to select *_pm_init functions Clément Léger
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=20220222150846.255307-3-clement.leger@bootlin.com \
--to=clement.leger@bootlin.com \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=ludovic.desroches@microchip.com \
--cc=nicolas.ferre@microchip.com \
--cc=thomas.petazzoni@bootlin.com \
/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 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).