From nobody Sat Feb 7 15:26:31 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 075E7C7EE43 for ; Mon, 12 Jun 2023 09:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232471AbjFLJbc (ORCPT ); Mon, 12 Jun 2023 05:31:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231418AbjFLJaJ (ORCPT ); Mon, 12 Jun 2023 05:30:09 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 364112D6B for ; Mon, 12 Jun 2023 02:24:45 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3f6da07ff00so42335425e9.3 for ; Mon, 12 Jun 2023 02:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1686561883; x=1689153883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vPRfCIFPGTjCNzA0zoFKpFOOb+gMs8UR4lDCHzO+xYc=; b=xa/KP+P3Zmb/Lx0rhjT625N/dGumpGheBG+7/5CCXii82aEzcv1iLt1h7b44GlBij0 D69l/6p4rjUdxNuvv/cvLZvHn6LCZm5b3JrLPXHj7p3U/LdTzrLNEekwGLW+o/T3Y7aZ PeA1InA/KpeS9gTUHK67bs/3jEHLYjmrGL/D3/LQL4a+X1W/99lxl7CpRiBP6Cao9d8W MapJdFYF+LaJ4BhaIG7KSINuHv2DSeFfbEJfMxN5B2p6E6YIw+XTSAD89BS2IkXdOKDL SNaJGeGp8r5a1A5BXHv/89caBDdrOXOqcQSApiSY4sXvIb3Ff2SpnXkGnciwuNxFwNbP NU0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686561883; x=1689153883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vPRfCIFPGTjCNzA0zoFKpFOOb+gMs8UR4lDCHzO+xYc=; b=iw8TVIKcsqBBZXBZiRrYAmY06yuRYlDvH8MNvVpTWcSKWzSCZc55bFuqlLWqGKXS8d tZaWoyb/3cWRGniGqmAxSo+Seat+K9kUg7g3OprqMl6offYHfN9FJ5VfDL3d+/7HxPIS Ib/pSg+xYW1bOMaquyiTK6gNlAXdeIbDAObR5nNip96IIs5aasC4ZK97zi+nXWGZVVHx NDn85md8P+Z7bLC44islrUoY78MqDsu/+RuSfjFW1MMuHTCZX6TRkLPMTVrF3fJP6ZYA C3PE0US9oeh3NQrN+W+nuUkVN5URVs6MNx8Bk7bLYRzmQ9G78ZD/vJS1iATZGwobNBTf nDIQ== X-Gm-Message-State: AC+VfDzmCP46BP/bozg77wK2JuXzBrxhINLfVWT7kkwMP1h3aNCyUc7O C79WjVV00y9iwlMnkiAZ0NL/uA== X-Google-Smtp-Source: ACHHUZ6y2zO9SRmgd6QTiNDY/FOPGHY7u5CU71HGkgTGaGv20bvmxhweXuqr9zyfR01coD+kH8e1xw== X-Received: by 2002:a05:600c:214:b0:3f7:3a31:847f with SMTP id 20-20020a05600c021400b003f73a31847fmr6720889wmi.31.1686561883574; Mon, 12 Jun 2023 02:24:43 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:a222:bbe9:c688:33ae]) by smtp.gmail.com with ESMTPSA id p14-20020a7bcc8e000000b003f727764b10sm10892044wma.4.2023.06.12.02.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 02:24:43 -0700 (PDT) From: Bartosz Golaszewski To: Vinod Koul , Bhupesh Sharma , Andy Gross , Bjorn Andersson , Konrad Dybcio , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kishon Vijay Abraham I , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu Cc: netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Bartosz Golaszewski Subject: [PATCH 12/26] net: stmmac: dwmac-qcom-ethqos: add support for the optional serdes phy Date: Mon, 12 Jun 2023 11:23:41 +0200 Message-Id: <20230612092355.87937-13-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230612092355.87937-1-brgl@bgdev.pl> References: <20230612092355.87937-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski On sa8775p platforms, there's a SGMII SerDes PHY between the MAC and external PHY that we need to enable and configure. Signed-off-by: Bartosz Golaszewski --- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/driv= ers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 8ed05f29fe8b..3438b6229351 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -6,6 +6,7 @@ #include #include #include +#include #include =20 #include "stmmac.h" @@ -93,6 +94,7 @@ struct qcom_ethqos { =20 unsigned int rgmii_clk_rate; struct clk *rgmii_clk; + struct phy *serdes_phy; unsigned int speed; =20 const struct ethqos_emac_por *por; @@ -566,6 +568,30 @@ static void ethqos_fix_mac_speed(void *priv, unsigned = int speed) ethqos_configure(ethqos); } =20 +static int qcom_ethqos_serdes_powerup(struct net_device *ndev, void *priv) +{ + struct qcom_ethqos *ethqos =3D priv; + int ret; + + ret =3D phy_set_speed(ethqos->serdes_phy, ethqos->speed); + if (ret) + return ret; + + ret =3D phy_init(ethqos->serdes_phy); + if (ret) + return ret; + + return phy_power_on(ethqos->serdes_phy); +} + +static void qcom_ethqos_serdes_powerdown(struct net_device *ndev, void *pr= iv) +{ + struct qcom_ethqos *ethqos =3D priv; + + phy_power_off(ethqos->serdes_phy); + phy_exit(ethqos->serdes_phy); +} + static int ethqos_clks_config(void *priv, bool enabled) { struct qcom_ethqos *ethqos =3D priv; @@ -651,6 +677,12 @@ static int qcom_ethqos_probe(struct platform_device *p= dev) if (ret) goto out_config_dt; =20 + ethqos->serdes_phy =3D devm_phy_optional_get(dev, "serdes"); + if (IS_ERR(ethqos->serdes_phy)) { + ret =3D PTR_ERR(ethqos->serdes_phy); + goto out_config_dt; + } + ethqos->speed =3D SPEED_1000; ethqos_update_rgmii_clk(ethqos, SPEED_1000); ethqos_set_func_clk_en(ethqos); @@ -666,6 +698,11 @@ static int qcom_ethqos_probe(struct platform_device *p= dev) if (of_device_is_compatible(np, "qcom,qcs404-ethqos")) plat_dat->rx_clk_runs_in_lpi =3D 1; =20 + if (ethqos->serdes_phy) { + plat_dat->serdes_powerup =3D qcom_ethqos_serdes_powerup; + plat_dat->serdes_powerdown =3D qcom_ethqos_serdes_powerdown; + } + ret =3D stmmac_dvr_probe(dev, plat_dat, &stmmac_res); if (ret) goto out_config_dt; --=20 2.39.2