Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174376983
D60068.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D60068.diff
View Options
Index: sys/dev/dpaa2/dpaa2_mc_acpi.c
===================================================================
--- sys/dev/dpaa2/dpaa2_mc_acpi.c
+++ sys/dev/dpaa2/dpaa2_mc_acpi.c
@@ -67,6 +67,7 @@
char phy_conn_type[64];
char phy_mode[64];
ACPI_HANDLE phy_channel;
+ ACPI_HANDLE sfp;
};
static int
@@ -117,14 +118,18 @@
sizeof(sc->phy_mode), DEVICE_PROP_ANY);
s = device_get_property(dev, "phy-handle", &sc->phy_channel,
sizeof(sc->phy_channel), DEVICE_PROP_HANDLE);
+ s = device_get_property(dev, "sfp", &sc->sfp, sizeof(sc->sfp),
+ DEVICE_PROP_HANDLE);
if (bootverbose)
device_printf(dev, "UID %#04x reg %#04jx managed '%s' "
- "phy-connection-type '%s' phy-mode '%s' phy-handle '%s'\n",
+ "phy-connection-type '%s' phy-mode '%s' phy-handle '%s' "
+ "sfp '%s'\n",
sc->uid, sc->reg, sc->managed[0] != '\0' ? sc->managed : "",
sc->phy_conn_type[0] != '\0' ? sc->phy_conn_type : "",
sc->phy_mode[0] != '\0' ? sc->phy_mode : "",
- sc->phy_channel != NULL ? acpi_name(sc->phy_channel) : "");
+ sc->phy_channel != NULL ? acpi_name(sc->phy_channel) : "",
+ sc->sfp != NULL ? acpi_name(sc->sfp) : "");
return (0);
}
@@ -159,6 +164,27 @@
return (acpi_get_device(sc->phy_channel));
}
+/*
+ * Resolve the "sff,sfp" device for this DPMAC from the "sfp" reference parsed
+ * at attach. acpi_iicbus(4) attached the transceiver to its namespace node
+ * when it enumerated it, so acpi_get_device() yields its device_t -- the same
+ * shape as the FDT path's OF_device_from_xref().
+ */
+static device_t
+dpaa2_mac_dev_get_sff_dev(device_t dev)
+{
+ struct dpaa2_mac_dev_softc *sc;
+
+ if (dev == NULL)
+ return (NULL);
+
+ sc = device_get_softc(dev);
+ if (sc->sfp == NULL)
+ return (NULL);
+
+ return (acpi_get_device(sc->sfp));
+}
+
static device_method_t dpaa2_mac_dev_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, dpaa2_mac_dev_probe),
@@ -327,6 +353,25 @@
return (0);
}
+static int
+dpaa2_mc_acpi_get_sff_dev(device_t dev, device_t *sff_dev, uint32_t id)
+{
+ device_t mdev, sffdev;
+
+ mdev = dpaa2_mc_acpi_find_dpaa2_mac_dev(dev, id);
+ if (mdev == NULL)
+ return (ENXIO);
+
+ sffdev = dpaa2_mac_dev_get_sff_dev(mdev);
+ if (sffdev == NULL)
+ return (ENXIO);
+
+ if (sff_dev != NULL)
+ *sff_dev = sffdev;
+
+ return (0);
+}
+
static ssize_t
dpaa2_mc_acpi_get_property(device_t dev, device_t child, const char *propname,
void *propvalue, size_t size, device_property_type_t type)
@@ -379,6 +424,7 @@
DEVMETHOD(dpaa2_mc_reserve_dev, dpaa2_mc_reserve_dev),
DEVMETHOD(dpaa2_mc_release_dev, dpaa2_mc_release_dev),
DEVMETHOD(dpaa2_mc_get_phy_dev, dpaa2_mc_acpi_get_phy_dev),
+ DEVMETHOD(dpaa2_mc_get_sff_dev, dpaa2_mc_acpi_get_sff_dev),
/* ACPI compar layer. */
DEVMETHOD(bus_read_ivar, dpaa2_mc_acpi_read_ivar),
Index: sys/dev/dpaa2/dpaa2_mc_fdt.c
===================================================================
--- sys/dev/dpaa2/dpaa2_mc_fdt.c
+++ sys/dev/dpaa2/dpaa2_mc_fdt.c
@@ -178,21 +178,33 @@
return (NULL);
sc = device_get_softc(dev);
- if (sc->phy_handle == 0 && sc->sfp == 0)
+ if (sc->phy_handle == 0)
return (NULL);
-#ifdef __not_yet__ /* No sff,sfp support yet. */
- if (sc->sfp != 0) {
- device_t xdev;
-
- xdev = OF_device_from_xref(OF_xref_from_node(sc->sfp));
- if (xdev != NULL)
- return (xdev);
- }
-#endif
return (OF_device_from_xref(OF_xref_from_node(sc->phy_handle)));
}
+/*
+ * Resolve the "sff,sfp" device for this DPMAC from the "sfp" phandle parsed at
+ * attach. The sff(4) driver (sfp_fdt) registers itself by the referenced node's
+ * xref, so a simple xref lookup yields its device_t. Returns NULL if the DPMAC
+ * has no SFP association or the sff device is not (yet) attached.
+ */
+static device_t
+dpaa2_mac_fdt_get_sff_dev(device_t dev)
+{
+ struct dpaa2_mac_fdt_softc *sc;
+
+ if (dev == NULL)
+ return (NULL);
+
+ sc = device_get_softc(dev);
+ if (sc->sfp == 0)
+ return (NULL);
+
+ return (OF_device_from_xref(OF_xref_from_node(sc->sfp)));
+}
+
static device_method_t dpaa2_mac_fdt_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, dpaa2_mac_dev_probe),
@@ -342,6 +354,25 @@
return (0);
}
+static int
+dpaa2_mc_fdt_get_sff_dev(device_t dev, device_t *sff_dev, uint32_t id)
+{
+ device_t mdev, sffdev;
+
+ mdev = dpaa2_mc_fdt_find_dpaa2_mac_dev(dev, id);
+ if (mdev == NULL)
+ return (ENXIO);
+
+ sffdev = dpaa2_mac_fdt_get_sff_dev(mdev);
+ if (sffdev == NULL)
+ return (ENXIO);
+
+ if (sff_dev != NULL)
+ *sff_dev = sffdev;
+
+ return (0);
+}
+
static const struct ofw_bus_devinfo *
dpaa2_mc_simplebus_get_devinfo(device_t bus, device_t child)
{
@@ -384,6 +415,7 @@
DEVMETHOD(dpaa2_mc_reserve_dev, dpaa2_mc_reserve_dev),
DEVMETHOD(dpaa2_mc_release_dev, dpaa2_mc_release_dev),
DEVMETHOD(dpaa2_mc_get_phy_dev, dpaa2_mc_fdt_get_phy_dev),
+ DEVMETHOD(dpaa2_mc_get_sff_dev, dpaa2_mc_fdt_get_sff_dev),
/* OFW/simplebus */
DEVMETHOD(ofw_bus_get_devinfo, dpaa2_mc_simplebus_get_devinfo),
Index: sys/dev/dpaa2/dpaa2_mc_if.m
===================================================================
--- sys/dev/dpaa2/dpaa2_mc_if.m
+++ sys/dev/dpaa2/dpaa2_mc_if.m
@@ -106,6 +106,15 @@
phy_dev, id));
return (ENXIO);
}
+
+ static int
+ bypass_get_sff_dev(device_t dev, device_t *sff_dev, uint32_t id)
+ {
+ if (device_get_parent(dev) != NULL)
+ return (DPAA2_MC_GET_SFF_DEV(device_get_parent(dev),
+ sff_dev, id));
+ return (ENXIO);
+ }
}
METHOD int manage_dev {
@@ -150,3 +159,22 @@
device_t *phy_dev;
uint32_t id;
} DEFAULT bypass_get_phy_dev;
+
+/**
+ * @brief Look up the "sff,sfp" device associated with a DPMAC.
+ *
+ * Resolved from the "sfp" reference in the DPMAC's firmware node: a phandle
+ * under FDT, a _DSD reference under ACPI. Either way the sff(4) transceiver
+ * device is looked up from it, so the caller does not learn which of the two
+ * described the hardware. Returns ENXIO when firmware names no transceiver
+ * for this DPMAC.
+ *
+ * dev - requesting device (walked up to the MC bus)
+ * sff_dev - the sff,sfp transceiver device (call SFF_READ_EEPROM() on it)
+ * id - DPMAC object id
+ */
+METHOD int get_sff_dev {
+ device_t dev;
+ device_t *sff_dev;
+ uint32_t id;
+} DEFAULT bypass_get_sff_dev;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 3, 7:13 PM (5 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40146261
Default Alt Text
D60068.diff (6 KB)
Attached To
Mode
D60068: dpaa2: resolve a DPMAC's SFP transceiver under ACPI too
Attached
Detach File
Event Timeline
Log In to Comment