Skip to content

Commit 938f65a

Browse files
tq-steinakuba-moo
authored andcommitted
net: phy: dp83867: Add led_brightness_set support
Up to 4 LEDs can be attached to the PHY, add support for setting brightness manually. Signed-off-by: Alexander Stein <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent aed8fda commit 938f65a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

drivers/net/phy/dp83867.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#define MII_DP83867_MICR 0x12
2727
#define MII_DP83867_ISR 0x13
2828
#define DP83867_CFG2 0x14
29+
#define DP83867_LEDCR1 0x18
30+
#define DP83867_LEDCR2 0x19
2931
#define DP83867_CFG3 0x1e
3032
#define DP83867_CTRL 0x1f
3133

@@ -150,6 +152,12 @@
150152
/* FLD_THR_CFG */
151153
#define DP83867_FLD_THR_CFG_ENERGY_LOST_THR_MASK 0x7
152154

155+
#define DP83867_LED_COUNT 4
156+
157+
/* LED_DRV bits */
158+
#define DP83867_LED_DRV_EN(x) BIT((x) * 4)
159+
#define DP83867_LED_DRV_VAL(x) BIT((x) * 4 + 1)
160+
153161
enum {
154162
DP83867_PORT_MIRROING_KEEP,
155163
DP83867_PORT_MIRROING_EN,
@@ -969,6 +977,27 @@ static int dp83867_loopback(struct phy_device *phydev, bool enable)
969977
enable ? BMCR_LOOPBACK : 0);
970978
}
971979

980+
static int
981+
dp83867_led_brightness_set(struct phy_device *phydev,
982+
u8 index, enum led_brightness brightness)
983+
{
984+
u32 val;
985+
986+
if (index >= DP83867_LED_COUNT)
987+
return -EINVAL;
988+
989+
/* DRV_EN==1: output is DRV_VAL */
990+
val = DP83867_LED_DRV_EN(index);
991+
992+
if (brightness)
993+
val |= DP83867_LED_DRV_VAL(index);
994+
995+
return phy_modify(phydev, DP83867_LEDCR2,
996+
DP83867_LED_DRV_VAL(index) |
997+
DP83867_LED_DRV_EN(index),
998+
val);
999+
}
1000+
9721001
static struct phy_driver dp83867_driver[] = {
9731002
{
9741003
.phy_id = DP83867_PHY_ID,
@@ -996,6 +1025,8 @@ static struct phy_driver dp83867_driver[] = {
9961025

9971026
.link_change_notify = dp83867_link_change_notify,
9981027
.set_loopback = dp83867_loopback,
1028+
1029+
.led_brightness_set = dp83867_led_brightness_set,
9991030
},
10001031
};
10011032
module_phy_driver(dp83867_driver);

0 commit comments

Comments
 (0)