From 1a99eb52dc78bbb3069fbe3fd270ebdab33111fe Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Mon, 24 Nov 2025 15:59:09 -0600 Subject: [PATCH] bsps/shared/xnandpsu: Parameterize number of active chipselects This makes the number of active chipselects a BSP configuration parameter. The name of the macro in upstream source is misleading and suggests that the driver can support up to the selected value when in actuality it requires that number of chips to be present. If this number of chips is not present, the driver will hang on initialization waiting for a chip to respond that does not exist. --- bsps/include/dev/nand/xnandpsu.h | 2 +- spec/build/bsps/objnandpsu.yml | 4 +++- spec/build/bsps/optnandpsuchips.yml | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 spec/build/bsps/optnandpsuchips.yml diff --git a/bsps/include/dev/nand/xnandpsu.h b/bsps/include/dev/nand/xnandpsu.h index e311bb155b..c0655f9ef6 100644 --- a/bsps/include/dev/nand/xnandpsu.h +++ b/bsps/include/dev/nand/xnandpsu.h @@ -189,7 +189,7 @@ extern "C" { #define XNANDPSU_DEBUG #ifdef __rtems__ -#define XNANDPSU_MAX_TARGETS 2U /**< ce_n0, ce_n1 */ +#define XNANDPSU_MAX_TARGETS BSP_NANDPSU_TOTAL_CHIPS #else #define XNANDPSU_MAX_TARGETS 1U /**< ce_n0, ce_n1 */ #endif diff --git a/spec/build/bsps/objnandpsu.yml b/spec/build/bsps/objnandpsu.yml index 30c2634f51..5a27007e9c 100644 --- a/spec/build/bsps/objnandpsu.yml +++ b/spec/build/bsps/objnandpsu.yml @@ -19,7 +19,9 @@ install: - bsps/include/dev/nand/xnandpsu.h - bsps/include/dev/nand/xnandpsu_hw.h - bsps/include/dev/nand/xnandpsu_onfi.h -links: [] +links: +- role: build-dependency + uid: optnandpsuchips source: - bsps/shared/dev/nand/xnandpsu_bbm.c - bsps/shared/dev/nand/xnandpsu.c diff --git a/spec/build/bsps/optnandpsuchips.yml b/spec/build/bsps/optnandpsuchips.yml new file mode 100644 index 0000000000..d2a8ada483 --- /dev/null +++ b/spec/build/bsps/optnandpsuchips.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +actions: +- get-integer: null +- env-enable: null +- format-and-define: null +build-type: option +copyrights: +- Copyright (C) 2025 On-Line Applications Research (OAR) Corporation +default: +- enabled-by: + - aarch64/zynqmp_cfc400x + value: 2 +- enabled-by: true + value: 1 +description: | + Set the number of NAND chips expected to be attached to the NAND controller +enabled-by: true +format: '{}' +links: [] +name: BSP_NANDPSU_TOTAL_CHIPS +type: build