From patchwork Fri Mar 31 21:22:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 13196591 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 201ADC761A6 for ; Fri, 31 Mar 2023 21:39:51 +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=Jq4cmyMAjYK6QeJey15wicWLuKJwwMpbAihCHHfSCkM=; b=bGZa2kDnrSc/qH WsiSmG3u+EYCm2qEiMhXoVlCx1+GIFyS+DuVh+vTe+eSo7QkDocD2Zhs/yahI0mbuioXewBM7L0Wb QpUjD9xhs4QFD4+JjBUEhdhNtiDF0VY6y+PSGsnvufDEAxrr26kAYaRh31FncIpov0vGcREKaDjcj ZhWP2Ujm1IzA0iKZCl/toCUh9FWL7AdzwhvoV04b6LAhhS003iFJZ+PII3yLf69pvbDC2gZt7LurX +uyIGF29Ljhd9B0qDvDeAWe8rquMbg3qXr5m6i8xhd0FWaFyDtVoATxsawcO9L9Dz8BoQ7Ehk5bEd fCsbuIan9nzUh+2GFYzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1piMSX-008wBa-1l; Fri, 31 Mar 2023 21:38:57 +0000 Received: from mail-vi1eur04on0623.outbound.protection.outlook.com ([2a01:111:f400:fe0e::623] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1piMSU-008wAo-1w for linux-arm-kernel@lists.infradead.org; Fri, 31 Mar 2023 21:38:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oPpS0jf20+V6Jbacjuf44G0H27iJ2y+mzBGvwe6LqvXb2MANE9AlFzgxT2yI1UQOzwMHCP3eUIbNUnCHbqqwR2ufV5YgTYf9I80uG7OTvHWnb3cSnKKtwegQOYQ+5PKC9+sL8UKa5DF8zZW0msC3V7EYItoSfkzj1oW4N7Staj73pspjPe+PZHlCImUeM32wJfW0jJneoleL1U6c8AQBNhnT74eNG4ci6uaOrlbnZPQ9EJNfO5GIWv+1P/wVnWNr8399KDL+45BNZ0lO0T4e6RbOFuOYlrT+e+6iSn/3OBrN6gwmg4OP2Y9/JSPkmY0SUQarb9+YeF/wjKhCrRHKbQ== 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=PzX5IizI2Jc4ZZs9cujs/cT91HuZ7dWYYHToIHfm538=; b=kHUgdMaOLWieu5oAJjxnGEN7su/CjyL+5EhenfASr91v7EdNmimiwj9vXbVq/WiFlkGqzYJqvyIdiEHkh6vdmukXYyOxlTAxB7F6sTqh+aW23NMJydivo9Hp0j/xBaBK5Hi3/WKq22dUksPw//xHppXWB0CYIlq+QgpDicaOMQApz1BVKsqLedCCqJqDORrxFDPKP9UeSjdhocpY2RM7K5pQnsXqgEHZhyOasv0+Py8Y9CHXdE+5dB42A7oLZ/dzeOcQW+n+ub8zTiwTtA+p4UxK2ISC6CQFS0vvA6K+TtfGpR9r6HVnOTH2jVJ0Aqxq7bOduk7bOe5M/Gd7c6Ygfg== 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=PzX5IizI2Jc4ZZs9cujs/cT91HuZ7dWYYHToIHfm538=; b=BQze+ygGNrWoDpCDNZoq0meKAoTcg0W2uW94GOsTSuRryFJAC1uZih/+45bl6gePaPmRLMA/5vxOrlEH0k2NDV80npjaTx+DSOu4OomiYkeU01WXjMQZeeLqL53wo+MvGbtEyDERN6fuAc0kWMaUqERdlBQrqCza9iPDH7BjO0s= 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 DB9PR04MB9992.eurprd04.prod.outlook.com (2603:10a6:10:4c1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.26; Fri, 31 Mar 2023 21:23:00 +0000 Received: from PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::28fb:82ec:7a6:62f3]) by PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::28fb:82ec:7a6:62f3%3]) with mapi id 15.20.6254.023; Fri, 31 Mar 2023 21:23:00 +0000 From: Shenwei Wang To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shawn Guo , Sascha Hauer , Maxime Coquelin Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Wong Vee Khee , Kurt Kanzenbach , Revanth Kumar Uppala , Andrey Konovalov , Shenwei Wang , Tan Tee Min , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, imx@lists.linux.dev Subject: [PATCH v4 1/2] net: stmmac: add support for platform specific reset Date: Fri, 31 Mar 2023 16:22:49 -0500 Message-Id: <20230331212250.103017-1-shenwei.wang@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR03CA0194.namprd03.prod.outlook.com (2603:10b6:a03:2ef::19) To PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9185:EE_|DB9PR04MB9992:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b99af03-1f2f-4cc0-8f81-08db322e1aa2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o2v/2h5jUhoHDJfCA+AU358Gc2DLDy+JXAR18maKfbbhU2lDPurHEsTEK6Q3ofc+qz0zR4BlWSKTLaZsLCzKkLBtFbH+xpjaaMAfOS3biQX+1I9jtT1kWq7a/rWhypovJLXrDqmK5yBFoNPuzjDi6MzwS5OM+j+AxGx/Xn+MgALQMfgIGPt8V9/z59wF6fOTs6zjYb9RC/rqaPxWN7wlhAQyYYA/pYIGV/asQwGiasqRcn/k2h4LNzli5I+xFFe92RARihFT0FC8TDr8K/dHqAzzce4P7pX2nR1YDcj0CDg8zdqXLVa5zdtQux6ffpRdw69N0N3NTq+pzkxv9pIbzXlbgLPZQwKsYv1J98+fWOdOuxUblItXAhI6mH+s+ucKCpbz6y4Sz56tB7nqKvHVYr6KgVug/tKB5StxP/80eyNvk79tct6MGx7Uze1FFRCyVtSgHZ1JQ6A0vZbwyBeuFvOrKvmRjrsN3nZjxIymsm6zDOFwBlBBxsnqaFsDxUPQ+ahYbuReSzSHwrmfxrqQC5VEG7W/O8mOnRXY/PDwfRbF73I5B6Elv8IXrGyg2mULAS8kNZIHliX7PI5lj/WGrSH4Tx+wm20aRAYocwoHsPaKPiLL/ZV4E9aD0PgvPspJ 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)(366004)(346002)(136003)(376002)(396003)(39860400002)(451199021)(110136005)(44832011)(6666004)(316002)(55236004)(6506007)(6512007)(1076003)(54906003)(38100700002)(4326008)(36756003)(66476007)(26005)(8676002)(66556008)(66946007)(186003)(38350700002)(478600001)(2906002)(7416002)(83380400001)(6486002)(41300700001)(5660300002)(86362001)(2616005)(52116002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CacxmvYwAqXMnML8W/E0brNVTWXjNd7/rmPUV0tBgjg8onF3lgwyljWpdekPA+2jIzCQRIg39TdMD0ghCAXZY965ZxbrYp0OWOvC3udXGeKd+HAiPRzu6bXd1wkrCkxVtZV484entNAPL9eAa5A6qNFSzjrdOdR/wOhk47KDiy8qK7nEI0RKx4juSdWSwX/NgXvqDoB88icN5zbc7m2NSPLg+8HJ4r5lEqB8hQswJHjDTpfCQs660vkno9io/6NWXPuXGD1OI7J1FtxXQ5K1T3p9iPA0Np+/vFV+8mVaKWZxHK2CSu5mamJ1ufYpmFKWkW79Tn4wmDB/UUz7iUVovz/KUP78ooo9pYeZu8kG4inNdpD7hNFHN8RiJRrrUXnmr1mfzotAmG36TkRkiT5NkYYSsk9OVgs95NZ1oVZWubfepGK6UVW7t34WC66N020+7RiTFLDhQ3KIip3mQXcTdFzv91f2itfVVahLSDN2tap0a4tUquNTT1y+irWfTExQS43RngnjMNVZz5qXc5qfWgBaxmD65GBH7/VE/mc7z5Hav30YonYtg9ShvUM+n97TKt+xzmoRGE01y1Orpexo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-08db322e1aa2 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9185.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2023 21:23:00.2941 (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: 2mvnVJYlTKlCxVsnzoEGy2NF0kck8DenSh2aQNq66lWv/bHquJb53jUp51tIz8a64juTstgyVClRT7P3ebHqcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9992 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230331_143854_664143_60A15CED X-CRM114-Status: GOOD ( 16.85 ) 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. Reviewed-by: Fabio Estevam Signed-off-by: Shenwei Wang --- 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..47a68f506c10 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 *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 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 Fri Mar 31 21:22:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 13196587 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 B54C4C761A6 for ; Fri, 31 Mar 2023 21:24:12 +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=s2qKwSjSbB58d//Ltmw906u+xdPNmm+fKktEM1MERVQ=; b=vaHsIJDfIK39si lMQgv2Cgpy0y/ZvHimkLzc/v5r0k2tfeWZcTQEGzGCfcsH4WZfqkPyyGZz8LNXX6yUbIGE1q/MN2U XuCnrQjX0SoEDHQUHS6BMJlXU3sOIb9oXzGLS3Q3DZ41MrXeb5gFm2msr4qscQzATqb6l9cvFY+TC RBy6NqL5mxxpMHxmYFeJbhPwtkZXxwcZqSsgUq0ueeMShpVedesV/sGNHqhfuAgRNQV05LCCzSyaI gY73D+RIFt0vfzRcYb0WawiAZYptH0st/FRIDZTlpK6nVs0Infz4CfUq/e6IuVBaWohG7VLzQg7Zu G1mpGohUFety+BJiMziA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1piMDH-008u5L-3C; Fri, 31 Mar 2023 21:23:12 +0000 Received: from mail-db8eur05on20617.outbound.protection.outlook.com ([2a01:111:f400:7e1a::617] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1piMDF-008u4R-1Z for linux-arm-kernel@lists.infradead.org; Fri, 31 Mar 2023 21:23:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Flor+5IANs9d021xg90TnBOAvBbyTM6pOksp//CP8utGXbAdeinc8rZWbLDUDEdoWcvZEhsBFWzXFikJ/GwdaNIp19xXU1ooiIm63N1xuDkN8e1Q9mTv3C2Qr2aLSD03aaKHNaHrruMwWrKwe9EG0DoUo5NuKPxZ3JnCyoD3zDJZkxtMU9kP4Y38kazNl/nxVkpAOWJsTrh5fIfEloP6N5WascurCoI+X59/9SQ4qVc9P+Qdq2l8SChCdoFhb85B7ALCfVNnWNuACKLmYRjpbnvICMUdpU5DYSm1PBFBjPBs8pX75XBTk6Q3YeTe0QrMbmBSNkZ/ww77ANsTft+GtQ== 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=8f1urwP/JcS7vUjP9999ZWBSe8H6+gdb6huAQDlORvs=; b=YAg6g03+5+cbbG8WnVjVKtVRzj9OE6LwRRqH2IPyGzzJQazfzQrjL7l1pE3jI2SvY/oqjFWVGVp7RnM40lW693/oAG0MVCHb9O/5R7Rumf9DX0cg4QnT7pZenGH72NDqV3OJR3xIqooynFODWIcj7QarYybeQS4OHNs6n4lhORQEhZYc5GJE8Qh/OkePoB/KVHK8i41ONqTJyh0/yUD0LkSyrYFFZ7d3ZCdABgytU3niu/mRy6vkc2GwG2PyLVziwzjYXaDO92f4Xq0CXZazILxSLWj+nzwXZvnO6eAo2920PhbaajzEsic2KBfds4kADosdMebNtwVLSGMU3SN8ew== 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=8f1urwP/JcS7vUjP9999ZWBSe8H6+gdb6huAQDlORvs=; b=KqoKMjIF5lxck7yjQDWCOsr0gToJ6vEt7b6JWPjVoB+jpj6ujD5e+WbN31LQJIfh6xfiogmgMT3o5dErkUfX55BOSiEeCwmL+oz2yPEjYq7B5WsiD/EGRZanr1dEfhdzXBF789eMggHKGeYj6ifg0mcisr2nzK6fUisoXQi2Amk= 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 DB9PR04MB9992.eurprd04.prod.outlook.com (2603:10a6:10:4c1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.26; Fri, 31 Mar 2023 21:23:06 +0000 Received: from PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::28fb:82ec:7a6:62f3]) by PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::28fb:82ec:7a6:62f3%3]) with mapi id 15.20.6254.023; Fri, 31 Mar 2023 21:23:06 +0000 From: Shenwei Wang To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shawn Guo , Sascha Hauer , Maxime Coquelin Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Wong Vee Khee , Kurt Kanzenbach , Revanth Kumar Uppala , Andrey Konovalov , Shenwei Wang , Tan Tee Min , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, imx@lists.linux.dev Subject: [PATCH v4 2/2] net: stmmac: dwmac-imx: use platform specific reset for imx93 SoCs Date: Fri, 31 Mar 2023 16:22:50 -0500 Message-Id: <20230331212250.103017-2-shenwei.wang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230331212250.103017-1-shenwei.wang@nxp.com> References: <20230331212250.103017-1-shenwei.wang@nxp.com> X-ClientProxiedBy: SJ0PR03CA0254.namprd03.prod.outlook.com (2603:10b6:a03:3a0::19) To PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9185:EE_|DB9PR04MB9992:EE_ X-MS-Office365-Filtering-Correlation-Id: f6d30dc8-58ef-4840-dbaa-08db322e1e31 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HNiwAyiYRL9D+ub3pWcae0ky5uiPEwN8auY5v9MTJtW2KmEsJtwP7giMatGISuccfOHhoyni8d9pfhH+DK9pfOAo07pMvHwXpV46Vl61EV2Vf2aEg+mwFV7uBgZI+LVaigl5DxWV2YHaYQGlYXOlEl5Vv+Lcv5Y0ienRwQa/4ZwAv+feiIoSmBq+lLNFeGo6fNDTHdVTon5hsMtmBmfQr4icGKbD3vFxDmFYx36sfu/HE2ruGyQKRb0WcE9QuDbtgKui+hgZIumJ9TYku5XtkwPhPwAN3EqTJRsLJ6d22NIMqzIEBd29UepIr0J4jM/Nw4FfRMDFB6pZ91UTo5DKjpr51pJMUZE0lPxUH+4QEiSYVwXp7kZ9Xbs3I6oHInmP0qm04flmPqN7mC/P8gUoZ9XtPu1KZ+Xb8zcTY15e6rmzb66lekaq5sOL1kHaHsUYxyNQhuRsl9CgtNImIDeo5PHmXVPsAY1U2JtokD7ypeteXjPGQAu2ZrIKUv7zZL1VEmkJF5bHxw7Q4FoICSx6TbhKYKAuFJWMrL+FKuMmoTwwanEH55hTZzBDafrrh1BLaovWYv8876DaOxHujvdhYNXLeQKqnIwRNMnPrhZAqyDYXKcAINMrjA/eJkQY9xNM 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)(366004)(346002)(136003)(376002)(396003)(39860400002)(451199021)(110136005)(44832011)(6666004)(316002)(55236004)(6506007)(6512007)(1076003)(54906003)(38100700002)(4326008)(36756003)(66476007)(26005)(8676002)(66556008)(66946007)(186003)(38350700002)(478600001)(2906002)(7416002)(6486002)(41300700001)(5660300002)(86362001)(2616005)(52116002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SH7ZB5LkkrkEs7Z1VGimc+99hbDKTPeTI/0VwZTOcIXosmb7ezjOG2q/Zdzzr6y8/Js1t3DQZwKlJzvEfNms4boqnOo63WEDHlvK2mlADpVxhbB7PxLJF9fmEDa7j1gLEvF2dzwv+EzbEY9AMAU3kN9ysmco1hZPqLGe+vdoOyDPrdG7JeB6924nKw7B9S/0ina0CwTWcezlthMXv6bD3DbQsbSm62WtMBHe28QrTjzMW5UiKyjDwjqPRcEUKvL9DjMoEHhrvxneNsBvLRjr1BK8lJ8/zeflcAkiLFCUKFa64F3le15GRx1CQHt8T1czmoYrcgpGExYMwDjHLAZAIdNfN8hTpUZ2G+wU3tMu1jqx4TZTfSHW7+p8z5eX4vbqb1l38AY12S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s5fMfxGzL/jgzhlERPoufnet6DD6z+Blcad5k5eDd3aePYuBQPJ21DquLrx8V/yqqiEovOF+0jLYRc9qo2OqD2Lk6X6DdAO3rcoIXCJXxEMHCidSShh6zfpu+0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6d30dc8-58ef-4840-dbaa-08db322e1e31 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9185.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2023 21:23:06.3992 (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: UlQ86ioEzNH8EiDfnQX55FbS9bZKi2L0/BFu9knCrE7D5ZLT/hLM2g0XRrBw/w2UipgmKsaYmCOG7DcDzl83rg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9992 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230331_142309_530710_60662AED X-CRM114-Status: GOOD ( 16.27 ) 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(+) -- 2.34.1 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c index ac8580f501e2..ebab2ced5422 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) { @@ -305,6 +329,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; @@ -338,6 +364,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[] = {