no-OS
Classes | Macros | Functions
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 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. More...
 
int adin1110_reg_read (struct adin1110_desc *desc, uint16_t addr, uint32_t *data)
 Read a register's value. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int adin1110_clear_mac_addr (struct adin1110_desc *desc, uint8_t mac_address[ADIN1110_ETH_ALEN])
 Drop a MAC address filter. More...
 
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. More...
 
int adin1110_write_fifo (struct adin1110_desc *desc, uint32_t port, struct adin1110_eth_buff *eth_buff)
 Write a frame to the TX FIFO. More...
 
int adin1110_read_fifo (struct adin1110_desc *desc, uint32_t port, struct adin1110_eth_buff *eth_buff)
 Read a frame from the RX FIFO. More...
 
int adin1110_mac_reset (struct adin1110_desc *desc)
 Reset the MAC device. More...
 
int adin1110_phy_reset (struct adin1110_desc *desc)
 Reset the PHY device. More...
 
int adin1110_sw_reset (struct adin1110_desc *desc)
 Reset both the MAC and PHY. More...
 
int adin1110_link_state (struct adin1110_desc *desc, uint32_t *state)
 Reset both the MAC and PHY. More...
 
int adin1110_set_promisc (struct adin1110_desc *desc, uint32_t port, bool promisc)
 Set a port in promiscuous mode. All MAC filters are dropped. More...
 
int adin1110_init (struct adin1110_desc **desc, struct adin1110_init_param *param)
 Initialize the device. More...
 
int adin1110_remove (struct adin1110_desc *desc)
 Free a device descriptor. More...
 

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.

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 of Analog Devices, Inc. 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 ANALOG DEVICES, INC. “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 ANALOG DEVICES, INC. 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.

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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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

Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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

Here is the caller graph for this function:

◆ NO_OS_DECLARE_CRC8_TABLE()

NO_OS_DECLARE_CRC8_TABLE ( _crc_table  )