no-OS
Loading...
Searching...
No Matches
adin1140.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "no_os_spi.h"
#include "no_os_util.h"
#include "oa_tc6.h"
Include dependency graph for adin1140.h:

Classes

struct  adin1140_desc
 ADIN1140 device descriptor. More...
 
struct  adin1140_mac_cfg
 MAC CONFIG0 user-configurable bitfields. TXFCSVE is always cleared so the MAC appends the FCS itself; SYNC, PROTE, SEQE are managed internally and not exposed here. More...
 
struct  adin1140_plca_diag
 PLCA diagnostic latches read from the DIAG register. All bits are sticky (W1C) on the device; pass clear=true to adin1140_plca_get_diag to acknowledge after reading. More...
 
struct  adin1140_plca_cfg
 PLCA (Physical Layer Collision Avoidance) configuration. More...
 
struct  adin1140_init_param
 Initialization parameter for the device descriptor. More...
 
struct  adin1140_eth_buff
 Buffer structure used for frame RX and TX transactions. More...
 
struct  adin1140_stats
 MAC hardware statistics counters (free-running accumulators read from the device counter registers). More...
 

Macros

#define ADIN1140_ETH_ALEN   6
 
#define ADIN1140_ETH_HDR_LEN   14
 
#define ADIN1140_PHY_ID   0x0283BE00
 
#define ADIN1140_MACPHY_ID_REG   OA_MMS_REG(0x0, 0x0001)
 
#define ADIN1140_CONFIG0_REG   OA_MMS_REG(0x0, 0x0004)
 
#define ADIN1140_CONFIG2_REG   OA_MMS_REG(0x0, 0x0006)
 
#define ADIN1140_STATUS0_REG   OA_MMS_REG(0x0, 0x0008)
 
#define ADIN1140_STATUS1_REG   OA_MMS_REG(0x0, 0x0009)
 
#define ADIN1140_IMASK1_REG   OA_MMS_REG(0x0, 0x000D)
 
#define ADIN1140_CONFIG0_SYNC   NO_OS_BIT(15)
 
#define ADIN1140_CONFIG0_TXFCSVE   NO_OS_BIT(14)
 
#define ADIN1140_CONFIG0_CSARFE   NO_OS_BIT(13)
 
#define ADIN1140_CONFIG0_ZARFE   NO_OS_BIT(12)
 
#define ADIN1140_CONFIG0_TXCTHRESH_MASK   NO_OS_GENMASK(11, 10)
 
#define ADIN1140_CONFIG0_TXCTE   NO_OS_BIT(9)
 
#define ADIN1140_CONFIG0_RXCTE   NO_OS_BIT(8)
 
#define ADIN1140_CONFIG0_FTSE   NO_OS_BIT(7)
 
#define ADIN1140_CONFIG0_FTSS   NO_OS_BIT(6)
 
#define ADIN1140_CONFIG0_CPS_MASK   NO_OS_GENMASK(2, 0)
 
#define ADIN1140_CONFIG0_CPS_64   NO_OS_GENMASK(2, 1)
 
#define ADIN1140_CONFIG2_FWD_UNK2HOST   NO_OS_BIT(2)
 
#define ADIN1140_STATUS0_RESETC   NO_OS_BIT(6)
 
#define ADIN1140_STATUS1_LINK_STATE   NO_OS_BIT(0)
 
#define ADIN1140_IMASK1_P1_RX_RDY_MASK   NO_OS_BIT(4)
 
#define ADIN1140_MAC_ADDR_FILT_UPR_REG(x)
 
#define ADIN1140_MAC_ADDR_FILT_LWR_REG(x)
 
#define ADIN1140_MAC_ADDR_MASK_UPR_REG(x)
 
#define ADIN1140_MAC_ADDR_MASK_LWR_REG(x)
 
#define ADIN1140_MAC_P1_LOOP_REG   OA_MMS_REG(0x1, 0xC4)
 
#define ADIN1140_MAC_ADDR_MASK_SLOTS   2
 
#define ADIN1140_MAC_ADDR_APPLY2PORT1   NO_OS_BIT(30)
 
#define ADIN1140_MAC_ADDR_TO_HOST   NO_OS_BIT(16)
 
#define ADIN1140_MAC_FILT_MULTICAST_SLOT   0
 
#define ADIN1140_MAC_FILT_BROADCAST_SLOT   1
 
#define ADIN1140_MAC_FILT_UNICAST_SLOT   2
 
#define ADIN1140_MAC_FILT_MAX_SLOT   16
 
#define ADIN1140_PHY_C45_PCS_MMS   2
 
#define ADIN1140_PHY_C45_PMA_PMD_MMS   3
 
#define ADIN1140_PHY_C45_VS_PLCA_MMS   4
 
#define ADIN1140_PLCA_IDVER_REG   OA_MMS_REG(0x4, 0xCA00)
 
#define ADIN1140_PLCA_CTRL0_REG   OA_MMS_REG(0x4, 0xCA01)
 
#define ADIN1140_PLCA_CTRL1_REG   OA_MMS_REG(0x4, 0xCA02)
 
#define ADIN1140_PLCA_STATUS_REG   OA_MMS_REG(0x4, 0xCA03)
 
#define ADIN1140_PLCA_TOTMR_REG   OA_MMS_REG(0x4, 0xCA04)
 
#define ADIN1140_PLCA_BURST_REG   OA_MMS_REG(0x4, 0xCA05)
 
#define ADIN1140_PLCA_DIAG_REG   OA_MMS_REG(0x4, 0xCA06)
 
#define ADIN1140_PLCA_CTRL0_EN   NO_OS_BIT(15)
 
#define ADIN1140_PLCA_CTRL0_RST   NO_OS_BIT(14)
 
#define ADIN1140_PLCA_CTRL1_NCNT_MASK   NO_OS_GENMASK(15, 8)
 
#define ADIN1140_PLCA_CTRL1_ID_MASK   NO_OS_GENMASK(7, 0)
 
#define ADIN1140_PLCA_STATUS_PST   NO_OS_BIT(15)
 
#define ADIN1140_PLCA_TOTMR_MASK   NO_OS_GENMASK(7, 0)
 
#define ADIN1140_PLCA_BURST_MAXBC_MASK   NO_OS_GENMASK(15, 8)
 
#define ADIN1140_PLCA_BURST_BTMR_MASK   NO_OS_GENMASK(7, 0)
 
#define ADIN1140_PLCA_DIAG_RXINTO   NO_OS_BIT(2)
 
#define ADIN1140_PLCA_DIAG_UNEXPB   NO_OS_BIT(1)
 
#define ADIN1140_PLCA_DIAG_BCNBFTO   NO_OS_BIT(0)
 
#define ADIN1140_RX_FRAME_CNT_REG   OA_MMS_REG(0x1, 0xA1)
 
#define ADIN1140_RX_BCAST_CNT_REG   OA_MMS_REG(0x1, 0xA2)
 
#define ADIN1140_RX_MCAST_CNT_REG   OA_MMS_REG(0x1, 0xA3)
 
#define ADIN1140_RX_UCAST_CNT_REG   OA_MMS_REG(0x1, 0xA4)
 
#define ADIN1140_RX_CRC_ERR_CNT_REG   OA_MMS_REG(0x1, 0xA5)
 
#define ADIN1140_RX_ALGN_ERR_CNT_REG   OA_MMS_REG(0x1, 0xA6)
 
#define ADIN1140_TX_FRAME_CNT_REG   OA_MMS_REG(0x1, 0xB1)
 
#define ADIN1140_TX_BCAST_CNT_REG   OA_MMS_REG(0x1, 0xB2)
 
#define ADIN1140_TX_MCAST_CNT_REG   OA_MMS_REG(0x1, 0xB3)
 
#define ADIN1140_TX_UCAST_CNT_REG   OA_MMS_REG(0x1, 0xB4)
 

Functions

int adin1140_reg_write (struct adin1140_desc *desc, uint32_t addr, uint32_t data)
 Write a register's value.
 
int adin1140_reg_read (struct adin1140_desc *desc, uint32_t addr, uint32_t *data)
 Read a register's value.
 
int adin1140_reg_update (struct adin1140_desc *desc, uint32_t addr, uint32_t mask, uint32_t data)
 Update a register's value based on a mask.
 
int adin1140_mdio_read_c22 (struct adin1140_desc *desc, uint16_t reg, uint16_t *data)
 Read a PHY register using clause 22 via MMS.
 
int adin1140_mdio_write_c22 (struct adin1140_desc *desc, uint16_t reg, uint16_t data)
 Write a PHY register using clause 22 via MMS.
 
int adin1140_mdio_read_c45 (struct adin1140_desc *desc, uint32_t devnum, uint16_t reg, uint16_t *data)
 Read a PHY register using clause 45 via MMS.
 
int adin1140_mdio_write_c45 (struct adin1140_desc *desc, uint32_t devnum, uint16_t reg, uint16_t data)
 Write a PHY register using clause 45 via MMS.
 
int adin1140_set_mac_addr (struct adin1140_desc *desc, uint8_t mac_address[ADIN1140_ETH_ALEN])
 Add a unicast MAC address filter in the first available slot. Slots 0, 1 and 2 are reserved (multicast, broadcast and the device's own address), so the address is placed in the first free slot starting from ADIN1140_MAC_FILT_UNICAST_SLOT + 1.
 
int adin1140_broadcast_filter (struct adin1140_desc *desc, bool enabled)
 Enable/disable the broadcast filter.
 
int adin1140_multicast_filter (struct adin1140_desc *desc, bool enabled)
 Enable/disable the all-multicast filter. Matches any frame with the multicast bit set in the destination MAC.
 
int adin1140_set_promisc (struct adin1140_desc *desc, bool promisc)
 Set/clear promiscuous mode via CONFIG2 FWD_UNK2HOST.
 
int adin1140_mac_set_cfg (struct adin1140_desc *desc, const struct adin1140_mac_cfg *cfg)
 Apply the MAC CONFIG0 bitfields exposed via struct adin1140_mac_cfg. TXFCSVE is always cleared so the MAC appends the FCS itself. SYNC is preserved (read-modify-write).
 
int adin1140_mac_get_cfg (struct adin1140_desc *desc, struct adin1140_mac_cfg *cfg)
 Read back the MAC CONFIG0 bitfields into struct adin1140_mac_cfg.
 
int adin1140_sw_reset (struct adin1140_desc *desc)
 Trigger a MAC-PHY soft reset via OA-TC6 SWRESET, then re-assert the CONFIG0.SYNC bit so the device is ready to handle traffic.
 
int adin1140_write_fifo (struct adin1140_desc *desc, struct adin1140_eth_buff *eth_buff)
 Write a frame to the TX FIFO via OA TC6.
 
int adin1140_read_fifo (struct adin1140_desc *desc, struct adin1140_eth_buff *eth_buff)
 Read a frame from the RX FIFO via OA TC6.
 
int adin1140_plca_set_cfg (struct adin1140_desc *desc, const struct adin1140_plca_cfg *cfg)
 Set the PLCA configuration.
 
int adin1140_plca_get_cfg (struct adin1140_desc *desc, struct adin1140_plca_cfg *cfg)
 Get the current PLCA configuration.
 
int adin1140_plca_get_status (struct adin1140_desc *desc, bool *active)
 Get the PLCA status (whether PLCA is active).
 
int adin1140_plca_reset (struct adin1140_desc *desc)
 Reset the PLCA logic by setting CTRL0.PLCARST. The bit is self-clearing once the PLCA state machines and counters have been returned to their reset state. Other CTRL0 bits (notably PLCAEN) are preserved.
 
int adin1140_plca_get_diag (struct adin1140_desc *desc, struct adin1140_plca_diag *diag, bool clear)
 Read the PLCA DIAG register and decode the three latched diagnostic indicators. Bits are RO/W1C on the device; if clear is true, write back any bits that were read as 1 to acknowledge them.
 
int adin1140_register_callback (struct adin1140_desc *desc, void(*callback)(struct adin1140_desc *, uint32_t, void *), void *arg)
 Register a callback for OA TC6 events (e.g. link state change).
 
int adin1140_poll (struct adin1140_desc *desc)
 
int adin1140_link_state (struct adin1140_desc *desc, uint32_t *state)
 Get the link state.
 
int adin1140_get_stats (struct adin1140_desc *desc, struct adin1140_stats *stats)
 Read the MAC hardware statistics counters.
 
int adin1140_init (struct adin1140_desc **desc, struct adin1140_init_param *param)
 Initialize the ADIN1140 device.
 
int adin1140_remove (struct adin1140_desc *desc)
 Free the ADIN1140 device descriptor.
 

Macro Definition Documentation

◆ ADIN1140_CONFIG0_CPS_64

#define ADIN1140_CONFIG0_CPS_64   NO_OS_GENMASK(2, 1)

◆ ADIN1140_CONFIG0_CPS_MASK

#define ADIN1140_CONFIG0_CPS_MASK   NO_OS_GENMASK(2, 0)

◆ ADIN1140_CONFIG0_CSARFE

#define ADIN1140_CONFIG0_CSARFE   NO_OS_BIT(13)

◆ ADIN1140_CONFIG0_FTSE

#define ADIN1140_CONFIG0_FTSE   NO_OS_BIT(7)

◆ ADIN1140_CONFIG0_FTSS

#define ADIN1140_CONFIG0_FTSS   NO_OS_BIT(6)

◆ ADIN1140_CONFIG0_REG

#define ADIN1140_CONFIG0_REG   OA_MMS_REG(0x0, 0x0004)

◆ ADIN1140_CONFIG0_RXCTE

#define ADIN1140_CONFIG0_RXCTE   NO_OS_BIT(8)

◆ ADIN1140_CONFIG0_SYNC

#define ADIN1140_CONFIG0_SYNC   NO_OS_BIT(15)

◆ ADIN1140_CONFIG0_TXCTE

#define ADIN1140_CONFIG0_TXCTE   NO_OS_BIT(9)

◆ ADIN1140_CONFIG0_TXCTHRESH_MASK

#define ADIN1140_CONFIG0_TXCTHRESH_MASK   NO_OS_GENMASK(11, 10)

◆ ADIN1140_CONFIG0_TXFCSVE

#define ADIN1140_CONFIG0_TXFCSVE   NO_OS_BIT(14)

◆ ADIN1140_CONFIG0_ZARFE

#define ADIN1140_CONFIG0_ZARFE   NO_OS_BIT(12)

◆ ADIN1140_CONFIG2_FWD_UNK2HOST

#define ADIN1140_CONFIG2_FWD_UNK2HOST   NO_OS_BIT(2)

◆ ADIN1140_CONFIG2_REG

#define ADIN1140_CONFIG2_REG   OA_MMS_REG(0x0, 0x0006)

◆ ADIN1140_ETH_ALEN

#define ADIN1140_ETH_ALEN   6

◆ ADIN1140_ETH_HDR_LEN

#define ADIN1140_ETH_HDR_LEN   14

◆ ADIN1140_IMASK1_P1_RX_RDY_MASK

#define ADIN1140_IMASK1_P1_RX_RDY_MASK   NO_OS_BIT(4)

◆ ADIN1140_IMASK1_REG

#define ADIN1140_IMASK1_REG   OA_MMS_REG(0x0, 0x000D)

◆ ADIN1140_MAC_ADDR_APPLY2PORT1

#define ADIN1140_MAC_ADDR_APPLY2PORT1   NO_OS_BIT(30)

◆ ADIN1140_MAC_ADDR_FILT_LWR_REG

#define ADIN1140_MAC_ADDR_FILT_LWR_REG ( x)
Value:
OA_MMS_REG(0x1, 0x51 + 2 * (x))
#define OA_MMS_REG(m, r)
Definition oa_tc6.h:52

◆ ADIN1140_MAC_ADDR_FILT_UPR_REG

#define ADIN1140_MAC_ADDR_FILT_UPR_REG ( x)
Value:
OA_MMS_REG(0x1, 0x50 + 2 * (x))

◆ ADIN1140_MAC_ADDR_MASK_LWR_REG

#define ADIN1140_MAC_ADDR_MASK_LWR_REG ( x)
Value:
OA_MMS_REG(0x1, 0x71 + 2 * (x))

◆ ADIN1140_MAC_ADDR_MASK_SLOTS

#define ADIN1140_MAC_ADDR_MASK_SLOTS   2

◆ ADIN1140_MAC_ADDR_MASK_UPR_REG

#define ADIN1140_MAC_ADDR_MASK_UPR_REG ( x)
Value:
OA_MMS_REG(0x1, 0x70 + 2 * (x))

◆ ADIN1140_MAC_ADDR_TO_HOST

#define ADIN1140_MAC_ADDR_TO_HOST   NO_OS_BIT(16)

◆ ADIN1140_MAC_FILT_BROADCAST_SLOT

#define ADIN1140_MAC_FILT_BROADCAST_SLOT   1

◆ ADIN1140_MAC_FILT_MAX_SLOT

#define ADIN1140_MAC_FILT_MAX_SLOT   16

◆ ADIN1140_MAC_FILT_MULTICAST_SLOT

#define ADIN1140_MAC_FILT_MULTICAST_SLOT   0

◆ ADIN1140_MAC_FILT_UNICAST_SLOT

#define ADIN1140_MAC_FILT_UNICAST_SLOT   2

◆ ADIN1140_MAC_P1_LOOP_REG

#define ADIN1140_MAC_P1_LOOP_REG   OA_MMS_REG(0x1, 0xC4)

◆ ADIN1140_MACPHY_ID_REG

#define ADIN1140_MACPHY_ID_REG   OA_MMS_REG(0x0, 0x0001)

◆ ADIN1140_PHY_C45_PCS_MMS

#define ADIN1140_PHY_C45_PCS_MMS   2

◆ ADIN1140_PHY_C45_PMA_PMD_MMS

#define ADIN1140_PHY_C45_PMA_PMD_MMS   3

◆ ADIN1140_PHY_C45_VS_PLCA_MMS

#define ADIN1140_PHY_C45_VS_PLCA_MMS   4

◆ ADIN1140_PHY_ID

#define ADIN1140_PHY_ID   0x0283BE00

◆ ADIN1140_PLCA_BURST_BTMR_MASK

#define ADIN1140_PLCA_BURST_BTMR_MASK   NO_OS_GENMASK(7, 0)

◆ ADIN1140_PLCA_BURST_MAXBC_MASK

#define ADIN1140_PLCA_BURST_MAXBC_MASK   NO_OS_GENMASK(15, 8)

◆ ADIN1140_PLCA_BURST_REG

#define ADIN1140_PLCA_BURST_REG   OA_MMS_REG(0x4, 0xCA05)

◆ ADIN1140_PLCA_CTRL0_EN

#define ADIN1140_PLCA_CTRL0_EN   NO_OS_BIT(15)

◆ ADIN1140_PLCA_CTRL0_REG

#define ADIN1140_PLCA_CTRL0_REG   OA_MMS_REG(0x4, 0xCA01)

◆ ADIN1140_PLCA_CTRL0_RST

#define ADIN1140_PLCA_CTRL0_RST   NO_OS_BIT(14)

◆ ADIN1140_PLCA_CTRL1_ID_MASK

#define ADIN1140_PLCA_CTRL1_ID_MASK   NO_OS_GENMASK(7, 0)

◆ ADIN1140_PLCA_CTRL1_NCNT_MASK

#define ADIN1140_PLCA_CTRL1_NCNT_MASK   NO_OS_GENMASK(15, 8)

◆ ADIN1140_PLCA_CTRL1_REG

#define ADIN1140_PLCA_CTRL1_REG   OA_MMS_REG(0x4, 0xCA02)

◆ ADIN1140_PLCA_DIAG_BCNBFTO

#define ADIN1140_PLCA_DIAG_BCNBFTO   NO_OS_BIT(0)

◆ ADIN1140_PLCA_DIAG_REG

#define ADIN1140_PLCA_DIAG_REG   OA_MMS_REG(0x4, 0xCA06)

◆ ADIN1140_PLCA_DIAG_RXINTO

#define ADIN1140_PLCA_DIAG_RXINTO   NO_OS_BIT(2)

◆ ADIN1140_PLCA_DIAG_UNEXPB

#define ADIN1140_PLCA_DIAG_UNEXPB   NO_OS_BIT(1)

◆ ADIN1140_PLCA_IDVER_REG

#define ADIN1140_PLCA_IDVER_REG   OA_MMS_REG(0x4, 0xCA00)

◆ ADIN1140_PLCA_STATUS_PST

#define ADIN1140_PLCA_STATUS_PST   NO_OS_BIT(15)

◆ ADIN1140_PLCA_STATUS_REG

#define ADIN1140_PLCA_STATUS_REG   OA_MMS_REG(0x4, 0xCA03)

◆ ADIN1140_PLCA_TOTMR_MASK

#define ADIN1140_PLCA_TOTMR_MASK   NO_OS_GENMASK(7, 0)

◆ ADIN1140_PLCA_TOTMR_REG

#define ADIN1140_PLCA_TOTMR_REG   OA_MMS_REG(0x4, 0xCA04)

◆ ADIN1140_RX_ALGN_ERR_CNT_REG

#define ADIN1140_RX_ALGN_ERR_CNT_REG   OA_MMS_REG(0x1, 0xA6)

◆ ADIN1140_RX_BCAST_CNT_REG

#define ADIN1140_RX_BCAST_CNT_REG   OA_MMS_REG(0x1, 0xA2)

◆ ADIN1140_RX_CRC_ERR_CNT_REG

#define ADIN1140_RX_CRC_ERR_CNT_REG   OA_MMS_REG(0x1, 0xA5)

◆ ADIN1140_RX_FRAME_CNT_REG

#define ADIN1140_RX_FRAME_CNT_REG   OA_MMS_REG(0x1, 0xA1)

◆ ADIN1140_RX_MCAST_CNT_REG

#define ADIN1140_RX_MCAST_CNT_REG   OA_MMS_REG(0x1, 0xA3)

◆ ADIN1140_RX_UCAST_CNT_REG

#define ADIN1140_RX_UCAST_CNT_REG   OA_MMS_REG(0x1, 0xA4)

◆ ADIN1140_STATUS0_REG

#define ADIN1140_STATUS0_REG   OA_MMS_REG(0x0, 0x0008)

◆ ADIN1140_STATUS0_RESETC

#define ADIN1140_STATUS0_RESETC   NO_OS_BIT(6)

◆ ADIN1140_STATUS1_LINK_STATE

#define ADIN1140_STATUS1_LINK_STATE   NO_OS_BIT(0)

◆ ADIN1140_STATUS1_REG

#define ADIN1140_STATUS1_REG   OA_MMS_REG(0x0, 0x0009)

◆ ADIN1140_TX_BCAST_CNT_REG

#define ADIN1140_TX_BCAST_CNT_REG   OA_MMS_REG(0x1, 0xB2)

◆ ADIN1140_TX_FRAME_CNT_REG

#define ADIN1140_TX_FRAME_CNT_REG   OA_MMS_REG(0x1, 0xB1)

◆ ADIN1140_TX_MCAST_CNT_REG

#define ADIN1140_TX_MCAST_CNT_REG   OA_MMS_REG(0x1, 0xB3)

◆ ADIN1140_TX_UCAST_CNT_REG

#define ADIN1140_TX_UCAST_CNT_REG   OA_MMS_REG(0x1, 0xB4)

Function Documentation

◆ adin1140_broadcast_filter()

int adin1140_broadcast_filter ( struct adin1140_desc * desc,
bool enabled )

Enable/disable the broadcast filter.

Parameters
desc- the device descriptor.
enabled- true to enable, false to disable.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_get_stats()

int adin1140_get_stats ( struct adin1140_desc * desc,
struct adin1140_stats * stats )

Read the MAC hardware statistics counters.

Parameters
desc- the device descriptor.
stats- storage for the counter snapshot.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_init()

int adin1140_init ( struct adin1140_desc ** desc,
struct adin1140_init_param * param )

Initialize the ADIN1140 device.

Parameters
desc- pointer to the device descriptor to be initialized.
param- the device's initialization parameters.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_link_state()

int adin1140_link_state ( struct adin1140_desc * desc,
uint32_t * state )

Get the link state.

Parameters
desc- the device descriptor.
state- pointer to store the link state (1 = up, 0 = down).
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_mac_get_cfg()

int adin1140_mac_get_cfg ( struct adin1140_desc * desc,
struct adin1140_mac_cfg * cfg )

Read back the MAC CONFIG0 bitfields into struct adin1140_mac_cfg.

Parameters
desc- the device descriptor.
cfg- pointer to store the configuration values.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_mac_set_cfg()

int adin1140_mac_set_cfg ( struct adin1140_desc * desc,
const struct adin1140_mac_cfg * cfg )

Apply the MAC CONFIG0 bitfields exposed via struct adin1140_mac_cfg. TXFCSVE is always cleared so the MAC appends the FCS itself. SYNC is preserved (read-modify-write).

Parameters
desc- the device descriptor.
cfg- configuration values to apply.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_mdio_read_c22()

int adin1140_mdio_read_c22 ( struct adin1140_desc * desc,
uint16_t reg,
uint16_t * data )

Read a PHY register using clause 22 via MMS.

Parameters
desc- the device descriptor.
reg- register address (0..31).
data- pointer to store the register value.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_mdio_read_c45()

int adin1140_mdio_read_c45 ( struct adin1140_desc * desc,
uint32_t devnum,
uint16_t reg,
uint16_t * data )

Read a PHY register using clause 45 via MMS.

Parameters
desc- the device descriptor.
devnum- MMD device number (1=PMA/PMD, 3=PCS, 31=VEND2).
reg- register address within the MMD.
data- pointer to store the register value.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_mdio_write_c22()

int adin1140_mdio_write_c22 ( struct adin1140_desc * desc,
uint16_t reg,
uint16_t data )

Write a PHY register using clause 22 via MMS.

Parameters
desc- the device descriptor.
reg- register address (0..31).
data- value to write.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_mdio_write_c45()

int adin1140_mdio_write_c45 ( struct adin1140_desc * desc,
uint32_t devnum,
uint16_t reg,
uint16_t data )

Write a PHY register using clause 45 via MMS.

Parameters
desc- the device descriptor.
devnum- MMD device number (1=PMA/PMD, 3=PCS, 31=VEND2).
reg- register address within the MMD.
data- value to write.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_multicast_filter()

int adin1140_multicast_filter ( struct adin1140_desc * desc,
bool enabled )

Enable/disable the all-multicast filter. Matches any frame with the multicast bit set in the destination MAC.

Parameters
desc- the device descriptor.
enabled- true to enable, false to disable.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_plca_get_cfg()

int adin1140_plca_get_cfg ( struct adin1140_desc * desc,
struct adin1140_plca_cfg * cfg )

Get the current PLCA configuration.

Parameters
desc- the device descriptor.
cfg- pointer to store the PLCA configuration.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_plca_get_diag()

int adin1140_plca_get_diag ( struct adin1140_desc * desc,
struct adin1140_plca_diag * diag,
bool clear )

Read the PLCA DIAG register and decode the three latched diagnostic indicators. Bits are RO/W1C on the device; if clear is true, write back any bits that were read as 1 to acknowledge them.

Parameters
desc- the device descriptor.
diag- pointer to store the decoded diagnostic values.
clear- true to W1C-clear the latches that were observed set.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_plca_get_status()

int adin1140_plca_get_status ( struct adin1140_desc * desc,
bool * active )

Get the PLCA status (whether PLCA is active).

Parameters
desc- the device descriptor.
active- pointer to store the status (true if PLCA is active).
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_plca_reset()

int adin1140_plca_reset ( struct adin1140_desc * desc)

Reset the PLCA logic by setting CTRL0.PLCARST. The bit is self-clearing once the PLCA state machines and counters have been returned to their reset state. Other CTRL0 bits (notably PLCAEN) are preserved.

Parameters
desc- the device descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_plca_set_cfg()

int adin1140_plca_set_cfg ( struct adin1140_desc * desc,
const struct adin1140_plca_cfg * cfg )

Set the PLCA configuration.

Parameters
desc- the device descriptor.
cfg- PLCA configuration to apply.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_poll()

int adin1140_poll ( struct adin1140_desc * desc)

◆ adin1140_read_fifo()

int adin1140_read_fifo ( struct adin1140_desc * desc,
struct adin1140_eth_buff * eth_buff )

Read a frame from the RX FIFO via OA TC6.

Parameters
desc- the device descriptor.
eth_buff- buffer to receive the frame.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_reg_read()

int adin1140_reg_read ( struct adin1140_desc * desc,
uint32_t addr,
uint32_t * data )

Read a register's value.

Parameters
desc- the device descriptor.
addr- MMS-encoded register address.
data- pointer to store the register value.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_reg_update()

int adin1140_reg_update ( struct adin1140_desc * desc,
uint32_t addr,
uint32_t mask,
uint32_t data )

Update a register's value based on a mask.

Parameters
desc- the device descriptor.
addr- MMS-encoded register address.
mask- the bits that may be modified.
data- new value for the masked bits.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_reg_write()

int adin1140_reg_write ( struct adin1140_desc * desc,
uint32_t addr,
uint32_t data )

Write a register's value.

Parameters
desc- the device descriptor.
addr- MMS-encoded register address.
data- register value to write.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_register_callback()

int adin1140_register_callback ( struct adin1140_desc * desc,
void(* callback )(struct adin1140_desc *, uint32_t, void *),
void * arg )

Register a callback for OA TC6 events (e.g. link state change).

Parameters
desc- the device descriptor.
callback- function called with the device descriptor, the event and the user argument. NULL disables the callback.
arg- user argument passed to the callback.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_remove()

int adin1140_remove ( struct adin1140_desc * desc)

Free the ADIN1140 device descriptor.

Parameters
desc- the device descriptor to be removed.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_set_mac_addr()

int adin1140_set_mac_addr ( struct adin1140_desc * desc,
uint8_t mac_address[ADIN1140_ETH_ALEN] )

Add a unicast MAC address filter in the first available slot. Slots 0, 1 and 2 are reserved (multicast, broadcast and the device's own address), so the address is placed in the first free slot starting from ADIN1140_MAC_FILT_UNICAST_SLOT + 1.

Parameters
desc- the device descriptor.
mac_address- the MAC address to filter on.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_set_promisc()

int adin1140_set_promisc ( struct adin1140_desc * desc,
bool promisc )

Set/clear promiscuous mode via CONFIG2 FWD_UNK2HOST.

Parameters
desc- the device descriptor.
promisc- true to enable promiscuous mode, false to disable.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_sw_reset()

int adin1140_sw_reset ( struct adin1140_desc * desc)

Trigger a MAC-PHY soft reset via OA-TC6 SWRESET, then re-assert the CONFIG0.SYNC bit so the device is ready to handle traffic.

Parameters
desc- the device descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ adin1140_write_fifo()

int adin1140_write_fifo ( struct adin1140_desc * desc,
struct adin1140_eth_buff * eth_buff )

Write a frame to the TX FIFO via OA TC6.

Parameters
desc- the device descriptor.
eth_buff- the frame to be transmitted.
Returns
0 in case of success, negative error code otherwise.