From patchwork Wed Jun 19 18:45:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13704448 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 75E69C27C53 for ; Wed, 19 Jun 2024 18:46:35 +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=XpAzXcNNxYpTdvfi+BDU0xCxyu40usRKC5CFcQJxaNM=; b=qN8d0iZts8Dz/emOA3gRATj9I+ 3MjfZx/7vaLyD2z4zSjBILosP3XUQL8BySZZBVYWPl7Lhj5W3IK1SOza4cOCyiArdP5tSG+ClG3pf qhuoC1HaGNmuO+Y71YlaDHIknW4j7H03yPWYGmcX/eTMWLejOSmgVVQEoM595fN4WQOoI40dfrfCY j5U72vN93Kq6yAW9gfqRsyzIrG/twzgN340mIVQfZiWnHIrTInLC3+TbceCefDdWXgl9dVZtQgvLg 8zfkLTTUAUb/rYzYP1oVJ1uI2hdxNU3/kDf9rJ5o4rHi/G6D2qwtJpgco+GWSVOJ+YFTR6KUvQiVV IoClAzZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sK0K8-00000002Qfc-12sy; Wed, 19 Jun 2024 18:46:24 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sK0Jv-00000002QVn-34q6 for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 18:46:13 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-362f62ae4c5so76192f8f.1 for ; Wed, 19 Jun 2024 11:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1718822770; x=1719427570; 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=XpAzXcNNxYpTdvfi+BDU0xCxyu40usRKC5CFcQJxaNM=; b=sixc0q4AmC9gGqDAjXW4TQs2pWCW6iJGaruS+ndKVvpNT//W7KO2KB6ElqYFG01MUA YpNTkX/saH0uARS5ZTNR/6P8CKk/lI3qERIfiH9BCTDfYYvTuWKn9cTPho0DF7GTMfhC Pc0MsSHsXv9Zv2PCoumf9iOrTSip4eFjpYHbFht53Qm5k6YCYFhBFJEe6N9khdERWXdR qdi95GFZaadNgxlgN3myK9eoOPUB3Enq4bZNB0V2qLokwt+5Tc5WT01DjoRpCq/tbQ8A aK8XLyl9BkxmelzllJ5KHIU65CWzW7KXOBVP4AIqnNLg2RvBB8qWokwOFsHFxXuYP52M ehpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718822770; x=1719427570; 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=XpAzXcNNxYpTdvfi+BDU0xCxyu40usRKC5CFcQJxaNM=; b=HgMs72LYqcVsZxSMluoEmPKBWaBV7QKt4uN/3VvO8yB8g0eiPhEcwrelC7y7h7gBPy l0MpASRELry5MARwLYwGPSTXFNIKuKFCAgNCc3HiqAqNHV6dvRJPeQ8ZUzluM5iYjEo5 SjVccny53GnHGdqeCN9wnfiS6J9b5y+SvyFggb8ToQV7VaOOCv5Ys4HdmCO4ZRf871/e h9AkoUFuldbVlsPKg8ViKR0wgVEaGTfeEiSz8jqN/edA5Q0H8q9crr4VeSsA7ulTAZ6q ITYtm+GtZfPQOA1Y6Cgo+AFctnJPgnTBQi//bZdvZHTv/UFVR4YH4aXnfsubvNWfAPjf SA/A== X-Forwarded-Encrypted: i=1; AJvYcCUwDvIN3uq+/Q/EALTHQpkaWyHQ/t77cHQr+4t/unkX27e0qSoucM4pCMGYSyUH07YYdYxL2FiZZvKspi20lNnzdZD7iLbr3GBE4KNlu0E844W+tr0= X-Gm-Message-State: AOJu0YwdqOFhkV2Qdjqu15fyWcPcJlLlWW6jqqy3M1YgXVM24OH+lNI+ Rz2GKmnGzLqCqTgUJVVWhNjS7vAwOFhDxWB4OinUC/C0lOcHqv3Gq6xzAoRbCAU= X-Google-Smtp-Source: AGHT+IHjF8mEpNI/gxyJaJmiFPRUJrocPqa3dz8xJy9EQvsllKfjPZWiH68BZOjcdaFrDoZZqxW6IA== X-Received: by 2002:adf:e390:0:b0:363:10cb:45aa with SMTP id ffacd0b85a97d-36310cb4a2bmr3050189f8f.24.1718822770504; Wed, 19 Jun 2024 11:46:10 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:dc:7e00:991f:deb8:4c5d:d73d]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36098c8c596sm7594156f8f.14.2024.06.19.11.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 11:46:10 -0700 (PDT) From: Bartosz Golaszewski To: Vinod Koul , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Andrew Lunn , Heiner Kallweit , Russell King 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 net-next 8/8] net: stmmac: qcom-ethqos: add a DMA-reset quirk for sa8775p-ride-r3 Date: Wed, 19 Jun 2024 20:45:49 +0200 Message-ID: <20240619184550.34524-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240619184550.34524-1-brgl@bgdev.pl> References: <20240619184550.34524-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_114611_814031_246DA226 X-CRM114-Status: GOOD ( 15.46 ) 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 provided callbacks to do it for this board. Signed-off-by: Bartosz Golaszewski --- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index dac91bc72070..ec43449d0252 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 { @@ -678,6 +682,29 @@ static int ethqos_configure(struct qcom_ethqos *ethqos) return ethqos->configure_func(ethqos); } +static void qcom_ethqos_set_serdes_loopback(struct qcom_ethqos *ethqos, + bool enable) +{ + 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 qcom_ethqos_open(struct net_device *pdev, void *priv) +{ + struct qcom_ethqos *ethqos = priv; + + qcom_ethqos_set_serdes_loopback(ethqos, true); +} + +static void qcom_ethqos_link_up(struct net_device *ndev, void *priv) +{ + struct qcom_ethqos *ethqos = priv; + + qcom_ethqos_set_serdes_loopback(ethqos, false); +} + static void ethqos_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) { struct qcom_ethqos *ethqos = priv; @@ -861,6 +888,12 @@ static int qcom_ethqos_probe(struct platform_device *pdev) if (data->dma_addr_width) plat_dat->host_dma_width = data->dma_addr_width; + if (of_device_is_compatible(np, "qcom,sa8775p-ethqos") && + ethqos->phy_mode == PHY_INTERFACE_MODE_OCSGMII) { + plat_dat->open = qcom_ethqos_open; + plat_dat->link_up = qcom_ethqos_link_up; + } + if (ethqos->serdes_phy) { plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup; plat_dat->serdes_powerdown = qcom_ethqos_serdes_powerdown;