mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-12 14:23:00 +00:00
05b60ac549
We want to be able to include some other system headers in phy.h but that requires us to have included common.h in the top-level first. Also, common.h includes config.h as the first thing it does, so don't include it directly. Series-to: u-boot Series-cc: Grygorii Strashko <grygorii.strashko@ti.com> Seried-cc: ti Series-process-log: sort, uniq Cover-letter: Prepare for net: phy: prevent uclass_eth device "node" field overwriting Prepare for [1] so that it doesn't break the build for a bunch of boards. There are a number of reasons this series broke the build but none of them depend on changes in the series, so fix up those situations ahead of applying that series. [1] https://patchwork.ozlabs.org/cover/940104/ END Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
91 lines
2.1 KiB
C
91 lines
2.1 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Generic PHY Management code
|
|
*
|
|
* Copyright 2011 Freescale Semiconductor, Inc.
|
|
* author Andy Fleming
|
|
*
|
|
* Based loosely off of Linux's PHY Lib
|
|
*/
|
|
#include <common.h>
|
|
#include <miiphy.h>
|
|
#include <phy.h>
|
|
|
|
int gen10g_shutdown(struct phy_device *phydev)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int gen10g_startup(struct phy_device *phydev)
|
|
{
|
|
int devad, reg;
|
|
u32 mmd_mask = phydev->mmds & MDIO_DEVS_LINK;
|
|
|
|
phydev->link = 1;
|
|
|
|
/* For now just lie and say it's 10G all the time */
|
|
phydev->speed = SPEED_10000;
|
|
phydev->duplex = DUPLEX_FULL;
|
|
|
|
/*
|
|
* Go through all the link-reporting devices, and make sure
|
|
* they're all up and happy
|
|
*/
|
|
for (devad = 0; mmd_mask; devad++, mmd_mask = mmd_mask >> 1) {
|
|
if (!(mmd_mask & 1))
|
|
continue;
|
|
|
|
/* Read twice because link state is latched and a
|
|
* read moves the current state into the register */
|
|
phy_read(phydev, devad, MDIO_STAT1);
|
|
reg = phy_read(phydev, devad, MDIO_STAT1);
|
|
if (reg < 0 || !(reg & MDIO_STAT1_LSTATUS))
|
|
phydev->link = 0;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int gen10g_discover_mmds(struct phy_device *phydev)
|
|
{
|
|
int mmd, stat2, devs1, devs2;
|
|
|
|
/* Assume PHY must have at least one of PMA/PMD, WIS, PCS, PHY
|
|
* XS or DTE XS; give up if none is present. */
|
|
for (mmd = 1; mmd <= 5; mmd++) {
|
|
/* Is this MMD present? */
|
|
stat2 = phy_read(phydev, mmd, MDIO_STAT2);
|
|
if (stat2 < 0 ||
|
|
(stat2 & MDIO_STAT2_DEVPRST) != MDIO_STAT2_DEVPRST_VAL)
|
|
continue;
|
|
|
|
/* It should tell us about all the other MMDs */
|
|
devs1 = phy_read(phydev, mmd, MDIO_DEVS1);
|
|
devs2 = phy_read(phydev, mmd, MDIO_DEVS2);
|
|
if (devs1 < 0 || devs2 < 0)
|
|
continue;
|
|
|
|
phydev->mmds = devs1 | (devs2 << 16);
|
|
return 0;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int gen10g_config(struct phy_device *phydev)
|
|
{
|
|
/* For now, assume 10000baseT. Fill in later */
|
|
phydev->supported = phydev->advertising = SUPPORTED_10000baseT_Full;
|
|
|
|
return gen10g_discover_mmds(phydev);
|
|
}
|
|
|
|
struct phy_driver gen10g_driver = {
|
|
.uid = 0xffffffff,
|
|
.mask = 0xffffffff,
|
|
.name = "Generic 10G PHY",
|
|
.features = 0,
|
|
.config = gen10g_config,
|
|
.startup = gen10g_startup,
|
|
.shutdown = gen10g_shutdown,
|
|
};
|