am335x_eth_driver.c File Reference

Sitara AM335x Gigabit Ethernet MAC driver. More...

#include "soc_am335x.h"
#include "hw_types.h"
#include "hw_cm_per.h"
#include "hw_control_am335x.h"
#include "hw_cpsw_ale.h"
#include "hw_cpsw_cpdma.h"
#include "hw_cpsw_cpdma_stateram.h"
#include "hw_cpsw_port.h"
#include "hw_cpsw_sl.h"
#include "hw_cpsw_ss.h"
#include "hw_cpsw_wr.h"
#include "hw_mdio.h"
#include "interrupt.h"
#include "core/net.h"
#include "drivers/mac/am335x_eth_driver.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NIC_TRACE_LEVEL
 
#define MDIO_INPUT_CLK   125000000
 
#define MDIO_OUTPUT_CLK   1000000
 

Functions

error_t am335xEthInitPort1 (NetInterface *interface)
 AM335x Ethernet MAC initialization (port 1) More...
 
error_t am335xEthInitPort2 (NetInterface *interface)
 AM335x Ethernet MAC initialization (port 2) More...
 
void am335xEthInitInstance (NetInterface *interface)
 Initialize CPSW instance. More...
 
__weak_func void am335xEthInitGpio (NetInterface *interface)
 GPIO configuration. More...
 
void am335xEthInitBufferDesc (NetInterface *interface)
 Initialize buffer descriptor lists. More...
 
void am335xEthTick (NetInterface *interface)
 AM335x Ethernet MAC timer handler. More...
 
void am335xEthEnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void am335xEthDisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
void am335xEthTxIrqHandler (void)
 Ethernet MAC transmit interrupt. More...
 
void am335xEthRxIrqHandler (void)
 Ethernet MAC receive interrupt. More...
 
void am335xEthEventHandler (NetInterface *interface)
 AM335x Ethernet MAC event handler. More...
 
error_t am335xEthSendPacketPort1 (NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
 Send a packet (port 1) More...
 
error_t am335xEthSendPacketPort2 (NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
 Send a packet (port 2) More...
 
error_t am335xEthUpdateMacAddrFilter (NetInterface *interface)
 Configure MAC address filtering. More...
 
error_t am335xEthUpdateMacConfig (NetInterface *interface)
 Adjust MAC configuration parameters for proper operation. More...
 
void am335xEthWritePhyReg (uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
 Write PHY register. More...
 
uint16_t am335xEthReadPhyReg (uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
 Read PHY register. More...
 
void am335xEthWriteEntry (uint_t index, const Am335xAleEntry *entry)
 Write an ALE table entry. More...
 
void am335xEthReadEntry (uint_t index, Am335xAleEntry *entry)
 Read an ALE table entry. More...
 
uint_t am335xEthFindFreeEntry (void)
 Find a free entry in the ALE table. More...
 
uint_t am335xEthFindVlanEntry (uint_t vlanId)
 Search the ALE table for the specified VLAN entry. More...
 
uint_t am335xEthFindVlanAddrEntry (uint_t vlanId, MacAddr *macAddr)
 Search the ALE table for the specified VLAN/address entry. More...
 
error_t am335xEthAddVlanEntry (uint_t port, uint_t vlanId)
 Add a VLAN entry in the ALE table. More...
 
error_t am335xEthAddVlanAddrEntry (uint_t port, uint_t vlanId, MacAddr *macAddr)
 Add a VLAN/address entry in the ALE table. More...
 
error_t am335xEthDeleteVlanAddrEntry (uint_t port, uint_t vlanId, MacAddr *macAddr)
 Remove a VLAN/address entry from the ALE table. More...
 

Variables

const NicDriver am335xEthPort1Driver
 AM335x Ethernet MAC driver (port1) More...
 
const NicDriver am335xEthPort2Driver
 AM335x Ethernet MAC driver (port2) More...
 

Detailed Description

Sitara AM335x Gigabit Ethernet MAC driver.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file am335x_eth_driver.c.

Macro Definition Documentation

◆ MDIO_INPUT_CLK

#define MDIO_INPUT_CLK   125000000

Definition at line 53 of file am335x_eth_driver.c.

◆ MDIO_OUTPUT_CLK

#define MDIO_OUTPUT_CLK   1000000

Definition at line 55 of file am335x_eth_driver.c.

◆ TRACE_LEVEL

#define TRACE_LEVEL   NIC_TRACE_LEVEL

Definition at line 32 of file am335x_eth_driver.c.

Function Documentation

◆ am335xEthAddVlanAddrEntry()

error_t am335xEthAddVlanAddrEntry ( uint_t  port,
uint_t  vlanId,
MacAddr macAddr 
)

Add a VLAN/address entry in the ALE table.

Parameters
[in]portPort number
[in]vlanIdVLAN identifier
[in]macAddrMAC address
Returns
Error code

Definition at line 1808 of file am335x_eth_driver.c.

◆ am335xEthAddVlanEntry()

error_t am335xEthAddVlanEntry ( uint_t  port,
uint_t  vlanId 
)

Add a VLAN entry in the ALE table.

Parameters
[in]portPort number
[in]vlanIdVLAN identifier
Returns
Error code

Definition at line 1748 of file am335x_eth_driver.c.

◆ am335xEthDeleteVlanAddrEntry()

error_t am335xEthDeleteVlanAddrEntry ( uint_t  port,
uint_t  vlanId,
MacAddr macAddr 
)

Remove a VLAN/address entry from the ALE table.

Parameters
[in]portPort number
[in]vlanIdVLAN identifier
[in]macAddrMAC address
Returns
Error code

Definition at line 1879 of file am335x_eth_driver.c.

◆ am335xEthDisableIrq()

void am335xEthDisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 894 of file am335x_eth_driver.c.

◆ am335xEthEnableIrq()

void am335xEthEnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 858 of file am335x_eth_driver.c.

◆ am335xEthEventHandler()

void am335xEthEventHandler ( NetInterface interface)

AM335x Ethernet MAC event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 1072 of file am335x_eth_driver.c.

◆ am335xEthFindFreeEntry()

uint_t am335xEthFindFreeEntry ( void  )

Find a free entry in the ALE table.

Returns
Index of the first free entry

Definition at line 1621 of file am335x_eth_driver.c.

◆ am335xEthFindVlanAddrEntry()

uint_t am335xEthFindVlanAddrEntry ( uint_t  vlanId,
MacAddr macAddr 
)

Search the ALE table for the specified VLAN/address entry.

Parameters
[in]vlanIdVLAN identifier
[in]macAddrMAC address
Returns
Index of the matching entry

Definition at line 1697 of file am335x_eth_driver.c.

◆ am335xEthFindVlanEntry()

uint_t am335xEthFindVlanEntry ( uint_t  vlanId)

Search the ALE table for the specified VLAN entry.

Parameters
[in]vlanIdVLAN identifier
Returns
Index of the matching entry

Definition at line 1655 of file am335x_eth_driver.c.

◆ am335xEthInitBufferDesc()

void am335xEthInitBufferDesc ( NetInterface interface)

Initialize buffer descriptor lists.

Parameters
[in]interfaceUnderlying network interface

Definition at line 715 of file am335x_eth_driver.c.

◆ am335xEthInitGpio()

__weak_func void am335xEthInitGpio ( NetInterface interface)

GPIO configuration.

Parameters
[in]interfaceUnderlying network interface

Definition at line 500 of file am335x_eth_driver.c.

◆ am335xEthInitInstance()

void am335xEthInitInstance ( NetInterface interface)

Initialize CPSW instance.

Parameters
[in]interfaceUnderlying network interface

Definition at line 327 of file am335x_eth_driver.c.

◆ am335xEthInitPort1()

error_t am335xEthInitPort1 ( NetInterface interface)

AM335x Ethernet MAC initialization (port 1)

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 178 of file am335x_eth_driver.c.

◆ am335xEthInitPort2()

error_t am335xEthInitPort2 ( NetInterface interface)

AM335x Ethernet MAC initialization (port 2)

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 253 of file am335x_eth_driver.c.

◆ am335xEthReadEntry()

void am335xEthReadEntry ( uint_t  index,
Am335xAleEntry entry 
)

Read an ALE table entry.

Parameters
[in]indexEntry index
[out]entryPointer to the ALE table entry

Definition at line 1604 of file am335x_eth_driver.c.

◆ am335xEthReadPhyReg()

uint16_t am335xEthReadPhyReg ( uint8_t  opcode,
uint8_t  phyAddr,
uint8_t  regAddr 
)

Read PHY register.

Parameters
[in]opcodeAccess type (2 bits)
[in]phyAddrPHY address (5 bits)
[in]regAddrRegister address (5 bits)
Returns
Register value

Definition at line 1543 of file am335x_eth_driver.c.

◆ am335xEthRxIrqHandler()

void am335xEthRxIrqHandler ( void  )

Ethernet MAC receive interrupt.

Definition at line 1025 of file am335x_eth_driver.c.

◆ am335xEthSendPacketPort1()

error_t am335xEthSendPacketPort1 ( NetInterface interface,
const NetBuffer buffer,
size_t  offset,
NetTxAncillary ancillary 
)

Send a packet (port 1)

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer containing the data to send
[in]offsetOffset to the first data byte
[in]ancillaryAdditional options passed to the stack along with the packet
Returns
Error code

Definition at line 1206 of file am335x_eth_driver.c.

◆ am335xEthSendPacketPort2()

error_t am335xEthSendPacketPort2 ( NetInterface interface,
const NetBuffer buffer,
size_t  offset,
NetTxAncillary ancillary 
)

Send a packet (port 2)

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer containing the data to send
[in]offsetOffset to the first data byte
[in]ancillaryAdditional options passed to the stack along with the packet
Returns
Error code

Definition at line 1295 of file am335x_eth_driver.c.

◆ am335xEthTick()

void am335xEthTick ( NetInterface interface)

AM335x Ethernet MAC timer handler.

This routine is periodically called by the TCP/IP stack to handle periodic operations such as polling the link state

Parameters
[in]interfaceUnderlying network interface

Definition at line 821 of file am335x_eth_driver.c.

◆ am335xEthTxIrqHandler()

void am335xEthTxIrqHandler ( void  )

Ethernet MAC transmit interrupt.

Definition at line 929 of file am335x_eth_driver.c.

◆ am335xEthUpdateMacAddrFilter()

error_t am335xEthUpdateMacAddrFilter ( NetInterface interface)

Configure MAC address filtering.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 1380 of file am335x_eth_driver.c.

◆ am335xEthUpdateMacConfig()

error_t am335xEthUpdateMacConfig ( NetInterface interface)

Adjust MAC configuration parameters for proper operation.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 1438 of file am335x_eth_driver.c.

◆ am335xEthWriteEntry()

void am335xEthWriteEntry ( uint_t  index,
const Am335xAleEntry entry 
)

Write an ALE table entry.

Parameters
[in]indexEntry index
[in]entryPointer to the ALE table entry

Definition at line 1586 of file am335x_eth_driver.c.

◆ am335xEthWritePhyReg()

void am335xEthWritePhyReg ( uint8_t  opcode,
uint8_t  phyAddr,
uint8_t  regAddr,
uint16_t  data 
)

Write PHY register.

Parameters
[in]opcodeAccess type (2 bits)
[in]phyAddrPHY address (5 bits)
[in]regAddrRegister address (5 bits)
[in]dataRegister value

Definition at line 1504 of file am335x_eth_driver.c.

Variable Documentation

◆ am335xEthPort1Driver

◆ am335xEthPort2Driver

error_t am335xEthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
#define TRUE
Definition: os_port.h:50
uint16_t am335xEthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
error_t am335xEthInitPort2(NetInterface *interface)
AM335x Ethernet MAC initialization (port 2)
void am335xEthDisableIrq(NetInterface *interface)
Disable interrupts.
error_t am335xEthSendPacketPort2(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet (port 2)
#define FALSE
Definition: os_port.h:46
error_t am335xEthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
void am335xEthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
error_t am335xEthSendPacketPort1(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet (port 1)
void am335xEthEnableIrq(NetInterface *interface)
Enable interrupts.
void am335xEthEventHandler(NetInterface *interface)
AM335x Ethernet MAC event handler.
#define ETH_MTU
Definition: ethernet.h:116
void am335xEthTick(NetInterface *interface)
AM335x Ethernet MAC timer handler.
error_t am335xEthInitPort1(NetInterface *interface)
AM335x Ethernet MAC initialization (port 1)
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83