mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
arch/arm64/src/imx9: Add Ethernet driver
This adds a driver for i.MX93 ENET1 MAC block Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
9277be2503
commit
cc9c3ed80b
@@ -316,6 +316,12 @@ endmenu # USB device controller driver (DCD) options
|
||||
|
||||
endif # IMX9_USBDEV
|
||||
|
||||
config IMX9_ENET
|
||||
bool "Ethernet"
|
||||
default n
|
||||
select ARCH_HAVE_PHY
|
||||
select ARCH_HAVE_NETDEV_STATISTICS
|
||||
|
||||
config IMX9_GPIO_IRQ
|
||||
bool "GPIO Interrupt Support"
|
||||
default n
|
||||
@@ -783,6 +789,113 @@ config IMX9_LPSPI8_DMA
|
||||
|
||||
endmenu # LPSPI Configuration
|
||||
|
||||
menu "Ethernet Configuration"
|
||||
depends on IMX9_ENET
|
||||
|
||||
config IMX9_ENET1
|
||||
bool "Ethernet MAC (non-QoS)"
|
||||
depends on IMX9_ENET
|
||||
default y
|
||||
|
||||
config IMX9_ENET_NRXBUFFERS
|
||||
int "Number of Rx buffers"
|
||||
default 6
|
||||
|
||||
config IMX9_ENET_NTXBUFFERS
|
||||
int "Number of Tx buffers"
|
||||
default 2
|
||||
|
||||
config IMX9_ENET_USE_OTP_MAC
|
||||
bool "Use MAC address from OCOTP"
|
||||
default n
|
||||
depends on IMX9_ENET
|
||||
|
||||
config IMX9_ENET1_OTP_MAC_ADDR
|
||||
hex "MAC address offset in OCOTP"
|
||||
default 0x4ec
|
||||
depends on IMX9_ENET_USE_OTP_MAC
|
||||
|
||||
config IMX9_ENET1_PROMISCUOUS
|
||||
bool "Set promiscuous mode"
|
||||
depends on IMX9_ENET1
|
||||
default n
|
||||
|
||||
choice
|
||||
prompt "i.MX9 ENET1 interface type"
|
||||
default IMX9_ENET1_RMII
|
||||
depends on IMX9_ENET1
|
||||
|
||||
config IMX9_ENET1_RMII
|
||||
bool "RMII"
|
||||
|
||||
config IMX9_ENET1_RGMII
|
||||
bool "RGMII"
|
||||
|
||||
endchoice
|
||||
|
||||
config IMX9_ENET1_PHY_AUTONEG
|
||||
bool "ENET1 PHY autonegotiation enable"
|
||||
default y
|
||||
---help---
|
||||
Enable PHY autonegotiation. If set to n, configure the speed
|
||||
and duplex mode manually. Note that only disabling this doesn't
|
||||
disable the autonegotiation completely; it just sets the MAC
|
||||
speed and duplex, and disables autonegotiation advertisement
|
||||
for other than the configured mode. To disable autonegotiation
|
||||
completely, also set the FORCE_SPEED flag.
|
||||
|
||||
choice
|
||||
prompt "Select ENET1 PHY link duplex mode"
|
||||
default IMX9_ENET1_PHY_FD
|
||||
depends on !IMX9_ENET1_PHY_AUTONEG
|
||||
|
||||
config IMX9_ENET1_PHY_FD
|
||||
bool "Full Duplex"
|
||||
|
||||
config IMX9_ENET1_PHY_HD
|
||||
bool "Half Duplex"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Select ENET1 PHY link speed"
|
||||
default IMX9_ENET1_PHY_100MBPS if IMX9_ENET1_RMII
|
||||
default IMX9_ENET1_PHY_1000MBPS if IMX9_ENET1_RGMII
|
||||
depends on !IMX9_ENET1_PHY_AUTONEG
|
||||
|
||||
config IMX9_ENET1_PHY_10MBPS
|
||||
bool "10 MBPS"
|
||||
|
||||
config IMX9_ENET1_PHY_100MBPS
|
||||
bool "100 MBPS"
|
||||
|
||||
config IMX9_ENET1_PHY_1000MBPS
|
||||
bool "1000 MBPS"
|
||||
depends on IMX9_ENET1_RGMII
|
||||
endchoice
|
||||
|
||||
config IMX9_ENET1_PHY_FORCE_SPEED
|
||||
bool "Disable PHY autonegotiation and force speed and duplex"
|
||||
depends on !IMX9_ENET1_PHY_AUTONEG
|
||||
default n
|
||||
---help---
|
||||
This disables PHY autonegotiation completely. Note that
|
||||
if the link partner has got autonegotiation enabled, the
|
||||
duplex mode is not auto-detected by the link partner. Only
|
||||
enable if you really know what you are doing!
|
||||
|
||||
config IMX9_ENET1_PHYINIT
|
||||
bool "Board-specific PHY Initialization for ENET1"
|
||||
default n
|
||||
---help---
|
||||
Some boards require specialized initialization of the PHY before it
|
||||
can be used. This may include such things as configuring GPIOs,
|
||||
resetting the PHY, etc. If CONFIG_IMX9_ENET_PHYINIT is defined in
|
||||
the configuration then the board specific logic must provide
|
||||
imx9_phy_boardinitialize(); The i.MX9 ENET driver will call this
|
||||
function one time before it first uses the PHY.
|
||||
|
||||
endmenu # IMX9_ENET
|
||||
|
||||
endmenu # iMX Peripheral Selection
|
||||
|
||||
endif # ARCH_CHIP_IMX9
|
||||
|
||||
@@ -59,3 +59,7 @@ endif
|
||||
ifeq ($(CONFIG_IMX9_DMA_ALLOC),y)
|
||||
CHIP_CSRCS += imx9_dma_alloc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_IMX9_ENET),y)
|
||||
CHIP_CSRCS += imx9_enet.c
|
||||
endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,106 @@
|
||||
/****************************************************************************
|
||||
* arch/arm64/src/imx9/imx9_enet.h
|
||||
*
|
||||
* 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 __ARCH_ARM64_SRC_IMX9_IMX9_ENET_H
|
||||
#define __ARCH_ARM64_SRC_IMX9_IMX9_ENET_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "hardware/imx9_enet.h"
|
||||
|
||||
#ifdef CONFIG_IMX9_ENET
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Definitions for use with imx9_phy_boardinitialize */
|
||||
|
||||
#define EMAC_INTF 0
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: imx9_netinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the Ethernet controller and driver
|
||||
*
|
||||
* Input Parameters:
|
||||
* intf - In the case where there are multiple EMACs, this value
|
||||
* identifies which EMAC is to be initialized.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; Negated errno on failure.
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int imx9_netinitialize(int intf);
|
||||
|
||||
/****************************************************************************
|
||||
* Function: imx9_phy_boardinitialize
|
||||
*
|
||||
* Description:
|
||||
* Some boards require specialized initialization of the PHY before it can
|
||||
* be used. This may include such things as configuring GPIOs, resetting
|
||||
* the PHY, etc. If CONFIG_IMX9_ENET_PHYINIT is defined in the
|
||||
* configuration then the board specific logic must provide
|
||||
* imx9_phyinitialize(); The i.MX RT Ethernet driver will call this
|
||||
* function one time before it first uses the PHY.
|
||||
*
|
||||
* Input Parameters:
|
||||
* intf - Always zero for now.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; Negated errno on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_IMX9_ENET_PHYINIT
|
||||
int imx9_phy_boardinitialize(int intf);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* CONFIG_IMX9_ENET */
|
||||
#endif /* __ARCH_ARM_SRC_IMX9_IMX9_ENET_H */
|
||||
@@ -22,7 +22,10 @@ CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEFAULT_TASK_STACKSIZE=8192
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_ETH0_PHY_MULTI=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXAMPLES_TCPBLASTER=y
|
||||
CONFIG_EXAMPLES_UDPBLASTER=y
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_ROMFS=y
|
||||
@@ -35,6 +38,9 @@ CONFIG_IDLETHREAD_STACKSIZE=8192
|
||||
CONFIG_IMX9_DMA_ALLOC=y
|
||||
CONFIG_IMX9_DMA_ALLOC_POOL_SIZE=81920
|
||||
CONFIG_IMX9_EDMA=y
|
||||
CONFIG_IMX9_ENET1_RGMII=y
|
||||
CONFIG_IMX9_ENET=y
|
||||
CONFIG_IMX9_ENET_USE_OTP_MAC=y
|
||||
CONFIG_IMX9_FLEXIO1_PWM=y
|
||||
CONFIG_IMX9_GPIO_IRQ=y
|
||||
CONFIG_IMX9_LPI2C1=y
|
||||
@@ -52,6 +58,14 @@ CONFIG_IMX9_USBDEV_USBC1=y
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LPUART1_SERIAL_CONSOLE=y
|
||||
CONFIG_NDEBUG=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NET_ICMP=y
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
@@ -78,6 +92,7 @@ CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_SYSTEM_CDCACM=y
|
||||
CONFIG_SYSTEM_I2CTOOL=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_SYSTEM_SPITOOL=y
|
||||
CONFIG_SYSTEM_SYSTEM=y
|
||||
CONFIG_SYSTEM_TIME64=y
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/net/mii.h>
|
||||
#include <nuttx/net/gmii.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@@ -121,6 +123,85 @@
|
||||
PFD_CFG(IMX9_SYSPLL_BASE, 2, PFD_PARMS(6, 2, true)), \
|
||||
}
|
||||
|
||||
/* Ethernet configuration */
|
||||
|
||||
#define BOARD_ENET1_PHY_LIST \
|
||||
{ \
|
||||
{ \
|
||||
.name = GMII_RTL8211F_NAME, \
|
||||
.id1 = GMII_PHYID1_RTL8211F, \
|
||||
.id2 = GMII_PHYID2_RTL8211F, \
|
||||
.status = GMII_RTL8211F_PHYSR_A43, \
|
||||
.address_lo = 2, \
|
||||
.address_high = 0xffff, \
|
||||
.mbps10 = GMII_RTL8211F_PHYSR_10MBPS, \
|
||||
.mbps100 = GMII_RTL8211F_PHYSR_100MBPS, \
|
||||
.duplex = GMII_RTL8211F_PHYSR_DUPLEX, \
|
||||
.clause = 22, \
|
||||
.mbps1000 = GMII_RTL8211F_PHYSR_1000MBPS, \
|
||||
.speed_mask = GMII_RTL8211F_PHYSR_SPEED_MASK, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#endif /* CONFIG_IMX9_ENET1 */
|
||||
|
||||
#ifdef CONFIG_IMX9_ENET1
|
||||
|
||||
#define MUX_ENET1_MDIO IOMUX_CFG(IOMUXC_PAD_ENET2_MDIO_ENET1_MDIO, IOMUXC_PAD_FSEL_FAST | IOMUXC_PAD_DSE_X6, IOMUXC_MUX_SION_ON)
|
||||
#define MUX_ENET1_MDC IOMUX_CFG(IOMUXC_PAD_ENET2_MDC_ENET1_MDC, IOMUXC_PAD_FSEL_FAST | IOMUXC_PAD_DSE_X6, 0)
|
||||
|
||||
#define MUX_ENET1_RX_DATA00 IOMUX_CFG(IOMUXC_PAD_ENET2_RD0_ENET1_RGMII_RD0, 0, 0)
|
||||
#define MUX_ENET1_RX_DATA01 IOMUX_CFG(IOMUXC_PAD_ENET2_RD1_ENET1_RGMII_RD1, 0, 0)
|
||||
|
||||
#define MUX_ENET1_TX_DATA00 IOMUX_CFG(IOMUXC_PAD_ENET2_TD0_ENET1_RGMII_TD0, IOMUXC_PAD_FSEL_FAST | IOMUXC_PAD_DSE_X6, 0)
|
||||
#define MUX_ENET1_TX_DATA01 IOMUX_CFG(IOMUXC_PAD_ENET2_TD1_ENET1_RGMII_TD1, IOMUXC_PAD_FSEL_FAST | IOMUXC_PAD_DSE_X6, 0)
|
||||
|
||||
#if defined(CONFIG_IMX9_ENET1_RGMII)
|
||||
|
||||
# define MUX_ENET1_RX_DATA02 IOMUX_CFG(IOMUXC_PAD_ENET2_RD2_ENET1_RGMII_RD2, 0, 0)
|
||||
# define MUX_ENET1_RX_DATA03 IOMUX_CFG(IOMUXC_PAD_ENET2_RD3_ENET1_RGMII_RD3, 0, 0)
|
||||
# define MUX_ENET1_TX_DATA02 IOMUX_CFG(IOMUXC_PAD_ENET2_TD2_ENET1_RGMII_TD2, IOMUXC_PAD_FSEL_FAST | IOMUXC_PAD_DSE_X6, 0)
|
||||
# define MUX_ENET1_TX_DATA03 IOMUX_CFG(IOMUXC_PAD_ENET2_TD3_ENET1_RGMII_TD3, IOMUXC_PAD_FSEL_FAST | IOMUXC_PAD_DSE_X6, 0)
|
||||
# define MUX_ENET1_RXC IOMUX_CFG(IOMUXC_PAD_ENET2_RXC_ENET1_RGMII_RXC, 0, 0)
|
||||
# define MUX_ENET1_TX_CTL IOMUX_CFG(IOMUXC_PAD_ENET2_TX_CTL_ENET1_RGMII_TX_CTL, IOMUXC_PAD_FSEL_FAST | IOMUXC_PAD_DSE_X6, 0)
|
||||
# define MUX_ENET1_RX_CTL IOMUX_CFG(IOMUXC_PAD_ENET2_RX_CTL_ENET1_RGMII_RX_CTL, 0, 0)
|
||||
|
||||
#elif defined(CONFIG_IMX9_ENET1_RMII)
|
||||
|
||||
/* Same pin as TX_CTL for RGMII */
|
||||
|
||||
# define MUX_ENET1_TX_EN IOMUX_CFG(IOMUXC_PAD_ENET2_TX_CTL_ENET1_RGMII_TX_CTL, IOMUXC_PAD_FSEL_FAST | IOMUXC_PAD_DSE_X6, 0)
|
||||
|
||||
/* Same pin as TX_DATA02 for RGMII */
|
||||
|
||||
# define MUX_ENET1_REF_CLK IOMUX_CFG(IOMUXC_PAD_ENET2_TD2_ENET1_RGMII_TD2, IOMUXC_PAD_FSEL_FAST | IOMUXC_PAD_DSE_X6, 0)
|
||||
|
||||
/* Same pin as RX_CTL for RGMII */
|
||||
|
||||
# define MUX_ENET1_CRS_DV IOMUX_CFG(IOMUXC_PAD_ENET2_RX_CTL_ENET1_RGMII_RX_CTL, 0, 0)
|
||||
|
||||
#else
|
||||
#error ENET1 supports only RMII and RGMII
|
||||
#endif
|
||||
|
||||
#define BOARD_ENET1_PHY_LIST \
|
||||
{ \
|
||||
{ \
|
||||
GMII_RTL8211F_NAME, \
|
||||
GMII_PHYID1_RTL8211F, \
|
||||
GMII_PHYID2_RTL8211F, \
|
||||
GMII_RTL8211F_PHYSR_A43, \
|
||||
2, \
|
||||
0xffff, \
|
||||
GMII_RTL8211F_PHYSR_10MBPS, \
|
||||
GMII_RTL8211F_PHYSR_100MBPS, \
|
||||
GMII_RTL8211F_PHYSR_DUPLEX, \
|
||||
22, \
|
||||
GMII_RTL8211F_PHYSR_1000MBPS, \
|
||||
GMII_RTL8211F_PHYSR_SPEED_MASK, \
|
||||
}, \
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user