Skip to contentSkip to conversation

Initial Traverse Ten64 board support

PATCH Superseded Mathew McBride 2 participants 4 messages Nov 3, 2021 – Nov 9, 2021 Arm (32-bit)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Initial Traverse Ten64 board support

This patchset adds initial support for the Traverse Ten64 family, which is a networking focused Mini-ITX board using NXP's LS1088A.

This patchset is the bare minimum necessary to get a system running on U-Boot and booting via distroboot/EFI.

There are still a few more drivers to come, such as the I2C setup for the USB5744 hub and EMC2301 fan controller.

Additionally, this patchset does not contain any of the defaults (e.g bootmenu settings) we have in our official firmware releases.

This set contains two additions:
- The driver for the board microcontroller
The microcontroller holds the board MAC address and controls some board functions (like power to the 10G retimer).
This has been placed in boards/traverse/common/ as future Traverse products may use it as well.
- The board file itself

Mathew McBride (2):
board: traverse: add Ten64 board controller driver
board: traverse: add initial Ten64 support

 arch/arm/Kconfig                         |  16 +
 arch/arm/dts/Makefile                    |   2 +
 arch/arm/dts/fsl-ls1088a-ten64.dts       | 377 ++++++++++++++++++++
 board/traverse/common/Kconfig            |   6 +
 board/traverse/common/Makefile           |   1 +
 board/traverse/common/ten64-controller.h |  28 ++
 board/traverse/common/ten64_controller.c | 238 +++++++++++++
 board/traverse/ten64/Kconfig             |  17 +
 board/traverse/ten64/MAINTAINERS         |   8 +
 board/traverse/ten64/Makefile            |   6 +
 board/traverse/ten64/eth_ten64.c         |  49 +++
 board/traverse/ten64/ten64.c             | 433 +++++++++++++++++++++++
 configs/ten64_tfa_defconfig              | 119 +++++++
 include/configs/ten64.h                  |  55 +++
 14 files changed, 1355 insertions(+)
 create mode 100644 arch/arm/dts/fsl-ls1088a-ten64.dts
 create mode 100644 board/traverse/common/Kconfig
 create mode 100644 board/traverse/common/Makefile
 create mode 100644 board/traverse/common/ten64-controller.h
 create mode 100644 board/traverse/common/ten64_controller.c
 create mode 100644 board/traverse/ten64/Kconfig
 create mode 100644 board/traverse/ten64/MAINTAINERS
 create mode 100644 board/traverse/ten64/Makefile
 create mode 100644 board/traverse/ten64/eth_ten64.c
 create mode 100644 board/traverse/ten64/ten64.c
 create mode 100644 configs/ten64_tfa_defconfig
 create mode 100644 include/configs/ten64.h
Signature · 1 line
2.30.1
#1 lore raw

PATCH 1/2 board: traverse: add Ten64 board controller driver

Traverse Technologies Ten64 family boards use a microcontroller to control low level board functions like startup and reset, as well as holding details such as the board MAC address.

Communication between the CPU and microcontroller is via I2C.

To keep the driver structure clean between the Ten64 board file, DM_I2C, and a future utility command, this driver has been implemented as a misc uclass device.

---
 board/traverse/common/Kconfig            |   6 +
 board/traverse/common/Makefile           |   1 +
 board/traverse/common/ten64-controller.h |  28 +++
 board/traverse/common/ten64_controller.c | 238 +++++++++++++++++++++++
 4 files changed, 273 insertions(+)
 create mode 100644 board/traverse/common/Kconfig
 create mode 100644 board/traverse/common/Makefile
 create mode 100644 board/traverse/common/ten64-controller.h
 create mode 100644 board/traverse/common/ten64_controller.c
board/traverse/common/Kconfig new file +6 -0
new file mode 100644
index 0000000000..d34832bd0d
@@ -0,0 +1,6 @@
+config TEN64_CONTROLLER
+	bool "Enable Ten64 board controller driver"
+	depends on TARGET_TEN64
+	help
+		Support for the board microcontroller on the Traverse
+		Ten64 family of boards.
board/traverse/common/Makefile new file +1 -0
new file mode 100644
index 0000000000..d31e3535b9
@@ -0,0 +1 @@
+obj-$(CONFIG_TEN64_CONTROLLER) += ten64_controller.o
board/traverse/common/ten64-controller.h new file +28 -0
new file mode 100644
index 0000000000..fed6af470d
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+#ifndef TEN64_CNTRL_H
+#define TEN64_CNTRL_H
+
+/**
+ * struct t64uc_board_info - Board Information Structure
+ * @mac: Base MAC address
+ * @cpuId: Microcontroller unique serial number
+ * @fwversion_major: Microcontroller version number (Major)
+ * @fwversion_minor: Microcontroller version number (Minor)
+ * @fwversion_patch: Microcontroller version number (Patch)
+ */
+struct t64uc_board_info {
+	u8 mac[6];
+	u32 cpuId[4];
+	u8 fwversion_major;
+	u8 fwversion_minor;
+	u8 fwversion_patch;
+} __packed;
+
+enum {
+	TEN64_CNTRL_GET_BOARD_INFO,
+	TEN64_CNTRL_10G_OFF,
+	TEN64_CNTRL_10G_ON,
+	TEN64_CNTRL_SET_NEXT_BOOTSRC
+};
+
+#endif
board/traverse/common/ten64_controller.c new file +238 -0

238 lines not on this page · raw message

Signature · 1 line
2.30.1
#2 lore raw

RE: [PATCH 1/2] board: traverse: add Ten64 board controller driver

Quoted 340 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Mathew McBride
Sent: Wednesday, November 3, 2021 10:59 AM
To: [email protected]; Priyanka Jain <[email protected]>
Cc: Mathew McBride <[email protected]>
Subject: [PATCH 1/2] board: traverse: add Ten64 board controller driver

Traverse Technologies Ten64 family boards use a microcontroller to control low level board functions like startup and reset, as well as holding details such as the board MAC address.

Communication between the CPU and microcontroller is via I2C.

To keep the driver structure clean between the Ten64 board file, DM_I2C, and a future utility command, this driver has been implemented as a misc uclass device.

---

board/traverse/common/Kconfig            |   6 +
board/traverse/common/Makefile           |   1 +
board/traverse/common/ten64-controller.h |  28 +++
board/traverse/common/ten64_controller.c | 238 +++++++++++++++++++++++
4 files changed, 273 insertions(+)

create mode 100644 board/traverse/common/Kconfig create mode 100644 board/traverse/common/Makefile create mode 100644 board/traverse/common/ten64-controller.h
create mode 100644 board/traverse/common/ten64_controller.c

board/traverse/common/Kconfig new file +6 -0
new file mode 100644 index 0000000000..d34832bd0d
@@ -0,0 +1,6 @@
+config TEN64_CONTROLLER
+	bool "Enable Ten64 board controller driver"
+	depends on TARGET_TEN64
+	help
+		Support for the board microcontroller on the Traverse
+		Ten64 family of boards.
(quoted diff) +0 -0

b/board/traverse/common/Makefile new file mode 100644 index 0000000000..d31e3535b9

board/traverse/common/Makefile new file +1 -0
@@ -0,0 +1 @@
+obj-$(CONFIG_TEN64_CONTROLLER) += ten64_controller.o
board/traverse/common/ten64-controller.h new file +26 -0
new file mode 100644
index 0000000000..fed6af470d
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0+ */ #ifndef TEN64_CNTRL_H #define
+TEN64_CNTRL_H
+
+/**
+ * struct t64uc_board_info - Board Information Structure
+ * @mac: Base MAC address
+ * @cpuId: Microcontroller unique serial number
+ * @fwversion_major: Microcontroller version number (Major)
+ * @fwversion_minor: Microcontroller version number (Minor)
+ * @fwversion_patch: Microcontroller version number (Patch)  */ struct
+t64uc_board_info {
+	u8 mac[6];
+	u32 cpuId[4];
+	u8 fwversion_major;
+	u8 fwversion_minor;
+	u8 fwversion_patch;
+} __packed;
+
+enum {
+	TEN64_CNTRL_GET_BOARD_INFO,
+	TEN64_CNTRL_10G_OFF,
+	TEN64_CNTRL_10G_ON,
+	TEN64_CNTRL_SET_NEXT_BOOTSRC
+};
+
+#endif
board/traverse/common/ten64_controller.c new file +93 -0
new file mode 100644
index 0000000000..11e068f94f
@@ -0,0 +1,238 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/* Ten64 Board Microcontroller Driver
+ * Copyright 2021 Traverse Technologies Australia
+ *
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <misc.h>
+#include <i2c.h>
+#include <hexdump.h>
+#include <dm/device_compat.h>
+#include <inttypes.h>
+#include <linux/delay.h>
+
+#include "ten64-controller.h"
+
+/* Microcontroller command set and structure
+ * These should not be used outside this file  */
+
+#define T64_UC_DATA_MAX_SIZE            128U
+#define T64_UC_API_MSG_HEADER_SIZE      4U
+#define T64_UC_API_HEADER_PREAMB        0xcabe
+
+#define TEN64_UC_CMD_SET_BOARD_MAC		0x10
+#define TEN64_UC_CMD_GET_BOARD_INFO		0x11
+
+#define TEN64_UC_CMD_GET_STATE			0x20
+#define TEN64_UC_CMD_SET_RESET_BTN_HOLD_TIME	0x21
+#define TEN64_UC_CMD_ENABLE_RESET_BUTTON	0x22
+#define TEN64_UC_CMD_SET_NEXT_BOOTSRC		0x23
+#define TEN64_UC_CMD_ENABLE_10G 		0x24
+
+#define TEN64_UC_CMD_FWUP_GET_INFO		0xA0
+#define TEN64_UC_CMD_FWUP_INIT			0xA1
+#define TEN64_UC_CMD_FWUP_XFER			0xA2
+#define TEN64_UC_CMD_FWUP_CHECK 		0xA3
+#define TEN64_UC_CMD_FWUPBOOT			0xA
+
+/** struct t64uc_message - Wire Format for microcontroller messages
+ * @preamb: Message preamble (always 0xcabe)
+ * @cmd: Command to invoke
+ * @len: Length of data
+ * @data: Command data, up to 128 bytes  */ struct t64uc_message {
+	u16 preamb;
+	u8 cmd;
+	u8 len;
+	u8 data[T64_UC_DATA_MAX_SIZE];
+}  __packed;
+
+#define	T64_CTRL_IO_SET		1U
+#define	T64_CTRL_IO_CLEAR	2U
+#define	T64_CTRL_IO_TOGGLE	3U
+#define	T64_CTRL_IO_RESET	4U
+#define	T64_CTRL_IO_UNKNOWN	5U
+
+/** struct t64uc_board_10g_enable - Wrapper for 10G enable command
+ * @control: state to set the 10G retimer - either
+ *	     T64_CTRL_IO_CLEAR (0x02) for off or
+ *	     T64_CTRL_IO_SET (0x01) for on.
+ *
+ * This struct exists to simplify the wrapping of the
+ * command value into a microcontroller message and passing into
+ * functions.
+ */
+struct t64uc_board_10g_enable {
+	u8 control;
+} __packed;
+
+/** ten64_controller_send_recv_command() - Wrapper function to
+ * send a command to the microcontroller.
+ * @uc_chip: the DM I2C chip handle for the microcontroller
+ * @uc_cmd: the microcontroller API command code
+ * @uc_cmd_data: pointer to the data struct for this command
+ * @uc_data_len: size of command data struct
+ * @return_data: place to store response from microcontroller, NULL if
+not expected
+ * @expected_return_len: expected size of microcontroller command
+response
+ * @return_message_wait: wait this long (in us) before reading the
+response
+ *
+ * Invoke a microcontroller command and receive a response.
+ * This function includes communicating with the microcontroller over
+ * I2C and encoding a message in the wire format.
+ *
+ * Return: 0 if successful, error code otherwise.
+ * Returns -EBADMSG if the microcontroller response could not be
+validated,
+ * other error codes may be passed from dm_i2c_xfer()  */ static int
+ten64_controller_send_recv_command(struct udevice *ucdev, u8 uc_cmd,
+					      void *uc_cmd_data, u8

cmd_data_len,

board/traverse/common/ten64_controller.c new file +1 -0
+					      void *return_data, u8

expected_return_len,

board/traverse/common/ten64_controller.c new file +29 -0
+					      u16 return_message_wait)
+{
+	int ret;
+	struct t64uc_message send, recv;
+	struct i2c_msg command_message, return_message;
+	struct dm_i2c_chip *chip = dev_get_parent_plat(ucdev);
+
+	dev_dbg(ucdev, "%s sending cmd %02X len %d\n", __func__, uc_cmd,
+cmd_data_len);
+
+	send.preamb = T64_UC_API_HEADER_PREAMB;
+	send.cmd = uc_cmd;
+	send.len = cmd_data_len;
+	if (uc_cmd_data && cmd_data_len > 0)
+		memcpy(send.data, uc_cmd_data, cmd_data_len);
+
+	command_message.addr = chip->chip_addr;
+	command_message.len = T64_UC_API_MSG_HEADER_SIZE + send.len;
+	command_message.buf = (void *)&send;
+	command_message.flags = I2C_M_STOP;
+
+	ret = dm_i2c_xfer(ucdev, &command_message, 1);
+	if (!return_data)
+		return ret;
+
+	udelay(return_message_wait);
+
+	return_message.addr = chip->chip_addr;
+	return_message.len = T64_UC_API_MSG_HEADER_SIZE +

expected_return_len;

board/traverse/common/ten64_controller.c new file +9 -0
+	return_message.buf = (void *)&recv;
+	return_message.flags = I2C_M_RD;
+
+	ret = dm_i2c_xfer(ucdev, &return_message, 1);
+	if (ret)
+		return ret;
+
+	if (recv.preamb != T64_UC_API_HEADER_PREAMB) {
+		dev_err(ucdev, "%s: No preamble received in microcontroller

response\n",

board/traverse/common/ten64_controller.c new file +5 -0
+			__func__);
+		return -EBADMSG;
+	}
+	if (recv.cmd != uc_cmd) {
+		dev_err(ucdev, "%s: command response mismatch, got %02X

expecting %02X\n",

board/traverse/common/ten64_controller.c new file +5 -0
+			__func__, recv.cmd, uc_cmd);
+		return -EBADMSG;
+	}
+	if (recv.len != expected_return_len) {
+		dev_err(ucdev, "%s: received message has unexpected length,

got %d expected %d\n",

board/traverse/common/ten64_controller.c new file +16 -0
+			__func__, recv.len, expected_return_len);
+		return -EBADMSG;
+	}
+	memcpy(return_data, recv.data, expected_return_len);
+	return ret;
+}
+
+/** ten64_controller_send_command() - Send command to microcontroller
+without
+ * expecting a response (for example, invoking a control command)
+ * @uc_chip: the DM I2C chip handle for the microcontroller
+ * @uc_cmd: the microcontroller API command code
+ * @uc_cmd_data: pointer to the data struct for this command
+ * @uc_data_len: size of command data struct  */ static int
+ten64_controller_send_command(struct udevice *ucdev, u8 uc_cmd,
+					 void *uc_cmd_data, u8 cmd_data_len)

{

board/traverse/common/ten64_controller.c new file +14 -0
+	return ten64_controller_send_recv_command(ucdev, uc_cmd,
+						  uc_cmd_data, cmd_data_len,
+						  NULL, 0, 0);
+}
+
+/** ten64_controller_get_board_info() - Get board information from
+microcontroller
+ * @dev: The microcontroller device handle
+ * @out: Pointer to a t64uc_board_info struct that has been allocated
+by the caller  */ static int ten64_controller_get_board_info(struct
+udevice *dev, struct t64uc_board_info *out) {
+	int ret;
+
+	ret = ten64_controller_send_recv_command(dev,

TEN64_UC_CMD_GET_BOARD_INFO,

board/traverse/common/ten64_controller.c new file +25 -0
+						 NULL, 0, out,
+						 sizeof(struct t64uc_board_info),
+						 10000);
+	if (ret) {
+		dev_err(dev, "%s unable to send board info command: %d\n",
+			__func__, ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+/**
+ * ten64_controller_10g_enable_command() - Sends a 10G (Retimer) enable
+command
+ * to the microcontroller.
+ * @ucdev: The microcontroller udevice
+ * @value: The value flag for the 10G state  */ static int
+ten64_controller_10g_enable_command(struct udevice *ucdev, u8 value) {
+	int ret;
+	struct t64uc_board_10g_enable enable_msg;
+
+	enable_msg.control = value;
+
+	ret = ten64_controller_send_command(ucdev,

TEN64_UC_CMD_ENABLE_10G,

board/traverse/common/ten64_controller.c new file +3 -0
+					    &enable_msg, sizeof(enable_msg));
+	if (ret) {
+		dev_err(ucdev, "ERROR sending uC 10G Enable message: %d\n",

ret);

board/traverse/common/ten64_controller.c new file +7 -0
+		return -1;
+	}
+
+	return 0;
+}
+
+int ten64_controller_call(struct udevice *dev, int msgid, void *tx_msg, int

tx_size,

board/traverse/common/ten64_controller.c new file +5 -0
+			  void *rx_msg, int rx_size)
+{
+	switch (msgid) {
+	case TEN64_CNTRL_GET_BOARD_INFO:
+		return ten64_controller_get_board_info(dev, (struct

t64uc_board_info *)rx_msg);

board/traverse/common/ten64_controller.c new file +2 -0
+	case TEN64_CNTRL_10G_OFF:
+		return ten64_controller_10g_enable_command(dev,

T64_CTRL_IO_CLEAR);

board/traverse/common/ten64_controller.c new file +2 -0
+	case TEN64_CNTRL_10G_ON:
+		return ten64_controller_10g_enable_command(dev,

T64_CTRL_IO_SET);

board/traverse/common/ten64_controller.c new file +21 -1
+	default:
+		dev_err(dev, "%s: Unknown operation %d\n", __func__, msgid);
+	}
+	return -EINVAL;
+}
+
+static struct misc_ops ten64_ctrl_ops  = {
+	.call = ten64_controller_call
+};
+
+static const struct udevice_id ten64_controller_ids[] = {
+	{.compatible = "traverse,ten64-controller"},
+	{}
+};
+
+U_BOOT_DRIVER(ten64_controller) = {
+	.name = "ten64-controller-i2c",
+	.id = UCLASS_MISC,
+	.of_match = ten64_controller_ids,
+	.ops = &ten64_ctrl_ops
+};
--
Quoted 1 line

2.30.1

Many checkpatch warnings and CHECKS in the series. Kindly help to fix.

Regards
Priyanka

#3 lore raw

PATCH 2/2 board: traverse: add initial Ten64 support

In reply to Mathew McBride

The Ten64 is a networking-oriented MiniITX board
using the NXP LS1088A SoC.

This patch provides the bare minimum to support
Ten64 boards under U-Boot for distroboot.

Some related drivers have not yet been submitted
and this basic support lacks some of the
opinionated defaults provided by our firmware
distribution.

---
 arch/arm/Kconfig                   |  16 ++
 arch/arm/dts/Makefile              |   2 +
 arch/arm/dts/fsl-ls1088a-ten64.dts | 377 +++++++++++++++++++++++++
 board/traverse/ten64/Kconfig       |  17 ++
 board/traverse/ten64/MAINTAINERS   |   8 +
 board/traverse/ten64/Makefile      |   6 +
 board/traverse/ten64/eth_ten64.c   |  49 ++++
 board/traverse/ten64/ten64.c       | 433 +++++++++++++++++++++++++++++
 configs/ten64_tfa_defconfig        | 119 ++++++++
 include/configs/ten64.h            |  55 ++++
 10 files changed, 1082 insertions(+)
 create mode 100644 arch/arm/dts/fsl-ls1088a-ten64.dts
 create mode 100644 board/traverse/ten64/Kconfig
 create mode 100644 board/traverse/ten64/MAINTAINERS
 create mode 100644 board/traverse/ten64/Makefile
 create mode 100644 board/traverse/ten64/eth_ten64.c
 create mode 100644 board/traverse/ten64/ten64.c
 create mode 100644 configs/ten64_tfa_defconfig
 create mode 100644 include/configs/ten64.h
arch/arm/Kconfig +16 -0
index b4808d4c75..d732a5a676 100644
@@ -1758,6 +1758,21 @@ config TARGET_SL28
 	help
 	  Support for Kontron SMARC-sAL28 board.
 
+config TARGET_TEN64
+	bool "Support ten64"
+	select ARCH_LS1088A
+	select ARCH_MISC_INIT
+	select ARM64
+	select ARMV8_MULTIENTRY
+	select ARCH_SUPPORT_TFABOOT
+	select BOARD_LATE_INIT
+	select SUPPORT_SPL
+	select FSL_DDR_INTERACTIVE if !SD_BOOT
+	select GPIO_EXTRA_HEADER
+	help
+	  Support for Traverse Technologies Ten64 board, based
+	  on NXP LS1088A.
+
 config TARGET_COLIBRI_PXA270
 	bool "Support colibri_pxa270"
 	select CPU_PXA
@@ -2194,6 +2209,7 @@ source "board/socionext/developerbox/Kconfig"
 source "board/st/stv0991/Kconfig"
 source "board/tcl/sl50/Kconfig"
 source "board/toradex/colibri_pxa270/Kconfig"
+source "board/traverse/ten64/Kconfig"
 source "board/variscite/dart_6ul/Kconfig"
 source "board/vscom/baltos/Kconfig"
 source "board/phytium/durian/Kconfig"
arch/arm/dts/Makefile +2 -0
index cc34da7bd8..2655707a43 100644
@@ -478,6 +478,8 @@ dtb-$(CONFIG_TARGET_SL28) += fsl-ls1028a-kontron-sl28.dtb \
 	fsl-ls1028a-kontron-sl28-var3.dtb \
 	fsl-ls1028a-kontron-sl28-var4.dtb \
 
+dtb-$(CONFIG_TARGET_TEN64) += fsl-ls1088a-ten64.dtb
+
 dtb-$(CONFIG_TARGET_DRAGONBOARD410C) += dragonboard410c.dtb
 dtb-$(CONFIG_TARGET_DRAGONBOARD820C) += dragonboard820c.dtb
 dtb-$(CONFIG_TARGET_STARQLTECHN) += starqltechn.dtb
arch/arm/dts/fsl-ls1088a-ten64.dts new file +377 -0

377 lines not on this page · raw message

board/traverse/ten64/Kconfig new file +17 -0
new file mode 100644
index 0000000000..ea8e3ea20d
@@ -0,0 +1,17 @@
+if TARGET_TEN64
+
+config SYS_BOARD
+	default "ten64"
+
+config SYS_VENDOR
+	default "traverse"
+
+config SYS_SOC
+	default "fsl-layerscape"
+
+config SYS_CONFIG_NAME
+	default "ten64"
+
+endif
+
+source "board/traverse/common/Kconfig"
board/traverse/ten64/MAINTAINERS new file +8 -0
new file mode 100644
index 0000000000..7b53e87938
@@ -0,0 +1,8 @@
+TEN64 BOARD
+M:	Mathew McBride <[email protected]>
+S:	Maintained
+F:	arch/arm/dts/fsl-ls1088a-ten64.dts
+F:	board/traverse/ten64/
+F:	board/traverse/common/
+F:	include/configs/ten64.h
+F:	configs/ten64_tfa_defconfig
board/traverse/ten64/Makefile new file +6 -0
new file mode 100644
index 0000000000..fd8d5cc87b
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += ten64.o
+obj-y += eth_ten64.o
+
+CFLAGS_ten64.o += -DDEBUG
board/traverse/ten64/eth_ten64.c new file +49 -0

49 lines not on this page · raw message

board/traverse/ten64/ten64.c new file +433 -0

433 lines not on this page · raw message

configs/ten64_tfa_defconfig new file +119 -0

119 lines not on this page · raw message

include/configs/ten64.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.30.1