[coreboot-gerrit] Change in coreboot[master]: [TEST]drivers/net/r8168: Add customized nic led function

Wisley Chen (Code Review) gerrit at coreboot.org
Mon Oct 2 07:12:15 CEST 2017


Wisley Chen has uploaded this change for review. ( https://review.coreboot.org/21839


Change subject: [TEST]drivers/net/r8168: Add customized nic led function
......................................................................

[TEST]drivers/net/r8168: Add customized nic led function

The nic led behavior can be customized by different LED pin configuration.
Applied the patch, we can add RTL8168_CUSTOMIZED_LED two bytes hex value by
different board to cutomize led behavior. Refer to spec, bit[3:0] is for PINLED0,
bit[7:4] is for PINLED1, bit[11:8] is for PINLED2, and bit[15:12] is for feature
control.

TEST= add RTL8168_CUSTOMIZED_LED in mainboard/fizz/Kconfig, build/boot on fizz,
and check nic led behavior change.

Change-Id: I9d2a5ad15dd7160afedb316493481490183222f9
Signed-off-by: Wisley Chen <wisley.chen at quantatw.com>
---
M src/drivers/net/r8168.c
1 file changed, 30 insertions(+), 2 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/39/21839/1

diff --git a/src/drivers/net/r8168.c b/src/drivers/net/r8168.c
index 3727ccd..acbb4d3 100644
--- a/src/drivers/net/r8168.c
+++ b/src/drivers/net/r8168.c
@@ -40,6 +40,7 @@
 #define CFG_9346		0x50
 #define  CFG_9346_LOCK		0x00
 #define  CFG_9346_UNLOCK	0xc0
+#define CFG_LED			0x18
 
 /**
  * search: Find first instance of string in a given region
@@ -211,6 +212,32 @@
 	printk(BIOS_DEBUG, "done\n");
 }
 
+/**
+ * The customizable LED operation is via IO register offset 0x18~0x19
+ * Bit[3:0]: LED Select for PINLED0
+ * Bit[7:4]: LED Select for PINLED1
+ * Bit[11:8]: LED Select for PINLED2
+ * Bit[15:12]: LED Feature Control
+ */
+static void program_led(struct device *dev, u16 io_base)
+{
+#if defined(CONFIG_RTL8168_CUSTOMIZED_LED)
+	printk(BIOS_DEBUG, "r8168: Programming led...");
+
+	/* Disable register protection */
+	outb(CFG_9346_UNLOCK, io_base + CFG_9346);
+
+	/* Set LED Behavior */
+	printk(BIOS_INFO, "r8168 customized led value=0x%04x\n", CONFIG_RTL8168_CUSTOMIZED_LED);
+	outl(CONFIG_RTL8168_CUSTOMIZED_LED, io_base + CFG_LED);
+	inl(io_base + CFG_LED);
+
+	/* Lock config regs */
+	outb(CFG_9346_LOCK, io_base + CFG_9346);
+	printk(BIOS_DEBUG, "done\n");
+#endif
+}
+
 static void r8168_init(struct device *dev)
 {
 	/* Get the resource of the NIC mmio */
@@ -223,9 +250,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);
-	else
+		program_led(dev, io_base);
+	} else
 		printk(BIOS_ERR, "r8168: Error cant find MMIO resource\n");
 }
 

-- 
To view, visit https://review.coreboot.org/21839
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d2a5ad15dd7160afedb316493481490183222f9
Gerrit-Change-Number: 21839
Gerrit-PatchSet: 1
Gerrit-Owner: Wisley Chen <wisley.chen at quantatw.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171002/7c6aadc0/attachment-0001.html>


More information about the coreboot-gerrit mailing list