![]() |
no-OS
|
Source file of the ADIN1140 driver. More...
#include <errno.h>#include <stdlib.h>#include <stdint.h>#include <string.h>#include "adin1140.h"#include "no_os_alloc.h"#include "no_os_util.h"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_poll (struct adin1140_desc *desc) |
| 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_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_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_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. | |
Source file of the ADIN1140 driver.
Copyright 2025-2026(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| int adin1140_broadcast_filter | ( | struct adin1140_desc * | desc, |
| bool | enabled ) |
Enable/disable the broadcast filter.
| desc | - the device descriptor. |
| enabled | - true to enable, false to disable. |
| int adin1140_get_stats | ( | struct adin1140_desc * | desc, |
| struct adin1140_stats * | stats ) |
Read the MAC hardware statistics counters.
| desc | - the device descriptor. |
| stats | - storage for the counter snapshot. |
| int adin1140_init | ( | struct adin1140_desc ** | desc, |
| struct adin1140_init_param * | param ) |
Initialize the ADIN1140 device.
| desc | - pointer to the device descriptor to be initialized. |
| param | - the device's initialization parameters. |
| int adin1140_link_state | ( | struct adin1140_desc * | desc, |
| uint32_t * | state ) |
Get the link state.
| desc | - the device descriptor. |
| state | - pointer to store the link state (1 = up, 0 = down). |
| 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.
| desc | - the device descriptor. |
| cfg | - pointer to store the configuration values. |
| 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).
| desc | - the device descriptor. |
| cfg | - configuration values to apply. |
| int adin1140_mdio_read_c22 | ( | struct adin1140_desc * | desc, |
| uint16_t | reg, | ||
| uint16_t * | data ) |
Read a PHY register using clause 22 via MMS.
| desc | - the device descriptor. |
| reg | - register address (0..31). |
| data | - pointer to store the register value. |
| 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.
| 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. |
| int adin1140_mdio_write_c22 | ( | struct adin1140_desc * | desc, |
| uint16_t | reg, | ||
| uint16_t | data ) |
Write a PHY register using clause 22 via MMS.
| desc | - the device descriptor. |
| reg | - register address (0..31). |
| data | - value to write. |
| 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.
| 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. |
| 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.
| desc | - the device descriptor. |
| enabled | - true to enable, false to disable. |
| int adin1140_plca_get_cfg | ( | struct adin1140_desc * | desc, |
| struct adin1140_plca_cfg * | cfg ) |
Get the current PLCA configuration.
| desc | - the device descriptor. |
| cfg | - pointer to store the PLCA configuration. |
| 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.
| desc | - the device descriptor. |
| diag | - pointer to store the decoded diagnostic values. |
| clear | - true to W1C-clear the latches that were observed set. |
| int adin1140_plca_get_status | ( | struct adin1140_desc * | desc, |
| bool * | active ) |
Get the PLCA status (whether PLCA is active).
| desc | - the device descriptor. |
| active | - pointer to store the status (true if 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.
| desc | - the device descriptor. |
| int adin1140_plca_set_cfg | ( | struct adin1140_desc * | desc, |
| const struct adin1140_plca_cfg * | cfg ) |
Set the PLCA configuration.
| desc | - the device descriptor. |
| cfg | - PLCA configuration to apply. |
| int adin1140_poll | ( | struct adin1140_desc * | desc | ) |
| int adin1140_read_fifo | ( | struct adin1140_desc * | desc, |
| struct adin1140_eth_buff * | eth_buff ) |
Read a frame from the RX FIFO via OA TC6.
| desc | - the device descriptor. |
| eth_buff | - buffer to receive the frame. |
| int adin1140_reg_read | ( | struct adin1140_desc * | desc, |
| uint32_t | addr, | ||
| uint32_t * | data ) |
Read a register's value.
| desc | - the device descriptor. |
| addr | - MMS-encoded register address. |
| data | - pointer to store the register 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.
| desc | - the device descriptor. |
| addr | - MMS-encoded register address. |
| mask | - the bits that may be modified. |
| data | - new value for the masked bits. |
| int adin1140_reg_write | ( | struct adin1140_desc * | desc, |
| uint32_t | addr, | ||
| uint32_t | data ) |
Write a register's value.
| desc | - the device descriptor. |
| addr | - MMS-encoded register address. |
| data | - register value to write. |
| 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).
| 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. |
| int adin1140_remove | ( | struct adin1140_desc * | desc | ) |
Free the ADIN1140 device descriptor.
| desc | - the device descriptor to be removed. |
| 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.
| desc | - the device descriptor. |
| mac_address | - the MAC address to filter on. |
| int adin1140_set_promisc | ( | struct adin1140_desc * | desc, |
| bool | promisc ) |
Set/clear promiscuous mode via CONFIG2 FWD_UNK2HOST.
| desc | - the device descriptor. |
| promisc | - true to enable promiscuous mode, false to disable. |
| 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.
| desc | - the device descriptor. |
| int adin1140_write_fifo | ( | struct adin1140_desc * | desc, |
| struct adin1140_eth_buff * | eth_buff ) |
Write a frame to the TX FIFO via OA TC6.
| desc | - the device descriptor. |
| eth_buff | - the frame to be transmitted. |