blob: a5942e85afddc15275ff53552a3b84a700c880b5 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 82985725e071f2a5735052f18e109a32aeac3a0b Mon Sep 17 00:00:00 2001
2From: David Bauer <mail@david-bauer.net>
3Date: Sun, 26 Jul 2020 02:38:31 +0200
4Subject: [PATCH] net: usb: r8152: add LED configuration from OF
5
6This adds the ability to configure the LED configuration register using
7OF. This way, the correct value for board specific LED configuration can
8be determined.
9
10Signed-off-by: David Bauer <mail@david-bauer.net>
11---
12 drivers/net/usb/r8152.c | 23 +++++++++++++++++++++++
13 1 file changed, 23 insertions(+)
14
15--- a/drivers/net/usb/r8152.c
16+++ b/drivers/net/usb/r8152.c
17@@ -11,6 +11,7 @@
18 #include <linux/mii.h>
19 #include <linux/ethtool.h>
20 #include <linux/usb.h>
21+#include <linux/of.h>
22 #include <linux/crc32.h>
23 #include <linux/if_vlan.h>
24 #include <linux/uaccess.h>
25@@ -4338,6 +4339,22 @@ static void rtl_tally_reset(struct r8152
26 ocp_write_word(tp, MCU_TYPE_PLA, PLA_RSTTALLY, ocp_data);
27 }
28
29+static int r8152_led_configuration(struct r8152 *tp)
30+{
31+ u32 led_data;
32+ int ret;
33+
34+ ret = of_property_read_u32(tp->udev->dev.of_node, "realtek,led-data",
35+ &led_data);
36+
37+ if (ret)
38+ return ret;
39+
40+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_LEDSEL, led_data);
41+
42+ return 0;
43+}
44+
45 static void r8152b_init(struct r8152 *tp)
46 {
47 u32 ocp_data;
48@@ -4379,6 +4396,8 @@ static void r8152b_init(struct r8152 *tp
49 ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
50 ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
51 ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
52+
53+ r8152_led_configuration(tp);
54 }
55
56 static void r8153_init(struct r8152 *tp)
57@@ -4513,6 +4532,8 @@ static void r8153_init(struct r8152 *tp)
58 tp->coalesce = COALESCE_SLOW;
59 break;
60 }
61+
62+ r8152_led_configuration(tp);
63 }
64
65 static void r8153b_init(struct r8152 *tp)
66@@ -4589,6 +4610,8 @@ static void r8153b_init(struct r8152 *tp
67 rtl_tally_reset(tp);
68
69 tp->coalesce = 15000; /* 15 us */
70+
71+ r8152_led_configuration(tp);
72 }
73
74 static int rtl8152_pre_reset(struct usb_interface *intf)