summaryrefslogtreecommitdiffstats
path: root/resources/libreboot/patch/coreboot/2a6f251f4d8d41d13051ec2c897aea800c07275a/grub/ga-g41m-es2l/004-add-driver-to-reset-nic.patch
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libreboot/patch/coreboot/2a6f251f4d8d41d13051ec2c897aea800c07275a/grub/ga-g41m-es2l/004-add-driver-to-reset-nic.patch')
-rw-r--r--resources/libreboot/patch/coreboot/2a6f251f4d8d41d13051ec2c897aea800c07275a/grub/ga-g41m-es2l/004-add-driver-to-reset-nic.patch89
1 files changed, 71 insertions, 18 deletions
diff --git a/resources/libreboot/patch/coreboot/2a6f251f4d8d41d13051ec2c897aea800c07275a/grub/ga-g41m-es2l/004-add-driver-to-reset-nic.patch b/resources/libreboot/patch/coreboot/2a6f251f4d8d41d13051ec2c897aea800c07275a/grub/ga-g41m-es2l/004-add-driver-to-reset-nic.patch
index 279d2f2..7d1d1c5 100644
--- a/resources/libreboot/patch/coreboot/2a6f251f4d8d41d13051ec2c897aea800c07275a/grub/ga-g41m-es2l/004-add-driver-to-reset-nic.patch
+++ b/resources/libreboot/patch/coreboot/2a6f251f4d8d41d13051ec2c897aea800c07275a/grub/ga-g41m-es2l/004-add-driver-to-reset-nic.patch
@@ -1,7 +1,12 @@
-From 5e99bbbf3140b198b2c4b68e646e7042f76806e3 Mon Sep 17 00:00:00 2001
+From 8f90ec9634e7eb0a385902fe2d74af4ebc33c7c2 Mon Sep 17 00:00:00 2001
From: Damien Zammit <damien@zamaudio.com>
Date: Sat, 21 May 2016 02:24:19 +1000
-Subject: [PATCH] drivers/net/r8168: Add driver for 10ec:8168 to reset the NIC
+Subject: [PATCH] drivers/net/r8168: Add driver for realtek nic
+
+One thing that is vital to this patch is the MAC address setting
+in case the EEPROM/efuse is unconfigured.
+Linux now recognises the default MAC address on GA-G41M-ES2L which
+does rely on the default bios settings for the MAC address.
Change-Id: I32e070b545b4c6369686a7087b7ff838d00764e3
Signed-off-by: Damien Zammit <damien@zamaudio.com>
@@ -28,41 +33,89 @@ index 9b3008d..e435d48 100644
+ramstage-$(CONFIG_REALTEK_8168_RESET) += r8168.c
diff --git a/src/drivers/net/r8168.c b/src/drivers/net/r8168.c
new file mode 100644
-index 0000000..be5a7b8
+index 0000000..4301693
--- /dev/null
+++ b/src/drivers/net/r8168.c
-@@ -0,0 +1,46 @@
+@@ -0,0 +1,94 @@
+/*
-+ * Copyright (C) 2015 Damien Zammit <damien@zamaudio.com>
++ * This file is part of the coreboot project.
++ *
++ * Copyright (C) 2016 Damien Zammit <damien@zamaudio.com>
+ *
-+ * This driver simply forces the 10ec:8168 device to reset so that it goes
-+ * into a proper power state.
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; version 2 of the License.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ */
++
++/*
++ * This driver forces the 10ec:8168 device to reset so that it goes
++ * into a proper power state, also programs a default MAC address
++ * so that if the EEPROM/efuse is unconfigured it still has a default MAC.
+ */
+
+#include <arch/io.h>
+#include <device/device.h>
+#include <device/pci.h>
-+#include <device/pci_ids.h>
+#include <device/pci_ops.h>
-+#include <stdlib.h>
-+#include <string.h>
++#include <device/pci_def.h>
++#include <delay.h>
++#include <console/console.h>
++
++#define NIC_TIMEOUT 1000
+
-+#define CMD_REG 0x37
++#define CMD_REG 0x37
++#define CMD_REG_RESET 0x10
++
++#define CFG_9346 0x50
++#define CFG_9346_LOCK 0x00
++#define CFG_9346_UNLOCK 0xc0
+
+static void r8168_init(struct device *dev)
+{
-+ u32 cnt = 0;
++ u32 i;
++ const u8 mac[6] = { 0x00, 0xe0, 0x4c, 0x00, 0xc0, 0xb0 };
+
+ /* Get the resource of the NIC mmio */
+ struct resource *nic_res = find_resource(dev, PCI_BASE_ADDRESS_0);
-+ u32 nic_mmio = (u32)res2mmio(nic_res, 0, 0);
++ u16 nic_port = (u16)nic_res->base;
++
++ /* Set bus master */
++ pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER
++ | PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
++
++ /* Reset NIC */
++ printk(BIOS_DEBUG, "r8168: Resetting NIC...");
++ outb(CMD_REG_RESET, nic_port + CMD_REG);
++
++ i = 0;
++ /* Poll for reset, with 1s timeout */
++ while (i < NIC_TIMEOUT && (inb(nic_port + CMD_REG) & CMD_REG_RESET)) {
++ udelay(1000);
++ if (++i >= NIC_TIMEOUT)
++ printk(BIOS_DEBUG, "timeout waiting for nic to reset\n");
++ }
++ if (i < NIC_TIMEOUT)
++ printk(BIOS_DEBUG, "done\n");
++
++ /* Unlock config regs */
++ outb(CFG_9346_UNLOCK, nic_port + CFG_9346);
++
++ /* Set MAC address 00:e0:4c:00:c0:b0
++ * NB: only 4-byte write accesses allowed
++ */
++ outl(mac[4] | mac[5] << 8, nic_port + 4);
++ inl(nic_port + 4);
+
-+ /* Reset */
-+ outb(0x10, nic_mmio + CMD_REG);
++ outl(mac[0] | mac[1] << 8 | mac[2] << 16 | mac[3] << 24, nic_port);
++ inl(nic_port);
+
-+ /* Poll for reset, with timeout */
-+ while (cnt < 1000 && (inb(nic_mmio + CMD_REG) & 0x10))
-+ cnt++;
++ /* Lock config regs */
++ outb(CFG_9346_LOCK, nic_port + CFG_9346);
+}
+
+static struct device_operations r8168_ops = {