// SPDX-License-Identifier: GPL-2.0-only
/*
* Clause 45 PHY support
*/
#include <linux/ethtool.h>
#include <linux/export.h>
#include <linux/mdio.h>
#include <linux/mii.h>
#include <linux/phy.h>
#include "mdio-open-alliance.h"
/**
* genphy_c45_baset1_able - checks if the PMA has BASE-T1 extended abilities
* @phydev: target phy_device struct
*/
static bool genphy_c45_baset1_able(struct phy_device *phydev)
{
int val;
if (phydev->pma_extable == -ENODATA) {
val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_EXTABLE);
if (val < 0)
return false;
phydev->pma_extable = val;
}
return !!(phydev->pma_extable & MDIO_PMA_EXTABLE_BT1);
}
/**
* genphy_c45_pma_can_sleep - checks if the PMA have sleep support
* @phydev: target phy_device struct
*/
static bool genphy_c45_pma_can_sleep(struct phy_device *phydev)
{
int stat1;
stat1 = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_STAT1);
if (stat1 < 0)
return false;
return !!(stat1 & MDIO_STAT1_LPOWERABLE);
}
/**
* genphy_c45_pma_resume - wakes up the PMA module
* @phydev: target phy_device struct
*/
int genphy_c45_pma_resume