From 2949df37aef8c7d18088eb15dce1a9412ab98df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 2 Nov 2007 18:09:02 +0000 Subject: [PATCH] The MII stuff did not work at all, this is at least an improvement for that; apparently, probing/attaching the MII bus should come later, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22806 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/libs/compat/freebsd_network/compat.c | 38 ++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/libs/compat/freebsd_network/compat.c b/src/libs/compat/freebsd_network/compat.c index 1770389c0e..2ccd58d70b 100644 --- a/src/libs/compat/freebsd_network/compat.c +++ b/src/libs/compat/freebsd_network/compat.c @@ -17,7 +17,7 @@ #include -#define DEBUG_PCI +//#define DEBUG_PCI #ifdef DEBUG_PCI # define TRACE_PCI(dev, format, args...) device_printf(dev, format , ##args) #else @@ -111,14 +111,14 @@ pci_enable_io(device_t dev, int space) int bit = 0; switch (space) { - case SYS_RES_IOPORT: - bit = PCI_command_io; - break; - case SYS_RES_MEMORY: - bit = PCI_command_memory; - break; - default: - return EINVAL; + case SYS_RES_IOPORT: + bit = PCI_command_io; + break; + case SYS_RES_MEMORY: + bit = PCI_command_memory; + break; + default: + return EINVAL; } pci_set_command_bit(dev, bit); @@ -352,6 +352,7 @@ device_add_child(device_t dev, const char *name, int order) if (child == NULL) return NULL; + snprintf(child->dev_name, sizeof(child->dev_name), "%s", name); child->parent = dev; list_add_item(&dev->children, child); @@ -370,10 +371,12 @@ __haiku_probe_miibus(device_t dev, driver_t *drivers[], int count) _resolve_method(drivers[i], "device_probe"); if (probe) { int result = probe(dev); - if (result >= 0) { + // the ukphy driver (fallback for unknown PHYs) return -100 here + if (result >= -100) { if (selected == NULL || result > selcost) { selected = drivers[i]; selcost = result; + device_printf(dev, "Found MII: %s\n", selected->name); } } } @@ -392,16 +395,21 @@ bus_generic_attach(device_t dev) if (child->driver == NULL) { if (dev->driver == &miibus_driver) { driver_t *driver = __haiku_select_miibus_driver(child); - if (driver) device_set_driver(child, driver); - } + else { + struct mii_attach_args *ma = device_get_ivars(child); - if (dev->driver == NULL) - panic("can't attach unknown driver"); + device_printf(dev, "No PHY module found (%x/%x)!\n", ma->mii_id1, + ma->mii_id2); + } + } + } else if (child->driver == &miibus_driver) { + child->methods.probe(child); } - child->methods.attach(child); + if (child->driver != NULL) + child->methods.attach(child); } }