Skip to content

ethernet: stm32: add a alternative HAL_ETH_Init for V1 api #88483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions drivers/ethernet/eth_stm32_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);

static const struct device *eth_stm32_phy_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0, phy_handle));

#define ETH_STM32_AUTO_NEGOTIATION_ENABLE \
UTIL_NOT(DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, phy_handle), fixed_link))

#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_ethernet)
#define IS_ETH_DMATXDESC_OWN(dma_tx_desc) (dma_tx_desc->DESC3 & \
ETH_DMATXNDESCRF_OWN)
Expand Down Expand Up @@ -893,26 +890,10 @@ static int eth_initialize(const struct device *dev)
#if defined(CONFIG_ETH_STM32_HAL_API_V1)
HAL_StatusTypeDef hal_ret = HAL_OK;

if (!ETH_STM32_AUTO_NEGOTIATION_ENABLE) {
struct phy_link_state state;

phy_get_link_state(eth_stm32_phy_dev, &state);

heth->Init.DuplexMode = PHY_LINK_IS_FULL_DUPLEX(state.speed) ? ETH_MODE_FULLDUPLEX
: ETH_MODE_HALFDUPLEX;
heth->Init.Speed =
PHY_LINK_IS_SPEED_100M(state.speed) ? ETH_SPEED_100M : ETH_SPEED_10M;
}

hal_ret = HAL_ETH_Init(heth);
if (hal_ret == HAL_TIMEOUT) {
/* HAL Init time out. This could be linked to */
/* a recoverable error. Log the issue and continue */
/* driver initialisation */
LOG_WRN("HAL_ETH_Init timed out (cable not connected?)");
} else if (hal_ret != HAL_OK) {
if (hal_ret != HAL_OK) {
LOG_ERR("HAL_ETH_Init failed: %d", hal_ret);
return -EINVAL;
return -EIO;
}

/* Initialize semaphores */
Expand Down Expand Up @@ -1362,9 +1343,6 @@ static struct eth_stm32_hal_dev_data eth0_data = {
.Instance = (ETH_TypeDef *)DT_REG_ADDR(DT_INST_PARENT(0)),
.Init = {
#if defined(CONFIG_ETH_STM32_HAL_API_V1)
.AutoNegotiation = ETH_STM32_AUTO_NEGOTIATION_ENABLE ?
ETH_AUTONEGOTIATION_ENABLE : ETH_AUTONEGOTIATION_DISABLE,
.PhyAddress = DT_REG_ADDR(DT_INST_PHANDLE(0, phy_handle)),
.RxMode = ETH_RXINTERRUPT_MODE,
.ChecksumMode = IS_ENABLED(CONFIG_ETH_STM32_HW_CHECKSUM) ?
ETH_CHECKSUM_BY_HARDWARE : ETH_CHECKSUM_BY_SOFTWARE,
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ manifest:
groups:
- hal
- name: hal_stm32
revision: 1e753266ddfb4b07a8a0b1ec566e9637ea45d5ef
revision: pull/300/head
path: modules/hal/stm32
groups:
- hal
Expand Down
Loading