driver/net/lan9250: Add LAN9250 driver(SPI and QSPI mode)
This commit is contained in:
parent
4d7cc95f80
commit
bf54a5ae50
@ -56,6 +56,10 @@ ifeq ($(CONFIG_ESP32S3_OTG),y)
|
||||
CSRCS += esp32s3_board_usb.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NET_LAN9250),y)
|
||||
CSRCS += esp32s3_lan9250.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path src
|
||||
VPATH += :src
|
||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
|
||||
|
245
boards/xtensa/esp32s3/common/src/esp32s3_lan9250.c
Normal file
245
boards/xtensa/esp32s3/common/src/esp32s3_lan9250.c
Normal file
@ -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_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 */
|
||||
|
@ -210,5 +210,26 @@ int esp32s3_pwm_setup(void);
|
||||
int esp32s3_twai_setup(void);
|
||||
#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 /* __BOARDS_XTENSA_ESP32S3_ESP32S3_DEVKIT_SRC_ESP32S3_DEVKIT_H */
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <errno.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/himem/himem.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#ifdef CONFIG_ESP32S3_TIMER
|
||||
# include "esp32s3_board_tim.h"
|
||||
@ -388,6 +389,14 @@ int esp32s3_bringup(void)
|
||||
}
|
||||
#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
|
||||
* at least enough succeeded to bring-up NSH with perhaps reduced
|
||||
* capabilities.
|
||||
|
@ -75,6 +75,10 @@ if(CONFIG_NET)
|
||||
list(APPEND SRCS w5500.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_NET_LAN9250)
|
||||
list(APPEND SRCS lan9250.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ARCH_PHY_INTERRUPT)
|
||||
list(APPEND SRCS phy_notify.c)
|
||||
endif()
|
||||
|
@ -428,6 +428,69 @@ config NET_W5500_NINTERFACES
|
||||
|
||||
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
|
||||
|
||||
comment "External Ethernet PHY Device Support"
|
||||
|
@ -76,6 +76,10 @@ ifeq ($(CONFIG_NET_W5500),y)
|
||||
CSRCS += w5500.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NET_LAN9250),y)
|
||||
CSRCS += lan9250.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_PHY_INTERRUPT),y)
|
||||
CSRCS += phy_notify.c
|
||||
endif
|
||||
|
2452
drivers/net/lan9250.c
Normal file
2452
drivers/net/lan9250.c
Normal file
File diff suppressed because it is too large
Load Diff
628
drivers/net/lan9250.h
Normal file
628
drivers/net/lan9250.h
Normal file
@ -0,0 +1,628 @@
|
||||
/****************************************************************************
|
||||
* drivers/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 __DRIVERS_NET_LAN9250_H
|
||||
#define __DRIVERS_NET_LAN9250_H
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* LAN9250 SPI Commands *****************************************************/
|
||||
|
||||
#define LAN9250_SPI_CMD_READ 0x03
|
||||
#define LAN9250_SPI_CMD_FREAD 0x0b
|
||||
#define LAN9250_SPI_CMD_WRITE 0x02
|
||||
#define LAN9250_SPI_CMD_ENABLE_SQI 0x38
|
||||
|
||||
#define LAN9250_QSPI_CMD_READ 0xeb
|
||||
#define LAN9250_QSPI_CMD_WRITE 0xe2
|
||||
|
||||
/* System Control and Status Registers **************************************/
|
||||
|
||||
#define LAN9250_RXDFR 0x000
|
||||
#define LAN9250_TXDFR 0x020
|
||||
#define LAN9250_RXSFR 0x040
|
||||
#define LAN9250_RXSPR 0x044
|
||||
#define LAN9250_TXSFR 0x048
|
||||
#define LAN9250_TXSPR 0x04c
|
||||
#define LAN9250_CIARR 0x050
|
||||
#define LAN9250_ICFGR 0x054
|
||||
#define LAN9250_ISR 0x058
|
||||
#define LAN9250_IER 0x05c
|
||||
#define LAN9250_BOTR 0x064
|
||||
#define LAN9250_FLIR 0x068
|
||||
#define LAN9250_RXCFGR 0x06c
|
||||
#define LAN9250_TXCFGR 0x070
|
||||
#define LAN9250_HWCFGR 0x074
|
||||
#define LAN9250_RDCR 0x078
|
||||
#define LAN9250_RXFIR 0x07c
|
||||
#define LAN9250_TXFIR 0x080
|
||||
#define LAN9250_PMCR 0x084
|
||||
#define LAN9250_GPTCFGR 0x08c
|
||||
#define LAN9250_GPTCR 0x090
|
||||
#define LAN9250_FR25MCR 0x09c
|
||||
#define LAN9250_HMRDFCR 0x0a0
|
||||
#define LAN9250_HMCSRICR 0x0a4
|
||||
#define LAN9250_HMCSRIDR 0x0a8
|
||||
#define LAN9250_HMAFCCFGR 0x0ac
|
||||
#define LAN9250_HMRXLPITXR 0x0b0
|
||||
#define LAN9250_HMRXLPITR 0x0b4
|
||||
#define LAN9250_HMTXLPITXR 0x0b8
|
||||
#define LAN9250_HMTXLPITR 0x0bc
|
||||
|
||||
/* 1588 Register Addresses */
|
||||
|
||||
#define LAN9250_1588CACR 0x100
|
||||
#define LAN9250_1588GCFGR 0x104
|
||||
#define LAN9250_1588ISR 0x108
|
||||
#define LAN9250_1588IER 0x10c
|
||||
#define LAN9250_1588CLKSR 0x110
|
||||
#define LAN9250_1588CLKNSR 0x114
|
||||
#define LAN9250_1588CLKSNSR 0x118
|
||||
#define LAN9250_1588CLKRAR 0x11c
|
||||
#define LAN9250_1588CLKTRAR 0x120
|
||||
#define LAN9250_1588CLKTRDR 0x124
|
||||
#define LAN9250_1588CLKSAR 0x128
|
||||
#define LAN9250_1588CLKATXSR 0x12c
|
||||
#define LAN9250_1588CLKATXNSR 0x130
|
||||
#define LAN9250_1588CLKATXRASR 0x134
|
||||
#define LAN9250_1588CLKATXRANSR 0x138
|
||||
#define LAN9250_1588CLKBTXSR 0x13c
|
||||
#define LAN9250_1588CLKBTXNSR 0x140
|
||||
#define LAN9250_1588CLKBTXRASR 0x144
|
||||
#define LAN9250_1588CLKBTXRANSR 0x148
|
||||
#define LAN9250_1588UMAHWR 0x14c
|
||||
#define LAN9250_1588UMALWR 0x150
|
||||
#define LAN9250_1588BPGSR 0x154
|
||||
|
||||
/* Bank 0 Control Register Addresses */
|
||||
|
||||
#define LAN9250_1588PLR 0x158
|
||||
#define LAN9250_1588PAAPDR 0x15c
|
||||
#define LAN9250_1588PCIR 0x160
|
||||
|
||||
/* Bank 1 Control Register Addresses */
|
||||
|
||||
#define LAN9250_1588PRXPCR 0x158
|
||||
#define LAN9250_1588PRXTSCR 0x15c
|
||||
#define LAN9250_1588PRXTICR 0x160
|
||||
#define LAN9250_1588PRXFCFGR 0x168
|
||||
#define LAN9250_1588PRXITSR 0x16c
|
||||
#define LAN9250_1588PRXITNSR 0x170
|
||||
#define LAN9250_1588PRXMHR 0x174
|
||||
#define LAN9250_1588PRXPDRITSR 0x178
|
||||
#define LAN9250_1588PRXPDRITNSR 0x17c
|
||||
#define LAN9250_1588PRXPDRICFHR 0x180
|
||||
#define LAN9250_1588PRXPDRICFLR 0x184
|
||||
#define LAN9250_1588PRXCSDCR 0x188
|
||||
#define LAN9250_1588PRXFCR 0x18c
|
||||
|
||||
/* Bank 2 Control Register Addresses */
|
||||
|
||||
#define LAN9250_1588PTXPCR 0x158
|
||||
#define LAN9250_1588PTXTSCR 0x15c
|
||||
#define LAN9250_1588PTXMR 0x164
|
||||
#define LAN9250_1588PTXM2R 0x168
|
||||
#define LAN9250_1588PTXETSR 0x16c
|
||||
#define LAN9250_1588PTXETNSR 0x170
|
||||
#define LAN9250_1588PTXMHR 0x174
|
||||
#define LAN9250_1588PTXDRDTSR 0x178
|
||||
#define LAN9250_1588PTXDRDTNSR 0x17c
|
||||
#define LAN9250_1588TXOSSUSR 0x180
|
||||
|
||||
/* Bank 3 Control Register Addresses */
|
||||
|
||||
#define LAN9250_1588GPIOCCFGR 0x15c
|
||||
#define LAN9250_1588GPIOXRECLKSCR 0x16c
|
||||
#define LAN9250_1588GPIOXRECLKNSCR 0x170
|
||||
#define LAN9250_1588GPIOXFECLKSCR 0x178
|
||||
#define LAN9250_1588GPIOXFECLKNSCR 0x17c
|
||||
|
||||
/* ISR_GPIO Register Addresses */
|
||||
|
||||
#define LAN9250_GPIOCFGR 0x1e0
|
||||
#define LAN9250_GPIODADR 0X1e4
|
||||
#define LAN9250_GPIOISAER 0X1e8
|
||||
|
||||
/* Reset Register Addresses */
|
||||
|
||||
#define LAN9250_RSTCR 0x1f8
|
||||
|
||||
/* Host MAC Registers *******************************************************/
|
||||
|
||||
#define LAN9250_HMACCR 0x01
|
||||
#define LAN9250_HMACAHR 0x02
|
||||
#define LAN9250_HMACALR 0x03
|
||||
#define LAN9250_HMACHTHR 0x04
|
||||
#define LAN9250_HMACHTLR 0x05
|
||||
#define LAN9250_HMACMIIAR 0x06
|
||||
#define LAN9250_HMACMIIDR 0x07
|
||||
#define LAN9250_HMACFCR 0x08
|
||||
#define LAN9250_HMACVLAN1TR 0x09
|
||||
#define LAN9250_HMACVLAN2TR 0x0a
|
||||
#define LAN9250_HMACWUFFR 0x0b
|
||||
#define LAN9250_HMACWUCASR 0x0c
|
||||
#define LAN9250_HMACCSOECR 0x0d
|
||||
#define LAN9250_HMACEEETWTXSR 0x0e
|
||||
#define LAN9250_HMACEEETXLPIRDR 0x0f
|
||||
|
||||
/* PHY Registers ************************************************************/
|
||||
|
||||
#define LAN9250_PHYBCR 0
|
||||
#define LAN9250_PHYBSR 1
|
||||
#define LAN9250_PHYIMSBR 2
|
||||
#define LAN9250_PHYILSBR 3
|
||||
#define LAN9250_PHYANAR 4
|
||||
#define LAN9250_PHYANLPBPAR 5
|
||||
#define LAN9250_PHYANER 6
|
||||
#define LAN9250_PHYANNPTXR 7
|
||||
#define LAN9250_PHYANNPRXR 8
|
||||
#define LAN9250_PHYMMDACR 13
|
||||
#define LAN9250_PHYMMDAODR 14
|
||||
#define LAN9250_PHYEDPDCFGR 16
|
||||
#define LAN9250_PHYMCOSR 17
|
||||
#define LAN9250_PHYSMR 18
|
||||
#define LAN9250_PHYTDRPODCR 24
|
||||
#define LAN9250_PHYTDRCOSR 25
|
||||
#define LAN9250_PHYSECR 26
|
||||
#define LAN9250_PHYSCOSIR 27
|
||||
#define LAN9250_PHYCLR 28
|
||||
#define LAN9250_PHYISFR 29
|
||||
#define LAN9250_PHYIER 30
|
||||
#define LAN9250_PHYSCOSR 31
|
||||
|
||||
/* LAN9250 SPI Commands Fields **********************************************/
|
||||
|
||||
/* SPI Write Command A */
|
||||
|
||||
#define SPI_CMD_WRITE_A_IOC 0X80000000
|
||||
#define SPI_CMD_WRITE_A_BEA 0x03000000
|
||||
#define SPI_CMD_WRITE_A_4BA 0x00000000
|
||||
#define SPI_CMD_WRITE_A_16BA 0x01000000
|
||||
#define SPI_CMD_WRITE_A_32BA 0x02000000
|
||||
#define SPI_CMD_WRITE_A_DO 0x00000000
|
||||
#define SPI_CMD_WRITE_A_FS 0x00002000
|
||||
#define SPI_CMD_WRITE_A_LS 0x00001000
|
||||
#define SPI_CMD_WRITE_A_BS_M 0x000007ff
|
||||
|
||||
/* SPI Write Command B */
|
||||
|
||||
#define SPI_CMD_WRITE_B_PT 0x05200000
|
||||
#define SPI_CMD_WRITE_B_CE 0x00004000
|
||||
#define SPI_CMD_WRITE_B_ACD 0x00002000
|
||||
#define SPI_CMD_WRITE_B_DP 0x00001000
|
||||
#define SPI_CMD_WRITE_B_PL_M 0x000007ff
|
||||
|
||||
/* RX FIFO Status Format Fields *********************************************/
|
||||
|
||||
#define RXSFF_PF 0x80000000
|
||||
#define RXSFF_FF 0x40000000
|
||||
#define RXSFF_PL_M 0x3fff0000
|
||||
#define RXSFF_PL_S 16
|
||||
#define RXSFF_ES 0x00008000
|
||||
#define RXSFF_BF 0x00002000
|
||||
#define RXSFF_LE 0x00001000
|
||||
#define RXSFF_RF 0x00000800
|
||||
#define RXSFF_MF 0x00000400
|
||||
#define RXSFF_FTL 0x00000080
|
||||
#define RXSFF_CS 0x00000040
|
||||
#define RXSFF_FT 0x00000020
|
||||
#define RXSFF_RWTO 0x00000010
|
||||
#define RXSFF_MIIE 0x00000008
|
||||
#define RXSFF_DB 0x00000004
|
||||
#define RXSFF_CRCE 0x00000002
|
||||
|
||||
/* System Control and Status Registers Fields *******************************/
|
||||
|
||||
/* RX FIFO Status Register */
|
||||
|
||||
#define RXFIR_RXSFUS_M 0x00ff0000
|
||||
#define RXFIR_RXSFUS_S 16
|
||||
#define RXFIR_RXDFUS_M 0x0000ffff
|
||||
|
||||
/* TX FIFO Status Register */
|
||||
|
||||
#define TXFIR_TXSFUS_M 0x00ff0000
|
||||
#define TXFIR_TXSFUS_S 16
|
||||
#define TXFIR_TXDFFS_M 0x0000ffff
|
||||
|
||||
/* Hardware Configuration Register */
|
||||
|
||||
#define HWCFGR_READY 0x08000000
|
||||
#define HWCFGR_AMDIXENSS 0x02000000
|
||||
#define HWCFGR_MBO 0x00100000
|
||||
#define HWCFGR_TXFS_M 0x000f0000
|
||||
#define HWCFGR_TXFS_S 16
|
||||
|
||||
/* Byte Order Test Register */
|
||||
|
||||
#define BOTR_MASK 0xffffffff
|
||||
#define BOTR_VAL 0x87654321
|
||||
|
||||
/* Host MAC Automatic Flow Control Configuration Register */
|
||||
|
||||
#define HMAFCCFGR_AFCHL_M 0x00ff0000
|
||||
#define HMAFCCFGR_AFCHL_S 16
|
||||
#define HMAFCCFGR_AFCLL_M 0x0000ff00
|
||||
#define HMAFCCFGR_AFCLL_S 8
|
||||
#define HMAFCCFGR_BPD_M 0x000000f0
|
||||
#define HMAFCCFGR_BPD_S 4
|
||||
#define HMAFCCFGR_FCOMF 0x00000008
|
||||
#define HMAFCCFGR_FCOBF 0x00000004
|
||||
#define HMAFCCFGR_FCOAD 0x00000002
|
||||
#define HMAFCCFGR_FCOAF 0x00000001
|
||||
|
||||
/* Chip ID and Revision Register */
|
||||
|
||||
#define CIARR_CID_M 0xffff0000
|
||||
#define CIARR_CID_S 16
|
||||
#define CIARR_CID_V (0x9250 << 16)
|
||||
#define CIARR_CREV_M 0x0000ffff
|
||||
|
||||
/* Interrupt Configuration Register */
|
||||
|
||||
#define ICFGR_IDAI_M 0xf0000000
|
||||
#define ICFGR_IDAI_S 24
|
||||
#define ICFGR_IDAIC 0x00004000
|
||||
#define ICFGR_IDAS 0x00002000
|
||||
#define ICFGR_MI 0x00001000
|
||||
#define ICFGR_IRQE 0x00000100
|
||||
#define ICFGR_IRQP 0x00000010
|
||||
#define ICFGR_IRQCLKS 0x00000002
|
||||
#define ICFGR_IRQBT 0x00000001
|
||||
|
||||
/* Interrupt Enable Register */
|
||||
|
||||
#define IER_SW 0x80000000
|
||||
#define IER_RAEDY 0x40000000
|
||||
#define IER_1588 0x20000000
|
||||
#define IER_PHY 0x04000000
|
||||
#define IER_TXSTOP 0x02000000
|
||||
#define IER_RXSTOP 0x01000000
|
||||
#define IER_RXDFH 0x00800000
|
||||
#define IER_TXIOC 0x00200000
|
||||
#define IER_RXD 0x00100000
|
||||
#define IER_GPT 0x00080000
|
||||
#define IER_PME 0x00020000
|
||||
#define IER_TXSO 0x00010000
|
||||
#define IER_RWT 0x00008000
|
||||
#define IER_RXE 0x00004000
|
||||
#define IER_TXE 0x00002000
|
||||
#define IER_GPIO 0x00001000
|
||||
#define IER_TDFO 0x00000400
|
||||
#define IER_TDFA 0x00000200
|
||||
#define IER_TSFF 0x00000100
|
||||
#define IER_TSFL 0x00000080
|
||||
#define IER_RXDF 0x00000040
|
||||
#define IER_RSFF 0x00000010
|
||||
#define IER_RSFL 0x00000008
|
||||
|
||||
/* Interrupt Status Register */
|
||||
|
||||
#define ISR_SW 0x80000000
|
||||
#define ISR_READY 0x40000000
|
||||
#define ISR_1588 0x20000000
|
||||
#define ISR_PHY 0x04000000
|
||||
#define ISR_TXS 0x02000000
|
||||
#define ISR_RXS 0x01000000
|
||||
#define ISR_RXDFH 0x00800000
|
||||
#define ISR_TXIOC 0x00200000
|
||||
#define ISR_RXD 0x00100000
|
||||
#define ISR_GPT 0x00080000
|
||||
#define ISR_PME 0x00020000
|
||||
#define ISR_TXSO 0x00010000
|
||||
#define ISR_RWT 0x00008000
|
||||
#define ISR_RXE 0x00004000
|
||||
#define ISR_TXE 0x00002000
|
||||
#define ISR_GPIO 0x00001000
|
||||
#define ISR_TDFO 0x00000400
|
||||
#define ISR_TDFA 0x00000200
|
||||
#define ISR_TSFF 0x00000100
|
||||
#define ISR_TSFL 0x00000080
|
||||
#define ISR_RXDF 0x00000040
|
||||
#define ISR_RSFF 0x00000010
|
||||
#define ISR_RSFL 0x00000008
|
||||
|
||||
/* FIFO Level Interrupt Register */
|
||||
|
||||
#define FLIR_FITXDAL_M 0xff000000
|
||||
#define FLIR_FITXDAL_S 24
|
||||
#define FLIR_FITXSL_M 0x00ff0000
|
||||
#define FLIR_FITXSL_S 16
|
||||
#define FLIR_FIRXSL_M 0x000000ff
|
||||
#define FLIR_FIRXSL_S 0
|
||||
|
||||
/* Receive Configuration Register */
|
||||
|
||||
#define RXCFGR_RXEA 0xc0000000
|
||||
#define RXCFGR_RXDMAC 0x06000000
|
||||
#define RXCFGR_RXDMAC_M 0x0fff0000
|
||||
#define RXCFGR_RXDMAC_S 16
|
||||
#define RXCFGR_FRXD 0x00008000
|
||||
#define RXCFGR_RXDO_M 0x00001f00
|
||||
#define RXCFGR_RXDO_S 8
|
||||
|
||||
/* Transmit Configuration Register */
|
||||
|
||||
#define TXCFGR_FTXSD 0x00008000
|
||||
#define TXCFGR_FTXDD 0x00004000
|
||||
#define TXCFGR_TXSAO 0x00000004
|
||||
#define TXCFGR_TXE 0x00000002
|
||||
#define TXCFGR_TXD 0x00000001
|
||||
|
||||
/* Power Management Control Register */
|
||||
|
||||
#define PMCR_PMM_M 0xe0000000
|
||||
#define PMCR_PMSE 0x10000000
|
||||
#define PMCR_PMWU 0x08000000
|
||||
#define PMCR_LEDD 0x04000000
|
||||
#define PMCR_1588CLKD 0x02000000
|
||||
#define PMCR_1588TSUCLKD 0x00400000
|
||||
#define PMCR_HMACCLKD 0x00080000
|
||||
#define PMCR_HMACSCOD 0x00040000
|
||||
#define PMCR_EDS 0x00010000
|
||||
#define PMCR_EDE 0x00004000
|
||||
#define PMCR_WOE 0x00000200
|
||||
#define PMCR_PMEBT 0x00000040
|
||||
#define PMCR_WOLS 0x00000020
|
||||
#define PMCR_PMEI 0x00000008
|
||||
#define PMCR_PMEP 0x00000004
|
||||
#define PMCR_PMEE 0x00000002
|
||||
#define PMCR_READY 0x00000001
|
||||
|
||||
/* Host MAC CSR Interface Command Register */
|
||||
|
||||
#define HMCSRICR_CSRB 0x80000000
|
||||
#define HMCSRICR_RNW 0x40000000
|
||||
#define HMCSRICR_CSRA_M 0x000000ff
|
||||
|
||||
/* Reset Control Register */
|
||||
|
||||
#define RSTCR_HMACR 0x00000020
|
||||
#define RSTCR_PHYR 0x00000002
|
||||
#define RSTCR_DR 0x00000001
|
||||
|
||||
/* Host MAC Registers Fields ************************************************/
|
||||
|
||||
/* Host MAC Control Register */
|
||||
|
||||
#define HMACCR_RXAM 0x80000000
|
||||
#define HMACCR_EEEE 0x02000000
|
||||
#define HMACCR_DRXO 0x00400000
|
||||
#define HMACCR_LOM 0x00200000
|
||||
#define HMACCR_FDM 0x00100000
|
||||
#define HMACCR_PAM 0x00080000
|
||||
#define HMACCR_PM 0x00040000
|
||||
#define HMACCR_IF 0x00020000
|
||||
#define HMACCR_PBF 0x00010000
|
||||
#define HMACCR_HOFM 0x00008000
|
||||
#define HMACCR_HOPFM 0x00002000
|
||||
#define HMACCR_DBF 0x00000800
|
||||
#define HMACCR_DR 0x00000400
|
||||
#define HMACCR_APS 0x00000100
|
||||
#define HMACCR_BOL_M 0x000000c0
|
||||
#define HMACCR_DC 0x00000020
|
||||
#define HMACCR_TXE 0x00000008
|
||||
#define HMACCR_RXE 0x00000004
|
||||
|
||||
/* Host MAC MII Access Register */
|
||||
|
||||
#define HMACMIIAR_PHYA_M 0x0000f800
|
||||
#define HMACMIIAR_PHYA_S 11
|
||||
#define HMACMIIAR_MIIRX_M 0x000007c0
|
||||
#define HMACMIIAR_MIIRX_S 6
|
||||
#define HMACMIIAR_MIIW 0x00000002
|
||||
#define HMACMIIAR_MIIB 0x00000001
|
||||
|
||||
/* Host MAC Flow Control Register */
|
||||
|
||||
#define HMACFCR_PT_M 0xffff0000
|
||||
#define HMACFCR_PT_S 16
|
||||
#define HMACFCR_PCF 0x00000004
|
||||
#define HMACFCR_FLE 0x00000002
|
||||
#define HMACFCR_FLB 0x00000001
|
||||
|
||||
/* PHY Registers Fields *****************************************************/
|
||||
|
||||
/* PHY Basic Control Register */
|
||||
|
||||
#define PHYBCR_SWR 0x8000
|
||||
#define PHYBCR_LB 0x4000
|
||||
#define PHYBCR_SSLSB 0x2000
|
||||
#define PHYBCR_ANE 0x1000
|
||||
#define PHYBCR_PD 0x0800
|
||||
#define PHYBCR_RAN 0x0200
|
||||
#define PHYBCR_DM 0x0100
|
||||
#define PHYBCR_CTM 0x0080
|
||||
|
||||
/* PHY Basic Status Register */
|
||||
|
||||
#define PHYBSR_100BT4 0x8000
|
||||
#define PHYBSR_100BXFD 0x4000
|
||||
#define PHYBSR_100BXHD 0x2000
|
||||
#define PHYBSR_10BXFD 0x1000
|
||||
#define PHYBSR_10BXHD 0x0800
|
||||
#define PHYBSR_100BT2FD 0x0400
|
||||
#define PHYBSR_100BT2HD 0x0200
|
||||
#define PHYBSR_ES 0x0100
|
||||
#define PHYBSR_UDA 0x0080
|
||||
#define PHYBSR_MFPS 0x0040
|
||||
#define PHYBSR_ANC 0x0020
|
||||
#define PHYBSR_RF 0x0010
|
||||
#define PHYBSR_ANA 0x0008
|
||||
#define PHYBSR_LS 0x0004
|
||||
#define PHYBSR_JD 0x0002
|
||||
#define PHYBSR_EC 0x0001
|
||||
|
||||
/* PHY Identification MSB Register */
|
||||
|
||||
#define PHYIMSBR_ID 0xffff
|
||||
|
||||
/* PHY Identification LSB Register */
|
||||
|
||||
#define PHYILSBR_ID_M 0xfc00
|
||||
#define PHYILSBR_ID_S 10
|
||||
#define PHYILSBR_MN_M 0x03f0
|
||||
#define PHYILSBR_MN_S 4
|
||||
#define PHYILSBR_RN_M 0x000f
|
||||
#define PHYILSBR_RN_S 0
|
||||
|
||||
/* PHY Auto-Negotiation Advertisement Register */
|
||||
|
||||
#define PHYANAR_NP 0x8000
|
||||
#define PHYANAR_RF 0x2000
|
||||
#define PHYANAR_ENP 0x1000
|
||||
#define PHYANAR_AP 0x0800
|
||||
#define PHYANAR_SP 0x0400
|
||||
#define PHYANAR_100BXFD 0x0100
|
||||
#define PHYANAR_100BXHD 0x0080
|
||||
#define PHYANAR_10BXFD 0x0040
|
||||
#define PHYANAR_10BXHD 0x0020
|
||||
#define PHYANAR_SF 0x0001
|
||||
|
||||
/* PHY Auto-Negotiation Link Partner Base Page Ability Register */
|
||||
|
||||
#define PHYANLPBPAR_NP 0x8000
|
||||
#define PHYANLPBPAR_ACK 0x4000
|
||||
#define PHYANLPBPAR_RF 0x2000
|
||||
#define PHYANLPBPAR_ENP 0x1000
|
||||
#define PHYANLPBPAR_AP 0x0800
|
||||
#define PHYANLPBPAR_PAUSE 0x0400
|
||||
#define PHYANLPBPAR_100BT4 0x0200
|
||||
#define PHYANLPBPAR_100BXFD 0x0100
|
||||
#define PHYANLPBPAR_100BXHD 0x0080
|
||||
#define PHYANLPBPAR_10BXFD 0x0040
|
||||
#define PHYANLPBPAR_10BXHD 0x0020
|
||||
#define PHYANLPBPAR_SF_M 0x001f
|
||||
|
||||
/* PHY Auto-Negotiation Expansion Register */
|
||||
|
||||
#define PHYANER_RXNPLA 0x0040
|
||||
#define PHYANER_RXNPSL 0x0020
|
||||
#define PHYANER_PDF 0x0010
|
||||
#define PHYANER_LPNPA 0x0008
|
||||
#define PHYANER_NPA 0x0004
|
||||
#define PHYANER_PRX 0x0002
|
||||
#define PHYANER_LPANA 0x0001
|
||||
|
||||
/* PHY Auto-Negotiation Next Page TX Register */
|
||||
|
||||
#define PHYANNPTXR_NP 0x8000
|
||||
#define PHYANNPTXR_MP 0x2000
|
||||
#define PHYANNPTXR_ACK2 0x1000
|
||||
#define PHYANNPTXR_TOG 0x0800
|
||||
#define PHYANNPTXR_MC_M 0x07ff
|
||||
|
||||
/* PHY Auto-Negotiation Next Page RX Register */
|
||||
|
||||
#define PHYANNPRXR_NP 0x8000
|
||||
#define PHYANNPRXR_ACK 0x4000
|
||||
#define PHYANNPRXR_MP 0x2000
|
||||
#define PHYANNPRXR_ACK2 0x1000
|
||||
#define PHYANNPRXR_TOG 0x0800
|
||||
#define PHYANNPRXR_MC_M 0x07ff
|
||||
|
||||
/* PHY MMD Access Control Register */
|
||||
|
||||
#define PHYMMDACR_MMDF_M 0xc000
|
||||
#define PHYMMDACR_MMDDA_M 0x001f
|
||||
|
||||
/* PHY EDPD NLP/Crossover Time/EEE Configuration Register */
|
||||
|
||||
#define PHYEDPDCFGR_EDPDTXNLPE 0x8000
|
||||
#define PHYEDPDCFGR_EDPDTXNLPITS_M 0x6000
|
||||
#define PHYEDPDCFGR_EDPDRXSNLPWE 0x1000
|
||||
#define PHYEDPDCFGR_EDPDRXNLPMIDS_M 0x0c00
|
||||
#define PHYEDPDCFGR_PEEEE 0x0004
|
||||
#define PHYEDPDCFGR_EDPDEC 0x0002
|
||||
#define PHYEDPDCFGR_EMAMDIXCT 0x0001
|
||||
|
||||
/* PHY Mode Control/Status Register */
|
||||
|
||||
#define PHYMCOSR_EDPD 0x2000
|
||||
#define PHYMCOSR_AIM 0x0040
|
||||
#define PHYMCOSR_EO 0x0002
|
||||
|
||||
/* PHY Special Modes Register */
|
||||
|
||||
#define PHYSMR_100BFXM 0x0400
|
||||
#define PHYSMR_PM_M 0x00e0
|
||||
#define PHYSMR_PM_S 5
|
||||
#define PHYSMR_ADDR_M 0x001f
|
||||
#define PHYSMR_ADDR_S 0x00e0
|
||||
|
||||
/* PHY TDR Patterns/Delay Control Register */
|
||||
|
||||
#define PHYTDRCOSR_TDRDI 0x8000
|
||||
#define PHYTDRCOSR_TDRLBC_M 0x7000
|
||||
#define PHYTDRCOSR_TDRPH 0x0fc0
|
||||
#define PHYTDRCOSR_TDRPL 0x003f
|
||||
|
||||
/* PHY TDR Control/Status Register */
|
||||
|
||||
#define PHYTDRCOSR_TDRE 0x8000
|
||||
#define PHYTDRCOSR_TDRATDFE 0x4000
|
||||
#define PHYTDRCOSR_TDRCCT 0x0600
|
||||
#define PHYTDRCOSR_TDRCS 0x0100
|
||||
#define PHYTDRCOSR_TDRCL 0x00FF
|
||||
|
||||
/* PHY Special Control/Status Indication register */
|
||||
|
||||
#define PHYSCOSIR_AMDIXC 0x8000
|
||||
#define PHYSCOSIR_AMDIXE 0x4000
|
||||
#define PHYSCOSIR_DMDIXS 0x2000
|
||||
#define PHYSCOSIR_SQETD 0x0800
|
||||
#define PHYSCOSIR_FEFIE 0x0020
|
||||
#define PHYSCOSIR_10BTPS 0x0010
|
||||
|
||||
/* PHY Cable Length Register */
|
||||
|
||||
#define PHYCLR_CL_M 0xf000
|
||||
|
||||
/* PHY Interrupt Source Flags Register */
|
||||
|
||||
#define PHYISFR_LU 0x0200
|
||||
#define PHYISFR_EO 0x0080
|
||||
#define PHYISFR_ANC 0x0040
|
||||
#define PHYISFR_RF 0x0020
|
||||
#define PHYISFR_LD 0x0010
|
||||
#define PHYISFR_ANLPA 0x0008
|
||||
#define PHYISFR_PDF 0x0004
|
||||
#define PHYISFR_ANPR 0x0002
|
||||
|
||||
/* PHY Interrupt Enable Register */
|
||||
|
||||
#define PHYIER_LU 0x0200
|
||||
#define PHYIER_EO 0x0080
|
||||
#define PHYIER_ANC 0x0040
|
||||
#define PHYIER_RF 0x0020
|
||||
#define PHYIER_LD 0x0010
|
||||
#define PHYIER_ANLPA 0x0008
|
||||
#define PHYIER_PDF 0x0004
|
||||
#define PHYIER_ANPR 0x0002
|
||||
|
||||
/* PHY Special Control/Status Register */
|
||||
|
||||
#define PHYSCOSR_AD 0x8000
|
||||
#define PHYSCOSR_RD 0x0040
|
||||
#define PHYSCOSR_SI_M 0x001c
|
||||
|
||||
#endif /* __DRIVERS_NET_LAN9250_H */
|
125
include/nuttx/net/lan9250.h
Normal file
125
include/nuttx/net/lan9250.h
Normal file
@ -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 */
|
Loading…
Reference in New Issue
Block a user