]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: cssi: Create dedicated file for common sources
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 4 Apr 2023 10:42:15 +0000 (12:42 +0200)
committerChristophe Leroy <christophe.leroy@csgroup.eu>
Fri, 28 Apr 2023 15:52:23 +0000 (17:52 +0200)
In preparation of the new cssi board called cmpcpro which
we be introduce in a future patch, move common
functions into a dedicated file in a common directory.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
board/cssi/cmpc885/Makefile
board/cssi/cmpc885/cmpc885.c
board/cssi/common/common.c [new file with mode: 0644]
board/cssi/common/common.h [new file with mode: 0644]

index 6c055097cddb8126f33861a10445ac3732317180..baf9e5ab4f68ccfbedd18de19f3b27cb196b727f 100644 (file)
@@ -5,6 +5,6 @@
 # Christophe Leroy <christophe.leroy@c-s.fr>
 #
 
-obj-y += cmpc885.o
+obj-y += cmpc885.o ../common/common.o
 obj-y += sdram.o
 obj-$(CONFIG_CMD_NAND) += nand.o
index 5233c24aae31bc0617c0bd2b6a2ec1abc2f54ae6..689d573075b31cca368308f5955431b802e16363 100644 (file)
 #include <init.h>
 #include <fdt_support.h>
 #include <linux/delay.h>
-
 #include <spi.h>
 
+#include "../common/common.h"
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #define BOARD_CMPC885          "cmpc885"
@@ -59,57 +60,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define R_RESET_STATUS         0x0400
 #define R_RST_STATUS           0x0004
 
-static int fdt_set_node_and_value(void *blob, char *node, const char *prop,
-                                 void *var, int size)
-{
-       int ret, off;
-
-       off = fdt_path_offset(blob, node);
-
-       if (off < 0) {
-               printf("Cannot find %s node err:%s\n", node, fdt_strerror(off));
-
-               return off;
-       }
-
-       ret = fdt_setprop(blob, off, prop, var, size);
-
-       if (ret < 0)
-               printf("Cannot set %s/%s prop err: %s\n", node, prop, fdt_strerror(ret));
-
-       return ret;
-}
-
-/* Checks front/rear id and remove unneeded nodes from the blob */
-static void ft_cleanup(void *blob, uint32_t id, const char *prop, const char *compatible)
-{
-       int off;
-
-       off = fdt_node_offset_by_compatible(blob, -1, compatible);
-
-       while (off != -FDT_ERR_NOTFOUND) {
-               const struct fdt_property *ids;
-               int nb_ids, idx;
-               int tmp = -1;
-
-               ids = fdt_get_property(blob, off, prop, &nb_ids);
-
-               for (idx = 0; idx < nb_ids; idx += 4) {
-                       if (*((uint32_t *)&ids->data[idx]) == id)
-                               break;
-               }
-
-               if (idx >= nb_ids)
-                       fdt_del_node(blob, off);
-               else
-                       tmp = off;
-
-               off = fdt_node_offset_by_compatible(blob, tmp, compatible);
-       }
-
-       fdt_set_node_and_value(blob, "/", prop, &id, sizeof(uint32_t));
-}
-
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
        u8 fav_id, far_id;
diff --git a/board/cssi/common/common.c b/board/cssi/common/common.c
new file mode 100644 (file)
index 0000000..71b35cc
--- /dev/null
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2010-2020 CS Group
+ * Charles Frey <charles.frey@c-s.fr>
+ * Florent Trinh Thai <florent.trinh-thai@c-s.fr>
+ * Christophe Leroy <christophe.leroy@c-s.fr>
+ *
+ * Common specific routines for the CS Group boards
+ */
+
+#include <fdt_support.h>
+
+static int fdt_set_node_and_value(void *blob, char *node, const char *prop,
+                                 void *var, int size)
+{
+       int ret, off;
+
+       off = fdt_path_offset(blob, node);
+
+       if (off < 0) {
+               printf("Cannot find %s node err:%s\n", node, fdt_strerror(off));
+
+               return off;
+       }
+
+       ret = fdt_setprop(blob, off, prop, var, size);
+
+       if (ret < 0)
+               printf("Cannot set %s/%s prop err: %s\n", node, prop, fdt_strerror(ret));
+
+       return ret;
+}
+
+/* Checks front/rear id and remove unneeded nodes from the blob */
+void ft_cleanup(void *blob, unsigned long id, const char *prop, const char *compatible)
+{
+       int off;
+
+       off = fdt_node_offset_by_compatible(blob, -1, compatible);
+
+       while (off != -FDT_ERR_NOTFOUND) {
+               const struct fdt_property *ids;
+               int nb_ids, idx;
+               int tmp = -1;
+
+               ids = fdt_get_property(blob, off, prop, &nb_ids);
+
+               for (idx = 0; idx < nb_ids; idx += 4) {
+                       if (*((uint32_t *)&ids->data[idx]) == id)
+                               break;
+               }
+
+               if (idx >= nb_ids)
+                       fdt_del_node(blob, off);
+               else
+                       tmp = off;
+
+               off = fdt_node_offset_by_compatible(blob, tmp, compatible);
+       }
+
+       fdt_set_node_and_value(blob, "/", prop, &id, sizeof(uint32_t));
+}
diff --git a/board/cssi/common/common.h b/board/cssi/common/common.h
new file mode 100644 (file)
index 0000000..16852b6
--- /dev/null
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _BOARD_CSSI_COMMON_H
+#define _BOARD_CSSI_COMMON_H
+
+void ft_cleanup(void *blob, unsigned long id, const char *prop, const char *compatible);
+
+#endif /* _BOARD_CSSI_COMMON_H */