All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Add external system driver
@ 2022-09-13 12:57 emekcan.aras
  2022-09-13 12:57 ` [PATCH 1/2] arm-bsp/u-boot: Add external system driver to u-boot device tree emekcan.aras
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: emekcan.aras @ 2022-09-13 12:57 UTC (permalink / raw)
  To: meta-arm, Jon.Mason; +Cc: nd, Emekcan

From: Emekcan <emekcan.aras@arm.com>

Corstone1000 needs a kernel driver to control the
external system (turn on/off, reset). This commit
adds the external system driver binding 
to the u-boot device tree and enables communication
with external system for corstone1000.

Emekcan (2):
  arm-bsp/u-boot: Add external system driver to u-boot device tree
  arm-bsp/kernel: Add external device driver

 ...e-external-sys-driver-to-device-tree.patch |  37 +++
 .../recipes-bsp/u-boot/u-boot_%.bbappend      |   1 +
 .../0002-Add-external-system-driver.patch     | 223 ++++++++++++++++++
 .../linux/files/corstone1000/defconfig        |   1 +
 .../linux/linux-arm-platforms.inc             |   1 +
 5 files changed, 263 insertions(+)
 create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-Introduce-external-sys-driver-to-device-tree.patch
 create mode 100644 meta-arm-bsp/recipes-kernel/linux/files/corstone1000/0002-Add-external-system-driver.patch

-- 
2.17.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] arm-bsp/u-boot: Add external system driver to u-boot device tree
  2022-09-13 12:57 [PATCH 0/2] Add external system driver emekcan.aras
@ 2022-09-13 12:57 ` emekcan.aras
  2022-09-13 12:57 ` [PATCH 2/2] arm-bsp/kernel: Add external device driver emekcan.aras
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: emekcan.aras @ 2022-09-13 12:57 UTC (permalink / raw)
  To: meta-arm, Jon.Mason; +Cc: nd, Emekcan

From: Emekcan <emekcan.aras@arm.com>

Corstone1000 needs a kernel driver to control the
external system (turn on/off, reset). This commit
adds the external system driver binding to the
u-boot device tree for corstone1000.

Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
---
 ...e-external-sys-driver-to-device-tree.patch | 37 +++++++++++++++++++
 .../recipes-bsp/u-boot/u-boot_%.bbappend      |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-Introduce-external-sys-driver-to-device-tree.patch

diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-Introduce-external-sys-driver-to-device-tree.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-Introduce-external-sys-driver-to-device-tree.patch
new file mode 100644
index 00000000..cc4ab0a3
--- /dev/null
+++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-Introduce-external-sys-driver-to-device-tree.patch
@@ -0,0 +1,37 @@
+Upstream-Status: Pending [Not submitted to upstream yet]
+Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
+
+From 83f16fe96a86b00f7a4b7c4c4f7416119b80eddd Mon Sep 17 00:00:00 2001
+From: Emekcan <emekcan.aras@arm.com>
+Date: Fri, 19 Aug 2022 16:04:48 +0100
+Subject: [PATCH] Introduce external sys driver to device-tree
+
+It adds external sys driver binding to u-boot
+device tree.
+
+Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
+---
+ arch/arm/dts/corstone1000.dtsi | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
+index d0194aa893..19b6e3ea72 100644
+--- a/arch/arm/dts/corstone1000.dtsi
++++ b/arch/arm/dts/corstone1000.dtsi
+@@ -160,6 +160,13 @@
+ 			secure-status = "okay";     /* secure-world-only */
+ 			status = "disabled";
+ 		};
++
++		extsys0: extsys@1A010310 {
++			compatible = "arm,extsys_ctrl";
++			reg = <0x1A010310 0x4>,
++			      <0x1A010314 0X4>;
++			reg-names = "rstreg", "streg";
++		};
+ 	};
+ 
+ 	arm_ffa: arm_ffa {
+-- 
+2.17.1
+
diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend
index a0a72845..3c316f30 100644
--- a/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend
+++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend
@@ -43,6 +43,7 @@ SRC_URI:append:corstone1000 = " \
         file://0023-efi_loader-fix-null-pointer-exception-with-get_image.patch \
         file://0024-arm-corstone1000-add-mmc-for-fvp.patch \
         file://0025-corstone1000-use-a-compressed-kernel.patch \
+        file://0026-Introduce-external-sys-driver-to-device-tree.patch \
       "
 
 #
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] arm-bsp/kernel: Add external device driver
  2022-09-13 12:57 [PATCH 0/2] Add external system driver emekcan.aras
  2022-09-13 12:57 ` [PATCH 1/2] arm-bsp/u-boot: Add external system driver to u-boot device tree emekcan.aras
@ 2022-09-13 12:57 ` emekcan.aras
  2022-09-14 14:09 ` [PATCH 0/2] Add external system driver Jon Mason
  2022-09-20 22:36 ` Jon Mason
  3 siblings, 0 replies; 5+ messages in thread
From: emekcan.aras @ 2022-09-13 12:57 UTC (permalink / raw)
  To: meta-arm, Jon.Mason; +Cc: nd, Emekcan

From: Emekcan <emekcan.aras@arm.com>

Adds external system device driver into linux.
User applications can control the external system
using the driver under /dev/extsys_ctrl in
corstone1000 platform.

Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
---
 .../0002-Add-external-system-driver.patch     | 223 ++++++++++++++++++
 .../linux/files/corstone1000/defconfig        |   1 +
 .../linux/linux-arm-platforms.inc             |   1 +
 3 files changed, 225 insertions(+)
 create mode 100644 meta-arm-bsp/recipes-kernel/linux/files/corstone1000/0002-Add-external-system-driver.patch

diff --git a/meta-arm-bsp/recipes-kernel/linux/files/corstone1000/0002-Add-external-system-driver.patch b/meta-arm-bsp/recipes-kernel/linux/files/corstone1000/0002-Add-external-system-driver.patch
new file mode 100644
index 00000000..ae69090a
--- /dev/null
+++ b/meta-arm-bsp/recipes-kernel/linux/files/corstone1000/0002-Add-external-system-driver.patch
@@ -0,0 +1,223 @@
+Upstream-Status: Pending[Not submitted to upstream yet]
+Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
+
+From 97509e82b51c57935fc8e918b33c09c4f6648ed7 Mon Sep 17 00:00:00 2001
+From: Emekcan <emekcan.aras@arm.com>
+Date: Fri, 19 Aug 2022 14:51:08 +0100
+Subject: [PATCH] Add external system driver
+
+Adds external system driver to control it
+from user-space. It provides run and reset
+functionality at the moment.
+
+Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
+---
+ drivers/misc/Kconfig           |   2 +
+ drivers/misc/Makefile          |   1 +
+ drivers/misc/arm/Kconfig       |   5 ++
+ drivers/misc/arm/Makefile      |   1 +
+ drivers/misc/arm/extsys_ctrl.c | 151 +++++++++++++++++++++++++++++++++
+ 5 files changed, 160 insertions(+)
+ create mode 100644 drivers/misc/arm/Kconfig
+ create mode 100644 drivers/misc/arm/Makefile
+ create mode 100644 drivers/misc/arm/extsys_ctrl.c
+
+diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
+index 0f5a49fc7c9e..5ca195110b3f 100644
+--- a/drivers/misc/Kconfig
++++ b/drivers/misc/Kconfig
+@@ -487,4 +487,6 @@ source "drivers/misc/cardreader/Kconfig"
+ source "drivers/misc/habanalabs/Kconfig"
+ source "drivers/misc/uacce/Kconfig"
+ source "drivers/misc/pvpanic/Kconfig"
++source "drivers/misc/arm/Kconfig"
++
+ endmenu
+diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
+index a086197af544..f5c1bd5747f7 100644
+--- a/drivers/misc/Makefile
++++ b/drivers/misc/Makefile
+@@ -59,3 +59,4 @@ obj-$(CONFIG_UACCE)		+= uacce/
+ obj-$(CONFIG_XILINX_SDFEC)	+= xilinx_sdfec.o
+ obj-$(CONFIG_HISI_HIKEY_USB)	+= hisi_hikey_usb.o
+ obj-$(CONFIG_HI6421V600_IRQ)	+= hi6421v600-irq.o
++obj-y				+= arm/
+diff --git a/drivers/misc/arm/Kconfig b/drivers/misc/arm/Kconfig
+new file mode 100644
+index 000000000000..3c4b3f08e6b4
+--- /dev/null
++++ b/drivers/misc/arm/Kconfig
+@@ -0,0 +1,5 @@
++config EXTSYS_CTRL
++	tristate "Arm External System control driver"
++	help
++	  Say y here to enable support for external system control
++	  driver for the Arm Corstone-700 and Corstone1000 platform
+\ No newline at end of file
+diff --git a/drivers/misc/arm/Makefile b/drivers/misc/arm/Makefile
+new file mode 100644
+index 000000000000..1ca3084cf8a0
+--- /dev/null
++++ b/drivers/misc/arm/Makefile
+@@ -0,0 +1 @@
++obj-$(CONFIG_EXTSYS_CTRL)	+= extsys_ctrl.o
+diff --git a/drivers/misc/arm/extsys_ctrl.c b/drivers/misc/arm/extsys_ctrl.c
+new file mode 100644
+index 000000000000..1c6ef14a32ae
+--- /dev/null
++++ b/drivers/misc/arm/extsys_ctrl.c
+@@ -0,0 +1,151 @@
++// SPDX-License-Identifier: GPL-2.0
++/*
++ * Arm Corstone700 and Corstone1000 external system reset control driver
++ *
++ * Copyright (C) 2019 Arm Ltd.
++ *
++ */
++
++#include <linux/fs.h>
++#include <linux/clk.h>
++#include <linux/err.h>
++#include <linux/interrupt.h>
++#include <linux/io.h>
++#include <linux/kernel.h>
++#include <linux/mod_devicetable.h>
++#include <linux/module.h>
++#include <linux/platform_device.h>
++#include <linux/miscdevice.h>
++#include <linux/init.h>
++
++#define EXTSYS_DRV_NAME		"extsys_ctrl"
++#define EXTSYS_MAX_DEVS		 4
++
++#define EXTSYS_RST_SIZE		U(0x8)
++#define EXTSYS_RST_CTRL_OFF	U(0x0)
++#define EXTSYS_RST_ST_OFF	U(0x4)
++
++/* External system reset control indexes */
++#define EXTSYS_CPU_WAIT		(0x0)
++#define EXTSYS_RST_REQ		(0x1)
++
++/* External system reset status masks */
++#define EXTSYS_RST_ST_ACK_OFF	U(0x1)
++
++/* No Reset Requested */
++#define EXTSYS_RST_ST_ACK_NRR	(0x0 << EXTSYS_RST_ST_ACK_OFF)
++
++/* Reset Request Complete */
++#define EXTSYS_RST_ST_ACK_RRC	(0x2 << EXTSYS_RST_ST_ACK_OFF)
++
++/* Reset Request Unable to Complete */
++#define EXTSYS_RST_ST_ACK_RRUC	(0x3 << EXTSYS_RST_ST_ACK_OFF)
++
++/* IOCTL commands */
++#define EXTSYS_CPU_WAIT_DISABLE	0x0
++#define EXTSYS_RESET_REQ_ENABLE	0x1
++
++struct extsys_ctrl {
++	struct miscdevice miscdev;
++	void __iomem *reset_reg;
++	void __iomem *set_reg;
++};
++
++#define CLEAR_BIT(addr, index) writel(readl(addr) & ~(1UL << index), addr)
++#define SET_BIT(addr, index) writel(readl(addr) | (1UL << index), addr)
++
++static long extsys_ctrl_ioctl(struct file *f, unsigned int cmd,
++			      unsigned long arg)
++{
++	struct extsys_ctrl *extsys;
++
++	extsys = container_of(f->private_data, struct extsys_ctrl, miscdev);
++
++	switch (cmd) {
++	case EXTSYS_CPU_WAIT_DISABLE:
++		CLEAR_BIT(extsys->reset_reg, EXTSYS_CPU_WAIT);
++		break;
++	case EXTSYS_RESET_REQ_ENABLE:
++		SET_BIT(extsys->reset_reg, EXTSYS_RST_REQ);
++		break;
++	default:
++		break;
++	}
++
++	return 0;
++}
++
++static const struct file_operations extsys_ctrl_fops = {
++	.owner = THIS_MODULE,
++	.unlocked_ioctl = extsys_ctrl_ioctl,
++};
++
++static int extsys_ctrl_probe(struct platform_device *pdev)
++{
++	struct device *dev = &pdev->dev;
++	struct extsys_ctrl *extsys;
++	struct resource *res;
++	void __iomem *reset_reg;
++	void __iomem *set_reg;
++	int ret;
++
++	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rstreg");
++	reset_reg = devm_ioremap_resource(dev, res);
++	if (IS_ERR(reset_reg))
++		return PTR_ERR(reset_reg);
++
++	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "streg");
++	set_reg = devm_ioremap_resource(dev, res);
++	if (IS_ERR(set_reg))
++		return PTR_ERR(set_reg);
++
++	extsys = devm_kzalloc(dev, sizeof(*extsys), GFP_KERNEL);
++	if (!extsys)
++		return -ENOMEM;
++
++	extsys->reset_reg = reset_reg;
++	extsys->set_reg = set_reg;
++
++	extsys->miscdev.minor = MISC_DYNAMIC_MINOR;
++	extsys->miscdev.name = EXTSYS_DRV_NAME;
++	extsys->miscdev.fops = &extsys_ctrl_fops;
++	extsys->miscdev.parent = dev;
++
++	ret = misc_register(&extsys->miscdev);
++	if (ret)
++		return ret;
++
++	dev_info(dev, "external system controller ready\n");
++
++	return 0;
++}
++
++static int extsys_ctrl_remove(struct platform_device *pdev)
++{
++	struct extsys_ctrl *extsys = dev_get_drvdata(&pdev->dev);
++
++	misc_deregister(&extsys->miscdev);
++
++	return 0;
++}
++
++static const struct of_device_id extsys_ctrl_match[] = {
++	{ .compatible = "arm,extsys_ctrl" },
++	{ },
++};
++MODULE_DEVICE_TABLE(of, extsys_ctrl_match);
++
++static struct platform_driver extsys_ctrl_driver = {
++	.driver = {
++		.name = EXTSYS_DRV_NAME,
++		.of_match_table = extsys_ctrl_match,
++	},
++	.probe = extsys_ctrl_probe,
++	.remove = extsys_ctrl_remove,
++};
++module_platform_driver(extsys_ctrl_driver);
++
++MODULE_LICENSE("GPL v2");
++MODULE_DESCRIPTION("Arm External System Control Driver");
++MODULE_AUTHOR("Morten Borup Petersen");
++MODULE_AUTHOR("Rui Miguel Silva <rui.silva@arm.com>");
+-- 
+2.17.1
+
diff --git a/meta-arm-bsp/recipes-kernel/linux/files/corstone1000/defconfig b/meta-arm-bsp/recipes-kernel/linux/files/corstone1000/defconfig
index 5f0a7e91..095cc257 100644
--- a/meta-arm-bsp/recipes-kernel/linux/files/corstone1000/defconfig
+++ b/meta-arm-bsp/recipes-kernel/linux/files/corstone1000/defconfig
@@ -92,3 +92,4 @@ CONFIG_LIBCRC32C=y
 CONFIG_DEBUG_FS=y
 CONFIG_PANIC_TIMEOUT=5
 CONFIG_STACKTRACE=y
+CONFIG_EXTSYS_CTRL=y
\ No newline at end of file
diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc b/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc
index 7bb4a925..c44d5883 100644
--- a/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc
+++ b/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc
@@ -41,6 +41,7 @@ KERNEL_EXTRA_ARGS:corstone1000 += "CONFIG_INITRAMFS_COMPRESSION_NONE=y"
 SRC_URI:append:corstone1000 = " \
            file://defconfig  \
            file://0001-UPSTREAM-firmware-arm_ffa-Handle-compatibility-with-.patch  \
+           file://0002-Add-external-system-driver.patch \
         "
 
 SRC_URI:append:corstone1000 = " ${@bb.utils.contains('MACHINE_FEATURES', \
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Add external system driver
  2022-09-13 12:57 [PATCH 0/2] Add external system driver emekcan.aras
  2022-09-13 12:57 ` [PATCH 1/2] arm-bsp/u-boot: Add external system driver to u-boot device tree emekcan.aras
  2022-09-13 12:57 ` [PATCH 2/2] arm-bsp/kernel: Add external device driver emekcan.aras
@ 2022-09-14 14:09 ` Jon Mason
  2022-09-20 22:36 ` Jon Mason
  3 siblings, 0 replies; 5+ messages in thread
From: Jon Mason @ 2022-09-14 14:09 UTC (permalink / raw)
  To: meta-arm, Jon.Mason, emekcan.aras; +Cc: nd

On Tue, 13 Sep 2022 13:57:09 +0100, emekcan.aras@arm.com wrote:
> Corstone1000 needs a kernel driver to control the
> external system (turn on/off, reset). This commit
> adds the external system driver binding
> to the u-boot device tree and enables communication
> with external system for corstone1000.
> 
> Emekcan (2):
>   arm-bsp/u-boot: Add external system driver to u-boot device tree
>   arm-bsp/kernel: Add external device driver
> 
> [...]

Applied, thanks!

[1/2] arm-bsp/u-boot: Add external system driver to u-boot device tree
      commit: 1182b0d2ea746327b70197c6de53b6c86c793930
[2/2] arm-bsp/kernel: Add external device driver
      commit: b086301d4621926cb8762c04b68ddffb295a7063

Best regards,
-- 
Jon Mason <jon.mason@arm.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Add external system driver
  2022-09-13 12:57 [PATCH 0/2] Add external system driver emekcan.aras
                   ` (2 preceding siblings ...)
  2022-09-14 14:09 ` [PATCH 0/2] Add external system driver Jon Mason
@ 2022-09-20 22:36 ` Jon Mason
  3 siblings, 0 replies; 5+ messages in thread
From: Jon Mason @ 2022-09-20 22:36 UTC (permalink / raw)
  To: meta-arm, Jon.Mason, emekcan.aras; +Cc: nd

On Tue, 13 Sep 2022 13:57:09 +0100, emekcan.aras@arm.com wrote:
> Corstone1000 needs a kernel driver to control the
> external system (turn on/off, reset). This commit
> adds the external system driver binding
> to the u-boot device tree and enables communication
> with external system for corstone1000.
> 
> Emekcan (2):
>   arm-bsp/u-boot: Add external system driver to u-boot device tree
>   arm-bsp/kernel: Add external device driver
> 
> [...]

Applied, thanks!

[1/2] arm-bsp/u-boot: Add external system driver to u-boot device tree
      commit: 1182b0d2ea746327b70197c6de53b6c86c793930
[2/2] arm-bsp/kernel: Add external device driver
      commit: b086301d4621926cb8762c04b68ddffb295a7063

Best regards,
-- 
Jon Mason <jon.mason@arm.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-20 22:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-13 12:57 [PATCH 0/2] Add external system driver emekcan.aras
2022-09-13 12:57 ` [PATCH 1/2] arm-bsp/u-boot: Add external system driver to u-boot device tree emekcan.aras
2022-09-13 12:57 ` [PATCH 2/2] arm-bsp/kernel: Add external device driver emekcan.aras
2022-09-14 14:09 ` [PATCH 0/2] Add external system driver Jon Mason
2022-09-20 22:36 ` Jon Mason

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.