Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2118295lqt; Mon, 22 Apr 2024 01:47:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXz0IF1LBO0bXVZJ1hlcY/9iR2YZQ0vgywzTBWNaJcHwv+MMwn6cAQY8XOaWsNxV9CBaUw1iv32o6kZ6qRBrhNIJBmNMVZwUBmYXTl+Sg== X-Google-Smtp-Source: AGHT+IGf4XsvRaU468HIw+s8JJLqPsnw6t5WlFer7LLmATyMdlmSv4xjc/5RksJu0e2DAEYIbup+ X-Received: by 2002:a05:6808:2819:b0:3c7:9fa:4691 with SMTP id et25-20020a056808281900b003c709fa4691mr8959637oib.52.1713775669819; Mon, 22 Apr 2024 01:47:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713775669; cv=pass; d=google.com; s=arc-20160816; b=MuNN1/v5s98RFNgo0b01zQbvom5GWdSwrTH/SYIkpkfw0nmDb2CrA60N7IlZukojPC tTxR3ai4Nf5e/Q5PKP9hBqGKUMaBh56IDEMewY7HSNcE4pTMoMQT4ygf6g71qa67jiTO nVHw1dujyHsxGdbL8XX1vHO63CNtjFC057CARa8IDOzUeRvQLkNMHFzmD7DUcRK46M85 9pIB3h4/8EY6nowBjGc3xZGnU2RDT+ozdbUINCk81sGHzG7c+HvpYY0t8+lZ3XTnUimQ aCVCV+D7oNn9mPpGJR+H/A/N4hlXBpu6QIETOV/MhzAXvP3U0D41JvLXf0I1wN3Q37/J eBpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from; bh=EpnQGTXm6Zy8JfkgRx8e1oPiU/wTR/oB6uquBV9JbEE=; fh=YVkujlvN5Y4Rrkj+By+pHgfHWTTXCIH/+pvMFJze4gU=; b=c8R2IsXcOYTNeJADQtKAANCV823M8C3EszneDequA1Solby+21cSRPjqvgSAvoZ17j +p6T9HrpdVrAzh4abXirfO5MVwl2cvZlEk+sgCBd47SeXlnxKxBPIWhZAD1U/ONI3ScK RkO2+T/RKLrUQS0kUVY6zDSa0gDSOT4bUdWy3jAqdw0mJv7PP9XMlrpy9wBBp0X7Rauz jF5FqCMGE3TKgs6Gy/CWXQoVVxyINXpiPvmWY/aaGRu0KBEvMauzztEqjYW+PwoPEwvB bu56I889XnyrKEN7nGze9l90AlMpQF5eLQFFqRgf44nAvIudNEREGZM3q2Lp48AzeyNS 6Bow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-153004-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153004-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l27-20020a63ba5b000000b005f7d3d4bd6bsi5807140pgu.476.2024.04.22.01.47.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 01:47:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153004-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-153004-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153004-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A143628313D for ; Mon, 22 Apr 2024 08:47:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9F0B54662; Mon, 22 Apr 2024 08:46:37 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 C5CA4482C1 for ; Mon, 22 Apr 2024 08:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713775597; cv=none; b=HKF9JjjD8V8TJpS7yVGGWL+vW9ScI6aV7RGYVwhXR8QCGkRBjMg7g7f1tlQGdOeRy45EEjpaYnMvyysFs9IBWuS/5sUajMn04WtwqxCTG2DSMspSV4GFsmy3RDyKWQaVMOu5ocB+FCCqDvn7Taa6d+bBAdxvhzcmhN0/TJPkZM8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713775597; c=relaxed/simple; bh=hbWncv3O5p+eXPs67WyDuajeTIZwF1P/8g1gar0nJUo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QaP6IhtArjiWEePOBp0BkB59QoG/TEKudKXNMJ3Tls3TIBxZr1wfyk3SF0R1zWNpVMiqunKQ76p0BtpFJAD7loGpe+iQjur5GZrN6o87061boBnjUFXHrD2QRjMfguPGd7jP+z/dn4WNzD1AcHuB6nSvnMV4GfhIWs50SPBz0H4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=ratatoskr.trumtrar.info) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1rypJg-0000ML-DO; Mon, 22 Apr 2024 10:46:24 +0200 From: Steffen Trumtrar Date: Mon, 22 Apr 2024 10:46:19 +0200 Subject: [PATCH 3/3] net: stmicro: imx: set TX_CLK direction in RMII mode 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="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240422-v6-9-topic-imx93-eqos-rmii-v1-3-30151fca43d2@pengutronix.de> References: <20240422-v6-9-topic-imx93-eqos-rmii-v1-0-30151fca43d2@pengutronix.de> In-Reply-To: <20240422-v6-9-topic-imx93-eqos-rmii-v1-0-30151fca43d2@pengutronix.de> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Clark Wang , Linux Team , Alexandre Torgue , Jose Abreu , Maxime Coquelin Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com X-Mailer: b4 0.13.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: s.trumtrar@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org In case of RMII connection, the TX_CLK must be set to output direction. Parse the register and offset from the devicetree and set the direction of the TX_CLK when the property was provided. Signed-off-by: Steffen Trumtrar --- drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c index 6b65420e11b5c..0fc81a626a664 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c @@ -37,6 +37,9 @@ #define MX93_GPR_ENET_QOS_INTF_SEL_RGMII (0x1 << 1) #define MX93_GPR_ENET_QOS_CLK_GEN_EN (0x1 << 0) +#define MX93_GPR_ENET_QOS_TX_CLK_SEL_MASK GENMASK(1, 1) +#define MX93_GPR_ENET_QOS_TX_CLK_SEL (0x1 << 1) + #define DMA_BUS_MODE 0x00001000 #define DMA_BUS_MODE_SFT_RESET (0x1 << 0) #define RMII_RESET_SPEED (0x3 << 14) @@ -57,7 +60,9 @@ struct imx_priv_data { struct clk *clk_tx; struct clk *clk_mem; struct regmap *intf_regmap; + struct regmap *enet_clk_regmap; u32 intf_reg_off; + u32 enet_clk_reg_off; bool rmii_refclk_ext; void __iomem *base_addr; @@ -116,6 +121,18 @@ static int imx93_set_intf_mode(struct plat_stmmacenet_data *plat_dat) break; case PHY_INTERFACE_MODE_RMII: val = MX93_GPR_ENET_QOS_INTF_SEL_RMII; + + /* According to NXP AN14149, the direction of the + * TX_CLK must be set to output in RMII mode. + */ + if (dwmac->enet_clk_regmap) + regmap_update_bits(dwmac->enet_clk_regmap, + dwmac->enet_clk_reg_off, + MX93_GPR_ENET_QOS_TX_CLK_SEL_MASK, + MX93_GPR_ENET_QOS_TX_CLK_SEL); + else + dev_warn(dwmac->dev, "TX_CLK can't be set to output mode.\n"); + break; case PHY_INTERFACE_MODE_RGMII: case PHY_INTERFACE_MODE_RGMII_ID: @@ -310,6 +327,16 @@ imx_dwmac_parse_dt(struct imx_priv_data *dwmac, struct device *dev) dev_err(dev, "Can't get intf mode reg offset (%d)\n", err); return err; } + + dwmac->enet_clk_regmap = syscon_regmap_lookup_by_phandle(np, "enet_clk_sel"); + if (IS_ERR(dwmac->enet_clk_regmap)) + return PTR_ERR(dwmac->enet_clk_regmap); + + err = of_property_read_u32_index(np, "enet_clk_sel", 1, &dwmac->enet_clk_reg_off); + if (err) { + dev_err(dev, "Can't get enet clk sel reg offset (%d)\n", err); + return err; + } } return err; -- 2.43.2