Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1150383pxb; Wed, 10 Feb 2021 01:01:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkS0tOaonx0be4wDC1g0uZgQtJoQ6lLmb2y30PSvOKjz/kbnJ3lYpY+0RYw096WDBozBA9 X-Received: by 2002:aa7:db16:: with SMTP id t22mr2143718eds.301.1612947719768; Wed, 10 Feb 2021 01:01:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612947719; cv=none; d=google.com; s=arc-20160816; b=bhfasJqpQQfBltP1jpXSblyjolvmzJRuFIMOuZuyuQuZpgrYc0reCS3kJ/BKy8IQix ZF3cxrGsFOtkvIcCBhHBokR1S0ICxk86V50smsqEIu+W+/OgrcZviRQGYw2yiE2yrMcN +0McEesyvO+MhBG52zfjRIm9AgCaJe+IGvIu8klbey6k12R4gN+tTVklbrXfGG36Scsy nrZ/rjzND7MBDK9JhfM38NRMoaLBpw90ju7ZQ1l2o93w2VnH8AlhefjeNKdqOaWX2L3X jGoVybbv2jb6jcyMbW99AV7x3Q5bJZOVqUChEObrBJAqWPBgiFATptm6XVn3RZewSPGw mL0g== 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=bHldN2R7AKKVwPHcyxYRA0Z2OA2+2boI5brYKQoIMSE=; b=nxIBKeJ4bl+35wQVdXPHgkVfMR30BBwhrQLFwFVn4KwHXf+D9XwV1mNaJYwY37El01 kpU7jF0m5Kq1Vx6UhNFIJhT5hF3mz5FO/mdO/ZHih2EAeTvq0zPHAabVJ4P0KPnF1FD3 emakccnonUmmaCokg9z9J32EIGexYN6SayBgKSeougAgPaHmttIDNf7uWZuezSM5O7pq RL9KG/uIbjX289g+Atg/Wscgi7KFvfG3mIyPqbDLHk7P2Zz23kwfQm2CMuLY16xC0i5F BO+B9zg+AuXj3CvfJpA8J8XYuLsVY5C/vM0JWqIRW5La/vhsM3DQaYvYpiXVm26CJbGc pVfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=g9XqqFce; 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 v12si896192ejw.256.2021.02.10.01.01.26; Wed, 10 Feb 2021 01:01:59 -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=g9XqqFce; 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 S230160AbhBJJAX (ORCPT + 99 others); Wed, 10 Feb 2021 04:00:23 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:51205 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbhBJIyZ (ORCPT ); Wed, 10 Feb 2021 03:54:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1612947264; x=1644483264; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wWrcWzYHT/+HXPulQO8+35r8GPSI1mInaaUPzsCjy7I=; b=g9XqqFceGHNmmhs7KlLi4i0kILYe7I6t1ts4VJoyko9hyz0j+d/ym3VE 9t4peFLE0nJK/u6SZUleLApClaXdgC2Q0frA+9/kLMthntwZYuTghqjFn vBUwoLxjRyUVfl+zh+UG+0943dDXJgsK3PZ3rJTqmCTfEdYAwnrLmD3wt BImPDYaEdOVEdZ+mx+VpzYpLZqazwhTQ3DE2xNo9RAi/9I3FSUxK5nCgP o1h2bWxyT+GXVcU2MJGTB2MMHhDJ2OJBRedFdXOilrxv9gjejJ9EV5kCP vY+4p/yvxckVdHNso4H1ROsXutVQnjfjTGBYA/B0kDjDqgKHSnCyUo3Rq g==; IronPort-SDR: JSBLNSD4g+ogyghFy5uARjdwUViMZSZ4gbZwwoP7xi4kVLXWak+adDqaSanal6OEgRp+YEWnl/ Cqj004BI/fwpZ/vf+i8+8+zHawUC3aE3RpDIH6/l5czEK57UMMRh37TYIDNsYxIyQDAiNg0us4 rcgws40jFpFPLEXDtLuhclNqjRTBKREh5Lnz1z696wM1yf27d9+kUfvsbeTvNyYfANnDa1dKG2 nX9clMFxtDqPcVY+++vJSzH66ON4KzJLUC0tDxKg7oo1OAVTB3HxY5hQgc3mxdBXazF6yiu94c aYQ= X-IronPort-AV: E=Sophos;i="5.81,167,1610434800"; d="scan'208";a="106091807" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 10 Feb 2021 01:53:07 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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; Wed, 10 Feb 2021 01:53:07 -0700 Received: from mchp-dev-shegelun.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 10 Feb 2021 01:53:05 -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 v14 2/4] phy: Add media type and speed serdes configuration interfaces Date: Wed, 10 Feb 2021 09:52:53 +0100 Message-ID: <20210210085255.2006824-3-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210085255.2006824-1-steen.hegelund@microchip.com> References: <20210210085255.2006824-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 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..e4fd69a1faa7 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 -ENOSYS; +} + +static inline int phy_set_speed(struct phy *phy, int speed) +{ + if (!phy) + return 0; + return -ENOSYS; +} + static inline enum phy_mode phy_get_mode(struct phy *phy) { return PHY_MODE_INVALID; -- 2.30.0