This is an automated email from the ASF dual-hosted git repository.

fdcavalcanti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 6eef3880a039a3a20449b0507569f59931767a74
Author: michal matias <[email protected]>
AuthorDate: Mon Aug 25 03:25:21 2025 +0200

    boards/risc-v/esp32c6: Add support for the OA-TC6 10BASE-T1x MAC-PHYs
    
    Add support for the OA-TC6 10BASE-T1x driver to the ESP32-C6 boards.
    
    Signed-off-by: michal matias <[email protected]>
---
 .../esp32c6/common/include/esp_board_oa_tc6.h      |  73 +++++++
 boards/risc-v/esp32c6/common/src/Make.defs         |   4 +
 .../risc-v/esp32c6/common/src/esp_board_oa_tc6.c   | 212 +++++++++++++++++++++
 .../esp32c6-devkitc/configs/oa_tc6/defconfig       |  74 +++++++
 .../esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c  |  12 ++
 .../esp32c6-devkitm/configs/oa_tc6/defconfig       |  73 +++++++
 .../esp32c6/esp32c6-devkitm/src/esp32c6_bringup.c  |  12 ++
 7 files changed, 460 insertions(+)

diff --git a/boards/risc-v/esp32c6/common/include/esp_board_oa_tc6.h 
b/boards/risc-v/esp32c6/common/include/esp_board_oa_tc6.h
new file mode 100644
index 00000000000..9c225c273fd
--- /dev/null
+++ b/boards/risc-v/esp32c6/common/include/esp_board_oa_tc6.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * boards/risc-v/esp32c6/common/include/esp_board_oa_tc6.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_OA_TC6_H
+#define __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_OA_TC6_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_oa_tc6_initialize
+ *
+ * Description:
+ *   Initialize and register the OA-TC6 10BASE-T1S network driver.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int board_oa_tc6_initialize(void);
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_OA_TC6_H */
diff --git a/boards/risc-v/esp32c6/common/src/Make.defs 
b/boards/risc-v/esp32c6/common/src/Make.defs
index 7563d53da5b..363508adf6b 100644
--- a/boards/risc-v/esp32c6/common/src/Make.defs
+++ b/boards/risc-v/esp32c6/common/src/Make.defs
@@ -86,6 +86,10 @@ ifeq ($(CONFIG_SENSORS_MPU60X0),y)
   CSRCS += esp_board_mpu60x0.c
 endif
 
+ifeq ($(CONFIG_NET_OA_TC6),y)
+  CSRCS += esp_board_oa_tc6.c
+endif
+
 ifeq ($(CONFIG_MMCSD_SPI),y)
   CSRCS += esp_board_mmcsd.c
 endif
diff --git a/boards/risc-v/esp32c6/common/src/esp_board_oa_tc6.c 
b/boards/risc-v/esp32c6/common/src/esp_board_oa_tc6.c
new file mode 100644
index 00000000000..60e40c060a6
--- /dev/null
+++ b/boards/risc-v/esp32c6/common/src/esp_board_oa_tc6.c
@@ -0,0 +1,212 @@
+/****************************************************************************
+ * boards/risc-v/esp32c6/common/src/esp_board_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 <stdint.h>
+#include <stdio.h>
+#include <assert.h>
+#include <debug.h>
+#include <stdbool.h>
+
+#include <nuttx/spi/spi.h>
+#include <nuttx/irq.h>
+#include <nuttx/net/oa_tc6.h>
+
+#include <arch/board/board.h>
+
+#include "espressif/esp_spi.h"
+#include "espressif/esp_gpio.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define BOARD_OA_TC6_0_INT_PIN 5
+
+/****************************************************************************
+ * 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_esp_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,
+};
+
+/****************************************************************************
+ * 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)
+{
+  int pin;
+
+  switch (config->id)
+    {
+      case SPIDEV_ETHERNET(0):
+          pin = BOARD_OA_TC6_0_INT_PIN;
+          break;
+      default:
+
+          /* Unknown id */
+
+          DEBUGPANIC();
+          return ERROR;
+    }
+
+  esp_configgpio(pin, INPUT_FUNCTION_2 | PULLUP);
+  irq_attach(ESP_PIN2IRQ(pin), handler, 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)
+{
+  int pin;
+
+  switch (config->id)
+    {
+      case SPIDEV_ETHERNET(0):
+          pin = BOARD_OA_TC6_0_INT_PIN;
+          break;
+      default:
+
+          /* Unknown id */
+
+          DEBUGPANIC();
+          return ERROR;
+    }
+
+  if (enable)
+    {
+      esp_gpioirqenable(ESP_PIN2IRQ(pin), FALLING);
+    }
+  else
+    {
+      esp_gpioirqdisable(ESP_PIN2IRQ(pin));
+    }
+
+  return OK;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_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 board_oa_tc6_initialize(void)
+{
+  FAR struct spi_dev_s *spi;
+  int ret;
+
+  spi = esp_spibus_initialize(ESPRESSIF_SPI2);
+  if (spi == NULL)
+    {
+      syslog(LOG_ERR,
+             "ERROR: Failed to initialize SPI port %d\n", ESPRESSIF_SPI2);
+      return -ENODEV;
+    }
+
+  /* Bind the SPI port and config to the OA-TC6 driver */
+
+  ret = oa_tc6_initialize(spi, &g_esp_oa_tc6_config);
+  if (ret != OK)
+    {
+      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;
+}
diff --git a/boards/risc-v/esp32c6/esp32c6-devkitc/configs/oa_tc6/defconfig 
b/boards/risc-v/esp32c6/esp32c6-devkitc/configs/oa_tc6/defconfig
new file mode 100644
index 00000000000..cd4d26a3944
--- /dev/null
+++ b/boards/risc-v/esp32c6/esp32c6-devkitc/configs/oa_tc6/defconfig
@@ -0,0 +1,74 @@
+#
+# 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_NDEBUG is not set
+# CONFIG_NSH_ARGCAT is not set
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+CONFIG_ARCH="risc-v"
+CONFIG_ARCH_BOARD="esp32c6-devkitc"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_ESP32C6_DEVKITC=y
+CONFIG_ARCH_CHIP="esp32c6"
+CONFIG_ARCH_CHIP_ESP32C6=y
+CONFIG_ARCH_CHIP_ESP32C6WROOM1=y
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_RISCV=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARD_LOOPSPERMSEC=15000
+CONFIG_BUILTIN=y
+CONFIG_ESPRESSIF_ESP32C6=y
+CONFIG_ESPRESSIF_GPIO_IRQ=y
+CONFIG_ESPRESSIF_SPI2=y
+CONFIG_ESPRESSIF_SPI2_CSPIN=0
+CONFIG_ESPRESSIF_SPI_SWCS=y
+CONFIG_FS_PROCFS=y
+CONFIG_IDLETHREAD_STACKSIZE=2048
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_THROTTLE=24
+CONFIG_LIBC_PERROR_STDOUT=y
+CONFIG_LIBC_STRERROR=y
+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_OA_TC6=y
+CONFIG_NET_OA_TC6_LAN865X=y
+CONFIG_NET_OA_TC6_NCV7410=y
+CONFIG_NET_STATISTICS=y
+CONFIG_NET_TCP=y
+CONFIG_NET_TCP_DELAYED_ACK=y
+CONFIG_NET_TCP_WRITE_BUFFERS=y
+CONFIG_NET_UDP=y
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_NSH_STRERROR=y
+CONFIG_PREALLOC_TIMERS=0
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_BACKTRACE=y
+CONFIG_SCHED_LPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=29
+CONFIG_START_MONTH=11
+CONFIG_START_YEAR=2019
+CONFIG_SYSTEM_DHCPC_RENEW=y
+CONFIG_SYSTEM_DUMPSTACK=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_PING=y
+CONFIG_TESTING_GETPRIME=y
+CONFIG_TESTING_OSTEST=y
+CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c 
b/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c
index aa3a2d804d3..69ba885e590 100644
--- a/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c
+++ b/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c
@@ -129,6 +129,10 @@
 #  include "espressif/esp_sha.h"
 #endif
 
+#ifdef CONFIG_NET_OA_TC6
+#  include "esp_board_oa_tc6.h"
+#endif
+
 #ifdef CONFIG_MMCSD_SPI
 #  include "esp_board_mmcsd.h"
 #endif
@@ -512,6 +516,14 @@ int esp_bringup(void)
   esp_ulp_init();
 #endif
 
+#ifdef CONFIG_NET_OA_TC6
+  ret = board_oa_tc6_initialize();
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: esp_oa_tc6_initialize failed: %d\n", ret);
+    }
+#endif
+
   /* If we got here then perhaps not all initialization was successful, but
    * at least enough succeeded to bring-up NSH with perhaps reduced
    * capabilities.
diff --git a/boards/risc-v/esp32c6/esp32c6-devkitm/configs/oa_tc6/defconfig 
b/boards/risc-v/esp32c6/esp32c6-devkitm/configs/oa_tc6/defconfig
new file mode 100644
index 00000000000..a97027cb88d
--- /dev/null
+++ b/boards/risc-v/esp32c6/esp32c6-devkitm/configs/oa_tc6/defconfig
@@ -0,0 +1,73 @@
+#
+# 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_NSH_ARGCAT is not set
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+CONFIG_ARCH="risc-v"
+CONFIG_ARCH_BOARD="esp32c6-devkitm"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_ESP32C6_DEVKITM=y
+CONFIG_ARCH_CHIP="esp32c6"
+CONFIG_ARCH_CHIP_ESP32C6=y
+CONFIG_ARCH_CHIP_ESP32C6MINI1=y
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_RISCV=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARD_LOOPSPERMSEC=15000
+CONFIG_BUILTIN=y
+CONFIG_ESPRESSIF_ESP32C6=y
+CONFIG_ESPRESSIF_GPIO_IRQ=y
+CONFIG_ESPRESSIF_SPI2=y
+CONFIG_ESPRESSIF_SPI2_CSPIN=0
+CONFIG_ESPRESSIF_SPI_SWCS=y
+CONFIG_FS_PROCFS=y
+CONFIG_IDLETHREAD_STACKSIZE=2048
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_THROTTLE=24
+CONFIG_LIBC_PERROR_STDOUT=y
+CONFIG_LIBC_STRERROR=y
+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_OA_TC6=y
+CONFIG_NET_OA_TC6_LAN865X=y
+CONFIG_NET_OA_TC6_NCV7410=y
+CONFIG_NET_STATISTICS=y
+CONFIG_NET_TCP=y
+CONFIG_NET_TCP_DELAYED_ACK=y
+CONFIG_NET_TCP_WRITE_BUFFERS=y
+CONFIG_NET_UDP=y
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_NSH_STRERROR=y
+CONFIG_PREALLOC_TIMERS=0
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_BACKTRACE=y
+CONFIG_SCHED_LPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=29
+CONFIG_START_MONTH=11
+CONFIG_START_YEAR=2019
+CONFIG_SYSTEM_DHCPC_RENEW=y
+CONFIG_SYSTEM_DUMPSTACK=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_PING=y
+CONFIG_TESTING_GETPRIME=y
+CONFIG_TESTING_OSTEST=y
+CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/risc-v/esp32c6/esp32c6-devkitm/src/esp32c6_bringup.c 
b/boards/risc-v/esp32c6/esp32c6-devkitm/src/esp32c6_bringup.c
index f685600fdd6..78093baef17 100644
--- a/boards/risc-v/esp32c6/esp32c6-devkitm/src/esp32c6_bringup.c
+++ b/boards/risc-v/esp32c6/esp32c6-devkitm/src/esp32c6_bringup.c
@@ -113,6 +113,10 @@
 #  include "espressif/esp_sdm.h"
 #endif
 
+#ifdef CONFIG_NET_OA_TC6
+#  include "esp_board_oa_tc6.h"
+#endif
+
 #include "esp32c6-devkitm.h"
 
 /****************************************************************************
@@ -421,6 +425,14 @@ int esp_bringup(void)
     }
 #endif
 
+#ifdef CONFIG_NET_OA_TC6
+  ret = board_oa_tc6_initialize();
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: esp_oa_tc6_initialize failed: %d\n", ret);
+    }
+#endif
+
   /* If we got here then perhaps not all initialization was successful, but
    * at least enough succeeded to bring-up NSH with perhaps reduced
    * capabilities.

Reply via email to