drivers: mdio: lan865x: add mdio driver support
Implement lan865x mdio driver to provide interface between lan865x MAC driver and internal PHY driver phy_microchip_t1s.c. This driver is needed to support the driver architecture followed. Signed-off-by: Parthiban Veerasooran <parthiban.veerasooran@microchip.com>
This commit is contained in:
parent
757581e43a
commit
7cfa5bf6cf
7 changed files with 236 additions and 0 deletions
|
|
@ -18,9 +18,42 @@ LOG_MODULE_REGISTER(eth_lan865x, CONFIG_ETHERNET_LOG_LEVEL);
|
||||||
#include <zephyr/net/net_if.h>
|
#include <zephyr/net/net_if.h>
|
||||||
#include <zephyr/net/ethernet.h>
|
#include <zephyr/net/ethernet.h>
|
||||||
#include <zephyr/net/phy.h>
|
#include <zephyr/net/phy.h>
|
||||||
|
#include <zephyr/drivers/ethernet/eth_lan865x.h>
|
||||||
|
|
||||||
#include "eth_lan865x_priv.h"
|
#include "eth_lan865x_priv.h"
|
||||||
|
|
||||||
|
int eth_lan865x_mdio_c22_read(const struct device *dev, uint8_t prtad, uint8_t regad,
|
||||||
|
uint16_t *data)
|
||||||
|
{
|
||||||
|
struct lan865x_data *ctx = dev->data;
|
||||||
|
|
||||||
|
return oa_tc6_mdio_read(ctx->tc6, prtad, regad, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
int eth_lan865x_mdio_c22_write(const struct device *dev, uint8_t prtad, uint8_t regad,
|
||||||
|
uint16_t data)
|
||||||
|
{
|
||||||
|
struct lan865x_data *ctx = dev->data;
|
||||||
|
|
||||||
|
return oa_tc6_mdio_write(ctx->tc6, prtad, regad, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
int eth_lan865x_mdio_c45_read(const struct device *dev, uint8_t prtad, uint8_t devad,
|
||||||
|
uint16_t regad, uint16_t *data)
|
||||||
|
{
|
||||||
|
struct lan865x_data *ctx = dev->data;
|
||||||
|
|
||||||
|
return oa_tc6_mdio_read_c45(ctx->tc6, prtad, devad, regad, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
int eth_lan865x_mdio_c45_write(const struct device *dev, uint8_t prtad, uint8_t devad,
|
||||||
|
uint16_t regad, uint16_t data)
|
||||||
|
{
|
||||||
|
struct lan865x_data *ctx = dev->data;
|
||||||
|
|
||||||
|
return oa_tc6_mdio_write_c45(ctx->tc6, prtad, devad, regad, data);
|
||||||
|
}
|
||||||
|
|
||||||
static int lan865x_mac_rxtx_control(const struct device *dev, bool en)
|
static int lan865x_mac_rxtx_control(const struct device *dev, bool en)
|
||||||
{
|
{
|
||||||
struct lan865x_data *ctx = dev->data;
|
struct lan865x_data *ctx = dev->data;
|
||||||
|
|
|
||||||
|
|
@ -17,3 +17,4 @@ zephyr_library_sources_ifdef(CONFIG_MDIO_INFINEON_XMC4XXX mdio_xmc4xxx.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_MDIO_NXP_ENET_QOS mdio_nxp_enet_qos.c)
|
zephyr_library_sources_ifdef(CONFIG_MDIO_NXP_ENET_QOS mdio_nxp_enet_qos.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_MDIO_DWCXGMAC mdio_dwcxgmac.c)
|
zephyr_library_sources_ifdef(CONFIG_MDIO_DWCXGMAC mdio_dwcxgmac.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_MDIO_RENESAS_RA mdio_renesas_ra.c)
|
zephyr_library_sources_ifdef(CONFIG_MDIO_RENESAS_RA mdio_renesas_ra.c)
|
||||||
|
zephyr_library_sources_ifdef(CONFIG_MDIO_LAN865X mdio_lan865x.c)
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ source "drivers/mdio/Kconfig.xmc4xxx"
|
||||||
source "drivers/mdio/Kconfig.nxp_enet_qos"
|
source "drivers/mdio/Kconfig.nxp_enet_qos"
|
||||||
source "drivers/mdio/Kconfig.dwcxgmac"
|
source "drivers/mdio/Kconfig.dwcxgmac"
|
||||||
source "drivers/mdio/Kconfig.renesas_ra"
|
source "drivers/mdio/Kconfig.renesas_ra"
|
||||||
|
source "drivers/mdio/Kconfig.lan865x"
|
||||||
|
|
||||||
config MDIO_INIT_PRIORITY
|
config MDIO_INIT_PRIORITY
|
||||||
int "Init priority"
|
int "Init priority"
|
||||||
|
|
|
||||||
20
drivers/mdio/Kconfig.lan865x
Normal file
20
drivers/mdio/Kconfig.lan865x
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Copyright 2024 Microchip Technology Inc
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
menuconfig MDIO_LAN865X
|
||||||
|
bool "LAN865X MDIO driver"
|
||||||
|
default y
|
||||||
|
depends on DT_HAS_MICROCHIP_LAN865X_MDIO_ENABLED
|
||||||
|
depends on ETH_LAN865X
|
||||||
|
help
|
||||||
|
Enable LAN865X MDIO driver.
|
||||||
|
|
||||||
|
if MDIO_LAN865X
|
||||||
|
|
||||||
|
config MDIO_LAN865X_INIT_PRIORITY
|
||||||
|
int "LAN865X MDIO init priority"
|
||||||
|
default 81
|
||||||
|
help
|
||||||
|
LAN865X MDIO device driver initialization priority.
|
||||||
|
|
||||||
|
endif
|
||||||
79
drivers/mdio/mdio_lan865x.c
Normal file
79
drivers/mdio/mdio_lan865x.c
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* 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 void lan865x_mdio_bus_enable(const struct device *dev)
|
||||||
|
{
|
||||||
|
ARG_UNUSED(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lan865x_mdio_bus_disable(const struct device *dev)
|
||||||
|
{
|
||||||
|
ARG_UNUSED(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 const struct mdio_driver_api 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,
|
||||||
|
.bus_enable = lan865x_mdio_bus_enable,
|
||||||
|
.bus_disable = lan865x_mdio_bus_disable};
|
||||||
|
|
||||||
|
#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_LAN865X_INIT_PRIORITY, &mdio_lan865x_api);
|
||||||
|
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY(MICROCHIP_LAN865X_MDIO_INIT)
|
||||||
10
dts/bindings/mdio/microchip,lan865x-mdio.yaml
Normal file
10
dts/bindings/mdio/microchip,lan865x-mdio.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Copyright (c) 2024 Microchip Technology Inc.
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
description: LAN865X MDIO Driver node
|
||||||
|
|
||||||
|
compatible: "microchip,lan865x-mdio"
|
||||||
|
|
||||||
|
include: mdio-controller.yaml
|
||||||
|
|
||||||
|
on-bus: lan865x
|
||||||
92
include/zephyr/drivers/ethernet/eth_lan865x.h
Normal file
92
include/zephyr/drivers/ethernet/eth_lan865x.h
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 Microchip Technology Inc.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZEPHYR_INCLUDE_DRIVERS_ETH_LAN865X_H__
|
||||||
|
#define ZEPHYR_INCLUDE_DRIVERS_ETH_LAN865X_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <zephyr/kernel.h>
|
||||||
|
#include <zephyr/device.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read C22 registers using LAN865X MDIO Bus
|
||||||
|
*
|
||||||
|
* This routine provides an interface to perform a C22 register read on the
|
||||||
|
* LAN865X MDIO bus.
|
||||||
|
*
|
||||||
|
* @param[in] dev Pointer to the device structure for the controller
|
||||||
|
* @param[in] prtad Port address
|
||||||
|
* @param[in] regad Register address
|
||||||
|
* @param data Pointer to receive read data
|
||||||
|
*
|
||||||
|
* @retval 0 If successful.
|
||||||
|
* @retval -EIO General input / output error.
|
||||||
|
* @retval -ETIMEDOUT If transaction timedout on the bus
|
||||||
|
* @retval -ENOSYS if read is not supported
|
||||||
|
*/
|
||||||
|
int eth_lan865x_mdio_c22_read(const struct device *dev, uint8_t prtad, uint8_t regad,
|
||||||
|
uint16_t *data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write C22 registers using LAN865X MDIO Bus
|
||||||
|
*
|
||||||
|
* This routine provides an interface to perform a C22 register write on the
|
||||||
|
* LAN865X MDIO bus.
|
||||||
|
*
|
||||||
|
* @param[in] dev Pointer to the device structure for the controller
|
||||||
|
* @param[in] prtad Port address
|
||||||
|
* @param[in] regad Register address
|
||||||
|
* @param[in] data Write data
|
||||||
|
*
|
||||||
|
* @retval 0 If successful.
|
||||||
|
* @retval -EIO General input / output error.
|
||||||
|
* @retval -ETIMEDOUT If transaction timedout on the bus
|
||||||
|
* @retval -ENOSYS if read is not supported
|
||||||
|
*/
|
||||||
|
int eth_lan865x_mdio_c22_write(const struct device *dev, uint8_t prtad, uint8_t regad,
|
||||||
|
uint16_t data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read C45 registers using LAN865X MDIO Bus
|
||||||
|
*
|
||||||
|
* This routine provides an interface to perform a C45 register read on the
|
||||||
|
* LAN865X MDIO bus.
|
||||||
|
*
|
||||||
|
* @param[in] dev Pointer to the device structure for the controller
|
||||||
|
* @param[in] prtad Port address
|
||||||
|
* @param[in] devad MMD device address
|
||||||
|
* @param[in] regad Register address
|
||||||
|
* @param data Pointer to receive read data
|
||||||
|
*
|
||||||
|
* @retval 0 If successful.
|
||||||
|
* @retval -EIO General input / output error.
|
||||||
|
* @retval -ETIMEDOUT If transaction timedout on the bus
|
||||||
|
* @retval -ENOSYS if read is not supported
|
||||||
|
*/
|
||||||
|
int eth_lan865x_mdio_c45_read(const struct device *dev, uint8_t prtad, uint8_t devad,
|
||||||
|
uint16_t regad, uint16_t *data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write C45 registers using LAN865X MDIO Bus
|
||||||
|
*
|
||||||
|
* This routine provides an interface to perform a C45 register write on the
|
||||||
|
* LAN865X MDIO bus.
|
||||||
|
*
|
||||||
|
* @param[in] dev Pointer to the device structure for the controller
|
||||||
|
* @param[in] prtad Port address
|
||||||
|
* @param[in] devad MMD device address
|
||||||
|
* @param[in] regad Register address
|
||||||
|
* @param[in] data Write data
|
||||||
|
*
|
||||||
|
* @retval 0 If successful.
|
||||||
|
* @retval -EIO General input / output error.
|
||||||
|
* @retval -ETIMEDOUT If transaction timedout on the bus
|
||||||
|
* @retval -ENOSYS if read is not supported
|
||||||
|
*/
|
||||||
|
int eth_lan865x_mdio_c45_write(const struct device *dev, uint8_t prtad, uint8_t devad,
|
||||||
|
uint16_t regad, uint16_t data);
|
||||||
|
|
||||||
|
#endif /* ZEPHYR_INCLUDE_DRIVERS_ETH_LAN865X_H__ */
|
||||||
Loading…
Reference in a new issue