diff mbox series

[net-next,RESEND,1/1] net: phy: dp83867: Add support for active-low LEDs

Message ID 20240131075048.1092551-1-alexander.stein@ew.tq-group.com (mailing list archive)
State Accepted
Commit 447b80a9330ef2d9a94fc5a9bf35b6eac061f38b
Delegated to: Netdev Maintainers
Headers show
Series [net-next,RESEND,1/1] net: phy: dp83867: Add support for active-low LEDs | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1048 this patch: 1048
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1065 this patch: 1065
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1065 this patch: 1065
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 40 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-01--18-00 (tests: 717)

Commit Message

Alexander Stein Jan. 31, 2024, 7:50 a.m. UTC
Add the led_polarity_set callback for setting LED polarity.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
With the addition of LED polarity modes, PHY LEDs attached to this PHY can
be configured as active-low.

Note1: This callback is only called if at least once bit of 'enum phy_led_modes'
  is set. This works only because active-high is default on this hardware.

Note2: DP83867_SW_RESET in dp83867_phy_reset clears any previously set config.
  This needs to be addressed as well. Same for interface down/up cycle which
  might include a hardware reset as well. So LED config needs to be cached.

But that's independent from this change.

This is just a resend with target tree named in subject

[1] https://lore.kernel.org/all/20240125203702.4552-4-ansuelsmth@gmail.com/

 drivers/net/phy/dp83867.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Andrew Lunn Jan. 31, 2024, 3:26 p.m. UTC | #1
On Wed, Jan 31, 2024 at 08:50:48AM +0100, Alexander Stein wrote:
> Add the led_polarity_set callback for setting LED polarity.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
patchwork-bot+netdevbpf@kernel.org Feb. 2, 2024, 10:20 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed, 31 Jan 2024 08:50:48 +0100 you wrote:
> Add the led_polarity_set callback for setting LED polarity.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> ---
> With the addition of LED polarity modes, PHY LEDs attached to this PHY can
> be configured as active-low.
> 
> [...]

Here is the summary with links:
  - [net-next,RESEND,1/1] net: phy: dp83867: Add support for active-low LEDs
    https://git.kernel.org/netdev/net-next/c/447b80a9330e

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 5f08f9d38bd7a..4120385c5a79d 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -158,6 +158,7 @@ 
 /* LED_DRV bits */
 #define DP83867_LED_DRV_EN(x)	BIT((x) * 4)
 #define DP83867_LED_DRV_VAL(x)	BIT((x) * 4 + 1)
+#define DP83867_LED_POLARITY(x)	BIT((x) * 4 + 2)
 
 #define DP83867_LED_FN(idx, val)	(((val) & 0xf) << ((idx) * 4))
 #define DP83867_LED_FN_MASK(idx)	(0xf << ((idx) * 4))
@@ -1152,6 +1153,26 @@  static int dp83867_led_hw_control_get(struct phy_device *phydev, u8 index,
 	return 0;
 }
 
+static int dp83867_led_polarity_set(struct phy_device *phydev, int index,
+				    unsigned long modes)
+{
+	/* Default active high */
+	u16 polarity = DP83867_LED_POLARITY(index);
+	u32 mode;
+
+	for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) {
+		switch (mode) {
+		case PHY_LED_ACTIVE_LOW:
+			polarity = 0;
+			break;
+		default:
+			return -EINVAL;
+		}
+	}
+	return phy_modify(phydev, DP83867_LEDCR2,
+			  DP83867_LED_POLARITY(index), polarity);
+}
+
 static struct phy_driver dp83867_driver[] = {
 	{
 		.phy_id		= DP83867_PHY_ID,
@@ -1184,6 +1205,7 @@  static struct phy_driver dp83867_driver[] = {
 		.led_hw_is_supported = dp83867_led_hw_is_supported,
 		.led_hw_control_set = dp83867_led_hw_control_set,
 		.led_hw_control_get = dp83867_led_hw_control_get,
+		.led_polarity_set = dp83867_led_polarity_set,
 	},
 };
 module_phy_driver(dp83867_driver);