From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH v1 10/12] ARM: sm: move get_gicd_base_address to header for reuse
Date: Mon, 17 Jun 2019 17:07:49 +0200 [thread overview]
Message-ID: <20190617150751.3421-11-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20190617150751.3421-1-a.fatoum@pengutronix.de>
Incoming PSCI implementation for the STM32MP1 needs
to get_gicd_base_address as well, so move it to gic.h to
avoid code duplication.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/cpu/sm.c | 29 +----------------------------
arch/arm/include/asm/gic.h | 29 +++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/arch/arm/cpu/sm.c b/arch/arm/cpu/sm.c
index d9d62fbd9db0..b7a9eae89b1a 100644
--- a/arch/arm/cpu/sm.c
+++ b/arch/arm/cpu/sm.c
@@ -22,9 +22,6 @@
#include "mmu.h"
-/* valid bits in CBAR register / PERIPHBASE value */
-#define CBAR_MASK 0xFFFF8000
-
static unsigned int read_id_pfr1(void)
{
unsigned int reg;
@@ -51,30 +48,6 @@ static void write_mvbar(u32 val)
asm("mcr p15, 0, %0, c12, c0, 1" : : "r"(val));
}
-static unsigned long get_cbar(void)
-{
- unsigned periphbase;
-
- /* get the GIC base address from the CBAR register */
- asm("mrc p15, 4, %0, c15, c0, 0\n" : "=r" (periphbase));
-
- /* the PERIPHBASE can be mapped above 4 GB (lower 8 bits used to
- * encode this). Bail out here since we cannot access this without
- * enabling paging.
- */
- if ((periphbase & 0xff) != 0) {
- pr_err("PERIPHBASE is above 4 GB, no access.\n");
- return -1;
- }
-
- return periphbase & CBAR_MASK;
-}
-
-static unsigned long get_gicd_base_address(void)
-{
- return get_cbar() + GIC_DIST_OFFSET;
-}
-
static int cpu_is_virt_capable(void)
{
return read_id_pfr1() & (1 << 12);
@@ -267,4 +240,4 @@ static int sm_init(void)
return 0;
}
-device_initcall(sm_init);
\ No newline at end of file
+device_initcall(sm_init);
diff --git a/arch/arm/include/asm/gic.h b/arch/arm/include/asm/gic.h
index bd3a80cdf70a..f83f52814107 100644
--- a/arch/arm/include/asm/gic.h
+++ b/arch/arm/include/asm/gic.h
@@ -107,4 +107,33 @@
#define ICC_SGI1R_EL1 S3_0_C12_C11_5
#define ICC_ASGI1R_EL1 S3_0_C12_C11_6
+#ifndef __ASSEMBLY__
+/* valid bits in CBAR register / PERIPHBASE value */
+#define CBAR_MASK 0xFFFF8000
+
+static inline unsigned long get_cbar(void)
+{
+ unsigned periphbase;
+
+ /* get the GIC base address from the CBAR register */
+ asm("mrc p15, 4, %0, c15, c0, 0\n" : "=r" (periphbase));
+
+ /* the PERIPHBASE can be mapped above 4 GB (lower 8 bits used to
+ * encode this). Bail out here since we cannot access this without
+ * enabling paging.
+ */
+ if ((periphbase & 0xff) != 0) {
+ pr_err("PERIPHBASE is above 4 GB, no access.\n");
+ return -1;
+ }
+
+ return periphbase & CBAR_MASK;
+}
+
+static inline unsigned long get_gicd_base_address(void)
+{
+ return get_cbar() + GIC_DIST_OFFSET;
+}
+#endif
+
#endif /* __GIC_H__ */
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-06-17 15:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-17 15:07 [PATCH v1 00/12] ARM: stm32mp: add drivers for GPIO, pinctrl Ahmad Fatoum
2019-06-17 15:07 ` [PATCH v1 01/12] ARM: dts: stm32mp157a-dk1.dts: include upstream dts before barebox' Ahmad Fatoum
2019-06-17 15:07 ` [PATCH v1 02/12] ARM: dts: stm32mp: factor out common DK nodes into dtsi Ahmad Fatoum
2019-06-17 15:07 ` [PATCH v1 03/12] gpiolib: add gpio_get_chip helper Ahmad Fatoum
2019-06-17 15:07 ` [PATCH v1 04/12] driver: add stubs for hardware spinlocks Ahmad Fatoum
2019-06-17 15:07 ` [PATCH v1 05/12] pinctrl: add driver for STM32 GPIO and pin multiplexer Ahmad Fatoum
2019-06-17 15:07 ` [PATCH v1 06/12] ARM: dts: stm32mp157a-dk1: enable heartbeat and error LEDs Ahmad Fatoum
2019-06-17 15:07 ` [PATCH v1 07/12] ARM: stm32mp: turn on GPIO related options Ahmad Fatoum
2019-06-17 15:07 ` [PATCH v1 08/12] ARM: stm32mp157c-dk2: add board-specific sysconf fixups Ahmad Fatoum
2019-06-17 15:14 ` Ahmad Fatoum
2019-06-18 5:43 ` Rouven Czerwinski
2019-06-17 15:07 ` [PATCH v1 09/12] ARM: psci: fix erroneous call of ->system_reset on system_off Ahmad Fatoum
2019-06-17 15:07 ` Ahmad Fatoum [this message]
2019-06-17 15:07 ` [PATCH v1 11/12] ARM: stm32mp: implement PSCI support Ahmad Fatoum
2019-06-17 15:07 ` [PATCH v1 12/12] ARM: stm32mp157c-dk2: boot kernel in nonsecure mode Ahmad Fatoum
2019-06-20 14:32 ` [PATCH v1 00/12] ARM: stm32mp: add drivers for GPIO, pinctrl Sascha Hauer
2019-07-03 16:51 ` Ahmad Fatoum
2019-07-04 5:39 ` Ahmad Fatoum
2019-07-04 7:01 ` Sascha Hauer
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=20190617150751.3421-11-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox