boards/arm/samv7/samv71-xult: Add support for the OA-TC6 10BASE-T1x MAC-PHYs
Add support for the OA-TC6 10BASE-T1x driver to the SAMV71 Xplained ultra board. Signed-off-by: michal matias <mich4l.matias@gmail.com>
This commit is contained in:
parent
d4efae2494
commit
12486d21dc
6 changed files with 389 additions and 0 deletions
58
boards/arm/samv7/common/include/board_oa_tc6.h
Normal file
58
boards/arm/samv7/common/include/board_oa_tc6.h
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/samv7/common/include/board_oa_tc6.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 __BOARDS_ARM_SAMV7_COMMON_INCLUDE_BOARD_OA_TC6_H
|
||||||
|
#define __BOARDS_ARM_SAMV7_COMMON_INCLUDE_BOARD_OA_TC6_H
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_oa_tc6_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize and register the OA-TC6 10BASE-T1x network driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_oa_tc6_initialize(void);
|
||||||
|
|
||||||
|
#endif /* __ASSEMBLY__ */
|
||||||
|
#endif /* __BOARDS_ARM_SAMV7_COMMON_INCLUDE_BOARD_OA_TC6_H */
|
||||||
94
boards/arm/samv7/samv71-xult/configs/oa_tc6/defconfig
Normal file
94
boards/arm/samv7/samv71-xult/configs/oa_tc6/defconfig
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
#
|
||||||
|
# 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_RAMFUNCS is not set
|
||||||
|
# CONFIG_MMCSD_MMCSUPPORT is not set
|
||||||
|
# CONFIG_MMCSD_SPI is not set
|
||||||
|
# CONFIG_NET_UDP_CHECKSUMS is not set
|
||||||
|
# CONFIG_SAMV7_UART0 is not set
|
||||||
|
# CONFIG_SAMV7_UART2 is not set
|
||||||
|
# CONFIG_SAMV7_UART4 is not set
|
||||||
|
CONFIG_ARCH="arm"
|
||||||
|
CONFIG_ARCH_BOARD="samv71-xult"
|
||||||
|
CONFIG_ARCH_BOARD_COMMON=y
|
||||||
|
CONFIG_ARCH_BOARD_SAMV71_XULT=y
|
||||||
|
CONFIG_ARCH_BUTTONS=y
|
||||||
|
CONFIG_ARCH_CHIP="samv7"
|
||||||
|
CONFIG_ARCH_CHIP_SAMV71=y
|
||||||
|
CONFIG_ARCH_CHIP_SAMV71Q21=y
|
||||||
|
CONFIG_ARCH_CHIP_SAMV71Q=y
|
||||||
|
CONFIG_ARCH_CHIP_SAMV7=y
|
||||||
|
CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
|
||||||
|
CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
|
||||||
|
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||||
|
CONFIG_ARCH_IRQBUTTONS=y
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_ARMV7M_DCACHE=y
|
||||||
|
CONFIG_ARMV7M_ICACHE=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=51262
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_FAT_LCNAMES=y
|
||||||
|
CONFIG_FAT_LFN=y
|
||||||
|
CONFIG_FS_FAT=y
|
||||||
|
CONFIG_FS_PROCFS=y
|
||||||
|
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_LIBC_HOSTNAME="SAMV71-XULT"
|
||||||
|
CONFIG_LINE_MAX=64
|
||||||
|
CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
|
||||||
|
CONFIG_MMCSD_SDIO=y
|
||||||
|
CONFIG_NET=y
|
||||||
|
CONFIG_NETDB_DNSCLIENT=y
|
||||||
|
CONFIG_NETDEV_HPWORK_THREAD=y
|
||||||
|
CONFIG_NETDEV_LATEINIT=y
|
||||||
|
CONFIG_NETDEV_PHY_IOCTL=y
|
||||||
|
CONFIG_NET_BROADCAST=y
|
||||||
|
CONFIG_NET_ICMP_SOCKET=y
|
||||||
|
CONFIG_NET_ICMPv6=y
|
||||||
|
CONFIG_NET_IPFRAG=y
|
||||||
|
CONFIG_NET_IPv6=y
|
||||||
|
CONFIG_NET_OA_TC6=y
|
||||||
|
CONFIG_NET_OA_TC6_LAN865X=y
|
||||||
|
CONFIG_NET_OA_TC6_NCV7410=y
|
||||||
|
CONFIG_NET_STATISTICS=y
|
||||||
|
CONFIG_NET_TCP=y
|
||||||
|
CONFIG_NET_TCP_DELAYED_ACK=y
|
||||||
|
CONFIG_NET_TCP_KEEPALIVE=y
|
||||||
|
CONFIG_NET_TCP_WRITE_BUFFERS=y
|
||||||
|
CONFIG_NET_UDP=y
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_RAM_SIZE=393216
|
||||||
|
CONFIG_RAM_START=0x20400000
|
||||||
|
CONFIG_RAW_BINARY=y
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_SAMV7_GPIOA_IRQ=y
|
||||||
|
CONFIG_SAMV7_GPIOB_IRQ=y
|
||||||
|
CONFIG_SAMV7_GPIOD_IRQ=y
|
||||||
|
CONFIG_SAMV7_GPIO_IRQ=y
|
||||||
|
CONFIG_SAMV7_HSMCI0=y
|
||||||
|
CONFIG_SAMV7_JTAG_FULL_SW_ENABLE=y
|
||||||
|
CONFIG_SAMV7_SPI0=y
|
||||||
|
CONFIG_SAMV7_SPI_DMA=y
|
||||||
|
CONFIG_SAMV7_SPI_DMATHRESHOLD=0
|
||||||
|
CONFIG_SAMV7_TWIHS0=y
|
||||||
|
CONFIG_SAMV7_USART1=y
|
||||||
|
CONFIG_SAMV7_XDMAC=y
|
||||||
|
CONFIG_SCHED_HPWORK=y
|
||||||
|
CONFIG_SCHED_LPWORK=y
|
||||||
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
CONFIG_SDIO_BLOCKSETUP=y
|
||||||
|
CONFIG_SPI_DELAY_CONTROL=y
|
||||||
|
CONFIG_START_DAY=10
|
||||||
|
CONFIG_START_MONTH=3
|
||||||
|
CONFIG_START_YEAR=2014
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_SYSTEM_PING6=y
|
||||||
|
CONFIG_SYSTEM_PING=y
|
||||||
|
CONFIG_USART1_SERIAL_CONSOLE=y
|
||||||
|
|
@ -105,6 +105,10 @@ ifeq ($(CONFIG_LCD_ST7789),y)
|
||||||
CSRCS += sam_st7789.c
|
CSRCS += sam_st7789.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_NET_OA_TC6),y)
|
||||||
|
CSRCS += sam_oa_tc6.c
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY = context distclean
|
.PHONY = context distclean
|
||||||
|
|
||||||
$(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE)
|
$(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE)
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,10 @@
|
||||||
# include "board_progmem.h"
|
# include "board_progmem.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_OA_TC6
|
||||||
|
# include "board_oa_tc6.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
@ -566,6 +570,14 @@ int sam_bringup(void)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_OA_TC6
|
||||||
|
ret = board_oa_tc6_initialize();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: board_oa_tc6_initialize() failed: %d\n", ret);
|
||||||
|
}
|
||||||
|
#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.
|
||||||
|
|
|
||||||
211
boards/arm/samv7/samv71-xult/src/sam_oa_tc6.c
Normal file
211
boards/arm/samv7/samv71-xult/src/sam_oa_tc6.c
Normal file
|
|
@ -0,0 +1,211 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/samv7/samv71-xult/src/sam_oa_tc6.c
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/spi/spi.h>
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/net/oa_tc6.h>
|
||||||
|
|
||||||
|
#include "sam_spi.h"
|
||||||
|
#include "sam_gpio.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define BOARD_OA_TC6_0_INT_PIN ( GPIO_INPUT | GPIO_CFG_PULLUP \
|
||||||
|
| GPIO_INT_FALLING | GPIO_PORT_PIOA \
|
||||||
|
| GPIO_PIN4)
|
||||||
|
#define BOARD_OA_TC6_0_IRQ SAM_IRQ_PA4
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int board_oa_tc6_attach(FAR const struct oa_tc6_config_s *config,
|
||||||
|
xcpt_t handler,
|
||||||
|
FAR void *arg);
|
||||||
|
|
||||||
|
static int board_oa_tc6_enable(FAR const struct oa_tc6_config_s *config,
|
||||||
|
bool enable);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static const struct oa_tc6_config_s g_esp_oa_tc6_config =
|
||||||
|
{
|
||||||
|
.id = SPIDEV_ETHERNET(0),
|
||||||
|
.frequency = 25000000,
|
||||||
|
.chunk_payload_size = 64,
|
||||||
|
.rx_cut_through = true,
|
||||||
|
.attach = board_oa_tc6_attach,
|
||||||
|
.enable = board_oa_tc6_enable,
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_oa_tc6_attach
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Configure interrupt and attach handler to the interrupt signal
|
||||||
|
* from the MAC-PHY.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* config - reference to the MAC-PHY configuration
|
||||||
|
* handler - the interrupt handler function
|
||||||
|
* arg - reference passed to the handler on invocation
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* On success OK is returned, otherwise ERROR is returned.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int board_oa_tc6_attach(FAR const struct oa_tc6_config_s *config,
|
||||||
|
xcpt_t handler, FAR void *arg)
|
||||||
|
{
|
||||||
|
gpio_pinset_t pin;
|
||||||
|
int irq;
|
||||||
|
|
||||||
|
switch (config->id)
|
||||||
|
{
|
||||||
|
case SPIDEV_ETHERNET(0):
|
||||||
|
pin = BOARD_OA_TC6_0_INT_PIN;
|
||||||
|
irq = BOARD_OA_TC6_0_IRQ;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
/* Unknown id */
|
||||||
|
|
||||||
|
DEBUGPANIC();
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
sam_configgpio(pin);
|
||||||
|
sam_gpioirq(pin);
|
||||||
|
irq_attach(irq, handler, arg);
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_oa_tc6_enable
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Enable or disable the interrupt on the hardware level.
|
||||||
|
* Enable when the enable argument is true, otherwise disable.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* config - reference to the MAC-PHY configuration
|
||||||
|
* enable - enable / disable control
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* On success OK is returned, otherwise ERROR is returned.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int board_oa_tc6_enable(FAR const struct oa_tc6_config_s *config,
|
||||||
|
bool enable)
|
||||||
|
{
|
||||||
|
int irq;
|
||||||
|
|
||||||
|
switch (config->id)
|
||||||
|
{
|
||||||
|
case SPIDEV_ETHERNET(0):
|
||||||
|
irq = BOARD_OA_TC6_0_IRQ;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
/* Unknown id */
|
||||||
|
|
||||||
|
DEBUGPANIC();
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
sam_gpioirqenable(irq);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sam_gpioirqdisable(irq);
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_oa_tc6_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize and register the OA-TC6 10BASE-T1x network driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_oa_tc6_initialize(void)
|
||||||
|
{
|
||||||
|
FAR struct spi_dev_s *spi;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
spi = sam_spibus_initialize(SPI0_CS1);
|
||||||
|
if (!spi)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: Failed to initialize SPI port %d\n", SPI0_CS1);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bind the SPI port and config to the OA-TC6 driver */
|
||||||
|
|
||||||
|
ret = oa_tc6_initialize(spi, &g_esp_oa_tc6_config);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR,
|
||||||
|
"ERROR: Failed to bind SPI port and config to the OA-TC6"
|
||||||
|
" network driver: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
syslog(LOG_INFO,
|
||||||
|
"Bound SPI and config to the OA-TC6 network driver\n");
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
@ -84,6 +84,12 @@ void sam_spidev_initialize(void)
|
||||||
sam_configgpio(GPIO_LCD_CD);
|
sam_configgpio(GPIO_LCD_CD);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_OA_TC6
|
||||||
|
/* Enable chip select for OA-TC6 MAC-PHY */
|
||||||
|
|
||||||
|
sam_configgpio(SPI0_NPCS1);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* CONFIG_SAMV7_SPI0_MASTER */
|
#endif /* CONFIG_SAMV7_SPI0_MASTER */
|
||||||
|
|
||||||
#ifdef CONFIG_SAMV7_SPI0_SLAVE
|
#ifdef CONFIG_SAMV7_SPI0_SLAVE
|
||||||
|
|
@ -183,6 +189,10 @@ void sam_spi0select(uint32_t devid, bool selected)
|
||||||
sam_gpiowrite(SPI0_NPCS1, !selected);
|
sam_gpiowrite(SPI0_NPCS1, !selected);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_NET_OA_TC6
|
||||||
|
case SPIDEV_ETHERNET(0):
|
||||||
|
sam_gpiowrite(SPI0_NPCS1, !selected);
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue