summaryrefslogtreecommitdiff
path: root/board/keymile/secu1/socfpga.c
diff options
context:
space:
mode:
authorHolger Brunck <holger.brunck@ch.abb.com>2020-02-19 19:55:14 +0100
committerMarek Vasut <marex@denx.de>2020-03-03 22:11:36 +0100
commit468ba8d00b5af7828302e297736ae23d4873cfb0 (patch)
tree1a60a77e307bbd56fb4733807d3c8a2586f80508 /board/keymile/secu1/socfpga.c
parent85f748ad953e92e62831bff24bfd2260ef23325c (diff)
ARM: socfpga: Add initial support for the ABB SECU board
Add initial support for the ABB SECU board, which is an ArriaV-based SoCFPGA system with ethernet and booting from Denali NAND. Signed-off-by: Holger Brunck <holger.brunck@ch.abb.com> Cc: Ley Foon Tan <ley.foon.tan@intel.com> Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Diffstat (limited to 'board/keymile/secu1/socfpga.c')
-rw-r--r--board/keymile/secu1/socfpga.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/board/keymile/secu1/socfpga.c b/board/keymile/secu1/socfpga.c
new file mode 100644
index 0000000000..dc04a21abe
--- /dev/null
+++ b/board/keymile/secu1/socfpga.c
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2017-2020 ABB
+ */
+#include <common.h>
+#include <i2c.h>
+#include <asm/gpio.h>
+
+#include "../common/common.h"
+
+/*
+ * For FU1, the MAC address associated with the mgmt port should
+ * be the base address (as read from the IVM) + 4, and for FU2 it
+ * is + 10
+ */
+#define MAC_ADDRESS_OFFSET_FU1 4
+#define MAC_ADDRESS_OFFSET_FU2 10
+
+/*
+ * This function reads the state of GPIO40 and returns true (non-zero)
+ * if it is '1' and false(0) otherwise.
+ *
+ * This pin is routed to a pull-up on FU2 and a pull-down on
+ */
+#define GPIO_FU_DETECTION 40
+
+int secu1_is_fu2(void)
+{
+ int value;
+ int ret = gpio_request(GPIO_FU_DETECTION, "secu");
+
+ if (ret) {
+ printf("gpio: failed to request pin for FU detection\n");
+ return 1;
+ }
+ gpio_direction_input(GPIO_FU_DETECTION);
+ value = gpio_get_value(GPIO_FU_DETECTION);
+
+ if (value == 1)
+ printf("FU2 detected\n");
+ else
+ printf("FU1 detected\n");
+
+ return value;
+}
+
+static uchar ivm_content[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
+
+#if defined(CONFIG_HUSH_INIT_VAR)
+int hush_init_var(void)
+{
+ ivm_analyze_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
+ return 0;
+}
+#endif
+
+int misc_init_r(void)
+{
+ if (secu1_is_fu2())
+ ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN,
+ MAC_ADDRESS_OFFSET_FU2);
+ else
+ ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN,
+ MAC_ADDRESS_OFFSET_FU1);
+
+ return 0;
+}