From patchwork Tue Mar 21 19:09:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 13183077 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 77650C6FD20 for ; Tue, 21 Mar 2023 19:11:37 +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=hSoHXIz4ZyjAlQANnk7s6cR/Ou7CsHwSkBaJ5yxGeeQ=; b=czj400bhO8vawg AHQuAdumdu1jPTGXkQv83jnyy+XEa2vXyCGmQt0zidpZNYozaO3pzxKODXG1Fa8Cm6VTf9sgV18tx avsa4T7U0zptRjYBNN76xeUePog5RNSoBVQtiknR2iSxR8G1EtT1d09x9DibcuiqHSYmVCovlkQrN sR8VxSFYy0LmuSRrmc/gg9iJkx5lSVM1cIATsI9bQdC/t+Hni+oR4yBlsDQnu/2+0yPjr840ZjW8+ 1xP0IhpWjVPpc7937M2u4M0Ye1Y9tlKSoJQJW/ToFzb+n72QqHL1GJQT6l68F1MbYpAA3qO4Dbkq/ fapb7FWqL3sC5qf9p1Rw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pehN0-00DQbW-2U; Tue, 21 Mar 2023 19:10:06 +0000 Received: from mail-db5eur01on0601.outbound.protection.outlook.com ([2a01:111:f400:fe02::601] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pehMr-00DQZl-2m for linux-arm-kernel@lists.infradead.org; Tue, 21 Mar 2023 19:10:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RtzWv5zPdBRLGZspsxTRUtdhE7wKYFTG9jFBbFraEhSWM9uf2rhKiYuWlaXrcEt9jBqPohZgFaxpQmk5pv8yndZn7MqC1xbPqbDXIHMtwmumDn2Q0TVOh6A4InTZzCMpecZtuDwIa6H+L1UWHaVra18YgKvoOA07RReejgYi6lOmTQY330rHNUFsjU5ryNq7QHgMvkTdG4+ogYAsRhjlYzgCZ5CAyf3mkj9FhUtYL1p9zrZj2nTlbsZ2nthbUpJv/5p/sLd89j+fr82vEPBlfDncy8hruUBrkdE7W1lsC+Z/cuWkezw8SiiwigfDBYZI6GuKorGg89oa6mQ/G4XmTA== 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=NArNsxQrzAgNBIxidYUKjAbJZL8hVbI3rc9qmA8OpCQ=; b=ViloyWQfbLhSfvLzroQu9PyJGh8kBYoVUNRvVZrRBVoI0i3RWo0M7c9P1MEULbhBcoofWkIOGJauwf+mMA/wqQQOs/A+jSAdHVnrtLxocbbEOU71qAU65hOSxLUbLXlNJr2VNw6Qk7tFMGTLrW4jZQJFquwQJNhUgjPOSsOyZ338OgQLjaICWxILYE0dWZo03HgSe+wigxXMmGoQhE0/TCxWnUN20P7OuaNIoAYwPv6+MJ+EYpKjmF0CoDTnxkX/ec+GbaAK5/x/1Ra41CDlBgx/QOD2Qvz6OhKc5ieekCT/jkwLxY6TcScpFsljyNuX5TT61o9vmDdICuJrN9mRyg== 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=NArNsxQrzAgNBIxidYUKjAbJZL8hVbI3rc9qmA8OpCQ=; b=WVGOW62HodUmtWigTjil4XucuAZRrLOpY3ue01SEC6E5480GTmWN4bdJfxZinRiqnGsMeAdlsRDIeVm9bo+BhPYqXB0blUWYWrMIQVILQrB+J/UucvDySVcd+Jpf4FjLggysrxO/vEYG6etZ9Ti0+iF7UScoRRRvRcLciACZ2Pc= 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:51 +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:51 +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 1/1] net: stmmac: add support for platform specific reset Date: Tue, 21 Mar 2023 14:09:20 -0500 Message-Id: <20230321190921.3113971-1-shenwei.wang@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR03CA0156.namprd03.prod.outlook.com (2603:10b6:a03:338::11) 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: e1a121f0-386b-4d0d-ee6c-08db2a3fd89b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Vce9/YT4kChBntn9aHxvAuZMm9cgY0SdPobonqjcUyHCqMBmX5R8DIPkncqdlAfnCnI6FTj5/AfJvhjrPQekr5WzQXKkSS4xe8zAEdpK4sjzxMsYy7r5LxtlaZrgLgxzeobUQ7H//4luiIQY241sAurHWDsYVRYhafaNRs7r4JTh1zYn1AFkAIHIynUAfd74C+uIYby6WBXZ4hQNdC1x6LnJwe8TYqSk7JhW6uRYg6TmR/W9WeeFxJAvxQniUTPEHaewZaox9Y7oFzvGSKmU4Mv/LonfEcMaZ539RCY33KiYLKcGqbT9fqsDETB+7eQKYy6o+rS05P3aPBEZ2yY8s+rxogBzyVuSNzYDKelRvSZxMYM6r3jAH6WTjzWLMn88R4SrjsysnBx6oL7RntTjCOzBifFwoqnBXBUGTQ+vA8+lotfwov4X0XycUjbKJnrBtq5S2NmodjEqGXsdRTDEXdvDpAtyQbfsSisIp5SaFg+ZNhra3csloVBgSJQEu0Omi8UF/AYmHg0zXCnDHQwmUk3AioKFwVGwxcsRXm2k4hp9ppu77wPdSkW15fmbAX09oHJ9TIL4Db+6NWi1bTfnQsNfsWHNrdcOhuHOfNBcspWMCymOqjFAni22Zi1/GVf400NA3SUfsDzS6Ju/ZCEoA8VU+bNMUfWmkbuibkEJPlSZ/pL5u/LxxQW62O4d4AsHXBhGJS/0Ba4kWaToqyWAiA== 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)(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;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SCNLfDgnhjwaszlePoWVxIMdTDjasdky66UHI13YU0Ru0WLJL8RGtriEjaQ6rqz/DCQ9hc4avR2343cEuZY0AGOu7aZbatEbljz8EwevDh9mqSVoau35/Y2Qn9al2EvH4W6pFd+ImDbnSUULEeSBkX0azf2FHpFqwXMcWLMHlY9WYZT0/a7MzNzGrR7nSe8+sa+SY2L3ws/KRw0IgwDXyePVi/tyRVNcQ+japj6Ly5FwRC9zo4AJ3zOVbXsEKIaVw9ZOmFtg+eOvKlDlpq8s5Wr01UKASwJ3VFgJUs1BRzQOQpYdVGtDro4B3BVNwKM6ve7GNjESyfHdf0STBi9lEnmPMUj3OnXrh+ACFaQGmtdFv0NIrAU8Y8/M+owXwIceWIx3Ty3pJyuYmZxZpcBFSbYVeuD2YZBApicLATHaidrH45fcinkCI31pe8WAUDGazV2jRnZK1L95C2TDiD9sxrYfFm5mnsmpRac3nqjzkZa0xfDV3lAo2haM1XGwPdJWJTe42xaKU41MzTfFGnkFhUwhKaJzstv6WVinSPtFV1C+px6NiNQ204+6nsR/uPpMrq366EOLDziNVf8xguZusNCpszdJei4yYA/WzKtGiyyqTQhrdvsHtX6OMtETTRkZlrjAySzBs7GclCYaaz4q8esgjg+ZK7DGUILsbeoKniPrCHMN6yiL7PbnnxwNFUblyO9PXSMBUQL1xDpj2V0PQ698jkOoSpSipYBdD3iHMTbYfnQSqQXeREe9ROQinMLlsE/1QGG004IzMTuszNtpjfIlyVQmSdertNAx64Ch15LR5TazjvKzhN2Ac2KIi2sloi58KMAAttRaq7N2kB/5rdsO0qSn5Rz85GXyox/HE1bPKOSOF3XY7YEkG5Ws2t18q8OSHcV2NVOLqgfPIMzNrqemf7JCbAxZFtQ2d9or5S4xbmOUCsC8e1IVAvYlY5pfo27I9UuB5mfrQIoVq3l8n98tQI53iZrqxTuYQnOBcoGDC9wTwYUFxvFBunOA97tK7CM1sISoGSP+6M58HqeO0Lw7/sFlyUuQyducUTcia9ZpJFIhqZH4nd7srHIHVZKNxeUl0/P9n/sHO2VNGLsQDv2/nAFdxHQ31JJDJ4ESMS0XyF/9i+gNIClX871CW8X9fT183HddzY9pI9BJmzgybAK44vbbUcZlVicHbGAKAJTmS8hkDUWg5F+d3goijo6l1jd7/poYpE3QVMc14MIQbso/bD/ui0U+8HZNbgInRgxbJTIF1xgnMIdairT9HwXWzODAOmSVl/CNZec3M7wgnJTwRzCRQMJeM/96ig6B7B08vzfPpfLYfAmPeSlreLs0RA5ILvWzCGR2ZVhi3Grrosf90bqcjmzsbzCVr4VTM1SIZ+RM7SXvIvElrYU1OhsOcdA3koMZ+Gg310NaqFe2STiIBmizPCk4czvL6rduD+5LYeSAjjDyA318YEDrpty57dwVuOOPDRwR67PFfm8asd/jVLt0LNArw5Fcp1DA7FMR4lW9o6uyWxg13C6NiDG+zHfHB4vXRf8LY1DpNvkzRSqCNYKBUvJY6o/lj572ii/2KNfDKltIONQXQMw1odlq X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1a121f0-386b-4d0d-ee6c-08db2a3fd89b 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:51.3629 (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: xAQuwBoiQWOjuYw2eQ4Y48hg8uM7/0epXuKOuPYKkE9dG3ACZI48rAblX3E+YJArjf1/uf4ezfxkxV63EOyvog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8348 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230321_120958_748978_9C764275 X-CRM114-Status: GOOD ( 16.41 ) 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 macro 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 --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 10 +++++++++- include/linux/stmmac.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 16a7421715cb..e24ce870690e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -215,7 +215,15 @@ struct stmmac_dma_ops { }; #define stmmac_reset(__priv, __args...) \ - stmmac_do_callback(__priv, dma, reset, __args) +({ \ + int __result = -EINVAL; \ + if ((__priv) && (__priv)->plat && (__priv)->plat->fix_soc_reset) { \ + __result = (__priv)->plat->fix_soc_reset((__priv)->plat, ##__args); \ + } else { \ + __result = stmmac_do_callback(__priv, dma, reset, __args); \ + } \ + __result; \ +}) #define stmmac_dma_init(__priv, __args...) \ stmmac_do_void_callback(__priv, dma, init, __args) #define stmmac_init_chan(__priv, __args...) \ diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index a152678b82b7..9044477fad61 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 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: 13183078 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 3EE6BC74A5B for ; Tue, 21 Mar 2023 19:11:39 +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=vc8tC/VZzGbrEJg3/6yVZTcEx7KKsCJSb9WQ/Lgsxwc=; b=tv1Xlpk5OfqbnI v2VuhAEMgXOMCR1wHNGgUxuhSaB0VoYrsHijZGKnoceUy0x+H+4nYyWCJh2bYFtGS9bb6wIzf7RvU DRH3jg2xL/vUZE8DPL/NYlRMbySYbAuFA141DzKCDSC/W98NFYT1UyqCnax3KI8DLTiKPzHOI8ox3 M1aYlo7/FAPTKn2h04w0q8SX1qMURzG3m2sdK+B7TNaMTiy7+yR+ZHuzafK4n60vyeBlPQRvJUaHv L7/rprvQe+Hx3lJUua1/svZ9dyNcOuntr3QFWNWEowbBkqZpNpAiQ5Qz/4Mub6M2n5qT4NAZTeFmF MU47j8ZGqY+0GtDlecHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pehN5-00DQdi-00; Tue, 21 Mar 2023 19:10:11 +0000 Received: from mail-db5eur01on0601.outbound.protection.outlook.com ([2a01:111:f400:fe02::601] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pehMv-00DQZl-2m for linux-arm-kernel@lists.infradead.org; Tue, 21 Mar 2023 19:10:03 +0000 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;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g3LvobxIpNTCeyU0zhbrmVH+ZYUiL1d69AbEJTacrM6B5D2XJU7L8dW8LjRBv7nn0cVc0U3n7h20aYFId/O5mCKU9y1IkpMb+cz8Wg2zcWf4/eSqQIY/+PyCzKj+Tr8WIUXvFc55q+LhlY8XQ61VAI8QqcQcnHerxiCdu3hyHrJxPPGTH9/4F/FhOProTKstFdWvayla48KYEWM4rcTcZbq8r6YegXS+CS6lhT5KvDs0kZ2hO3w46TxWfFbp0nTzvesvaLiI+T067An1KbjRWxNtyW4IAq7DgheYJXSOMTia1fnqy8saN9XP4zUqP0ekJsuHnfGDkULd4OE2xLWozF2bJb/cNpbM73vjKT/FYM0cILx1z9zFn5Ao2EF8u+TkO5BP4CAftZ+GUr21pDJeLeKiAjD2BQ9ncxDeDXGYBvdgIi252KO49i7uJN8944xGtfiLU4KjgXjTL9RDa7H5PX/xwhPBC5Y4JxWsMteGPAwtLZt5Z3WtEOpX5YOueEwMCCCXRgsMjbIyKEUetQlS+7X6OlaysPFAuOU2W9qgEga+5Bk4iKTpn+Zm2t+XQZLplXVzodk8MotlsuOaoU+MwElCmS4kfmFCHmoVnC98dlo3dyMmH4usfnYcxxBfPlqVjHQf7vYn87vWzEF/fxphhe2DP2NSZDN2tte/lr3gpg285k290O88upDc9f06JxyHaUJr8UXGP+eW8ITXr3RgkbQqEaWTuYOKvk5swXO1Z36rBg/ENQ4pzR3OI17+HBQ9F+a07+rZdYZRxsHsdnxTbnJeqRPHyhNbdHYcogjJ9gCeN+7BqlrVoGZhM3ylN15knXk1SG5wkQKJzThRM374uJ4593eRTfXx1hIAqiV5IlACRLaExLuolAhYVAYWkCBY16qQT8AHaZXffWKOmvhXdmfn+DsFGVt7fvyLMbULBCajcWKtw6mF/8EGmBRAbanEjK50yr3zSewzp6hgwrOcRC6PRDJGXyo65daAxNOiLxAlb51HolmYO0fxitm1oNlCZGqAgWcMcEHv5Glt0ASEEymyGEf+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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230321_121001_920299_4B76021F X-CRM114-Status: GOOD ( 17.20 ) 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. 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;