From patchwork Tue Nov 14 10:55:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13455141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1486AC4332F for ; Tue, 14 Nov 2023 10:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/ydsA/J38ZPbaqPV0XEAHBIH5XMrttNKUQ/y5fh2gh0=; b=uOhg+wRmNuqnuj Ropg6jvZDwCJUyQb5EN5YuP8YBwGeGaOEQoDrWTS8I7Y9F59cp63qvzgSD8MqA6s7u2SNJGejBMul f2Rti1e2MhitHK2OseSb4Mxx5q9Rpj6HacwnOdjYh1m0tKTEP7wIWKxTLqBFaAh7MuDpeuc6WS9ao 986D9lPROo13mxeMiEJzOPqyvc4+nK3lDVi3UwEu8U7n4oAjcNH7pbR2aUhsmO+yhcllt8uGnn/UI umSbQ+uAsds8TsDfZKae4B4iLKp+hV9GaOfAbuvuzHmqYRb+CfDVMUa0Aewvn5S1FGSTlMXVAWCYz TQIjv5bYoK8UoOn2Dg3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r2r5T-00Fc2l-2v; Tue, 14 Nov 2023 10:56:07 +0000 Received: from relay7-d.mail.gandi.net ([2001:4b98:dc4:8::227]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r2r5N-00Fbyu-1B for linux-arm-kernel@lists.infradead.org; Tue, 14 Nov 2023 10:56:02 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id D1CF52000B; Tue, 14 Nov 2023 10:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699959359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=illYHKSC+nzt4aAs1/2/0DTKL0P6DwlH/jpdzwxEP8M=; b=bVQLczHJb/uzAp9+bYQMFCtVmlA1XJsrpxj9gf8GhkNvbq6oJvR2zZE0Jy7IYuDqUzHnBo GWmTzTYwqkogzKiI6mWRZKYjMz5IxeyLtBPbPgXBm4VqFT2J4Lg8cEfMuRi7/qz5aA5AC/ XwfeG8+lwQrblTNIvpJv9iSWcwD/x+qzQP2f1dI9FJoZty1/YrPW5A1jsIUVWCcSbQ+0Ej q3c258MVyOu0L6K1bKO3bENfvvlAarQMu6WRVZn3YuCQkKcZJYtm3JOTXr8ZaguLi3JAJk V3YCXo8jFpmZXUYuLFq3QV12f7+fScTSH7uAxr9WxcSDFBA2IC1H33WRQpxUlA== From: Romain Gantois To: davem@davemloft.net, Rob Herring , Krzysztof Kozlowski Cc: Romain Gantois , Jakub Kicinski , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , linux-arm-kernel@lists.infradead.org, Vladimir Oltean , Luka Perkov , Robert Marko , Andy Gross , Bjorn Andersson , Konrad Dybcio Subject: [PATCH net-next v3 6/8] net: phy: add calibration callbacks to phy_driver Date: Tue, 14 Nov 2023 11:55:56 +0100 Message-ID: <20231114105600.1012056-7-romain.gantois@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114105600.1012056-1-romain.gantois@bootlin.com> References: <20231114105600.1012056-1-romain.gantois@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231114_025601_693739_9B7C4221 X-CRM114-Status: GOOD ( 11.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The IPQESS integrated Ethernet switch found in the IPQ4019 SoC requires calibration of the PHY link when its ports are brought up. This calibration procedure requires knowledge of precise timings and vendor-specific registers on both the PHY and MAC side. The existing PHY abstraction layer does not allow coordinating this kind of calibration operation between MAC drivers and PHY drivers. As a consequence, PHY-specific calibration information has to be included in Ethernet drivers, since it has to schedule the entire calibration procedure on it's own. Add two callbacks that extend the PHY abstraction layer to allow MAC drivers to start and stop PHY calibration runs in a PHY-model-independent manner. Signed-off-by: Romain Gantois --- include/linux/phy.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index 3cc52826f18e..b1092b2ecee3 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1142,6 +1142,13 @@ struct phy_driver { int (*led_hw_control_get)(struct phy_device *dev, u8 index, unsigned long *rules); + /* @calibration_start: Start calibrating the MAC-to-PHY link. */ + int (*calibration_start)(struct phy_device *dev); + + /* @calibration_start: Finalize MAC-to-PHY link calibration + * and run tests. Returns 0 if the calibration tests are successful. + */ + int (*calibration_stop)(struct phy_device *dev); }; #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv) @@ -1770,6 +1777,27 @@ int phy_start_cable_test_tdr(struct phy_device *phydev, } #endif +static inline +int phy_start_calibration(struct phy_device *phydev) +{ + if (!(phydev->drv && + phydev->drv->calibration_start && + phydev->drv->calibration_stop)) + return -EOPNOTSUPP; + + return phydev->drv->calibration_start(phydev); +} + +static inline +int phy_stop_calibration(struct phy_device *phydev) +{ + if (!(phydev->drv && + phydev->drv->calibration_stop)) + return -EOPNOTSUPP; + + return phydev->drv->calibration_stop(phydev); +} + static inline void phy_device_reset(struct phy_device *phydev, int value) { mdio_device_reset(&phydev->mdio, value);