no-OS
Loading...
Searching...
No Matches
adin1110.c File Reference

Source file of the ADIN1110 driver. More...

#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "no_os_spi.h"
#include "adin1110.h"
#include "no_os_alloc.h"
#include "no_os_crc8.h"
#include "no_os_delay.h"
#include "no_os_util.h"
#include "oa_tc6.h"
Include dependency graph for adin1110.c:

Classes

struct  _adin1110_priv
 

Macros

#define ADIN1110_CRC_POLYNOMIAL   0x7
 

Functions

 NO_OS_DECLARE_CRC8_TABLE (_crc_table)
 
int adin1110_reg_write (struct adin1110_desc *desc, uint16_t addr, uint32_t data)
 Write a register's value.
 
int adin1110_reg_read (struct adin1110_desc *desc, uint16_t addr, uint32_t *data)
 Read a register's value.
 
int adin1110_reg_update (struct adin1110_desc *desc, uint16_t addr, uint32_t mask, uint32_t data)
 Update a register's value based on a mask.
 
int adin1110_mdio_read (struct adin1110_desc *desc, uint32_t phy_id, uint32_t reg, uint16_t *data)
 Read a PHY register using clause 22.
 
int adin1110_mdio_write (struct adin1110_desc *desc, uint32_t phy_id, uint32_t reg, uint16_t data)
 Write a PHY register using clause 22.
 
int adin1110_mdio_write_c45 (struct adin1110_desc *desc, uint32_t phy_id, uint32_t dev_id, uint32_t reg, uint16_t data)
 Write a PHY register using clause 45.
 
int adin1110_mdio_read_c45 (struct adin1110_desc *desc, uint32_t phy_id, uint32_t dev_id, uint16_t reg, uint16_t *data)
 Read a PHY register using clause 45.
 
int adin1110_set_mac_addr (struct adin1110_desc *desc, uint8_t mac_address[ADIN1110_ETH_ALEN])
 Set a MAC address destination filter, frames who's DA doesn't match are dropped.
 
int adin1110_clear_mac_addr (struct adin1110_desc *desc, uint8_t mac_address[ADIN1110_ETH_ALEN])
 Drop a MAC address filter.
 
int adin1110_broadcast_filter (struct adin1110_desc *desc, bool enabled)
 Set/clear a broadcast filter. By enabling this, broadcast frames will be forwarded to the host.
 
int adin1110_write_fifo (struct adin1110_desc *desc, uint32_t port, struct adin1110_eth_buff *eth_buff)
 Write a frame to the TX FIFO.
 
int adin1110_read_fifo (struct adin1110_desc *desc, uint32_t port, struct adin1110_eth_buff *eth_buff)
 Read a frame from the RX FIFO.
 
int adin1110_mac_reset (struct adin1110_desc *desc)
 Reset the MAC device.
 
int adin1110_phy_reset (struct adin1110_desc *desc)
 Reset the PHY device.
 
int adin1110_sw_reset (struct adin1110_desc *desc)
 Reset both the MAC and PHY.
 
int adin1110_link_state (struct adin1110_desc *desc, uint32_t *state)
 Reset both the MAC and PHY.
 
int adin1110_set_promisc (struct adin1110_desc *desc, uint32_t port, bool promisc)
 Set a port in promiscuous mode. All MAC filters are dropped.
 
int adin1110_init (struct adin1110_desc **desc, struct adin1110_init_param *param)
 Initialize the device.
 
int adin1110_remove (struct adin1110_desc *desc)
 Free a device descriptor.
 

Detailed Description

Source file of the ADIN1110 driver.

Author
Ciprian Regus (cipri.nosp@m.an.r.nosp@m.egus@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2023(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ ADIN1110_CRC_POLYNOMIAL

#define ADIN1110_CRC_POLYNOMIAL   0x7

Function Documentation

◆ adin1110_broadcast_filter()

int adin1110_broadcast_filter ( struct adin1110_desc * desc,
bool enabled )

Set/clear a broadcast filter. By enabling this, broadcast frames will be forwarded to the host.

Parameters
desc- the device descriptor
enabled- the set/clear option
Returns
0 in case of success, negative error code otherwise

◆ adin1110_clear_mac_addr()

int adin1110_clear_mac_addr ( struct adin1110_desc * desc,
uint8_t mac_address[ADIN1110_ETH_ALEN] )

Drop a MAC address filter.

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

◆ adin1110_init()

int adin1110_init ( struct adin1110_desc ** desc,
struct adin1110_init_param * param )

Initialize the device.

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

◆ adin1110_link_state()

int adin1110_link_state ( struct adin1110_desc * desc,
uint32_t * state )

Reset both the MAC and PHY.

Parameters
desc- the device descriptor
state- status (up/down) of the link
Returns
0 in case of success, negative error code otherwise

◆ adin1110_mac_reset()

int adin1110_mac_reset ( struct adin1110_desc * desc)

Reset the MAC device.

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

◆ adin1110_mdio_read()

int adin1110_mdio_read ( struct adin1110_desc * desc,
uint32_t phy_id,
uint32_t reg,
uint16_t * data )

Read a PHY register using clause 22.

Parameters
desc- the device descriptor
phy_id- the phy device's id
reg- register's address
data- register's value
Returns
0 in case of success, negative error code otherwise

◆ adin1110_mdio_read_c45()

int adin1110_mdio_read_c45 ( struct adin1110_desc * desc,
uint32_t phy_id,
uint32_t dev_id,
uint16_t reg,
uint16_t * data )

Read a PHY register using clause 45.

Parameters
desc- the device descriptor
phy_id- the phy device's MDIO id
dev_id- the device id of the register
reg- register's address
data- register's value
Returns
0 in case of success, negative error code otherwise

◆ adin1110_mdio_write()

int adin1110_mdio_write ( struct adin1110_desc * desc,
uint32_t phy_id,
uint32_t reg,
uint16_t data )

Write a PHY register using clause 22.

Parameters
desc- the device descriptor
phy_id- the phy device's id
reg- register's address
data- register's value
Returns
0 in case of success, negative error code otherwise

◆ adin1110_mdio_write_c45()

int adin1110_mdio_write_c45 ( struct adin1110_desc * desc,
uint32_t phy_id,
uint32_t dev_id,
uint32_t reg,
uint16_t data )

Write a PHY register using clause 45.

Parameters
desc- the device descriptor
phy_id- the phy device's MDIO id
dev_id- the device id of the register
reg- register's address
data- register's value
Returns
0 in case of success, negative error code otherwise

◆ adin1110_phy_reset()

int adin1110_phy_reset ( struct adin1110_desc * desc)

Reset the PHY device.

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

◆ adin1110_read_fifo()

int adin1110_read_fifo ( struct adin1110_desc * desc,
uint32_t port,
struct adin1110_eth_buff * eth_buff )

Read a frame from the RX FIFO.

Parameters
desc- the device descriptor
port- the port from which the frame shall be received.
eth_buff- the frame to be received.
Returns
0 in case of success, negative error code otherwise

Burst read the whole frame

◆ adin1110_reg_read()

int adin1110_reg_read ( struct adin1110_desc * desc,
uint16_t addr,
uint32_t * data )

Read a register's value.

Parameters
desc- the device descriptor
addr- register's address
data- register's value
Returns
0 in case of success, negative error code otherwise

◆ adin1110_reg_update()

int adin1110_reg_update ( struct adin1110_desc * desc,
uint16_t addr,
uint32_t mask,
uint32_t data )

Update a register's value based on a mask.

Parameters
desc- the device descriptor
addr- register's address
mask- the bits that may be modified
data- register's value
Returns
0 in case of success, negative error code otherwise

◆ adin1110_reg_write()

int adin1110_reg_write ( struct adin1110_desc * desc,
uint16_t addr,
uint32_t data )

Write a register's value.

Parameters
desc- the device descriptor
addr- register's address
data- register's value
Returns
0 in case of success, negative error code otherwise

◆ adin1110_remove()

int adin1110_remove ( struct adin1110_desc * desc)

Free a device descriptor.

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

◆ adin1110_set_mac_addr()

int adin1110_set_mac_addr ( struct adin1110_desc * desc,
uint8_t mac_address[ADIN1110_ETH_ALEN] )

Set a MAC address destination filter, frames who's DA doesn't match are dropped.

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

◆ adin1110_set_promisc()

int adin1110_set_promisc ( struct adin1110_desc * desc,
uint32_t port,
bool promisc )

Set a port in promiscuous mode. All MAC filters are dropped.

Parameters
desc- the device descriptor
port- the port for which the mode will be applied
promisc- either enable or disable the promiscuous mode.
Returns
0 in case of success, negative error code otherwise

◆ adin1110_sw_reset()

int adin1110_sw_reset ( struct adin1110_desc * desc)

Reset both the MAC and PHY.

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

◆ adin1110_write_fifo()

int adin1110_write_fifo ( struct adin1110_desc * desc,
uint32_t port,
struct adin1110_eth_buff * eth_buff )

Write a frame to the TX FIFO.

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

Align the frame length to 4 bytes

◆ NO_OS_DECLARE_CRC8_TABLE()

NO_OS_DECLARE_CRC8_TABLE ( _crc_table )