From patchwork Tue Jan 11 21:55:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12710756 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 E91F1C433FE for ; Tue, 11 Jan 2022 21:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230171AbiAKVzy (ORCPT ); Tue, 11 Jan 2022 16:55:54 -0500 Received: from mx0c-0054df01.pphosted.com ([67.231.159.91]:8212 "EHLO mx0c-0054df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231654AbiAKVzu (ORCPT ); Tue, 11 Jan 2022 16:55:50 -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 20BBn7jA012445; Tue, 11 Jan 2022 16:55:31 -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 3dgjrs98t5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jan 2022 16:55:31 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Akpavn2njX07btXSbsYuoRxdx/FZh0Dpf0Gb8Sn2/av+sNLmk9RsxfbUADAdHQecRF5uBkqLeFdSq9PZ6+3maI9JRdQCuTyc1qKB7kb0GiP63OxpqtLI6tMJoRanDBTEaqRm1gRp5sy5P4wwoUEumLc+2/6Fauw9lDxSlXRyosGFMVS3tpS/QbmYWH+z7AH6BwjwcDXJkOqkf5pZtgvWSwYtRhSF/8JhkjOLRzmCOR/8H85nFfAg/ZBpxGLS59LKA987vZn8tf5nsifCCu0E4ibtBexkPxSBAaO6+6xUrZmx8T4kesSJWDE7X9xk7zQPgTloAOcznz2kscK5R3WcQA== 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=YuAOwskVohn1G0sROrtidgXl/Lw5cfa+Pv+sjvljH9k=; b=VqbeerkiE97321RTOrM4KH1+5GlSHVvA+tb717L1EqCjvaP5qFhvtf+4HemZ+fxzemBfhZxzC3c6V3XBVZZRP730qe2iXWTDsAJ479mVaFrsrGW5GJ1pjxOJrSwUJJ38alTw9LAoqi7gEq/+lcO7/zqnHiwa+QTKODQ5j6LEDBv+oIUnUhAZemRWVEQjBtjYSzED+v59WwGSsVlxB8Z+5+yemm6ZffJ3wiOyeyD3IQILEharDxCbyCKd2bUpJF8njwXULs/xz8Jkjl/zLCl/RuPEhentcHNGemsHOBm8Z0MJqerFsXRcSxXYVOTGkShzLj2zP7A+1dbo1U7jxLOfbg== 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=YuAOwskVohn1G0sROrtidgXl/Lw5cfa+Pv+sjvljH9k=; b=MLsJ2d6Qg7K247y82Y6iwtecTx1gFbaTsZjMwqcQYmjfKv1pCLdf1iPOONtkZmDCslA7tsxdtTETA5WurKlBj/ThSPdcXRNTFjdLymqgkzK4ZArLShHLRPNnN6eJ8h+52pNkEJ8NlbKVPDQy8Jl6+IegdiXjuSvW3bwqqWQOHFA= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YTOPR0101MB0860.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:24::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Tue, 11 Jan 2022 21:55:29 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76%5]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 21:55:29 +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, Robert Hancock Subject: [PATCH net-next v2 1/3] net: phy: at803x: move page selection fix to config_init Date: Tue, 11 Jan 2022 15:55:02 -0600 Message-Id: <20220111215504.2714643-2-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220111215504.2714643-1-robert.hancock@calian.com> References: <20220111215504.2714643-1-robert.hancock@calian.com> X-ClientProxiedBy: CH0PR04CA0021.namprd04.prod.outlook.com (2603:10b6:610:76::26) 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: e70970c9-82d5-4c63-424e-08d9d54d1551 X-MS-TrafficTypeDiagnostic: YTOPR0101MB0860: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: 51tDPXiJwDe6pdTdRDzaQ1HRSE2tbhiTgtpToxb+Z1YIFVZsgwnJpiIRjAvcj4feO/qzGWHq/epNiyZ4sbzlcFIPb79y/jMzAbz28L+AM8/gnuG3OC84rZbMQ0kvUXe7J5Rnqt4bFRYcIWsZMmkKnC3MJxo8pDkzg7AEwk5ePFydHKo/NJVnZqiquTf9P3Y2mRncOfZbDTnvqEQSymkP5HW/37rYiAJw8wp8ZxCuZYLCpQzxxHIM2LeB7bGwiUEVsGaWQT9d5keGrV2vU3d+zZ1C5DksSttLFELM8cMcgCX2ORGEW+seBOLhW/GgPmXJWzM9aTQe90Uw1a40JDiRmS1gP7HBfENI3P+KTHKNHRecBfWTbOTMwBZS/y3UEXVctTBJZLw5RZUGhAKtLSh/BVS5OO119jZGdnHdIQ0weewcOzNVBjBxx8I0nT4qbnv7MdnJEClFFWzYzHMkZNbraQ8ZT4EH5tg62T9SDUdbD82sXnL26FJsiKqhSf6GztmO3rhp4Xc69a/PBPNobzJZVvo16jXtHut1Yw49T+zrrZV3nzow8nYguB1r5PBWM0cNy8XNUlGISDZFHIqMa+DGc52lRNKz3398zTk+9D9EIIOMlmAhhTSZ2oZEfcNny9TfApQG5/aF1fWIbHsrkTlkYsSOaUKG/6wjEMdHveep/xmzck6oipBA5rwdmXWKF2Z6T61QIz0SEHwCrCiE9hzUwg== 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)(1076003)(52116002)(36756003)(186003)(6506007)(8936002)(38100700002)(6666004)(44832011)(38350700002)(6512007)(2616005)(316002)(66476007)(508600001)(83380400001)(107886003)(8676002)(86362001)(5660300002)(6916009)(66556008)(2906002)(66946007)(4326008)(26005)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w522B4iVQDhU7G277qydwc6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QC26FQ7Ol8AO3/V5S2/iGjhA1HMgkfa1naavugHUzuVbzHsBDrAP9ow1yOAAvgx97gzJNsP4xkLwo+YBp4pGVXDEprBCWTETUug2DXTkEOaeyyBU2oa2yYIUBuxRA+kGzcWiL2LugJ0ZvBtBFJhHOVQ3d1n6kZzJzQyU5jIQ+LvmLpV982TvcjRmoYTp5lbjRX8rszc9woeaIZZzUy2Y8S6kK1jLrX2jF1PHPGjdlMYhySzmka4gqtvvKchamSQUaLHKbLrfBRfnRj7g5T8A3mg25TZYKrUxHe770mSZ9QQAAOZxNbqLkXHau0/ivkR1hmwhFfigirdI3XBgGsnUSzpfoIot5r+z/++foKjYKBuydO7yIJu4bNojl0bsw21XVmbAxeY1RAE4jtjI4GTWsGWG1lxMojvXBIBahvOUHv6TpmTClXzBpL2wNPHqXQKGLYmBCb02TcEPWB0MyFrWTnyocE9bH8itbWZC3ai30JJc0IZJg3HGAWqTtGxc0DdNv3PgO0UqipBpUYkqDoC7UiMQ0wAkeh86OHTToRwlV2XTsPRfiwqpRvmFdZ5Rk4GBKCeI6h+wJnys5CQNcXjd6zEbok= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: e70970c9-82d5-4c63-424e-08d9d54d1551 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 21:55:29.7105 (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: BmAZjv3qe5MFWYDKrFpmIOfCTsXAa1pSu3xujOrqkTQY3Q6fSKXY07EeBlovfiJw7pb9+LTV/71OsbAlZJJtHUGqGkslxSW71rO99z4/mMo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTOPR0101MB0860 X-Proofpoint-ORIG-GUID: W12rnVayZDxDqPcNFENCWir8yh2vdKIh X-Proofpoint-GUID: W12rnVayZDxDqPcNFENCWir8yh2vdKIh 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-11_04,2022-01-11_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 adultscore=0 clxscore=1015 phishscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201110114 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..23d6f2e5f48b 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 Tue Jan 11 21:55:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12710759 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 695CFC433FE for ; Tue, 11 Jan 2022 21:56:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232894AbiAKVz7 (ORCPT ); Tue, 11 Jan 2022 16:55:59 -0500 Received: from mx0c-0054df01.pphosted.com ([67.231.159.91]:8216 "EHLO mx0c-0054df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbiAKVzx (ORCPT ); Tue, 11 Jan 2022 16:55:53 -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 20BBn7jB012445; Tue, 11 Jan 2022 16:55:32 -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 3dgjrs98t5-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jan 2022 16:55:31 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UnytHqBIs+Ot+yv2qLkJXzNEFDlqcW86aZTi2pQx7HIKv49hhjIiandh9sL9z4hAKL+IsF4peDRTQzT4/j/sp/P8xeTftO8ngZNkZ/3zNmHr4zzmAdJRO59unzAX5nZsPyOGsDh09YgoMpIzHzslj/eKWP0YCsSom2jiBF/7P5U6lVuHgXtf+rjW5Cl3rAFYD7RnxWfln62TM7Hwei/pqEGkukZMmDavsPywYVOpqlATog4CkB09gL9tEkc1e3f2mETOmQoVAn4xzVAud1RR8Qp8xEu+Wn/zUhBIvx8wRVmDttweAdJ9Qr9sPUdfZ5aMvgwgdxgYk38lMD//2VDxYg== 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=EEZkAxnjK9MWxxhWI3Gz46BeOPRHgtv6cjjv1/qXUMI=; b=X6GKUt/IGkl7w8EtVZ/fXb2j5QaUAyvwftDqJbLcZ38Va6voc8egwwW73/P4NW/yw5HWjIFDlJeSehhYNatTbsdfQwOMkh6F6vThaGAFxSTqV0BB84EtPzUD87geo8bNAT3XhzYKeb9ATFW1wl9JNC4Dr2RlWFFqtLIErFi9uCZSTmK2F4FQyDlFV7wT6z2nlmCBNdLT3ec86DWh9e1H7KGLqrpzYJwqEMIVocW2Erqus6yQlKRAc2pftNEQwbadHAiJoZEkoFNqUHGDQbiYF222TTTZw8j7DQnRwuElqJgHEZbXVikAdutkwU2f8Va7PQryZ+8cBxyan/yxU8n0JA== 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=EEZkAxnjK9MWxxhWI3Gz46BeOPRHgtv6cjjv1/qXUMI=; b=Y6sUzfWaeOol5xEs8i5XYwYQ9SQPFqyjb+2AjDK1iCp123tgQo8z8o9+lRgKUjl1Y2qh8VTCHKqlkYdD4VTREj2HFMAYhq4XfXxjTA1eBi7RHmEAfpn0tDCRIi/hbpDFYLBQchQHvzfxD4GV8WXUU9n43BeMPxY3Qbn8/7uQQZY= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YTOPR0101MB0860.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:24::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Tue, 11 Jan 2022 21:55:30 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76%5]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 21:55:30 +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, Robert Hancock Subject: [PATCH net-next v2 2/3] net: phy: at803x: add fiber support Date: Tue, 11 Jan 2022 15:55:03 -0600 Message-Id: <20220111215504.2714643-3-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220111215504.2714643-1-robert.hancock@calian.com> References: <20220111215504.2714643-1-robert.hancock@calian.com> X-ClientProxiedBy: CH0PR04CA0021.namprd04.prod.outlook.com (2603:10b6:610:76::26) 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: 76545d77-f122-4ac9-fe73-08d9d54d15b2 X-MS-TrafficTypeDiagnostic: YTOPR0101MB0860: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: j/sJ98Rd/zqtg1PpyovtweIjxK6JGiHrnuG5xQh0rCQgy67vbGIhkrSNSImBSUT0x6XCfQYILEtfo86Lrpxoy1AzbV7nPx9ryZAIEmx6sIp60IrFN1l+eekdXo2yv007IIH9Xz2ehAQDfM/Q5ArqGSOjzWwtVEPZKtZqEBHgMut1WjDotvq14WFIyz/1eSeVN7ms6kzd4LzqRzSJoj0+GfW6IrxAm6iHUzEysYRwkcLZ8QzQuUMBwOmbkkyyAwvncjorQMi39qtak64okEZ2VyH6l4zcSVPjRr0rPKJ7ifZzJvwNWD2cAIphNHNeHDlYrPmQtb8HRFbj2bTIoOQEbRZYdpUtu71bflL2DQ0B759GSBPml/HusQtXdc80B7+1kNHYQdzJ95J2OUUo/GcCdKwt8WC6WkCUrm4OZXf6r5285Y5kg7G5DD0COUeCVZ0odJt5DhPzfMD5TmVRnwtEVY4EtcnN1w98SwHqb4RZvxrbiFfkTgcc2kUzwKrsQYnAEq61aMyMy18L9J9M9Yw2sc+kRK18izVdq2gSWCb0eAmdcV09KPjoTsYbeSq8sy/LzrK9anBTUfTzZkNAzvuYWtT0+8lThPvca5lJLey/1RqYCeQvVyLgxg/W79YlfKGxP22f65CRNsPdGYGOnKaCyExat9VYur05jlHu1cIjHXWXPGGAst7qKqw16a70lg9I+4oukrHZZe+OitjYXVospg== 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)(1076003)(52116002)(36756003)(186003)(6506007)(8936002)(38100700002)(6666004)(44832011)(38350700002)(6512007)(2616005)(316002)(66476007)(508600001)(83380400001)(107886003)(8676002)(86362001)(5660300002)(6916009)(66556008)(2906002)(66946007)(4326008)(26005)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wdQ6bRFiaYO7B1+tghaqYJA1q2EZpE5Lbq+bN961Jv5SxhmnMR4yqbvVakDCnQCoVrX9+sbo4wI2rkKcG9s2mEDENIulP0cYP5KghMGIqhvBe5XPj6S618Yp/ZH5zTyA2Dod3fmCgD4gGyyYX9FTS0bzCRtWUubLXU3t2ojIQHE5Fnc9HfjNyCUAuQawo0uubl8cNeqlVpfBNmVXNp3Y7nnPXgIWQtcPThqIp8v9tRq6TeQcJiq0+X4gWW/Gbop/8+bt7x5iZfu6ori+LGus/fKvnE+j+7+vmAMrISuQKFXWh0f4jHSDtFelcX9gdaePQ6+QRxO4qJ+EEMgi3ZpsAFc1bE/xmfu2F9LufWtLc03pRV18eYILGpweIbsfaViUbu7Df+dhvG6hrEgek/FmKpVwF37rNzOPBDNskfwsj4VwKGhShn0RfGd7UncB6u1Of34BMsFM4+gt8qhEkL0wlXVvlt8BvoBbmGZlSjAUoqH6KXJ7EvUEh20qdBC+Q6cu3E3UznAmaBCx/AO334ItWFGOGeoaKDQimpx864RXs/YE1k+d+Xg1O1CAldDwf7P8sPTNRsmnaIMNy1USWYY9jGtuY6BGSuAfws098HKM9n+vT+ELiH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ian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76545d77-f122-4ac9-fe73-08d9d54d15b2 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 21:55:30.4135 (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: 3lTl8VNTdcJPpPjVCu7Su7mhxaif3hRl7hjs3K04Hc6aFRdD1vfTaKUQNYzwQoe7gI8etM8DhjdwRxX0C7wz2WxPMMp+eBA7kvqTezlJasE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTOPR0101MB0860 X-Proofpoint-ORIG-GUID: MjbVefZXynYSXqmXsX6v7-Cz_BCqUSlD X-Proofpoint-GUID: MjbVefZXynYSXqmXsX6v7-Cz_BCqUSlD 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-11_04,2022-01-11_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 adultscore=0 clxscore=1015 phishscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201110114 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 | 80 ++++++++++++++++++++++++++++++++++------ 1 file changed, 69 insertions(+), 11 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 23d6f2e5f48b..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. - */ + /* Some bootloaders leave the fiber page selected. + * 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 Tue Jan 11 21:55:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12710758 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 B1E49C433F5 for ; Tue, 11 Jan 2022 21:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231654AbiAKVz5 (ORCPT ); Tue, 11 Jan 2022 16:55:57 -0500 Received: from mx0c-0054df01.pphosted.com ([67.231.159.91]:15928 "EHLO mx0c-0054df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231287AbiAKVzv (ORCPT ); Tue, 11 Jan 2022 16:55:51 -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 20BCxNSl017415; Tue, 11 Jan 2022 16:55:33 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2054.outbound.protection.outlook.com [104.47.61.54]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dgjrs98t6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jan 2022 16:55:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EMMnp3rJfRdlg1Vw1W2qkWLok6hPWu1no4NowKLWhNCRJB9D0NSvM31VTE8DeERbsbrhVJBgsFV0CgOq8gAplBAeay4NtvrEMr0gSwM/uai8HiG7YDtqBAMk8lwEHYFdiKibtPNWX8doV/w0hc7hSxZGq/vMR93vcFfzwaHnxvcgZnxQhcBp/pKYolTAkgR+ZJCt6EpzakgqiJhPyErzYdjK+Q55JTFVQfsKRS7uqKRvqViIT0ZX3IN1nBG6fQFgJFRxE4xy3QLHtjLMAt4YtCG1581qcL5U2hZXn9LexNdbS/ccwgvmOhE6BInuE68NTPZ3WAHcBScuUQPWRy/9YQ== 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=kBuYLjUDUCk8+JiMFFV6Q4Tp9SgMq6BTRse48ZpGO7uY2ZogqjIwNCGgUq+pq+NzsbJCFTBlQ6ZLD8Sxg9yfnGFsnVe+zybP5DlGxgmq1+1nZsSU3LUH4MygPm+6L9IOQVzuUY7wouMMWbsxWiSJzaRe9ViOUyCR7obrfjCIPTRIFlaoPZ9XtQX2uh6OEArRCHSG3W1v/7ZFUs52lf7GzrqhfNg0lwWtOcTBWTBzmhubrjzcHWIsZdZqmOPD1bfH9DuWmAH8B5oJL2SmWX9IulSXntSrjg5u4r+kdqH4g2qr0U/69sAub+UExuPJSNs8rxSj1gv6vWWB0gQ91x217g== 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=tqvSheuFcctPXEsS0Y49oIH+7iy6m6tHNw1hkqQ+903JVOv4oZHS8hH/g4q1nvdTxO0WqcLpRzP1tUunvznwwwv8BXTHf3Jdyda9MJyuXuQwrph1t/ZZzDmYRMcSFS/np46ObumdpuoO81jSj8s7G0n2VnL0AWJSO3MmCXFDUfQ= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YTOPR0101MB0860.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:24::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Tue, 11 Jan 2022 21:55:31 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76%5]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 21:55:31 +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, Robert Hancock Subject: [PATCH net-next v2 3/3] net: phy: at803x: Support downstream SFP cage Date: Tue, 11 Jan 2022 15:55:04 -0600 Message-Id: <20220111215504.2714643-4-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220111215504.2714643-1-robert.hancock@calian.com> References: <20220111215504.2714643-1-robert.hancock@calian.com> X-ClientProxiedBy: CH0PR04CA0021.namprd04.prod.outlook.com (2603:10b6:610:76::26) 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: f90ba91e-b918-4ca4-826e-08d9d54d1620 X-MS-TrafficTypeDiagnostic: YTOPR0101MB0860: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: Lf7SpS+Xrl6smfMx/TVm4SO54oWYrzd5jUfNPtrDudwREoGK6MYdjUTtXll8jHvPZoTRYKEBledROY3dYM2CfjjOb9UtYQQHTDk7GfUQE0oHo32UZEZp6PYGBlwZrF8O4+D59TcAKbVGOfQa1YOEYBZxln1iABdc4QbzjfaTu4Soa6zJ+ooRi+gTFMVvsdQjvIQmCI3k7bRKksmtQ7emOae8vzDj+IQBTe4VathXvJQQGhkMEWxUtYVyUTab0rdKyDFl3te6l92rhQWmjUrzm1ZKhQChzVgxsA1UxrPoq+L9QnqD48tNoUXVOu/urROWPC6UoW5BaqPCY+daRmNxlUsJKwsuvoWQ38OEplToRiUNMQ0bB9JjUZDEuXXKzu06cUm0OJXxBwIykB4xGDZuWdlPTE9RZKzYJX5B3mfHfpz4K/jDopek1uCBp6vU4K+CZbnVTStizdeeNxSw+XWsLWFYlDb0bvp9ZRu36lbSl4FaxE8wwryaoqCcqRf+m16aMGGt6o54IOqgqg3TTTC9iiSEIaP938KNjtCoQgIIe/NmqnnEUMlWMYuplJdhJxxiQyHA95JvLkaK4DhL4Ta7WG3SlqhvvUMA3111jy3FzcM0Exbye5P3oshzA3xWnNfcfIw11v7ADiTrGsOFEz9ndk1fF3mL3B7SodNKkU36cGTP2mIfBo5pl57W2MwxLvBwAJ3x/CBuTCy9ur/rBJ2DSw== 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)(1076003)(52116002)(36756003)(186003)(6506007)(8936002)(38100700002)(6666004)(44832011)(38350700002)(6512007)(2616005)(316002)(66476007)(508600001)(83380400001)(107886003)(8676002)(86362001)(5660300002)(6916009)(66556008)(2906002)(66946007)(4326008)(26005)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OjvvW1MbJFJlpYnd7v6GtLFp5zTqcnYbLA66i+xOQ6aAeJ29TXyabb3qcGW7ztn2rB1KdLHug7vfi3TP9IuJaTmKeyxKmt5lzJ6jtcwPDXr54ErS2vGu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QjT8Hb2u5gaNLJJAWrXLzu0XyZ4Gd8exhFVRWKJOQRzkE37iiXKWIcAxa7qoiDG9Lp9CrYDy+/xLwpgD9hgPcuNg/btZR2zDVocfrunyrvgbWl44/nb+JH6cNe2+fAq913lAuLd3ZQiFbhrrZczV8YXmq9bT7alF2g53zgP5hdJG3uWFQ0zZTLOtCUPvskXA7bot8eJKrVY6MWNCIlrpisK9y0tWgoX973/00qwjaPdvU2nAZ/ojqeoOeqCay1eYa4LQ9KEGOksNDs6TN7QXyetqbD6oOv3SemkTCY2Dl9DhleXQrwc821c5wQ+KAWfSa2MQ4aThJebkpFkkRCzwhuSayWFInvuZqw6ufJpciGgTNx6V9tpH5b0/uN/4UBKjuyaAJOvq3cJj9wNV99AbRkR4b8FbB1HDJEVrd49CCHUOLUKpWwQKDTPbUHrvTeJLrw+EpoMtamcYygVfBPZus4cfWutBvGPm0quzleVsi6+7hO359mnE930E0uQ+bvjg= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: f90ba91e-b918-4ca4-826e-08d9d54d1620 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 21:55:31.1325 (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: ucrubeCxWgK/4moWPyJsui3eZWl+AxBZGMkCyQmZBkIfqbboxjQhTDB57JdltA97eO4Zg2Z1uKj+nT4i1aaHsc49wGVkBsi8mw03nB54gaY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTOPR0101MB0860 X-Proofpoint-ORIG-GUID: D8gp-DxLWdK2GQPApJ8Lfde3fYn8uRGw X-Proofpoint-GUID: D8gp-DxLWdK2GQPApJ8Lfde3fYn8uRGw 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-11_04,2022-01-11_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 adultscore=0 clxscore=1015 phishscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201110114 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;