Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7465038pxb; Thu, 18 Feb 2021 10:42:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+svIbE66ugzpS1FS1C59onomZBhhFXvGg5TysuogBTdfQFvRYyn6MHggsjQ/45AYob5Mr X-Received: by 2002:a17:906:c2d2:: with SMTP id ch18mr5413465ejb.385.1613673769073; Thu, 18 Feb 2021 10:42:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613673769; cv=none; d=google.com; s=arc-20160816; b=xKO14lG6TWC2VdqWyUBM4kFPTEu6sHhBXAHlgIPR9UXFZMBilZ+qn5HM3kl0aLVpSP iuHH+q1WuLiMMHhzedRjKO35Y9Wz+frG9TbrH5pX20SvPa92M+KANhxDdemJq4sFx/UH ZEGH7L2Ek/STOpJms+8FWQ2ve93ZEuKVin5Q90pu5a5OwXkSi0R1Z1Sl1XlxdSYvyQlE 3sv8jKGjgpeHjImk4vX6GcQk9iq455CI8SPfWARz1sHK4iAjkDmfC9n5SIlgSuZTAA2Q gyyLsBsxm7NxSK+8OboOVWm7KIYlJdLyqqxcoho3x0Q6OdBtuQsFjhA9kMpUVs1/Tajn nChA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:dkim-signature; bh=B9AZQ9CWmwRN4ft9Q1KRZx4e6wWTXcIp+FEnFN68Xyg=; b=pAz9Lwlhjz89cCf9YVHlnPaCg9s6WUneTtEEE6v6WoYENjrNWld/TS3yf/NDWyrqAA yAzsWV2/QQP9WH2nhppuoMTTlKExuytPj3OJj7KnfBlEqs03vg3Hf6/TVowwSJG5S1AU q78INyHOv05JKlVFOq94qflnH8n0QWQhdwMdd2W2omNp7dzTu0JDUh95iG0fy+Epje8K OGHlxC3xZPUdrOWd/zLX9rYgcRO4+nqI+TP48ddiZMbLkgXmEfdFi+YtuKDtCzbUUes9 kYIYwcvPHzHInw+iYtrZAaWu59ROEaLQNNaH4SZsZAC0+hopmQksmgZbq42MGuyB0KAB U4UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=DgHVk1Ua; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e26si4626614edr.556.2021.02.18.10.42.23; Thu, 18 Feb 2021 10:42:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=DgHVk1Ua; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232924AbhBRSiZ (ORCPT + 99 others); Thu, 18 Feb 2021 13:38:25 -0500 Received: from esa.microchip.iphmx.com ([68.232.153.233]:54728 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233157AbhBRQQ3 (ORCPT ); Thu, 18 Feb 2021 11:16:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1613664987; x=1645200987; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1nnvswdMGV7YOXxPq8283T4a69ySRCQHedAu3sGiWWw=; b=DgHVk1Uan47Al9APYoY7JVfxpPIJfsEMtA5hbVZkq48Rz5mmJEEYZ1TT vBLhhQp4D/AFkC2rP1NCoSlFe89YLFygz1M6ZhkZ47/ljK5AB5UMixqQQ HEqE0OJDO3krl1fo0SolsN/zSK4w3RhrDofOgJqewBYZVvVL8t+nYOfZu CeYbgFujtlkp5IQhjtGh/R/8x+r8pdVxyysK6Mhi9JIKu7Ladcnp/mHxg clpFtX9jULkB3W0oCZbanidAzhOayjepEB95hlh6W2dUyA6gsLDEkfm8t a8/QDmOGi7l+P7TQ1oojWz+jMNA8OkOcl3Iy0X2D8Tqw97VN3lMBt67Bw Q==; IronPort-SDR: 9uOtFRu2J94JgqHfpqnq8NjimsOHE8GJxHDuJ2mZbda1u0BtOcJzfHblgkPp7YjzJ29MEMuHvR jNlzT0Ge8z7cKIPLPA99/5A2dTKs5DOWWcMHm8ESAhToAXqCQj5e567CVi1IWfk0zjX7wq22ya hKhEctCVjOweQwcb5tRhVLhdC7oozZX2kcYshDpkE+J2qyqlL+NDpM/MaVmt1507F160uHt6fA OlUobnlUnmNUfdEq44i2Wb+xphu2rDaY3pMaO1bGGHiLDbTYCLidT4E+BiD1KVuc5UdUPlisgP 3Ig= X-IronPort-AV: E=Sophos;i="5.81,187,1610434800"; d="scan'208";a="115692358" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 18 Feb 2021 09:15:04 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 18 Feb 2021 09:15:04 -0700 Received: from mchp-dev-shegelun.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Thu, 18 Feb 2021 09:15:02 -0700 From: Steen Hegelund To: Kishon Vijay Abraham I , Vinod Koul CC: Steen Hegelund , Alexandre Belloni , Lars Povlsen , Bjarni Jonasson , Microchip UNG Driver List , , , Andrew Lunn Subject: [PATCH v15 2/4] phy: Add media type and speed serdes configuration interfaces Date: Thu, 18 Feb 2021 17:14:49 +0100 Message-ID: <20210218161451.3489955-3-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210218161451.3489955-1-steen.hegelund@microchip.com> References: <20210218161451.3489955-1-steen.hegelund@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide new phy configuration interfaces for media type and speed that allows e.g. PHYs used for ethernet to be configured with this information. Signed-off-by: Lars Povlsen Signed-off-by: Steen Hegelund Reviewed-by: Andrew Lunn Reviewed-by: Alexandre Belloni --- drivers/phy/phy-core.c | 30 ++++++++++++++++++++++++++++++ include/linux/phy/phy.h | 26 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 71cb10826326..ccb575b13777 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -373,6 +373,36 @@ int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode) } EXPORT_SYMBOL_GPL(phy_set_mode_ext); +int phy_set_media(struct phy *phy, enum phy_media media) +{ + int ret; + + if (!phy || !phy->ops->set_media) + return 0; + + mutex_lock(&phy->mutex); + ret = phy->ops->set_media(phy, media); + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_set_media); + +int phy_set_speed(struct phy *phy, int speed) +{ + int ret; + + if (!phy || !phy->ops->set_speed) + return 0; + + mutex_lock(&phy->mutex); + ret = phy->ops->set_speed(phy, speed); + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_set_speed); + int phy_reset(struct phy *phy) { int ret; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index e435bdb0bab3..0ed434d02196 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -44,6 +44,12 @@ enum phy_mode { PHY_MODE_DP }; +enum phy_media { + PHY_MEDIA_DEFAULT, + PHY_MEDIA_SR, + PHY_MEDIA_DAC, +}; + /** * union phy_configure_opts - Opaque generic phy configuration * @@ -64,6 +70,8 @@ union phy_configure_opts { * @power_on: powering on the phy * @power_off: powering off the phy * @set_mode: set the mode of the phy + * @set_media: set the media type of the phy (optional) + * @set_speed: set the speed of the phy (optional) * @reset: resetting the phy * @calibrate: calibrate the phy * @release: ops to be performed while the consumer relinquishes the PHY @@ -75,6 +83,8 @@ struct phy_ops { int (*power_on)(struct phy *phy); int (*power_off)(struct phy *phy); int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode); + int (*set_media)(struct phy *phy, enum phy_media media); + int (*set_speed)(struct phy *phy, int speed); /** * @configure: @@ -215,6 +225,8 @@ int phy_power_off(struct phy *phy); int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode); #define phy_set_mode(phy, mode) \ phy_set_mode_ext(phy, mode, 0) +int phy_set_media(struct phy *phy, enum phy_media media); +int phy_set_speed(struct phy *phy, int speed); int phy_configure(struct phy *phy, union phy_configure_opts *opts); int phy_validate(struct phy *phy, enum phy_mode mode, int submode, union phy_configure_opts *opts); @@ -344,6 +356,20 @@ static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, #define phy_set_mode(phy, mode) \ phy_set_mode_ext(phy, mode, 0) +static inline int phy_set_media(struct phy *phy, enum phy_media media) +{ + if (!phy) + return 0; + return -ENODEV; +} + +static inline int phy_set_speed(struct phy *phy, int speed) +{ + if (!phy) + return 0; + return -ENODEV; +} + static inline enum phy_mode phy_get_mode(struct phy *phy) { return PHY_MODE_INVALID; -- 2.30.0