[OpenBIOS] [PATCH] drivers/pci: Recognise RTL8139 network card and enable bus mastering

BALATON Zoltan balaton at eik.bme.hu
Tue Jun 3 01:34:00 CEST 2014


Apart from the older NE2000 card also recognise RTL8139 and set bus
master bit for it. This makes it work in MorphOS which uses it in a
different (DMA) mode than the Linux driver.

Signed-off-by: BALATON Zoltan <balaton at eik.bme.hu>
---
 openbios-devel/drivers/pci.c          | 11 +++++++++++
 openbios-devel/drivers/pci_database.c |  6 ++++++
 openbios-devel/include/drivers/pci.h  |  1 +
 3 files changed, 18 insertions(+)

diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c
index ca4de87..b3cce17 100644
--- a/openbios-devel/drivers/pci.c
+++ b/openbios-devel/drivers/pci.c
@@ -596,6 +596,17 @@ int ide_config_cb2 (const pci_config_t *config)
 int eth_config_cb (const pci_config_t *config)
 {
 	phandle_t ph = get_cur_dev();
+	pci_addr addr = 0x80000000u | config->dev;
+
+	/* Enable bus master bit for RTL8139 */
+	if (pci_config_read16(addr, PCI_VENDOR_ID) == PCI_VENDOR_ID_REALTEK &&
+	    pci_config_read16(addr, PCI_DEVICE_ID) == PCI_DEVICE_ID_REALTEK_RTL8139) {
+		uint16_t cmd;
+
+		cmd = pci_config_read16(addr, PCI_COMMAND);
+		cmd |= PCI_COMMAND_BUS_MASTER;
+		pci_config_write16(addr, PCI_COMMAND, cmd);
+	}
 
 	set_property(ph, "network-type", "ethernet", 9);
 	set_property(ph, "removable", "network", 8);
diff --git a/openbios-devel/drivers/pci_database.c b/openbios-devel/drivers/pci_database.c
index 3b670d3..4fb3530 100644
--- a/openbios-devel/drivers/pci_database.c
+++ b/openbios-devel/drivers/pci_database.c
@@ -129,6 +129,12 @@ static const pci_dev_t eth_devices[] = {
         NULL, "ethernet",
     },
     {
+        PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_RTL8139,
+        NULL, "RTL8139",   "RTL8139 PCI",  NULL,
+        0, 0, 0,
+        NULL, "ethernet",
+    },
+    {
         /* Virtio-network controller */
         PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_NET,
         NULL, "virtio-net", NULL,
diff --git a/openbios-devel/include/drivers/pci.h b/openbios-devel/include/drivers/pci.h
index 2eb5685..5772b79 100644
--- a/openbios-devel/include/drivers/pci.h
+++ b/openbios-devel/include/drivers/pci.h
@@ -202,6 +202,7 @@ extern const pci_arch_t *arch;
 
 #define PCI_VENDOR_ID_REALTEK            0x10ec
 #define PCI_DEVICE_ID_REALTEK_RTL8029    0x8029
+#define PCI_DEVICE_ID_REALTEK_RTL8139    0x8139
 
 #define PCI_VENDOR_ID_QEMU               0x1234
 #define PCI_DEVICE_ID_QEMU_VGA           0x1111
-- 
1.8.1.5




More information about the OpenBIOS mailing list