Message ID | trinity-da86cb70-f227-403a-be94-6e6a3fd0a0ca-1726082854312@3c-app-gmx-bs04 (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: tn40xx: add support for AQR105 based cards (was: net: phy: aquantia: emable firmware loading for aqr105) | expand |
On Wed, Sep 11, 2024 at 09:27:34PM +0200, Hans-Frieder Vogt wrote: > For loading of a firmware file over the filesystem, and > if the system is non-device-tree, try finding firmware-name from the software > node (or: fwnode) of the mdio device. This software node may have been > provided by the MAC or MDIO driver. > > Signed-off-by: Hans-Frieder Vogt <hfdevel@gmx.net> > --- > drivers/net/phy/aquantia/aquantia_firmware.c | 25 +++++++++++++++++++- > 1 file changed, 24 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/phy/aquantia/aquantia_firmware.c b/drivers/net/phy/aquantia/aquantia_firmware.c > index 090fcc9a3413..f6154f815d72 100644 > --- a/drivers/net/phy/aquantia/aquantia_firmware.c > +++ b/drivers/net/phy/aquantia/aquantia_firmware.c > @@ -324,14 +324,37 @@ static int aqr_firmware_load_nvmem(struct phy_device *phydev) > static int aqr_firmware_load_fs(struct phy_device *phydev) > { > struct device *dev = &phydev->mdio.dev; > + struct fwnode_handle *fw_node; > const struct firmware *fw; > const char *fw_name; > + u32 phy_id; > int ret; > > ret = of_property_read_string(dev->of_node, "firmware-name", > &fw_name); Did you try just replacing this with: ret = device_property_read_string(dev, "firmware-name", &fw_name); As far as i understand, the device_property_ functions will look around in OF, ACPI and swnode to find the given property. As long as the MAC driver puts the property in the right place, i _think_ this will just work. Andrew
On 11.09.2024 22.58, Andrew Lunn wrote: > On Wed, Sep 11, 2024 at 09:27:34PM +0200, Hans-Frieder Vogt wrote: >> For loading of a firmware file over the filesystem, and >> if the system is non-device-tree, try finding firmware-name from the software >> node (or: fwnode) of the mdio device. This software node may have been >> provided by the MAC or MDIO driver. >> >> Signed-off-by: Hans-Frieder Vogt <hfdevel@gmx.net> >> --- >> drivers/net/phy/aquantia/aquantia_firmware.c | 25 +++++++++++++++++++- >> 1 file changed, 24 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/phy/aquantia/aquantia_firmware.c b/drivers/net/phy/aquantia/aquantia_firmware.c >> index 090fcc9a3413..f6154f815d72 100644 >> --- a/drivers/net/phy/aquantia/aquantia_firmware.c >> +++ b/drivers/net/phy/aquantia/aquantia_firmware.c >> @@ -324,14 +324,37 @@ static int aqr_firmware_load_nvmem(struct phy_device *phydev) >> static int aqr_firmware_load_fs(struct phy_device *phydev) >> { >> struct device *dev = &phydev->mdio.dev; >> + struct fwnode_handle *fw_node; >> const struct firmware *fw; >> const char *fw_name; >> + u32 phy_id; >> int ret; >> >> ret = of_property_read_string(dev->of_node, "firmware-name", >> &fw_name); > Did you try just replacing this with: > > ret = device_property_read_string(dev, "firmware-name", &fw_name); > > As far as i understand, the device_property_ functions will look > around in OF, ACPI and swnode to find the given property. As long as > the MAC driver puts the property in the right place, i _think_ this > will just work. > > Andrew device_property_read_string() would would be very elegant, but it only looks for properties in the swnode of this device. However, I did not find a way to add a swnode directly to the phy, but only to the mdiobus. I could have added the firmware-name directly to the swnode of the mdiobus of course, then ret = device_property_read_string(dev->parent, "firmware-name", &fw_name); would have succeeded. But adding a "firmware-name" property to an mdiobus seemed not sensible to me. Did I maybe overlook a clever way to directly add a swnode to the phy_device? I'll certainly investigate this another time. Thanks! Hans
> device_property_read_string() would would be very elegant, but it only > looks for properties in the swnode of this device. > However, I did not find a way to add a swnode directly to the phy, but > only to the mdiobus. Think about the DT representation, taken from marvell,aquantia.yaml. mdio { #address-cells = <1>; #size-cells = <0>; ethernet-phy@0 { compatible = "ethernet-phy-id31c3.1c12", "ethernet-phy-ieee802.3-c45"; reg = <0>; firmware-name = "AQR-G4_v5.4.C-AQR_CIG_WF-1945_0x8_ID44776_VER1630.cld"; }; ethernet-phy@1 { compatible = "ethernet-phy-id31c3.1c12", "ethernet-phy-ieee802.3-c45"; reg = <1>; nvmem-cells = <&aqr_fw>; nvmem-cell-names = "firmware"; }; }; You want to construct the same. Do you know the address on the bus the PHY uses? Can you create a ethernet-phy@X node? And then put the property there? Then there is the question of if the current code associates the swnode to the PHY device. I've no idea if it does! If not, it might mean we need to add a device_set_node(&mdiodev->dev, fwnode) somewhere in the core code. Andrew
diff --git a/drivers/net/phy/aquantia/aquantia_firmware.c b/drivers/net/phy/aquantia/aquantia_firmware.c index 090fcc9a3413..f6154f815d72 100644 --- a/drivers/net/phy/aquantia/aquantia_firmware.c +++ b/drivers/net/phy/aquantia/aquantia_firmware.c @@ -324,14 +324,37 @@ static int aqr_firmware_load_nvmem(struct phy_device *phydev) static int aqr_firmware_load_fs(struct phy_device *phydev) { struct device *dev = &phydev->mdio.dev; + struct fwnode_handle *fw_node; const struct firmware *fw; const char *fw_name; + u32 phy_id; int ret; ret = of_property_read_string(dev->of_node, "firmware-name", &fw_name); - if (ret) + /* check if there is an fwnode connected to mdio */ + if (ret && dev->parent->fwnode) { + fw_node = fwnode_get_phy_node(dev->parent->fwnode); + if (fw_node) { + ret = fwnode_get_phy_id(fw_node, &phy_id); + if (ret) + goto cleanup_fwnode; + phy_id &= phydev->drv->phy_id_mask; + if (phy_id != (phydev->drv->phy_id & + phydev->drv->phy_id_mask)) + goto cleanup_fwnode; + + ret = fwnode_property_read_string(fw_node, + "firmware-name", + &fw_name); + } +cleanup_fwnode: + fwnode_handle_put(fw_node); + } + if (ret) { + phydev_err(phydev, "failed to read firmware name: %d\n", ret); return ret; + } ret = request_firmware(&fw, fw_name, dev); if (ret) {
For loading of a firmware file over the filesystem, and if the system is non-device-tree, try finding firmware-name from the software node (or: fwnode) of the mdio device. This software node may have been provided by the MAC or MDIO driver. Signed-off-by: Hans-Frieder Vogt <hfdevel@gmx.net> --- drivers/net/phy/aquantia/aquantia_firmware.c | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) -- 2.45.2