From patchwork Fri Sep 30 20:09:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12995958 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 723EEC433F5 for ; Fri, 30 Sep 2022 20:11:46 +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=dTZC6i2mPEwf79D1HBd4aX+AaiKLTkr29bf28w0Kfzs=; b=XV1cMgzED+Yi7X lNol8ncgXe/c9e944T/8tCej4DsFh/c3RvHSq/pqdJi2bEZlgcHwJl4kfskUD7p2QPGBQVTVzGug6 083UV3WeFf+cvXUcmhHXt8Lqf7q+1xuQPsbuYsZ0pYRN5K98+OwYdGLYwTAutHlMRCZCkCb1GIl2q 1ufEfgpHuMoh+ISMIxF3JgGro0VCqwMTuxYsuhNKhIOWFESnWsp1a8UHCYCucHi/31w/ouDLtxdce 96mNtc6p0Ks9nvkCYYJcHaagCPUoNEf5WZluWrUD4je1X0ZeBjoBuDlyMdx8WN4mR8EREIhrsPKl+ 1gv13rJqHWeaVyGZlS9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oeML5-00BKC4-SQ; Fri, 30 Sep 2022 20:10:28 +0000 Received: from mail-dbaeur03on2073.outbound.protection.outlook.com ([40.107.104.73] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oeMKf-00BK1P-BT for linux-arm-kernel@lists.infradead.org; Fri, 30 Sep 2022 20:10:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iUCWzUskeuvxNtCX9IxpZumyjNqZvURWAnW4HTjXuLWtwcLiVQnvakSgY+fd9Z2yUwAb3RScLtwL8AvkUmPKrXmhFMTYibA064IOoSZPpYnSN+mq6Pv5ZPiBdOFHm3r1iwCoN7+4xdMZSkriYfIqu4aJtj+yyTqFMfPoHd3U7ulGxamx0mdkxw2c8dLSpcpNwNRZvdycG56SueOcYBAF+9T6o38+JcyUs/m2ue/z5YV2mQmf7/HWTYSsj0/+RKrUNoideE65FVMyGTi7+WJDu4iw5I4aBSUYSevtxC3gOL+Gt7fcfThk0jKjjSfH2k36FJknLfIg92wD+a7ZwIFZag== 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=ppbX7gkdSbkxfHgc6D5Y+h9NkpsO2d0pVIeXPyTOAWM=; b=Wo0Lk/l8Lcru/CEOhfENQCDnTZdb9tbqvhNA3a03jz23XGMwaUyZ/LTlIgAnZvHZLL3gSEervmcft5o6Ngo0FQEOqCfwzOJmAScL0Dwhm5TDSDX28MJcNEwWmy6ZRHPES8FvsMDT33MEXmLsD08hq3Y/fc9+r61bSGcFxTKMNrlZRe7M0Pjvs2G9zY1UNbddfDeIn7Q0aoMowJ5cHh4/lyJpdrHx6KiSH+v1v298f5HkrLQOUHAS3Jgyl9Rs2ekwG2k0/or6XJPK5nV+MKnsgCKejg+aKMFn9pEyEsdSgY3I4TDs1p59iv6wfN8xhhNdcJ3dy/ZkbVZGWz1clgS3pw== 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=ppbX7gkdSbkxfHgc6D5Y+h9NkpsO2d0pVIeXPyTOAWM=; b=nLkNaLq5fJFddyPc+wgtlWlNgpxqgvbFHaIOb9yvacWb/IeFfqqPvv3ncNFio3L1+ruRwPY54FHTbFGPHQNXrLqigcBeDiWuYBirWzipj1gzUWnZIWTCoMn4e+hC2ud4fl/ApNEI+rdjC9leG+SS81YPR0NX1r0IZwOgMoHjkKWQsi6lJ9SN6WMLeKeNzwL8I++dPJ6Jdk9yNvcLiqHbfkLl15BMi4j0syO8bKZeX2v66v9zL0swJ8zPuObJyP2HqZY6lG7LOZNSAP84YqX4PT0y8eZgNxl9xCiBDoBRZEi8Ai2D4f9gsvFtLh6QuuxR+jb3llwqVvsFMLA38Y9v6w== 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 AS8PR03MB7749.eurprd03.prod.outlook.com (2603:10a6:20b:404::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23; Fri, 30 Sep 2022 20:09:53 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::204a:de22:b651:f86d%6]) with mapi id 15.20.5676.023; Fri, 30 Sep 2022 20:09:53 +0000 From: Sean Anderson To: "David S . Miller" , Jakub Kicinski , Madalin Bucur , Camelia Alexandra Groza , netdev@vger.kernel.org Cc: Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Paolo Abeni , Eric Dumazet , "linuxppc-dev @ lists . ozlabs . org" , Sean Anderson Subject: [PATCH net-next v6 4/9] net: fman: memac: Add serdes support Date: Fri, 30 Sep 2022 16:09:28 -0400 Message-Id: <20220930200933.4111249-5-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220930200933.4111249-1-sean.anderson@seco.com> References: <20220930200933.4111249-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0144.namprd13.prod.outlook.com (2603:10b6:208:2bb::29) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR03MB4972:EE_|AS8PR03MB7749:EE_ X-MS-Office365-Filtering-Correlation-Id: 40db64cf-c497-451f-fbb9-08daa31fbd03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gvb1L68JNvrxi8xxy4PAUlb451shNQ2il+yuWnof9yjWMBaH1+Z6r67W4Kf+5XwLe4Xy7T8yKqhYjJRaEOWg+MRJSArDXWmDkBz7zEzTmCH17BBeu4QVu2zw0RQHNZYjCOivTfodUlU5XOgrHEHNg+n0OJrBqUFgo7t2viZ6bB+jWvu+A0AqRNiX+2mkBfcDLiavuPJahvcI5kT2L5oNSifZeQqxyy7JEowaOr0fYaprbYrUsbqoj2wHQMA4zKPrJIREpfaas6YoA8aICBTF+vVrypwlLvE5pURO5RLbJ3VSig9JDxdjV3AJwxWVnNWZxIzw6U3gQpPRSavTTyk7ZDWlpO4seK4xbUtA8rajnzRBsL4+4GnbKhpv8VbYY9NtO4lI7lUcDQrEp3ZhGaP+LB6sVsgVeYkcsmu07VFQmVg45DWza8a1GC6oDRwohtZI8lHAZoSEctEOs7+G7UJblux7eWE91SvakeIR0DR0FFbvd495lw7/8U7oE0gYIFO7I9sVcVL4GGU2Z1nrM9pWOpifW857D+bP9jtkWV2bFF+5TEBD0OR/CEGHpEcnTcS5Ka/i/P3SBmU/FsMgqpU1FTr304NS1Xxbg1vTIlvWnu/1wde8PI4+zD2R3Lhndm1vWOFS92VJcMzSUcRPGLZ3vmQP5tnDFYMEtuBKwSuxHiuTvFncmh4dXwe+P3YAZppJK9w+GIYHZ+eUf0T+RP9RD9z82JYtpzGCsNYhcZf03NxINoM6BjKY+cSRZiIfJo9L9qtGvb2XJl7nITuQ9S1cXQ== 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:(13230022)(376002)(136003)(366004)(396003)(346002)(39850400004)(451199015)(66946007)(2906002)(6666004)(38350700002)(38100700002)(8676002)(66476007)(66556008)(4326008)(83380400001)(41300700001)(36756003)(6486002)(6512007)(478600001)(6506007)(52116002)(26005)(110136005)(316002)(107886003)(54906003)(186003)(1076003)(2616005)(86362001)(8936002)(7416002)(44832011)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I0tIzu8gISFjV0mdaOgVoaEeB5SU3QlEhIWQ2vHKn9+iIusS6UW+dL5cgcS0TuE6VHko4nt+HKzzYx6Q/fIF58ia7IvfzRgodRgy3UXk4ChU0mkYALLanufZbL81kA59gQbvQM1f/6tI8ZCJEYAfm41VzdGhpIvHm3Sl+hFiTgSyzKozD41162fdf+6MOVIshTjqbFoN706H73gs8UykaFL+7FY1+iZVytbGr3iPUYvXhvbWcsefcN0FGNU1jnQoVvD1BRpykEvuji+3lRXkYUGa/CO9Y2OG7G9I9jCLxJmg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kRZklkgKtngmqaUX+BF3zbGWxp0f8zskSBi4pvgiMX/k6Y+X7lwh/iZNlnIx9YXDgQG18qxMDoZiQ+8mqnMDPfFN4pOnxkkYNVLrGUqiPMVPqtmIvgb5tmoBtIhonTD5GG52IfIYT+2b70SJEA3miJ/Gdgnb6+6oPPpglG/3qxUIIfQ6MEw5ea1FoMmP7WOtd/5+rdU9PmGxRghZB+tACHN/RV65dBndw0Gs05RH+zynjSw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40db64cf-c497-451f-fbb9-08daa31fbd03 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2022 20:09:53.7596 (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: 5a2HND06pznLZl6QmRp7lBI663o9UedeHEO3F73rovUWUTy+lN6RqPqmw13CCZvJZpTg79z4Hf42+hU2W0JcQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB7749 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220930_131001_418626_0E1B3EB4 X-CRM114-Status: GOOD ( 17.54 ) 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 --- (no changes since v4) 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 32d26cf17843..56a29f505590 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: