net: phy: move __phy_package_[read|write]_mmd to phy_package.c
Move both functions to phy_package.c, so that phy_core.c no longer has a dependency on phy_package.c (phy_package_address). Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Link: https://patch.msgid.link/8956fa53-3eda-4079-8203-a8fddcc17bf3@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
883af78926
commit
cbd1ab0ce8
@@ -375,8 +375,8 @@ static void mmd_phy_indirect(struct mii_bus *bus, int phy_addr, int devad,
|
||||
devad | MII_MMD_CTRL_NOINCR);
|
||||
}
|
||||
|
||||
static int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45,
|
||||
int devad, u32 regnum)
|
||||
int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45,
|
||||
int devad, u32 regnum)
|
||||
{
|
||||
if (is_c45)
|
||||
return __mdiobus_c45_read(bus, phy_addr, devad, regnum);
|
||||
@@ -385,9 +385,10 @@ static int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45,
|
||||
/* Read the content of the MMD's selected register */
|
||||
return __mdiobus_read(bus, phy_addr, MII_MMD_DATA);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mmd_phy_read);
|
||||
|
||||
static int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45,
|
||||
int devad, u32 regnum, u16 val)
|
||||
int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45,
|
||||
int devad, u32 regnum, u16 val)
|
||||
{
|
||||
if (is_c45)
|
||||
return __mdiobus_c45_write(bus, phy_addr, devad, regnum, val);
|
||||
@@ -396,6 +397,7 @@ static int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45,
|
||||
/* Write the data into MMD's selected register */
|
||||
return __mdiobus_write(bus, phy_addr, MII_MMD_DATA, val);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mmd_phy_write);
|
||||
|
||||
/**
|
||||
* __phy_read_mmd - Convenience function for reading a register
|
||||
@@ -485,71 +487,6 @@ int phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val)
|
||||
}
|
||||
EXPORT_SYMBOL(phy_write_mmd);
|
||||
|
||||
/**
|
||||
* __phy_package_read_mmd - read MMD reg relative to PHY package base addr
|
||||
* @phydev: The phy_device struct
|
||||
* @addr_offset: The offset to be added to PHY package base_addr
|
||||
* @devad: The MMD to read from
|
||||
* @regnum: The register on the MMD to read
|
||||
*
|
||||
* Convenience helper for reading a register of an MMD on a given PHY
|
||||
* using the PHY package base address. The base address is added to
|
||||
* the addr_offset value.
|
||||
*
|
||||
* Same calling rules as for __phy_read();
|
||||
*
|
||||
* NOTE: It's assumed that the entire PHY package is either C22 or C45.
|
||||
*/
|
||||
int __phy_package_read_mmd(struct phy_device *phydev,
|
||||
unsigned int addr_offset, int devad,
|
||||
u32 regnum)
|
||||
{
|
||||
int addr = phy_package_address(phydev, addr_offset);
|
||||
|
||||
if (addr < 0)
|
||||
return addr;
|
||||
|
||||
if (regnum > (u16)~0 || devad > 32)
|
||||
return -EINVAL;
|
||||
|
||||
return mmd_phy_read(phydev->mdio.bus, addr, phydev->is_c45, devad,
|
||||
regnum);
|
||||
}
|
||||
EXPORT_SYMBOL(__phy_package_read_mmd);
|
||||
|
||||
/**
|
||||
* __phy_package_write_mmd - write MMD reg relative to PHY package base addr
|
||||
* @phydev: The phy_device struct
|
||||
* @addr_offset: The offset to be added to PHY package base_addr
|
||||
* @devad: The MMD to write to
|
||||
* @regnum: The register on the MMD to write
|
||||
* @val: value to write to @regnum
|
||||
*
|
||||
* Convenience helper for writing a register of an MMD on a given PHY
|
||||
* using the PHY package base address. The base address is added to
|
||||
* the addr_offset value.
|
||||
*
|
||||
* Same calling rules as for __phy_write();
|
||||
*
|
||||
* NOTE: It's assumed that the entire PHY package is either C22 or C45.
|
||||
*/
|
||||
int __phy_package_write_mmd(struct phy_device *phydev,
|
||||
unsigned int addr_offset, int devad,
|
||||
u32 regnum, u16 val)
|
||||
{
|
||||
int addr = phy_package_address(phydev, addr_offset);
|
||||
|
||||
if (addr < 0)
|
||||
return addr;
|
||||
|
||||
if (regnum > (u16)~0 || devad > 32)
|
||||
return -EINVAL;
|
||||
|
||||
return mmd_phy_write(phydev->mdio.bus, addr, phydev->is_c45, devad,
|
||||
regnum, val);
|
||||
}
|
||||
EXPORT_SYMBOL(__phy_package_write_mmd);
|
||||
|
||||
/**
|
||||
* phy_modify_changed - Function for modifying a PHY register
|
||||
* @phydev: the phy_device struct
|
||||
|
||||
@@ -52,7 +52,8 @@ void *phy_package_get_priv(struct phy_device *phydev)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(phy_package_get_priv);
|
||||
|
||||
int phy_package_address(struct phy_device *phydev, unsigned int addr_offset)
|
||||
static int phy_package_address(struct phy_device *phydev,
|
||||
unsigned int addr_offset)
|
||||
{
|
||||
struct phy_package_shared *shared = phydev->shared;
|
||||
u8 base_addr = shared->base_addr;
|
||||
@@ -90,6 +91,71 @@ int __phy_package_write(struct phy_device *phydev, unsigned int addr_offset,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__phy_package_write);
|
||||
|
||||
/**
|
||||
* __phy_package_read_mmd - read MMD reg relative to PHY package base addr
|
||||
* @phydev: The phy_device struct
|
||||
* @addr_offset: The offset to be added to PHY package base_addr
|
||||
* @devad: The MMD to read from
|
||||
* @regnum: The register on the MMD to read
|
||||
*
|
||||
* Convenience helper for reading a register of an MMD on a given PHY
|
||||
* using the PHY package base address. The base address is added to
|
||||
* the addr_offset value.
|
||||
*
|
||||
* Same calling rules as for __phy_read();
|
||||
*
|
||||
* NOTE: It's assumed that the entire PHY package is either C22 or C45.
|
||||
*/
|
||||
int __phy_package_read_mmd(struct phy_device *phydev,
|
||||
unsigned int addr_offset, int devad,
|
||||
u32 regnum)
|
||||
{
|
||||
int addr = phy_package_address(phydev, addr_offset);
|
||||
|
||||
if (addr < 0)
|
||||
return addr;
|
||||
|
||||
if (regnum > (u16)~0 || devad > 32)
|
||||
return -EINVAL;
|
||||
|
||||
return mmd_phy_read(phydev->mdio.bus, addr, phydev->is_c45, devad,
|
||||
regnum);
|
||||
}
|
||||
EXPORT_SYMBOL(__phy_package_read_mmd);
|
||||
|
||||
/**
|
||||
* __phy_package_write_mmd - write MMD reg relative to PHY package base addr
|
||||
* @phydev: The phy_device struct
|
||||
* @addr_offset: The offset to be added to PHY package base_addr
|
||||
* @devad: The MMD to write to
|
||||
* @regnum: The register on the MMD to write
|
||||
* @val: value to write to @regnum
|
||||
*
|
||||
* Convenience helper for writing a register of an MMD on a given PHY
|
||||
* using the PHY package base address. The base address is added to
|
||||
* the addr_offset value.
|
||||
*
|
||||
* Same calling rules as for __phy_write();
|
||||
*
|
||||
* NOTE: It's assumed that the entire PHY package is either C22 or C45.
|
||||
*/
|
||||
int __phy_package_write_mmd(struct phy_device *phydev,
|
||||
unsigned int addr_offset, int devad,
|
||||
u32 regnum, u16 val)
|
||||
{
|
||||
int addr = phy_package_address(phydev, addr_offset);
|
||||
|
||||
if (addr < 0)
|
||||
return addr;
|
||||
|
||||
if (regnum > (u16)~0 || devad > 32)
|
||||
return -EINVAL;
|
||||
|
||||
return mmd_phy_write(phydev->mdio.bus, addr, phydev->is_c45, devad,
|
||||
regnum, val);
|
||||
}
|
||||
EXPORT_SYMBOL(__phy_package_write_mmd);
|
||||
|
||||
static bool __phy_package_set_once(struct phy_device *phydev, unsigned int b)
|
||||
{
|
||||
struct phy_package_shared *shared = phydev->shared;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#define __PHYLIB_INTERNAL_H
|
||||
|
||||
struct phy_device;
|
||||
struct mii_bus;
|
||||
|
||||
/*
|
||||
* phy_supported_speeds - return all speeds currently supported by a PHY device
|
||||
@@ -20,7 +21,10 @@ void of_set_phy_timing_role(struct phy_device *phydev);
|
||||
int phy_speed_down_core(struct phy_device *phydev);
|
||||
void phy_check_downshift(struct phy_device *phydev);
|
||||
|
||||
int phy_package_address(struct phy_device *phydev, unsigned int addr_offset);
|
||||
int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45,
|
||||
int devad, u32 regnum);
|
||||
int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45,
|
||||
int devad, u32 regnum, u16 val);
|
||||
|
||||
int genphy_c45_read_eee_adv(struct phy_device *phydev, unsigned long *adv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user