diff mbox series

[2/2] r8152: add LED configuration from OF

Message ID 20210814181107.138992-2-mail@david-bauer.net (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [1/2] dt-bindings: net: add RTL8152 binding documentation | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 4 maintainers not CCed: lee.jones@linaro.org tiwai@suse.de hayeswang@realtek.com linux-usb@vger.kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 53 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

David Bauer Aug. 14, 2021, 6:11 p.m. UTC
This adds the ability to configure the LED configuration register using
OF. This way, the correct value for board specific LED configuration can
be determined.

Signed-off-by: David Bauer <mail@david-bauer.net>
---
 drivers/net/usb/r8152.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index e09b107b5c99..6f92e8bb2f1a 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -11,6 +11,7 @@ 
 #include <linux/mii.h>
 #include <linux/ethtool.h>
 #include <linux/usb.h>
+#include <linux/of.h>
 #include <linux/crc32.h>
 #include <linux/if_vlan.h>
 #include <linux/uaccess.h>
@@ -6791,6 +6792,22 @@  static void rtl_tally_reset(struct r8152 *tp)
 	ocp_write_word(tp, MCU_TYPE_PLA, PLA_RSTTALLY, ocp_data);
 }
 
+static int r8152_led_configuration(struct r8152 *tp)
+{
+	u32 led_data;
+	int ret;
+
+	ret = of_property_read_u32(tp->udev->dev.of_node, "realtek,led-data",
+				   &led_data);
+
+	if (ret)
+		return ret;
+
+	ocp_write_word(tp, MCU_TYPE_PLA, PLA_LEDSEL, led_data);
+
+	return 0;
+}
+
 static void r8152b_init(struct r8152 *tp)
 {
 	u32 ocp_data;
@@ -6832,6 +6849,8 @@  static void r8152b_init(struct r8152 *tp)
 	ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
 	ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
 	ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
+
+	r8152_led_configuration(tp);
 }
 
 static void r8153_init(struct r8152 *tp)
@@ -7988,6 +8007,8 @@  static void r8156_init(struct r8152 *tp)
 	rtl_tally_reset(tp);
 
 	tp->coalesce = 15000;	/* 15 us */
+
+	r8152_led_configuration(tp);
 }
 
 static void r8156b_init(struct r8152 *tp)
@@ -8117,6 +8138,8 @@  static void r8156b_init(struct r8152 *tp)
 	rtl_tally_reset(tp);
 
 	tp->coalesce = 15000;	/* 15 us */
+
+	r8152_led_configuration(tp);
 }
 
 static bool rtl_check_vendor_ok(struct usb_interface *intf)