[coreboot-gerrit] Change in coreboot[master]: drivers/net/r8168: Add customized LED mode
Gaggery Tsai (Code Review)
gerrit at coreboot.org
Tue Oct 3 09:23:23 CEST 2017
Gaggery Tsai has uploaded this change for review. ( https://review.coreboot.org/21862
Change subject: drivers/net/r8168: Add customized LED mode
......................................................................
drivers/net/r8168: Add customized LED mode
This patch is to add a function for programming
cusotmized LEDs setting to Realtek 81xx family.
It reads RT8111H_CUSTOMIZED_LED_VALUE from target
board config file and programs the setting to
offset 0x18 and 0x19.
BUG=b:65437780
TEST=Add RT8111H_CUSOMIZED_LED_VALUE in Kconfig file
under target board and make sure the setting
is programmed correctly to offset 0x18 and
0x19. Observed the LEDs were behaving as
expected. Executed suspend/resume and the LEDs
were still working as expected.
Change-Id: Ib3d4f2cd98ac391e1661a891d604bdd1974d07f6
Signed-off-by: Gaggery Tsai <gaggery.tsai at intel.com>
---
M src/drivers/net/Kconfig
M src/drivers/net/r8168.c
2 files changed, 45 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/62/21862/1
diff --git a/src/drivers/net/Kconfig b/src/drivers/net/Kconfig
index 67a1389..61f1788 100644
--- a/src/drivers/net/Kconfig
+++ b/src/drivers/net/Kconfig
@@ -18,3 +18,8 @@
bool
default n
select REALTEK_8168_RESET
+
+config RT8111H_SET_LED_MODE
+ bool
+ default n
+ select REALTEK_8168_RESET
diff --git a/src/drivers/net/r8168.c b/src/drivers/net/r8168.c
index 3727ccd..a8a2500 100644
--- a/src/drivers/net/r8168.c
+++ b/src/drivers/net/r8168.c
@@ -36,6 +36,8 @@
#define CMD_REG 0x37
#define CMD_REG_RESET 0x10
+#define CMD_LED0_LED1 0x18
+#define CMD_LED2_FC 0x19
#define CFG_9346 0x50
#define CFG_9346_LOCK 0x00
@@ -211,6 +213,41 @@
printk(BIOS_DEBUG, "done\n");
}
+static void r8111h_set_customized_led(u16 io_base)
+{
+#if IS_ENABLED(CONFIG_RT8111H_SET_LED_MODE)
+ u16 setting = 0;
+
+ /* check the VPD for the mac address */
+ setting = CONFIG_RT8111H_CUSTOMIZED_LED_VALUE;
+ printk(BIOS_DEBUG, "r8111h: Customized LED 0x%x\n", setting);
+
+ /* Disable register protection */
+ outb(CFG_9346_UNLOCK, io_base + CFG_9346);
+
+ /* Refer to datasheet 7.2, 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(setting & 0xffff, io_base + CMD_LED0_LED1);
+ printk(BIOS_DEBUG, "r8111h: read back LED setting as 0x%x\n",
+ inw(io_base + CMD_LED0_LED1));
+
+ /* Lock config regs */
+ outb(CFG_9346_LOCK, io_base + CFG_9346);
+#endif
+}
+
static void r8168_init(struct device *dev)
{
/* Get the resource of the NIC mmio */
@@ -223,8 +260,10 @@
/* Program MAC address based on CBFS "macaddress" containing
* a string AA:BB:CC:DD:EE:FF */
- if (io_base)
+ if (io_base) {
program_mac_address(dev, io_base);
+ r8111h_set_customized_led(io_base);
+ }
else
printk(BIOS_ERR, "r8168: Error cant find MMIO resource\n");
}
--
To view, visit https://review.coreboot.org/21862
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib3d4f2cd98ac391e1661a891d604bdd1974d07f6
Gerrit-Change-Number: 21862
Gerrit-PatchSet: 1
Gerrit-Owner: Gaggery Tsai <gaggery.tsai at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171003/9b6303a6/attachment-0001.html>
More information about the coreboot-gerrit
mailing list