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,28 +252,69 @@ static void r8168_set_customized_led(struct device *dev, u16 io_base)
if (!config) if (!config)
return; return;
/* Read the customized LED setting from devicetree */ if (dev->device == PCI_DEVICE_ID_REALTEK_8125) {
printk(BIOS_DEBUG, "r8168: Customized LED 0x%x\n", config->customized_leds); /* 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 RTL8111H datasheet 7.2 Customizable LED Configuration * Refer to RTL8125 datasheet 5.Customizable LED Configuration
* Starting from offset 0x18 * Register Name IO Address
* Bit[15:12] LED Feature Control(FC) * LEDSEL0 0x18
* Bit[11:08] LED Select for PINLED2 * LEDSEL2 0x84
* Bit[07:04] LED Select for PINLED1 * LEDFEATURE 0x94
* Bit[03:00] LED Select for PINLED0 *
* * LEDSEL Bit[] Description
* Speed Link10M Link100M Link1000M ACT/Full * Bit0 Link10M
* LED0 Bit0 Bit1 Bit2 Bit3 * Bit1 Link100M
* LED1 Bit4 Bit5 Bit6 Bit7 * Bit3 Link1000M
* LED2 Bit8 Bit9 Bit10 Bit11 * Bit5 Link2.5G
* FC Bit12 Bit13 Bit14 Bit15 * 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 LED registers */ /* Set customized LED0 register */
outw(config->customized_leds, io_base + CMD_LED0_LED1); outw(config->customized_led0, io_base + CMD_LEDSEL0);
printk(BIOS_DEBUG, "r8168: read back LED setting as 0x%x\n", printk(BIOS_DEBUG, "r8125: read back LED0 setting as 0x%x\n",
inw(io_base + CMD_LED0_LED1)); 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 */
printk(BIOS_DEBUG, "r8168: Customized LED 0x%x\n", config->customized_leds);
/*
* Refer to RTL8111H datasheet 7.2 Customizable LED Configuration
* Starting from offset 0x18
* Bit[15:12] LED Feature Control(FC)
* Bit[11:08] LED Select for PINLED2
* Bit[07:04] LED Select for PINLED1
* Bit[03:00] LED Select for PINLED0
*
* Speed Link10M Link100M Link1000M ACT/Full
* LED0 Bit0 Bit1 Bit2 Bit3
* LED1 Bit4 Bit5 Bit6 Bit7
* LED2 Bit8 Bit9 Bit10 Bit11
* FC Bit12 Bit13 Bit14 Bit15
*/
/* Set customized LED registers */
outw(config->customized_leds, io_base + CMD_LED0_LED1);
printk(BIOS_DEBUG, "r8168: read back LED setting as 0x%x\n",
inw(io_base + CMD_LED0_LED1));
}
} }
static void r8168_init(struct device *dev) static void r8168_init(struct device *dev)