SAMV7: Quick'n'dirty port of the SAMA5D4 Ethernet MAC driver to the SAMV7. Still some unresovled issues with DCache handling

This commit is contained in:
Gregory Nutt 2015-03-16 13:51:37 -06:00
parent 8a73d9b8ea
commit a590bdc737
8 changed files with 5266 additions and 27 deletions

View File

@ -89,7 +89,7 @@
#define SAM_PID_MCAN01 (36) /* CAN0 IRQ line 1 */
#define SAM_PID_MCAN10 (37) /* CAN1 IRQ line 0 */
#define SAM_PID_MCAN11 (38) /* CAN1 IRQ line 1 */
#define SAM_PID_EMAC (39) /* Ethernet MAC */
#define SAM_PID_EMAC0 (39) /* Ethernet MAC */
#define SAM_PID_AFEC1 (40) /* Analog Front End 1 */
#define SAM_PID_TWIHS2 (41) /* Two-Wire Interface 2 */
#define SAM_PID_SPI1 (42) /* Serial Peripheral Interface 1 */
@ -159,7 +159,7 @@
#define SAM_IRQ_MCAN01 (SAM_IRQ_EXTINT+SAM_PID_MCAN01) /* CAN0 IRQ line 1 */
#define SAM_IRQ_MCAN10 (SAM_IRQ_EXTINT+SAM_PID_MCAN10) /* CAN1 IRQ line 0 */
#define SAM_IRQ_MCAN11 (SAM_IRQ_EXTINT+SAM_PID_MCAN11) /* CAN1 IRQ line 1 */
#define SAM_IRQ_EMAC (SAM_IRQ_EXTINT+SAM_PID_EMAC) /* Ethernet MAC */
#define SAM_IRQ_EMAC0 (SAM_IRQ_EXTINT+SAM_PID_EMAC0) /* Ethernet MAC */
#define SAM_IRQ_AFEC1 (SAM_IRQ_EXTINT+SAM_PID_AFEC1) /* Analog Front End 1 */
#define SAM_IRQ_TWIHS2 (SAM_IRQ_EXTINT+SAM_PID_TWIHS2) /* Two-Wire Interface 2 */
#define SAM_IRQ_SPI1 (SAM_IRQ_EXTINT+SAM_PID_SPI1) /* Serial Peripheral Interface 1 */

View File

@ -114,6 +114,10 @@ config SAMV7_HAVE_EBI
bool
default n
config SAMV7_EMAC
bool
default n
config SAMV7_HSMCI
bool
default n
@ -217,9 +221,10 @@ config SAMV7_EBI
default n
depends on SAMV7_HAVE_EBI
config SAMV7_EMAC
config SAMV7_EMAC0
bool "Ethernet MAC (GMAC)"
default n
select SAMV7_EMAC
select NETDEVICES
select ARCH_HAVE_PHY
@ -1009,3 +1014,225 @@ config SAMV7_HSMCI_REGDEBUG
Very invasive! Requires also DEBUG.
endmenu # HSMCI device driver options
menu "EMAC device driver options"
depends on SAMV7_EMAC0
config SAMV7_EMAC0_NRXBUFFERS
int "Number of RX buffers"
default 16
---help---
EMAC buffer memory is segmented into 128 byte units (not
configurable). This setting provides the number of such 128 byte
units used for reception. This is also equal to the number of RX
descriptors that will be allocated The selected value must be an
even power of 2.
config SAMV7_EMAC0_NTXBUFFERS
int "Number of TX buffers"
default 8
---help---
EMAC buffer memory is segmented into full Ethernet packets (size
NET_BUFSIZE bytes). This setting provides the number of such packets
that can be in flight. This is also equal to the number of TX
descriptors that will be allocated.
config SAMV7_EMAC0_PHYADDR
int "PHY address"
default 1
---help---
The 5-bit address of the PHY on the board. Default: 1
config SAMV7_EMAC0_PHYINIT
bool "Board-specific PHY Initialization"
default n
---help---
Some boards require specialized initialization of the PHY before it can be used.
This may include such things as configuring GPIOs, resetting the PHY, etc. If
SAMV7_EMAC0_PHYINIT is defined in the configuration then the board specific logic must
provide sam_phyinitialize(); The SAMV7 EMAC driver will call this function
one time before it first uses the PHY.
choice
prompt "PHY interface"
default SAMV7_EMAC0_MII
config SAMV7_EMAC0_MII
bool "MII"
---help---
Support Ethernet MII interface (vs RMII).
config SAMV7_EMAC0_RMII
bool "RMII"
depends on !ARCH_CHIP_SAM4E
---help---
Support Ethernet RMII interface (vs MII).
endchoice # PHY interface
config SAMV7_EMAC0_CLAUSE45
bool "Clause 45 MII"
depends on SAMV7_EMAC0_MII
---help---
MDIO was originally defined in Clause 22 of IEEE RFC802.3. In the
original specification, a single MDIO interface is able to access up
to 32 registers in 32 different PHY devices. To meet the needs the
expanding needs of 10-Gigabit Ethernet devices, Clause 45 of the
802.3ae specification provided the following additions to MDIO:
- Ability to access 65,536 registers in 32 different devices on
32 different ports
- Additional OP-code and ST-code for Indirect Address register
access for 10 Gigabit Ethernet
- End-to-end fault signaling
- Multiple loopback points
- Low voltage electrical specification
By default, Clause 22 PHYs will be supported unless this option is
selected.
config SAMV7_EMAC0_AUTONEG
bool "Use autonegotiation"
default y
---help---
Use PHY autonegotiation to determine speed and mode
config SAMV7_EMAC0_ETHFD
bool "Full duplex"
default n
depends on !SAMV7_EMAC0_AUTONEG
---help---
If SAMV7_EMAC0_AUTONEG is not defined, then this may be defined to select full duplex
mode. Default: half-duplex
config SAMV7_EMAC0_ETH100MBPS
bool "100 Mbps"
default n
depends on !SAMV7_EMAC0_AUTONEG
---help---
If SAMV7_EMAC0_AUTONEG is not defined, then this may be defined to select 100 MBps
speed. Default: 10 Mbps
config SAMV7_EMAC0_PHYSR
int "PHY Status Register Address (decimal)"
depends on SAMV7_EMAC0_AUTONEG
---help---
This must be provided if SAMV7_EMAC0_AUTONEG is defined. The PHY status register
address may diff from PHY to PHY. This configuration sets the address of
the PHY status register.
config SAMV7_EMAC0_PHYSR_ALTCONFIG
bool "PHY Status Alternate Bit Layout"
default n
depends on SAMV7_EMAC0_AUTONEG
---help---
Different PHYs present speed and mode information in different ways. Some
will present separate information for speed and mode (this is the default).
Those PHYs, for example, may provide a 10/100 Mbps indication and a separate
full/half duplex indication. This options selects an alternative representation
where speed and mode information are combined. This might mean, for example,
separate bits for 10HD, 100HD, 10FD and 100FD.
if SAMV7_EMAC0_AUTONEG
if SAMV7_EMAC0_PHYSR_ALTCONFIG
config SAMV7_EMAC0_PHYSR_ALTMODE
hex "PHY Mode Mask"
---help---
This must be provided if SAMV7_EMAC0_AUTONEG is defined. This provide bit mask
for isolating the speed and full/half duplex mode bits.
config SAMV7_EMAC0_PHYSR_10HD
hex "10MBase-T Half Duplex Value"
---help---
This must be provided if SAMV7_EMAC0_AUTONEG is defined. This is the value
under the bit mask that represents the 10Mbps, half duplex setting.
config SAMV7_EMAC0_PHYSR_100HD
hex "100Base-T Half Duplex Value"
---help---
This must be provided if SAMV7_EMAC0_AUTONEG is defined. This is the value
under the bit mask that represents the 100Mbps, half duplex setting.
config SAMV7_EMAC0_PHYSR_10FD
hex "10Base-T Full Duplex Value"
---help---
This must be provided if SAMV7_EMAC0_AUTONEG is defined. This is the value
under the bit mask that represents the 10Mbps, full duplex setting.
config SAMV7_EMAC0_PHYSR_100FD
hex "100Base-T Full Duplex Value"
---help---
This must be provided if SAMV7_EMAC0_AUTONEG is defined. This is the value
under the bit mask that represents the 100Mbps, full duplex setting.
endif # SAMV7_EMAC0_PHYSR_ALTCONFIG
if !SAMV7_EMAC0_PHYSR_ALTCONFIG
config SAMV7_EMAC0_PHYSR_SPEED
hex "PHY Speed Mask"
---help---
This must be provided if SAMV7_EMAC0_AUTONEG is defined. This provides bit mask
for isolating the 10 or 100MBps speed indication.
config SAMV7_EMAC0_PHYSR_100MBPS
hex "PHY 100Mbps Speed Value"
---help---
This must be provided if SAMV7_EMAC0_AUTONEG is defined. This provides the value
of the speed bit(s) indicating 100MBps speed.
config SAMV7_EMAC0_PHYSR_MODE
hex "PHY Mode Mask"
---help---
This must be provided if SAMV7_EMAC0_AUTONEG is defined. This provides the
bit mask for isolating the full or half duplex mode bits.
config SAMV7_EMAC0_PHYSR_FULLDUPLEX
hex "PHY Full Duplex Mode Value"
---help---
This must be provided if SAMV7_EMAC0_AUTONEG is defined. This provides the
value of the mode bits indicating full duplex mode.
endif # !SAMV7_EMAC0_PHYSR_ALTCONFIG
endif # SAMV7_EMAC0_AUTONEG
# These apply to both EMAC0 and EMAC1 (but are in the EMAC0 menu for now
# because there is not yet any SAMV7 chip that supports two Ethernet MACS
config SAMV7_EMAC0_ISETH0
bool
default y
config SAMV7_EMAC_PREALLOCATE
bool "Preallocate buffers"
default n
---help---
Buffer an descriptor many may either be allocated from the memory
pool or pre-allocated to lie in .bss. This options selected pre-
allocated buffer memory.
config SAMV7_EMAC_NBC
bool "Disable Broadcast"
default n
---help---
Select to disable receipt of broadcast packets.
config SAMV7_EMAC_DEBUG
bool "Force EMAC0/1 DEBUG"
default n
depends on DEBUG && !DEBUG_NET
---help---
This option will force debug output from EMAC driver even without
network debug output enabled. This is not normally something
that would want to do but is convenient if you are debugging the
driver and do not want to get overloaded with other
network-related debug output.
config SAMV7_EMAC_REGDEBUG
bool "Register-Level Debug"
default n
depends on DEBUG
---help---
Enable very low-level register access debug. Depends on DEBUG.
endmenu # EMAC0 device driver options

View File

@ -140,3 +140,7 @@ endif
ifeq ($(CONFIG_SAMV7_HSMCI),y)
CHIP_CSRCS += sam_hsmci.c sam_hsmci_clkdiv.c
endif
ifeq ($(CONFIG_SAMV7_EMAC),y)
CHIP_CSRCS += sam_emac.c sam_ethernet.c
endif

View File

@ -167,28 +167,28 @@
/* Ethernet MAC Controller (EMAC) */
#define GPIO_EMAC_COL (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN13)
#define GPIO_EMAC_CRS (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN10)
#define GPIO_EMAC_MDC (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN8)
#define GPIO_EMAC_MDIO (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN9)
#define GPIO_EMAC_RX0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN5)
#define GPIO_EMAC_RX1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN6)
#define GPIO_EMAC_RX2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN11)
#define GPIO_EMAC_RX3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN12)
#define GPIO_EMAC_RXCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN14)
#define GPIO_EMAC_RXDV (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN4)
#define GPIO_EMAC_RXER (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN7)
#define GPIO_EMAC_TSUCOMP_1 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN1)
#define GPIO_EMAC_TSUCOMP_2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN12)
#define GPIO_EMAC_TSUCOMP_3 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN11)
#define GPIO_EMAC_TSUCOMP_4 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN20)
#define GPIO_EMAC_TX0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN2)
#define GPIO_EMAC_TX1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN3)
#define GPIO_EMAC_TX2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN15)
#define GPIO_EMAC_TX3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN16)
#define GPIO_EMAC_TXCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN0)
#define GPIO_EMAC_TXEN (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN1)
#define GPIO_EMAC_TXER (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN17)
#define GPIO_EMAC0_COL (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN13)
#define GPIO_EMAC0_CRS (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN10)
#define GPIO_EMAC0_MDC (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN8)
#define GPIO_EMAC0_MDIO (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN9)
#define GPIO_EMAC0_RX0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN5)
#define GPIO_EMAC0_RX1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN6)
#define GPIO_EMAC0_RX2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN11)
#define GPIO_EMAC0_RX3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN12)
#define GPIO_EMAC0_RXCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN14)
#define GPIO_EMAC0_RXDV (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN4)
#define GPIO_EMAC0_RXER (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN7)
#define GPIO_EMAC0_TSUCOMP_1 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN1)
#define GPIO_EMAC0_TSUCOMP_2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN12)
#define GPIO_EMAC0_TSUCOMP_3 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN11)
#define GPIO_EMAC0_TSUCOMP_4 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN20)
#define GPIO_EMAC0_TX0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN2)
#define GPIO_EMAC0_TX1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN3)
#define GPIO_EMAC0_TX2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN15)
#define GPIO_EMAC0_TX3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN16)
#define GPIO_EMAC0_TXCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN0)
#define GPIO_EMAC0_TXEN (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN1)
#define GPIO_EMAC0_TXER (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN17)
/* Image Sensor Interface (ISI) */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,118 @@
/****************************************************************************
* arch/arm/src/samv7/sam_ethernet.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include "sam_ethernet.h"
#ifdef CONFIG_NET
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Function: up_netinitialize
*
* Description:
* This is the "standard" network initialization logic called from the
* low-level initialization logic in up_initialize.c. This is just
* a shim to support the slightly different prototype of
* sam_emac_intiialize() and to provide support for future chips that
* may have multiple EMAC peripherals.
*
* Parameters:
* None.
*
* Returned Value:
* None.
*
* Assumptions:
*
****************************************************************************/
void up_netinitialize(void)
{
#ifdef CONFIG_SAMV7_EMAC0
int ret;
#ifdef CONFIG_SAMV7_EMAC0
/* Initialize the EMAC0 driver */
ret = sam_emac_initialize(EMAC0_INTF);
if (ret < 0)
{
nlldbg("ERROR: up_emac_initialize(EMAC0) failed: %d\n", ret);
}
#endif
#ifdef CONFIG_SAMV7_EMAC1
/* Initialize the EMAC1 driver */
ret = sam_emac_initialize(EMAC1_INTF);
if (ret < 0)
{
nlldbg("ERROR: up_emac_initialize(EMAC1) failed: %d\n", ret);
}
#endif
#endif
}
#endif /* CONFIG_NET */

View File

@ -0,0 +1,234 @@
/************************************************************************************
* arch/arm/src/samv7/sam_ethernet.h
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
#ifndef __ARCH_ARM_SRC_SAMV7_SAM_ETHERNET_H
#define __ARCH_ARM_SRC_SAMV7_SAM_ETHERNET_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <arch/samv7/chip.h>
#include "chip/sam_emac.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Understood PHY types */
#define SAMV7_PHY_DM9161 0
#define SAMV7_PHY_LAN8700 1
#define SAMV7_PHY_KSZ8051 2
#define SAMV7_PHY_KSZ8061 3
#define SAMV7_PHY_KSZ8081 4
#define SAMV7_PHY_KSZ90x1 5
/* Definitions for use with sam_phy_boardinitialize */
#define EMAC0_INTF 0
#define EMAC1_INTF 1
/* Which is ETH0 and which is ETH1? */
#ifndef CONFIG_SAMV7_EMAC
# undef CONFIG_SAMV7_EMAC0_ISETH0
# undef CONFIG_SAMV7_EMAC1_ISETH0
#endif
#if defined(CONFIG_SAMV7_EMAC0_ISETH0) && defined(CONFIG_SAMV7_EMAC1_ISETH0)
# error EMAC0 and EMAC2 cannot both be ETH0
#endif
#if defined(CONFIG_SAMV7_EMAC0_ISETH0)
# if defined(CONFIG_ETH0_PHY_DM9161)
# define SAMV7_EMAC0_PHY_DM9161 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_DM9161
# elif defined(CONFIG_ETH0_PHY_LAN8700)
# define SAMV7_EMAC0_PHY_LAN8700 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_LAN8700
# elif defined(CONFIG_ETH0_PHY_KSZ8051)
# define SAMV7_EMAC0_PHY_KSZ8051 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_KSZ8051
# elif defined(CONFIG_ETH0_PHY_KSZ8061)
# define SAMV7_EMAC0_PHY_KSZ8061 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_KSZ8061
# elif defined(CONFIG_ETH0_PHY_KSZ8081)
# define SAMV7_EMAC0_PHY_KSZ8081 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_KSZ8081
# elif defined(CONFIG_ETH0_PHY_KSZ90x1)
# define SAMV7_EMAC0_PHY_KSZ90x1 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_KSZ90x1
# else
# error ETH0 PHY unrecognized
# endif
#elif defined(CONFIG_SAMV7_EMAC0)
# if defined(CONFIG_ETH1_PHY_DM9161)
# define SAMV7_EMAC0_PHY_DM9161 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_DM9161
# elif defined(CONFIG_ETH1_PHY_LAN8700)
# define SAMV7_EMAC0_PHY_LAN8700 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_LAN8700
# elif defined(CONFIG_ETH1_PHY_KSZ8051)
# define SAMV7_EMAC0_PHY_KSZ8051 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_KSZ8051
# elif defined(CONFIG_ETH1_PHY_KSZ8061)
# define SAMV7_EMAC0_PHY_KSZ8061 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_KSZ8061
# elif defined(CONFIG_ETH0_PHY_KSZ8081)
# define SAMV7_EMAC0_PHY_KSZ8081 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_KSZ8081
# elif defined(CONFIG_ETH1_PHY_KSZ90x1)
# define SAMV7_EMAC0_PHY_KSZ90x1 1
# define SAMV7_EMAC0_PHY_TYPE SAMV7_PHY_KSZ90x1
# else
# error ETH1 PHY unrecognized
# endif
#endif
#if defined(CONFIG_SAMV7_EMAC1_ISETH0)
# if defined(CONFIG_ETH0_PHY_DM9161)
# define SAMV7_EMAC1_PHY_DM9161 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_DM9161
# elif defined(CONFIG_ETH0_PHY_LAN8700)
# define SAMV7_EMAC1_PHY_LAN8700 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_LAN8700
# elif defined(CONFIG_ETH0_PHY_KSZ8051)
# define SAMV7_EMAC1_PHY_KSZ8051 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_KSZ8051
# elif defined(CONFIG_ETH0_PHY_KSZ8061)
# define SAMV7_EMAC1_PHY_KSZ8061 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_KSZ8061
# elif defined(CONFIG_ETH0_PHY_KSZ8081)
# define SAMV7_EMAC1_PHY_KSZ8081 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_KSZ8081
# elif defined(CONFIG_ETH0_PHY_KSZ90x1)
# define SAMV7_EMAC1_PHY_KSZ90x1 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_KSZ90x1
# else
# error ETH0 PHY unrecognized
# endif
#elif defined(CONFIG_SAMV7_EMAC1)
# if defined(CONFIG_ETH1_PHY_DM9161)
# define SAMV7_EMAC1_PHY_DM9161 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_DM9161
# elif defined(CONFIG_ETH1_PHY_LAN8700)
# define SAMV7_EMAC1_PHY_LAN8700 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_LAN8700
# elif defined(CONFIG_ETH1_PHY_KSZ8051)
# define SAMV7_EMAC1_PHY_KSZ8051 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_KSZ8051
# elif defined(CONFIG_ETH1_PHY_KSZ8061)
# define SAMV7_EMAC1_PHY_KSZ8061 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_KSZ8061
# elif defined(CONFIG_ETH0_PHY_KSZ8081)
# define SAMV7_EMAC1_PHY_KSZ8081 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_KSZ8081
# elif defined(CONFIG_ETH1_PHY_KSZ90x1)
# define SAMV7_EMAC1_PHY_KSZ90x1 1
# define SAMV7_EMAC1_PHY_TYPE SAMV7_PHY_KSZ90x1
# else
# error ETH1 PHY unrecognized
# endif
#endif
/************************************************************************************
* Public Functions
************************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Function: sam_emac_initialize
*
* Description:
* Initialize the EMAC driver.
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success; Negated errno on failure.
*
* Assumptions:
* Called very early in the initialization sequence.
*
****************************************************************************/
#ifdef CONFIG_SAMV7_EMAC
int sam_emac_initialize(int intf);
#endif
/************************************************************************************
* Function: sam_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_SAMV7_PHYINIT is defined in the configuration then the board specific
* logic must provide sam_phyinitialize(); The SAMV7 Ethernet driver will call
* this function one time before it first uses the PHY.
*
* Parameters:
* intf - Always zero for now.
*
* Returned Value:
* OK on success; Negated errno on failure.
*
* Assumptions:
*
************************************************************************************/
#ifdef CONFIG_SAMV7_PHYINIT
int sam_phy_boardinitialize(int intf);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMV7_SAM_ETHERNET_H */

View File

@ -96,7 +96,7 @@
#define sam_mcan01_enableclk()
#define sam_mcan10_enableclk() sam_enableperiph1(SAM_PID_MCAN10)
#define sam_mcan11_enableclk()
#define sam_emac_enableclk() sam_enableperiph1(SAM_PID_EMAC)
#define sam_emac0_enableclk() sam_enableperiph1(SAM_PID_EMAC0)
#define sam_afec1_enableclk() sam_enableperiph1(SAM_PID_AFEC1)
#define sam_twihs2_enableclk() sam_enableperiph1(SAM_PID_TWIHS2)
#define sam_spi1_enableclk() sam_enableperiph1(SAM_PID_SPI1)
@ -164,7 +164,7 @@
#define sam_mcan01_disableclk()
#define sam_mcan10_disableclk() sam_disableperiph1(SAM_PID_MCAN10)
#define sam_mcan11_disableclk()
#define sam_emac_disableclk() sam_disableperiph1(SAM_PID_EMAC)
#define sam_emac0_disableclk() sam_disableperiph1(SAM_PID_EMAC0)
#define sam_afec1_disableclk() sam_disableperiph1(SAM_PID_AFEC1)
#define sam_twihs2_disableclk() sam_disableperiph1(SAM_PID_TWIHS2)
#define sam_spi1_disableclk() sam_disableperiph1(SAM_PID_SPI1)