mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 00/11] kvx arch update
@ 2022-01-17 22:19 Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 01/11] kvx: dma: Remove arch dma_map/unmap_single Jules Maselbas
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

This series has updates for the KVX architecture, with some fixes and
with the addition of kvx specific drivers for the otp-nvmem and socinfo.

With this series it is now possible to run barebox on qemu, however
our qemu port isn't upstreamed yet, it can still be compiled. To do
so you will need to check this git repo [1] and follow the build
instructions.

To compile barebox for the KVX architecture there is a pre-built
toolchain that can be downloaded here [2]

The following commands should build an run barebox on qemu:
$ PATH=<path/to/gcc-kalray-kvx-v4.7.0-cd2>/bin:$PATH ARCH=kvx make generic_defconfig all
$ qemu-system-kvx -m 1G -nographic -kernel barebox

[1] https://github.com/kalray/qemu-builder
[2] https://github.com/kalray/build-scripts/releases/tag/v4.7.0-cd2

---

Changes in v2:
 - rebased on master
 - updated with Clement's new email address
 - droped two patches (the config and device-tree update) as there are
   not needed by qemu and the device-tree requires drivers not upstreamed
   yet.
 - small fixup on the nvmem driver

Clement Leger (6):
  common: elf: add elf_load_binary
  kvx: enable FITIMAGE support
  nvmem: add kvx otp non volatile regbank support
  kvx: add kvx_sfr_field_val
  drivers: add soc hierarchy properly
  soc: add kvx_socinfo driver

Jules Maselbas (4):
  kvx: dma: Remove arch dma_map/unmap_single
  kvx: Move LINUX_BOOT_PARAM_MAGIC in asm/common.h
  kvx: Accept LINUX_BOOT_PARAM_MAGIC as a valid magic value
  clocksource: kvx: Register as postcore_platform_driver

Louis Morhet (1):
  watchdog: kvx: do not disable watchdog on probe

 arch/kvx/Kconfig                |   1 +
 arch/kvx/cpu/cpu.c              |   2 +-
 arch/kvx/include/asm/bootm.h    |  11 ---
 arch/kvx/include/asm/common.h   |   3 +-
 arch/kvx/include/asm/sfr.h      |   4 +
 arch/kvx/lib/bootm.c            |  33 +++++++-
 arch/kvx/lib/dma-default.c      |  38 ---------
 common/elf.c                    |  83 ++++++++++++++-----
 drivers/Kconfig                 |   2 +-
 drivers/clocksource/kvx_timer.c |   2 +-
 drivers/nvmem/Kconfig           |   7 ++
 drivers/nvmem/Makefile          |   3 +
 drivers/nvmem/kvx-otp-nv.c      |  98 ++++++++++++++++++++++
 drivers/soc/Kconfig             |   6 ++
 drivers/soc/Makefile            |   1 +
 drivers/soc/kvx/Kconfig         |  10 +++
 drivers/soc/kvx/Makefile        |   1 +
 drivers/soc/kvx/kvx_socinfo.c   | 141 ++++++++++++++++++++++++++++++++
 drivers/watchdog/kvx_wdt.c      |   4 +-
 include/elf.h                   |   1 +
 20 files changed, 371 insertions(+), 80 deletions(-)
 delete mode 100644 arch/kvx/include/asm/bootm.h
 create mode 100644 drivers/nvmem/kvx-otp-nv.c
 create mode 100644 drivers/soc/Kconfig
 create mode 100644 drivers/soc/kvx/Kconfig
 create mode 100644 drivers/soc/kvx/Makefile
 create mode 100644 drivers/soc/kvx/kvx_socinfo.c

-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* [PATCH v2 01/11] kvx: dma: Remove arch dma_map/unmap_single
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
@ 2022-01-17 22:19 ` Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 02/11] kvx: Move LINUX_BOOT_PARAM_MAGIC in asm/common.h Jules Maselbas
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

Since dma_map/unmap_single functions have been moved to common, barebox
doesn't compile for kvx anymore. The original functions were doing some
magic to support 32bits dma buffer addresses. The original behavior can
be replaced by a device-tree dma-range property.

Fixes: 3f975f810 ("dma: move dma_map/unmap_single from ARM to common code")
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 arch/kvx/lib/dma-default.c | 38 --------------------------------------
 1 file changed, 38 deletions(-)

diff --git a/arch/kvx/lib/dma-default.c b/arch/kvx/lib/dma-default.c
index 2a4144696c..c84a32954e 100644
--- a/arch/kvx/lib/dma-default.c
+++ b/arch/kvx/lib/dma-default.c
@@ -54,41 +54,3 @@ void dma_sync_single_for_cpu(dma_addr_t addr, size_t size,
 		BUG();
 	}
 }
-
-#define KVX_DDR_ALIAS_OFFSET \
-	(KVX_DDR_64BIT_RAM_WINDOW_BA - KVX_DDR_32BIT_RAM_WINDOW_BA)
-#define KVX_DDR_ALIAS_WINDOW \
-	(KVX_DDR_64BIT_RAM_WINDOW_BA + KVX_DDR_ALIAS_OFFSET)
-
-/* Local smem is aliased between 0 and 16MB */
-#define KVX_SMEM_LOCAL_ALIAS 0x1000000ULL
-
-dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
-			  enum dma_data_direction dir)
-{
-	uintptr_t addr = (uintptr_t) ptr;
-
-	dma_sync_single_for_device(addr, size, dir);
-
-	/* Local smem alias should never be used for dma */
-	if (addr < KVX_SMEM_LOCAL_ALIAS)
-		return addr + (1 + kvx_cluster_id()) * KVX_SMEM_LOCAL_ALIAS;
-
-	if (dev->dma_mask && addr <= dev->dma_mask)
-		return addr;
-
-	if (addr >= KVX_DDR_ALIAS_WINDOW)
-		return DMA_ERROR_CODE;
-
-	addr -= KVX_DDR_ALIAS_OFFSET;
-	if (dev->dma_mask && addr > dev->dma_mask)
-		return DMA_ERROR_CODE;
-
-	return addr;
-}
-
-void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
-		      enum dma_data_direction dir)
-{
-	dma_sync_single_for_cpu(addr, size, dir);
-}
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* [PATCH v2 02/11] kvx: Move LINUX_BOOT_PARAM_MAGIC in asm/common.h
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 01/11] kvx: dma: Remove arch dma_map/unmap_single Jules Maselbas
@ 2022-01-17 22:19 ` Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 03/11] kvx: Accept LINUX_BOOT_PARAM_MAGIC as a valid magic value Jules Maselbas
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

Declare both defines FSBL_PARAM_MAGIC and LINUX_BOOT_PARAM_MAGIC in the
same header file, as they both have a very similar uses and value.

Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 arch/kvx/include/asm/bootm.h  | 11 -----------
 arch/kvx/include/asm/common.h |  3 ++-
 arch/kvx/lib/bootm.c          |  1 -
 3 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 arch/kvx/include/asm/bootm.h

diff --git a/arch/kvx/include/asm/bootm.h b/arch/kvx/include/asm/bootm.h
deleted file mode 100644
index 7ad7e2e878..0000000000
--- a/arch/kvx/include/asm/bootm.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2019 Kalray Inc.
- */
-
-#ifndef _ASM_KVX_BOOTM_H
-#define _ASM_KVX_BOOTM_H
-
-#define LINUX_BOOT_PARAM_MAGIC 0x31564752414E494CULL
-
-#endif /* _ASM_KVX_BOOTM_H */
diff --git a/arch/kvx/include/asm/common.h b/arch/kvx/include/asm/common.h
index a7e301e53a..754953962b 100644
--- a/arch/kvx/include/asm/common.h
+++ b/arch/kvx/include/asm/common.h
@@ -12,7 +12,8 @@
  * Magic value passed in r0 to indicate valid parameters from FSBL when booting
  * If $r0 contains this value, then $r1 contains dtb pointer.
  */
-#define FSBL_PARAM_MAGIC	0x31564752414C414BULL
+#define FSBL_PARAM_MAGIC	0x31564752414C414BULL /* KALARGV1 */
+#define LINUX_BOOT_PARAM_MAGIC	0x31564752414E494CULL /* LINARGV1 */
 
 extern char _exception_start;
 extern char __end;
diff --git a/arch/kvx/lib/bootm.c b/arch/kvx/lib/bootm.c
index 4d17e1846d..3e9772c458 100644
--- a/arch/kvx/lib/bootm.c
+++ b/arch/kvx/lib/bootm.c
@@ -17,7 +17,6 @@
 #include <linux/kernel.h>
 
 #include <asm/cache.h>
-#include <asm/bootm.h>
 
 typedef void __noreturn (*boot_func_entry)(unsigned long, void *);
 
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* [PATCH v2 03/11] kvx: Accept LINUX_BOOT_PARAM_MAGIC as a valid magic value
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 01/11] kvx: dma: Remove arch dma_map/unmap_single Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 02/11] kvx: Move LINUX_BOOT_PARAM_MAGIC in asm/common.h Jules Maselbas
@ 2022-01-17 22:19 ` Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 04/11] common: elf: add elf_load_binary Jules Maselbas
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

Both defines FSBL_PARAM_MAGIC and LINUX_BOOT_PARAM_MAGIC have a similar
uses and yet have different values. Making barebox accept both as valid
magic boot param will make it possible to use qemu-system-kvx to boot a
barebox image as a normal kernel.

Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 arch/kvx/cpu/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/kvx/cpu/cpu.c b/arch/kvx/cpu/cpu.c
index 788d3194fe..4b0d4d2d96 100644
--- a/arch/kvx/cpu/cpu.c
+++ b/arch/kvx/cpu/cpu.c
@@ -16,7 +16,7 @@ void kvx_lowlevel_setup(unsigned long r0, void *dtb_ptr)
 {
 	uint64_t ev_val = (uint64_t) &_exception_start | EXCEPTION_STRIDE;
 
-	if (r0 == FSBL_PARAM_MAGIC) {
+	if (r0 == FSBL_PARAM_MAGIC || r0 == LINUX_BOOT_PARAM_MAGIC) {
 		boot_dtb = dtb_ptr;
 		pr_info("Using DTB provided by FSBL\n");
 	}
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* [PATCH v2 04/11] common: elf: add elf_load_binary
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
                   ` (2 preceding siblings ...)
  2022-01-17 22:19 ` [PATCH v2 03/11] kvx: Accept LINUX_BOOT_PARAM_MAGIC as a valid magic value Jules Maselbas
@ 2022-01-17 22:19 ` Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 05/11] kvx: enable FITIMAGE support Jules Maselbas
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

From: Clement Leger <clement.leger@bootlin.com>

In order to load elf from a binary buffer, add elf_load_binary. This
will be used by FIT support to allow loading an elf from FIT.

Signed-off-by: Clement Leger <clement.leger@bootlin.com>
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 common/elf.c  | 83 +++++++++++++++++++++++++++++++++++++--------------
 include/elf.h |  1 +
 2 files changed, 62 insertions(+), 22 deletions(-)

diff --git a/common/elf.c b/common/elf.c
index af22be37e6..f10fb77953 100644
--- a/common/elf.c
+++ b/common/elf.c
@@ -101,15 +101,17 @@ static int elf_section_cmp(void *priv, struct list_head *a, struct list_head *b)
 static int load_elf_to_memory(struct elf_image *elf)
 {
 	void *dst;
-	int ret, fd;
+	int ret, fd = -1;
 	u64 p_filesz, p_memsz, p_offset;
 	struct elf_section *r;
 	struct list_head *list = &elf->list;
 
-	fd = open(elf->filename, O_RDONLY);
-	if (fd < 0) {
-		pr_err("could not open: %s\n", errno_str());
-		return -errno;
+	if (elf->filename) {
+		fd = open(elf->filename, O_RDONLY);
+		if (fd < 0) {
+			pr_err("could not open: %s\n", errno_str());
+			return -errno;
+		}
 	}
 
 	list_for_each_entry(r, list, list) {
@@ -118,21 +120,26 @@ static int load_elf_to_memory(struct elf_image *elf)
 		p_memsz = elf_phdr_p_memsz(elf, r->phdr);
 		dst = (void *) (phys_addr_t) elf_phdr_p_paddr(elf, r->phdr);
 
-		ret = lseek(fd, p_offset, SEEK_SET);
-		if (ret == -1) {
-			pr_err("lseek at offset 0x%llx failed\n", p_offset);
-			close(fd);
-			return ret;
-		}
-
 		pr_debug("Loading phdr offset 0x%llx to 0x%p (%llu bytes)\n",
 			 p_offset, dst, p_filesz);
 
-		if (read_full(fd, dst, p_filesz) < 0) {
-			pr_err("could not read elf segment: %s\n",
-			       errno_str());
-			close(fd);
-			return -errno;
+		if (fd >= 0) {
+			ret = lseek(fd, p_offset, SEEK_SET);
+			if (ret == -1) {
+				pr_err("lseek at offset 0x%llx failed\n",
+				       p_offset);
+				close(fd);
+				return ret;
+			}
+
+			if (read_full(fd, dst, p_filesz) < 0) {
+				pr_err("could not read elf segment: %s\n",
+				       errno_str());
+				close(fd);
+				return -errno;
+			}
+		} else {
+			memcpy(dst, elf->hdr_buf + p_offset, p_filesz);
 		}
 
 		if (p_filesz < p_memsz)
@@ -202,6 +209,37 @@ static int elf_check_image(struct elf_image *elf, void *buf)
 	return 0;
 }
 
+static void elf_init_struct(struct elf_image *elf)
+{
+	INIT_LIST_HEAD(&elf->list);
+	elf->low_addr = (void *) (unsigned long) -1;
+	elf->high_addr = 0;
+	elf->filename = NULL;
+}
+
+struct elf_image *elf_open_binary(void *buf)
+{
+	int ret;
+	struct elf_image *elf;
+
+	elf = calloc(1, sizeof(*elf));
+	if (!elf)
+		return ERR_PTR(-ENOMEM);
+
+	elf_init_struct(elf);
+
+	elf->hdr_buf = buf;
+	ret = elf_check_image(elf, buf);
+	if (ret) {
+		free(elf);
+		return ERR_PTR(-EINVAL);
+	}
+
+	elf->entry = elf_hdr_e_entry(elf, elf->hdr_buf);
+
+	return elf;
+}
+
 static struct elf_image *elf_check_init(const char *filename)
 {
 	int ret, fd;
@@ -213,9 +251,7 @@ static struct elf_image *elf_check_init(const char *filename)
 	if (!elf)
 		return ERR_PTR(-ENOMEM);
 
-	INIT_LIST_HEAD(&elf->list);
-	elf->low_addr = (void *) (unsigned long) -1;
-	elf->high_addr = 0;
+	elf_init_struct(elf);
 
 	/* First pass is to read elf header only */
 	fd = open(filename, O_RDONLY);
@@ -299,7 +335,10 @@ void elf_close(struct elf_image *elf)
 {
 	elf_release_regions(elf);
 
-	free(elf->hdr_buf);
-	free(elf->filename);
+	if (elf->filename) {
+		free(elf->hdr_buf);
+		free(elf->filename);
+	}
+
 	free(elf);
 }
diff --git a/include/elf.h b/include/elf.h
index 7970fd2c95..12673e93ed 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -414,6 +414,7 @@ static inline size_t elf_get_mem_size(struct elf_image *elf)
 	return elf->high_addr - elf->low_addr;
 }
 
+struct elf_image *elf_open_binary(void *buf);
 struct elf_image *elf_open(const char *filename);
 void elf_close(struct elf_image *elf);
 int elf_load(struct elf_image *elf);
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* [PATCH v2 05/11] kvx: enable FITIMAGE support
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
                   ` (3 preceding siblings ...)
  2022-01-17 22:19 ` [PATCH v2 04/11] common: elf: add elf_load_binary Jules Maselbas
@ 2022-01-17 22:19 ` Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 06/11] clocksource: kvx: Register as postcore_platform_driver Jules Maselbas
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

From: Clement Leger <clement.leger@bootlin.com>

Enable FITIMAGE support in kvx defconfig and add code to handle fit boot
from bootm command. This is rather a simple addition and it allow to boot
a fit image containing an ELF file as the kernel.

Signed-off-by: Clement Leger <clement.leger@bootlin.com>
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 arch/kvx/Kconfig     |  1 +
 arch/kvx/lib/bootm.c | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/kvx/Kconfig b/arch/kvx/Kconfig
index 0934440880..100a945761 100644
--- a/arch/kvx/Kconfig
+++ b/arch/kvx/Kconfig
@@ -10,6 +10,7 @@ config KVX
 	select COMMON_CLK_OF_PROVIDER
 	select ELF
 	select FLEXIBLE_BOOTARGS
+	select FITIMAGE
 	select GENERIC_FIND_NEXT_BIT
 	select HAS_ARCH_SJLJ
 	select HAS_CACHE
diff --git a/arch/kvx/lib/bootm.c b/arch/kvx/lib/bootm.c
index 3e9772c458..4c77f676ec 100644
--- a/arch/kvx/lib/bootm.c
+++ b/arch/kvx/lib/bootm.c
@@ -94,7 +94,7 @@ static int do_boot_elf(struct image_data *data, struct elf_image *elf)
 		goto err_free_fdt;
 	}
 
-	entry = (boot_func_entry) data->os_address;
+	entry = (boot_func_entry) elf->entry;
 
 	ret = do_boot_entry(data, entry, fdt);
 
@@ -104,6 +104,27 @@ err_free_fdt:
 	return ret;
 }
 
+static int do_bootm_fit(struct image_data *data)
+{
+	int ret;
+	struct elf_image *elf;
+
+	elf = elf_open_binary((void *) data->fit_kernel);
+	if (IS_ERR(elf))
+		return PTR_ERR(data->elf);
+
+	ret = elf_load(elf);
+	if (ret)
+		goto close_elf;
+
+	ret = do_boot_elf(data, elf);
+
+close_elf:
+	elf_close(elf);
+
+	return ret;
+}
+
 static int do_bootm_elf(struct image_data *data)
 {
 	int ret;
@@ -121,6 +142,12 @@ static struct image_handler elf_handler = {
 	.filetype = filetype_elf,
 };
 
+static struct image_handler fit_handler = {
+	.name = "FIT",
+	.bootm = do_bootm_fit,
+	.filetype = filetype_oftree,
+};
+
 static struct binfmt_hook binfmt_elf_hook = {
 	.type = filetype_elf,
 	.exec = "bootm",
@@ -130,6 +157,9 @@ static int kvx_register_image_handler(void)
 {
 	register_image_handler(&elf_handler);
 
+	if (IS_ENABLED(CONFIG_FITIMAGE))
+		register_image_handler(&fit_handler);
+
 	binfmt_register(&binfmt_elf_hook);
 
 	return 0;
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* [PATCH v2 06/11] clocksource: kvx: Register as postcore_platform_driver
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
                   ` (4 preceding siblings ...)
  2022-01-17 22:19 ` [PATCH v2 05/11] kvx: enable FITIMAGE support Jules Maselbas
@ 2022-01-17 22:19 ` Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 07/11] watchdog: kvx: do not disable watchdog on probe Jules Maselbas
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

Register the kvx clocksource driver sooner, before probing other device
drivers by using the postcore_platform_driver macro. That way the other
drivers will have a correct timestamp when printing messages.

Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 drivers/clocksource/kvx_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/kvx_timer.c b/drivers/clocksource/kvx_timer.c
index 4125ddbee0..2a05d8deed 100644
--- a/drivers/clocksource/kvx_timer.c
+++ b/drivers/clocksource/kvx_timer.c
@@ -55,4 +55,4 @@ static struct driver_d kvx_timer_driver = {
 	.of_compatible = DRV_OF_COMPAT(kvx_timer_dt_ids),
 };
 
-device_platform_driver(kvx_timer_driver);
+postcore_platform_driver(kvx_timer_driver);
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* [PATCH v2 07/11] watchdog: kvx: do not disable watchdog on probe
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
                   ` (5 preceding siblings ...)
  2022-01-17 22:19 ` [PATCH v2 06/11] clocksource: kvx: Register as postcore_platform_driver Jules Maselbas
@ 2022-01-17 22:19 ` Jules Maselbas
  2022-01-19 14:25   ` Ahmad Fatoum
  2022-01-17 22:19 ` [PATCH v2 08/11] nvmem: add kvx otp non volatile regbank support Jules Maselbas
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

From: Louis Morhet <lmorhet@kalray.eu>

As the watchdog may be set by a lower stage in the boot chain, and for
a good reason (precisely to ensure reliable update when something
unexpected happens during the boot chain), it is a bad idea to always
disable it during probe.

We should either have a mechanism to refresh it on a regular basis in
barebox itself and set it to something bigger for Linux, or handle it
transparently and let the previous stage set the global watchdog up to
Linux. This patch assumes for now the latter.

Signed-off-by: Louis Morhet <lmorhet@kalray.eu>
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 drivers/watchdog/kvx_wdt.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/watchdog/kvx_wdt.c b/drivers/watchdog/kvx_wdt.c
index da19136fda..df9430769b 100644
--- a/drivers/watchdog/kvx_wdt.c
+++ b/drivers/watchdog/kvx_wdt.c
@@ -73,11 +73,9 @@ static int kvx_wdt_drv_probe(struct device_d *dev)
 	wdd->hwdev = dev;
 	wdd->set_timeout = kvx_wdt_set_timeout;
 
-	/* Be sure that interrupt are disable */
+	/* Be sure that interrupt are disabled */
 	kvx_sfr_set_field(TCR, WIE, 0);
 
-	kvx_watchdog_disable();
-
 	return watchdog_register(wdd);
 }
 
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* [PATCH v2 08/11] nvmem: add kvx otp non volatile regbank support
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
                   ` (6 preceding siblings ...)
  2022-01-17 22:19 ` [PATCH v2 07/11] watchdog: kvx: do not disable watchdog on probe Jules Maselbas
@ 2022-01-17 22:19 ` Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 09/11] kvx: add kvx_sfr_field_val Jules Maselbas
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

From: Clement Leger <clement.leger@bootlin.com>

Backport Linux driver to barebox to access nvmem.

Signed-off-by: Clement Leger <clement.leger@bootlin.com>
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
changes in v2:
 - removed if (allways set skip to 0 after the memcopy)
---
 drivers/nvmem/Kconfig      |  7 +++
 drivers/nvmem/Makefile     |  3 ++
 drivers/nvmem/kvx-otp-nv.c | 98 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 108 insertions(+)
 create mode 100644 drivers/nvmem/kvx-otp-nv.c

diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index 7b1ebe1d68..2e60734156 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -76,6 +76,13 @@ config STM32_BSEC_WRITE
 	    mw -l -d /dev/stm32-bsec 0x000000e4+4 0x78563412
 	    mw -l -d /dev/stm32-bsec 0x000000e8+4 0x0000bc9a
 
+config KVX_OTP_NV
+	tristate "kalray KVX OTP Non volatile regs Support"
+	depends on KVX
+	help
+	  This is a simple driver to dump specified values of KVX OTP non
+	  volatile regs.
+
 config STARFIVE_OTP
 	tristate "Starfive OTP Supprot"
 	depends on SOC_STARFIVE
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index 5865919612..62a1f925dd 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -24,4 +24,7 @@ nvmem_eeprom_93xx46-y		:= eeprom_93xx46.o
 obj-$(CONFIG_STM32_BSEC)	+= nvmem_bsec.o
 nvmem_bsec-y			:= bsec.o
 
+obj-$(CONFIG_KVX_OTP_NV)	+= nvmem-kvx-otp-nv.o
+nvmem-kvx-otp-nv-y		:= kvx-otp-nv.o
+
 obj-$(CONFIG_STARFIVE_OTP)	+= starfive-otp.o
diff --git a/drivers/nvmem/kvx-otp-nv.c b/drivers/nvmem/kvx-otp-nv.c
new file mode 100644
index 0000000000..d614c16e1e
--- /dev/null
+++ b/drivers/nvmem/kvx-otp-nv.c
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2020 Kalray Inc., Clément Léger
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <malloc.h>
+#include <xfuncs.h>
+#include <errno.h>
+#include <init.h>
+#include <net.h>
+#include <io.h>
+
+#include <linux/nvmem-provider.h>
+
+#define OTP_NV_ALIGN		4
+#define OTP_NV_ALIGN_MASK	(OTP_NV_ALIGN - 1)
+
+struct kvx_otp_nv_priv {
+	void __iomem *base;
+};
+
+static int kvx_otp_nv_read(void *context, unsigned int offset,
+			  void *_val, size_t bytes)
+{
+	struct kvx_otp_nv_priv *priv = context;
+	u8 *val = _val;
+	u32 tmp, copy_size;
+	u8 skip = offset & OTP_NV_ALIGN_MASK;
+
+	offset &= ~OTP_NV_ALIGN_MASK;
+
+	while (bytes) {
+		tmp = readl(priv->base + offset);
+		if (skip != 0)
+			copy_size = min(OTP_NV_ALIGN - skip, (int) bytes);
+		else
+			copy_size = min(bytes, sizeof(tmp));
+
+		memcpy(val, ((u8 *) &tmp) + skip, copy_size);
+		skip = 0;
+
+		bytes -= copy_size;
+		val += copy_size;
+		offset += OTP_NV_ALIGN;
+	}
+
+	return 0;
+}
+
+static const struct nvmem_bus kvx_otp_nv_bus = {
+	.read = kvx_otp_nv_read,
+};
+
+static const struct of_device_id kvx_otp_nv_match[] = {
+	{ .compatible = "kalray,kvx-otp-nv" },
+	{ /* sentinel */},
+};
+
+static int kvx_otp_nv_probe(struct device_d *dev)
+{
+	struct resource *res;
+	struct nvmem_device *nvmem;
+	struct nvmem_config econfig = { 0 };
+	struct kvx_otp_nv_priv *priv;
+
+	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	res = dev_request_mem_resource(dev, 0);
+	if (IS_ERR(res))
+		return PTR_ERR(res);
+
+	priv->base = IOMEM(res->start);
+
+	econfig.name = "kvx-nv-regbank";
+	econfig.stride = 1;
+	econfig.word_size = 1;
+	econfig.size = resource_size(res);
+	econfig.dev = dev;
+	econfig.priv = priv;
+	econfig.bus = &kvx_otp_nv_bus;
+
+	dev->priv = priv;
+
+	nvmem = nvmem_register(&econfig);
+
+	return PTR_ERR_OR_ZERO(nvmem);
+}
+
+static struct driver_d kvx_otp_nv_driver = {
+	.name	= "kvx-otp-nv",
+	.probe	= kvx_otp_nv_probe,
+	.of_compatible = DRV_OF_COMPAT(kvx_otp_nv_match),
+};
+postcore_platform_driver(kvx_otp_nv_driver);
-- 
2.17.1






_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 09/11] kvx: add kvx_sfr_field_val
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
                   ` (7 preceding siblings ...)
  2022-01-17 22:19 ` [PATCH v2 08/11] nvmem: add kvx otp non volatile regbank support Jules Maselbas
@ 2022-01-17 22:19 ` Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 10/11] drivers: add soc hierarchy properly Jules Maselbas
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

From: Clement Leger <clement.leger@bootlin.com>

Add this macro for upcoming socinfo driver. This extract a sfr field
using only its name.

Signed-off-by: Clement Leger <clement.leger@bootlin.com>
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 arch/kvx/include/asm/sfr.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/kvx/include/asm/sfr.h b/arch/kvx/include/asm/sfr.h
index 5b93cee345..89ff64bbdc 100644
--- a/arch/kvx/include/asm/sfr.h
+++ b/arch/kvx/include/asm/sfr.h
@@ -44,4 +44,8 @@ kvx_sfr_set_mask(unsigned char sfr, uint64_t mask, uint64_t value)
 #define kvx_sfr_set(_sfr, _val)	__builtin_kvx_set(KVX_SFR_ ## _sfr, _val)
 #define kvx_sfr_get(_sfr)	__builtin_kvx_get(KVX_SFR_ ## _sfr)
 
+#define kvx_sfr_field_val(_val, _sfr, _field) \
+			  (((_val) & KVX_SFR_ ## _sfr ## _ ## _field ## _MASK) \
+			  >> KVX_SFR_ ## _sfr ## _ ## _field ## _SHIFT)
+
 #endif	/* _ASM_KVX_SFR_DEFS_H */
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* [PATCH v2 10/11] drivers: add soc hierarchy properly
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
                   ` (8 preceding siblings ...)
  2022-01-17 22:19 ` [PATCH v2 09/11] kvx: add kvx_sfr_field_val Jules Maselbas
@ 2022-01-17 22:19 ` Jules Maselbas
  2022-01-17 22:19 ` [PATCH v2 11/11] soc: add kvx_socinfo driver Jules Maselbas
  2022-01-18  8:09 ` [PATCH v2 00/11] kvx arch update Sascha Hauer
  11 siblings, 0 replies; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

From: Clement Leger <clement.leger@bootlin.com>

We will add kvx driver in this folder to create a proper hierarchy.

Signed-off-by: Clement Leger <clement.leger@bootlin.com>
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 drivers/Kconfig     | 2 +-
 drivers/soc/Kconfig | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/Kconfig

diff --git a/drivers/Kconfig b/drivers/Kconfig
index 01b659b02c..2636eed1a3 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -41,7 +41,7 @@ source "drivers/fpga/Kconfig"
 source "drivers/phy/Kconfig"
 source "drivers/crypto/Kconfig"
 source "drivers/memory/Kconfig"
-source "drivers/soc/imx/Kconfig"
+source "drivers/soc/Kconfig"
 source "drivers/nvme/Kconfig"
 source "drivers/ddr/Kconfig"
 source "drivers/power/Kconfig"
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
new file mode 100644
index 0000000000..d78f13f3f8
--- /dev/null
+++ b/drivers/soc/Kconfig
@@ -0,0 +1,5 @@
+menu "SoC drivers"
+
+source "drivers/soc/imx/Kconfig"
+
+endmenu
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* [PATCH v2 11/11] soc: add kvx_socinfo driver
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
                   ` (9 preceding siblings ...)
  2022-01-17 22:19 ` [PATCH v2 10/11] drivers: add soc hierarchy properly Jules Maselbas
@ 2022-01-17 22:19 ` Jules Maselbas
  2022-01-18  8:09 ` [PATCH v2 00/11] kvx arch update Sascha Hauer
  11 siblings, 0 replies; 14+ messages in thread
From: Jules Maselbas @ 2022-01-17 22:19 UTC (permalink / raw)
  To: barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau, Jules Maselbas

From: Clement Leger <clement.leger@bootlin.com>

This driver uses various source (sfr, nvmem) to determine the mppa_id
and the architecture revision. These are then exported using global
variables which are:
- global.kvx.arch_rev: Architecture revision (kv3-1 for instance)
- global.kvx.mppa_id: Unique chip id, composed of lot and wafer id

Signed-off-by: Clement Leger <clement.leger@bootlin.com>
Co-developed-by: Jules Maselbas <jmaselbas@kalray.eu>
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 drivers/soc/Kconfig           |   1 +
 drivers/soc/Makefile          |   1 +
 drivers/soc/kvx/Kconfig       |  10 +++
 drivers/soc/kvx/Makefile      |   1 +
 drivers/soc/kvx/kvx_socinfo.c | 141 ++++++++++++++++++++++++++++++++++
 5 files changed, 154 insertions(+)
 create mode 100644 drivers/soc/kvx/Kconfig
 create mode 100644 drivers/soc/kvx/Makefile
 create mode 100644 drivers/soc/kvx/kvx_socinfo.c

diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index d78f13f3f8..54b69cc42e 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -1,5 +1,6 @@
 menu "SoC drivers"
 
 source "drivers/soc/imx/Kconfig"
+source "drivers/soc/kvx/Kconfig"
 
 endmenu
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index c4efb8f02f..e5b319e6da 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -3,3 +3,4 @@
 obj-y	+= imx/
 obj-$(CONFIG_CPU_SIFIVE)	+= sifive/
 obj-$(CONFIG_SOC_STARFIVE)	+= starfive/
+obj-$(CONFIG_KVX)	+= kvx/
diff --git a/drivers/soc/kvx/Kconfig b/drivers/soc/kvx/Kconfig
new file mode 100644
index 0000000000..18dcb8ba14
--- /dev/null
+++ b/drivers/soc/kvx/Kconfig
@@ -0,0 +1,10 @@
+menu "KVX SoC drivers"
+
+config KVX_SOCINFO
+        bool "KVX SoC Info driver"
+	depends on KVX
+	select NVMEM
+	select KVX_OTP_NV
+	default y
+
+endmenu
diff --git a/drivers/soc/kvx/Makefile b/drivers/soc/kvx/Makefile
new file mode 100644
index 0000000000..cacfef21a1
--- /dev/null
+++ b/drivers/soc/kvx/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_KVX_SOCINFO) += kvx_socinfo.o
diff --git a/drivers/soc/kvx/kvx_socinfo.c b/drivers/soc/kvx/kvx_socinfo.c
new file mode 100644
index 0000000000..100faae766
--- /dev/null
+++ b/drivers/soc/kvx/kvx_socinfo.c
@@ -0,0 +1,141 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2020 Kalray Inc., Clément Léger
+ */
+
+#define pr_fmt(fmt) "kvx_socinfo: " fmt
+
+#include <init.h>
+#include <driver.h>
+#include <globalvar.h>
+#include <magicvar.h>
+#include <command.h>
+#include <libfile.h>
+#include <getopt.h>
+#include <common.h>
+#include <fs.h>
+
+#include <asm/sfr.h>
+
+#include <linux/kernel.h>
+#include <linux/nvmem-consumer.h>
+
+#define LOT_ID_STR_LEN	8
+
+#define EWS_LOT_ID_MASK		0x1ffffffffffULL
+#define EWS_WAFER_ID_SHIFT	42
+#define EWS_WAFER_ID_MASK	0x1fULL
+
+#define FT_COM_AP_SHIFT		16
+#define FT_COM_AP_MASK		0x3f
+#define FT_DEVICE_ID_SHIFT	22
+#define FT_DEVICE_ID_MASK	0x1ff
+
+static char *kvx_mppa_id;
+static char *kvx_arch_rev;
+
+BAREBOX_MAGICVAR(kvx.arch_rev, "KVX architecture revision");
+BAREBOX_MAGICVAR(kvx.mppa_id, "KVX MPPA chip id");
+
+static void kvx_soc_info_read_revision(void)
+{
+	u64 pcr = kvx_sfr_get(PCR);
+	u8 sv = kvx_sfr_field_val(pcr, PCR, SV);
+	u8 car = kvx_sfr_field_val(pcr, PCR, CAR);
+	const char *car_str = "", *ver_str = "";
+
+	switch (car) {
+	case 0:
+		car_str = "kv3";
+		break;
+	}
+
+	switch (sv) {
+	case 0:
+		ver_str = "1";
+		break;
+	case 1:
+		ver_str = "2";
+		break;
+	}
+
+	kvx_arch_rev = basprintf("%s-%s", car_str, ver_str);
+
+	globalvar_add_simple_string("kvx.arch_rev", &kvx_arch_rev);
+}
+
+static int base38_decode(char *s, u64 val, int nb_char)
+{
+	int i;
+	const char *alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_?";
+	const int base = strlen(alphabet);
+
+	if (s == NULL)
+		return -1;
+
+	for (i = 0; i < nb_char; i++) {
+		s[i] = alphabet[val % base];
+		val /= base;
+	}
+
+	return 0;
+}
+
+static int kvx_read_serial(struct device_node *socinfo)
+{
+	char lot_id[LOT_ID_STR_LEN + 1] = "";
+	char com_ap;
+	u64 *cell_val64;
+	u64 ews_val;
+	u32 *cell_val32;
+	u32 ft_val;
+	u8 wafer_id;
+	u16 device_id;
+
+	cell_val64 = (u64 *) nvmem_cell_get_and_read(socinfo, "ews_fuse", 8);
+	if (IS_ERR(cell_val64)) {
+		pr_debug("Fail to read ews_fuse\n");
+		return PTR_ERR(cell_val64);
+	}
+
+	ews_val = *cell_val64;
+	ews_val = (ews_val >> 32) | (ews_val << 32);
+	wafer_id = (ews_val >> EWS_WAFER_ID_SHIFT) & EWS_WAFER_ID_MASK;
+	base38_decode(lot_id, ews_val & EWS_LOT_ID_MASK, LOT_ID_STR_LEN);
+
+	cell_val32 = (u32 *) nvmem_cell_get_and_read(socinfo, "ft_fuse", 4);
+	if (IS_ERR(cell_val32)) {
+		pr_debug("Fail to read ft_fuse\n");
+		return PTR_ERR(cell_val32);
+	}
+
+	ft_val = *cell_val32;
+	device_id = (ft_val >> FT_DEVICE_ID_SHIFT) & FT_DEVICE_ID_MASK;
+	base38_decode(&com_ap, (ft_val >> FT_COM_AP_SHIFT) & FT_COM_AP_MASK, 1);
+
+	kvx_mppa_id = basprintf("%sA-%d%c-%03d", lot_id, wafer_id, com_ap,
+			       device_id);
+
+	globalvar_add_simple_string("kvx.mppa_id", &kvx_mppa_id);
+
+	return 0;
+}
+
+static int kvx_socinfo_probe(struct device_d *dev)
+{
+	kvx_soc_info_read_revision();
+
+	return kvx_read_serial(dev->device_node);
+}
+
+static const struct of_device_id kvx_socinfo_dt_ids[] = {
+	{ .compatible = "kalray,kvx-socinfo" },
+	{ }
+};
+
+static struct driver_d kvx_socinfo_driver = {
+	.name = "kvx-socinfo",
+	.probe = kvx_socinfo_probe,
+	.of_compatible = DRV_OF_COMPAT(kvx_socinfo_dt_ids),
+};
+coredevice_platform_driver(kvx_socinfo_driver);
-- 
2.17.1






_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v2 00/11] kvx arch update
  2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
                   ` (10 preceding siblings ...)
  2022-01-17 22:19 ` [PATCH v2 11/11] soc: add kvx_socinfo driver Jules Maselbas
@ 2022-01-18  8:09 ` Sascha Hauer
  11 siblings, 0 replies; 14+ messages in thread
From: Sascha Hauer @ 2022-01-18  8:09 UTC (permalink / raw)
  To: Jules Maselbas
  Cc: barebox, Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau

On Mon, Jan 17, 2022 at 11:19:06PM +0100, Jules Maselbas wrote:
> This series has updates for the KVX architecture, with some fixes and
> with the addition of kvx specific drivers for the otp-nvmem and socinfo.
> 
> With this series it is now possible to run barebox on qemu, however
> our qemu port isn't upstreamed yet, it can still be compiled. To do
> so you will need to check this git repo [1] and follow the build
> instructions.
> 
> To compile barebox for the KVX architecture there is a pre-built
> toolchain that can be downloaded here [2]
> 
> The following commands should build an run barebox on qemu:
> $ PATH=<path/to/gcc-kalray-kvx-v4.7.0-cd2>/bin:$PATH ARCH=kvx make generic_defconfig all
> $ qemu-system-kvx -m 1G -nographic -kernel barebox
> 
> [1] https://github.com/kalray/qemu-builder
> [2] https://github.com/kalray/build-scripts/releases/tag/v4.7.0-cd2

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* Re: [PATCH v2 07/11] watchdog: kvx: do not disable watchdog on probe
  2022-01-17 22:19 ` [PATCH v2 07/11] watchdog: kvx: do not disable watchdog on probe Jules Maselbas
@ 2022-01-19 14:25   ` Ahmad Fatoum
  0 siblings, 0 replies; 14+ messages in thread
From: Ahmad Fatoum @ 2022-01-19 14:25 UTC (permalink / raw)
  To: Jules Maselbas, barebox
  Cc: Clement Leger, Louis Morhet, Luc Michel, Yann Sionneau

Hi,

On 17.01.22 23:19, Jules Maselbas wrote:
> From: Louis Morhet <lmorhet@kalray.eu>
> 
> As the watchdog may be set by a lower stage in the boot chain, and for
> a good reason (precisely to ensure reliable update when something
> unexpected happens during the boot chain), it is a bad idea to always
> disable it during probe.
> 
> We should either have a mechanism to refresh it on a regular basis in
> barebox itself and set it to something bigger for Linux, or handle it
> transparently and let the previous stage set the global watchdog up to
> Linux. This patch assumes for now the latter.

The latter is preferable, because barebox execution time should be bound
and the watchdog ensures that in face of spurious bugs.

There's an autopoll mechanism that tries to ensure forward progress by
polling the watchdog in is_timeout. The idea is that loops checking for
is_timeout will either see forward progress or propagate an error. This
is more robust than explicitly littering around WATCHDOG_PING()s, but it's
not immune to all bugs, so turning on the watchdog very early is IMO
the best course of action. For development use, you can always do wd 0
or wd -x which I just sent out and CC'd you on. wd -x will disable
all watchdogs either by wd 0 if supported by the hardware and driver
or by enabling autopolling.

It's a strict development feature (like wd in general. There's
global.boot.watchdog_timeout for normal use during booting).

> Signed-off-by: Louis Morhet <lmorhet@kalray.eu>
> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>

For this patch,

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Cheers,
Ahmad

> ---
>  drivers/watchdog/kvx_wdt.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/watchdog/kvx_wdt.c b/drivers/watchdog/kvx_wdt.c
> index da19136fda..df9430769b 100644
> --- a/drivers/watchdog/kvx_wdt.c
> +++ b/drivers/watchdog/kvx_wdt.c
> @@ -73,11 +73,9 @@ static int kvx_wdt_drv_probe(struct device_d *dev)
>  	wdd->hwdev = dev;
>  	wdd->set_timeout = kvx_wdt_set_timeout;
>  
> -	/* Be sure that interrupt are disable */
> +	/* Be sure that interrupt are disabled */
>  	kvx_sfr_set_field(TCR, WIE, 0);
>  
> -	kvx_watchdog_disable();
> -
>  	return watchdog_register(wdd);
>  }
>  
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

end of thread, other threads:[~2022-01-19 14:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17 22:19 [PATCH v2 00/11] kvx arch update Jules Maselbas
2022-01-17 22:19 ` [PATCH v2 01/11] kvx: dma: Remove arch dma_map/unmap_single Jules Maselbas
2022-01-17 22:19 ` [PATCH v2 02/11] kvx: Move LINUX_BOOT_PARAM_MAGIC in asm/common.h Jules Maselbas
2022-01-17 22:19 ` [PATCH v2 03/11] kvx: Accept LINUX_BOOT_PARAM_MAGIC as a valid magic value Jules Maselbas
2022-01-17 22:19 ` [PATCH v2 04/11] common: elf: add elf_load_binary Jules Maselbas
2022-01-17 22:19 ` [PATCH v2 05/11] kvx: enable FITIMAGE support Jules Maselbas
2022-01-17 22:19 ` [PATCH v2 06/11] clocksource: kvx: Register as postcore_platform_driver Jules Maselbas
2022-01-17 22:19 ` [PATCH v2 07/11] watchdog: kvx: do not disable watchdog on probe Jules Maselbas
2022-01-19 14:25   ` Ahmad Fatoum
2022-01-17 22:19 ` [PATCH v2 08/11] nvmem: add kvx otp non volatile regbank support Jules Maselbas
2022-01-17 22:19 ` [PATCH v2 09/11] kvx: add kvx_sfr_field_val Jules Maselbas
2022-01-17 22:19 ` [PATCH v2 10/11] drivers: add soc hierarchy properly Jules Maselbas
2022-01-17 22:19 ` [PATCH v2 11/11] soc: add kvx_socinfo driver Jules Maselbas
2022-01-18  8:09 ` [PATCH v2 00/11] kvx arch update Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox