From: Krzysztof Kozlowski <krzk@kernel.org>
To: ysionneau@kalrayinc.com, linux-kernel@vger.kernel.org
Cc: Jonathan Borne <jborne@kalrayinc.com>,
Julian Vetter <jvetter@kalrayinc.com>,
Clement Leger <clement@clement-leger.fr>,
Louis Morhet <lmorhet@kalrayinc.com>,
Marius Gligor <mgligor@kalrayinc.com>,
Jules Maselbas <jmaselbas@zdiv.net>,
bpf@vger.kernel.org
Subject: Re: [RFC PATCH v3 34/37] kvx: Add power controller driver
Date: Mon, 22 Jul 2024 14:37:37 +0200 [thread overview]
Message-ID: <daa59ab0-08d6-4a65-9367-c34bb42b8ad8@kernel.org> (raw)
In-Reply-To: <20240722094226.21602-35-ysionneau@kalrayinc.com>
On 22/07/2024 11:41, ysionneau@kalrayinc.com wrote:
> From: Yann Sionneau <ysionneau@kalrayinc.com>
>
> The Power Controller (pwr-ctrl) controls cores reset and wake-up
> procedure.
>
> Co-developed-by: Clement Leger <clement@clement-leger.fr>
> Signed-off-by: Clement Leger <clement@clement-leger.fr>
> Co-developed-by: Julian Vetter <jvetter@kalrayinc.com>
> Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
> Co-developed-by: Louis Morhet <lmorhet@kalrayinc.com>
> Signed-off-by: Louis Morhet <lmorhet@kalrayinc.com>
> Co-developed-by: Marius Gligor <mgligor@kalrayinc.com>
> Signed-off-by: Marius Gligor <mgligor@kalrayinc.com>
> Signed-off-by: Jules Maselbas <jmaselbas@zdiv.net>
> Signed-off-by: Yann Sionneau <ysionneau@kalrayinc.com>
> ---
>
> Notes:
> V1 -> V2: new patch
> V2 -> V3:
> - Moved driver from arch/kvx/platform to drivers/soc/kvx/
> see discussions there:
> - https://lore.kernel.org/bpf/Y8qlOpYgDefMPqWH@zx2c4.com/T/#m722d8f7c7501615251e4f97705198f5485865ce2
> - indent
> - add missing static qualifier
> - driver now registers a cpu_method/smp_op via CPU_METHOD_OF_DECLARE
> like arm and sh, it puts a struct into a __cpu_method_of_table ELF section.
> the smp_ops is used by smpboot.c if its name matches the DT 'cpus' node
> enable-method property.
> ---
> arch/kvx/include/asm/pwr_ctrl.h | 57 ++++++++++++++++++++
> drivers/soc/Kconfig | 1 +
> drivers/soc/Makefile | 1 +
> drivers/soc/kvx/Kconfig | 10 ++++
> drivers/soc/kvx/Makefile | 2 +
> drivers/soc/kvx/coolidge_pwr_ctrl.c | 84 +++++++++++++++++++++++++++++
> 6 files changed, 155 insertions(+)
> create mode 100644 arch/kvx/include/asm/pwr_ctrl.h
> create mode 100644 drivers/soc/kvx/Kconfig
> create mode 100644 drivers/soc/kvx/Makefile
> create mode 100644 drivers/soc/kvx/coolidge_pwr_ctrl.c
>
> diff --git a/arch/kvx/include/asm/pwr_ctrl.h b/arch/kvx/include/asm/pwr_ctrl.h
> new file mode 100644
> index 0000000000000..715eddd45a88c
> --- /dev/null
> +++ b/arch/kvx/include/asm/pwr_ctrl.h
> @@ -0,0 +1,57 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (C) 2017-2024 Kalray Inc.
> + * Author(s): Clement Leger
> + * Marius Gligor
> + * Julian Vetter
> + * Yann Sionneau
> + */
> +
> +#ifndef _ASM_KVX_PWR_CTRL_H
> +#define _ASM_KVX_PWR_CTRL_H
> +
> +#ifndef __ASSEMBLY__
> +
> +static int kvx_pwr_ctrl_probe(void);
> +
> +int kvx_pwr_ctrl_cpu_poweron(unsigned int cpu);
> +
> +#endif
> +
> +#define PWR_CTRL_ADDR 0xA40000
> +
> +/* Power controller vector register definitions */
> +#define KVX_PWR_CTRL_VEC_OFFSET 0x1000
> +#define KVX_PWR_CTRL_VEC_WUP_SET_OFFSET 0x10
> +#define KVX_PWR_CTRL_VEC_WUP_CLEAR_OFFSET 0x20
> +
> +/* Power controller PE reset PC register definitions */
> +#define KVX_PWR_CTRL_RESET_PC_OFFSET 0x2000
> +
> +/* Power controller global register definitions */
> +#define KVX_PWR_CTRL_GLOBAL_OFFSET 0x4040
> +
> +#define KVX_PWR_CTRL_GLOBAL_SET_OFFSET 0x10
> +#define KVX_PWR_CTRL_GLOBAL_CLEAR_OFFSET 0x20
> +#define KVX_PWR_CTRL_GLOBAL_SET_PE_EN_SHIFT 0x1
> +
> +#define PWR_CTRL_WUP_SET_OFFSET \
> + (KVX_PWR_CTRL_VEC_OFFSET + \
> + KVX_PWR_CTRL_VEC_WUP_SET_OFFSET)
> +
> +#define PWR_CTRL_WUP_CLEAR_OFFSET \
> + (KVX_PWR_CTRL_VEC_OFFSET + \
> + KVX_PWR_CTRL_VEC_WUP_CLEAR_OFFSET)
> +
> +#define PWR_CTRL_GLOBAL_CONFIG_SET_OFFSET \
> + (KVX_PWR_CTRL_GLOBAL_OFFSET + \
> + KVX_PWR_CTRL_GLOBAL_SET_OFFSET)
> +
> +#define PWR_CTRL_GLOBAL_CONFIG_CLEAR_OFFSET \
> + (KVX_PWR_CTRL_GLOBAL_OFFSET + \
> + KVX_PWR_CTRL_GLOBAL_CLEAR_OFFSET)
> +
> +#define PWR_CTRL_GLOBAL_CONFIG_PE_EN \
> + (1 << KVX_PWR_CTRL_GLOBAL_SET_PE_EN_SHIFT)
> +
> +#endif /* _ASM_KVX_PWR_CTRL_H */
> diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
> index 5d924e946507b..f28078620da14 100644
> --- a/drivers/soc/Kconfig
> +++ b/drivers/soc/Kconfig
> @@ -12,6 +12,7 @@ source "drivers/soc/fujitsu/Kconfig"
> source "drivers/soc/hisilicon/Kconfig"
> source "drivers/soc/imx/Kconfig"
> source "drivers/soc/ixp4xx/Kconfig"
> +source "drivers/soc/kvx/Kconfig"
> source "drivers/soc/litex/Kconfig"
> source "drivers/soc/loongson/Kconfig"
> source "drivers/soc/mediatek/Kconfig"
> diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
> index fb2bd31387d07..240e148eaaff8 100644
> --- a/drivers/soc/Makefile
> +++ b/drivers/soc/Makefile
> @@ -16,6 +16,7 @@ obj-$(CONFIG_ARCH_GEMINI) += gemini/
> obj-y += hisilicon/
> obj-y += imx/
> obj-y += ixp4xx/
> +obj-$(CONFIG_KVX) += kvx/
> obj-$(CONFIG_SOC_XWAY) += lantiq/
> obj-$(CONFIG_LITEX_SOC_CONTROLLER) += litex/
> obj-y += loongson/
> diff --git a/drivers/soc/kvx/Kconfig b/drivers/soc/kvx/Kconfig
> new file mode 100644
> index 0000000000000..96d05efe4bfb5
> --- /dev/null
> +++ b/drivers/soc/kvx/Kconfig
> @@ -0,0 +1,10 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +config COOLIDGE_POWER_CONTROLLER
> + bool "Coolidge power controller"
> + default n
> + depends on KVX
> + help
> + The Kalray Coolidge Power Controller is used to manage the power
> + state of secondary CPU cores. Currently only powering up is
> + supported.
> diff --git a/drivers/soc/kvx/Makefile b/drivers/soc/kvx/Makefile
> new file mode 100644
> index 0000000000000..c7b0b3e99eabc
> --- /dev/null
> +++ b/drivers/soc/kvx/Makefile
> @@ -0,0 +1,2 @@
> +# SPDX-License-Identifier: GPL-2.0
> +obj-$(CONFIG_COOLIDGE_POWER_CONTROLLER) += coolidge_pwr_ctrl.o
> diff --git a/drivers/soc/kvx/coolidge_pwr_ctrl.c b/drivers/soc/kvx/coolidge_pwr_ctrl.c
> new file mode 100644
> index 0000000000000..67af3e446d0e7
> --- /dev/null
> +++ b/drivers/soc/kvx/coolidge_pwr_ctrl.c
> @@ -0,0 +1,84 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (C) 2017-2024 Kalray Inc.
> + * Author(s): Clement Leger
> + * Yann Sionneau
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/of_address.h>
> +#include <linux/of_platform.h>
> +#include <linux/slab.h>
> +#include <linux/smp.h>
> +#include <linux/types.h>
> +
> +#include <asm/pwr_ctrl.h>
> +#include <asm/symbols.h>
> +
> +struct kvx_pwr_ctrl {
> + void __iomem *regs;
> +};
> +
> +static struct kvx_pwr_ctrl kvx_pwr_controller;
> +
> +static bool pwr_ctrl_not_initialized = true;
Do not use inverted meanings.
> +
> +/**
> + * kvx_pwr_ctrl_cpu_poweron() - Wakeup a cpu
> + * @cpu: cpu to wakeup
> + */
> +int __init kvx_pwr_ctrl_cpu_poweron(unsigned int cpu)
> +{
> + int ret = 0;
> +
> + if (pwr_ctrl_not_initialized) {
> + pr_err("KVX power controller not initialized!\n");
> + return -ENODEV;
> + }
> +
> + /* Set PE boot address */
> + writeq((unsigned long long)kvx_start,
Addresses use kernel_ulong_t
> + kvx_pwr_controller.regs + KVX_PWR_CTRL_RESET_PC_OFFSET);
> + /* Wake up processor ! */
> + writeq(1ULL << cpu,
That's BIT
> + kvx_pwr_controller.regs + PWR_CTRL_WUP_SET_OFFSET);
> + /* Then clear wakeup to allow processor to sleep */
> + writeq(1ULL << cpu,
BIT
> + kvx_pwr_controller.regs + PWR_CTRL_WUP_CLEAR_OFFSET);
> +
> + return ret;
> +}
> +
> +static const struct smp_operations coolidge_smp_ops __initconst = {
> + .smp_boot_secondary = kvx_pwr_ctrl_cpu_poweron,
> +};
> +
> +static int __init kvx_pwr_ctrl_probe(void)
That's not a probe, please rename to avoid confusion. Or make it a
proper device driver.
> +{
> + struct device_node *ctrl;
> +
> + ctrl = of_find_compatible_node(NULL, NULL, "kalray,coolidge-pwr-ctrl");
> + if (!ctrl) {
> + pr_err("Failed to get power controller node\n");
> + return -EINVAL;
> + }
> +
> + kvx_pwr_controller.regs = of_iomap(ctrl, 0);
> + if (!kvx_pwr_controller.regs) {
> + pr_err("Failed ioremap\n");
> + return -EINVAL;
> + }
> +
> + pwr_ctrl_not_initialized = false;
> + pr_info("KVX power controller probed\n");
> +
> + return 0;
> +}
> +
> +CPU_METHOD_OF_DECLARE(coolidge_pwr_ctrl, "kalray,coolidge-pwr-ctrl",
> + &coolidge_smp_ops);
> +
> +early_initcall(kvx_pwr_ctrl_probe);
Best regards,
Krzysztof
next prev parent reply other threads:[~2024-07-22 12:37 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 9:41 [RFC PATCH v3 00/37] Upstream kvx Linux port ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 01/37] Documentation: kvx: Add basic documentation ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 02/37] dt-bindings: soc: kvx: Add binding for kalray,coolidge-pwr-ctrl ysionneau
2024-07-22 9:47 ` Krzysztof Kozlowski
2024-07-31 14:31 ` Yann Sionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 9:41 ` [RFC PATCH v3 03/37] dt-bindings: Add binding for kalray,kv3-1-intc ysionneau
2024-07-22 9:51 ` Krzysztof Kozlowski
2024-07-31 14:47 ` Yann Sionneau
2024-08-07 7:55 ` Krzysztof Kozlowski
2024-07-23 20:49 ` Rob Herring
2024-07-22 9:41 ` [RFC PATCH v3 04/37] dt-bindings: Add binding for kalray,coolidge-apic-gic ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 9:41 ` [RFC PATCH v3 05/37] dt-bindings: Add binding for kalray,coolidge-apic-mailbox ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 20:47 ` Rob Herring
2024-09-04 15:07 ` Yann Sionneau
2024-07-22 9:41 ` [RFC PATCH v3 06/37] dt-bindings: Add binding for kalray,coolidge-itgen ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 9:41 ` [RFC PATCH v3 07/37] dt-bindings: Add binding for kalray,coolidge-ipi-ctrl ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 20:50 ` Rob Herring
2024-09-04 15:37 ` Yann Sionneau
2024-07-22 9:41 ` [RFC PATCH v3 08/37] dt-bindings: Add binding for kalray,coolidge-dsu-clock ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 21:45 ` Stephen Boyd
2024-07-22 9:41 ` [RFC PATCH v3 09/37] dt-bindings: Add binding for kalray,kv3-1-timer ysionneau
2024-07-23 20:52 ` Rob Herring
2024-07-22 9:41 ` [RFC PATCH v3 10/37] dt-bindings: kalray: Add CPU bindings for Kalray kvx ysionneau
2024-07-22 18:41 ` Rob Herring (Arm)
2024-07-22 20:58 ` Rob Herring
2024-07-22 9:41 ` [RFC PATCH v3 11/37] dt-bindings: kalray: Add Kalray SoC board compatibles ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 12/37] kvx: Add ELF-related definitions ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 13/37] kvx: Add build infrastructure ysionneau
2024-07-23 9:46 ` Arnd Bergmann
2024-07-22 9:41 ` [RFC PATCH v3 14/37] kvx: Add CPU definition headers ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 15/37] kvx: Add atomic/locking headers ysionneau
2024-07-23 8:26 ` Arnd Bergmann
2024-07-22 9:41 ` [RFC PATCH v3 16/37] kvx: Add other common headers ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 17/37] kvx: Add boot and setup routines ysionneau
2024-07-23 8:44 ` Arnd Bergmann
2024-07-27 14:31 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 18/37] kvx: Add exception/interrupt handling ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 19/37] irqchip: Add irq-kvx-apic-gic driver ysionneau
2024-07-22 12:28 ` Krzysztof Kozlowski
2024-08-23 12:37 ` Yann Sionneau
2024-07-27 13:10 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 20/37] irqchip: Add irq-kvx-itgen driver ysionneau
2024-07-22 12:30 ` Krzysztof Kozlowski
2024-08-23 12:42 ` Yann Sionneau
2024-07-27 13:18 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 21/37] irqchip: Add irq-kvx-apic-mailbox driver ysionneau
2024-07-27 13:35 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 22/37] irqchip: Add kvx-core-intc core interrupt controller driver ysionneau
2024-07-22 12:32 ` Krzysztof Kozlowski
2024-08-23 12:54 ` Yann Sionneau
2024-07-27 13:37 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 23/37] kvx: Add process management ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 24/37] kvx: Add memory management ysionneau
2024-07-22 14:58 ` Christoph Hellwig
2024-07-30 13:48 ` Robin Murphy
2024-08-23 16:02 ` Yann Sionneau
2024-07-22 9:41 ` [RFC PATCH v3 25/37] kvx: Add system call support ysionneau
2024-07-23 9:20 ` Arnd Bergmann
2024-07-22 9:41 ` [RFC PATCH v3 26/37] kvx: Add signal handling support ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 27/37] kvx: Add ELF relocations and module support ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 28/37] kvx: Add misc common routines ysionneau
2024-07-23 8:50 ` Arnd Bergmann
2024-07-23 9:58 ` Arnd Bergmann
2024-07-22 9:41 ` [RFC PATCH v3 29/37] kvx: Add some library functions ysionneau
2024-07-23 9:26 ` Arnd Bergmann
2024-07-22 9:41 ` [RFC PATCH v3 30/37] kvx: Add multi-processor (SMP) support ysionneau
2024-07-27 14:22 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 31/37] kvx: Add kvx default config file ysionneau
2024-07-23 8:55 ` Arnd Bergmann
2024-07-22 9:41 ` [RFC PATCH v3 32/37] kvx: Add debugging related support ysionneau
2024-07-22 9:41 ` [RFC PATCH v3 33/37] kvx: Add support for cpuinfo ysionneau
2024-07-22 12:35 ` Krzysztof Kozlowski
2024-08-23 13:00 ` Yann Sionneau
2024-07-22 9:41 ` [RFC PATCH v3 34/37] kvx: Add power controller driver ysionneau
2024-07-22 12:37 ` Krzysztof Kozlowski [this message]
2024-08-23 13:07 ` Yann Sionneau
2024-07-22 9:41 ` [RFC PATCH v3 35/37] kvx: Add IPI driver ysionneau
2024-07-22 12:39 ` Krzysztof Kozlowski
2024-08-23 14:46 ` Yann Sionneau
2024-09-07 13:20 ` Krzysztof Kozlowski
2024-07-27 14:08 ` Thomas Gleixner
2024-07-22 9:41 ` [RFC PATCH v3 36/37] kvx: dts: DeviceTree for qemu emulated Coolidge SoC ysionneau
2024-07-22 9:55 ` Krzysztof Kozlowski
2024-07-22 11:12 ` Conor Dooley
2024-07-31 15:38 ` Yann Sionneau
2024-07-31 16:57 ` Krzysztof Kozlowski
2024-07-22 9:41 ` [RFC PATCH v3 37/37] Add Kalray Inc. to the list of vendor-prefixes.yaml ysionneau
2024-07-22 9:56 ` Krzysztof Kozlowski
2024-08-01 7:35 ` Yann Sionneau
2024-07-24 7:59 ` [RFC PATCH v3 00/37] Upstream kvx Linux port Arnd Bergmann
2024-07-25 10:07 ` Yann Sionneau
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=daa59ab0-08d6-4a65-9367-c34bb42b8ad8@kernel.org \
--to=krzk@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clement@clement-leger.fr \
--cc=jborne@kalrayinc.com \
--cc=jmaselbas@zdiv.net \
--cc=jvetter@kalrayinc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lmorhet@kalrayinc.com \
--cc=mgligor@kalrayinc.com \
--cc=ysionneau@kalrayinc.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