From patchwork Mon Apr 3 15:24:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 13198602 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 37A9DC76188 for ; Mon, 3 Apr 2023 18:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Sz7f0b67orygmLTb4Yd9ICgoLLfZHhcl+Bxpk6eACkY=; b=cnazDaYKtdoXE+ /RneZ0p6K9awHv5rCchCv0hJUnBaSMsmFgCLh5CPLqwcDDgNuSU7z5wkZFFl+Io6S8sNwnjqnZkFT xGFxXCLUbP1QqfT12lfAfZLw9kjXjf5SN8PhkVcfaAuDh7tZ/bGb4+lfhsojiw6G7X+ATV+wsvZRI C2uZhVWFvjoKZUa64PDbESaqUJWKASpKF9BMYJooGvNu6AsYHul0cUKbGhDMy1paFZ1Pa+QVdzhAH oU56Ouf+LdKUBlgm6A0cmjCYRUAzQN839zXXZVLPUlncGAhzGZCMY6jn/Ac/QuptCWImI5xe6fvS1 hKXvKjx96miezn9Aq5oA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjPCL-00GHwL-0C; Mon, 03 Apr 2023 18:46:33 +0000 Received: from desiato.infradead.org ([90.155.92.199]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjPCJ-00GHvN-1M for linux-arm-kernel@bombadil.infradead.org; Mon, 03 Apr 2023 18:46:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:In-Reply-To:References; bh=GxGReCJlmTHaMmHuzXzSEQ2BFfUN2YkWJccVtTR7tIU=; b=DTuGRQZBq6NiRqd6GCigE5efmI WHirjoa53xddVoFG4C7G9qjXiJB6e7GZBCQBLX7wSbEC6ICLiWk/a0CBks5F/7lVaE7y84YlOQIM2 1QShfqbRC6dU7a/Wv5gBlavzP19VMnfPTy9ixuZ0kPRMcXm4J9d+rVnkLfBsExNFU9/9xcA5t4k4V drMISB9LNFqmChsasjg7LIvRmNIo/w0b1GKMpHxLXvtkgUCbNVly7aDZWP00Uo6/GJQ7RNCdeKRwu /JZMozl0vHSabXr4tbD8YyCZGUXD8HGND5vcLZzYfZR60gCO8HVR3BojKRoOnzbCHwImht+V+9T67 KCGL5xKA==; Received: from mail-vi1eur04on0621.outbound.protection.outlook.com ([2a01:111:f400:fe0e::621] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjM2z-008uXs-1I for linux-arm-kernel@lists.infradead.org; Mon, 03 Apr 2023 15:24:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZUAAaNeK83i4QJ34PUtCkf9M8M1oP99WIAsQcWQHRpXA5e3JsXPZWSy8xr04I6emK6CN2nIaIxyeZLjdxWGdZdZlgr0Ph/tSFOUo9OVxjRdesHyWqcDxYSog59KlZfAvkuKeMGf2A6b3aXPTDdw4EuJZmH6p80UlOuZZJefO5W2uvZqDAZwp48f3PJB0Lim1ifInAUAiYRqHGHlH6y0x0zYFMlbomr3h5HrALSR/9eoXcoLqXA5s4qqg8LlSlhERLQ5MB2y9LU3Ooc5kXk2hB9jIMPTsEfQDlrlgEhHEVIaq2QObQEHy1nd16zUGqfCFnOdbjllOkedgAv/vE0xcOw== 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=GxGReCJlmTHaMmHuzXzSEQ2BFfUN2YkWJccVtTR7tIU=; b=Wb9GmjBJ/MiLbUDLrjVT1crEyMp4HePQCcvfLhRcIV0ltmHIP6nF2gWq6hgV6XZcrSaF4/WURQJGVGjTCBg56PEx+3x6K65BqeGYkifKwWsVFhUr8oCC7ayOHroQAklmHf+Gy3n+pFvddJ6ZbpgYIhXJQb+KCRZPSv0RpKNTZK0OUTrL9TXcf091GmzaJkfduKFvg/s6CfnhJFRt1+adj+Fr/l2GB0uHiNQV5uZiqFWeyGQ4cta8fltZy56U1PQKczLobNdZLfwFV4uzvUeNkX96niZ+WHftdpsKwMgAucwpIEbd/tEXfqj/10ffBXfoTpoPLJUrCyC5+MUTHDptNw== 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=GxGReCJlmTHaMmHuzXzSEQ2BFfUN2YkWJccVtTR7tIU=; b=nhxdOlhpnkk5Gp2pF6/lIZotSfCf1Mvci0GFKaI5DbqH8zE1VTAqLXzxBGqe+vrA9vYD/IgAUYJ8JYR26omEGhfIpCgwQcvWt7bgF0tONHq6qCQ83k/YR76uJZQZ7qtcrLDsrjUxIeHRJ6jtjCNjp/N8fQZLOa0yyiJgsjsdblI= 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 PAXPR04MB8717.eurprd04.prod.outlook.com (2603:10a6:102:21c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.33; Mon, 3 Apr 2023 15:24:33 +0000 Received: from PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::28fb:82ec:7a6:62f3]) by PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::28fb:82ec:7a6:62f3%4]) with mapi id 15.20.6254.029; Mon, 3 Apr 2023 15:24:33 +0000 From: Shenwei Wang To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Fabio Estevam , NXP Linux Team , Maxime Coquelin , Wong Vee Khee , Kurt Kanzenbach , Mohammad Athari Bin Ismail , Andrey Konovalov , Jochen Henneberg , Tan Tee Min , Shenwei Wang , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, imx@lists.linux.dev Subject: [PATCH v5 1/2] net: stmmac: add support for platform specific reset Date: Mon, 3 Apr 2023 10:24:07 -0500 Message-Id: <20230403152408.238530-1-shenwei.wang@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BYAPR11CA0104.namprd11.prod.outlook.com (2603:10b6:a03:f4::45) To PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9185:EE_|PAXPR04MB8717:EE_ X-MS-Office365-Filtering-Correlation-Id: 59b657d7-73c6-4647-1a0e-08db345786a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e0cjH/TyqJATd15/dtoKEfyo1vlkEzTs6YYYG8VHUfQ4N8fJN7tHZm+nzLKoJCQLWtJPEXhDEmuaEVW4jqJAwDQy/72QRyQFQ9dRss2MmLPbvfez5CMyEtji2wxTl3kLnytEpOA5cLsP2xtxVxUayKzSi33k3UYOtHHg1vr+iFTD2rtrm3Tqw8iWimDsS1MjJh3aQ7rBlQXw0ACl/1IQqSgMftR+4ROs28hiuCTOeYjKKpO4BCxwOz78ypVn7M0WM319JhTywMeB+4CDTIccvDRZ0nHRe+WTgut2rHdByQWCjLrAAEu7NRH1o/zXbNAkuuGbI8SV9OGlnfYIPgU/dxqngenm/FQOgIQCEnoWcf9MI3ZqRV6IePm6VNR0E9TU4M1GM4rPT6k65pUMav64M9MmC+6BsjDFKCFdtaVfiUclCpwk26HoWLxrQd/as7gvz9pwV2Ehmik+YuCWdZAXTtjY8GthVfaBRkW+hSJPn+hLE/TnolFAyXLBaLbh6QtAg8VYaEve2uRsy8Y5/wU0ck7XoMpUxkVpAuhTNZMz0aDDN9ZT3wP1p0U7lEXUiofR3sjuGxS6MpO69cGl69fwsza9dhCmS6psiuCMSW21axmygwW3Bhys9azquZ5Ms6CR 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:(13230028)(4636009)(396003)(366004)(136003)(39860400002)(346002)(376002)(451199021)(4326008)(41300700001)(38350700002)(86362001)(38100700002)(52116002)(83380400001)(55236004)(186003)(2616005)(6506007)(6512007)(1076003)(26005)(5660300002)(8936002)(8676002)(7416002)(44832011)(54906003)(110136005)(478600001)(316002)(66476007)(66946007)(66556008)(2906002)(6486002)(36756003)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F/4YqvPIGoPIVPVwUDV84YgFlwLeEq5h4TDSv0rsG/sDV2ebjl22O/h3KvSc2vmgNIb6WgG0uJ5NwwthGXu41Mmc5qcJ92vP+HxwhCqSoJHsMwgqg93IK2K/9uaFB80f2D+2i9ipEvaJmLSEG9wCbbbtdAhDGUrYffJv6Ez4YoujI7o0BkMPI/foh7ImPK9PMRIssMFVC6hms3A8O1aXFHDCNfjyA95nXHR1yQACGFgVRGK2gELmwo81paIY3RLdhZrgBHJK9tVNM18F9CoSZ9bXQ4zHMAPplEWfl3krqTOIW13MHAUO1635TJoiDY/fZ2WOKEx/RIkqlIde0X/xTOCiTepEWs6y05//pf6vsRJl5jVmDRw5w22b/nEJxxH91ccRNxEK8SfpTmCIBY0A40vU9l2bFzuIiWga4qoCqj4z+ZXaSLT1fE03Ec/RE+NZ4Tm+Pd+JqnLnA8pkYj5axNjnHOciQnFzB1O7rsh6m3JWlme24vlYGN2drTui3ru/VBKFxmLJVP72TWJvMB75W7xslBHxy34kvIgt2zKBmdkLwG7NoSNpZ3BSNSev2QZOoc3pbxuBAPZd/miom4zzZfHxNv8VL7ZBv7R3VCyU2jvnNJW+Bhikg9x+eqWtCXG2rvrGhBd+QAVhflFAX9RvNL8jdUoi5rCb03bDqrIXoJqnA5715pxT8IGRvVQNJAuDLmO/50PsdBGJO+dG4uQUpRNnIeAbv2MooSRkfOMyeIJk0u2dud72OX/LWq+o3B1TCpQkRKgcztpxVy/dhpqqcS+suiWqXSpaTOUNcgUI29ZmfiLdYTVjiPZSxcg/oTBA7KUMctoOSAF/0luNPzki3lND1yWEzekrkAhYT+/TMeRN91Dl97CjYSY7m4eoL0QjOGFDv97Q7/zyGOobUNk/ghDYfAaPemND/WN/QDk69ez/dUejQ3tWiTtYphA/E5kIaP9mMCBzKMkft5vM8+o9MmG0N0b8wNjKqYhGooTrrrWbGUQQaRAfPi7AVx47J8aI9s9JpzB35VFb/JAIBXMayj2deJrsERaSsDHJjKaxvSefcsFLLLSvcVZimLz8FJJ6qfZXgKB8ZpeIjNUlXrQBKaFdQM15tTdixc/ZQUAzvY65rsMQyQRelKMfVrQDXYzgOYcm9f9jSys8oF9NSfx87z3pbPz5g5D4LMG95tqrigE5VQ9etJVNETqtvuTS2D661/BKuUb2lR4MCFrKwatTolnMQNaFrDBO1qh/xyLKBamHPtNstl7uQGmhpS1HCe/Jt+5CR+PRk/dmF3+zA2ZRAueRuhDeTSEVPiSnIiMA/tMnC7QDR2SDTd7rPCoSn4dtFm8s8AUszMt4kWIeLoWqO2M6wgfd9fXEz2pwA1I7K9ZlErKXFm6N/1ictas26px4q2TFMpWuh8cGw4pk7DjrWDZI9CcWsn3n0XOWliYMC2pjnkwxTaAPpsfgSTW36FBAPddER3T7G3XH/Zd3yqSrApu/sNBxUxea1+H3G7S67qvC4cXXPNzi+l/ZlxGMAMDAz7xaE/NW5DmHRlpFziwXltfvgxXn+Jm1tL/ugencftFGqoW8GLDey9frwoxneX67 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59b657d7-73c6-4647-1a0e-08db345786a7 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9185.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 15:24:33.1797 (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: L4utCq2ZMVQ7Cnesv68U4X7XKXfzzPRxGGRLGYXR9SLB5hEgAuws5uZMt9E8L0jQ9Yuyn0CPQ2Xj9+xFiHpsZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8717 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230403_162441_640927_5901F1B8 X-CRM114-Status: GOOD ( 17.00 ) 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 This patch adds support for platform-specific reset logic in the stmmac driver. Some SoCs require a different reset mechanism than the standard dwmac IP reset. To support these platforms, a new function pointer 'fix_soc_reset' is added to the plat_stmmacenet_data structure. The stmmac_reset in hwif.h is modified to call the 'fix_soc_reset' function if it exists. This enables the driver to use the platform-specific reset logic when necessary. Signed-off-by: Shenwei Wang --- v5: - add the missing __iomem tag in the stmmac_reset definition. drivers/net/ethernet/stmicro/stmmac/hwif.c | 10 ++++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 +-- include/linux/stmmac.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) -- 2.34.1 diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c index bb7114f970f8..0eefa697ffe8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -87,6 +87,16 @@ static int stmmac_dwxlgmac_quirks(struct stmmac_priv *priv) return 0; } +int stmmac_reset(struct stmmac_priv *priv, void __iomem *ioaddr) +{ + struct plat_stmmacenet_data *plat = priv ? priv->plat : NULL; + + if (plat && plat->fix_soc_reset) + return plat->fix_soc_reset(plat, ioaddr); + + return stmmac_do_callback(priv, dma, reset, ioaddr); +} + static const struct stmmac_hwif_entry { bool gmac; bool gmac4; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 16a7421715cb..1cc286b000b6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -214,8 +214,6 @@ struct stmmac_dma_ops { int (*enable_tbs)(void __iomem *ioaddr, bool en, u32 chan); }; -#define stmmac_reset(__priv, __args...) \ - stmmac_do_callback(__priv, dma, reset, __args) #define stmmac_dma_init(__priv, __args...) \ stmmac_do_void_callback(__priv, dma, init, __args) #define stmmac_init_chan(__priv, __args...) \ @@ -640,6 +638,7 @@ extern const struct stmmac_mmc_ops dwxgmac_mmc_ops; #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */ #define GMAC4_VERSION 0x00000110 /* GMAC4+ CORE Version */ +int stmmac_reset(struct stmmac_priv *priv, void __iomem *ioaddr); int stmmac_hwif_init(struct stmmac_priv *priv); #endif /* __STMMAC_HWIF_H__ */ diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index a2414c187483..dafa001e9e7a 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -223,6 +223,7 @@ struct plat_stmmacenet_data { struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES]; struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES]; void (*fix_mac_speed)(void *priv, unsigned int speed); + int (*fix_soc_reset)(void *priv, void __iomem *ioaddr); int (*serdes_powerup)(struct net_device *ndev, void *priv); void (*serdes_powerdown)(struct net_device *ndev, void *priv); void (*speed_mode_2500)(struct net_device *ndev, void *priv); From patchwork Mon Apr 3 15:24:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 13198331 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 5793BC77B74 for ; Mon, 3 Apr 2023 15:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tmeP+hKg2Q8Kjh8LJv/uL4bQqRSg5gqalt4ITh8kv9E=; b=OQ47J9ouTET25U LDvCDQYWB64fxz+TmHm40CJSf3vIOT6fcMQqof7FV8zog8wIlKN3FtQY7Iu+gOLCPQXpX2UwTcXeD diJQqBRklXovyfoRPLzKSLJlBn3ImejoPag4uI7JcXDIh7mpCkHeeVR71h+ZvaT4JGNZWzoZ6msTs 4eeBL9rVnmEp+U+b2WLchDJo3J1zze6pG4b847Ve+YI3rxccsKY6fEiheEn+f1d4dSVsBZ760f6Kl 5GG/2bas1ZUVyzYe1nI0c53n16MMB8kEYt2/cnj+Se6kFfRL00kHGu/s80rzEYm1hScPjDoTsyPvk J4tq2Ux6KJVfq7myOq4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjMIZ-00Fo3J-1w; Mon, 03 Apr 2023 15:40:47 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjMIU-00Fnzj-2I for linux-arm-kernel@bombadil.infradead.org; Mon, 03 Apr 2023 15:40:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=np2NzjseM3zTUSfAp9YG4eXtEf7ic4w8hcs+Vz+qMaI=; b=AQgDiWx2R0RT3skW0DVt+gDkh4 JSEJi8y6aIrA6vxpq3BnKOdhb6WSIoF3B22xm8YzOHMHM/HPbcU4YHr0FSAm8WBrLvuf8xuqtKtrh VF3t+1wPdiEt9TZuXJjNSJDvLCNfiM5/lufSrMbHJ5g/H/tfhqF8soNCMK7/iz5JCkfo8BDd3SKVH BQwFur2z+NarCs+B3+19QlOInxAqe8yL02uD7NetSw4NPpQt0u8UZ1NigFJ3f1OapEtMOwlLP4c2O z4TKjXf1qYWD4oQ2ieFesYT8wRWWMg9aDi2TH9tn+6fnskGrOaa+9GWuoF44ZlmbwldARt5XDpa/c wKhIVvnQ==; Received: from mail-he1eur04on0620.outbound.protection.outlook.com ([2a01:111:f400:fe0d::620] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjM3O-008uYq-0P for linux-arm-kernel@lists.infradead.org; Mon, 03 Apr 2023 15:25:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VBrak9OT5ScEhuxqti2RmEakF6/vkiwQFkbLh5G6fD6gtMYhpCg6ddlQxtSmCp9+cRuvqi8qrHlDyRwym98+sZIiI/ufmhXJ39SKivd7pMGNfEcMAHiL3QJdzMy/zTFpRA9LEdYookWcveYG7W3sUrkcWQfY8EXihMSM6OEqM49CDKAzvDW9vva7pDf224+SSczr7sQFH5vbqn6UtPDDSUW3KhuDLyhwFHjzpcR/AElRTFHhnRe3WleAjFtNXrgYViFCB2MVqeKbAV+VZCWufvRLy9jE5j+3Ke/eLtsmU7UJw9jOvTDZdgRpzjq7oIK1b+7NnpSACzmyhNOAdpI0FA== 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=np2NzjseM3zTUSfAp9YG4eXtEf7ic4w8hcs+Vz+qMaI=; b=ZhoVdFnn5A0+eA8IfjmKom41EC6m0fNvu6pvqR2OA/zakZG45dn9DvAiH9b/qJVRXxkNkPdkVJlrgJfStUSfLf/7qT9Ej4Q6gpTWIayJ+WeZWDy40Jv+QNiyPO5neMBc6OXRxNiDOA82kdgEBBIKSw4GWSRunz5ksH03h3adp5JORaEoPUrWb4qjxbFS0tY6tbhrwteuNkSqV4Wv33/2OJqxXhJXn5kKZxePfYh5W4KNLIWsQZ81jhZa7QN2Dfxhfy0Ykvivg573QWhP8n0DUuMLrWFxB/Y4NHFISBmD5Hc7C3iTk7aLmSex0V11N32js9iw19HFrHyoX/MXniawvg== 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=np2NzjseM3zTUSfAp9YG4eXtEf7ic4w8hcs+Vz+qMaI=; b=AQb6liTqE2TryVBN6Slc49Addd6FcCJT/nti1sUQ+Iw6h7TbGofI6jZH/S3GhYAR/HB6oPtSa9I0nkrtK6yaQjKzYEvXVIKoO18tC2DnbmblEvaf2jOUWeqDO8fstWO9ll5KIm6F4GOjVlNz5pvC5UzliSZWR/NmRFO6iEDpFFE= 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 AS5PR04MB10057.eurprd04.prod.outlook.com (2603:10a6:20b:67d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.33; Mon, 3 Apr 2023 15:25:01 +0000 Received: from PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::28fb:82ec:7a6:62f3]) by PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::28fb:82ec:7a6:62f3%4]) with mapi id 15.20.6254.029; Mon, 3 Apr 2023 15:25:01 +0000 From: Shenwei Wang To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Fabio Estevam , NXP Linux Team , Maxime Coquelin , Wong Vee Khee , Kurt Kanzenbach , Mohammad Athari Bin Ismail , Andrey Konovalov , Jochen Henneberg , Tan Tee Min , Shenwei Wang , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, imx@lists.linux.dev Subject: [PATCH v5 2/2] net: stmmac: dwmac-imx: use platform specific reset for imx93 SoCs Date: Mon, 3 Apr 2023 10:24:08 -0500 Message-Id: <20230403152408.238530-2-shenwei.wang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403152408.238530-1-shenwei.wang@nxp.com> References: <20230403152408.238530-1-shenwei.wang@nxp.com> X-ClientProxiedBy: BYAPR05CA0076.namprd05.prod.outlook.com (2603:10b6:a03:e0::17) To PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9185:EE_|AS5PR04MB10057:EE_ X-MS-Office365-Filtering-Correlation-Id: 9489415c-8bec-4af3-74d9-08db345797a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: znF1uoiZFSGG/yycHSL/6HzXy7z+out8QH9CgsFTZFtryuwmThF/4fBxx+KgOhR9nS65eRClDbm+FPF5DaFnemG9mfFJw08R3HMTJSs0Waj8YrTY4QwMr5FtvcP+seQ1gPHE+ZWaBvh0eQyIO74rAu+WXynT90UWRfHyfxlV+cfYFY1sX+yZxCrjDV4fFyLOEW8mYz/rD+VnfJ42uwgBd/LJxalu60WTIa9h85Rga+KaDyZQPuHWmN8+5NHvt25fyJHBMPyj69WuZ9C3jJitFrPR0IN1pf6UWkkLBCHB/8FsIrngyT0tRtF6JAvaAY2J3A1pgYJYd9Lu19NKolz9xQAKWmD4UFEBereSRfTLWYCO7MgI7fHssyuoFfueZrAL4yxHS0KWhOQ422X/5QwlCJ1lmRin3zMUckgC3X+5N7Qb70gAMRYSQ0JZXgFOv4asXYceGEb53NEHj6NBlrGWyQ3NYFAiK+jyxGRmok+KnE7Cq/rdJEt4PE/RKG/pkxliKkSsgqGREPdqn7YI6SAn/zbxbwxb0VqSrUlucbCicbagxThrOLssJ+UUhW0KCaNfZkhbBMoc+Y7j2+VcZpmIVEfVTI9B10/qZHloeLoBj8LwjIoxMK3RvXRcfYNwphlD 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:(13230028)(6029001)(4636009)(396003)(39860400002)(136003)(376002)(366004)(346002)(451199021)(86362001)(36756003)(2906002)(52116002)(2616005)(6486002)(186003)(55236004)(6512007)(26005)(1076003)(6506007)(44832011)(66556008)(8676002)(66946007)(66476007)(478600001)(41300700001)(5660300002)(7416002)(4326008)(38100700002)(38350700002)(316002)(110136005)(54906003)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hIK0mfmQ0bi1OeVyLSMLnbD5tamRro1nWdr9M13nNx+4/IqVuxVjmKIY3AhsvNvTNb6bDX82HZRGl+fdaXUcW0hfn1rhSppfYiwTQuRKdbiz07I53DVERgxV/h3j/Oc7FPKw2WT5dgJ1TEIKiP22p1NBybbw+SjAK9TukUxx4DLBWAzpchhrFCEtByYf/0vVfXXbkVQUNqy0Oo0gJ2B9jH7jccUmQkJuLM8KNYkza78QzyjzEUQKd4paA2nEE4QXLrGqTuQpg2b4mMkJcjcl7Jst+rkdhfBL3i5OJAMggaZguCUYDjI8SLXcFZYWBUAotCMTKE53zyCeqEQA7NxYz6i6UgqjbOz2+1998Zh5ralJbzfdKZcosCQRs7LS/Hv5NF91s/aPzeCmsj9YCao7ufzufQ/1RCcz5kfcSQVECFNXoq4giM5iB35YpvdYsg56gBA3HzBaVkVNjzroV6fmQj0RM4VLGPyeq5b3WbMhBnLsPGQ1hs2n6WhVfUvXIHfWANVOWp9zWOx9Ydt+A1Ck+80+aJFVoBVK9SHetdQ7KvtIubgv8nIWWjO2ytf1IfwetFbLwJpeYCGLSWxAHmMUlvo3Ts+sjAAa90KiBDHSe/UTxPPVTC5ctruaBEnm50A9gz3S0XeF9xZFdZqIIce4dCjTrpHTxZv4bPLx2KYHEoxIOGiXEXQ0Td1yHSr378TQFIJYRYz3IIx4nQGxNW+qfzhlgKepgkFXJwn+zn9dPlhgciOIwj5IuYvkLXSSvcnGV2Kfv6394O4xfAsX21Z0EZLRXQqnWj000apc25LCvo5ia8VTK7Xc7ecyk+fcaPFqFV6rN8U7pPoVHKBwNHbTWCtVD2idDdssJbEb7PeLTagjzX54qk2X51dXOqde0xXh0vPy+SvN6uXq2FXFrUcvV7u4cVXoE2doWMY2f9HF0hkjQ2vzbvdDi46s9NuIhOQpsMy06Qi/CzkvdAsZwmbInJOKW+Y+v9hwzYJ4qLbLqpHXmgog6fTWu5SVgT9kcWi4+F8rRsJlUMN9ECovSfafQBbw1xLs1XKR+T7/u2jY8VDOrAU66MNc9T9VNf2sRLbmV5nEN4gDtdtse4ONUZpf3XYAW6cqXnTc2X0pswEF6zvn6+Do79Jwx7RbuHfFJIVqVv+PPt9zE2O07VjVYT7Ib6EXbbtZb/dQtVezg7inKUYNw66XP9zOaA06D5H30YyUvAUKNa7gkX9QybZDNztSVXia/j5+etGXAmn54N0kayssQp0k9tLaESGt334fjppAorv8Yfzk3jCZd1sD5+w1EHd/PuX9faObQaZy2vyaFzTjX6GfZJbyGZohAqPOqgIqRpx/LZJdLCDha3gt0gqPT88101QLX01hNOHs9pove0Q+jJlhfm46W5SN+Q4ev0uIXGs+doa1zSRKhkkJ6uKcBFjMjuxPokFdBi7h7Z68QSLRYVnz4spdC5ddAM0T7YPZYxSfqkERFnnS+/GQEg7DEyCurXFkDzSYXgpUjzjAaca65Z/1YQp7O08I+M9kKhol8ZW7bx/O62kcffkPgZsLz/6k/s0+At9Rlhr3bNXhSjkAASM5R+NExIme7aTkBdU6 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9489415c-8bec-4af3-74d9-08db345797a6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9185.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 15:25:01.6888 (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: aoJbmJ7lX+a2y7mEPiVDW5iI/p5LDpSz/F/shtMMVwMAVv2zeaAQWvNXS5RtDlHmBwIDrILVIyjDoIV3RgSXkQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR04MB10057 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230403_162506_404230_B4792E80 X-CRM114-Status: GOOD ( 16.17 ) 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 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. Reviewed-by: Fabio Estevam Signed-off-by: Shenwei Wang --- .../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 2a2be65d65a0..465de3392e4e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c @@ -37,10 +37,15 @@ #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; + int (*fix_soc_reset)(void *priv, void __iomem *ioaddr); int (*set_intf_mode)(struct plat_stmmacenet_data *plat_dat); }; @@ -207,6 +212,25 @@ 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) +{ + u32 value = readl(ioaddr + DMA_BUS_MODE); + struct plat_stmmacenet_data *plat_dat = priv; + + /* DMA SW reset */ + value |= DMA_BUS_MODE_SFT_RESET; + writel(value, ioaddr + DMA_BUS_MODE); + + if (plat_dat->interface == PHY_INTERFACE_MODE_RMII) { + usleep_range(100, 200); + 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) { @@ -304,6 +328,8 @@ static int imx_dwmac_probe(struct platform_device *pdev) if (ret) goto err_dwmac_init; + dwmac->plat_dat->fix_soc_reset = dwmac->ops->fix_soc_reset; + ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); if (ret) goto err_drv_probe; @@ -337,6 +363,7 @@ static struct imx_dwmac_ops imx93_dwmac_data = { .addr_width = 32, .mac_rgmii_txclk_auto_adj = true, .set_intf_mode = imx93_set_intf_mode, + .fix_soc_reset = imx_dwmac_mx93_reset, }; static const struct of_device_id imx_dwmac_match[] = {