Browse Source
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>pull/84120/head
7 changed files with 236 additions and 0 deletions
@ -0,0 +1,20 @@
@@ -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 |
@ -0,0 +1,79 @@
@@ -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) |
@ -0,0 +1,10 @@
@@ -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 |
@ -0,0 +1,92 @@
@@ -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 new issue