forked from Minki/linux
net: phy: mscc: factorize function for getting LED mode from DT
Microsemi PHYs support different LED modes depending on the variant, so let's factorize the code so we just have to give the supported modes while the logic behind getting the mode remains identical. Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
11bfdabb7f
commit
0969abaa50
@ -104,8 +104,24 @@ enum rgmii_rx_clock_delay {
|
||||
#define DOWNSHIFT_COUNT_MAX 5
|
||||
|
||||
#define MAX_LEDS 4
|
||||
#define VSC85XX_SUPP_LED_MODES (BIT(VSC8531_LINK_ACTIVITY) | \
|
||||
BIT(VSC8531_LINK_1000_ACTIVITY) | \
|
||||
BIT(VSC8531_LINK_100_ACTIVITY) | \
|
||||
BIT(VSC8531_LINK_10_ACTIVITY) | \
|
||||
BIT(VSC8531_LINK_100_1000_ACTIVITY) | \
|
||||
BIT(VSC8531_LINK_10_1000_ACTIVITY) | \
|
||||
BIT(VSC8531_LINK_10_100_ACTIVITY) | \
|
||||
BIT(VSC8531_DUPLEX_COLLISION) | \
|
||||
BIT(VSC8531_COLLISION) | \
|
||||
BIT(VSC8531_ACTIVITY) | \
|
||||
BIT(VSC8531_AUTONEG_FAULT) | \
|
||||
BIT(VSC8531_SERIAL_MODE) | \
|
||||
BIT(VSC8531_FORCE_LED_OFF) | \
|
||||
BIT(VSC8531_FORCE_LED_ON))
|
||||
|
||||
struct vsc8531_private {
|
||||
int rate_magic;
|
||||
u16 supp_led_modes;
|
||||
u8 leds_mode[MAX_LEDS];
|
||||
u8 nleds;
|
||||
};
|
||||
@ -401,6 +417,7 @@ static int vsc85xx_dt_led_mode_get(struct phy_device *phydev,
|
||||
char *led,
|
||||
u8 default_mode)
|
||||
{
|
||||
struct vsc8531_private *priv = phydev->priv;
|
||||
struct device *dev = &phydev->mdio.dev;
|
||||
struct device_node *of_node = dev->of_node;
|
||||
u8 led_mode;
|
||||
@ -411,7 +428,7 @@ static int vsc85xx_dt_led_mode_get(struct phy_device *phydev,
|
||||
|
||||
led_mode = default_mode;
|
||||
err = of_property_read_u8(of_node, led, &led_mode);
|
||||
if (!err && (led_mode > 15 || led_mode == 7 || led_mode == 11)) {
|
||||
if (!err && !(BIT(led_mode) & priv->supp_led_modes)) {
|
||||
phydev_err(phydev, "DT %s invalid\n", led);
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -655,6 +672,7 @@ static int vsc85xx_probe(struct phy_device *phydev)
|
||||
|
||||
vsc8531->rate_magic = rate_magic;
|
||||
vsc8531->nleds = 2;
|
||||
vsc8531->supp_led_modes = VSC85XX_SUPP_LED_MODES;
|
||||
|
||||
return vsc85xx_dt_led_modes_get(phydev, default_mode);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user