no-OS
|
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"
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... | |
Source file of the ADIN1110 driver.
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:
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.
#define ADIN1110_CRC_POLYNOMIAL 0x7 |
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.
desc | - the device descriptor |
enabled | - the set/clear option |
int adin1110_clear_mac_addr | ( | struct adin1110_desc * | desc, |
uint8_t | mac_address[ADIN1110_ETH_ALEN] | ||
) |
Drop a MAC address filter.
desc | - the device descriptor |
mac_address | - the MAC filter to be cleared |
int adin1110_init | ( | struct adin1110_desc ** | desc, |
struct adin1110_init_param * | param | ||
) |
Initialize the device.
desc | - the device descriptor to be initialized |
param | - the device's parameter |
int adin1110_link_state | ( | struct adin1110_desc * | desc, |
uint32_t * | state | ||
) |
Reset both the MAC and PHY.
desc | - the device descriptor |
state | - status (up/down) of the link |
int adin1110_mac_reset | ( | struct adin1110_desc * | desc | ) |
Reset the MAC device.
desc | - the device descriptor |
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.
desc | - the device descriptor |
phy_id | - the phy device's id |
reg | - register's address |
data | - register's value |
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.
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 |
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.
desc | - the device descriptor |
phy_id | - the phy device's id |
reg | - register's address |
data | - register's value |
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.
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 |
int adin1110_phy_reset | ( | struct adin1110_desc * | desc | ) |
Reset the PHY device.
desc | - the device descriptor |
int adin1110_read_fifo | ( | struct adin1110_desc * | desc, |
uint32_t | port, | ||
struct adin1110_eth_buff * | eth_buff | ||
) |
Read a frame from the RX FIFO.
desc | - the device descriptor |
port | - the port from which the frame shall be received. |
eth_buff | - the frame to be received. |
Burst read the whole frame
int adin1110_reg_read | ( | struct adin1110_desc * | desc, |
uint16_t | addr, | ||
uint32_t * | data | ||
) |
Read a register's value.
desc | - the device descriptor |
addr | - register's address |
data | - 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.
desc | - the device descriptor |
addr | - register's address |
mask | - the bits that may be modified |
data | - register's value |
int adin1110_reg_write | ( | struct adin1110_desc * | desc, |
uint16_t | addr, | ||
uint32_t | data | ||
) |
Write a register's value.
desc | - the device descriptor |
addr | - register's address |
data | - register's value |
int adin1110_remove | ( | struct adin1110_desc * | desc | ) |
Free a device descriptor.
desc | - the device descriptor to be removed. |
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.
desc | - the device descriptor |
mac_address | - the MAC filter to be set |
int adin1110_set_promisc | ( | struct adin1110_desc * | desc, |
uint32_t | port, | ||
bool | promisc | ||
) |
Set a port in promiscuous mode. All MAC filters are dropped.
desc | - the device descriptor |
port | - the port for which the mode will be applied |
promisc | - either enable or disable the promiscuous mode. |
int adin1110_sw_reset | ( | struct adin1110_desc * | desc | ) |
Reset both the MAC and PHY.
desc | - the device descriptor |
int adin1110_write_fifo | ( | struct adin1110_desc * | desc, |
uint32_t | port, | ||
struct adin1110_eth_buff * | eth_buff | ||
) |
Write a frame to the TX FIFO.
desc | - the device descriptor |
port | - the port for the frame to be transmitted on. |
eth_buff | - the frame to be transmitted. |
Align the frame length to 4 bytes
NO_OS_DECLARE_CRC8_TABLE | ( | _crc_table | ) |