public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Daniel Schultz <d.schultz@phytec.de>
To: <u-boot@lists.denx.de>
Cc: Daniel Schultz <d.schultz@phytec.de>
Subject: [PATCH 1/5] board: phytec: common: Generic "add extension" function
Date: Fri, 19 Apr 2024 08:55:36 -0700	[thread overview]
Message-ID: <20240419155540.2447006-2-d.schultz@phytec.de> (raw)
In-Reply-To: <20240419155540.2447006-1-d.schultz@phytec.de>

Add a generic function to apply overlays in our board code to not
implement the same logic in different PHYTEC products.

Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
---
 board/phytec/common/phytec_som_detection.c | 33 ++++++++++++++++++++++
 board/phytec/common/phytec_som_detection.h |  5 ++++
 2 files changed, 38 insertions(+)

diff --git a/board/phytec/common/phytec_som_detection.c b/board/phytec/common/phytec_som_detection.c
index a56e0f60d62..d167a77c25b 100644
--- a/board/phytec/common/phytec_som_detection.c
+++ b/board/phytec/common/phytec_som_detection.c
@@ -9,6 +9,8 @@
 #include <dm/uclass.h>
 #include <i2c.h>
 #include <u-boot/crc.h>
+#include <malloc.h>
+#include <extension_board.h>
 
 #include "phytec_som_detection.h"
 
@@ -213,6 +215,28 @@ u8 __maybe_unused phytec_get_som_type(struct phytec_eeprom_data *data)
 	return data->data.data_api2.som_type;
 }
 
+#if IS_ENABLED(CONFIG_CMD_EXTENSION)
+struct extension *phytec_add_extension(const char *name, const char *overlay,
+				       const char *other)
+{
+	struct extension *extension;
+
+	if (strlen(overlay) > sizeof(extension->overlay)) {
+		pr_err("Overlay name %s is longer than %lu.\n", overlay,
+		       sizeof(extension->overlay));
+		return NULL;
+	}
+
+	extension = calloc(1, sizeof(struct extension));
+	snprintf(extension->name, sizeof(extension->name), name);
+	snprintf(extension->overlay, sizeof(extension->overlay), overlay);
+	snprintf(extension->other, sizeof(extension->other), other);
+	snprintf(extension->owner, sizeof(extension->owner), "PHYTEC");
+
+	return extension;
+}
+#endif /* IS_ENABLED(CONFIG_CMD_EXTENSION) */
+
 #else
 
 inline int phytec_eeprom_data_setup(struct phytec_eeprom_data *data,
@@ -253,4 +277,13 @@ u8 __maybe_unused phytec_get_som_type(struct phytec_eeprom_data *data)
 	return PHYTEC_EEPROM_INVAL;
 }
 
+#if IS_ENABLED(CONFIG_CMD_EXTENSION)
+inline struct extension *phytec_add_extension(const char *name,
+					      const char *overlay,
+					      const char *other)
+{
+	return NULL;
+}
+#endif /* IS_ENABLED(CONFIG_CMD_EXTENSION) */
+
 #endif /* IS_ENABLED(CONFIG_PHYTEC_SOM_DETECTION) */
diff --git a/board/phytec/common/phytec_som_detection.h b/board/phytec/common/phytec_som_detection.h
index 7edbfa3ca5c..ea99a687fee 100644
--- a/board/phytec/common/phytec_som_detection.h
+++ b/board/phytec/common/phytec_som_detection.h
@@ -76,4 +76,9 @@ char * __maybe_unused phytec_get_opt(struct phytec_eeprom_data *data);
 u8 __maybe_unused phytec_get_rev(struct phytec_eeprom_data *data);
 u8 __maybe_unused phytec_get_som_type(struct phytec_eeprom_data *data);
 
+#if IS_ENABLED(CONFIG_CMD_EXTENSION)
+struct extension *phytec_add_extension(const char *name, const char *overlay,
+				       const char *other);
+#endif /* IS_ENABLED(CONFIG_CMD_EXTENSION) */
+
 #endif /* _PHYTEC_SOM_DETECTION_H */
-- 
2.25.1


  reply	other threads:[~2024-04-19 16:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 15:55 [PATCH 0/5] Update PHYTEC SOM Detection Daniel Schultz
2024-04-19 15:55 ` Daniel Schultz [this message]
2024-04-23  7:30   ` [PATCH 1/5] board: phytec: common: Generic "add extension" function Teresa Remmet
2024-04-19 15:55 ` [PATCH 2/5] board: phytec: introduce eeprom struct member 'valid' Daniel Schultz
2024-04-23  7:26   ` Teresa Remmet
2024-04-19 15:55 ` [PATCH 3/5] board: phytec: check eeprom_data validity Daniel Schultz
2024-04-23  7:27   ` Teresa Remmet
2024-04-19 15:55 ` [PATCH 4/5] board: phytec: common: Fix eepom is empty check Daniel Schultz
2024-04-23  7:26   ` Teresa Remmet
2024-04-19 15:55 ` [PATCH 5/5] board: phytec: Add SOM detection for AM6x Daniel Schultz
2024-04-29 23:04 ` [PATCH 0/5] Update PHYTEC SOM Detection Tom Rini

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=20240419155540.2447006-2-d.schultz@phytec.de \
    --to=d.schultz@phytec.de \
    --cc=u-boot@lists.denx.de \
    /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