mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-02 01:13:26 +00:00
Align the LAN865x driver module initialization priority with the default priorities of MDIO and PHY drivers. The microchip_t1s PHY driver supports both LAN865x internal PHY and LAN867x external PHY. It was observed that the microchip_t1s driver initialization priority did not match the priority sequence used by the GMAC driver when the evb-lan8670-rmii (an external LAN8670 PHY) was connected to the SAME54 Curiosity Ultra platform, leading to potential initialization order issues. This change ensures the correct initialization sequence for reliable operation. The initialization priorities of the microchip_t1s and mdio_lan865x drivers are now set to the default values used in Zephyr. The LAN865x driver init priority is updated to the most appropriate value so that the microchip_t1s init priority aligns with all MAC drivers, maintaining the correct initialization sequence. Since the microchip_t1s driver can be used by many MAC drivers, keeping the default priority provided by Zephyr is a good approach. Instead, setting a specific priority for the eth_lan865x driver is more appropriate to ensure proper initialization order. Signed-off-by: Parthiban Veerasooran <parthiban.veerasooran@microchip.com>
70 lines
2.2 KiB
C
70 lines
2.2 KiB
C
/*
|
|
* Copyright (c) 2024 Microchip Technology Inc.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <zephyr/logging/log.h>
|
|
LOG_MODULE_REGISTER(mdio_lan865x, CONFIG_MDIO_LOG_LEVEL);
|
|
|
|
#define DT_DRV_COMPAT microchip_lan865x_mdio
|
|
|
|
#include <stdint.h>
|
|
#include <errno.h>
|
|
#include <zephyr/device.h>
|
|
#include <zephyr/kernel.h>
|
|
#include <zephyr/drivers/mdio.h>
|
|
#include <zephyr/drivers/ethernet/eth_lan865x.h>
|
|
|
|
struct mdio_lan865x_config {
|
|
const struct device *dev;
|
|
};
|
|
|
|
static int lan865x_mdio_c22_read(const struct device *dev, uint8_t prtad, uint8_t regad,
|
|
uint16_t *data)
|
|
{
|
|
const struct mdio_lan865x_config *const cfg = dev->config;
|
|
|
|
return eth_lan865x_mdio_c22_read(cfg->dev, prtad, regad, data);
|
|
}
|
|
|
|
static int lan865x_mdio_c22_write(const struct device *dev, uint8_t prtad, uint8_t regad,
|
|
uint16_t data)
|
|
{
|
|
const struct mdio_lan865x_config *const cfg = dev->config;
|
|
|
|
return eth_lan865x_mdio_c22_write(cfg->dev, prtad, regad, data);
|
|
}
|
|
|
|
static int lan865x_mdio_c45_read(const struct device *dev, uint8_t prtad, uint8_t devad,
|
|
uint16_t regad, uint16_t *data)
|
|
{
|
|
const struct mdio_lan865x_config *const cfg = dev->config;
|
|
|
|
return eth_lan865x_mdio_c45_read(cfg->dev, prtad, devad, regad, data);
|
|
}
|
|
|
|
static int lan865x_mdio_c45_write(const struct device *dev, uint8_t prtad, uint8_t devad,
|
|
uint16_t regad, uint16_t data)
|
|
{
|
|
const struct mdio_lan865x_config *const cfg = dev->config;
|
|
|
|
return eth_lan865x_mdio_c45_write(cfg->dev, prtad, devad, regad, data);
|
|
}
|
|
|
|
static DEVICE_API(mdio, mdio_lan865x_api) = {
|
|
.read = lan865x_mdio_c22_read,
|
|
.write = lan865x_mdio_c22_write,
|
|
.read_c45 = lan865x_mdio_c45_read,
|
|
.write_c45 = lan865x_mdio_c45_write,
|
|
};
|
|
|
|
#define MICROCHIP_LAN865X_MDIO_INIT(n) \
|
|
static const struct mdio_lan865x_config mdio_lan865x_config_##n = { \
|
|
.dev = DEVICE_DT_GET(DT_INST_PARENT(n)), \
|
|
}; \
|
|
DEVICE_DT_INST_DEFINE(n, NULL, NULL, NULL, &mdio_lan865x_config_##n, POST_KERNEL, \
|
|
CONFIG_MDIO_INIT_PRIORITY, &mdio_lan865x_api);
|
|
|
|
DT_INST_FOREACH_STATUS_OKAY(MICROCHIP_LAN865X_MDIO_INIT)
|