diff mbox series

[v2,05/11] platform: andes: Enable Andes PMU for AE350

Message ID 20231019113713.3508153-6-peterlin@andestech.com
State Changes Requested
Headers show
Series Add Andes PMU extension support | expand

Commit Message

Yu-Chien Peter Lin Oct. 19, 2023, 11:37 a.m. UTC
Enable Andes PMU extension support for AE350 platforms.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
---
Changes v1 -> v2:
  - Implement ae350_extensions_init()
---
 platform/generic/Kconfig       |  1 +
 platform/generic/andes/ae350.c | 13 +++++++++++++
 2 files changed, 14 insertions(+)

Comments

Anup Patel Nov. 16, 2023, 6:45 a.m. UTC | #1
On Thu, Oct 19, 2023 at 5:10 PM Yu Chien Peter Lin
<peterlin@andestech.com> wrote:
>
> Enable Andes PMU extension support for AE350 platforms.
>
> Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
> Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
> ---
> Changes v1 -> v2:
>   - Implement ae350_extensions_init()
> ---
>  platform/generic/Kconfig       |  1 +
>  platform/generic/andes/ae350.c | 13 +++++++++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig
> index e7bd94e..9b2f9c7 100644
> --- a/platform/generic/Kconfig
> +++ b/platform/generic/Kconfig
> @@ -31,6 +31,7 @@ config PLATFORM_ALLWINNER_D1
>  config PLATFORM_ANDES_AE350
>         bool "Andes AE350 support"
>         select SYS_ATCSMU
> +       select ANDES_PMU
>         default n
>
>  config PLATFORM_RENESAS_RZFIVE
> diff --git a/platform/generic/andes/ae350.c b/platform/generic/andes/ae350.c
> index 80eca05..c3f280d 100644
> --- a/platform/generic/andes/ae350.c
> +++ b/platform/generic/andes/ae350.c
> @@ -8,6 +8,7 @@
>   */
>
>  #include <platform_override.h>
> +#include <andes/andes_pmu.h>
>  #include <sbi_utils/fdt/fdt_helper.h>
>  #include <sbi_utils/fdt/fdt_fixup.h>
>  #include <sbi_utils/sys/atcsmu.h>
> @@ -110,6 +111,17 @@ static int ae350_final_init(bool cold_boot, const struct fdt_match *match)
>         return 0;
>  }
>
> +static int ae350_extensions_init(const struct fdt_match *match,
> +                         struct sbi_hart_features *hfeatures)
> +{
> +       int rc;
> +       rc = andes_pmu_init();
> +       if (rc && rc != SBI_ENOTSUPP)
> +               return rc;
> +
> +       return 0;
> +}
> +
>  static const struct fdt_match andes_ae350_match[] = {
>         { .compatible = "andestech,ae350" },
>         { },
> @@ -118,4 +130,5 @@ static const struct fdt_match andes_ae350_match[] = {
>  const struct platform_override andes_ae350 = {
>         .match_table = andes_ae350_match,
>         .final_init  = ae350_final_init,
> +       .extensions_init = ae350_extensions_init,

This is not the right way.

Add a new callback pmu_init() in "struct platform_override" and
implement that here.

The generic_pmu_init() will call pmu_init() in "struct platform_override"
if it is available otherwise it will call fdt_pmu_setup().

>  };
> --
> 2.34.1
>

Regards,
Anup
diff mbox series

Patch

diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig
index e7bd94e..9b2f9c7 100644
--- a/platform/generic/Kconfig
+++ b/platform/generic/Kconfig
@@ -31,6 +31,7 @@  config PLATFORM_ALLWINNER_D1
 config PLATFORM_ANDES_AE350
 	bool "Andes AE350 support"
 	select SYS_ATCSMU
+	select ANDES_PMU
 	default n
 
 config PLATFORM_RENESAS_RZFIVE
diff --git a/platform/generic/andes/ae350.c b/platform/generic/andes/ae350.c
index 80eca05..c3f280d 100644
--- a/platform/generic/andes/ae350.c
+++ b/platform/generic/andes/ae350.c
@@ -8,6 +8,7 @@ 
  */
 
 #include <platform_override.h>
+#include <andes/andes_pmu.h>
 #include <sbi_utils/fdt/fdt_helper.h>
 #include <sbi_utils/fdt/fdt_fixup.h>
 #include <sbi_utils/sys/atcsmu.h>
@@ -110,6 +111,17 @@  static int ae350_final_init(bool cold_boot, const struct fdt_match *match)
 	return 0;
 }
 
+static int ae350_extensions_init(const struct fdt_match *match,
+			  struct sbi_hart_features *hfeatures)
+{
+	int rc;
+	rc = andes_pmu_init();
+	if (rc && rc != SBI_ENOTSUPP)
+		return rc;
+
+	return 0;
+}
+
 static const struct fdt_match andes_ae350_match[] = {
 	{ .compatible = "andestech,ae350" },
 	{ },
@@ -118,4 +130,5 @@  static const struct fdt_match andes_ae350_match[] = {
 const struct platform_override andes_ae350 = {
 	.match_table = andes_ae350_match,
 	.final_init  = ae350_final_init,
+	.extensions_init = ae350_extensions_init,
 };