aboutsummaryrefslogtreecommitdiff
path: root/board/phytec
diff options
context:
space:
mode:
authorDaniel Schultz <d.schultz@phytec.de>2024-04-19 08:55:36 -0700
committerTom Rini <trini@konsulko.com>2024-04-29 10:55:57 -0600
commitf1c6f5797f53cddd8f87e208062c76697b2d65bc (patch)
tree60ae5161e6bbdc67b7af5e4c8372a0df2c051489 /board/phytec
parentc9e25d8c1d2c844ab76a7b0195f293275dcfdc6e (diff)
downloadu-boot-f1c6f5797f53cddd8f87e208062c76697b2d65bc.zip
u-boot-f1c6f5797f53cddd8f87e208062c76697b2d65bc.tar.gz
u-boot-f1c6f5797f53cddd8f87e208062c76697b2d65bc.tar.bz2
board: phytec: common: Generic "add extension" function
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> Reviewed-by: Teresa Remmet <t.remmet@phytec.de>
Diffstat (limited to 'board/phytec')
-rw-r--r--board/phytec/common/phytec_som_detection.c33
-rw-r--r--board/phytec/common/phytec_som_detection.h5
2 files changed, 38 insertions, 0 deletions
diff --git a/board/phytec/common/phytec_som_detection.c b/board/phytec/common/phytec_som_detection.c
index a56e0f6..d167a77 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 7edbfa3..ea99a68 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 */