drivers/net/r8168: Modify to support RTL8125 LEDs

The Realtek RTL8125 has four registers for four leds
and a feature config register.
We use led0 and led2 in brask, so modify ethernet driver.
Those registers' IO address are based on RTL8125 datasheet.

BUG=b:193750191
TEST=Modify overridetree.cb to verify LEDs' settings.

Signed-off-by: Rory Liu <rory.liu@quanta.corp-partner.google.com>
Change-Id: I4b05a859dc0a0d2b8d6b35d6491fc88f7077cb92
Reviewed-on: https://review.coreboot.org/c/coreboot/+/59531
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
This commit is contained in:
Rory Liu 2021-11-22 10:42:25 +08:00 committed by Felix Held
parent 4bf08cfbfe
commit 2b1e737289
2 changed files with 69 additions and 20 deletions

View File

@ -8,6 +8,11 @@
struct drivers_net_config { struct drivers_net_config {
uint16_t customized_leds; uint16_t customized_leds;
/* RTL8125 LED settings */
uint8_t led_feature;
uint16_t customized_led0;
uint16_t customized_led2;
unsigned int wake; /* Wake pin for ACPI _PRW */ unsigned int wake; /* Wake pin for ACPI _PRW */
/* Does the device have a power resource? */ /* Does the device have a power resource? */

View File

@ -29,6 +29,9 @@
#define CMD_REG 0x37 #define CMD_REG 0x37
#define CMD_REG_RESET 0x10 #define CMD_REG_RESET 0x10
#define CMD_LED0_LED1 0x18 #define CMD_LED0_LED1 0x18
#define CMD_LED_FEATURE 0x94
#define CMD_LEDSEL0 0x18
#define CMD_LEDSEL2 0x84
#define CFG_9346 0x50 #define CFG_9346 0x50
#define CFG_9346_LOCK 0x00 #define CFG_9346_LOCK 0x00
@ -249,6 +252,46 @@ static void r8168_set_customized_led(struct device *dev, u16 io_base)
if (!config) if (!config)
return; return;
if (dev->device == PCI_DEVICE_ID_REALTEK_8125) {
/* Set LED global Feature register */
outb(config->led_feature, io_base + CMD_LED_FEATURE);
printk(BIOS_DEBUG, "r8125: read back LED global feature setting as 0x%x\n",
inb(io_base + CMD_LED_FEATURE));
/*
* Refer to RTL8125 datasheet 5.Customizable LED Configuration
* Register Name IO Address
* LEDSEL0 0x18
* LEDSEL2 0x84
* LEDFEATURE 0x94
*
* LEDSEL Bit[] Description
* Bit0 Link10M
* Bit1 Link100M
* Bit3 Link1000M
* Bit5 Link2.5G
* Bit9 ACT
* Bit10 preboot enable
* Bit11 lp enable
* Bit12 active low/high
*
* LEDFEATURE Description
* Bit0 LED Table V1/V2
* Bit1~3 Reserved
* Bit4~5 LED Blinking Duty Cycle 12.5%/ 25%/ 50%/ 75%
* Bit6~7 LED Blinking Freq. 240ms/160ms/80ms/Link-Speed-Dependent
*/
/* Set customized LED0 register */
outw(config->customized_led0, io_base + CMD_LEDSEL0);
printk(BIOS_DEBUG, "r8125: read back LED0 setting as 0x%x\n",
inw(io_base + CMD_LEDSEL0));
/* Set customized LED2 register */
outw(config->customized_led2, io_base + CMD_LEDSEL2);
printk(BIOS_DEBUG, "r8125: read back LED2 setting as 0x%x\n",
inw(io_base + CMD_LEDSEL2));
} else {
/* Read the customized LED setting from devicetree */ /* Read the customized LED setting from devicetree */
printk(BIOS_DEBUG, "r8168: Customized LED 0x%x\n", config->customized_leds); printk(BIOS_DEBUG, "r8168: Customized LED 0x%x\n", config->customized_leds);
@ -272,6 +315,7 @@ static void r8168_set_customized_led(struct device *dev, u16 io_base)
printk(BIOS_DEBUG, "r8168: read back LED setting as 0x%x\n", printk(BIOS_DEBUG, "r8168: read back LED setting as 0x%x\n",
inw(io_base + CMD_LED0_LED1)); inw(io_base + CMD_LED0_LED1));
} }
}
static void r8168_init(struct device *dev) static void r8168_init(struct device *dev)
{ {