53b6413cf34f68acdcf758d8dc33ecb71ae528cd
[openwrt/openwrt.git] / target / linux / rockchip / patches-5.4 / 002-net-usb-r8152-add-LED-configuration-from-OF.patch
1 From 82985725e071f2a5735052f18e109a32aeac3a0b Mon Sep 17 00:00:00 2001
2 From: David Bauer <mail@david-bauer.net>
3 Date: Sun, 26 Jul 2020 02:38:31 +0200
4 Subject: [PATCH] net: usb: r8152: add LED configuration from OF
5
6 This adds the ability to configure the LED configuration register using
7 OF. This way, the correct value for board specific LED configuration can
8 be determined.
9
10 Signed-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 @@ -4363,6 +4364,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 @@ -4404,6 +4421,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 @@ -4533,6 +4552,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 @@ -4609,6 +4630,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)