mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
phy: Fix style violations
Fix some style violations in the generic PHY management code. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Mario Six <mario.six@gdsys.cc>
This commit is contained in:

committed by
Joe Hershberger

parent
c550389881
commit
8d6312032e
@ -27,7 +27,7 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||||||
/* Generic PHY support and helper functions */
|
/* Generic PHY support and helper functions */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* genphy_config_advert - sanitize and advertise auto-negotation parameters
|
* genphy_config_advert - sanitize and advertise auto-negotiation parameters
|
||||||
* @phydev: target phy_device struct
|
* @phydev: target phy_device struct
|
||||||
*
|
*
|
||||||
* Description: Writes MII_ADVERTISE with the appropriate values,
|
* Description: Writes MII_ADVERTISE with the appropriate values,
|
||||||
@ -117,7 +117,6 @@ static int genphy_config_advert(struct phy_device *phydev)
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* genphy_setup_forced - configures/forces speed/duplex from @phydev
|
* genphy_setup_forced - configures/forces speed/duplex from @phydev
|
||||||
* @phydev: target phy_device struct
|
* @phydev: target phy_device struct
|
||||||
@ -130,14 +129,15 @@ static int genphy_setup_forced(struct phy_device *phydev)
|
|||||||
int err;
|
int err;
|
||||||
int ctl = BMCR_ANRESTART;
|
int ctl = BMCR_ANRESTART;
|
||||||
|
|
||||||
phydev->pause = phydev->asym_pause = 0;
|
phydev->pause = 0;
|
||||||
|
phydev->asym_pause = 0;
|
||||||
|
|
||||||
if (SPEED_1000 == phydev->speed)
|
if (phydev->speed == SPEED_1000)
|
||||||
ctl |= BMCR_SPEED1000;
|
ctl |= BMCR_SPEED1000;
|
||||||
else if (SPEED_100 == phydev->speed)
|
else if (phydev->speed == SPEED_100)
|
||||||
ctl |= BMCR_SPEED100;
|
ctl |= BMCR_SPEED100;
|
||||||
|
|
||||||
if (DUPLEX_FULL == phydev->duplex)
|
if (phydev->duplex == DUPLEX_FULL)
|
||||||
ctl |= BMCR_FULLDPLX;
|
ctl |= BMCR_FULLDPLX;
|
||||||
|
|
||||||
err = phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, ctl);
|
err = phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, ctl);
|
||||||
@ -145,7 +145,6 @@ static int genphy_setup_forced(struct phy_device *phydev)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* genphy_restart_aneg - Enable and Restart Autonegotiation
|
* genphy_restart_aneg - Enable and Restart Autonegotiation
|
||||||
* @phydev: target phy_device struct
|
* @phydev: target phy_device struct
|
||||||
@ -169,7 +168,6 @@ int genphy_restart_aneg(struct phy_device *phydev)
|
|||||||
return ctl;
|
return ctl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* genphy_config_aneg - restart auto-negotiation or write BMCR
|
* genphy_config_aneg - restart auto-negotiation or write BMCR
|
||||||
* @phydev: target phy_device struct
|
* @phydev: target phy_device struct
|
||||||
@ -182,7 +180,7 @@ int genphy_config_aneg(struct phy_device *phydev)
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if (AUTONEG_ENABLE != phydev->autoneg)
|
if (phydev->autoneg != AUTONEG_ENABLE)
|
||||||
return genphy_setup_forced(phydev);
|
return genphy_setup_forced(phydev);
|
||||||
|
|
||||||
result = genphy_config_advert(phydev);
|
result = genphy_config_advert(phydev);
|
||||||
@ -191,8 +189,10 @@ int genphy_config_aneg(struct phy_device *phydev)
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
/* Advertisment hasn't changed, but maybe aneg was never on to
|
/*
|
||||||
* begin with? Or maybe phy was isolated? */
|
* Advertisment hasn't changed, but maybe aneg was never on to
|
||||||
|
* begin with? Or maybe phy was isolated?
|
||||||
|
*/
|
||||||
int ctl = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR);
|
int ctl = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR);
|
||||||
|
|
||||||
if (ctl < 0)
|
if (ctl < 0)
|
||||||
@ -202,8 +202,10 @@ int genphy_config_aneg(struct phy_device *phydev)
|
|||||||
result = 1; /* do restart aneg */
|
result = 1; /* do restart aneg */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only restart aneg if we are advertising something different
|
/*
|
||||||
* than we were before. */
|
* Only restart aneg if we are advertising something different
|
||||||
|
* than we were before.
|
||||||
|
*/
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
result = genphy_restart_aneg(phydev);
|
result = genphy_restart_aneg(phydev);
|
||||||
|
|
||||||
@ -305,7 +307,8 @@ int genphy_parse_link(struct phy_device *phydev)
|
|||||||
*/
|
*/
|
||||||
gblpa = phy_read(phydev, MDIO_DEVAD_NONE, MII_STAT1000);
|
gblpa = phy_read(phydev, MDIO_DEVAD_NONE, MII_STAT1000);
|
||||||
if (gblpa < 0) {
|
if (gblpa < 0) {
|
||||||
debug("Could not read MII_STAT1000. Ignoring gigabit capability\n");
|
debug("Could not read MII_STAT1000. ");
|
||||||
|
debug("Ignoring gigabit capability\n");
|
||||||
gblpa = 0;
|
gblpa = 0;
|
||||||
}
|
}
|
||||||
gblpa &= phy_read(phydev,
|
gblpa &= phy_read(phydev,
|
||||||
@ -338,8 +341,9 @@ int genphy_parse_link(struct phy_device *phydev)
|
|||||||
if (lpa & LPA_100FULL)
|
if (lpa & LPA_100FULL)
|
||||||
phydev->duplex = DUPLEX_FULL;
|
phydev->duplex = DUPLEX_FULL;
|
||||||
|
|
||||||
} else if (lpa & LPA_10FULL)
|
} else if (lpa & LPA_10FULL) {
|
||||||
phydev->duplex = DUPLEX_FULL;
|
phydev->duplex = DUPLEX_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extended status may indicate that the PHY supports
|
* Extended status may indicate that the PHY supports
|
||||||
@ -580,7 +584,9 @@ static int phy_probe(struct phy_device *phydev)
|
|||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
phydev->advertising = phydev->supported = phydev->drv->features;
|
phydev->advertising = phydev->drv->features;
|
||||||
|
phydev->supported = phydev->drv->features;
|
||||||
|
|
||||||
phydev->mmds = phydev->drv->mmds;
|
phydev->mmds = phydev->drv->mmds;
|
||||||
|
|
||||||
if (phydev->drv->probe)
|
if (phydev->drv->probe)
|
||||||
@ -622,8 +628,10 @@ static struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
|
|||||||
{
|
{
|
||||||
struct phy_device *dev;
|
struct phy_device *dev;
|
||||||
|
|
||||||
/* We allocate the device, and initialize the
|
/*
|
||||||
* default values */
|
* We allocate the device, and initialize the
|
||||||
|
* default values
|
||||||
|
*/
|
||||||
dev = malloc(sizeof(*dev));
|
dev = malloc(sizeof(*dev));
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
printf("Failed to allocate PHY device for %s:%d\n",
|
printf("Failed to allocate PHY device for %s:%d\n",
|
||||||
@ -665,8 +673,10 @@ int __weak get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
|
|||||||
{
|
{
|
||||||
int phy_reg;
|
int phy_reg;
|
||||||
|
|
||||||
/* Grab the bits from PHYIR1, and put them
|
/*
|
||||||
* in the upper half */
|
* Grab the bits from PHYIR1, and put them
|
||||||
|
* in the upper half
|
||||||
|
*/
|
||||||
phy_reg = bus->read(bus, addr, devad, MII_PHYSID1);
|
phy_reg = bus->read(bus, addr, devad, MII_PHYSID1);
|
||||||
|
|
||||||
if (phy_reg < 0)
|
if (phy_reg < 0)
|
||||||
@ -686,9 +696,11 @@ int __weak get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct phy_device *create_phy_by_mask(struct mii_dev *bus,
|
static struct phy_device *create_phy_by_mask(struct mii_dev *bus,
|
||||||
unsigned phy_mask, int devad, phy_interface_t interface)
|
uint phy_mask, int devad,
|
||||||
|
phy_interface_t interface)
|
||||||
{
|
{
|
||||||
u32 phy_id = 0xffffffff;
|
u32 phy_id = 0xffffffff;
|
||||||
|
|
||||||
while (phy_mask) {
|
while (phy_mask) {
|
||||||
int addr = ffs(phy_mask) - 1;
|
int addr = ffs(phy_mask) - 1;
|
||||||
int r = get_phy_id(bus, addr, devad, &phy_id);
|
int r = get_phy_id(bus, addr, devad, &phy_id);
|
||||||
@ -701,11 +713,13 @@ static struct phy_device *create_phy_by_mask(struct mii_dev *bus,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct phy_device *search_for_existing_phy(struct mii_dev *bus,
|
static struct phy_device *search_for_existing_phy(struct mii_dev *bus,
|
||||||
unsigned phy_mask, phy_interface_t interface)
|
uint phy_mask,
|
||||||
|
phy_interface_t interface)
|
||||||
{
|
{
|
||||||
/* If we have one, return the existing device, with new interface */
|
/* If we have one, return the existing device, with new interface */
|
||||||
while (phy_mask) {
|
while (phy_mask) {
|
||||||
int addr = ffs(phy_mask) - 1;
|
int addr = ffs(phy_mask) - 1;
|
||||||
|
|
||||||
if (bus->phymap[addr]) {
|
if (bus->phymap[addr]) {
|
||||||
bus->phymap[addr]->interface = interface;
|
bus->phymap[addr]->interface = interface;
|
||||||
return bus->phymap[addr];
|
return bus->phymap[addr];
|
||||||
@ -716,7 +730,8 @@ static struct phy_device *search_for_existing_phy(struct mii_dev *bus,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus,
|
static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus,
|
||||||
unsigned phy_mask, phy_interface_t interface)
|
uint phy_mask,
|
||||||
|
phy_interface_t interface)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct phy_device *phydev;
|
struct phy_device *phydev;
|
||||||
@ -738,6 +753,7 @@ static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus,
|
|||||||
debug("\n%s PHY: ", bus->name);
|
debug("\n%s PHY: ", bus->name);
|
||||||
while (phy_mask) {
|
while (phy_mask) {
|
||||||
int addr = ffs(phy_mask) - 1;
|
int addr = ffs(phy_mask) - 1;
|
||||||
|
|
||||||
debug("%d ", addr);
|
debug("%d ", addr);
|
||||||
phy_mask &= ~(1 << addr);
|
phy_mask &= ~(1 << addr);
|
||||||
}
|
}
|
||||||
@ -747,7 +763,8 @@ static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get_phy_device - reads the specified PHY device and returns its @phy_device struct
|
* get_phy_device - reads the specified PHY device and returns its
|
||||||
|
* @phy_device struct
|
||||||
* @bus: the target MII bus
|
* @bus: the target MII bus
|
||||||
* @addr: PHY address on the MII bus
|
* @addr: PHY address on the MII bus
|
||||||
*
|
*
|
||||||
@ -826,7 +843,7 @@ int miiphy_reset(const char *devname, unsigned char addr)
|
|||||||
return phy_reset(phydev);
|
return phy_reset(phydev);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask,
|
struct phy_device *phy_find_by_mask(struct mii_dev *bus, uint phy_mask,
|
||||||
phy_interface_t interface)
|
phy_interface_t interface)
|
||||||
{
|
{
|
||||||
/* Reset the bus */
|
/* Reset the bus */
|
||||||
@ -834,7 +851,7 @@ struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask,
|
|||||||
bus->reset(bus);
|
bus->reset(bus);
|
||||||
|
|
||||||
/* Wait 15ms to make sure the PHY has come out of hard reset */
|
/* Wait 15ms to make sure the PHY has come out of hard reset */
|
||||||
udelay(15000);
|
mdelay(15);
|
||||||
}
|
}
|
||||||
|
|
||||||
return get_phy_device_by_mask(bus, phy_mask, interface);
|
return get_phy_device_by_mask(bus, phy_mask, interface);
|
||||||
@ -859,20 +876,23 @@ void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev)
|
|||||||
|
|
||||||
#ifdef CONFIG_DM_ETH
|
#ifdef CONFIG_DM_ETH
|
||||||
struct phy_device *phy_connect(struct mii_dev *bus, int addr,
|
struct phy_device *phy_connect(struct mii_dev *bus, int addr,
|
||||||
struct udevice *dev, phy_interface_t interface)
|
struct udevice *dev,
|
||||||
|
phy_interface_t interface)
|
||||||
#else
|
#else
|
||||||
struct phy_device *phy_connect(struct mii_dev *bus, int addr,
|
struct phy_device *phy_connect(struct mii_dev *bus, int addr,
|
||||||
struct eth_device *dev, phy_interface_t interface)
|
struct eth_device *dev,
|
||||||
|
phy_interface_t interface)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
struct phy_device *phydev = NULL;
|
struct phy_device *phydev = NULL;
|
||||||
#ifdef CONFIG_PHY_FIXED
|
#ifdef CONFIG_PHY_FIXED
|
||||||
int sn;
|
int sn;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
sn = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
|
sn = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
|
||||||
while (sn > 0) {
|
while (sn > 0) {
|
||||||
name = fdt_get_name(gd->fdt_blob, sn, NULL);
|
name = fdt_get_name(gd->fdt_blob, sn, NULL);
|
||||||
if (name != NULL && strcmp(name, "fixed-link") == 0) {
|
if (name && strcmp(name, "fixed-link") == 0) {
|
||||||
phydev = phy_device_create(bus,
|
phydev = phy_device_create(bus,
|
||||||
sn, PHY_FIXED_ID, interface);
|
sn, PHY_FIXED_ID, interface);
|
||||||
break;
|
break;
|
||||||
@ -880,7 +900,7 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
|
|||||||
sn = fdt_next_subnode(gd->fdt_blob, sn);
|
sn = fdt_next_subnode(gd->fdt_blob, sn);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (phydev == NULL)
|
if (!phydev)
|
||||||
phydev = phy_find_by_mask(bus, 1 << addr, interface);
|
phydev = phy_find_by_mask(bus, 1 << addr, interface);
|
||||||
|
|
||||||
if (phydev)
|
if (phydev)
|
||||||
|
Reference in New Issue
Block a user