<p>Wisley Chen has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/21839">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">[TEST]drivers/net/r8168: Add customized nic led function<br><br>The nic led behavior can be customized by different LED pin configuration.<br>Applied the patch, we can add RTL8168_CUSTOMIZED_LED two bytes hex value by<br>different board to cutomize led behavior. Refer to spec, bit[3:0] is for PINLED0,<br>bit[7:4] is for PINLED1, bit[11:8] is for PINLED2, and bit[15:12] is for feature<br>control.<br><br>TEST= add RTL8168_CUSTOMIZED_LED in mainboard/fizz/Kconfig, build/boot on fizz,<br>and check nic led behavior change.<br><br>Change-Id: I9d2a5ad15dd7160afedb316493481490183222f9<br>Signed-off-by: Wisley Chen <wisley.chen@quantatw.com><br>---<br>M src/drivers/net/r8168.c<br>1 file changed, 30 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/39/21839/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/drivers/net/r8168.c b/src/drivers/net/r8168.c<br>index 3727ccd..acbb4d3 100644<br>--- a/src/drivers/net/r8168.c<br>+++ b/src/drivers/net/r8168.c<br>@@ -40,6 +40,7 @@<br> #define CFG_9346            0x50<br> #define  CFG_9346_LOCK           0x00<br> #define  CFG_9346_UNLOCK 0xc0<br>+#define CFG_LED                  0x18<br> <br> /**<br>  * search: Find first instance of string in a given region<br>@@ -211,6 +212,32 @@<br>      printk(BIOS_DEBUG, "done\n");<br> }<br> <br>+/**<br>+ * The customizable LED operation is via IO register offset 0x18~0x19<br>+ * Bit[3:0]: LED Select for PINLED0<br>+ * Bit[7:4]: LED Select for PINLED1<br>+ * Bit[11:8]: LED Select for PINLED2<br>+ * Bit[15:12]: LED Feature Control<br>+ */<br>+static void program_led(struct device *dev, u16 io_base)<br>+{<br>+#if defined(CONFIG_RTL8168_CUSTOMIZED_LED)<br>+       printk(BIOS_DEBUG, "r8168: Programming led...");<br>+<br>+        /* Disable register protection */<br>+    outb(CFG_9346_UNLOCK, io_base + CFG_9346);<br>+<br>+        /* Set LED Behavior */<br>+       printk(BIOS_INFO, "r8168 customized led value=0x%04x\n", CONFIG_RTL8168_CUSTOMIZED_LED);<br>+   outl(CONFIG_RTL8168_CUSTOMIZED_LED, io_base + CFG_LED);<br>+      inl(io_base + CFG_LED);<br>+<br>+   /* Lock config regs */<br>+       outb(CFG_9346_LOCK, io_base + CFG_9346);<br>+     printk(BIOS_DEBUG, "done\n");<br>+#endif<br>+}<br>+<br> static void r8168_init(struct device *dev)<br> {<br>      /* Get the resource of the NIC mmio */<br>@@ -223,9 +250,10 @@<br> <br>       /* Program MAC address based on CBFS "macaddress" containing<br>         * a string AA:BB:CC:DD:EE:FF */<br>-     if (io_base)<br>+ if (io_base) {<br>                program_mac_address(dev, io_base);<br>-   else<br>+         program_led(dev, io_base);<br>+   } else<br>                printk(BIOS_ERR, "r8168: Error cant find MMIO resource\n");<br> }<br> <br></pre><p>To view, visit <a href="https://review.coreboot.org/21839">change 21839</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/21839"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I9d2a5ad15dd7160afedb316493481490183222f9 </div>
<div style="display:none"> Gerrit-Change-Number: 21839 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Wisley Chen <wisley.chen@quantatw.com> </div>