diff options
author | Rory Liu <rory.liu@quanta.corp-partner.google.com> | 2021-11-22 10:42:25 +0800 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2021-12-23 21:15:13 +0000 |
commit | 2b1e737289e617ece51a20d670cb1493176570d0 (patch) | |
tree | da544c66143fbd87a3a71e03d55431331ad61b6e /src/drivers/net | |
parent | 4bf08cfbfe5a07a69715f727d571fa7870640f2e (diff) |
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>
Diffstat (limited to 'src/drivers/net')
-rw-r--r-- | src/drivers/net/chip.h | 5 | ||||
-rw-r--r-- | src/drivers/net/r8168.c | 88 |
2 files changed, 71 insertions, 22 deletions
diff --git a/src/drivers/net/chip.h b/src/drivers/net/chip.h index 9b6a4e550b..a4ba8afc53 100644 --- a/src/drivers/net/chip.h +++ b/src/drivers/net/chip.h @@ -8,6 +8,11 @@ struct drivers_net_config { 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 */ /* Does the device have a power resource? */ diff --git a/src/drivers/net/r8168.c b/src/drivers/net/r8168.c index 5606859489..2299a99b02 100644 --- a/src/drivers/net/r8168.c +++ b/src/drivers/net/r8168.c @@ -29,6 +29,9 @@ #define CMD_REG 0x37 #define CMD_REG_RESET 0x10 #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_LOCK 0x00 @@ -249,28 +252,69 @@ static void r8168_set_customized_led(struct device *dev, u16 io_base) if (!config) return; - /* 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)); + 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 */ + 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) |