risc-v/mpfs: add support for ethernet

This commit is contained in:
Janne Rosberg
2022-03-14 11:26:53 +02:00
committed by Petro Karashchenko
parent 07aeb12b30
commit d72a523c00
5 changed files with 4803 additions and 1 deletions
+160 -1
View File
@@ -244,6 +244,26 @@ config MPFS_EMMCSD
---help---
Selects the MPFS eMMCSD driver.
config MPFS_ETHMAC
bool
default n
select NETDEVICES
select ARCH_HAVE_PHY
config MPFS_ETHMAC_0
bool "Ethernet MAC 0"
default n
select MPFS_ETHMAC
---help---
Enable MPFS ethernet MAC-0.
config MPFS_ETHMAC_1
bool "Ethernet MAC 1"
default n
select MPFS_ETHMAC
---help---
Enable MPFS ethernet MAC-1.
comment "CorePWM Options"
config MPFS_HAVE_COREPWM
@@ -317,10 +337,149 @@ config MPFS_DMA
---help---
Enable DMA Support. MPFS DMA is Memory-to-Memory only.
menu "MPFS Others"
menu "Ethernet MAC configuration"
depends on MPFS_ETHMAC
choice
prompt "MII Interface mode"
config MPFS_MAC_SGMII
bool "SGMII"
---help---
Use Ethernet SGMII interface.
config MPFS_MAC_GMII
bool "GMII"
---help---
Use Ethernet GMII interface.
endchoice
config MPFS_PHYADDR
int "PHY address"
default 1
---help---
The 5-bit address of the PHY on the board. Default: 1
config MPFS_MAC_NO_BROADCAST
bool "Disable Broadcast"
default n
---help---
Select to disable receipt of broadcast packets.
config MPFS_MAC_AUTONEG
bool "Use autonegotiation"
default y
---help---
Use PHY autonegotiation to determine speed and mode
config MPFS_MAC_AUTONEG_DISABLE_1000MBPS
bool "Disable Gigabit mode"
default n
depends on MPFS_MAC_AUTONEG
---help---
Select to disable Gigabit speed support.
If disabled then autonegotiation don't advertise 1GB mode
config MPFS_PHYINIT
bool "Use board phyinit"
default n
---help---
call mpfs_phy_boardinitialize() on init
if !MPFS_MAC_AUTONEG
config MPFS_MAC_ETHFD
bool "Full duplex"
default n
---help---
If MPFS_MAC_AUTONEG is not defined, then this may be defined to
select full duplex mode. Default: half-duplex
choice
prompt "MAC Speed"
default MPFS_MAC_ETH100MBPS
---help---
If autonegotiation is not used, then you must select the fixed speed
of the PHY
config MPFS_MAC_ETH10MBPS
bool "10 Mbps"
---help---
If MPFS_MAC_AUTONEG is not defined, then this may be defined to select 10 MBps
speed. Default: 100 Mbps
config MPFS_MAC_ETH100MBPS
bool "100 Mbps"
---help---
If MPFS_MAC_AUTONEG is not defined, then this may be defined to select 100 MBps
speed. Default: 100 Mbps
config MPFS_MAC_ETH1000MBPS
bool "1000 Mbps"
---help---
If MPFS_MAC_AUTONEG is not defined, then this may be defined to select 1000 MBps
speed. Default: 100 Mbps
endchoice # GMAC speed
endif # !MPFS_MAC_AUTONEG
config MPFS_ETHMAC_MDC_CLOCK_SOURCE_HZ
int "MDC Clock Source (Hz)"
default 125000000
range 1000000 240000000
depends on MPFS_ETHMAC
---help---
Select the MDC clock source frequency.
config MPFS_ETHMAC_NTXBUFFERS
int "Number of TX DMA Buffers"
default 8
depends on MPFS_ETHMAC
---help---
Select the number of TX DMA buffers.
config MPFS_ETHMAC_NRXBUFFERS
int "Number of RX DMA Buffers"
default 16
depends on MPFS_ETHMAC
---help---
Select the number of RX DMA buffers.
config MPFS_ETHMAC_64BIT_ADDRESS_MODE
bool "64-bit DMA address mode"
default n
depends on MPFS_ETHMAC
---help---
Select to enable 64-bit DMA address mode. This is only needed if the
Nuttx memory address is above 4GB.
config MPFS_ETHMAC_REGDEBUG
bool "Register-Level Debug"
default n
depends on DEBUG_NET_INFO
---help---
Enable very low-level register access debug. Depends on
CONFIG_DEBUG_FEATURES.
config MPFS_MPU_DMA_ENABLE
bool "Enable ALL memory access for eth DMA"
default n
---help---
Set ALL memory accessible for Ethernet DMA.
This should be done on bootloader. This is mostly for testing only.
endmenu
config MPFS_HAVE_CORERMII
bool "CoreRMII FPGA IP block configured"
default n
config MPFS_CORERMII_ADDRESS
int "CoreRMII Phy address"
default 1
depends on MPFS_HAVE_CORERMII
# Override the default values for MPU / PMP parameters here
config ARCH_MPU_MIN_BLOCK_SIZE
+4
View File
@@ -93,6 +93,10 @@ ifeq ($(CONFIG_MPFS_EMMCSD),y)
CHIP_CSRCS += mpfs_emmcsd.c
endif
ifeq ($(CONFIG_MPFS_ETHMAC),y)
CHIP_CSRCS += mpfs_ethernet.c
endif
ifeq (${CONFIG_MPFS_HAVE_COREPWM},y)
CHIP_CSRCS += mpfs_corepwm.c
endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+97
View File
@@ -0,0 +1,97 @@
/****************************************************************************
* arch/risc-v/src/mpfs/mpfs_ethernet.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_RISCV_SRC_MPFS_MPFS_ETHERNET_H
#define __ARCH_RISCV_SRC_MPFS_MPFS_ETHERNET_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "hardware/mpfs_ethernet.h"
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Function: mpfs_ethinitialize
*
* Description:
* Initialize the Ethernet driver for one interface.
*
* 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 mpfs_ethinitialize(int intf);
/****************************************************************************
* Function: mpfs_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_MPFS_PHYINIT is defined in the configuration
* then the board specific logic must provide mpfs_phyinitialize();
* The MPFS 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.
*
* Assumptions:
*
****************************************************************************/
#ifdef CONFIG_MPFS_PHYINIT
int mpfs_phy_boardinitialize(int intf);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_RISCV_SRC_MPFS_MPFS_ETHERNET_H */