From patchwork Wed Jan 12 17:44:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12711790 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 3BF0CC433F5 for ; Wed, 12 Jan 2022 17:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355912AbiALRpR (ORCPT ); Wed, 12 Jan 2022 12:45:17 -0500 Received: from mx0c-0054df01.pphosted.com ([67.231.159.91]:35439 "EHLO mx0c-0054df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355884AbiALRpI (ORCPT ); Wed, 12 Jan 2022 12:45:08 -0500 Received: from pps.filterd (m0208999.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20CE6j93020242; Wed, 12 Jan 2022 12:44:43 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2050.outbound.protection.outlook.com [104.47.61.50]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dj0fcg598-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Jan 2022 12:44:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BMc2Nzg1yurs3SU9DERKIHdlVKQoDHKaQhQ9zdfH56IXnrXxfWVCkjUVLXZlqTmRsUjgYPl6gol+do1zlqtT8pcwh6y957N7tJeEj79DUk4jZmZ8i6BKG9ECyOUBoBAh6gZ+3XRw9Vy0VCJsNbSLaMebvS+vJWF5ROua8zyj/IkquYbs4jDgdOFrBQe/I1Li5GGprvfWze5zGYFRbEIr5AOAP/jEAhO45JkiRzATkaFrw1/FzyElu7q5Mj5OQ8D0mmdwsN3rB+d+HaPpY6+MeXxFublFbta5Srzq1asj5reC4K6dq14xXyqYwUE8eMD5JsUSJd7MXtW///tZ77ME0g== 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=seG5I/bcQo/fgxkf7Kl/CAe9gc2d0pwCufN/U9tferM=; b=MJRCPy9c/5zfT5aO7pkGVs/kHDxTvRz1hTM1gUN9QFPdPas3KEuktMfWwmvXF5FNfbM4uAScUy9TLLTyq0Yo3+XpuNdCaTsOoL5k4V8NeS2iEdNiKdltZE0p36Mav4NJQq9y/ygIh8rM0BX8HN3ECGYz4R7i9GZWooMRCuAB/j0SMF77NDOq1/xQRCznkjYWz+8jK69X17p9V0UiACvGjK13JuD62uMBNDw1cm0RsWw5lE/Fz9uYzoSTYhHLkoXahMv9Gs9zIdg0lbP5dsGf1u/dOnX0OoGCwKVEaf4PCJJIxs8DYFiLsWOEpYiGCLaWVPSx+oxBe+XFV25ApWxxng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=seG5I/bcQo/fgxkf7Kl/CAe9gc2d0pwCufN/U9tferM=; b=NLCI0wTNAQetJsJBPNQ2uKA/9MZWXSF8Ku+TYAiSL4ctJftAe5AjDHbW81MAyx3uztUZj6Wm0RqdcZR50SWUDaPx6UspZNtUoYWRymeJT0ByUuJpK3Kx6qDCS/lbQSORtfDgA2OJ0RLXW8N4DXoV/ALLpZSzcvvR4nnxkgyZJN8= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YTXPR0101MB1215.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.10; Wed, 12 Jan 2022 17:44:42 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::6929:c39f:d893:b6c8]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::6929:c39f:d893:b6c8%2]) with mapi id 15.20.4888.010; Wed, 12 Jan 2022 17:44:42 +0000 From: Robert Hancock To: netdev@vger.kernel.org Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org, mail@david-bauer.net, Robert Hancock Subject: [PATCH net-next v3 1/3] net: phy: at803x: move page selection fix to config_init Date: Wed, 12 Jan 2022 11:44:16 -0600 Message-Id: <20220112174418.873691-2-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220112174418.873691-1-robert.hancock@calian.com> References: <20220112174418.873691-1-robert.hancock@calian.com> X-ClientProxiedBy: CH2PR18CA0029.namprd18.prod.outlook.com (2603:10b6:610:4f::39) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 59fbaafd-3fea-42c5-3394-08d9d5f3369f X-MS-TrafficTypeDiagnostic: YTXPR0101MB1215:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qkHnNRkpswtbJH9yuALnlYeffKc2ALksSEe6bRIE0OfCQ00/RUrvsF7fGa3md4zxP01Gn5v6X0oLeK81NcaC/IInxToi70Zhizmx3OPLACjLH8anf4LRHkQ+wq1oVPPw6KUWUnysek3anX3O3mHgEW9LKYn/5qKjVq6zHnskJQi8IxGQEMwEblD0LZO0GHtm3kO8QAqrFJ4plJ8WipOAEr543J1woENoN4IcsQQX4CFP/Cln9+bk3mq1uBRSf4U8EKv+lyCdtMh4WQhaxwtyBxNid3D4iWL0auz9NuB/jEO4Q8BgnFL4yYnafcTHsIao/UHMZMjSFZ4lG/bmiyfZ5CMrifr+nyt0RF9OkCHf7cfuYwuk2NJrTCztI7FgNLIJMIhadsvHVNSlm/BuX3jIqEPDzE9io4AR0ZiSaYVmODkvTEHfgFH+B4ayBdPPx4St/u+5KXwDHvVAc6rDnzNlbmrVA48cAbO/cj+PdSBklZWMgErRco6dfVAIpbsbd8EdtQqLbuUnI6L9SU9L99ItDDIDSoKPViwuklrq8nhBEDYIIb7CZnz4TDGy5oxXYmgk5WbkSriGKS4iKjvEZ9T4G5pgFTBkcJKkgqfO1b4TZqVF94zHn2WbV3cKRRyTCcEmeYcMSld4LWSLGSQWafz05MGOYbLP/c8N5rNCrh5W5YdW66AaS5vVisSaamGqVi47x7u5Xv5IYVKTT/sw2crK2w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(8676002)(107886003)(66476007)(6486002)(26005)(5660300002)(8936002)(2906002)(83380400001)(6666004)(508600001)(66556008)(186003)(1076003)(66946007)(6916009)(2616005)(316002)(38350700002)(6512007)(38100700002)(4326008)(52116002)(44832011)(6506007)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RgfZC9UT1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TrFi/GrRUw94EgJlOpL5ZyWB9wE3wdFHxGU/ntqEBDiDDOVvZclonhvRA8tEqPQE/PyUOGvXczbiCjDkrHfw/4Klwxq6ZlpcbfV3+xtrz/wwcA3Bb3mek82zoN5a/6WJGvLijOcfGjqNkzfTRojYCCr8Plm/9uP++Xo4t15PyZGTULKF4T311t9qKFK1gZMd2dSkX2574F9d92XEbjj5ARke9um4YF/OBqPF2SFn8PzUGup7fX8uAdjYF7TwSHGyQFwcZwpmz1hSejYM//dHwXe6ZjyKcd4C42DY9QbbHrchnGKhHSL/ToYCgEkachtbCTv3Er0B5HOrACyy4Lr/CgGkyX8BCN7bEHA+Hu49YP3kShq+QL0Fbnvi9H+iCM6T8NsVuoJO5Ud/fk0DDnJq52odjBBglbbl0xolxtrpxgKvkLEMyc4vuI4qcIpkvMwdkTeNFlbZHxxhPnL8bDzpVxIfdIA1OkFblt8YTiWmsMt21B57/+RliNG6vJl5HWunC1AMXkSqbyuPAlL8itsRyv9ibgIKVCJ0/QFCKr3fdfD1mp3auTxZJ9B/IFauDSDKbh8c7GhDia3ez4axx4dG8OOe4h8L2nZJDEna8d6uE0CgRMsD/7NCuvw3cVniU= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59fbaafd-3fea-42c5-3394-08d9d5f3369f X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2022 17:44:42.0915 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TB9m6vUwbNonkrGfsS5R+SHhervNkSzZP/gIc+q/rrDntZ3qjZi6NXuPoY8ecjcLn5kvmLUWRNbk4kjtDsGNSeQPTEWq3PdNNGlkA8xqnHA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTXPR0101MB1215 X-Proofpoint-GUID: XKHxiMml7lTLOLxh9FLO9lH5gElinf9s X-Proofpoint-ORIG-GUID: XKHxiMml7lTLOLxh9FLO9lH5gElinf9s X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-12_05,2022-01-11_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201120108 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The fix to select the copper page on AR8031 was being done in the probe function rather than config_init, so it would not be redone after resume from suspend. Move this to config_init so it is always redone when needed. Fixes: c329e5afb42f ("net: phy: at803x: select correct page on config init") Signed-off-by: Robert Hancock --- drivers/net/phy/at803x.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index dae95d9a07e8..3d7eeb572be8 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -784,25 +784,7 @@ static int at803x_probe(struct phy_device *phydev) return ret; } - /* Some bootloaders leave the fiber page selected. - * Switch to the copper page, as otherwise we read - * the PHY capabilities from the fiber side. - */ - if (phydev->drv->phy_id == ATH8031_PHY_ID) { - phy_lock_mdio_bus(phydev); - ret = at803x_write_page(phydev, AT803X_PAGE_COPPER); - phy_unlock_mdio_bus(phydev); - if (ret) - goto err; - } - return 0; - -err: - if (priv->vddio) - regulator_disable(priv->vddio); - - return ret; } static void at803x_remove(struct phy_device *phydev) @@ -912,6 +894,22 @@ static int at803x_config_init(struct phy_device *phydev) { int ret; + if (phydev->drv->phy_id == ATH8031_PHY_ID) { + /* Some bootloaders leave the fiber page selected. + * Switch to the copper page, as otherwise we read + * the PHY capabilities from the fiber side. + */ + phy_lock_mdio_bus(phydev); + ret = at803x_write_page(phydev, AT803X_PAGE_COPPER); + phy_unlock_mdio_bus(phydev); + if (ret) + return ret; + + ret = at8031_pll_config(phydev); + if (ret < 0) + return ret; + } + /* The RX and TX delay default is: * after HW reset: RX delay enabled and TX delay disabled * after SW reset: RX delay enabled, while TX delay retains the @@ -941,12 +939,6 @@ static int at803x_config_init(struct phy_device *phydev) if (ret < 0) return ret; - if (phydev->drv->phy_id == ATH8031_PHY_ID) { - ret = at8031_pll_config(phydev); - if (ret < 0) - return ret; - } - /* Ar803x extended next page bit is enabled by default. Cisco * multigig switches read this bit and attempt to negotiate 10Gbps * rates even if the next page bit is disabled. This is incorrect From patchwork Wed Jan 12 17:44:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12711787 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 273FCC433FE for ; Wed, 12 Jan 2022 17:45:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355772AbiALRpM (ORCPT ); Wed, 12 Jan 2022 12:45:12 -0500 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]:62794 "EHLO mx0d-0054df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355882AbiALRpI (ORCPT ); Wed, 12 Jan 2022 12:45:08 -0500 Received: from pps.filterd (m0209000.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20CGTfDb011851; Wed, 12 Jan 2022 12:44:44 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2056.outbound.protection.outlook.com [104.47.61.56]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dj2j2g1ep-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Jan 2022 12:44:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BnWuVZnK7Rh5oQ+IgeGwdWw/Ba2VjYppjkddI/MPWcyafQWoeKupXk4zw44ofK1rHWnA6Kxi6YX3BwtGyfEZ5j4slEI1VWsDrT73TiZal7rFIel6wf1M1O+JPll/FyYcdX+ID4us2p1303Q/AYp/uxguq8RINGu9YZvDciHhQ1By4nWNKIlYL+9mry/XQmIihgDgZYn4L63jEj9zCn0mpE9U2cmSpsoH/8pMCmw8+BfI+8nPWcC1AscLaBdvc43fe4Ycx53lFPbuZ558/5T2toRHwxFFWAkNNpXPbNaB06dOnToY3SoizZP9PSFSsshyP40Obvt92w2l+k2R8RdGBQ== 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=LVJOkig9QGwWZQUgg3Fhko0kVzyV2cGqWNLIij2MbIw=; b=BzeMYreNOOimLadwmOLeZzzSGJZkgEaPc7SxJk9k66GaWxccBitSu+Q1YN3z8CreZqoVyv2mwi67xf3h43ttX3uoo2VRSCHAzmoa+nwOIC1WWY3KVjRKHRSj5PtTnpD0Cj7IvS4I0rosOtTZrnU9gxxUtOLqjWVaKEZ04KcGJqZVtdS/mpwfGAm3aUZIGTtLmDfcVEpVv9lvhqM/nF0LKE3ewCkD4mRhQ5nkb49MJtGq2tR0QEwG3a7HhsOF8Tdm66tdayWMFWQCcFpYeEDenrhdVfDGpqFvkKk+g1k8EafIFMIOCUHOhEXzspsMZkQMIngClXK7NB977tIrIUjAOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LVJOkig9QGwWZQUgg3Fhko0kVzyV2cGqWNLIij2MbIw=; b=XHpsyqYtL2rhBd9s2yjhpWR9l4yIrzeMEFHjMjC57sK4WAN0oRPfr6bNR4aIBEZgXVkuIf90blKtatnmLxQuL6LD+pxSQLE1ukzLZd948KaGUDZyr9bVV+lemLVQkiDBc3f+KyPxwOaR7tRHs3iGF50d1fjaoGcwacI9VTPsBx8= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YTXPR0101MB1215.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.10; Wed, 12 Jan 2022 17:44:43 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::6929:c39f:d893:b6c8]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::6929:c39f:d893:b6c8%2]) with mapi id 15.20.4888.010; Wed, 12 Jan 2022 17:44:42 +0000 From: Robert Hancock To: netdev@vger.kernel.org Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org, mail@david-bauer.net, Robert Hancock Subject: [PATCH net-next v3 2/3] net: phy: at803x: add fiber support Date: Wed, 12 Jan 2022 11:44:17 -0600 Message-Id: <20220112174418.873691-3-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220112174418.873691-1-robert.hancock@calian.com> References: <20220112174418.873691-1-robert.hancock@calian.com> X-ClientProxiedBy: CH2PR18CA0029.namprd18.prod.outlook.com (2603:10b6:610:4f::39) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: acf964f9-f248-42d2-c126-08d9d5f3371d X-MS-TrafficTypeDiagnostic: YTXPR0101MB1215:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F7P5AquL77re6E5Lr4tdQC/gn0GTrjC/9dsH1rQrSzItjl9aDYDrARRXW7YpTsM67LkAOcOzHZoXTmjatDnBAnFO5Akkr2ASBzQH6al+1pO3gSPiTRXlWsIhYXh+Ow/B/RRaimLeQLYqr9d8UyQF/IS3kAAyY9lAFdjiYQXD8kNZwbfJQj+DnbL3vXtHuCGVfEsf1zhRctvANK8PdpfWJN+E4zyGrt6sEFfCuLDv45f38EaIeuYrBO2Ft+MvN/d79MU6LcTeUN7jul5aBgzE9igvy3RN5qjCM5CayIOPimvQ/+YH5Pd9ETMcbrRFDRsTYSip+zGhfUA0Er6QOnXLS4uAM7I1DgDXareboGfjsVC8xQTBjtR/eSGI5xhjy8Y4HJehoWAXz3zO5bUT9xWTlUgEpc/TTT+ZOkv1Uskcx2/2JcSOgjsHSxJ0SkYhD3sOef9ys5yzFHA4cVZBXf8rzOYYDKjYpp8sg/TnTTh1CfrXE7wx1NwCqnJzpy6roEwIvqUFk9RJebccN2tcOGbuEJk/uNGBwceYE/579uwDBUGsk4mV+CS6ZcHCpanTKcjEBNyyft32ik5tpzufLesY9ChiBsy2v9pmS34s/6U7WInEAjXcJ1otZapvJY0Exg+e6P8T2Yi+Jp/GnDeuQN/gvEla2atOhLTv4pcdVBwpknkYKp60luo8C32QhT6qok0rdC4NIWJdqnRuyQbsdG1MqQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(8676002)(107886003)(66476007)(6486002)(26005)(5660300002)(8936002)(2906002)(83380400001)(6666004)(508600001)(66556008)(186003)(1076003)(66946007)(6916009)(2616005)(316002)(38350700002)(6512007)(38100700002)(4326008)(52116002)(44832011)(6506007)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: u2Gfps1NMzw4K+lM0/UpYi2kF7qn8xkJaCPz8hgnxPGHoIqU5RWqspvNNjLdythpEk6toITE1znrzAhy+3xwt6r5MKvfRjoneO3XshBLcvoeksJ8Rcu8SpbmCtN/qaclmbhUgIoFnJe0PqF0jL6bHNL9T6l/g4TtYqVRIlNCfw1JgG1ZXxhzj+0aa8sA8SLT6yIunihimxWJXthZgVcihlewz/5UbIx3C/moS49j3cY2/sJ01+Hu61Kc5VpRTkr+nYeR5i5IBe7Yvd0tF1EUT0ldL5Ri+YAOE75P/FRsjAOePMJGWNx/YBOm5KHqg2F1aiMJ7/ZEaPZtio7ROEf8I0cH8VaggMIxOCwFHmCBpJQPsoXxU5X7wToxsgKn+9GlKZLSEPPyvIeaYf1kr5uIImFBacUg6nEfsEUVfPSZMLvZ/bvpYhwQu2eCprtFMILzVan8RJ6U6eeiC3B5V0HZnUTqvCvJz/MZazAitquGtvXS9090vFScO7uD2aj27/hPNLdtxhUGpuNWPnjkD04VQwt4LtfzP4dEVAjD1RJ8wmXBW9okli+3yZq8vR6eZfjYlj3UEU8tS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KeVUciIyfvdHGchHfEp+MSD+POuD9C8gXhPh+T4af+CATYPO/9jM= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: acf964f9-f248-42d2-c126-08d9d5f3371d X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2022 17:44:42.9195 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NbGgOZZarQ3/DJeia0F3oGbtdv69Sj+jjElhreZMtbPB+BlsLHbDqDfaFMp/oQejzBWllIsfOWp4x+SmqzSbDdCSIzYUdkck8tDACp4crx8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTXPR0101MB1215 X-Proofpoint-GUID: bhNo9WacvieUKGMlGPNlJebP88zrITY_ X-Proofpoint-ORIG-GUID: bhNo9WacvieUKGMlGPNlJebP88zrITY_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-12_05,2022-01-11_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201120108 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Previously this driver always forced the copper page to be selected, however for AR8031 in 100Base-FX or 1000Base-X modes, the fiber page needs to be selected. Set the appropriate mode based on the hardware mode_cfg strap selection. Enable the appropriate interrupt bits to detect fiber-side link up or down events. Update config_aneg and read_status methods to use the appropriate Clause 37 calls when fiber mode is in use. Signed-off-by: Robert Hancock --- drivers/net/phy/at803x.c | 76 +++++++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 3d7eeb572be8..63d84eb2eddb 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -51,6 +51,8 @@ #define AT803X_INTR_ENABLE_PAGE_RECEIVED BIT(12) #define AT803X_INTR_ENABLE_LINK_FAIL BIT(11) #define AT803X_INTR_ENABLE_LINK_SUCCESS BIT(10) +#define AT803X_INTR_ENABLE_LINK_FAIL_BX BIT(8) +#define AT803X_INTR_ENABLE_LINK_SUCCESS_BX BIT(7) #define AT803X_INTR_ENABLE_WIRESPEED_DOWNGRADE BIT(5) #define AT803X_INTR_ENABLE_POLARITY_CHANGED BIT(1) #define AT803X_INTR_ENABLE_WOL BIT(0) @@ -85,7 +87,17 @@ #define AT803X_DEBUG_DATA 0x1E #define AT803X_MODE_CFG_MASK 0x0F -#define AT803X_MODE_CFG_SGMII 0x01 +#define AT803X_MODE_CFG_BASET_RGMII 0x00 +#define AT803X_MODE_CFG_BASET_SGMII 0x01 +#define AT803X_MODE_CFG_BX1000_RGMII_50 0x02 +#define AT803X_MODE_CFG_BX1000_RGMII_75 0x03 +#define AT803X_MODE_CFG_BX1000_CONV_50 0x04 +#define AT803X_MODE_CFG_BX1000_CONV_75 0x05 +#define AT803X_MODE_CFG_FX100_RGMII_50 0x06 +#define AT803X_MODE_CFG_FX100_CONV_50 0x07 +#define AT803X_MODE_CFG_RGMII_AUTO_MDET 0x0B +#define AT803X_MODE_CFG_FX100_RGMII_75 0x0E +#define AT803X_MODE_CFG_FX100_CONV_75 0x0F #define AT803X_PSSR 0x11 /*PHY-Specific Status Register*/ #define AT803X_PSSR_MR_AN_COMPLETE 0x0200 @@ -283,6 +295,8 @@ struct at803x_priv { u16 clk_25m_mask; u8 smarteee_lpi_tw_1g; u8 smarteee_lpi_tw_100m; + bool is_fiber; + bool is_1000basex; struct regulator_dev *vddio_rdev; struct regulator_dev *vddh_rdev; struct regulator *vddio; @@ -784,7 +798,33 @@ static int at803x_probe(struct phy_device *phydev) return ret; } + if (phydev->drv->phy_id == ATH8031_PHY_ID) { + int ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG); + int mode_cfg; + + if (ccr < 0) + goto err; + mode_cfg = ccr & AT803X_MODE_CFG_MASK; + + switch (mode_cfg) { + case AT803X_MODE_CFG_BX1000_RGMII_50: + case AT803X_MODE_CFG_BX1000_RGMII_75: + priv->is_1000basex = true; + fallthrough; + case AT803X_MODE_CFG_FX100_RGMII_50: + case AT803X_MODE_CFG_FX100_RGMII_75: + priv->is_fiber = true; + break; + } + } + return 0; + +err: + if (priv->vddio) + regulator_disable(priv->vddio); + + return ret; } static void at803x_remove(struct phy_device *phydev) @@ -797,6 +837,7 @@ static void at803x_remove(struct phy_device *phydev) static int at803x_get_features(struct phy_device *phydev) { + struct at803x_priv *priv = phydev->priv; int err; err = genphy_read_abilities(phydev); @@ -823,12 +864,13 @@ static int at803x_get_features(struct phy_device *phydev) * As a result of that, ESTATUS_1000_XFULL is set * to 1 even when operating in copper TP mode. * - * Remove this mode from the supported link modes, - * as this driver currently only supports copper - * operation. + * Remove this mode from the supported link modes + * when not operating in 1000BaseX mode. */ - linkmode_clear_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, - phydev->supported); + if (!priv->is_1000basex) + linkmode_clear_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, + phydev->supported); + return 0; } @@ -892,15 +934,18 @@ static int at8031_pll_config(struct phy_device *phydev) static int at803x_config_init(struct phy_device *phydev) { + struct at803x_priv *priv = phydev->priv; int ret; if (phydev->drv->phy_id == ATH8031_PHY_ID) { /* Some bootloaders leave the fiber page selected. - * Switch to the copper page, as otherwise we read - * the PHY capabilities from the fiber side. + * Switch to the appropriate page (fiber or copper), as otherwise we + * read the PHY capabilities from the wrong page. */ phy_lock_mdio_bus(phydev); - ret = at803x_write_page(phydev, AT803X_PAGE_COPPER); + ret = at803x_write_page(phydev, + priv->is_fiber ? AT803X_PAGE_FIBER : + AT803X_PAGE_COPPER); phy_unlock_mdio_bus(phydev); if (ret) return ret; @@ -959,6 +1004,7 @@ static int at803x_ack_interrupt(struct phy_device *phydev) static int at803x_config_intr(struct phy_device *phydev) { + struct at803x_priv *priv = phydev->priv; int err; int value; @@ -975,6 +1021,10 @@ static int at803x_config_intr(struct phy_device *phydev) value |= AT803X_INTR_ENABLE_DUPLEX_CHANGED; value |= AT803X_INTR_ENABLE_LINK_FAIL; value |= AT803X_INTR_ENABLE_LINK_SUCCESS; + if (priv->is_fiber) { + value |= AT803X_INTR_ENABLE_LINK_FAIL_BX; + value |= AT803X_INTR_ENABLE_LINK_SUCCESS_BX; + } err = phy_write(phydev, AT803X_INTR_ENABLE, value); } else { @@ -1107,8 +1157,12 @@ static int at803x_read_specific_status(struct phy_device *phydev) static int at803x_read_status(struct phy_device *phydev) { + struct at803x_priv *priv = phydev->priv; int err, old_link = phydev->link; + if (priv->is_1000basex) + return genphy_c37_read_status(phydev); + /* Update the link, but return if there was an error */ err = genphy_update_link(phydev); if (err) @@ -1162,6 +1216,7 @@ static int at803x_config_mdix(struct phy_device *phydev, u8 ctrl) static int at803x_config_aneg(struct phy_device *phydev) { + struct at803x_priv *priv = phydev->priv; int ret; ret = at803x_config_mdix(phydev, phydev->mdix_ctrl); @@ -1178,6 +1233,9 @@ static int at803x_config_aneg(struct phy_device *phydev) return ret; } + if (priv->is_1000basex) + return genphy_c37_config_aneg(phydev); + /* Do not restart auto-negotiation by setting ret to 0 defautly, * when calling __genphy_config_aneg later. */ From patchwork Wed Jan 12 17:44:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12711789 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 DD622C433FE for ; Wed, 12 Jan 2022 17:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355910AbiALRpQ (ORCPT ); Wed, 12 Jan 2022 12:45:16 -0500 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]:23264 "EHLO mx0d-0054df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355881AbiALRpI (ORCPT ); Wed, 12 Jan 2022 12:45:08 -0500 Received: from pps.filterd (m0209000.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20CGTfDc011851; Wed, 12 Jan 2022 12:44:44 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2056.outbound.protection.outlook.com [104.47.61.56]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dj2j2g1ep-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Jan 2022 12:44:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PtDrKJJrjk4VRpCbe3vQPGwIBUogQcMAF/cUB6xOx0PyB6mmJXR54bJwg8vqbAU5b+YVmx0nS62gg8X/D7Fntv/Ubvdw7tGDk2ezxwSTj7tM2t6mVTSQsfAixElmaY0JQqD7gcUN/kNI4GUOS0qmXC0gtdCckcEx+U8wkt6FwhixlbQVisZmCmvvDoiB6kAFbE4Vb9lgYPOQ4a6aIprB/0Bqc4n7RhLgqPNp6tdi52xaMvI/8tj20wasthDf0zcm2MIybXPJ4CuGMUkMF1+HLagJ4z/p28bRBriMyrblfC7G1ZuL2P10gFNq99IJPxOEdKB/Ss/rcbpQMciZox/wcg== 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=ZpXWaBZB/QYS8THuKXaWQSKjFB8HiOgnMRklhzH7QlM=; b=RGwcDCOaYMweLIyEoXr4drKoZJe4bEE2UErwp2pVCXH6D4fV8dh5O1sDS0kqG1zsp/GlJt2PJ69KVtevUqkyIW74O8V4w9GWQi4YYZgsaIos749GezFcEwMSSFIhVbTA2O3BK9fnsts9HANvP5xjiPr/xLnYH3LggWQFWEoYmCxiMGBbziyoNWoTr84zEZANnMg1rUjTcd0tf4Gh6inKOnOYZOut1nyO+oNekPQwzcn/REzoGLKMxeSqXlJMsX4Zp+D0sJFZMgFFnqycGQMc7UgG4cyzuFKcUWgbkOhTWhwyF7BnYEpTC7yVM5zWAqSfwv04Ebn3DfvFiThVKxAkOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZpXWaBZB/QYS8THuKXaWQSKjFB8HiOgnMRklhzH7QlM=; b=jOBVe6bTqFSNi5hE79kmTFr0gQKDpkvqP5tPZc354gmjbd6YMbtztGeyAtiM0ZwJVktqI4QSiOg70snQ+gK8gTwqyGR1JqKRgMcnr8WxIAIrmAP6lMdnYKwCEjzoNuGeZNoY2XhyvoxM68AngVc73LJeoo0nZ5OOOvl+Sd+44DU= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YTXPR0101MB1215.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.10; Wed, 12 Jan 2022 17:44:43 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::6929:c39f:d893:b6c8]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::6929:c39f:d893:b6c8%2]) with mapi id 15.20.4888.010; Wed, 12 Jan 2022 17:44:43 +0000 From: Robert Hancock To: netdev@vger.kernel.org Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org, mail@david-bauer.net, Robert Hancock Subject: [PATCH net-next v3 3/3] net: phy: at803x: Support downstream SFP cage Date: Wed, 12 Jan 2022 11:44:18 -0600 Message-Id: <20220112174418.873691-4-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220112174418.873691-1-robert.hancock@calian.com> References: <20220112174418.873691-1-robert.hancock@calian.com> X-ClientProxiedBy: CH2PR18CA0029.namprd18.prod.outlook.com (2603:10b6:610:4f::39) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ff35fad-e912-4066-e883-08d9d5f33799 X-MS-TrafficTypeDiagnostic: YTXPR0101MB1215:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tkTrAVH5TcMLB6DuKNevI0Y1HNhySsZRQIT7R4KyJRxcbLwdxqz8qt2CPIGyZUN3zzyEPr48XJb54SJkcW2qUE7XDPX7PXivuY0I6ea8z588ryc3BtbS5pB7ou7hZ5ABad+BiE658R67OU4Q/8GJg5GtVILHapEj41f88ZDYsrCS3jqlSgWP11dGL0QY89xixgLMBYGd/uup15p8xoWotW459E/zKQCT4GpbZpO3NjroFuGGKAsrF34o13U9F9YL+ntniQ8LzycO1z10vlsvBGoFa3whSP+FNpoeDaKEYrkEWqoo84Sz2TYTEf/t0Ga1csgv8q+DbvZXA1VGgJxFogkkm3JmfD4gWoVV6N7RvBxXgGlcnobu0Q+Ap6ls4bt80C0kPcI8kHMSG3avngpP698BolRzKMr4MnFrSD4fXVh2TEWrQtktmysPj0keXdsyH0hwlVm+F0pceky73yLh5h+icTeFAufFJFe9Tch+kg6dvS0Tw7i1p/mOO+rbGyPMXE/glgP/pPSze2PxaNDOmXzT8lz1hOIjr4W91gvWnmuLXZj1pfHYEBfy2EHEgWqcigNlFXCaELfJn0Mhi19RAwm6CUVoJpgu09xmITZSvnW2K1chvJ+tLXhQBCXMtH1WMK+osFjA8khr2tdXHGOn2EVMOmAVhJtz/FdeWcrgfccZY19Guhd2lUJIbqZfkPIE8YRGXVO0RfR8fDjYsNSo3w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(8676002)(107886003)(66476007)(6486002)(26005)(5660300002)(8936002)(2906002)(83380400001)(6666004)(508600001)(66556008)(186003)(1076003)(66946007)(6916009)(2616005)(316002)(38350700002)(6512007)(38100700002)(4326008)(52116002)(44832011)(6506007)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7llg50XNvJ0G2yhZUZyBpBY+33i5kDUh4Tgc7dNek7tXYYwKl+cz6DzQ+9fED8CWxMnU+8Y+AMtTOXwDvtjRCGvyRUttrsLYMpGVbjoY7Ni5Ie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wDyHP66YWrYMjNqrVVD8K4F+Qp5f/b0db/RA0aut8XGfpgZfvlLNu/c3WFKDf9X+XpgrYkSH/vad5S4ndA0NBNhHCtkjgLkNQkQhWGbyor/yt14r15mTBsBYSpn+ZNq4yyEy/+ekPaHEqMGWzqjKFXYesRCi7xTKjcVEIdqZ7lHgDvjREhmltjhJPdwIDnSCEqcsYyLyKlCrGqRuFYK6wAlLuIjif1qexNEMSBomn4so6ne+Tkw0VuEsgfDKez7P5ySMt32SM6lZNfxaE5BGCs6QQnET3gtncxEemSGE5gTwXTwFv8az2YWMhID5TVddvIj2N357i+oL+VoCc43s8Ec/hZmVJg6RusCJVcKZbbNHJJQhPE1hMR5cfVQOAx/QURw7Gv6VGgmBTLJgEQ9msKaaJ7LIJhppFlSh1Wqn0zyjzztG5dY1u8ijFB3sA3jGLOhuz2B5m+Bbs/8t9YMgJn0JhtZVpCSznBlC3x+apt9XGAUeqjDAjq5nMBHFJD30qHFuOPpTGFlEp4Ls= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ff35fad-e912-4066-e883-08d9d5f33799 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2022 17:44:43.8581 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ktlCynWk5qqWO2eO0s1tA9evvWKGKF4upaPEPoLx9pP4y45Qk+dKnWSJDAglHHeeMvivbUtrOUnzl9VuNeCNuUX/goowWR42AfcZVXROMpU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTXPR0101MB1215 X-Proofpoint-GUID: dfRgOUFu1HU4I_csDdPb171Xy4b4_ZXY X-Proofpoint-ORIG-GUID: dfRgOUFu1HU4I_csDdPb171Xy4b4_ZXY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-12_05,2022-01-11_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201120108 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add support for downstream SFP cages for AR8031 and AR8033. This is primarily intended for fiber modules or direct-attach cables, however copper modules which work in 1000Base-X mode may also function. Such modules are allowed with a warning. Signed-off-by: Robert Hancock --- drivers/net/phy/at803x.c | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 63d84eb2eddb..c4e87c76edcb 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #define AT803X_SPECIFIC_FUNCTION_CONTROL 0x10 @@ -664,6 +666,55 @@ static int at8031_register_regulators(struct phy_device *phydev) return 0; } +static int at803x_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) +{ + struct phy_device *phydev = upstream; + __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_support); + __ETHTOOL_DECLARE_LINK_MODE_MASK(sfp_support); + phy_interface_t iface; + + linkmode_zero(phy_support); + phylink_set(phy_support, 1000baseX_Full); + phylink_set(phy_support, 1000baseT_Full); + phylink_set(phy_support, Autoneg); + phylink_set(phy_support, Pause); + phylink_set(phy_support, Asym_Pause); + + linkmode_zero(sfp_support); + sfp_parse_support(phydev->sfp_bus, id, sfp_support); + /* Some modules support 10G modes as well as others we support. + * Mask out non-supported modes so the correct interface is picked. + */ + linkmode_and(sfp_support, phy_support, sfp_support); + + if (linkmode_empty(sfp_support)) { + dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); + return -EINVAL; + } + + iface = sfp_select_interface(phydev->sfp_bus, sfp_support); + + /* Only 1000Base-X is supported by AR8031/8033 as the downstream SerDes + * interface for use with SFP modules. + * However, some copper modules detected as having a preferred SGMII + * interface do default to and function in 1000Base-X mode, so just + * print a warning and allow such modules, as they may have some chance + * of working. + */ + if (iface == PHY_INTERFACE_MODE_SGMII) + dev_warn(&phydev->mdio.dev, "module may not function if 1000Base-X not supported\n"); + else if (iface != PHY_INTERFACE_MODE_1000BASEX) + return -EINVAL; + + return 0; +} + +static const struct sfp_upstream_ops at803x_sfp_ops = { + .attach = phy_sfp_attach, + .detach = phy_sfp_detach, + .module_insert = at803x_sfp_insert, +}; + static int at803x_parse_dt(struct phy_device *phydev) { struct device_node *node = phydev->mdio.dev.of_node; @@ -771,6 +822,11 @@ static int at803x_parse_dt(struct phy_device *phydev) phydev_err(phydev, "failed to get VDDIO regulator\n"); return PTR_ERR(priv->vddio); } + + /* Only AR8031/8033 support 1000Base-X for SFP modules */ + ret = phy_sfp_probe(phydev, &at803x_sfp_ops); + if (ret < 0) + return ret; } return 0;