Skip to content

Commit

Permalink
minilaketb : config phy(RTL8211E-VB) LED (torvalds#544)
Browse files Browse the repository at this point in the history
Summary:
Summary :
1. config phy led, 1000M is amber LED, 100M/10M is green LED.
2. remove the CONFIG_FTGMAC100_NCSI for minilaketb, because minilaketb is dedicated lan.

Test Plan :
test on minilaketb pass
Closes facebookexternal/openbmc.quanta#544

Reviewed By: vineelasmile

Differential Revision: D8188370

Pulled By: mikechoifb

fbshipit-source-id: 2743d2e
  • Loading branch information
Ken Chen authored and facebook-github-bot committed Jul 3, 2018
1 parent 8f44d82 commit 6d50712
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/net/ethernet/faraday/ftgmac100.c
Original file line number Diff line number Diff line change
Expand Up @@ -2117,7 +2117,7 @@ void ncsi_start(struct net_device *dev) {
//TODO: This is an issue in Get_Version_ID that always returns
//mezz_type to be -1, so it only calls Get_MAC_Address_bcm.
//It may need to work with Mlx to find a solution.
#if defined(CONFIG_FBY2) || defined(CONFIG_YOSEMITE) || defined(CONFIG_MINILAKETB) //For multi-host NIC initialization
#if defined(CONFIG_FBY2) || defined(CONFIG_YOSEMITE) //For multi-host NIC initialization
// Try Mlx first
Get_MAC_Address_mlx(dev);
Set_MAC_Affinity_mlx(dev);
Expand Down Expand Up @@ -3258,6 +3258,7 @@ static int ftgmac100_open(struct net_device *netdev)
init_completion(&priv->ncsi_complete);
dev_add_pack(&ptype_ncsi);
#else
phy_config_led(priv->mii_bus);
phy_start(priv->phydev);
#endif

Expand All @@ -3266,10 +3267,6 @@ static int ftgmac100_open(struct net_device *netdev)

/* enable all interrupts */
#ifdef CONFIG_FTGMAC100_NCSI
#ifdef CONFIG_MINILAKETB
iowrite32(INT_MASK_ALL_ENABLED, priv->base + FTGMAC100_OFFSET_IER);
return 0;
#endif
iowrite32(INT_MASK_NCSI_ENABLED, priv->base + FTGMAC100_OFFSET_IER);
ncsi_start(netdev);
#else
Expand Down
28 changes: 28 additions & 0 deletions drivers/net/phy/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,34 @@ void phy_start(struct phy_device *phydev)
}
EXPORT_SYMBOL(phy_start);

void phy_config_led(struct mii_bus *bus)
{
u16 data;
u8 phy_addr = 0x01; //for minilaketb

//static int ftgmac100_mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)
//static int ftgmac100_mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum, u16 value)

//To switch to extension Page44, set register31 Data = 0x07, set register30 Data = 0x2C
bus->write(bus, phy_addr, 31, 0x07);
bus->write(bus, phy_addr, 30, 0x2C);

// LED1(Amber) is 1000M, bit6 = 1
// LED2(Green) is 100M/10M, bit8/9 = 1
data = bus->read(bus, phy_addr, 28);
data = data & 0xF000;
data = data | 0x0340;
bus->write(bus, phy_addr, 28, data);

data = bus->read(bus, phy_addr, 26);
data = data & 0xFF8F;
data = data | 0x0010;
bus->write(bus, phy_addr, 26, data);

//After LED setting, switch to page0 (register31 Data = 0x00)
bus->write(bus, phy_addr, 31, 0x0000);
}

/**
* phy_state_machine - Handle the state machine
* @work: work_struct that describes the work to be done
Expand Down
1 change: 1 addition & 0 deletions include/linux/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ struct phy_device *phy_connect(struct net_device *dev, const char *bus_id,
phy_interface_t interface);
void phy_disconnect(struct phy_device *phydev);
void phy_detach(struct phy_device *phydev);
void phy_config_led(struct mii_bus *bus);
void phy_start(struct phy_device *phydev);
void phy_stop(struct phy_device *phydev);
int phy_start_aneg(struct phy_device *phydev);
Expand Down

0 comments on commit 6d50712

Please sign in to comment.