drivers/net/oa_tc6: Add driver for the Onsemi NCV7410 (NCN26010) SPI MAC-PHY

Add driver for the Onsemi NCV7410 10BASE-T1S SPI MAC-PHY.
The driver also works for the NCN26010, which is an identical chip.
The driver is a lower-half driver to the OA-TC6 base driver.

Signed-off-by: michal matias <mich4l.matias@gmail.com>
This commit is contained in:
michal matias
2025-09-03 00:53:03 +08:00
committed by Xiang Xiao
parent 95b3b65778
commit fbb3b6d07b
7 changed files with 825 additions and 0 deletions
+4
View File
@@ -23,5 +23,9 @@
if(CONFIG_NET_OA_TC6)
set(SRCS oa_tc6.c)
if(CONFIG_NET_OA_TC6_NCV7410)
list(APPEND SRCS oa_tc6_ncv7410.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()
+15
View File
@@ -9,3 +9,18 @@ menuconfig NET_OA_TC6
depends on NETDEVICES
---help---
Enable support for OPEN Alliance protocol SPI MAC-PHYs.
if NET_OA_TC6
config NET_OA_TC6_NCV7410
bool "Onsemi NCV7410 (NCN26010) 10BASE-T1S SPI MAC-PHY Support"
default n
config NET_OA_TC6_NCV7410_LEDS
bool "Setup NCV7410 DIO outputs as status LEDs"
default n
depends on NET_OA_TC6_NCV7410
---help---
Setup DIO0 to blink on TX/RX and DIO1 to reflect the LCTL bit in the PHY CONTROL register (Up/Down).
endif
+4
View File
@@ -24,6 +24,10 @@ ifeq ($(CONFIG_NET_OA_TC6),y)
CSRCS += oa_tc6.c
ifeq ($(CONFIG_NET_OA_TC6_NCV7410),y)
CSRCS += oa_tc6_ncv7410.c
endif
DEPPATH += --dep-path net/oa_tc6
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)drivers$(DELIM)net$(DELIM)oa_tc6
VPATH += :net/oa_tc6
+9
View File
@@ -32,6 +32,10 @@
#include <nuttx/net/ioctl.h>
#ifdef CONFIG_NET_OA_TC6_NCV7410
#include "oa_tc6_ncv7410.h"
#endif
#include "oa_tc6.h"
/****************************************************************************
@@ -1072,6 +1076,11 @@ static int oa_tc6_init_by_id(FAR struct spi_dev_s *spi,
{
switch (phyid)
{
#ifdef CONFIG_NET_OA_TC6_NCV7410
case OA_TC6_NCV7410_PHYID:
ninfo("Info: Detected NCV7410 or NCN26010\n");
return ncv7410_initialize(spi, config);
#endif
default:
nerr("Error: Unknown PHYID 0x%08lX. "
"Is the support enabled in Kconfig? "
File diff suppressed because it is too large Load Diff
+101
View File
@@ -0,0 +1,101 @@
/****************************************************************************
* drivers/net/oa_tc6/oa_tc6_ncv7410.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 __DRIVERS_NET_OA_TC6_NCV7410_H
#define __DRIVERS_NET_OA_TC6_NCV7410_H
/****************************************************************************
* Included Files
****************************************************************************/
#include "oa_tc6.h"
/****************************************************************************
* Preprocessor Macros
****************************************************************************/
/* The PHYID of the NCN26010 chip is identical */
#define OA_TC6_NCV7410_PHYID 0xBC0189A1U
/* Registers specific to the NCV7410 */
#define NCV_PHY_CONTROL_LCTL_POS 12
#define NCV_MAC_CONTROL0_MMS 1
#define NCV_MAC_CONTROL0_ADDR 0x0U
#define NCV_MAC_CONTROL0_REGID OA_TC6_MAKE_REGID(NCV_MAC_CONTROL0_MMS, NCV_MAC_CONTROL0_ADDR)
#define NCV_MAC_CONTROL0_ADRF_POS 16
#define NCV_MAC_CONTROL0_FCSA_POS 8
#define NCV_MAC_CONTROL0_TXEN_POS 1
#define NCV_MAC_CONTROL0_RXEN_POS 0
#define NCV_ADDRFILT0L_MMS 1
#define NCV_ADDRFILT0L_ADDR 0x10U
#define NCV_ADDRFILT0L_REGID OA_TC6_MAKE_REGID(NCV_ADDRFILT0L_MMS, NCV_ADDRFILT0L_ADDR)
#define NCV_ADDRFILT0H_MMS 1
#define NCV_ADDRFILT0H_ADDR 0x11U
#define NCV_ADDRFILT0H_REGID OA_TC6_MAKE_REGID(NCV_ADDRFILT0H_MMS, NCV_ADDRFILT0H_ADDR)
#define NCV_ADDRMASK0L_MMS 1
#define NCV_ADDRMASK0L_ADDR 0x20U
#define NCV_ADDRMASK0L_REGID OA_TC6_MAKE_REGID(NCV_ADDRMASK0L_MMS, NCV_ADDRMASK0L_ADDR)
#define NCV_ADDRMASK0H_MMS 1
#define NCV_ADDRMASK0H_ADDR 0x21U
#define NCV_ADDRMASK0H_REGID OA_TC6_MAKE_REGID(NCV_ADDRMASK0H_MMS, NCV_ADDRMASK0H_ADDR)
#define NCV_ADDRFILTL_REGID(i) OA_TC6_MAKE_REGID(NCV_ADDRFILT0L_MMS, NCV_ADDRFILT0L_ADDR + 4 * i)
#define NCV_ADDRFILTH_REGID(i) OA_TC6_MAKE_REGID(NCV_ADDRFILT0H_MMS, NCV_ADDRFILT0H_ADDR + 4 * i)
#define NCV_ADDRMASKL_REGID(i) OA_TC6_MAKE_REGID(NCV_ADDRMASK0L_MMS, NCV_ADDRMASK0L_ADDR + 4 * i)
#define NCV_ADDRMASKH_REGID(i) OA_TC6_MAKE_REGID(NCV_ADDRMASK0H_MMS, NCV_ADDRMASK0H_ADDR + 4 * i)
#define NCV_DIO_CONFIG_MMS 12
#define NCV_DIO_CONFIG_ADDR 0x0012U
#define NCV_DIO_CONFIG_REGID OA_TC6_MAKE_REGID(NCV_DIO_CONFIG_MMS, NCV_DIO_CONFIG_ADDR)
#define NCV_DIO_CONFIG_DEF 0x6060
#define NCV_DIO0_FUNC_POS 1
#define NCV_DIO1_FUNC_POS 9
#define NCV_DIO0_OUT_VAL_POS 0
#define NCV_DIO1_OUT_VAL_POS 8
#define NCV_DIO_TRISTATE_FUNC 0x0
#define NCV_DIO_GPIO_FUNC 0x1
#define NCV_DIO_SFD_TX_FUNC 0x2
#define NCV_DIO_SFD_RX_FUNC 0x3
#define NCV_DIO_LINK_CTRL_FUNC 0x4
#define NCV_DIO_SFD_TXRX_FUNC 0xB
#define NCV_DIO_TXRX_FUNC 0xF
#define NCV_MACID0_MMS 12
#define NCV_MACID0_ADDR 0x1002U
#define NCV_MACID0_REGID OA_TC6_MAKE_REGID(NCV_MACID0_MMS, NCV_MACID0_ADDR)
#define NCV_MACID0_MASK GENMASK(15, 0)
#define NCV_MACID0_POS 0
#define NCV_MACID1_MMS 12
#define NCV_MACID1_ADDR 0x1003U
#define NCV_MACID1_REGID OA_TC6_MAKE_REGID(NCV_MACID1_MMS, NCV_MACID1_ADDR)
#define NCV_MACID1_MASK GENMASK(7, 0)
#define NCV_MACID1_POS 0
#endif /* __DRIVERS_NET_OA_TC6_NCV7410_H */
+21
View File
@@ -94,6 +94,27 @@ struct spi_dev_s; /* forward declaration, see nuttx/spi/spi.h */
int oa_tc6_initialize(FAR struct spi_dev_s *spi,
FAR const struct oa_tc6_config_s *config);
/****************************************************************************
* Name: ncv7410_initialize
*
* Description:
* Initialize and register the OA-TC6 and the NCV7410 (NCN26010) drivers.
* This function is called by the oa_tc6_initialize upon detecting
* the NCV7410 MAC-PHY on the SPI, but it also may be called directly from
* the board level code.
*
* Input Parameters:
* spi - pointer to the initialized SPI interface
* config - pointer to the initialized MAC-PHY configuration
*
* Returned Value:
* On success OK is returned, otherwise negated errno is returned.
*
****************************************************************************/
int ncv7410_initialize(FAR struct spi_dev_s *spi,
FAR const struct oa_tc6_config_s *config);
#undef EXTERN
#ifdef __cplusplus
}