From patchwork Wed Aug 31 08:02:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 12960498 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 C6293ECAAD3 for ; Wed, 31 Aug 2022 08:03:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231286AbiHaIDO (ORCPT ); Wed, 31 Aug 2022 04:03:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231289AbiHaIDH (ORCPT ); Wed, 31 Aug 2022 04:03:07 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2058.outbound.protection.outlook.com [40.107.21.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25BD1B9F8A; Wed, 31 Aug 2022 01:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HNESeeEZZu9lGjfQKwciNP2ZjhAkR5C5AD7gwx6DcsAcSMQNaFsH834a8K7Inf1OUcjK+Vl8uJ8CbbUJj9Tp6SL/7D8wQ1Y+vS+ELAbo1uuPyhNISWKxdMrvcEDMuUM8B3fQ59LpNd7pQmbVDlod16fHfsgD12L8cAcfmnUxWaWJaEoOPlQmVQmUk2fhbGu+zkpTvxxCgnH8Gp1agLypxXNLKD7hQpqK/PQsiW4dj2rJ4JYwreU4Kz7CXLEerEDeqwLIcWTuMNo8VTsV9tbL/Ity1xGDjJm6b5sGHfayLmh145cCLn1CIwmYMg8jKm8xEIWAxptg4UVaYJPDyxtOpw== 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=WKM8lF50Kekz06qdN0izInd8fmkt4syGDxPDUMNPx9U=; b=MTwL6NM9OI2LbvbWl72kVKU52/eqfXqPJeo8HdplPD7C75N0xwgeNzLDcba9iJd7eI34ul5NBtid0oaY9KjApETc7plMcIpx9wqgRzpaUAL3wb03IajcjuZPCNaVP6kUJ5nnjoNcU4OqSzhANTGjmczyHEdFMonuSnPprtr0/8jmskmXfwjUfCyrJD1+CX6eY3VfDgOxRFnYwlpUtCNn0yK6T7eQWj4PTyuFL4X4CJXpnPU22sHK4xdFzadPwEFJ+Vx1HfiCQGtnRUS6pq7rjo5ZOscM50DquLTk8rAVi1wAZyTgU4aK3Ln0BA9MjiciMtD2LmI6I472HL56Lsi+OQ== 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=WKM8lF50Kekz06qdN0izInd8fmkt4syGDxPDUMNPx9U=; b=FWrj11jIkghvd07B6zG/KwzvUrBaVVwnmVakeZ7H7mZzQQyux0nhFBCKnEcp9aQfzGLGC17RekgxVwkGhp2pTYiSuFgrcwdVd4hnpE5yD2R3q5uxgnyPWEumpb9WE2uEvX0r9h8zmqeATtnwWj9DOBK1v7nvc40JJUoqjn/oZXo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB8106.eurprd04.prod.outlook.com (2603:10a6:10:24b::13) by DB6PR04MB2997.eurprd04.prod.outlook.com (2603:10a6:6:a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.21; Wed, 31 Aug 2022 08:03:02 +0000 Received: from DB9PR04MB8106.eurprd04.prod.outlook.com ([fe80::a569:c84a:d972:38ce]) by DB9PR04MB8106.eurprd04.prod.outlook.com ([fe80::a569:c84a:d972:38ce%7]) with mapi id 15.20.5588.010; Wed, 31 Aug 2022 08:03:02 +0000 From: wei.fang@nxp.com To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next] net: fec: add stop mode support for imx8 platform Date: Wed, 31 Aug 2022 16:02:37 +0800 Message-Id: <20220831080237.2073452-1-wei.fang@nxp.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SGBP274CA0001.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::13) To DB9PR04MB8106.eurprd04.prod.outlook.com (2603:10a6:10:24b::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc205802-6c9e-4e2d-5052-08da8b273a2d X-MS-TrafficTypeDiagnostic: DB6PR04MB2997:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IMEvgIRtEAAuQp9QuGkmiBYaCqwlvOQCfYQq0yy9XreN2nTUrjNdGaqgEZi/ZtSWY+SVHWdMXc5lpg8K6QHMRDqEUwzRYrpUA9epAK8lfYJWyfcAxHKCZCttwMS+jdaGQoTemNYCuHvdsexCfE9os3+uNahddHSJSpsPthCT0rUXZzoK0wDwlYRACl9+XFoALRwItIvl/fZ+z2WInDir11AaPpgW8Ipg2/zZbFtXqIqc9eI3mQvwGXDkqe0nTsL4CderQxdfM6CvWMyACt2eiSEQZ1JoQL1iRcxS65hXmReH3ftZyguMKgZmD3gyr774Ow3csosGb0QzqEkOkp7qe4szVzw6xbf+XAUweavr9791NMQY8ETFdjWNH714dvyDaJLbb9Z6s75vU7zoMZ/KbGdJrFX9msWz/7VIfHJ/81EmXWI69dbVbNKWfCmkebC7OZ8ZcZ/3cgVEHbYiPpzvFHRoL2MJ2a5clnTnQExq8PyxWtVIFuVuA/VuOJJPYchuse/OOYzkN5FTnKxcU9QmNQiErPEin+dV6eOpouu5DlTXOVhX/p2C/DlvM68omCkmcGatUcu0kIQT9brHfBsHZYUbVwnrAzweXHkAzgk7IvJKt0JTlwRX2ZKhcQRTAKMW+KKKvbt3v11G7ZZgb+sLVJKD+5ANob4wsD5xnj/GPBMybPv9t+kWCj6DA+mIwtHOs6D6dNM2qqbrU1nQfRw7cwe33sHTQHqzVjTTcv9P5WW6Eq0hyQ32X5ADhRhnjyIFv3T5qjWeX5HjzWFk8L4IdA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB8106.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(396003)(376002)(346002)(39860400002)(366004)(6666004)(9686003)(52116002)(41300700001)(6486002)(6512007)(186003)(6506007)(26005)(83380400001)(2616005)(2906002)(5660300002)(8936002)(1076003)(316002)(4326008)(8676002)(66476007)(66946007)(66556008)(478600001)(38350700002)(86362001)(38100700002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hTbpo9uh0aqg7vQCjqvadEogG7O/9R01T2fv9TVRS69C7lg94R6p9xc7vUcSH1mYO6301i//OYu+2iLioOO/+JAN8XUiQBwzR+coCCFp5mFzYBf6iOO0vAj4qJGcxVPo3DzhUrUAxZPY9YLGH7rmo1nN6OviH7qjpXhDX5QgX+xayiW7QljoV6ePY7H+n8c0ATcJ1dQO1d9omNc/xT0UGqU/gST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hTFO23NMJZMrJX0k211Mcneo0U+tt/uiIzkmzNSvkudYESyYre4X6lzmvbbPc85Y9Lphnj0bM50dPgN+m2lWqdV/1Ofl31S+ONwmwaYrWPmFpwyUz+SCiw9cfXWqCelqTLBoBxWtT0z4qy0LBlfTXgEtezWCxPZZXN+Rcf7fMphNqxdq/jaKL/YWA78QxXEPc3LjXbPo9wVei1ecXNOP16sCly9+pImIvQDwqFln5jtR4ogTL0fKhw/y1Ih1oELVtJEttmo2SOYyoazTRbtpdrXuGyWs X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc205802-6c9e-4e2d-5052-08da8b273a2d X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB8106.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 08:03:02.4098 (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: FzH73hlhisNYDVSflRMSPHKMcvXM6YShnD4XST0k7tdZHxFJFuPB5xZWVipSrA30eCPYpubTWjBvzs/LEKQtOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR04MB2997 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Wei Fang The current driver support stop mode by calling machine api. The patch add dts support to set GPR register for stop request. imx8mq enter stop/exit stop mode by setting GPR bit, which can be accessed by A core. imx8qm enter stop/exit stop mode by calling IMX_SC ipc APIs that communicate with M core ipc service, and the M core set the related GPR bit at last. Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/fec.h | 4 +++ drivers/net/ethernet/freescale/fec_main.c | 35 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index ed7301b69169..cbde8f148c16 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -18,6 +18,8 @@ #include #include #include +#include +#include #if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) || \ @@ -634,6 +636,8 @@ struct fec_enet_private { int pps_enable; unsigned int next_counter; + struct imx_sc_ipc *ipc_handle; + u64 ethtool_stats[]; }; diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index e8e2aa1e7f01..3be7ee67f379 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1167,6 +1167,34 @@ fec_restart(struct net_device *ndev) } +static int fec_enet_ipc_handle_init(struct fec_enet_private *fep) +{ + if (!(of_machine_is_compatible("fsl,imx8qm") || + of_machine_is_compatible("fsl,imx8qxp") || + of_machine_is_compatible("fsl,imx8dxl"))) + return 0; + + return imx_scu_get_handle(&fep->ipc_handle); +} + +static void fec_enet_ipg_stop_set(struct fec_enet_private *fep, bool enabled) +{ + struct device_node *np = fep->pdev->dev.of_node; + u32 rsrc_id, val; + int idx; + + if (!np || !fep->ipc_handle) + return; + + idx = of_alias_get_id(np, "ethernet"); + if (idx < 0) + idx = 0; + rsrc_id = idx ? IMX_SC_R_ENET_1 : IMX_SC_R_ENET_0; + + val = enabled ? 1 : 0; + imx_sc_misc_set_control(fep->ipc_handle, rsrc_id, IMX_SC_C_IPG_STOP, val); +} + static void fec_enet_stop_mode(struct fec_enet_private *fep, bool enabled) { struct fec_platform_data *pdata = fep->pdev->dev.platform_data; @@ -1182,6 +1210,8 @@ static void fec_enet_stop_mode(struct fec_enet_private *fep, bool enabled) BIT(stop_gpr->bit), 0); } else if (pdata && pdata->sleep_mode_enable) { pdata->sleep_mode_enable(enabled); + } else { + fec_enet_ipg_stop_set(fep, enabled); } } @@ -3817,6 +3847,10 @@ fec_probe(struct platform_device *pdev) !of_property_read_bool(np, "fsl,err006687-workaround-present")) fep->quirks |= FEC_QUIRK_ERR006687; + ret = fec_enet_ipc_handle_init(fep); + if (ret) + goto failed_ipc_init; + if (of_get_property(np, "fsl,magic-packet", NULL)) fep->wol_flag |= FEC_WOL_HAS_MAGIC_PACKET; @@ -4014,6 +4048,7 @@ fec_probe(struct platform_device *pdev) of_phy_deregister_fixed_link(np); of_node_put(phy_node); failed_stop_mode: +failed_ipc_init: failed_phy: dev_id--; failed_ioremap: