Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp44111rdb; Mon, 18 Dec 2023 08:28:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6/4hBDa04PfNIA+qTuzuX6yJwIG2UhXK+f88eoIROx8IDzGuoefjiQtpMXqnYeX5jhv/E X-Received: by 2002:a17:906:1c1:b0:a18:7999:764 with SMTP id 1-20020a17090601c100b00a1879990764mr7492985ejj.17.1702916910408; Mon, 18 Dec 2023 08:28:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702916910; cv=none; d=google.com; s=arc-20160816; b=KMvAQoS3JdOjX+mnB6DhArVrWUZ08DLJNp+DBcdcoloKeIHmIxhBHUIypZtb2v8aEV 6YenFpz1BfHKXPlNRwa18M7xu6ptZ0kubJrHhgr7C10rl5rZva0r9xzu2seH9IjvuxdH BpEqGXbwxgkS1yenkvx4Xa4d35MXAQheoWoCw6Ah1ugd9KcqNNtkRqOBpTSLJiUKa8rS rhZR5VAjLND/lX+wmu1nWO23m4rbpkPYtuvOeH7M2GQhtQXA34OMNyl2rujcZOZlfJI7 dzKuWTP04hnZ2VxdBuD8DpFv1akVrBRUl8CMH1M9omHplntO7dXqUtF4snSIDoVYdssL ELDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tTEkicxeHNXHb/6pSYfpZYOfjZVCf7gx8W87QpG78TA=; fh=C/AhJY3HcMD4cCzUXE55ml90B8Ao0T3eiErIiT7CtNA=; b=C2gPk7YKeO9XP2nEeWWdk41WI6Q5/O9YaOHr7RJ5Uv3uHn9aUI8J8hmlIC7P2ntzEb Nwd0vpM056KNkonq7kz1ykYW9C/gl5JJHQQw/G1SWCTJpBFvn3TuSbFq2KuvxLvHyccp 5uc0W8C/WqOPdquIYQmgupbs4uQwKP2x6D6P71DGVOt1MRQ92dw2PxxXChlinJxDGECJ 1nlRnjNSHL1Dltf34V5yKTLFWGuGp+1oleT8hsUzfyHKkEKtKUzOfsh6alr2BOAljdeG ZVM3aiCLkd9PDlDG57FMuY7KZgnnwdU6f+otLpHaWkSGpkO0H3UE5QmGeD9LbPL0UbgN 3Ncg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L4jGfYWw; spf=pass (google.com: domain of linux-kernel+bounces-4055-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4055-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i21-20020a170906115500b00a23486b9d3asi1457516eja.474.2023.12.18.08.28.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 08:28:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4055-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L4jGfYWw; spf=pass (google.com: domain of linux-kernel+bounces-4055-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4055-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 292261F213F1 for ; Mon, 18 Dec 2023 16:20:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0EB13495DE; Mon, 18 Dec 2023 16:20:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="L4jGfYWw" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 307984239F for ; Mon, 18 Dec 2023 16:20:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702916443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tTEkicxeHNXHb/6pSYfpZYOfjZVCf7gx8W87QpG78TA=; b=L4jGfYWwFN5U5bo0Gq1vRTD2vKP7jgMo9gFQDzpAM4PV1tVqaH1XY9FBPaPfgS+hRCU0T9 DS+8/ome3UM+AiTib6G+m/TMXhNf9w7bnboFSK7VyzRphaJzgcBVGux4UUBThCMg9fIQ2L 0FLQZPlnAaqMy8LYxbtkEu8omPUQA2g= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-FL-tlJUxPXSDru6kdxk6QA-1; Mon, 18 Dec 2023 11:20:10 -0500 X-MC-Unique: FL-tlJUxPXSDru6kdxk6QA-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-77f4ae2e25bso568400185a.1 for ; Mon, 18 Dec 2023 08:20:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702916407; x=1703521207; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tTEkicxeHNXHb/6pSYfpZYOfjZVCf7gx8W87QpG78TA=; b=IyB0K7R9uuFltY5N7kpwZRYBRR4RaAkgKlVue88Z94CW1lxQzSyvmItsHlyDvMSSdl CSKIafj8UqeYU7KUcyHaTtRaDpx1zsgWRuUr5JM4w9lYUQXPpIKctZfD8dyJLS/khGRo MJLYHHVufjTmLz8FNoW3sOJO+4GV1Px9qRFBUnjcE0Vo7+hAUKE7LXX63J2MkJ/vxmvT LtUlc9ej98EhCg3lBxr1s8sOfXitxi+DfUpCIQijOOukkXjszL7hTwCFpzFxzMNJX6+F CTQLJdpWbSRazOjwVGEnsOcr7SbY2U/3bpfgSThh7iV8aCiRnMlDxzONUJEULJQHIUhE zSuw== X-Gm-Message-State: AOJu0YwWEvfdqm5tuHSyjiGjryevrZVqFkO87pv98FKlZKTWTvY3Cge9 blYxCCXM36hUZ3PKGc9YcWtwKLLqu5Q2kgCL1BgDLBR7FoIQxOvxeOgYygnXo0iYN65qlTfjggX xZwhJ3QavnIot3Kvdij0K9rqqlng2LZsl X-Received: by 2002:a05:620a:4591:b0:77e:fba3:58e2 with SMTP id bp17-20020a05620a459100b0077efba358e2mr21670378qkb.115.1702916407338; Mon, 18 Dec 2023 08:20:07 -0800 (PST) X-Received: by 2002:a05:620a:4591:b0:77e:fba3:58e2 with SMTP id bp17-20020a05620a459100b0077efba358e2mr21670361qkb.115.1702916407066; Mon, 18 Dec 2023 08:20:07 -0800 (PST) Received: from fedora ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id vq18-20020a05620a559200b0077fafc08e46sm2772136qkn.84.2023.12.18.08.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 08:20:06 -0800 (PST) Date: Mon, 18 Dec 2023 10:20:03 -0600 From: Andrew Halaney To: Sneh Shah Cc: Vinod Koul , Bhupesh Sharma , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@quicinc.com Subject: Re: [PATCH net-next] net: stmmac: dwmac-qcom-ethqos: Add support for 2.5G SGMII Message-ID: <4zbf5fmijxnajk7kygcjrcusf6tdnuzsqqboh23nr6f3rb3c4g@qkfofhq7jmv6> References: <20231218071118.21879-1-quic_snehshah@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231218071118.21879-1-quic_snehshah@quicinc.com> On Mon, Dec 18, 2023 at 12:41:18PM +0530, Sneh Shah wrote: > Serdes phy needs to operate at 2500 mode for 2.5G speed and 1000 > mode for 1G/100M/10M speed. > Added changes to configure serdes phy and mac based on link speed. > > Signed-off-by: Sneh Shah > --- > .../stmicro/stmmac/dwmac-qcom-ethqos.c | 31 +++++++++++++++++-- > 1 file changed, 29 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c > index d3bf42d0fceb..b3a28dc19161 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c > @@ -21,6 +21,7 @@ > #define RGMII_IO_MACRO_CONFIG2 0x1C > #define RGMII_IO_MACRO_DEBUG1 0x20 > #define EMAC_SYSTEM_LOW_POWER_DEBUG 0x28 > +#define ETHQOS_MAC_AN_CTRL 0xE0 > > /* RGMII_IO_MACRO_CONFIG fields */ > #define RGMII_CONFIG_FUNC_CLK_EN BIT(30) > @@ -78,6 +79,10 @@ > #define ETHQOS_MAC_CTRL_SPEED_MODE BIT(14) > #define ETHQOS_MAC_CTRL_PORT_SEL BIT(15) > > +/*ETHQOS_MAC_AN_CTRL bits */ > +#define ETHQOS_MAC_AN_CTRL_RAN BIT(9) > +#define ETHQOS_MAC_AN_CTRL_ANE BIT(12) > + nit: space please add a space before ETHQOS_MAC_AN_CTRL > struct ethqos_emac_por { > unsigned int offset; > unsigned int value; > @@ -109,6 +114,7 @@ struct qcom_ethqos { > unsigned int num_por; > bool rgmii_config_loopback_en; > bool has_emac_ge_3; > + unsigned int serdes_speed; > }; > > static int rgmii_readl(struct qcom_ethqos *ethqos, unsigned int offset) > @@ -600,27 +606,47 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos) > > static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) > { > - int val; > - > + int val, mac_an_value; > val = readl(ethqos->mac_base + MAC_CTRL_REG); > + mac_an_value = readl(ethqos->mac_base + ETHQOS_MAC_AN_CTRL); > > switch (ethqos->speed) { > + case SPEED_2500: > + val &= ~ETHQOS_MAC_CTRL_PORT_SEL; > + rgmii_updatel(ethqos, RGMII_CONFIG2_RGMII_CLK_SEL_CFG, > + RGMII_CONFIG2_RGMII_CLK_SEL_CFG, > + RGMII_IO_MACRO_CONFIG2); > + if (ethqos->serdes_speed != SPEED_2500) > + phy_set_speed(ethqos->serdes_phy, ethqos->speed); > + mac_an_value &= ~ETHQOS_MAC_AN_CTRL_ANE; > + break; > case SPEED_1000: > val &= ~ETHQOS_MAC_CTRL_PORT_SEL; > rgmii_updatel(ethqos, RGMII_CONFIG2_RGMII_CLK_SEL_CFG, > RGMII_CONFIG2_RGMII_CLK_SEL_CFG, > RGMII_IO_MACRO_CONFIG2); > + if (ethqos->serdes_speed != SPEED_1000) > + phy_set_speed(ethqos->serdes_phy, ethqos->speed); > + mac_an_value |= ETHQOS_MAC_AN_CTRL_RAN | ETHQOS_MAC_AN_CTRL_ANE; > break; > case SPEED_100: > val |= ETHQOS_MAC_CTRL_PORT_SEL | ETHQOS_MAC_CTRL_SPEED_MODE; > + if (ethqos->serdes_speed != SPEED_1000) > + phy_set_speed(ethqos->serdes_phy, ethqos->speed); > + mac_an_value |= ETHQOS_MAC_AN_CTRL_RAN | ETHQOS_MAC_AN_CTRL_ANE; > break; > case SPEED_10: > val |= ETHQOS_MAC_CTRL_PORT_SEL; > val &= ~ETHQOS_MAC_CTRL_SPEED_MODE; > + if (ethqos->serdes_speed != SPEED_1000) > + phy_set_speed(ethqos->serdes_phy, ethqos->speed); > + mac_an_value |= ETHQOS_MAC_AN_CTRL_RAN | ETHQOS_MAC_AN_CTRL_ANE; > break; > } > > writel(val, ethqos->mac_base + MAC_CTRL_REG); > + writel(mac_an_value, ethqos->mac_base + ETHQOS_MAC_AN_CTRL); > + ethqos->serdes_speed = ethqos->speed; I see these bits are generic and there's some functions in stmmac_pcs.h that muck with these... Could you help me understand if this really should be Qualcomm specific, or if this is something that should be considered for the more core bits of the driver? I feel in either case we should take advantage of the common definitions in that file if possible. > > return val; > } > @@ -789,6 +815,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) > "Failed to get serdes phy\n"); > > ethqos->speed = SPEED_1000; > + ethqos->serdes_speed = SPEED_1000; > ethqos_update_link_clk(ethqos, SPEED_1000); > ethqos_set_func_clk_en(ethqos); > > -- > 2.17.1 >