mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +08:00
driver/net/lan9250: Add LAN9250 driver(SPI and QSPI mode)
This commit is contained in:
@@ -56,6 +56,10 @@ ifeq ($(CONFIG_ESP32S3_OTG),y)
|
|||||||
CSRCS += esp32s3_board_usb.c
|
CSRCS += esp32s3_board_usb.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_NET_LAN9250),y)
|
||||||
|
CSRCS += esp32s3_lan9250.c
|
||||||
|
endif
|
||||||
|
|
||||||
DEPPATH += --dep-path src
|
DEPPATH += --dep-path src
|
||||||
VPATH += :src
|
VPATH += :src
|
||||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
|
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
|
||||||
|
|||||||
@@ -0,0 +1,245 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/xtensa/esp32s3/common/src/esp32s3_lan9250.c
|
||||||
|
*
|
||||||
|
* 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 <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/board.h>
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/net/lan9250.h>
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "xtensa.h"
|
||||||
|
#include "esp32s3_gpio.h"
|
||||||
|
#ifdef CONFIG_LAN9250_SPI
|
||||||
|
#include "esp32s3_spi.h"
|
||||||
|
#else
|
||||||
|
#include "esp32s3_qspi.h"
|
||||||
|
#endif
|
||||||
|
#include "hardware/esp32s3_efuse.h"
|
||||||
|
#include "hardware/esp32s3_gpio_sigmap.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Function Protototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int lan9250_attach(const struct lan9250_lower_s *lower,
|
||||||
|
xcpt_t handler, void *arg);
|
||||||
|
static void lan9250_enable(const struct lan9250_lower_s *lower);
|
||||||
|
static void lan9250_disable(const struct lan9250_lower_s *lower);
|
||||||
|
static void lan9250_getmac(const struct lan9250_lower_s *lower,
|
||||||
|
uint8_t *mac);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static struct lan9250_lower_s g_lan9250_lower =
|
||||||
|
{
|
||||||
|
.attach = lan9250_attach,
|
||||||
|
.enable = lan9250_enable,
|
||||||
|
.disable = lan9250_disable,
|
||||||
|
.getmac = lan9250_getmac
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lan9250_attach
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Attach LAN9250 interrupt.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* lower - A reference to the LAN9250 low-level object data.
|
||||||
|
* handler - Interrupt handle
|
||||||
|
* arg - Interrupt private argument
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int lan9250_attach(const struct lan9250_lower_s *lower,
|
||||||
|
xcpt_t handler, void *arg)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
int irq = ESP32S3_PIN2IRQ(LAN9250_IRQ);
|
||||||
|
|
||||||
|
ret = irq_attach(irq, handler, arg);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: irq_attach() failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ninfo("Attach the interrupt\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lan9250_enable
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Enable LAN9250 interrupt.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* lower - A reference to the LAN9250 low-level object data.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void lan9250_enable(const struct lan9250_lower_s *lower)
|
||||||
|
{
|
||||||
|
int irq = ESP32S3_PIN2IRQ(LAN9250_IRQ);
|
||||||
|
|
||||||
|
/* Configure the interrupt for rising and falling edges */
|
||||||
|
|
||||||
|
esp32s3_gpioirqenable(irq, GPIO_INTR_LOW_LEVEL);
|
||||||
|
ninfo("Enable the interrupt\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lan9250_disable
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Disable LAN9250 interrupt.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* lower - A reference to the LAN9250 low-level object data.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void lan9250_disable(const struct lan9250_lower_s *lower)
|
||||||
|
{
|
||||||
|
int irq = ESP32S3_PIN2IRQ(LAN9250_IRQ);
|
||||||
|
|
||||||
|
ninfo("Disable the interrupt\n");
|
||||||
|
esp32s3_gpioirqdisable(irq);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lan9250_getmac
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Retrieves the ESP32-S3 MAC address to be set in the LAN9250 driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* lower - A reference to the LAN9250 low-level object data.
|
||||||
|
* mac - A pointer to a buffer where the MAC address will be stored.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void lan9250_getmac(const struct lan9250_lower_s *lower, uint8_t *mac)
|
||||||
|
{
|
||||||
|
uint32_t regval[2];
|
||||||
|
uint8_t *data = (uint8_t *)regval;
|
||||||
|
|
||||||
|
regval[0] = getreg32(EFUSE_RD_MAC_SPI_SYS_0_REG);
|
||||||
|
regval[1] = getreg32(EFUSE_RD_MAC_SPI_SYS_1_REG);
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
mac[i] = data[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32s3_lan9250_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function is called by platform-specific setup logic to initialize
|
||||||
|
* the LAN9250 device. This function will register the driver
|
||||||
|
* as a network device.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* port - The SPI port used for the device
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero is returned on success. Otherwise, a negated errno value is
|
||||||
|
* returned to indicate the nature of the failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int esp32s3_lan9250_initialize(int port)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
#ifdef CONFIG_LAN9250_SPI
|
||||||
|
struct spi_dev_s *dev;
|
||||||
|
#else
|
||||||
|
struct qspi_dev_s *dev;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
esp32s3_configgpio(LAN9250_IRQ, INPUT_FUNCTION_2 | PULLUP);
|
||||||
|
esp32s3_configgpio(LAN9250_RST, OUTPUT_FUNCTION_2 | PULLUP);
|
||||||
|
|
||||||
|
#ifdef CONFIG_LAN9250_SPI
|
||||||
|
dev = esp32s3_spibus_initialize(port);
|
||||||
|
if (!dev)
|
||||||
|
{
|
||||||
|
nerr("ERROR: Failed to initialize SPI port %d\n", port);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
dev = esp32s3_qspibus_initialize(port);
|
||||||
|
if (!dev)
|
||||||
|
{
|
||||||
|
nerr("ERROR: Failed to initialize QSPI port %d\n", port);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = lan9250_initialize(dev, &g_lan9250_lower);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
nerr("ERROR: Failed to initialize LAN9250 ret=%d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
#
|
||||||
|
# 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_ARCH_LEDS is not set
|
||||||
|
# CONFIG_ESP32S3_RTC is not set
|
||||||
|
# CONFIG_NDEBUG is not set
|
||||||
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
|
# CONFIG_SPI_EXCHANGE is not set
|
||||||
|
CONFIG_ALLOW_BSD_COMPONENTS=y
|
||||||
|
CONFIG_ARCH="xtensa"
|
||||||
|
CONFIG_ARCH_BOARD="esp32s3-devkit"
|
||||||
|
CONFIG_ARCH_BOARD_COMMON=y
|
||||||
|
CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y
|
||||||
|
CONFIG_ARCH_CHIP="esp32s3"
|
||||||
|
CONFIG_ARCH_CHIP_ESP32S3=y
|
||||||
|
CONFIG_ARCH_CHIP_ESP32S3WROOM1=y
|
||||||
|
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_ARCH_XTENSA=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_DEFAULT_TASK_STACKSIZE=4096
|
||||||
|
CONFIG_ESP32S3_GPIO_IRQ=y
|
||||||
|
CONFIG_ESP32S3_SPI2=y
|
||||||
|
CONFIG_ESP32S3_SPI_SWCS=y
|
||||||
|
CONFIG_ESP32S3_UART0=y
|
||||||
|
CONFIG_FS_PROCFS=y
|
||||||
|
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||||
|
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_INIT_STACKSIZE=8192
|
||||||
|
CONFIG_INTELHEX_BINARY=y
|
||||||
|
CONFIG_IOB_BUFSIZE=1514
|
||||||
|
CONFIG_IOB_NBUFFERS=5
|
||||||
|
CONFIG_LAN9250_FREQUENCY=40000000
|
||||||
|
CONFIG_LAN9250_SPI_EXCLUSIVE=y
|
||||||
|
CONFIG_NAME_MAX=48
|
||||||
|
CONFIG_NET=y
|
||||||
|
CONFIG_NETDB_DNSCLIENT=y
|
||||||
|
CONFIG_NETDEV_LATEINIT=y
|
||||||
|
CONFIG_NETUTILS_IPERF=y
|
||||||
|
CONFIG_NET_ARP_SEND=y
|
||||||
|
CONFIG_NET_ETH_PKTSIZE=1518
|
||||||
|
CONFIG_NET_ICMP=y
|
||||||
|
CONFIG_NET_ICMP_SOCKET=y
|
||||||
|
CONFIG_NET_LAN9250=y
|
||||||
|
CONFIG_NET_TCP=y
|
||||||
|
CONFIG_NET_UDP=y
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_LINELEN=64
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=2048
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||||
|
CONFIG_RAM_SIZE=114688
|
||||||
|
CONFIG_RAM_START=0x20000000
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_SCHED_LPWORK=y
|
||||||
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
CONFIG_SIG_DEFAULT=y
|
||||||
|
CONFIG_START_DAY=6
|
||||||
|
CONFIG_START_MONTH=12
|
||||||
|
CONFIG_START_YEAR=2011
|
||||||
|
CONFIG_SYSLOG_BUFFER=y
|
||||||
|
CONFIG_SYSTEM_DHCPC_RENEW=y
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_SYSTEM_PING=y
|
||||||
|
CONFIG_UART0_BAUD=2000000
|
||||||
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
@@ -49,4 +49,19 @@
|
|||||||
#define BOARD_NGPIOIN 1 /* Amount of GPIO Input without Interruption */
|
#define BOARD_NGPIOIN 1 /* Amount of GPIO Input without Interruption */
|
||||||
#define BOARD_NGPIOINT 1 /* Amount of GPIO Input w/ Interruption pins */
|
#define BOARD_NGPIOINT 1 /* Amount of GPIO Input w/ Interruption pins */
|
||||||
|
|
||||||
|
/* LAN9250 SPI and GPIO pins configuration */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_LAN9250
|
||||||
|
|
||||||
|
# define LAN9250_SPI 2
|
||||||
|
|
||||||
|
/* LAN9250 IRQ pin */
|
||||||
|
|
||||||
|
# define LAN9250_IRQ 38
|
||||||
|
|
||||||
|
/* LAN9250 reset pin */
|
||||||
|
|
||||||
|
# define LAN9250_RST 17
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_DEVKIT_INCLUDE_BOARD_H */
|
#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_DEVKIT_INCLUDE_BOARD_H */
|
||||||
|
|||||||
@@ -210,5 +210,26 @@ int esp32s3_pwm_setup(void);
|
|||||||
int esp32s3_twai_setup(void);
|
int esp32s3_twai_setup(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32s3_lan9250_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function is called by platform-specific setup logic to initialize
|
||||||
|
* the LAN9250 device. This function will register the driver
|
||||||
|
* as a network device.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* port - The SPI port used for the device
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero is returned on success. Otherwise, a negated errno value is
|
||||||
|
* returned to indicate the nature of the failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_LAN9250
|
||||||
|
int esp32s3_lan9250_initialize(int port);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_DEVKIT_SRC_ESP32S3_DEVKIT_H */
|
#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_DEVKIT_SRC_ESP32S3_DEVKIT_H */
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/himem/himem.h>
|
#include <nuttx/himem/himem.h>
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#ifdef CONFIG_ESP32S3_TIMER
|
#ifdef CONFIG_ESP32S3_TIMER
|
||||||
# include "esp32s3_board_tim.h"
|
# include "esp32s3_board_tim.h"
|
||||||
@@ -388,6 +389,14 @@ int esp32s3_bringup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_LAN9250
|
||||||
|
ret = esp32s3_lan9250_initialize(LAN9250_SPI);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: Failed to initialize SPI ethernet LAN9250.\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If we got here then perhaps not all initialization was successful, but
|
/* If we got here then perhaps not all initialization was successful, but
|
||||||
* at least enough succeeded to bring-up NSH with perhaps reduced
|
* at least enough succeeded to bring-up NSH with perhaps reduced
|
||||||
* capabilities.
|
* capabilities.
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ if(CONFIG_NET)
|
|||||||
list(APPEND SRCS w5500.c)
|
list(APPEND SRCS w5500.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CONFIG_NET_LAN9250)
|
||||||
|
list(APPEND SRCS lan9250.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CONFIG_ARCH_PHY_INTERRUPT)
|
if(CONFIG_ARCH_PHY_INTERRUPT)
|
||||||
list(APPEND SRCS phy_notify.c)
|
list(APPEND SRCS phy_notify.c)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -428,6 +428,69 @@ config NET_W5500_NINTERFACES
|
|||||||
|
|
||||||
endif # W5500
|
endif # W5500
|
||||||
|
|
||||||
|
menuconfig NET_LAN9250
|
||||||
|
bool "Microchip LAN9250 support"
|
||||||
|
default n
|
||||||
|
select SPI
|
||||||
|
select ARCH_HAVE_NETDEV_STATISTICS
|
||||||
|
---help---
|
||||||
|
Enable LAN9250 SPI Ethernet driver.
|
||||||
|
|
||||||
|
if NET_LAN9250
|
||||||
|
|
||||||
|
choice LAN9250_INTERFACE
|
||||||
|
prompt "Select interface"
|
||||||
|
default LAN9250_SPI
|
||||||
|
---help---
|
||||||
|
Select LAN9250 interface: SPI(4-line) or SQI(6-line).
|
||||||
|
|
||||||
|
config LAN9250_SPI
|
||||||
|
bool "SPI"
|
||||||
|
|
||||||
|
config LAN9250_SQI
|
||||||
|
bool "SQI"
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
config LAN9250_SPI_EXCLUSIVE
|
||||||
|
bool "SPI Exclusive"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
The SPI is exclusive for LAN9250.
|
||||||
|
|
||||||
|
config LAN9250_SPIMODE
|
||||||
|
int "SPI mode"
|
||||||
|
default 0
|
||||||
|
---help---
|
||||||
|
Controls the SPI mode.
|
||||||
|
|
||||||
|
config LAN9250_FREQUENCY
|
||||||
|
int "SPI frequency"
|
||||||
|
default 10000000
|
||||||
|
---help---
|
||||||
|
Define to use a different bus frequency.
|
||||||
|
|
||||||
|
config LAN9250_HALFDUPPLEX
|
||||||
|
bool "Enable half duplex"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Default is full duplex.
|
||||||
|
|
||||||
|
config LAN9250_DUMPPACKET
|
||||||
|
bool "Dump Packets"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
If selected, the LAN9250 driver will dump the contents of each
|
||||||
|
packet to the console.
|
||||||
|
|
||||||
|
config LAN9250_REGDEBUG
|
||||||
|
bool "Register-Level Debug"
|
||||||
|
default n
|
||||||
|
depends on DEBUG_FEATURES && DEBUG_NET
|
||||||
|
---help---
|
||||||
|
Enable very low-level register access debug.
|
||||||
|
|
||||||
|
endif # NET_LAN9250
|
||||||
|
|
||||||
if ARCH_HAVE_PHY
|
if ARCH_HAVE_PHY
|
||||||
|
|
||||||
comment "External Ethernet PHY Device Support"
|
comment "External Ethernet PHY Device Support"
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ ifeq ($(CONFIG_NET_W5500),y)
|
|||||||
CSRCS += w5500.c
|
CSRCS += w5500.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_NET_LAN9250),y)
|
||||||
|
CSRCS += lan9250.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ARCH_PHY_INTERRUPT),y)
|
ifeq ($(CONFIG_ARCH_PHY_INTERRUPT),y)
|
||||||
CSRCS += phy_notify.c
|
CSRCS += phy_notify.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,125 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/net/lan9250.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 __INCLUDE_NUTTX_NET_LAN9250_H
|
||||||
|
#define __INCLUDE_NUTTX_NET_LAN9250_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* The LAN9250 device typically provides interrupts to the MCU through a GPIO
|
||||||
|
* pin. The structure below provides an MCU-independent mechanism for
|
||||||
|
* controlling this LAN9250 GPIO interrupt.
|
||||||
|
*
|
||||||
|
* "When an enabled interrupt occurs, the interrupt pin will remain low until
|
||||||
|
* all flags which are causing the interrupt are cleared or masked off
|
||||||
|
* (enable bit is cleared) by the host controller." However, the interrupt
|
||||||
|
* will behave like a falling edge interrupt because "After an interrupt
|
||||||
|
* occurs, the host controller [clears] the global enable bit for the
|
||||||
|
* interrupt pin before servicing the interrupt. Clearing the enable bit
|
||||||
|
* will cause the interrupt pin to return to the non-asserted state (high).
|
||||||
|
* Doing so will prevent the host controller from missing a falling edge
|
||||||
|
* should another interrupt occur while the immediate interrupt is being
|
||||||
|
* serviced."
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct lan9250_lower_s
|
||||||
|
{
|
||||||
|
int (*attach)(FAR const struct lan9250_lower_s *lower, xcpt_t handler,
|
||||||
|
FAR void *arg);
|
||||||
|
void (*enable)(FAR const struct lan9250_lower_s *lower);
|
||||||
|
void (*disable)(FAR const struct lan9250_lower_s *lower);
|
||||||
|
|
||||||
|
/* This function is optional and used to get a specific MAC address from
|
||||||
|
* a MCU-specific implementation. If this function is NULL, the LAN9250
|
||||||
|
* driver will not read the MAC from the CPU.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void (*getmac)(FAR const struct lan9250_lower_s *lower, FAR uint8_t *mac);
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lan9250_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize the LAN9250 Ethernet driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* spi - A reference to the platform's SPI driver for the LAN9250 when
|
||||||
|
* enable CONFIG_LAN9250_SPI
|
||||||
|
* qspi - A reference to the platform's SQI driver for the LAN9250 when
|
||||||
|
* enable CONFIG_LAN9250_SQI
|
||||||
|
* lower - The MCU-specific interrupt used to control low-level MCU
|
||||||
|
* functions (i.e., LAN9250 GPIO interrupts).
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; Negated errno on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_LAN9250_SPI
|
||||||
|
struct spi_dev_s; /* see nuttx/spi/spi.h */
|
||||||
|
#else
|
||||||
|
struct qspi_dev_s; /* see nuttx/spi/qspi.h */
|
||||||
|
#endif
|
||||||
|
int lan9250_initialize(
|
||||||
|
#ifdef CONFIG_LAN9250_SPI
|
||||||
|
FAR struct spi_dev_s *spi,
|
||||||
|
#else
|
||||||
|
FAR struct qspi_dev_s *qspi,
|
||||||
|
#endif
|
||||||
|
FAR const struct lan9250_lower_s *lower);
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_NET_LAN9250_H */
|
||||||
Reference in New Issue
Block a user