From patchwork Thu Jun 27 11:39:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13714257 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8154C30653 for ; Thu, 27 Jun 2024 11:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sxu9SpdSTVz3ebvxMLh70e0y0HDyyRtIxZX5+1VZmbE=; b=Dgjs3WQO5r4srzTwjuRA3ZBo2s AUy1pRrid8MnMvHTzEr70SnAnOte5bGaYxHezKXZN6NivNjDX5B0W1sXVGEO5rMk/rP4sd78kafzB 8Umk5d6KoR31l9YSAWsCEajsHtRrUzBFucrk6J9u2vvceATwdL/SGan4fTEzfoQ7QfDNbDxeh9G0b Cno8y56ofuePVRygjCEli8HvOl483Burlwuf169vjg4nrS2ofTrn7GUXfDEfEzn4vGWE1BtBzy4k+ QJp9bFgKm/ZofMpByRWMpdj+/UoAo2WpPSLB4t5/RSnLFUvFwy1naNJu5WwJ3wro4r9kFZrcSgbkn xKesKBFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMnUM-0000000ABqW-1s1H; Thu, 27 Jun 2024 11:40:30 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMnTw-0000000ABiX-08q3 for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 11:40:14 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2ec58040f39so53343041fa.2 for ; Thu, 27 Jun 2024 04:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1719488397; x=1720093197; darn=lists.infradead.org; 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=sxu9SpdSTVz3ebvxMLh70e0y0HDyyRtIxZX5+1VZmbE=; b=ENL8L3j+heULEHJqLdMgVHrsq+E0wgR46PSIYe1Zk7eDHiLRLMcarfXTbJp5MgDLdy o6tZzD4Qohp0o6oI75vyAYfExnv58g4kgPzwRQNrJe4AZqDYr2QWdvwbLUguxxnK0pmY eEDC2mTLQG3wHaEr6LOK8zdzZOJF2QEwcx6B+NvLrXxiyCG+PE0jzDOlSf6035OAz/+m ef+G11qnWhj2LfayjvreJSqmAyt6iOyCum6w7N2kyEJjgqqt8PEPMZb/UDdx6mNmycto qkx+MABBHY9nirQAWpUsxfOiTE0axgSTXHs6+VIRZDTk2a1iBdxdrlqU+nbIjGbEQ2Q/ W1bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719488397; x=1720093197; 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=sxu9SpdSTVz3ebvxMLh70e0y0HDyyRtIxZX5+1VZmbE=; b=T6G9PMIt6T53v9KeH0OX8+V6B6aYvd8auK+IaaVIUy0YSLNGdrJqno6ahXnswQ6grW rOpgXapjD3m9cqqKHKBQue+0IDuEJgtup7tvVD1aTQt0n+hCj+hD/a4S+sSsNN7DRngf CXmK5lAwmHGytqOggde1bgwqHcxPgS2qh5gY4hIS88Xt5PddVyadJjBr7UJDd2Ubp8Iu NMuOiRTL7+s3is2r7h6s6qXY7IDeWNTVUBNGmJVgwsc36G6+MI8nZWVE4S99fKgxIaXT KptUzidOUXXZnKVU+8bHq9PWiKIh26xt6F6VdBTIk5bumvhPAZNiI66lK9l+Zgo86KWK oTHw== X-Forwarded-Encrypted: i=1; AJvYcCVlv9ktLrPuFlGQyPLatUolqebZRFmRLk5iWn8Gg8+QSrpzhQvt7U45zkV1t+V9li56Tt5FycPZtMH4YL93Okk1qj4L1nbt7E5FuloadHy3jhifnfw= X-Gm-Message-State: AOJu0YzqSCxKZ0AxglNJskeedsqiENpeKQwMmtJe/w9GWRD9gKw0hbgK rIWGwfdWxreykcGQv7dPkh919TMjg1nNj+MfLF/QKg9DNr7xma/RSJ/H03Bl4TE= X-Google-Smtp-Source: AGHT+IEX942vNvyHTmy9tspQQQL/qKLX+sbQ4RkDTe+pTb3TOEUopxyuIw7WbECrr/t329Hui5TQGA== X-Received: by 2002:a2e:8047:0:b0:2eb:ed3a:9c65 with SMTP id 38308e7fff4ca-2ec593d93a0mr77254481fa.15.1719488397179; Thu, 27 Jun 2024 04:39:57 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:dc:7e00:7fe5:47e9:28c5:7f25]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8468613sm62081815e9.39.2024.06.27.04.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 04:39:56 -0700 (PDT) From: Bartosz Golaszewski To: Vinod Koul , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: 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, Bartosz Golaszewski Subject: [PATCH v2 net-next 1/2] net: stmmac: qcom-ethqos: add support for 2.5G BASEX mode Date: Thu, 27 Jun 2024 13:39:46 +0200 Message-ID: <20240627113948.25358-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240627113948.25358-1-brgl@bgdev.pl> References: <20240627113948.25358-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_044004_691648_B521853A X-CRM114-Status: GOOD ( 11.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski Add support for 2.5G speed in 2500BASEX mode to the QCom ethqos driver. Signed-off-by: Bartosz Golaszewski --- .../net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 80eb72bc6311..91fe57a3e59e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -665,6 +665,14 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) return val; } +static void qcom_ethqos_speed_mode_2500(struct net_device *ndev, void *data) +{ + struct stmmac_priv *priv = netdev_priv(ndev); + + priv->plat->max_speed = 2500; + priv->plat->phy_interface = PHY_INTERFACE_MODE_2500BASEX; +} + static int ethqos_configure(struct qcom_ethqos *ethqos) { return ethqos->configure_func(ethqos); @@ -787,6 +795,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev) case PHY_INTERFACE_MODE_RGMII_TXID: ethqos->configure_func = ethqos_configure_rgmii; break; + case PHY_INTERFACE_MODE_2500BASEX: + plat_dat->speed_mode_2500 = qcom_ethqos_speed_mode_2500; + fallthrough; case PHY_INTERFACE_MODE_SGMII: ethqos->configure_func = ethqos_configure_sgmii; break; From patchwork Thu Jun 27 11:39:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13714259 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC311C30653 for ; Thu, 27 Jun 2024 11:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4pg+dewGD9qJnz964kSExuGkcfdlUV33yviPPBuaIJc=; b=xb0TQOmbVZzldHD5eqk6sfhANU F4BKDeZHjWZbl8/FtwLZB53x2Rdijl8l6N+GT5R2w5EoRo6g/3/DBFN1BS1RMAAy9ehhaK5esLz+s XgyU9HjFDRvAjQDtluqY8N855rkg7kXW4Xl2XFny4K+YTFsigkUkuXKPx31aU94aSId7tKDLTMSRV +5/St5djI9/2RKRRtu5MMe1r+M5nx46uA2NCWmgxwF5KSn0Tks2yojdKrPXlyHXe6nZ2nzkBV9a9G Qpz/ntq1sYW6/7H72P7M28HCX08qlS1zViSDIKm960Saz0ZPZu6t88cWqD+k4L9exUmgEj84f6bNY Ol6ScHSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMnUY-0000000ABvw-2U6w; Thu, 27 Jun 2024 11:40:43 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMnTw-0000000ABid-08yL for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 11:40:22 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2ec4eefbaf1so70860151fa.1 for ; Thu, 27 Jun 2024 04:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1719488398; x=1720093198; darn=lists.infradead.org; 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=4pg+dewGD9qJnz964kSExuGkcfdlUV33yviPPBuaIJc=; b=ncv4aLFM9k0M3OFaj4WCsmajvI87Z1Ytik8GoxiTThSOBjDFFlpffxdf9YsL3Fh0By 3vBU34eSeBkbxXBTzmB0DTTy1dpt+JP7LbVDQ7dBHyMvHeSlQkUo9mntvAKadvQSf1in Zc/jW8m5AaVZehylF8nsAJZrY8cjodEd40GYg/c1g8ttGlf6rZ27HUrC12q65PHWu0Mj azepUemaymNrr43k71vvli7VPaU1mb9rtOlYkD5GtC36XhOwLg8uScG3ZAOeztbgZ/hr jmThATTYzYYL3A37qNeUOPm19NbcvwVbn5WlQc8XX4Kzp1GUpyd6IXdHOg0+6hAOaub4 xJqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719488398; x=1720093198; 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=4pg+dewGD9qJnz964kSExuGkcfdlUV33yviPPBuaIJc=; b=NVgu1AyCmOUOAFmrSSADh6J/pZ86LJS4HgggDRntbfmaemRVMum7/uYlplaAVHo4x3 gipcyfBbnjS9ozvBTj8n5fz8IDg9Aap/sygBRLogYGMzj5CZpZsx+dVYzfgTqL7AhE7v AR9DQCmIv92wqiwCny+q+A3X5IYphNVTsmcXaI0PYXQvFQPJQRXEsnxKLYoZOBOQUOLm g+0PKkA8CA2dAG02KFvPmyTBeGBY9sMztIRfM+XSbosaoxx4GN7XFMtSzczgbFqiWLNO aceB++RClUwNLK5/IcDZsFlgH00QilFZm+adqAhSalOc75tY7q3+alHeE5qleSoUAaj2 EKiA== X-Forwarded-Encrypted: i=1; AJvYcCW9dgISBRZraZrEifzngRf/EpTwzwWZPLr3zdHZr+vjiiAmXynLon/YJkoY4k0HeiJIBM4EVd++VvwqTzLJYBAebVsjT+kVh9QZr8r7T63377KRNQY= X-Gm-Message-State: AOJu0YyuJA3x3heXfiwL9UFXIBI+WnHqmJGLQ7y483+YkcJkcdvsrc99 tjYG+8pUk0e4ZxRMo6/sT8mC+7npVwAQDWY/g46KjDQ0yKwKS4z/XSOqg1yzNco= X-Google-Smtp-Source: AGHT+IFesDthKKQJOFKJN5mrhDcAjnIOVckKhyM8WzR1KTGyuUBEn5Q3dR+OhY/YzKz0W/J5FKzIyg== X-Received: by 2002:a2e:7e0f:0:b0:2ec:56b9:259f with SMTP id 38308e7fff4ca-2ec5b3e24d7mr75758781fa.48.1719488398134; Thu, 27 Jun 2024 04:39:58 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:dc:7e00:7fe5:47e9:28c5:7f25]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8468613sm62081815e9.39.2024.06.27.04.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 04:39:57 -0700 (PDT) From: Bartosz Golaszewski To: Vinod Koul , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: 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, Bartosz Golaszewski Subject: [PATCH v2 net-next 2/2] net: stmmac: qcom-ethqos: add a DMA-reset quirk for sa8775p-ride Date: Thu, 27 Jun 2024 13:39:47 +0200 Message-ID: <20240627113948.25358-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240627113948.25358-1-brgl@bgdev.pl> References: <20240627113948.25358-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_044004_635621_848539FD X-CRM114-Status: GOOD ( 16.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski On sa8775p-ride the RX clocks from the AQR115C PHY are not available at the time of the DMA reset so we need to loop TX clocks to RX and then disable loopback after link-up. Use the existing callbacks to do it just for this board. Signed-off-by: Bartosz Golaszewski --- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 91fe57a3e59e..f4d72d75e8de 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 EMAC_WRAPPER_SGMII_PHY_CNTRL1 0xf4 /* RGMII_IO_MACRO_CONFIG fields */ #define RGMII_CONFIG_FUNC_CLK_EN BIT(30) @@ -79,6 +80,9 @@ #define ETHQOS_MAC_CTRL_SPEED_MODE BIT(14) #define ETHQOS_MAC_CTRL_PORT_SEL BIT(15) +/* EMAC_WRAPPER_SGMII_PHY_CNTRL1 bits */ +#define SGMII_PHY_CNTRL1_SGMII_TX_TO_RX_LOOPBACK_EN BIT(3) + #define SGMII_10M_RX_CLK_DVDR 0x31 struct ethqos_emac_por { @@ -95,6 +99,7 @@ struct ethqos_emac_driver_data { bool has_integrated_pcs; u32 dma_addr_width; struct dwmac4_addrs dwmac4_addrs; + bool needs_sgmii_loopback; }; struct qcom_ethqos { @@ -114,6 +119,7 @@ struct qcom_ethqos { unsigned int num_por; bool rgmii_config_loopback_en; bool has_emac_ge_3; + bool needs_sgmii_loopback; }; static int rgmii_readl(struct qcom_ethqos *ethqos, unsigned int offset) @@ -191,8 +197,21 @@ ethqos_update_link_clk(struct qcom_ethqos *ethqos, unsigned int speed) clk_set_rate(ethqos->link_clk, ethqos->link_clk_rate); } +static void +qcom_ethqos_set_sgmii_loopback(struct qcom_ethqos *ethqos, bool enable) +{ + if (!ethqos->needs_sgmii_loopback) + return; + + rgmii_updatel(ethqos, + SGMII_PHY_CNTRL1_SGMII_TX_TO_RX_LOOPBACK_EN, + enable ? SGMII_PHY_CNTRL1_SGMII_TX_TO_RX_LOOPBACK_EN : 0, + EMAC_WRAPPER_SGMII_PHY_CNTRL1); +} + static void ethqos_set_func_clk_en(struct qcom_ethqos *ethqos) { + qcom_ethqos_set_sgmii_loopback(ethqos, true); rgmii_updatel(ethqos, RGMII_CONFIG_FUNC_CLK_EN, RGMII_CONFIG_FUNC_CLK_EN, RGMII_IO_MACRO_CONFIG); } @@ -277,6 +296,7 @@ static const struct ethqos_emac_driver_data emac_v4_0_0_data = { .has_emac_ge_3 = true, .link_clk_name = "phyaux", .has_integrated_pcs = true, + .needs_sgmii_loopback = true, .dma_addr_width = 36, .dwmac4_addrs = { .dma_chan = 0x00008100, @@ -682,6 +702,7 @@ static void ethqos_fix_mac_speed(void *priv, unsigned int speed, unsigned int mo { struct qcom_ethqos *ethqos = priv; + qcom_ethqos_set_sgmii_loopback(ethqos, false); ethqos->speed = speed; ethqos_update_link_clk(ethqos, speed); ethqos_configure(ethqos); @@ -820,6 +841,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ethqos->num_por = data->num_por; ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en; ethqos->has_emac_ge_3 = data->has_emac_ge_3; + ethqos->needs_sgmii_loopback = data->needs_sgmii_loopback; ethqos->link_clk = devm_clk_get(dev, data->link_clk_name ?: "rgmii"); if (IS_ERR(ethqos->link_clk))