From patchwork Tue Dec 17 21:07:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Frieder Vogt via B4 Relay X-Patchwork-Id: 13912497 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EECB1F9409 for ; Tue, 17 Dec 2024 21:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; cv=none; b=nTtrdUsYadA8sXMsbOA7CxWuYLKr8if0SdFAymYpICQn5VIkqUj8jwvufHMH+orJuxBmkpjYVj0M6/GuZMhk/+V6Z8x+as6ProGv9/T5uOY158f/JeClwteBIqpmrlkJkVwA4DYhtEW2SAjciFtm+5+63KYV8TKPQ4haVW4yWIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; c=relaxed/simple; bh=f5j//xxzj5NG7f1I5TsQwnahRvJvaAhnjd/z+1rYzzQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P6OWC1nL0G+zIbE+NK9B1NbDawGTaWE5jwSe+qEaOIOg3m+jKWfHTmBgSw6sotOmbt2/8SDQlejZHKVPQR/Ubwu2i6/nGlscNgBKeQ8GkgwLkeat46fH21sQlbUFG4lGmY06lKIlvnwhANt/+E8gj85pBluWH6ii/jsyYml8dxg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wm+JV0bO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Wm+JV0bO" Received: by smtp.kernel.org (Postfix) with ESMTPS id C7E8EC4CEDD; Tue, 17 Dec 2024 21:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734469658; bh=f5j//xxzj5NG7f1I5TsQwnahRvJvaAhnjd/z+1rYzzQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Wm+JV0bOrOEBxxknfltY9gUUcfQEz2/4m8OHHh2igtUAVyKms7rDzr4K1H5KcFnvO J9UeZcDeVJV0PZkPyYsCTgS00057bg4hxlZYXklYivocg/EyUJ8I+9gyE0g2tvZfoH otWSFfnZjdW+c1lhhLQAORSKBWPFEF6Ew+2QXqckzxovBzVAz2yzS4rozUd6oAUVZW mp43risqkZqSrAhL8yJB5T1OM0VTN4K3OlPG5gQEtr1IKBYDfXQsRRCAPap2M9L1Cs VZj0mIiigNTtQRTt0h+uRsqZ51wV8FKWsBvxVo3lnXhV9/ErL00Ve1c04GtzXYU2Fy /7T8W5tKWGWtA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B42C8E77187; Tue, 17 Dec 2024 21:07:38 +0000 (UTC) From: Hans-Frieder Vogt via B4 Relay Date: Tue, 17 Dec 2024 22:07:32 +0100 Subject: [PATCH net-next v3 1/7] net: phy: Add swnode support to mdiobus_scan Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-tn9510-v3a-v3-1-4d5ef6f686e0@gmx.net> References: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> In-Reply-To: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , FUJITA Tomonori , Andrew Lunn Cc: netdev@vger.kernel.org, Hans-Frieder Vogt X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734469657; l=1936; i=hfdevel@gmx.net; s=20240915; h=from:subject:message-id; bh=tjXgAqiIJ9J3+v8YrXDfNqVpQpUv8M+JKJWk7sw4eKE=; b=pUKEW6gWmJ6Jod+VW4X1UJ6wLO2Ci8B1REHU+c8axfptUcmIuoOWlmNmB8oHwzDOqePkYKFeJ DfnuyFH3QzuDRhiMt3eTOw+s80CrFFlWugkLCQ8AZIGZyJ4FwlPFsjI X-Developer-Key: i=hfdevel@gmx.net; a=ed25519; pk=s3DJ3DFe6BJDRAcnd7VGvvwPXcLgV8mrfbpt8B9coRc= X-Endpoint-Received: by B4 Relay for hfdevel@gmx.net/20240915 with auth_id=209 X-Original-From: Hans-Frieder Vogt Reply-To: hfdevel@gmx.net X-Patchwork-Delegate: kuba@kernel.org From: Hans-Frieder Vogt This patch will allow to use a swnode/fwnode defined for a phy_device. The MDIO bus (mii_bus) needs to contain nodes for the PHY devices, named "ethernet-phy@i", with i being the MDIO address (0 .. PHY_MAX_ADDR - 1). The fwnode is only attached to the phy_device if there isn't already an fwnode attached. fwnode_get_named_child_node will increase the usage counter of the fwnode. However, no new code is needed to decrease the counter again, since this is already implemented in the phy_device_release function. Signed-off-by: Hans-Frieder Vogt --- drivers/net/phy/mdio_bus.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 7e2f10182c0cf37bef4cea1820863f047b5cb466..ede596c1a69d1b2b986e9eef51c3beb4a5fbc805 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -551,6 +551,8 @@ static int mdiobus_create_device(struct mii_bus *bus, static struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr, bool c45) { struct phy_device *phydev = ERR_PTR(-ENODEV); + struct fwnode_handle *fwnode; + char node_name[16]; int err; phydev = get_phy_device(bus, addr, c45); @@ -562,6 +564,18 @@ static struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr, bool c45) */ of_mdiobus_link_mdiodev(bus, &phydev->mdio); + /* Search for a swnode for the phy in the swnode hierarchy of the bus. + * If there is no swnode for the phy provided, just ignore it. + */ + if (dev_fwnode(&bus->dev) && !dev_fwnode(&phydev->mdio.dev)) { + snprintf(node_name, sizeof(node_name), "ethernet-phy@%d", + addr); + fwnode = fwnode_get_named_child_node(dev_fwnode(&bus->dev), + node_name); + if (fwnode) + device_set_node(&phydev->mdio.dev, fwnode); + } + err = phy_device_register(phydev); if (err) { phy_device_free(phydev); From patchwork Tue Dec 17 21:07:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Frieder Vogt via B4 Relay X-Patchwork-Id: 13912499 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39C391FA14A for ; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; cv=none; b=Aoe2oUA6N4Gl77U/FkFtV2XnS8sMUqFZ8cI+yI5j59Ja/113TRYXe62jzsh3OZP7N0qKisKc9vXGM7NMTP60kJfXlZfC9tn+R469k3OIB3qsuA5zJM+38oV+t5NUiBfnx/hnryAzrR82h8CXPtPeIvbq1pCN/4Eo/0E5wW3Q+u8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; c=relaxed/simple; bh=cUcGPtCzFichnrOkpOruH+m9VGQDdpbUd4lkMhluDUA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=F/Hh4IOO33LJuCI2wxgNmU2IyCDSari/wMIDza7uYcajwvO8fDWBGyCTT3fRJvb1tbXKtPmTvFMhBvxTIrj85RPM5PzXtZDDDa9YOAd5vffUVa7XBMGgJoMVzEDzaBWzZ/FtjQbg1mFRNFbzJpsRPw7LVriSP2sguTxHrC0XQCk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uzS7Fot1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uzS7Fot1" Received: by smtp.kernel.org (Postfix) with ESMTPS id D3BE7C4CED7; Tue, 17 Dec 2024 21:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734469658; bh=cUcGPtCzFichnrOkpOruH+m9VGQDdpbUd4lkMhluDUA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=uzS7Fot1yiGPyssnn95RYe7JbkyRlpb0PDOpNPGqkU6qi9DobjwWvLfJOhDoNM6RC RNQvegweyGbEo+FkjygwHOtwkheurvr+iKB1/AMOw1OIrjdvYw+lnZStU+X9fjUMqY 5ah6vQXjuB6QAxo/Esg3Atz7M/IdeZPedk80CEu/8LU6ourM6DZdWkDlRAfQvymtjA P+13OD/h5HXq3BeI+Dg0vbJK9eBRvaPvQtAZbDCW3EOnPG4c63i2u516XHlGMR4oOy pJHJBQkgLrUdgq7WrkxVPIJlJq84Am9KzBr+89+ip3h+S/tFZ2DNh9TMpo54Xazthv gzCUVkEWkNlBQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5B91E77188; Tue, 17 Dec 2024 21:07:38 +0000 (UTC) From: Hans-Frieder Vogt via B4 Relay Date: Tue, 17 Dec 2024 22:07:33 +0100 Subject: [PATCH net-next v3 2/7] net: phy: aquantia: add probe function to aqr105 for firmware loading Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-tn9510-v3a-v3-2-4d5ef6f686e0@gmx.net> References: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> In-Reply-To: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , FUJITA Tomonori , Andrew Lunn Cc: netdev@vger.kernel.org, Hans-Frieder Vogt X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734469657; l=857; i=hfdevel@gmx.net; s=20240915; h=from:subject:message-id; bh=O5mlrVhtjAYbCCzI+ndsrKr3J5xvxej0+u1cLQwUG08=; b=NIUZiVfs8wwgDLkPxzZzdL/0qmz2uL9oWi6fZrjCH3Az8lkI41JKlfq4E/d+H0/1+sT/m1szY xV4e/tFK8w2DWm2z7N/SCVL+OQ9hDyFJdFWByGFZTctMxumzCEiysm4 X-Developer-Key: i=hfdevel@gmx.net; a=ed25519; pk=s3DJ3DFe6BJDRAcnd7VGvvwPXcLgV8mrfbpt8B9coRc= X-Endpoint-Received: by B4 Relay for hfdevel@gmx.net/20240915 with auth_id=209 X-Original-From: Hans-Frieder Vogt Reply-To: hfdevel@gmx.net X-Patchwork-Delegate: kuba@kernel.org From: Hans-Frieder Vogt Re-use the AQR107 probe function to load the firmware on the AQR105 (and to probe the HWMON). Signed-off-by: Hans-Frieder Vogt Reviewed-by: Andrew Lunn --- drivers/net/phy/aquantia/aquantia_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/phy/aquantia/aquantia_main.c b/drivers/net/phy/aquantia/aquantia_main.c index bb56a66d2a48fab35eac87f75ad030a3ca6d9ec0..81eeee29ba3e6fb11a476a5b51a8a8be061ca8c3 100644 --- a/drivers/net/phy/aquantia/aquantia_main.c +++ b/drivers/net/phy/aquantia/aquantia_main.c @@ -912,6 +912,7 @@ static struct phy_driver aqr_driver[] = { PHY_ID_MATCH_MODEL(PHY_ID_AQR105), .name = "Aquantia AQR105", .config_aneg = aqr_config_aneg, + .probe = aqr107_probe, .config_intr = aqr_config_intr, .handle_interrupt = aqr_handle_interrupt, .read_status = aqr_read_status, From patchwork Tue Dec 17 21:07:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Frieder Vogt via B4 Relay X-Patchwork-Id: 13912498 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39BDF1FA149 for ; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; cv=none; b=Tw7Xo8cXsV4Jhum3aj/yILFR/vDqc057LYq5IqcMMTAgja/WJYy9bvQmR2feBWQ95ZUXGsEJBwGg518CgwOzEIpfl/vv4116cp2yNhKvLDUbgk8764gStSsloY9C29AI6be7YVk56JjKUf8S0t9i9VslunbMPh5bXLe4GVNlqFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; c=relaxed/simple; bh=rRM9rqY105gwQ9Trpekhtf0qrz7Ez72hvagUjR58WZs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ag7XWneknV+7oh87v2l/lYZyhhMiiSfb/hxvuhEiWFdYQTsVta1Olq7bFCe8maaKjvUpt1kdTbfffUFQ8mp7swG0fC0YsygJPbtk/5hLdmzBcKeJo4JCBbPEhSiVijeknaTInVi3Az+60g0YIb3Ms8ZzYc4rSDhADvQ0TXFaFo0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=razbLG2o; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="razbLG2o" Received: by smtp.kernel.org (Postfix) with ESMTPS id E96C6C4CEE0; Tue, 17 Dec 2024 21:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734469659; bh=rRM9rqY105gwQ9Trpekhtf0qrz7Ez72hvagUjR58WZs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=razbLG2oqTILUSxuBdWNC4DFSB47QFpzq2ZqGD8dGgpaEvQX5vprkuGQzpUzaAL3y gAH7bHho96FmBlRyMCVE1tVv0BS1UFOLghtaPQew0hmi5Xrz7VMp+snG8RrmF1TPi5 UH2XpNUi+xBPiHDI8MtgrND8zZ2tuEfZsLEgd3AmFWtK7jdn36fRzUg2CJ+rjFuve0 ZIm8zL0vYQpE7emEI2B0+bsV/c8E2+8+HfkCRWnkeCULZS2IbTZt/Dn0xfQltVrWB8 IkCBoBzoDU2J4uLC+sRrUi1eeaYRB9SqIN94iLRG/+4ThKkrhAgAqtpxzloLuA406+ e1mti0L/kwgQA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF750E77184; Tue, 17 Dec 2024 21:07:38 +0000 (UTC) From: Hans-Frieder Vogt via B4 Relay Date: Tue, 17 Dec 2024 22:07:34 +0100 Subject: [PATCH net-next v3 3/7] net: phy: aquantia: search for firmware-name in fwnode Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-tn9510-v3a-v3-3-4d5ef6f686e0@gmx.net> References: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> In-Reply-To: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , FUJITA Tomonori , Andrew Lunn Cc: netdev@vger.kernel.org, Hans-Frieder Vogt X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734469657; l=1126; i=hfdevel@gmx.net; s=20240915; h=from:subject:message-id; bh=sG/QOhA4xYOILxJWUzC7JzkduHQAxfV+9Kfu79XgLf8=; b=RAEsfviHllTrrSMjRCk4d8V2+3Uj6IZ7twUyHWixDd9gJbuvAwYf5MYPGXL/M46f2efq/mZfl oayOmiOF7RwA1NqnaSst6+0n6DskvNPUkY92Cs9hbZUOI4HGYUiHJ0i X-Developer-Key: i=hfdevel@gmx.net; a=ed25519; pk=s3DJ3DFe6BJDRAcnd7VGvvwPXcLgV8mrfbpt8B9coRc= X-Endpoint-Received: by B4 Relay for hfdevel@gmx.net/20240915 with auth_id=209 X-Original-From: Hans-Frieder Vogt Reply-To: hfdevel@gmx.net X-Patchwork-Delegate: kuba@kernel.org From: Hans-Frieder Vogt Allow the firmware name of an Aquantia PHY alternatively be provided by the property "firmware-name" of a swnode. This software node may be provided by the MAC or MDIO driver. Signed-off-by: Hans-Frieder Vogt Reviewed-by: Andrew Lunn --- drivers/net/phy/aquantia/aquantia_firmware.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/aquantia/aquantia_firmware.c b/drivers/net/phy/aquantia/aquantia_firmware.c index dab3af80593f51ff6dc670dfb54ae358c2458c40..bbbcc9736b00e1cfa193f4398889a4c172ca27a4 100644 --- a/drivers/net/phy/aquantia/aquantia_firmware.c +++ b/drivers/net/phy/aquantia/aquantia_firmware.c @@ -328,10 +328,11 @@ static int aqr_firmware_load_fs(struct phy_device *phydev) const char *fw_name; int ret; - ret = of_property_read_string(dev->of_node, "firmware-name", - &fw_name); - if (ret) + ret = device_property_read_string(dev, "firmware-name", &fw_name); + if (ret) { + phydev_err(phydev, "failed to read firmware-name: %d\n", ret); return ret; + } ret = request_firmware(&fw, fw_name, dev); if (ret) { From patchwork Tue Dec 17 21:07:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Frieder Vogt via B4 Relay X-Patchwork-Id: 13912500 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 613361FA8E5 for ; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; cv=none; b=aoeualbj2UNshBH8OMdd+8GML5WlpTFxKTA6cDaCG3ghesveNMccFdXRIiLjkfuKBLi1bf+azA/wYcQl9Ps9ydUlRTEmtBy2BfhjfylkCoHtOj8T1BFSLNkKgy7lLf7eC96usR7h9Jlpn2Msf4lCszImhB4u5L7b2ZRj9XalfWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; c=relaxed/simple; bh=AcJSOyIBzMiESsPiZBPHRGeIdC9AC1Kg2n1SPRoVeYU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TEX9qTQ5xMv6yCiU4AoxZOAKsnUv9w+HNtf9yKDlSzabQPBNwsO0Im+6gD/0Ua3w+YFgyEJDQINl2vTfvqOvSIFYRg3PZPLsVlhg9BGCoYoqdY48JIHTLgMJoysTsqO8avl4qlRVutbb5b95exkLffQQ9yBj627/Ksb/LtUYGJs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZG2Rlv2I; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZG2Rlv2I" Received: by smtp.kernel.org (Postfix) with ESMTPS id 08BB4C4CEE3; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734469659; bh=AcJSOyIBzMiESsPiZBPHRGeIdC9AC1Kg2n1SPRoVeYU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ZG2Rlv2I+QLDD6U8TuG0AabcddPjdvtLXluZKg5xAZa79H/R9Yh75cvYWYzOAkMBb M7+StddYZvn/EMJxjyt6UWHwSnjf0JsW+sCO3t4YdT8HP3AUvsaa/iWvh8gmuTL5Eu f+3Oy0lEOe4jzMSRw/SfA4TmpGwQ4WzZEwh0sDq8PVqfYP2tGI20hputg9em5B10fx 98a3Dk+Qntf04qWAB4PCWNQcwKJqZbkAVlwIDYppazG9OQEN/8ZY+RLdM8PJxfMswf RbTEg5K58lkDtVL6m8GgokVeO4kvvSKQkZUNO5ZZw8xWbnJnz9OL7M1mGSuTwuIe+V L2nN7+7R1OEhg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3CA3E7717F; Tue, 17 Dec 2024 21:07:38 +0000 (UTC) From: Hans-Frieder Vogt via B4 Relay Date: Tue, 17 Dec 2024 22:07:35 +0100 Subject: [PATCH net-next v3 4/7] net: phy: aquantia: add essential functions to aqr105 driver Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-tn9510-v3a-v3-4-4d5ef6f686e0@gmx.net> References: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> In-Reply-To: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , FUJITA Tomonori , Andrew Lunn Cc: netdev@vger.kernel.org, Hans-Frieder Vogt X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734469657; l=8794; i=hfdevel@gmx.net; s=20240915; h=from:subject:message-id; bh=ctTiAl4wmGgoj/eQI0xNjdg5Ki78Oas1YQuhYekuf7U=; b=DtNmreKSV9fBZlNUyqr2E4il9DPJxSjz+A4HuIby6BVVZ7f+oTjVf0yJaYs0GP5yrVf71Nhgo dj3eoJMD9rvAiH0vanLbfvUYo3FfMGRZvO/fSzShloneBqrS04XLdNG X-Developer-Key: i=hfdevel@gmx.net; a=ed25519; pk=s3DJ3DFe6BJDRAcnd7VGvvwPXcLgV8mrfbpt8B9coRc= X-Endpoint-Received: by B4 Relay for hfdevel@gmx.net/20240915 with auth_id=209 X-Original-From: Hans-Frieder Vogt Reply-To: hfdevel@gmx.net X-Patchwork-Delegate: kuba@kernel.org From: Hans-Frieder Vogt This patch makes functions that were provided for aqr107 applicable to aqr105, or replaces generic functions with specific ones. Since the aqr105 was introduced before NBASE-T was defined (or 802.3bz), there are a number of vendor specific registers involved in the definition of the advertisement, in auto-negotiation and in the setting of the speed. The functions have been written following the downstream driver for TN4010 cards with AQR105 PHY. To avoid duplication of code, aqr_config_aneg was split in a common part and a specific part for aqr105 and other aqr PHYs. A similar approach has been chosen for the aqr107_read_status function. Here, the aqr generation (=1 for aqr105, and =2 for aqr107 and higher) is used to decide whether aqr107(and up) specific registers can be used. I know this is not particularly elegant, but it is doing the job. Signed-off-by: Hans-Frieder Vogt --- drivers/net/phy/aquantia/aquantia_main.c | 168 ++++++++++++++++++++++++++----- 1 file changed, 144 insertions(+), 24 deletions(-) diff --git a/drivers/net/phy/aquantia/aquantia_main.c b/drivers/net/phy/aquantia/aquantia_main.c index 81eeee29ba3e6fb11a476a5b51a8a8be061ca8c3..a112e3473e079822671535c313f3ae816fe186dd 100644 --- a/drivers/net/phy/aquantia/aquantia_main.c +++ b/drivers/net/phy/aquantia/aquantia_main.c @@ -33,6 +33,9 @@ #define PHY_ID_AQR115C 0x31c31c33 #define PHY_ID_AQR813 0x31c31cb2 +#define MDIO_AN_10GBT_CTRL_ADV_LTIM BIT(0) +#define ADVERTISE_XNP BIT(12) + #define MDIO_PHYXS_VEND_IF_STATUS 0xe812 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK GENMASK(7, 3) #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_KR 0 @@ -50,6 +53,7 @@ #define MDIO_AN_VEND_PROV_1000BASET_HALF BIT(14) #define MDIO_AN_VEND_PROV_5000BASET_FULL BIT(11) #define MDIO_AN_VEND_PROV_2500BASET_FULL BIT(10) +#define MDIO_AN_VEND_PROV_EXC_PHYID_INFO BIT(6) #define MDIO_AN_VEND_PROV_DOWNSHIFT_EN BIT(4) #define MDIO_AN_VEND_PROV_DOWNSHIFT_MASK GENMASK(3, 0) #define MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT 4 @@ -107,6 +111,30 @@ #define AQR107_OP_IN_PROG_SLEEP 1000 #define AQR107_OP_IN_PROG_TIMEOUT 100000 +static int aqr105_get_features(struct phy_device *phydev) +{ + int ret; + + /* Normal feature discovery */ + ret = genphy_c45_pma_read_abilities(phydev); + if (ret) + return ret; + + /* The AQR105 PHY misses to indicate the 2.5G and 5G modes, so add them + * here + */ + linkmode_set_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, + phydev->supported); + linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, + phydev->supported); + + /* The AQR105 PHY suppports both RJ45 and SFP+ interfaces */ + linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT, phydev->supported); + linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->supported); + + return 0; +} + static int aqr107_get_sset_count(struct phy_device *phydev) { return AQR107_SGMII_STAT_SZ; @@ -164,6 +192,59 @@ static void aqr107_get_stats(struct phy_device *phydev, } } +static int aqr105_config_speed(struct phy_device *phydev) +{ + int vend = MDIO_AN_VEND_PROV_EXC_PHYID_INFO; + int ctrl10 = MDIO_AN_10GBT_CTRL_ADV_LTIM; + int adv = ADVERTISE_CSMA; + int ret; + + /* Half duplex is not supported */ + if (phydev->duplex != DUPLEX_FULL) + return -EINVAL; + + switch (phydev->speed) { + case SPEED_100: + adv |= ADVERTISE_100FULL; + break; + case SPEED_1000: + adv |= ADVERTISE_NPAGE; + vend |= MDIO_AN_VEND_PROV_1000BASET_FULL; + break; + case SPEED_2500: + adv |= (ADVERTISE_NPAGE | ADVERTISE_XNP); + vend |= MDIO_AN_VEND_PROV_2500BASET_FULL; + break; + case SPEED_5000: + adv |= (ADVERTISE_NPAGE | ADVERTISE_XNP); + vend |= MDIO_AN_VEND_PROV_5000BASET_FULL; + break; + case SPEED_10000: + adv |= (ADVERTISE_NPAGE | ADVERTISE_XNP); + ctrl10 |= MDIO_AN_10GBT_CTRL_ADV10G; + break; + default: + return -EINVAL; + } + ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_ADVERTISE, adv); + if (ret < 0) + return ret; + ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_VEND_PROV, vend); + if (ret < 0) + return ret; + ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, ctrl10); + if (ret < 0) + return ret; + + /* set by vendor driver, but should be on by default */ + ret = phy_set_bits_mmd(phydev, MDIO_MMD_AN, MDIO_CTRL1, + MDIO_AN_CTRL1_XNP); + if (ret < 0) + return ret; + + return genphy_c45_an_disable_aneg(phydev); +} + static int aqr_set_mdix(struct phy_device *phydev, int mdix) { u16 val = 0; @@ -186,21 +267,11 @@ static int aqr_set_mdix(struct phy_device *phydev, int mdix) MDIO_AN_RESVD_VEND_PROV_MDIX_MASK, val); } -static int aqr_config_aneg(struct phy_device *phydev) +static int aqr_common_config_aneg(struct phy_device *phydev, bool changed) { - bool changed = false; u16 reg; int ret; - ret = aqr_set_mdix(phydev, phydev->mdix_ctrl); - if (ret < 0) - return ret; - if (ret > 0) - changed = true; - - if (phydev->autoneg == AUTONEG_DISABLE) - return genphy_c45_pma_setup_forced(phydev); - ret = genphy_c45_an_config_aneg(phydev); if (ret < 0) return ret; @@ -241,6 +312,40 @@ static int aqr_config_aneg(struct phy_device *phydev) return genphy_c45_check_and_restart_aneg(phydev, changed); } +static int aqr105_config_aneg(struct phy_device *phydev) +{ + bool changed = false; + int ret; + + ret = aqr_set_mdix(phydev, phydev->mdix_ctrl); + if (ret < 0) + return ret; + if (ret > 0) + changed = true; + + if (phydev->autoneg == AUTONEG_DISABLE) + return aqr105_config_speed(phydev); + + return aqr_common_config_aneg(phydev, changed); +} + +static int aqr_config_aneg(struct phy_device *phydev) +{ + bool changed = false; + int ret; + + ret = aqr_set_mdix(phydev, phydev->mdix_ctrl); + if (ret < 0) + return ret; + if (ret > 0) + changed = true; + + if (phydev->autoneg == AUTONEG_DISABLE) + return genphy_c45_pma_setup_forced(phydev); + + return aqr_common_config_aneg(phydev, changed); +} + static int aqr_config_intr(struct phy_device *phydev) { bool en = phydev->interrupts == PHY_INTERRUPT_ENABLED; @@ -333,7 +438,7 @@ static int aqr_read_status(struct phy_device *phydev) return genphy_c45_read_status(phydev); } -static int aqr107_read_rate(struct phy_device *phydev) +static int aqr_common_read_rate(struct phy_device *phydev, int aqr_gen) { u32 config_reg; int val; @@ -377,20 +482,22 @@ static int aqr107_read_rate(struct phy_device *phydev) return 0; } - val = phy_read_mmd(phydev, MDIO_MMD_VEND1, config_reg); - if (val < 0) - return val; + if (aqr_gen > 1) { + val = phy_read_mmd(phydev, MDIO_MMD_VEND1, config_reg); + if (val < 0) + return val; - if (FIELD_GET(VEND1_GLOBAL_CFG_RATE_ADAPT, val) == - VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE) - phydev->rate_matching = RATE_MATCH_PAUSE; - else - phydev->rate_matching = RATE_MATCH_NONE; + if (FIELD_GET(VEND1_GLOBAL_CFG_RATE_ADAPT, val) == + VEND1_GLOBAL_CFG_RATE_ADAPT_PAUSE) + phydev->rate_matching = RATE_MATCH_PAUSE; + else + phydev->rate_matching = RATE_MATCH_NONE; + } return 0; } -static int aqr107_read_status(struct phy_device *phydev) +static int aqr_common_read_status(struct phy_device *phydev, int aqr_gen) { int val, ret; @@ -415,6 +522,7 @@ static int aqr107_read_status(struct phy_device *phydev) if (ret && ret != -ETIMEDOUT) return ret; + phydev->rate_matching = RATE_MATCH_NONE; switch (FIELD_GET(MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK, val)) { case MDIO_PHYXS_VEND_IF_STATUS_TYPE_KR: phydev->interface = PHY_INTERFACE_MODE_10GKR; @@ -448,7 +556,17 @@ static int aqr107_read_status(struct phy_device *phydev) } /* Read possibly downshifted rate from vendor register */ - return aqr107_read_rate(phydev); + return aqr_common_read_rate(phydev, aqr_gen); +} + +static int aqr105_read_status(struct phy_device *phydev) +{ + return aqr_common_read_status(phydev, 1); +} + +static int aqr107_read_status(struct phy_device *phydev) +{ + return aqr_common_read_status(phydev, 2); } static int aqr107_get_downshift(struct phy_device *phydev, u8 *data) @@ -911,11 +1029,13 @@ static struct phy_driver aqr_driver[] = { { PHY_ID_MATCH_MODEL(PHY_ID_AQR105), .name = "Aquantia AQR105", - .config_aneg = aqr_config_aneg, + .get_features = aqr105_get_features, .probe = aqr107_probe, + .config_init = aqr107_config_init, + .config_aneg = aqr105_config_aneg, .config_intr = aqr_config_intr, .handle_interrupt = aqr_handle_interrupt, - .read_status = aqr_read_status, + .read_status = aqr105_read_status, .suspend = aqr107_suspend, .resume = aqr107_resume, }, From patchwork Tue Dec 17 21:07:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Frieder Vogt via B4 Relay X-Patchwork-Id: 13912502 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BFD81FA8ED for ; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; cv=none; b=T6jaL+Y/0AG9HzNvIoBtOYE/n+unzzo4HL3IB+JW5tXXmP0miyKhcLj8AeHP9X9upd6+c4reOOIzOovu9Lg50DbBxFOFcD3ZD2BfMO7MzO31aPfGqi+kOISc9OE3TQjt0IU5623fXQeoWO4xQC7btGGcyNp/Hk1CD0HGWiVwes4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; c=relaxed/simple; bh=42JKCHWtedKZlqoaUUebXcvrkGtOYC5SOgvvlMD/lEE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fMB2Xx8fJ6BsQ0Op3J/V1Oi8/+Ef7bMbu4nZ3QsrbUb/SPm+78D1Ewifk5ahQZr10QuHnAalcWEouWlYD3lUOdAagOz0QIb9CsuisD1QwZzsYfelBKNXfiGly3vyKvhRmJF847GjKNf/4bnpHE8Fy+3wNB7x6S5ekSIY0otUOI4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZWPFSSi2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZWPFSSi2" Received: by smtp.kernel.org (Postfix) with ESMTPS id 18E94C4CEE4; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734469659; bh=42JKCHWtedKZlqoaUUebXcvrkGtOYC5SOgvvlMD/lEE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ZWPFSSi2gHJcShkOJk5Bs8DpYWRUqPZcDb/JxymDwHlUH6P3cHbT/tH033qh5d89Z rm7KgHRY7lBfYV/Cj/Omav3S6DNJl84RdOzrFJIyAutSf8FJUNCFlMp4XB6grEA/hf pl1HqRNoQySf4Zuw0OU6PtsbqUf9ahZCTfKJmDnkYZWkww9H5JXxHTv04TB4XNxtuZ wsPv5r+tcNrEPVMmvAg2Ea/Iboe8TagfooRtX7zJxf0mnqQv44PPXu+GsBARD1iApc FgdxXGKELVmlpDq7BZXsu+QPl6ggvfyB9Dxf3MYEJOs74SoVRLCwZp5MCDk3uTq/GS eXueLYC9zIH/A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FFE1E77187; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) From: Hans-Frieder Vogt via B4 Relay Date: Tue, 17 Dec 2024 22:07:36 +0100 Subject: [PATCH net-next v3 5/7] net: tn40xx: create software node for mdio and phy and add to mdiobus Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-tn9510-v3a-v3-5-4d5ef6f686e0@gmx.net> References: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> In-Reply-To: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , FUJITA Tomonori , Andrew Lunn Cc: netdev@vger.kernel.org, Hans-Frieder Vogt X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734469657; l=6540; i=hfdevel@gmx.net; s=20240915; h=from:subject:message-id; bh=4/i6FVXGucUwDy2wgJmhDqtqKtov9plpSkkW58Fze9g=; b=qn3exb0jZcNvSWhlvYozCRMmqJVVvh+BNFccMYoK8MeOuRuwWQiqdTxC/ejAE45BB36zGlaJI KiDqynHhR8IAS5xZfl+6yGU54+u3tR1UuZZxQG/AFaQtMcY9Gb1qTVh X-Developer-Key: i=hfdevel@gmx.net; a=ed25519; pk=s3DJ3DFe6BJDRAcnd7VGvvwPXcLgV8mrfbpt8B9coRc= X-Endpoint-Received: by B4 Relay for hfdevel@gmx.net/20240915 with auth_id=209 X-Original-From: Hans-Frieder Vogt Reply-To: hfdevel@gmx.net X-Patchwork-Delegate: kuba@kernel.org From: Hans-Frieder Vogt Create a software node for the mdio function, with a child node for the Aquantia AQR105 PHY, providing a firmware-name (and a bit more, which may be used for future checks) to allow the PHY to load a MAC specific firmware from the file system. The name of the PHY software node follows the naming convention suggested in the patch for the mdiobus_scan function (in the same patch series). Signed-off-by: Hans-Frieder Vogt --- drivers/net/ethernet/tehuti/tn40.c | 10 ++++- drivers/net/ethernet/tehuti/tn40.h | 30 +++++++++++++++ drivers/net/ethernet/tehuti/tn40_mdio.c | 65 ++++++++++++++++++++++++++++++++- 3 files changed, 103 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/tehuti/tn40.c b/drivers/net/ethernet/tehuti/tn40.c index 259bdac24cf211113b8f80934feb093d61e46f2d..5f73eb1f7d9f74294cd5546c2ef4797ebc24c052 100644 --- a/drivers/net/ethernet/tehuti/tn40.c +++ b/drivers/net/ethernet/tehuti/tn40.c @@ -1778,7 +1778,7 @@ static int tn40_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ret = tn40_phy_register(priv); if (ret) { dev_err(&pdev->dev, "failed to set up PHY.\n"); - goto err_free_irq; + goto err_unregister_swnodes; } ret = tn40_priv_init(priv); @@ -1795,6 +1795,10 @@ static int tn40_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return 0; err_unregister_phydev: tn40_phy_unregister(priv); +err_unregister_swnodes: + fwnode_handle_put(dev_fwnode(&priv->mdio->dev)); + device_remove_software_node(&priv->mdio->dev); + software_node_unregister_node_group(priv->nodes.group); err_free_irq: pci_free_irq_vectors(pdev); err_unset_drvdata: @@ -1816,6 +1820,10 @@ static void tn40_remove(struct pci_dev *pdev) unregister_netdev(ndev); tn40_phy_unregister(priv); + /* cleanup software nodes */ + fwnode_handle_put(dev_fwnode(&priv->mdio->dev)); + device_remove_software_node(&priv->mdio->dev); + software_node_unregister_node_group(priv->nodes.group); pci_free_irq_vectors(priv->pdev); pci_set_drvdata(pdev, NULL); iounmap(priv->regs); diff --git a/drivers/net/ethernet/tehuti/tn40.h b/drivers/net/ethernet/tehuti/tn40.h index 490781fe512053d0d2cf0d6e819fc11d078a6733..e083f34f29849186a5ea68ed710a96ba9def116e 100644 --- a/drivers/net/ethernet/tehuti/tn40.h +++ b/drivers/net/ethernet/tehuti/tn40.h @@ -4,6 +4,7 @@ #ifndef _TN40_H_ #define _TN40_H_ +#include #include "tn40_regs.h" #define TN40_DRV_NAME "tn40xx" @@ -102,10 +103,39 @@ struct tn40_txdb { int size; /* Number of elements in the db */ }; +#define NODE_PROP(_NAME, _PROP) ( \ + (const struct software_node) { \ + .name = _NAME, \ + .properties = _PROP, \ + }) + +#define NODE_PAR_PROP(_NAME, _PAR, _PROP) ( \ + (const struct software_node) { \ + .name = _NAME, \ + .parent = _PAR, \ + .properties = _PROP, \ + }) + +enum tn40_swnodes { + SWNODE_MDIO, + SWNODE_PHY, + SWNODE_MAX +}; + +struct tn40_nodes { + char phy_name[32]; + char mdio_name[32]; + struct property_entry phy_props[3]; + struct software_node swnodes[SWNODE_MAX]; + const struct software_node *group[SWNODE_MAX + 1]; +}; + struct tn40_priv { struct net_device *ndev; struct pci_dev *pdev; + struct tn40_nodes nodes; + struct napi_struct napi; /* RX FIFOs: 1 for data (full) descs, and 2 for free descs */ struct tn40_rxd_fifo rxd_fifo0; diff --git a/drivers/net/ethernet/tehuti/tn40_mdio.c b/drivers/net/ethernet/tehuti/tn40_mdio.c index af18615d64a8a290c7f79e56260b9aacf82c0386..b8ee553f60d1beadeda828584adfea670f0d4ca8 100644 --- a/drivers/net/ethernet/tehuti/tn40_mdio.c +++ b/drivers/net/ethernet/tehuti/tn40_mdio.c @@ -14,6 +14,8 @@ (FIELD_PREP(TN40_MDIO_PRTAD_MASK, (port)))) #define TN40_MDIO_CMD_READ BIT(15) +#define AQR105_FIRMWARE "tehuti/aqr105-tn40xx.cld" + static void tn40_mdio_set_speed(struct tn40_priv *priv, u32 speed) { void __iomem *regs = priv->regs; @@ -111,6 +113,46 @@ static int tn40_mdio_write_c45(struct mii_bus *mii_bus, int addr, int devnum, return tn40_mdio_write(mii_bus->priv, addr, devnum, regnum, val); } +/* registers an mdio node and an aqr105 PHY at address 1 + * tn40_mdio-%id { + * ethernet-phy@1 { + * compatible = "ethernet-phy-id03a1.b4a3"; + * reg = <1>; + * firmware-name = AQR105_FIRMWARE; + * }; + * }; + */ +static int tn40_swnodes_register(struct tn40_priv *priv) +{ + struct tn40_nodes *nodes = &priv->nodes; + struct pci_dev *pdev = priv->pdev; + struct software_node *swnodes; + u32 id; + + id = pci_dev_id(pdev); + + snprintf(nodes->phy_name, sizeof(nodes->phy_name), "ethernet-phy@1"); + snprintf(nodes->mdio_name, sizeof(nodes->mdio_name), "tn40_mdio-%x", + id); + + swnodes = nodes->swnodes; + + swnodes[SWNODE_MDIO] = NODE_PROP(nodes->mdio_name, NULL); + + nodes->phy_props[0] = PROPERTY_ENTRY_STRING("compatible", + "ethernet-phy-id03a1.b4a3"); + nodes->phy_props[1] = PROPERTY_ENTRY_U32("reg", 1); + nodes->phy_props[2] = PROPERTY_ENTRY_STRING("firmware-name", + AQR105_FIRMWARE); + swnodes[SWNODE_PHY] = NODE_PAR_PROP(nodes->phy_name, + &swnodes[SWNODE_MDIO], + nodes->phy_props); + + nodes->group[SWNODE_PHY] = &swnodes[SWNODE_PHY]; + nodes->group[SWNODE_MDIO] = &swnodes[SWNODE_MDIO]; + return software_node_register_node_group(nodes->group); +} + int tn40_mdiobus_init(struct tn40_priv *priv) { struct pci_dev *pdev = priv->pdev; @@ -130,13 +172,34 @@ int tn40_mdiobus_init(struct tn40_priv *priv) bus->read_c45 = tn40_mdio_read_c45; bus->write_c45 = tn40_mdio_write_c45; + ret = tn40_swnodes_register(priv); + if (ret) { + pr_err("swnodes failed\n"); + return ret; + } + + ret = device_add_software_node(&bus->dev, + priv->nodes.group[SWNODE_MDIO]); + if (ret) { + dev_err(&pdev->dev, "device_add_software_node failed: %d\n", + ret); + } + ret = devm_mdiobus_register(&pdev->dev, bus); if (ret) { dev_err(&pdev->dev, "failed to register mdiobus %d %u %u\n", ret, bus->state, MDIOBUS_UNREGISTERED); - return ret; + goto err_swnodes_unregister; } tn40_mdio_set_speed(priv, TN40_MDIO_SPEED_6MHZ); priv->mdio = bus; return 0; + +err_swnodes_unregister: + fwnode_handle_put(dev_fwnode(&bus->dev)); + device_remove_software_node(&bus->dev); + software_node_unregister_node_group(priv->nodes.group); + return ret; } + +MODULE_FIRMWARE(AQR105_FIRMWARE); From patchwork Tue Dec 17 21:07:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Frieder Vogt via B4 Relay X-Patchwork-Id: 13912503 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BF581FA8EC for ; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; cv=none; b=cuy9ovqZTrcFqtgjsrQQaabwEjfOaU7NFxy+uHPVRu2wZZoMxsZOYTjw9vSiYnoEmWy0SutldCqIQmeSUmC4RkQ9duSfjo2uD23qSyNBTSdZCvynm6j8pzVkIulFJpYHTyCOt2E9CmyYNLTQbjB9xGmJs9WhlrfKT7p3ghU7i7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; c=relaxed/simple; bh=ARm3wZdsJFE1EXnn6XMmXs+6j95IcoRF/BPmTCJB7yE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FrWUa3TJVFN0GUraVD1uCeseAbW2lmumMg+FkGhvr5PI58x5GuBzgmVUp/rNkMXF47zEp8GY91EBLGtkOABCG0S9BJNus7nIH/r6X4J4YDVqDhgykiUq9gUNtmIMZztnY0yLPBOLRuMwXgg5x3NiaxnvxgZK56So9+lyi/1AlMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tQHgsnCt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tQHgsnCt" Received: by smtp.kernel.org (Postfix) with ESMTPS id 304BAC4CEE6; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734469659; bh=ARm3wZdsJFE1EXnn6XMmXs+6j95IcoRF/BPmTCJB7yE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=tQHgsnCtFytSA/MqL+C4MNL4ICP6j9A9UzaQ3svO7QzxB1KeXb7/ydfK/mo7A109W B4w0GCkeHVkmHx3S9/hrpyEZBUvsxqVtN0UI6UWTn1PxrNODEgOPf3QF4EVHDIUu1C UfjC96zQtsQGtQqkKS5HFuZmCB6pmHjGatkeJ/cdDnM9pbW/5Cx79bqczFPhxYcIwF VcGU/74jmibiNtnxBFnq3ShenlNvoKk/Anz2oIwVoRfHlO6c8mjWxI5TSi2z7FV9Np KKTp2fKjEl9t+Owpgl28a6xQ3vUXjqHMiQ7kc2l+vyccYzn/p8VRJok6A6vG79wyG3 Khr7PcumqeHgw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 261DCE77184; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) From: Hans-Frieder Vogt via B4 Relay Date: Tue, 17 Dec 2024 22:07:37 +0100 Subject: [PATCH net-next v3 6/7] net: tn40xx: prepare tn40xx driver to find phy of the TN9510 card Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-tn9510-v3a-v3-6-4d5ef6f686e0@gmx.net> References: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> In-Reply-To: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , FUJITA Tomonori , Andrew Lunn Cc: netdev@vger.kernel.org, Hans-Frieder Vogt X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734469657; l=1416; i=hfdevel@gmx.net; s=20240915; h=from:subject:message-id; bh=rESsj+vd7KGKfozt3aHW3N4Wnw4DdcDrscsB4sUdilI=; b=xf0hdxtZyuXoEfg78h7+uWKrxqCrXtjcIE1fYmrVWHkjXeNAkCbLsnoun5jW49gku5zbj3SOZ zfwcEafc4TrDdBF7T5PN34qqNyG7DfiqjHoV47qzdAQrYELwyLXnZow X-Developer-Key: i=hfdevel@gmx.net; a=ed25519; pk=s3DJ3DFe6BJDRAcnd7VGvvwPXcLgV8mrfbpt8B9coRc= X-Endpoint-Received: by B4 Relay for hfdevel@gmx.net/20240915 with auth_id=209 X-Original-From: Hans-Frieder Vogt Reply-To: hfdevel@gmx.net X-Patchwork-Delegate: kuba@kernel.org From: Hans-Frieder Vogt Prepare the tn40xx driver to load for Tehuti TN9510 cards, which require bit 3 in the register TN40_REG_MDIO_CMD_STAT to be set. The function of bit 3 is unclear, but may have something to do with the length of the preamble in the MDIO communication. If bit 3 is not set, the PHY will not be found when performing a scan for PHYs. Use the available tn40_mdio_set_speed function which includes setting bit 3. Just move the function to before the devm_mdio_register function, which scans the mdio bus for PHYs. Signed-off-by: Hans-Frieder Vogt Reviewed-by: Andrew Lunn Reviewed-by: FUJITA Tomonori --- drivers/net/ethernet/tehuti/tn40_mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/tehuti/tn40_mdio.c b/drivers/net/ethernet/tehuti/tn40_mdio.c index b8ee553f60d1beadeda828584adfea670f0d4ca8..993458cc49322de3466c604385dca64d4c3b949f 100644 --- a/drivers/net/ethernet/tehuti/tn40_mdio.c +++ b/drivers/net/ethernet/tehuti/tn40_mdio.c @@ -185,13 +185,13 @@ int tn40_mdiobus_init(struct tn40_priv *priv) ret); } + tn40_mdio_set_speed(priv, TN40_MDIO_SPEED_6MHZ); ret = devm_mdiobus_register(&pdev->dev, bus); if (ret) { dev_err(&pdev->dev, "failed to register mdiobus %d %u %u\n", ret, bus->state, MDIOBUS_UNREGISTERED); goto err_swnodes_unregister; } - tn40_mdio_set_speed(priv, TN40_MDIO_SPEED_6MHZ); priv->mdio = bus; return 0; From patchwork Tue Dec 17 21:07:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Frieder Vogt via B4 Relay X-Patchwork-Id: 13912501 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FD7E1FA8E6 for ; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; cv=none; b=B6A4bNmnoqlGfDjOoBu9GtE41/k2xFPGjX1wac5zejiIeH/Zu0yoXLyxOh+THT41J2bS9waQP5+El19cIjZiVSwXyjOjLpIE9OZvhO6ONQ8DrgTHzau4cQyvlqD4a9nFPry2p8KQYYQmJlQiVF4AkU7o0dTPS/quOpl3iTuuHrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734469659; c=relaxed/simple; bh=MGrxxfG18O/UOrjPuFWbMeYHAZMncy1WnK1iYAlTJL0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PhRHxI2JyNSZg+3JEhX+BcW6iAy24HCsxTdMJniaA/ofLFt/7FdkOi6tvvZdMcJPcftSJ1cRlKd1Jw7hQ2+7OiEVWxBkEgIAmBrMk91yCQ4nheIVjIBLfgvJgtuvxJlylxD2QFU0agFpYDci1oDopBT11dddJJ/Cy/ZKWSZS/nI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q2XHY6Ya; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q2XHY6Ya" Received: by smtp.kernel.org (Postfix) with ESMTPS id 45FD9C4CEDE; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734469659; bh=MGrxxfG18O/UOrjPuFWbMeYHAZMncy1WnK1iYAlTJL0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Q2XHY6Ya0IJhxTrIPKDx3wHM7Y16JfjWcVwtL0cQ/nmgBq9VhD/QdvhrazdsPYWG8 lAm+AwkEtA52LX9itDo5QEHf8KsjM5KAwQep5IvVe8G4r+aqLzpT7ifX95NIxeexFB 2kP+Sk8Xq/X+PYsZiOa3xKkTzk3mRIBZjxhKgIIu5FqeQl98hSXL9tOK1UNwcLAlLz fqZhTPlHU7wsQVI10a1tMJV9HkOlUx3RNRjvqZafnTSSCK1oqQtFhxU219dg6l74Es W4k7hsgJgVtP5S1KkkCflMFDTaNIWOLBRJeWEA1lMHbCicLVT7RCdPxIEMBlv+gmKT 3PnG9j2WTYevA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B08BE77187; Tue, 17 Dec 2024 21:07:39 +0000 (UTC) From: Hans-Frieder Vogt via B4 Relay Date: Tue, 17 Dec 2024 22:07:38 +0100 Subject: [PATCH net-next v3 7/7] net: tn40xx: add pci-id of the aqr105-based Tehuti TN4010 cards Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-tn9510-v3a-v3-7-4d5ef6f686e0@gmx.net> References: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> In-Reply-To: <20241217-tn9510-v3a-v3-0-4d5ef6f686e0@gmx.net> To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , FUJITA Tomonori , Andrew Lunn Cc: netdev@vger.kernel.org, Hans-Frieder Vogt X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734469657; l=1228; i=hfdevel@gmx.net; s=20240915; h=from:subject:message-id; bh=aJL2+Qt1fXp1c8Nkhc4Qvp7fWnaLIrf+lqxUzAEbh+w=; b=ykcDIxI1JWhHGDCGeBp/uszL6eStVzeak/U/tdYGxkuh67ZfBvP/SyieLLLsMWqxADcAkyS0O PUm2L9mpc+QDbt4EIfovsq189psHzM9/jnw8yM7fdegdfICNc9Lr0I3 X-Developer-Key: i=hfdevel@gmx.net; a=ed25519; pk=s3DJ3DFe6BJDRAcnd7VGvvwPXcLgV8mrfbpt8B9coRc= X-Endpoint-Received: by B4 Relay for hfdevel@gmx.net/20240915 with auth_id=209 X-Original-From: Hans-Frieder Vogt Reply-To: hfdevel@gmx.net X-Patchwork-Delegate: kuba@kernel.org From: Hans-Frieder Vogt Add the PCI-ID of the AQR105-based Tehuti TN4010 cards to allow loading of the tn40xx driver on these cards. Here, I chose the detailed definition with the subvendor ID similar to the QT2025 cards with the PCI-ID TEHUTI:0x4022, because there is a card with an AQ2104 hiding amongst the AQR105 cards, and they all come with the same PCI-ID (TEHUTI:0x4025). But the AQ2104 is currently not supported. Signed-off-by: Hans-Frieder Vogt Reviewed-by: Andrew Lunn Reviewed-by: FUJITA Tomonori --- drivers/net/ethernet/tehuti/tn40.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/tehuti/tn40.c b/drivers/net/ethernet/tehuti/tn40.c index 5f73eb1f7d9f74294cd5546c2ef4797ebc24c052..2f4e0dad388f84d6daf651d67ef99c6f62244586 100644 --- a/drivers/net/ethernet/tehuti/tn40.c +++ b/drivers/net/ethernet/tehuti/tn40.c @@ -1840,6 +1840,10 @@ static const struct pci_device_id tn40_id_table[] = { PCI_VENDOR_ID_ASUSTEK, 0x8709) }, { PCI_DEVICE_SUB(PCI_VENDOR_ID_TEHUTI, 0x4022, PCI_VENDOR_ID_EDIMAX, 0x8103) }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_TEHUTI, 0x4025, + PCI_VENDOR_ID_TEHUTI, 0x3015) }, + { PCI_DEVICE_SUB(PCI_VENDOR_ID_TEHUTI, 0x4025, + PCI_VENDOR_ID_EDIMAX, 0x8102) }, { } };