boards/nucleo-h723zg: Add support for the OA-TC6 10BASE-T1S SPI Ethernet

Add support for the 10BASE-T1S SPI MAC-PHYs based on the OA-TC6 protocol.

Signed-off-by: Michal Matias <mich4l.matias@gmail.com>
This commit is contained in:
Michal Matias
2026-03-02 02:42:35 +01:00
committed by Alan C. Assis
parent 9a10ea0277
commit a3ec08c0d8
7 changed files with 350 additions and 0 deletions
@@ -0,0 +1,88 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_STANDARD_SERIAL is not set
# CONFIG_STM32H7_USE_LEGACY_PINMAP is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="nucleo-h723zg"
CONFIG_ARCH_BOARD_NUCLEO_H723ZG=y
CONFIG_ARCH_CHIP="stm32h7"
CONFIG_ARCH_CHIP_STM32H723ZG=y
CONFIG_ARCH_CHIP_STM32H7=y
CONFIG_ARCH_CHIP_STM32H7_CORTEXM7=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
CONFIG_ARMV7M_DTCM=y
CONFIG_ARMV7M_ICACHE=y
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=43103
CONFIG_BUILTIN=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_NET=y
CONFIG_DEBUG_NET_ERROR=y
CONFIG_DEBUG_NET_INFO=y
CONFIG_DEBUG_NET_WARN=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_EXPERIMENTAL=y
CONFIG_FS_PROCFS=y
CONFIG_FS_PROCFS_REGISTER=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=4096
CONFIG_INTELHEX_BINARY=y
CONFIG_LINE_MAX=64
CONFIG_MM_REGIONS=4
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDEV_LATEINIT=y
CONFIG_NETDEV_PHY_IOCTL=y
CONFIG_NETUTILS_PLCATOOL=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMPv6=y
CONFIG_NET_IPFRAG=y
CONFIG_NET_IPv6=y
CONFIG_NET_LOOPBACK=y
CONFIG_NET_OA_TC6=y
CONFIG_NET_OA_TC6_LAN865X=y
CONFIG_NET_OA_TC6_NCV7410=y
CONFIG_NET_OA_TC6_NCV7410_LEDS=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_DELAYED_ACK=y
CONFIG_NET_TCP_KEEPALIVE=y
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_UDP=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=131072
CONFIG_RAM_START=0x24000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_STM32H7_DTCMEXCLUDE=y
CONFIG_STM32H7_FLASH_OVERRIDE_G=y
CONFIG_STM32H7_SPI3=y
CONFIG_STM32H7_SRAM4EXCLUDE=y
CONFIG_STM32H7_USART3=y
CONFIG_SYSTEM_DHCPC_RENEW=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_PING6=y
CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_SERIAL_CONSOLE=y
@@ -64,6 +64,10 @@ if(CONFIG_BOARDCTL_RESET)
list(APPEND SRCS stm32_reset.c)
endif()
if(CONFIG_NET_OA_TC6)
list(APPEND SRCS stm32_oa_tc6.c)
endif()
target_sources(board PRIVATE ${SRCS})
if(CONFIG_STM32_APP_FORMAT_MCUBOOT)
@@ -66,4 +66,8 @@ ifeq ($(CONFIG_BOARDCTL_RESET),y)
CSRCS += stm32_reset.c
endif
ifeq ($(CONFIG_NET_OA_TC6), y)
CSRCS += stm32_oa_tc6.c
endif
include $(TOPDIR)/boards/Board.mk
@@ -170,6 +170,19 @@
GPIO_OUTPUT_SET | GPIO_PORTE | GPIO_PIN4)
#define GPIO_INT1 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTE | GPIO_PIN5)
/* OA-TC6 SPI CS + INT signal mapping
* MOSI - PB5 (D22)
* CLK - PB3 (D23)
* MISO - PB4 (D25)
* CS - PD14 (D10)
* INT - PF3 (D8)
*/
#define GPIO_OA_TC6_SPI_PORT 3
#define GPIO_OA_TC6_CS (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
GPIO_OUTPUT_SET | GPIO_PORTD | GPIO_PIN14)
#define GPIO_OA_TC6_INT (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTF | GPIO_PIN3)
/* PWM */
#define NUCLEOH723ZG_PWMTIMER 1
@@ -257,4 +270,16 @@ void weak_function stm32_usbinitialize(void);
int stm32_pwm_setup(void);
#endif
/****************************************************************************
* Name: stm32_oa_tc6_initialize
*
* Description:
* Initialize OA-TC6 10BASE-T1S subsystem.
*
****************************************************************************/
#ifdef CONFIG_NET_OA_TC6
int stm32_oa_tc6_initialize(void);
#endif
#endif /* __BOARDS_ARM_STM32H7_NUCLEO_H723ZG_SRC_NUCLEO_H723ZG_H */
@@ -216,5 +216,9 @@ int stm32_bringup(void)
}
#endif
#ifdef CONFIG_NET_OA_TC6
stm32_oa_tc6_initialize();
#endif
return OK;
}
@@ -0,0 +1,212 @@
/****************************************************************************
* boards/arm/stm32h7/nucleo-h723zg/src/stm32_oa_tc6.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/spi/spi.h>
#include <nuttx/irq.h>
#include <nuttx/net/oa_tc6.h>
#include "stm32.h"
#include "nucleo-h723zg.h"
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int board_oa_tc6_attach(FAR const struct oa_tc6_config_s *config,
xcpt_t handler,
FAR void *arg);
static int board_oa_tc6_enable(FAR const struct oa_tc6_config_s *config,
bool enable);
/****************************************************************************
* Private Data
****************************************************************************/
static const struct oa_tc6_config_s g_stm32_oa_tc6_config =
{
.id = SPIDEV_ETHERNET(0),
.frequency = 25000000,
.chunk_payload_size = 64,
.rx_cut_through = true,
.attach = board_oa_tc6_attach,
.enable = board_oa_tc6_enable,
};
static xcpt_t g_stm32_oa_tc6_isr = NULL;
static void *g_stm32_oa_tc6_isr_arg = NULL;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: board_oa_tc6_attach
*
* Description:
* Configure interrupt and attach handler to the interrupt signal
* from the MAC-PHY.
*
* Input Parameters:
* config - reference to the MAC-PHY configuration
* handler - the interrupt handler function
* arg - reference passed to the handler on invocation
*
* Returned Value:
* On success OK is returned, otherwise ERROR is returned.
*
****************************************************************************/
static int board_oa_tc6_attach(FAR const struct oa_tc6_config_s *config,
xcpt_t handler, FAR void *arg)
{
uint32_t pin;
switch (config->id)
{
case SPIDEV_ETHERNET(0):
pin = GPIO_OA_TC6_INT;
break;
default:
/* Unknown id */
DEBUGPANIC();
return ERROR;
}
/* Configure pin and disable all possible interrupt events */
stm32_configgpio(pin);
stm32_gpiosetevent(pin, false, false, false, NULL, NULL);
g_stm32_oa_tc6_isr = handler;
g_stm32_oa_tc6_isr_arg = arg;
return OK;
}
/****************************************************************************
* Name: board_oa_tc6_enable
*
* Description:
* Enable or disable the interrupt on the hardware level.
* Enable when the enable argument is true, otherwise disable.
*
* Input Parameters:
* config - reference to the MAC-PHY configuration
* enable - enable / disable control
*
* Returned Value:
* On success OK is returned, otherwise ERROR is returned.
*
****************************************************************************/
static int board_oa_tc6_enable(FAR const struct oa_tc6_config_s *config,
bool enable)
{
uint32_t pin;
switch (config->id)
{
case SPIDEV_ETHERNET(0):
pin = GPIO_OA_TC6_INT;
break;
default:
/* Unknown id */
DEBUGPANIC();
return ERROR;
}
DEBUGASSERT(g_stm32_oa_tc6_isr != NULL && g_stm32_oa_tc6_isr_arg != NULL);
if (enable)
{
/* Enable interrupt on the falling edge */
stm32_gpiosetevent(pin, false, true, false,
g_stm32_oa_tc6_isr, g_stm32_oa_tc6_isr_arg);
}
else
{
stm32_gpiosetevent(pin, false, false, false, NULL, NULL);
}
return OK;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_oa_tc6_initialize
*
* Description:
* Initialize and register the OA-TC6 10BASE-T1x network driver.
*
* Input Parameters:
* None
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int stm32_oa_tc6_initialize(void)
{
FAR struct spi_dev_s *spi;
int ret;
spi = stm32_spibus_initialize(GPIO_OA_TC6_SPI_PORT);
if (!spi)
{
syslog(LOG_ERR, "ERROR: Failed to initialize SPI port %d\n",
GPIO_OA_TC6_SPI_PORT);
return -ENODEV;
}
/* Bind the SPI port and config to the OA-TC6 driver */
ret = oa_tc6_initialize(spi, &g_stm32_oa_tc6_config);
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to bind SPI port and config to the OA-TC6"
" network driver: %d\n", ret);
return ret;
}
syslog(LOG_INFO,
"Bound SPI and config to the OA-TC6 network driver\n");
return OK;
}
@@ -65,6 +65,13 @@ void stm32_spidev_initialize(void)
#ifdef CONFIG_STM32H7_SPI3
spiinfo("Configure GPIO for SPI3/CS\n");
# ifdef CONFIG_NET_OA_TC6
/* Configure the SPI-based chip select GPIO for OA_TC6 MAC-PHYs */
stm32_configgpio(GPIO_OA_TC6_CS);
stm32_gpiowrite(GPIO_OA_TC6_CS, true);
# endif
#endif
}
@@ -128,6 +135,12 @@ void stm32_spi3select(struct spi_dev_s *dev,
{
switch (devid)
{
#ifdef CONFIG_NET_OA_TC6
case SPIDEV_ETHERNET(0):
stm32_gpiowrite(GPIO_OA_TC6_CS, !selected);
break;
#endif
default:
break;
}