OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yu Chien Peter Lin <peterlin@andestech.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v2 09/11] platform: andes: Factor out is_andes() helper
Date: Thu, 19 Oct 2023 19:37:11 +0800	[thread overview]
Message-ID: <20231019113713.3508153-10-peterlin@andestech.com> (raw)
In-Reply-To: <20231019113713.3508153-1-peterlin@andestech.com>

We will need is_andes(45) in the following patch,
so factor out the code that parses marchid to make
it reusable for checking any Andes CPU variants.

Also improves the comment in ae350_hart_start().

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
---
Changes v1 -> v2:
  - New patch
---
 platform/generic/andes/ae350.c           | 16 +++++++---------
 platform/generic/include/andes/andes45.h |  6 ++++++
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/platform/generic/andes/ae350.c b/platform/generic/andes/ae350.c
index c3f280d..80cd294 100644
--- a/platform/generic/andes/ae350.c
+++ b/platform/generic/andes/ae350.c
@@ -24,16 +24,14 @@ static struct smu_data smu = { 0 };
 extern void __ae350_enable_coherency_warmboot(void);
 extern void __ae350_disable_coherency(void);
 
-static __always_inline bool is_andes25(void)
-{
-	ulong marchid = csr_read(CSR_MARCHID);
-	return !!(EXTRACT_FIELD(marchid, CSR_MARCHID_MICROID) == 0xa25);
-}
-
 static int ae350_hart_start(u32 hartid, ulong saddr)
 {
-	/* Don't send wakeup command at boot-time */
-	if (!sbi_init_count(hartid) || (is_andes25() && hartid == 0))
+	/*
+	 * Don't send wakeup command
+	 * 1) at boot-time
+	 * 2) the target hart is non-sleepable 25-series hart0
+	 */
+	if (!sbi_init_count(hartid) || (is_andes(25) && hartid == 0))
 		return sbi_ipi_raw_send(sbi_hartid_to_hartindex(hartid));
 
 	/* Write wakeup command to the sleep hart */
@@ -52,7 +50,7 @@ static int ae350_hart_stop(void)
 	 * L2-cache, instead of turning it off, it should fall
 	 * through and jump to warmboot_addr.
 	 */
-	if (is_andes25() && hartid == 0)
+	if (is_andes(25) && hartid == 0)
 		return SBI_ENOTSUPP;
 
 	if (!smu_support_sleep_mode(&smu, DEEPSLEEP_MODE, hartid))
diff --git a/platform/generic/include/andes/andes45.h b/platform/generic/include/andes/andes45.h
index ce31617..01f63d4 100644
--- a/platform/generic/include/andes/andes45.h
+++ b/platform/generic/include/andes/andes45.h
@@ -43,6 +43,12 @@
 
 #ifndef __ASSEMBLER__
 
+#define is_andes(series)				\
+({							\
+	char value = csr_read(CSR_MARCHID) & 0xff;	\
+	(series) == (value >> 4) * 10 + (value & 0x0f);	\
+})
+
 #define has_andes_pmu()					\
 ({							\
 	(((csr_read(CSR_MMSC_CFG) &			\
-- 
2.34.1



  parent reply	other threads:[~2023-10-19 11:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-19 11:37 [PATCH v2 00/11] Add Andes PMU extension support Yu Chien Peter Lin
2023-10-19 11:37 ` [PATCH v2 01/11] sbi: sbi_pmu: Improve sbi_pmu_init() error handling Yu Chien Peter Lin
2023-11-16  6:32   ` Anup Patel
2023-10-19 11:37 ` [PATCH v2 02/11] sbi: sbi_pmu: Add hw_counter_filter_mode() to pmu device Yu Chien Peter Lin
2023-11-16  6:36   ` Anup Patel
2023-10-19 11:37 ` [PATCH v2 03/11] platform: include: andes45: Add PMU related CSR defines Yu Chien Peter Lin
2023-11-16  6:39   ` Anup Patel
2023-10-19 11:37 ` [PATCH v2 04/11] platform: andes: Add Andes custom PMU support Yu Chien Peter Lin
2023-11-16  6:41   ` Anup Patel
2023-10-19 11:37 ` [PATCH v2 05/11] platform: andes: Enable Andes PMU for AE350 Yu Chien Peter Lin
2023-11-16  6:45   ` Anup Patel
2023-10-19 11:37 ` [PATCH v2 06/11] platform: rzfive: Enable Andes PMU for RZ/Five Yu Chien Peter Lin
2023-11-16  6:45   ` Anup Patel
2023-10-19 11:37 ` [PATCH v2 07/11] lib: utils: fdt_fixup: Add fdt_add_pmu_mappings() helper function Yu Chien Peter Lin
2023-10-21 12:25   ` [PATCH v2 10/11] platform: andes: Implement andes_fdt_add_pmu_mappings platform override Inochi Amaoto
2023-10-22  6:50     ` Yu-Chien Peter Lin
2023-11-16  6:59   ` [PATCH v2 07/11] lib: utils: fdt_fixup: Add fdt_add_pmu_mappings() helper function Anup Patel
2023-10-19 11:37 ` [PATCH v2 08/11] lib: utils: fdt_fixup: Allow preserving PMU properties Yu Chien Peter Lin
2023-11-16  6:48   ` Anup Patel
2023-10-19 11:37 ` Yu Chien Peter Lin [this message]
2023-11-16  6:49   ` [PATCH v2 09/11] platform: andes: Factor out is_andes() helper Anup Patel
2023-10-19 11:37 ` [PATCH v2 10/11] platform: andes: Implement andes_fdt_add_pmu_mappings platform override Yu Chien Peter Lin
2023-11-16  6:58   ` Anup Patel
2023-10-19 11:37 ` [PATCH v2 11/11] docs: pmu: Add Andes PMU node example Yu Chien Peter Lin
2023-11-16  7:00   ` Anup Patel
2023-11-16  7:01 ` [PATCH v2 00/11] Add Andes PMU extension support Anup Patel
2023-11-21  7:44   ` Yu-Chien Peter Lin

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=20231019113713.3508153-10-peterlin@andestech.com \
    --to=peterlin@andestech.com \
    --cc=opensbi@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