[OpenBIOS] [PATCH v3] drivers/pci: Recognise RTL8139 network card and enable bus mastering
BALATON Zoltan
balaton at eik.bme.hu
Thu Jun 26 00:31:58 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>
---
v2: Only enable bus master bit in PCI config on QEMU
v3: Replace comment saying why we enable bus master
---
openbios-devel/drivers/pci.c | 13 ++++++++++++-
openbios-devel/drivers/pci_database.c | 6 ++++++
openbios-devel/include/drivers/pci.h | 1 +
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c
index 1154426..3412e85 100644
--- a/openbios-devel/drivers/pci.c
+++ b/openbios-devel/drivers/pci.c
@@ -596,7 +596,18 @@ 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;
+#if defined(CONFIG_QEMU)
+ /* RTL8139 needs bus master bit set for MorphOS */
+ 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);
+ }
+#endif
set_property(ph, "network-type", "ethernet", 9);
set_property(ph, "removable", "network", 8);
set_property(ph, "category", "net", 4);
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