]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
arm: socfpga: system: Clean up pinmux_config.c
authorMarek Vasut <marex@denx.de>
Sat, 25 Jul 2015 09:09:11 +0000 (11:09 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Thu, 10 Sep 2015 06:17:21 +0000 (08:17 +0200)
Implement new accessor, sysmgr_get_pinmux_table(), used to obtain pinmux
table and it's size from the QTS-generated pinmux_config.c. The target
here is again to get rid of poluting global namespace by including the
pinmux_config.h into it.

Furthermore, the pinmux_config.h declares some CONFIG_HPS_* macros,
which are explicitly useless to us in U-Boot. Instead, U-Boot does
use DT to detect exactly these configuration options. This patch
makes sure that while this QTS-generated file can stay in the tree,
these obscure macros do not ooze into the namespace anymore.

Signed-off-by: Marek Vasut <marex@denx.de>
arch/arm/mach-socfpga/include/mach/system_manager.h
arch/arm/mach-socfpga/system_manager.c
board/altera/socfpga/Makefile
board/altera/socfpga/qts/Makefile [deleted file]
board/altera/socfpga/wrap_pinmux_config.c [new file with mode: 0644]
include/configs/socfpga_arria5.h
include/configs/socfpga_cyclone5.h

index de05aaf198494eab081629160fd6ed08f8253884..46af30b640e009c60b6f3de09cff921506b868ac 100644 (file)
@@ -12,9 +12,8 @@
 void sysmgr_pinmux_init(void);
 void sysmgr_config_warmrstcfgio(int enable);
 
-/* declaration for handoff table type */
-extern unsigned long sys_mgr_init_table[CONFIG_HPS_PINMUX_NUM];
-
+void sysmgr_get_pinmux_table(const unsigned long **table,
+                            unsigned int *table_len);
 #endif
 
 struct socfpga_system_manager {
index 5ed47c3cff354a90e9513feea9895c4a7b561cfc..744ec326b49ee679a39d7ccf6d4bde36ed6c8246 100644 (file)
@@ -57,9 +57,13 @@ static void populate_sysmgr_fpgaintf_module(void)
 void sysmgr_pinmux_init(void)
 {
        uint32_t regs = (uint32_t)&sysmgr_regs->emacio[0];
+       const unsigned long *sys_mgr_init_table;
+       unsigned int len;
        int i;
 
-       for (i = 0; i < ARRAY_SIZE(sys_mgr_init_table); i++) {
+       sysmgr_get_pinmux_table(&sys_mgr_init_table, &len);
+
+       for (i = 0; i < len; i++) {
                writel(sys_mgr_init_table[i], regs);
                regs += sizeof(regs);
        }
index 7cd4ef9b509591a4f3a7a1538c6a4d52d2422e1f..640f629856709c97837afd28a8baa9437ef91b9b 100644 (file)
@@ -7,4 +7,4 @@
 #
 
 obj-y  := socfpga.o wrap_pll_config.o
-obj-$(CONFIG_SPL_BUILD) += qts/ wrap_iocsr_config.o
+obj-$(CONFIG_SPL_BUILD) += wrap_iocsr_config.o wrap_pinmux_config.o
diff --git a/board/altera/socfpga/qts/Makefile b/board/altera/socfpga/qts/Makefile
deleted file mode 100644 (file)
index cd8fecc..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-# (C) Copyright 2015 Marek Vasut <marex@denx.de>
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y += pinmux_config.o
diff --git a/board/altera/socfpga/wrap_pinmux_config.c b/board/altera/socfpga/wrap_pinmux_config.c
new file mode 100644 (file)
index 0000000..b33e2ca
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2015 Marek Vasut <marex@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <errno.h>
+/*
+ * Yes, dear reader, we're including a C file here, this is no mistake.
+ * But this time around, we do even more perverse hacking here to be
+ * compatible with QTS headers and obtain reasonably nice results too.
+ *
+ * First, we define _PRELOADER_PINMUX_CONFIG_H_, which will neutralise
+ * the pinmux_config.h inclusion in pinmux_config.c . Since we are
+ * probing everything from DT, we do NOT want those macros from the
+ * pinmux_config.h to ooze into our build system, anywhere, ever. So
+ * we nip it at the bud.
+ *
+ * Next, pinmux_config.c needs CONFIG_HPS_PINMUX_NUM and uses it to
+ * specify sized array explicitly. Instead, we want to use ARRAY_SIZE
+ * to figure out the size of the array, so define this macro as an
+ * empty one, so that the preprocessor optimizes things such that the
+ * arrays are not sized by default.
+ */
+#define _PRELOADER_PINMUX_CONFIG_H_
+#define CONFIG_HPS_PINMUX_NUM
+#include "qts/pinmux_config.c"
+
+void sysmgr_get_pinmux_table(const unsigned long **table,
+                            unsigned int *table_len)
+{
+       *table = sys_mgr_init_table;
+       *table_len = ARRAY_SIZE(sys_mgr_init_table);
+}
index 3ef87b40e91d1d118c5c1881d878bf916129f6cf..2d31df8a4547d6c18d223a1f3690a83ee80e440d 100644 (file)
@@ -7,7 +7,6 @@
 #define __CONFIG_SOCFPGA_ARRIA5_H__
 
 #include <asm/arch/socfpga_base_addrs.h>
-#include "../../board/altera/socfpga/qts/pinmux_config.h"
 
 /* U-Boot Commands */
 #define CONFIG_SYS_NO_FLASH
index 1bc57455a3865c644a54acb0f7980845db2130f8..6b7563305dece975d9db57f5f6ceac843240efee 100644 (file)
@@ -5,7 +5,6 @@
  */
 
 #include <asm/arch/socfpga_base_addrs.h>
-#include "../../board/altera/socfpga/qts/pinmux_config.h"
 
 /* U-Boot Commands */
 #define CONFIG_SYS_NO_FLASH