From patchwork Thu Aug 4 19:47:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12936672 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 98900C3F6B0 for ; Thu, 4 Aug 2022 19:49:44 +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=YUgRT+2qCPXHD48wVQPKpNp1jf5j7rXeujMMgMM4KWo=; b=TE5xND5lUNLyRD xTybMsb28QOX9QNgYKB7nZ1pxKRQNBe32W6nOQ09yDDwOjLcs7Nm2RPBgLPRzme9rexaEGrnLrA5C 0dGO4KHnZjAKuW10Bek0H5ruTkUXXoeFY9I+M/cJ07OTUDQzZRfa1F65fl33XOKBNzr21D1Jz4WyC ARrK177fAYXCIXnktsdBx0WdzYNAE0vaYVgFngZK8mixfajmqdp1kxVTeCuqOxYEpb04cpyO1kxij dpasJlsXtU9aQrWT+BTR00iDlr0QupqTFePA+cWEIwqe/LufZWeuqAXLfBC6MWBu/+9WbYM5DfAMP sX6xjJbV1XNJ+pbzFInQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJgpY-008hMn-H1; Thu, 04 Aug 2022 19:48:29 +0000 Received: from mail-eopbgr130071.outbound.protection.outlook.com ([40.107.13.71] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJgom-008gwv-Sf for linux-arm-kernel@lists.infradead.org; Thu, 04 Aug 2022 19:47:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dqGCGIJHp+Y2iQck7fystPa3gBGW+wtW6sJyE7meP3/yfVcHvPCKsUr1lE00J6jDvMiXGRT6WmSx/26X8OXPVLFO692OkCrcLiEQNI4fnVHaoeRmeYG2haf8avd9To75i8++/81NKsc8oU2eMLTVR/1YUxKbm0ZBpb7trTgacwWSdnKYYAwd/8F/hIVIuooBS04ie3b3NjFsvfGYEy4gNbHJ6R7BVn1sXlsVJOxGEa5wtplSW9tBMWLwpaZLqR+ZKwjQ3AoCU+2d5RL7iazGhKPVyVIl2j0+pyoqHcthY1cDAz/TNpQHQUQu3rW9xjCKq8jrOY19XS+3E9M8YH6osA== 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=R+q9wxmuYFEtYhelB1kFPXp0tCVpIWTJa8bakEDEdas=; b=T7bbBV4DcEP0oP+BvNwCMnZEjN7cqHKsJqqOzb5ein/Yq52COzhPQAOkogQeUaAoTCa/B8RywQlN1y8LdB7ugG3Xe+1ha5/VGHDA3sH3xPeVs/HLmJ5RSzu05JmIcc7thpKZH1uruwjiy4QxTp2vhFnU3xMNrbmr5xhYn8whD7VV3gxIUyLxb4niDr4WtyJWpQKTD1kegUDt+IkXQ9QTWDMN6Ne9HKTimrfcxJNViVxg0StsB1qVwewscn1+Y7/DCfrzi6tx11anAfJOCTYSN87b5K45j1US3TYoDqnxOE5b78Z3dYX1BAhfW2BgwWLzDGi5bg5XFwx7pIg6JIN7mA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R+q9wxmuYFEtYhelB1kFPXp0tCVpIWTJa8bakEDEdas=; b=jjBAGIyUVfS+/NS99JyeJxd6HVcCVrsVm2rkrViaXGUMbU38Mwe7+4/A9h8n1v3k+vF+xhnt/swQmgclKfdF1BgHzv1Y5UlnVWqRhNd1qbV9k25A9uuGuLDBS8zMWvvA9FFyrcSWGob0f+igDb59th9+7/BXYnfYI4T4rHi9v1FjqVLCc6Kj2dxuZagoOIv64zmcKZotAy6BFBhgBm7Tf91SMG6wJzi/XfKja3r7JYidSInlrOKcfpNJZuLHVKL2H8U27lqjQvRsJzZgaMhIhaVh8BVhY7ZAfZbJZpNJETrQF1B0Y84SL6QExCzafH/CnZRpxiRGlrgJXOM4SN79qg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by HE1PR0301MB2297.eurprd03.prod.outlook.com (2603:10a6:3:25::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Thu, 4 Aug 2022 19:47:29 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::ecaa:a5a9:f0d5:27a2%4]) with mapi id 15.20.5504.014; Thu, 4 Aug 2022 19:47:29 +0000 From: Sean Anderson To: "David S . Miller" , Jakub Kicinski , Madalin Bucur , Camelia Alexandra Groza , netdev@vger.kernel.org Cc: "linuxppc-dev @ lists . ozlabs . org" , linux-kernel@vger.kernel.org, Paolo Abeni , linux-arm-kernel@lists.infradead.org, Eric Dumazet , Russell King , Sean Anderson Subject: [PATCH net-next v4 3/8] net: fman: memac: Add serdes support Date: Thu, 4 Aug 2022 15:47:00 -0400 Message-Id: <20220804194705.459670-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220804194705.459670-1-sean.anderson@seco.com> References: <20220804194705.459670-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1P223CA0012.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::17) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 759cdf4d-dff1-4424-14e3-08da76522a37 X-MS-TrafficTypeDiagnostic: HE1PR0301MB2297:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mdMRPIhLE7mqggphjKn9snFchn3y6Efj7HqmTFv/mZZOIFDtlvjfNoOYY37ICzCBIBZMso8rVEGG1Q41CGQDGF46tofMrkg4k41HsOzvVaaOrtHrMuYNuI4oPxWJovB7790aZ67WvXTsS4ytEStqbSR/x+7chn9PAiH+dx51sktJx9lH5joDsQuu/3olFmWbL42PpgYo85su16c6hTx5SR1Nw932sHAnqJZJM3x0bQsJOUM8+U3OjU18IAGXPjq/5aJ2MWiXruSp1ZxWCSVBk1Yh53AJstv/VJopd398WPwuJDckue/CubU/gGHNmtcwWgVXfLbmRKoSeAr8vYWwXPz6ruTZ1wKYDxDpOn4851cQhlZs5dqcW4PCvzmyirdEMLeHKPtFASSLgeRRkMpJ45/yVJN7iaQBMZTvG9oYVD/sYaOZ8T9QGgBUGlgBs/gEf93hfm6Bhst7eI6t+eDrYcczSldj0umyZBbn4T5UGzL7AjcNIVfyBzwHJl2lGQdF8XpEbA8sDaX3IY2wZ740E+GdLKZb1zKHAJm+XUyVeyQFKthQoXHFKIxkSJOWynwQwrwY5uZI3L0UKGQF+01ezNKQJlQhFoR8TMWDOjk/DrUyEBWFgC/L/iMiiTy0jWzgdc4ttRqsMngoABTzkLTsvXkmyjbeNVdvOUk9A1tCklcq12stJZeE5rgzOCAxLPVP0ByVeraAeGRMaUawtiMSJTupSzbF6bOj2AXY55X7d+37IhoRTJ60vq4+kE85ygLuyQ/Z8Tjiu7QNVWSjM2RhnJumul2z0B1ew7gdh4UY9Y0KV/x+a9hBBKs285hfKdoQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4972.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39850400004)(366004)(346002)(376002)(136003)(396003)(6486002)(478600001)(186003)(1076003)(26005)(107886003)(7416002)(6506007)(6666004)(2906002)(6512007)(8936002)(83380400001)(44832011)(41300700001)(38350700002)(110136005)(38100700002)(86362001)(316002)(5660300002)(54906003)(8676002)(36756003)(66946007)(66556008)(4326008)(2616005)(66476007)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rkOd34TvRi823iH+wR7UvL7PuBlZDsEAnYzjxXIh88RZs3t2HRkzkle4NufWzJshuxQKg1dnd9Gxp6tQ++wpGj5gTaG3OzuZ8VgBFEIrohkLVUXkSL5kAK/1uTmD9479qp8FqMZPL5uO35tg+jfHJytRLJEEddOIV+j8METPTyHoLK1QOQcaKqaxKPVguCt0s/rdWpE82Is/FEVobRNdSVnD3GvW8NZCfR0Mio4Y47MC81TnoyYwPHUtGfPilbJ3CCKqkWF45ZePRsrlnx4rHnpu8iVBFD0J5J0AwxoWOZYy+a/1GLljSY9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a5ZQ+dJKiKiHf70tapbgvioUPbW3biRYH+TZWubNIX90eWto3maX02AYc8HeG9M/t71+yJVeojOYG5DSgPqwdRTPYfZDgNRs+dYu3blcizEVa4zUWjygSSGa2U2wAi0McPRv3JP0tYNyM7MytTRjFJH0tHdFR2sjpiPX2hfMVGDCyHt1LQh/OmgfuxlzB7Ej5RvCVNyMvqvzUp/+JvVtUR2pbZQ== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 759cdf4d-dff1-4424-14e3-08da76522a37 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2022 19:47:29.6026 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1DQFt8ZdbMcKsANxK6coOkNXEMHgzLWoaY9iAD+Awbcf9Tcr1lG/v2TsyAvmCQj3HCXu2M6NhRbcitz4U0hgDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0301MB2297 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220804_124741_008405_A5964CCA X-CRM114-Status: GOOD ( 17.06 ) 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 adds support for using a serdes which has to be configured. This is primarly in preparation for the next commit, which will then change the serdes mode dynamically. Signed-off-by: Sean Anderson --- Changes in v4: - Don't fail if phy support was not compiled in .../net/ethernet/freescale/fman/fman_memac.c | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c index 02b3a0a2d5d1..2886f86e45ba 100644 --- a/drivers/net/ethernet/freescale/fman/fman_memac.c +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c @@ -13,6 +13,7 @@ #include #include #include +#include #include /* PCS registers */ @@ -324,6 +325,7 @@ struct fman_mac { void *fm; struct fman_rev_info fm_rev_info; bool basex_if; + struct phy *serdes; struct phy_device *pcsphy; bool allmulti_enabled; }; @@ -1203,17 +1205,56 @@ int memac_initialization(struct mac_device *mac_dev, } } + memac->serdes = devm_of_phy_get(mac_dev->dev, mac_node, "serdes"); + err = PTR_ERR(memac->serdes); + if (err == -ENODEV || err == -ENOSYS) { + dev_dbg(mac_dev->dev, "could not get (optional) serdes\n"); + memac->serdes = NULL; + } else if (IS_ERR(memac->serdes)) { + dev_err_probe(mac_dev->dev, err, "could not get serdes\n"); + goto _return_fm_mac_free; + } else { + err = phy_init(memac->serdes); + if (err) { + dev_err_probe(mac_dev->dev, err, + "could not initialize serdes\n"); + goto _return_fm_mac_free; + } + + err = phy_power_on(memac->serdes); + if (err) { + dev_err_probe(mac_dev->dev, err, + "could not power on serdes\n"); + goto _return_phy_exit; + } + + if (memac->phy_if == PHY_INTERFACE_MODE_SGMII || + memac->phy_if == PHY_INTERFACE_MODE_1000BASEX || + memac->phy_if == PHY_INTERFACE_MODE_2500BASEX || + memac->phy_if == PHY_INTERFACE_MODE_QSGMII || + memac->phy_if == PHY_INTERFACE_MODE_XGMII) { + err = phy_set_mode_ext(memac->serdes, PHY_MODE_ETHERNET, + memac->phy_if); + if (err) { + dev_err_probe(mac_dev->dev, err, + "could not set serdes mode to %s\n", + phy_modes(memac->phy_if)); + goto _return_phy_power_off; + } + } + } + if (!mac_dev->phy_node && of_phy_is_fixed_link(mac_node)) { struct phy_device *phy; err = of_phy_register_fixed_link(mac_node); if (err) - goto _return_fm_mac_free; + goto _return_phy_power_off; fixed_link = kzalloc(sizeof(*fixed_link), GFP_KERNEL); if (!fixed_link) { err = -ENOMEM; - goto _return_fm_mac_free; + goto _return_phy_power_off; } mac_dev->phy_node = of_node_get(mac_node); @@ -1242,6 +1283,10 @@ int memac_initialization(struct mac_device *mac_dev, goto _return; +_return_phy_power_off: + phy_power_off(memac->serdes); +_return_phy_exit: + phy_exit(memac->serdes); _return_fixed_link_free: kfree(fixed_link); _return_fm_mac_free: