From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E335D606A689 for ; Fri, 4 Dec 2026 11:08:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=mqnW0Xr5; dkim=fail reason="signature verification failed" (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=cITPQY37; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=U9SNxyu0 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=1W7znx3ez+FGgA8emKL/7U6MHPHPY8y6lQIUvQtaS+M=; b=mqnW0Xr5t2dPcXUZLZ0bTaDH73 0ybduq0hTMr5uzGR4CFnFBBV7OPeIpKS0DfiXrFP8/eQkEi7q6MHP885K222E7Itt9kZYU7FC/dwv 7F/+83xyGGIH05Usp8OeLUopGasuiFingooIdXIuq4PQv+K7D2K/g42DiYMfSQ6zIf+L4+X6Rzl3u xdUX0ljEmZRe+WbNcOnfB1AMytX3Tj6t19VVcoevK3az5XjhncOV9xBGH9cnKccp0z8Dhj0razA9y zXpxgN/jEtN6ZFFWmNNDsRb+8Y4/VaJ7/x3Rk8Hdjj7HeiJv8+EwJwQEjVor3rnYxDxklL0VHjNuo 1pFAK/Yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZR9F-000000004aZ-1W2G; Fri, 04 Dec 2026 11:08:17 +0000 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZR8r-000000004UT-3j31 for linux-phy@lists.infradead.org; Fri, 04 Dec 2026 11:07:55 +0000 Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B45GLFr1440640 for ; Fri, 4 Dec 2026 11:07:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=yBskNufu2Vtp1SUlsDnPkVup C/gtfDKi7IthfwuKgk4=; b=cITPQY376lKOFSeMkIFQWYj0Id0Q6Cx7mas1CGV9 UToXk/nfgXt8SsBHnE+4lsdf9LlkrmBYK3u9nG6zScMHVEt6kOclOPWiI3hhAS+E 1hbD0C/eAC2gpLFIkxFJuQjewL/vZE8GOnpe2iiXHGoIC5TQ/MoaK6ckd7MHGRJV s/1IKh7P7zURSJqzeOgP2e0dlRxxUol+kRq7w1Rs1i1k1/rBNZBzKYYrGD2/slAl lo7u7lW76+c4m7x0WupUGLRQPqB7fQABD/+Zv4lSnwp34b9KG6WBdKfuG553Iqx7 mrUMKlGtV8RGjxci9Vc3FqmUplKctakTHd5CXZBA+gxvWg== Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4jbq7rh0n7-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 04 Dec 2026 11:07:53 +0000 (GMT) Received: by mail-vs1-f72.google.com with SMTP id ada2fe7eead31-7d2cb77c7abso240591137.3 for ; Fri, 04 Dec 2026 03:07:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796382472; x=1796987272; darn=lists.infradead.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=yBskNufu2Vtp1SUlsDnPkVupC/gtfDKi7IthfwuKgk4=; b=U9SNxyu0jfyHrZCeUwjz6eGO3M4agT9uK0xf965sUztDV6TBKwVaVsTukgZP043law EQ2JWN3/aw0JFN43b5nOXyJhOMG1dIZtMIMrk6Ae+5iKXEOGKYOH1+KHy84+gtfz0NkO jo9ng2cxBAQDDO9cWEE1/7/AJzcD+kusOxgSXbAPslHDn41uBsj8gi/GqTpytGAjl0hP li7Dr3ZIfGRWZwcK/VUbF74nyacjactI+H56BWeKP+h8JmxjkSILrbcywRxlYbwVactB sPRCyL/2J2Mr+KizKZcYINmjQ+3bMvbFiho3GsyrdyL3s2QLxnbLxLU0UEKuDleQmwvF Oj4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796382472; x=1796987272; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yBskNufu2Vtp1SUlsDnPkVupC/gtfDKi7IthfwuKgk4=; b=ZnSAlq9VFxTje+IDiyH38bv4flzIEZq8/IE5ijpBMk/+EqBA5R7c4/uhi2Iy2+81qz v+o/h+uQfe0vCxGLc9asQQ2Y6ikoxvIaCxdxaSc7sqe3s+GRd5NKpw666JVU7Z+O19NF EC8+fZL/sSYjzteRr9mtpovM8UUwLbmcbY8e9MghirEHWvnqQ4FAUo2ptnrOPbQ3PSRi /wVkwU34wRfy9+uWzCjnpHGr4Stro+2/aYI7+VQVg/eS9hKdsrxriisYkbqIWSzP/bNp t7XgiAh9pQAALqw5cNHG1IzeYlN9h1q1EE4kUAxUUlxxZX+Kmji8zCoG2pgWIPIy/6DU VakA== X-Forwarded-Encrypted: i=1; AL+hErGZLRFLe4d6yfFA0Y2NvtoJ2mNeHZ29Et2lz35EooqCdTMSl2K/3R/OlMVTdfutx1tvOVB4dcE4+zY=@lists.infradead.org X-Gm-Message-State: APuU4Z+IK0DSM5mkc8S9+5z7QjoBIEirY76JiHoR5LdicjSlYwxem2k0 6CBPg/JF+p/YKQo7dHd6RHKHxzcPfTEUV7IX8l6PYz1fr9w/owrq7HKaDy/RNGK6brl55hHyLUH QxZBuCrVCkNz1eeUCjvNXwkGd3MHjhhhUTGYeI271mg/B2lKkmDSXBEUWxB//vh8SqzPmMEUZK6 Al X-Gm-Gg: AZFdTZfDashFB76VKhXzoqZM2b0yJhLWWS/9GmjheGc+UACLP5iz/DjlmMbr756wbUX NI4EPpV8a8Qj71PDgJm+AdwfhkbkAWX8k2EWCHZBaluw/FAskPZ1Ec96V3092QATzNlGlLhvuSZ WY+6WCJYU5/kVd9oLXmsn63LlcW34yeI2t4JDzan25rioLLf7CkbeTeOEg9F8uW9vLsWzq1DWxW nsgMvd/OcbCmwwgyaMeN+WIuIY7wWCEhHLxGfEyCs3jkfGohXnAYV2jPATTHO84w9YSerhS1Qcu CYW1NKPGhLEBWsy3U1C/L8vNlOqlKqiRRzZcnaNmgTmNLtA4urZr2FjyxKFpQo3kxBti4Ykj33i 0GoN3xRR1ejxdSZ7fOnqTiYDaOdyHwtaXW3Co3S8ryo9bBdr2ILe9K9jlzlteXg== X-Received: by 2002:a05:6102:548b:b0:7cc:2cef:b341 with SMTP id ada2fe7eead31-7daec5712a2mr1056599137.4.1796382472029; Fri, 04 Dec 2026 03:07:52 -0800 (PST) X-Received: by 2002:a05:6102:548b:b0:7cc:2cef:b341 with SMTP id ada2fe7eead31-7daec5712a2mr1056577137.4.1796382471428; Fri, 04 Dec 2026 03:07:51 -0800 (PST) Received: from localhost ([130.25.105.85]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d1724ad3a5sm5911431f8f.9.2026.12.04.03.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 03:07:50 -0800 (PST) Date: Fri, 4 Dec 2026 12:07:49 +0100 From: Lorenzo Bianconi To: Mohd Ayaan Anwar Cc: Vinod Koul , Neil Armstrong , Manivannan Sadhasivam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bartosz Golaszewski , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org Subject: Re: [PATCH v2 3/5] phy: qcom: sgmii-eth: select init functions through match data Message-ID: References: <20261202-nord_ethernet_serdes-v2-0-95bb41a719c7@oss.qualcomm.com> <20261202-nord_ethernet_serdes-v2-3-95bb41a719c7@oss.qualcomm.com> X-Archived-By: MIME-Version: 1.0 In-Reply-To: <20261202-nord_ethernet_serdes-v2-3-95bb41a719c7@oss.qualcomm.com> X-Proofpoint-ORIG-GUID: d79rusXD5xIWQiDfCoCyVi2VpIbi_Kqm X-Proofpoint-Spam-Info: AW1haW4tMjYxMjA0MDA0NCBTYWx0ZWRfXxhjk+6C61oYY rBbbilS+ZDvd+bgAxm9qRzED6CURa0c5RnLHWANYQpslKONGYGeqFqhlbdLGn4QufYOjuKc6p3F RJ1D6AbEI1WtHp7TQci3Ja5wXJxw+SQ= X-Authority-Analysis: v=2.4 cv=PtEG/AM3 c=1 sm=1 tr=0 ts=6b129f09 cx=c_pps a=DUEm7b3gzWu7BqY5nP7+9g==:117 a=RcFDq6c+avmIvxkL9iwlxA==:17 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=sviDw_sGuii692ThSIkA:9 a=CjuIK1q_8ugA:10 a=RqMH_413aJ5yQyJeOcAA:9 a=-aSRE8QhW-JAV6biHavz:22 X-Proofpoint-GUID: d79rusXD5xIWQiDfCoCyVi2VpIbi_Kqm X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjA0MDA0NCBTYWx0ZWRfX3ETT90Bn6cJs fHg82uSs983YcBSGMpvjUjWCkSJs9oAtHqakXg3Nel0OL2zO82QmjPHros9+81MsIDv0ZklxXrB ox93hUid4G8qcdnJKcbFbUuUQQ4LHEKB7DF07q3Atl+gdieGHT+njoT3wlz6LrdI6zsyfXnh2Au 87ORmklMeI8Or/s6zIZ7vcGelx6Y0vXVwIle+0qkUL+AajGFNNREPs6rum8qCLFlPwQ+xBUDWva LNSTodH0ch/QSBu01ADGhXzK6b17rUjbkpBwSGDYzp+6tyi4zqynPYxM/NO2fXUq7Ji8xDgOc1e 4D0gsFdpNlFNx8sIXclucKgaf0mW8L1wmHf704DVxCuyItp+iWwFXlSDMFviBwR7ysZD/UDbyVp RoS/K7z+BUJ2/XvWqLDJ0vraBr4TkpQB3n4Sc2gnojjvX9P+YTUUONGiIIHjZq9iPT5kWM6y18+ IjAsHyAY7kX2cARJc3w== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-04_01,2026-12-03_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 adultscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612040044 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_030753_945770_E838C9EC X-CRM114-Status: GOOD ( 29.56 ) X-Spam-Score: -2.8 (--) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1734659107480983379==" Sender: "linux-phy" X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 --===============1734659107480983379== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="1UIXvlTUN8/Swf+M" Content-Disposition: inline --1UIXvlTUN8/Swf+M Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > The current initialization sequences use QMP v5 registers. Adding > support for a new SerDes generation requires selecting its sequences by > the compatible. >=20 > Store the initial interface and per-rate initializer callbacks in match > data. Use a selector for validation and calibration, rejecting modes > without an initializer before accessing registers. This also protects > calibration invoked directly or through power-on. >=20 > Populate the existing SGMII/1000BASE-X and 2500BASE-X initializers for > SA8775P and retain SGMII as its initial interface. Register programming > and readiness checks are unchanged. >=20 > Signed-off-by: Mohd Ayaan Anwar Hi Mohd, I think the patch is fine, just few comments inline. Regards, Lorenzo > --- > drivers/phy/qualcomm/phy-qcom-sgmii-eth.c | 76 ++++++++++++++++++++++---= ------ > 1 file changed, 55 insertions(+), 21 deletions(-) >=20 > diff --git a/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c b/drivers/phy/qual= comm/phy-qcom-sgmii-eth.c > index 196e9f057387..25e49f2b6824 100644 > --- a/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c > +++ b/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c > @@ -34,13 +34,42 @@ static const struct regulator_bulk_data qcom_dwmac_sg= mii_phy_vregs[] =3D { > =20 > #define QCOM_SGMII_NUM_SUPPLIES ARRAY_SIZE(qcom_dwmac_sgmii_phy_vregs) > =20 > +struct qcom_dwmac_sgmii_phy_match_data { > + /* Initial interface used before the consumer selects a mode. */ > + phy_interface_t interface; > + void (*init_1g)(struct regmap *regmap); > + void (*init_2p5g)(struct regmap *regmap); > +}; > + > struct qcom_dwmac_sgmii_phy_data { > + const struct qcom_dwmac_sgmii_phy_match_data *match_data; > struct regulator_bulk_data *vregs; > struct regmap *regmap; > struct clk *refclk; > phy_interface_t interface; > }; > =20 > +static int > +qcom_dwmac_sgmii_phy_select_init(const struct qcom_dwmac_sgmii_phy_match= _data *match_data, > + int submode, void (**init)(struct regmap *regmap)) > +{ > + switch (submode) { > + case PHY_INTERFACE_MODE_SGMII: > + case PHY_INTERFACE_MODE_1000BASEX: > + /* 1.25 Gbaud */ > + *init =3D match_data->init_1g; > + break; > + case PHY_INTERFACE_MODE_2500BASEX: > + /* 3.125 Gbaud */ > + *init =3D match_data->init_2p5g; > + break; > + default: > + return -EINVAL; > + } > + > + return *init ? 0 : -EINVAL; I guess you can run the function here instead of returning it, right? > +} > + > static void qcom_dwmac_sgmii_phy_init_v5_1g(struct regmap *regmap) > { > regmap_write(regmap, QSERDES_PCS + QPHY_PCS_SW_RESET, 0x01); > @@ -231,20 +260,14 @@ static int qcom_dwmac_sgmii_phy_calibrate(struct ph= y *phy) > { > struct qcom_dwmac_sgmii_phy_data *data =3D phy_get_drvdata(phy); > struct device *dev =3D phy->dev.parent; > + void (*init)(struct regmap *regmap); > + int ret; > =20 > - switch (data->interface) { > - case PHY_INTERFACE_MODE_SGMII: > - case PHY_INTERFACE_MODE_1000BASEX: > - /* 1.25Gbps mode */ > - qcom_dwmac_sgmii_phy_init_v5_1g(data->regmap); > - break; > - case PHY_INTERFACE_MODE_2500BASEX: > - /* 3.125Gbps mode */ > - qcom_dwmac_sgmii_phy_init_v5_2p5g(data->regmap); > - break; > - default: > - return -EINVAL; > - } > + ret =3D qcom_dwmac_sgmii_phy_select_init(data->match_data, data->interf= ace, &init); > + if (ret) > + return ret; > + > + init(data->regmap); > =20 > if (qcom_dwmac_sgmii_phy_poll_status(data->regmap, > QSERDES_QMP_PLL + QSERDES_V5_COM_C_READY_STATUS, > @@ -325,15 +348,13 @@ static int qcom_dwmac_sgmii_phy_validate(struct phy= *phy, enum phy_mode mode, > int submode, > union phy_configure_opts *opts) > { > + struct qcom_dwmac_sgmii_phy_data *data =3D phy_get_drvdata(phy); > + void (*init)(struct regmap *regmap); > + > if (mode !=3D PHY_MODE_ETHERNET) > return -EINVAL; > =20 > - if (submode =3D=3D PHY_INTERFACE_MODE_SGMII || > - submode =3D=3D PHY_INTERFACE_MODE_1000BASEX || > - submode =3D=3D PHY_INTERFACE_MODE_2500BASEX) > - return 0; > - > - return -EINVAL; > + return qcom_dwmac_sgmii_phy_select_init(data->match_data, submode, &ini= t); Why is it needed here? It seems you are not using the init function pointer, right? > } > =20 > static int qcom_dwmac_sgmii_phy_set_mode(struct phy *phy, enum phy_mode = mode, > @@ -385,7 +406,11 @@ static int qcom_dwmac_sgmii_phy_probe(struct platfor= m_device *pdev) > if (!data) > return -ENOMEM; > =20 > - data->interface =3D PHY_INTERFACE_MODE_SGMII; > + data->match_data =3D device_get_match_data(dev); > + if (!data->match_data) > + return -EINVAL; > + > + data->interface =3D data->match_data->interface; > =20 > base =3D devm_platform_ioremap_resource(pdev, 0); > if (IS_ERR(base)) > @@ -419,8 +444,17 @@ static int qcom_dwmac_sgmii_phy_probe(struct platfor= m_device *pdev) > return 0; > } > =20 > +static const struct qcom_dwmac_sgmii_phy_match_data sa8775p_match_data = =3D { > + .interface =3D PHY_INTERFACE_MODE_SGMII, > + .init_1g =3D qcom_dwmac_sgmii_phy_init_v5_1g, > + .init_2p5g =3D qcom_dwmac_sgmii_phy_init_v5_2p5g, > +}; > + > static const struct of_device_id qcom_dwmac_sgmii_phy_of_match[] =3D { > - { .compatible =3D "qcom,sa8775p-dwmac-sgmii-phy" }, > + { > + .compatible =3D "qcom,sa8775p-dwmac-sgmii-phy", > + .data =3D &sa8775p_match_data, > + }, > { }, > }; > MODULE_DEVICE_TABLE(of, qcom_dwmac_sgmii_phy_of_match); >=20 > --=20 > 2.34.1 >=20 --1UIXvlTUN8/Swf+M Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCaxKfBQAKCRA6cBh0uS2t rPfqAQDX/Mw5T8+iYyv3zt3RtsYCxaSk+Z6OoGsOnXcv0SHn8QD/dDhP2JzQC4X5 Jc42VIHveCZ2YyTFrG8n7iSpwjyjlgQ= =21q0 -----END PGP SIGNATURE----- --1UIXvlTUN8/Swf+M-- --===============1734659107480983379== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy --===============1734659107480983379==--