From patchwork Tue Mar 21 19:09:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 13183075 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FE34C74A5B for ; Tue, 21 Mar 2023 19:10:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230216AbjCUTKE (ORCPT ); Tue, 21 Mar 2023 15:10:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230138AbjCUTKC (ORCPT ); Tue, 21 Mar 2023 15:10:02 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2054.outbound.protection.outlook.com [40.107.15.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A56C1EBE7 for ; Tue, 21 Mar 2023 12:10:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P7/FWA/bI1QtRJzsCM0AVWzO/QOI1V9wHyStWJ1DAVDriMvWfspypGzt+kUFelkaXm+70gcOBX8+CrO9bfWewmIZzoafMiVU6LI+sgLlFoG9fr6NIXiF6pGG0eYsODQsuTvX9fR+kvQ1RmDSSNbIrZJiFAscf0LoOlVx0Wm5XZd7xKh4LDtdSjbTCdkm7O6AXeAhESLtIjkhRo4F5z+331hqo8rUoOkJcdCj1ibkUw966FGubpvFLKpHtxQ2tUiz92IVTjIbAUTMYGuVGiVL7vrwFv6J/e/7SVLtHb/KFqK02mkTfCcohqk7E2v1LDjPlgDdKfCSgoFIjjqiGjTK6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yl/Nal0PpgBFmmyQJ3enEWiLymBs3mGdmq4D2SJEd18=; b=JbKzMqSj7DX4UBd3MXa1zKEMBPs+DS/Wb1pRnVTPuFQwDNxGyLED8wXhKrmEf5819ldiuVH5K+8J4wcrbhLy/UBTLFSu/SqfO3yIRV/995FXze1m15AU5dw4uiRjAbVJK2GkMfI+D4/XktsEFvOFpF24S8ONtnhoZak9yY70zx4+dOP+6xt5gC8GGh97fbiVN7cX6cZXldD8Co0IGi8KsV8zu+FTPT1yZaknBZFTO9Spfai1kk4GKrpbvy5SiHnJbDzBZHPouBGdsRUABAjPrYuf1e8YFNscu+85kJ0+eyqf/2sq0gMhO/cSkbIy7nUraoRTGOn1E1jIBZcFkt+M/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yl/Nal0PpgBFmmyQJ3enEWiLymBs3mGdmq4D2SJEd18=; b=SkzoeoiRzwkqJkNH5jh59OEKQbHNWshdySSSax0lq6NgUa4OKetETML+We3w9BJ33+Eq+0HKugENYiiq9FUDYFUu569rCe1KlLhtHwneT/c+OC976TWi1c+YckQMj5UDCzfwfWSU9of+McH2DXJ8jvnKTPJtrHiBO8Dizj1HnFI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) by DB9PR04MB8348.eurprd04.prod.outlook.com (2603:10a6:10:25c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Tue, 21 Mar 2023 19:09:59 +0000 Received: from PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::31d:b51c:db92:cb15]) by PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::31d:b51c:db92:cb15%8]) with mapi id 15.20.6178.037; Tue, 21 Mar 2023 19:09:59 +0000 From: Shenwei Wang To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Shawn Guo , NXP Linux Team Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Wong Vee Khee , Jon Hunter , Mohammad Athari Bin Ismail , Andrey Konovalov , Revanth Kumar Uppala , Tan Tee Min , Shenwei Wang , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH 2/2] net: stmmac: dwmac-imx: use platform specific reset for imx93 SoCs Date: Tue, 21 Mar 2023 14:09:21 -0500 Message-Id: <20230321190921.3113971-2-shenwei.wang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230321190921.3113971-1-shenwei.wang@nxp.com> References: <20230321190921.3113971-1-shenwei.wang@nxp.com> X-ClientProxiedBy: SJ0PR05CA0208.namprd05.prod.outlook.com (2603:10b6:a03:330::33) To PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9185:EE_|DB9PR04MB8348:EE_ X-MS-Office365-Filtering-Correlation-Id: 9be0a17b-9435-4dab-1ba3-08db2a3fdcff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ae4UbhwdaTC+qwpkquInJUgCqjDUYzw3TEyPz/XfRsHCQZ7Bdap7ra+OatuvoVemeUlfU9fEvbsHnzj14qEHBU9JFo0iqS6W6/Bx8nsZwzglqbBT+nX7JP1w+QhhaQ0Z/uKyWn41LdpNnK/2dIL9nl5U8GeYCEyibRrpVuQSoxjaMV1Xeyql5LyaNWsOK4yOOTPJlzLlDanIsn9EFlTHfFRfwV90ZNnjb9IW3ALleR6onmH5oDjD+BOxIkQ6gdCM7DBvb07Tj0u8+17kW+7inQC3VofBdHRxkKEcTasJLWKI3NrKnML0ZutrEfcd90gPgEKHoEBGILV3pIsNbdFRbYI+XqWabX9vkoJ3NfXJdLpgYRdu8tl4u/9ZUseHlZDDOESxZok5rHGFIwtwB0TTsZyUhS8pW8h7pUqYP+mXEVN5lz3NpdghSKmF4QJKcUQxnbajSUBS5Zm5iDz2TOMs9YPEJBTAt0shzLF/+fpo/GXFyXi74V0mlOQ2wx2VRzccJ1jlGGCSFQcSiz+K/ydkOTYgLaOBy88hpM1hAh1SJhRV2pKMA3e61GMRUeXl7WGNkxjpcCkuiIsktgbDD8uBkwyrPW61TtoSl+3rDhfIBx5r+HCKi99oh+aAKJO2ygnb6Dhy74rj7QWzlgrLToTUQMXCD0wSijhcB09CxniC+wjatmbyHM8X/TqprdvM+2YpX6+UNAdvs8xUXaO3PVp7WA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9185.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(6029001)(4636009)(39860400002)(396003)(376002)(136003)(366004)(346002)(451199018)(54906003)(83380400001)(2616005)(6636002)(52116002)(6512007)(6506007)(6486002)(478600001)(7416002)(110136005)(26005)(6666004)(1076003)(55236004)(186003)(5660300002)(316002)(44832011)(38350700002)(38100700002)(86362001)(2906002)(8936002)(66946007)(36756003)(4326008)(66556008)(8676002)(41300700001)(66476007);DIR:OUT;SF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gWcMcEHv5Glt0ASEEymyGEf+n1klRoN8aNlbl6rz9tG4jItF/9HST4E6jEi8DcueQLUVsfpNNFw/LlPS2mAkp8BTzBitxiyYLR1BaikqSZMYP1R3mEvJKFFC2X8Cg8VqHh0a4DRuctbF6AJKvtBO8uFStoMIvxA4TE6uXh86cLoBY6fqG7u4lGrPQTzoT5ffdddZuFfyj1R3Al1+ncAIaQ0otMS7vKxONRX1RTQTDNxhDpo4j/SijHbiJShJr0VEOrA/rL2lSr83vljtQO0YKC0FHoap6lUfZ8xOigehToPnuDLfW8kauGtyyqVTG+BvRO7Sk8864f0N5SlSbjqUSinSrqVSSAJ8+54SEYijgc1sM63noq17Ql1XcJXLKaHnbY7UxJXhbB6tt+//GlXiLfzgNoAYTzOhiwA1+cYQE49mfL5pou5p8msSDpA1lLq61wjzVXLa8DetoM8mIIJjnAZQ1jOQrDkP8eA4TpRRC3xe4fbWjvweHA295VLRJBBRmZZ3YwGcKGrrdrewCjKm9a4lxX2arl4/Tr+ulCrn8NO6vi9f7jokYSUM98I+ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9be0a17b-9435-4dab-1ba3-08db2a3fdcff X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9185.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2023 19:09:58.9738 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yi03taI5uFGHu+9OQlEzoztUBf44vGLBJwshl1qay9L3K8yRsjssIABGXpc8Qf0OjVzUarLthS1vN+zKqwDknw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8348 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The patch addresses an issue with the reset logic on the i.MX93 SoC, which requires configuration of the correct interface speed under RMII mode to complete the reset. The patch implements a fix_soc_reset function and uses it specifically for the i.MX93 SoCs. Signed-off-by: Shenwei Wang --- .../net/ethernet/stmicro/stmmac/dwmac-imx.c | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c index ac8580f501e2..3329150010ce 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c @@ -19,9 +19,9 @@ #include #include #include -#include #include "stmmac_platform.h" +#include "common.h" #define GPR_ENET_QOS_INTF_MODE_MASK GENMASK(21, 16) #define GPR_ENET_QOS_INTF_SEL_MII (0x0 << 16) @@ -37,6 +37,10 @@ #define MX93_GPR_ENET_QOS_INTF_SEL_RGMII (0x1 << 1) #define MX93_GPR_ENET_QOS_CLK_GEN_EN (0x1 << 0) +#define DMA_BUS_MODE 0x00001000 +#define DMA_BUS_MODE_SFT_RESET (0x1 << 0) +#define RMII_RESET_SPEED (0x3 << 14) + struct imx_dwmac_ops { u32 addr_width; bool mac_rgmii_txclk_auto_adj; @@ -207,6 +211,24 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed) dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); } +static int imx_dwmac_mx93_reset(void *priv, void __iomem *ioaddr) +{ + struct plat_stmmacenet_data *plat_dat = priv; + u32 value = readl(ioaddr + DMA_BUS_MODE); + + /* DMA SW reset */ + value |= DMA_BUS_MODE_SFT_RESET; + writel(value, ioaddr + DMA_BUS_MODE); + + usleep_range(100, 200); + if (plat_dat->interface == PHY_INTERFACE_MODE_RMII) + writel(RMII_RESET_SPEED, ioaddr + MAC_CTRL_REG); + + return readl_poll_timeout(ioaddr + DMA_BUS_MODE, value, + !(value & DMA_BUS_MODE_SFT_RESET), + 10000, 1000000); +} + static int imx_dwmac_parse_dt(struct imx_priv_data *dwmac, struct device *dev) { @@ -305,6 +327,9 @@ static int imx_dwmac_probe(struct platform_device *pdev) if (ret) goto err_dwmac_init; + if (of_machine_is_compatible("fsl,imx93")) + dwmac->plat_dat->fix_soc_reset = imx_dwmac_mx93_reset; + ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); if (ret) goto err_drv_probe;