Skip to contentSkip to conversation

arm: socfpga: add board support for ic-automation Moritz III

PATCH Superseded Nico Becker 2 participants 2 messages Jul 17, 2020 – Sep 7, 2020

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 arm: socfpga: add board support for ic-automation Moritz III

add board support for the moritz III from ic-automation

Changes for v4:
- re-sort list alphabetically
- c style comments

Changes for v3:
- Resend via git send-email

Changes for v2:
- Coding Style cleanup

---
 arch/arm/dts/Makefile                         |   1 +
 ...ocfpga_cyclone5_ica_moritz_iii-u-boot.dtsi |  45 ++
 .../dts/socfpga_cyclone5_ica_moritz_iii.dts   | 123 ++++
 arch/arm/mach-socfpga/Kconfig                 |   8 +
 board/ic-automation/moritz_iii/MAINTAINERS    |   8 +
 board/ic-automation/moritz_iii/Makefile       |   8 +
 .../moritz_iii/moritz_iii_board.c             | 126 ++++
 .../moritz_iii/qts/iocsr_config.h             | 658 ++++++++++++++++++
 .../moritz_iii/qts/pinmux_config.h            | 218 ++++++
 .../ic-automation/moritz_iii/qts/pll_config.h |  83 +++
 .../moritz_iii/qts/sdram_config.h             | 344 +++++++++
 board/ic-automation/moritz_iii/socfpga.c      |   5 +
 configs/socfpga_moritz_iii_defconfig          |  74 ++
 include/configs/socfpga_ica_moritz_iii.h      |  46 ++
 14 files changed, 1747 insertions(+)
 create mode 100644 arch/arm/dts/socfpga_cyclone5_ica_moritz_iii-u-boot.dtsi
 create mode 100644 arch/arm/dts/socfpga_cyclone5_ica_moritz_iii.dts
 create mode 100644 board/ic-automation/moritz_iii/MAINTAINERS
 create mode 100644 board/ic-automation/moritz_iii/Makefile
 create mode 100644 board/ic-automation/moritz_iii/moritz_iii_board.c
 create mode 100644 board/ic-automation/moritz_iii/qts/iocsr_config.h
 create mode 100644 board/ic-automation/moritz_iii/qts/pinmux_config.h
 create mode 100644 board/ic-automation/moritz_iii/qts/pll_config.h
 create mode 100644 board/ic-automation/moritz_iii/qts/sdram_config.h
 create mode 100644 board/ic-automation/moritz_iii/socfpga.c
 create mode 100644 configs/socfpga_moritz_iii_defconfig
 create mode 100644 include/configs/socfpga_ica_moritz_iii.h
arch/arm/dts/Makefile +1 -0
index 9900b44274..6fbedfe3b3 100644
@@ -352,6 +352,7 @@ dtb-$(CONFIG_ARCH_SOCFPGA) +=				\
 	socfpga_cyclone5_de0_nano_soc.dtb		\
 	socfpga_cyclone5_de1_soc.dtb			\
 	socfpga_cyclone5_de10_nano.dtb			\
+	socfpga_cyclone5_ica_moritz_iii.dtb		\
 	socfpga_cyclone5_sockit.dtb			\
 	socfpga_cyclone5_socrates.dtb			\
 	socfpga_cyclone5_sr1500.dtb			\
arch/arm/dts/socfpga_cyclone5_ica_moritz_iii-u-boot.dtsi new file +45 -0

45 lines not on this page · raw message

arch/arm/dts/socfpga_cyclone5_ica_moritz_iii.dts new file +123 -0

123 lines not on this page · raw message

arch/arm/mach-socfpga/Kconfig +8 -0
index a3699e82a1..13a9ebac5f 100644
@@ -118,6 +118,11 @@ config TARGET_SOCFPGA_EBV_SOCRATES
 	bool "EBV SoCrates (Cyclone V)"
 	select TARGET_SOCFPGA_CYCLONE5
 
+	config TARGET_SOCFPGA_ICA_MORITZ_III
+		bool "ic-automation Moritz III (Cyclone V)"
+		select BOARD_LATE_INIT
+		select TARGET_SOCFPGA_CYCLONE5
+
 config TARGET_SOCFPGA_IS1
 	bool "IS1 (Cyclone V)"
 	select TARGET_SOCFPGA_CYCLONE5
@@ -164,6 +169,7 @@ config SYS_BOARD
 	default "de10-nano" if TARGET_SOCFPGA_TERASIC_DE10_NANO
 	default "is1" if TARGET_SOCFPGA_IS1
 	default "mcvevk" if TARGET_SOCFPGA_ARIES_MCVEVK
+	default "moritz_iii" if TARGET_SOCFPGA_ICA_MORITZ_III
 	default "secu1" if TARGET_SOCFPGA_ARRIA5_SECU1
 	default "sockit" if TARGET_SOCFPGA_TERASIC_SOCKIT
 	default "socrates" if TARGET_SOCFPGA_EBV_SOCRATES
@@ -180,6 +186,7 @@ config SYS_VENDOR
 	default "aries" if TARGET_SOCFPGA_ARIES_MCVEVK
 	default "devboards" if TARGET_SOCFPGA_DEVBOARDS_DBM_SOC1
 	default "ebv" if TARGET_SOCFPGA_EBV_SOCRATES
+	default "ic-automation" if TARGET_SOCFPGA_ICA_MORITZ_III
 	default "keymile" if TARGET_SOCFPGA_ARRIA5_SECU1
 	default "softing" if TARGET_SOCFPGA_SOFTING_VINING_FPGA
 	default "terasic" if TARGET_SOCFPGA_TERASIC_DE0_NANO
@@ -200,6 +207,7 @@ config SYS_CONFIG_NAME
 	default "socfpga_de0_nano_soc" if TARGET_SOCFPGA_TERASIC_DE0_NANO
 	default "socfpga_de1_soc" if TARGET_SOCFPGA_TERASIC_DE1_SOC
 	default "socfpga_de10_nano" if TARGET_SOCFPGA_TERASIC_DE10_NANO
+	default "socfpga_ica_moritz_iii" if TARGET_SOCFPGA_ICA_MORITZ_III
 	default "socfpga_is1" if TARGET_SOCFPGA_IS1
 	default "socfpga_mcvevk" if TARGET_SOCFPGA_ARIES_MCVEVK
 	default "socfpga_sockit" if TARGET_SOCFPGA_TERASIC_SOCKIT
board/ic-automation/moritz_iii/MAINTAINERS new file +8 -0
new file mode 100644
index 0000000000..0c8c8ecf21
@@ -0,0 +1,8 @@
+MORITZ III BOARD
+M:	Nico Becker ic-automation GmbH <[email protected]>
+S:	Maintained
+F:	board/ic-automation/moritz_iii/
+F:	include/configs/socfpga_ica_moritz_iii.h
+F:	configs/socfpga_moritz_iii_defconfig
+F:	arch/arm/dts/socfpga_cyclone5_ica_moritz_iii.dts
+F:	arch/arm/dts/socfpga_cyclone5_ica_moritz_iii-u-boot.dtsi
board/ic-automation/moritz_iii/Makefile new file +8 -0
new file mode 100644
index 0000000000..3577c94928
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2001-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+# (C) Copyright 2010, Thomas Chou <[email protected]>
+
+obj-y	:= socfpga.o
+obj-y	:= moritz_iii_board.o
\ No newline at end of file
board/ic-automation/moritz_iii/moritz_iii_board.c new file +126 -0

126 lines not on this page · raw message

board/ic-automation/moritz_iii/qts/iocsr_config.h new file +658 -0

658 lines not on this page · raw message

board/ic-automation/moritz_iii/qts/pinmux_config.h new file +218 -0

218 lines not on this page · raw message

board/ic-automation/moritz_iii/qts/pll_config.h new file +83 -0

83 lines not on this page · raw message

board/ic-automation/moritz_iii/qts/sdram_config.h new file +344 -0

344 lines not on this page · raw message

board/ic-automation/moritz_iii/socfpga.c new file +5 -0
new file mode 100644
index 0000000000..48bfe32951
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ */
+#include <common.h>
configs/socfpga_moritz_iii_defconfig new file +74 -0

74 lines not on this page · raw message

include/configs/socfpga_ica_moritz_iii.h new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
2.20.1
#1 lore raw

PATCH v4 1/1 arm: socfpga: add board support for ic-automation Moritz III

Quoted 115 lines

-----Original Message-----
From: Nico Becker <[email protected]>
Sent: Friday, July 17, 2020 6:23 PM
To: u-boot at lists.denx.de; marex at denx.de; simon.k.r.goldschmidt at gmail.com; Tan, Ley Foon <[email protected]>
Cc: Nico Becker <[email protected]>
Subject: [PATCH v4] arm: socfpga: add board support for ic-automation Moritz III

add board support for the moritz III from ic-automation

Changes for v4:
- re-sort list alphabetically
- c style comments

Changes for v3:
- Resend via git send-email

Changes for v2:
- Coding Style cleanup

board/ic-automation/moritz_iii/moritz_iii_board.c new file +16 -0
+
+#include <common.h>
+#include <net.h>
+#include <dm/uclass.h>
+#include <i2c.h>
+#include <env_flags.h>
+#include <u-boot/crc.h>
+
+#define I2C_BUS_NUM						1
+#define EEPROM_ADDR						0x50
+#define GPIO_ADDR							0x20
+
+#define SERIALNUMBER_LENGTH		8
+#define MAC_LENGTH						6
+#define CRC32_LENGTH					4
+#define OVERALL_LENGTH

(SERIALNUMBER_LENGTH + MAC_LENGTH + CRC32_LENGTH)

board/ic-automation/moritz_iii/moritz_iii_board.c new file +17 -0
+
+int board_late_init(void)
+{
+	u8 mac[MAC_LENGTH];
+	char serial[SERIALNUMBER_LENGTH + 1];
+	u8 eeprom_data[OVERALL_LENGTH];
+	u32 calc_crc32;
+	u32 *read_crc32;
+	u8 w_data;
+	int error;
+	u8 registers[] = {0x02, 0x03, 0x06, 0x07};
+
+	for (int i = 0; i < OVERALL_LENGTH; i++)
+		eeprom_data[i] = 0x00;
+
+	printf(" _                       _                        _   _\n");
+	printf("(_) ___       __ _ _   _| |_ ___  _ __ ___   __ _| |_(_) ___  _

__\n");

(quoted diff) +1 -0
+	printf("| |/ __|____ / _` | | | | __/ _ \\| '_ ` _ \\ / _` | __| |/ _ \\| '_

\\\n");

(quoted diff) +1 -0
+	printf("| | (_|_____| (_| | |_| | || (_) | | | | | | (_| | |_| | (_) | | |

|\n");

(quoted diff) +1 -0
+	printf("|_|\\___|     \\__,_|\\__,_|\\__\\___/|_| |_|

|_|\\__,_|\\__|_|\\___/|_| |_|\n");

board/ic-automation/moritz_iii/moritz_iii_board.c new file +3 -0
+	printf("\n");
+
+	/* delete environment var first. Otherwise we are unable to set it's

value... */

board/ic-automation/moritz_iii/moritz_iii_board.c new file +6 -0
+	env_set("ethaddr", "");
+
+	struct udevice *bus;
+	struct udevice *dev;
+
+	error = uclass_get_device_by_seq(UCLASS_I2C, I2C_BUS_NUM,

&bus);

(quoted diff) +2 -0
+	if (error) {
+		printf("cannot get I2C bus 1: uclass_get_device_by_seq

failed: %i\n", error);

board/ic-automation/moritz_iii/moritz_iii_board.c new file +24 -0
+		return 0;
+	}
+
+	error = i2c_get_chip(bus, EEPROM_ADDR, 1, &dev);
+	if (error) {
+		printf("Cannot get I2C chip: i2c_get_chip failed: %i\n", error);
+		return 0;
+	}
+
+	/* i2c EEPROM available? */
+	error = dm_i2c_probe(bus, EEPROM_ADDR, 0, &dev);
+	if (error) {
+		printf("Couldn't find i2c eeprom\n");
+		return 0;
+	}
+
+	error = dm_i2c_read(dev, 0, eeprom_data, OVERALL_LENGTH);
+	if (error) {
+		printf("i2c_read failed %d\n", error);
+		return 0;
+	}
+
+	/* check crc32 */
+	calc_crc32 = crc32(0, eeprom_data, OVERALL_LENGTH -

CRC32_LENGTH);

(quoted diff) +1 -0
+	read_crc32 = (u32 *)&eeprom_data[SERIALNUMBER_LENGTH +

MAC_LENGTH];

board/ic-automation/moritz_iii/moritz_iii_board.c new file +8 -0
+	if (*read_crc32 != calc_crc32) {
+		/* print read data is crc32 not valid */
+		printf("read data:");
+		for (int i = 0; i < OVERALL_LENGTH; i++)
+			printf("%02X", eeprom_data[i]);
+		printf("\n");
+		/* print crc32 */
+		printf("read crc32 %08X calc crc32 %08X\n", *read_crc32,

calc_crc32);

board/ic-automation/moritz_iii/moritz_iii_board.c line 91

Quoted 5 lines
board/ic-automation/moritz_iii/moritz_iii_board.c new file +5 -0
+
+		strncpy(serial, "00000000", 8);
+		memset((void *)mac, 0x00, 8);
+	} else {
+		/* copy and print serial */

Comment should be "copy".

board/ic-automation/moritz_iii/moritz_iii_board.c line 94

Quoted 4 lines
(quoted diff) +1 -0
+		memcpy((void *)serial, (void *)eeprom_data,

SERIALNUMBER_LENGTH);

board/ic-automation/moritz_iii/moritz_iii_board.c new file +2 -0
+
+		/* print MAC address */

Comment should be "copy".

board/ic-automation/moritz_iii/moritz_iii_board.c line 102

Quoted 9 lines
(quoted diff) +1 -0
+		memcpy((void *)mac, (void

*)&eeprom_data[SERIALNUMBER_LENGTH], MAC_LENGTH);

board/ic-automation/moritz_iii/moritz_iii_board.c new file +7 -0
+	}
+
+	serial[SERIALNUMBER_LENGTH] = 0x00;
+	printf("Serialnumber = %s\n", serial);
+
+	if (!is_valid_ethaddr(mac)) {
+		printf("MAC address is invalid, set random MAC\n");

How it set random MAC address here? Need call to net_random_ethaddr() here?

Quoted 19 lines
board/ic-automation/moritz_iii/moritz_iii_board.c new file +18 -0
+	} else {
+		printf("MAC = %02X:%02X:%02X:%02X:%02X:%02X\n",
+			mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+		error = eth_env_set_enetaddr("ethaddr", mac);
+		if (error)
+			printf("MAC address NOT set. Error: %d\n", error);
+		else
+			printf("MAC address successfully set\n");
+	}
+
+	/* set GPIOs */
+	error = i2c_get_chip(bus, GPIO_ADDR, 1, &dev);
+	w_data = 0x00;
+	for (int i = 0 ; i < sizeof(registers) / sizeof(u8); i++) {
+		/* set all values 0 at GPIO-Bank 0 */
+		error = dm_i2c_write(dev, registers[i], &w_data, 1);
+		if (error) {
+			printf("i2c_write GPIO register %X failed.

Error: %d\n",

board/ic-automation/moritz_iii/moritz_iii_board.c line 126

Quoted 6 lines
board/ic-automation/moritz_iii/moritz_iii_board.c new file +6 -0
+				registers[i], error);
+			return 0;
+		}
+	}
+	return 0;
+}

Thanks.

Regards
Ley Foon