[PATCH] platform: generic: spacemit: add K1

Troy Mitchell troy.mitchell at linux.spacemit.com
Tue Sep 16 18:23:39 PDT 2025


Hi Xing W,
Thanks for your review.

On Tue, Sep 16, 2025 at 09:11:12PM +0800, Xiang W wrote:
> 在 2025-09-16二的 13:57 +0800,Troy Mitchell写道:
> > From: Xianbin Zhu <xianbin.zhu at linux.spacemit.com>
> > 
> > Extend generic platform to support SpacemiT K1.
> > 
> > On K1, the BROM only brings up the primary core and leaves the
> > other cores in a disabled state. This prevents Linux from booting
> > SMP and only one core is available.
> > 
> > Add code to bring up all 8 cores during OpenSBI initialization so
> > that the Linux kernel can detect and use all cores properly.
> > 
> > Co-authored-by: Troy Mitchell <troy.mitchell at linux.spacemit.com>
> > Signed-off-by: Troy Mitchell <troy.mitchell at linux.spacemit.com>
> > Signed-off-by: Xianbin Zhu <xianbin.zhu at linux.spacemit.com>
> > ---
> >  platform/generic/Kconfig             |   4 +
> >  platform/generic/configs/defconfig   |   5 +-
> >  platform/generic/spacemit/k1.c       | 330 +++++++++++++++++++++++++++++++++++
> >  platform/generic/spacemit/objects.mk |   7 +
> >  4 files changed, 344 insertions(+), 2 deletions(-)
> > 
> > diff --git a/platform/generic/spacemit/k1.c b/platform/generic/spacemit/k1.c
> > new file mode 100644
> > index 0000000000000000000000000000000000000000..11e7bb50948dbe3287f4afb2692d28ce71dc1906
> > --- /dev/null
> > +++ b/platform/generic/spacemit/k1.c
> > +static bool spacemit_cold_boot_allowed(u32 hartid)
> > +{
> > +	csr_set(CSR_ML2SETUP, 1 << (hartid % PLATFORM_MAX_CPUS_PER_CLUSTER));
> > +
> > +	return __sbi_hsm_hart_get_state(hartid) != SBI_HSM_STATE_SUSPENDED &&
> > +	       !hartid;
> 
> __sbi_hsm_hart_get_state cannot be call before sbi_hsm_init.
> 
> Regards,
> Xiang W
We'll remove __sbi_hsm_hart_get_state() and just return !hartid,
because __sbi_hsm_hart_get_state() is used to check the core
state(sortware state), but we don't need it now.

This patch only introduces opening and closing cores without
idle state switching.

                                      - Troy
> 
> > +}
> > +
> > +static int spacemit_k1_platform_init(const void *fdt, int nodeoff,
> > +				     const struct fdt_match *match)
> > +{
> > +	generic_platform_ops.early_init = spacemit_k1_early_init;
> > +	generic_platform_ops.final_init = spacemit_k1_final_init;
> > +	generic_platform_ops.cold_boot_allowed = spacemit_cold_boot_allowed;
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct fdt_match spacemit_k1_match[] = {
> > +	{ .compatible = "spacemit,k1" },
> > +	{ /* sentinel */ }
> > +};
> > +
> > +const struct fdt_driver spacemit_k1 = {
> > +	.match_table = spacemit_k1_match,
> > +	.init = spacemit_k1_platform_init,
> > +};
> > diff --git a/platform/generic/spacemit/objects.mk b/platform/generic/spacemit/objects.mk
> > new file mode 100644
> > index 0000000000000000000000000000000000000000..4bf973aab1ba749b59cfdc14a572226d54c3ff15
> > --- /dev/null
> > +++ b/platform/generic/spacemit/objects.mk
> > @@ -0,0 +1,7 @@
> > +#
> > +# SPDX-License-Identifier: BSD-2-Clause
> > +#
> > +# Copyright (c) 2025 SpacemiT
> > +
> > +carray-platform_override_modules-$(CONFIG_PLATFORM_SPACEMIT_K1) += spacemit_k1
> > +platform-objs-$(CONFIG_PLATFORM_SPACEMIT_K1) += spacemit/k1.o
> > 
> > ---
> > base-commit: 153cdeea5350837c1206a2d2b6189fd0ba06d1f2
> > change-id: 20250911-smt-k1-8-cores-8985c5f40c5f
> > 
> > Best regards,
> > -- 
> > Troy Mitchell <troy.mitchell at linux.spacemit.com>
> > 
> 
> 



More information about the opensbi mailing list