From 73b60d31a3318344428842c7368b2f1eb0c05596 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
Date: Sun, 11 Aug 2024 11:27:35 +0200
Subject: [PATCH 27/27] net: usb: r8152: add r8153b support for link/activity
 LEDs
Organization: Wires

This patch adds support for the link/activity LEDs on the NanoPi R2S
and OrangePi R1 Plus.

From the Rockchip kernel hosted by FriendlyARM/FriendlyELEC at
https://github.com/friendlyarm/kernel-rockchip/

Specifically commit be0b1939b271c307ab1fef5fb1478beaafc6de17

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
---
 drivers/net/usb/r8152.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 2cab046749a9..c9947ad320ff 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -41,6 +41,11 @@
 #define DRIVER_DESC "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters"
 #define MODULENAME "r8152"
 
+/* LED0: Activity, LED1: Link */
+static int ledsel = 0x78;
+module_param(ledsel, int, 0);
+MODULE_PARM_DESC(ledsel, "Override default LED configuration");
+
 #define R8152_PHY_ID		32
 
 #define PLA_IDR			0xc000
@@ -7307,6 +7312,9 @@ static void r8153b_init(struct r8152 *tp)
 	ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
 	ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
 
+	/* set customized led */
+	ocp_write_word(tp, MCU_TYPE_PLA, PLA_LEDSEL, ledsel);
+
 	rtl_tally_reset(tp);
 
 	tp->coalesce = 15000;	/* 15 us */
