lan78xx: Read LED states from Device Tree
Add support for DT property "microchip,led-modes", a vector of zero to four cells (u32s) in the range 0-15, each of which sets the mode for one of the LEDs. Some possible values are: 0=link/activity 1=link1000/activity 2=link100/activity 3=link10/activity 4=link100/1000/activity 5=link10/1000/activity 6=link10/100/activity 14=off 15=on These values are given symbolic constants in a dt-bindings header. Also use the presence of the DT property to indicate that the LEDs should be enabled - necessary in the event that no valid OTP or EEPROM is available. Signed-off-by: Phil Elwell <phil@raspberrypi.org> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
760db29bdc
commit
1827b06788
@@ -20,6 +20,8 @@
|
||||
#include <linux/ethtool.h>
|
||||
#include <linux/phy.h>
|
||||
#include <linux/microchipphy.h>
|
||||
#include <linux/of.h>
|
||||
#include <dt-bindings/net/microchip-lan78xx.h>
|
||||
|
||||
#define DRIVER_AUTHOR "WOOJUNG HUH <woojung.huh@microchip.com>"
|
||||
#define DRIVER_DESC "Microchip LAN88XX PHY driver"
|
||||
@@ -70,6 +72,8 @@ static int lan88xx_probe(struct phy_device *phydev)
|
||||
{
|
||||
struct device *dev = &phydev->mdio.dev;
|
||||
struct lan88xx_priv *priv;
|
||||
u32 led_modes[4];
|
||||
int len;
|
||||
|
||||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
@@ -77,6 +81,27 @@ static int lan88xx_probe(struct phy_device *phydev)
|
||||
|
||||
priv->wolopts = 0;
|
||||
|
||||
len = of_property_read_variable_u32_array(dev->of_node,
|
||||
"microchip,led-modes",
|
||||
led_modes,
|
||||
0,
|
||||
ARRAY_SIZE(led_modes));
|
||||
if (len >= 0) {
|
||||
u32 reg = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (led_modes[i] > 15)
|
||||
return -EINVAL;
|
||||
reg |= led_modes[i] << (i * 4);
|
||||
}
|
||||
for (; i < ARRAY_SIZE(led_modes); i++)
|
||||
reg |= LAN78XX_FORCE_LED_OFF << (i * 4);
|
||||
(void)phy_write(phydev, LAN78XX_PHY_LED_MODE_SELECT, reg);
|
||||
} else if (len == -EOVERFLOW) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* these values can be used to identify internal PHY */
|
||||
priv->chip_id = phy_read_mmd(phydev, 3, LAN88XX_MMD3_CHIP_ID);
|
||||
priv->chip_rev = phy_read_mmd(phydev, 3, LAN88XX_MMD3_CHIP_REV);
|
||||
|
Reference in New Issue
Block a user