From patchwork Tue Jan 25 16:54:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12724033 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 84E7FC433EF for ; Tue, 25 Jan 2022 16:58:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1586900AbiAYQ5V (ORCPT ); Tue, 25 Jan 2022 11:57:21 -0500 Received: from mx0c-0054df01.pphosted.com ([67.231.159.91]:11580 "EHLO mx0c-0054df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235103AbiAYQzG (ORCPT ); Tue, 25 Jan 2022 11:55:06 -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 20PBNFCI021579; Tue, 25 Jan 2022 11:54:37 -0500 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2055.outbound.protection.outlook.com [104.47.60.55]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dsvtr0xq1-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jan 2022 11:54:37 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CtLTQp1gmAUCyVGwPxw3gpW6CRYR9k1pVnTqWQtsHkM+4TSKcWqS9ralQXlieW0W1EjRibmdS4h3aF01D30wGrSxWJc97P89otuq3fcVGdEYDQ2OIMafNg/6YKNtO71u6hKyPYBEPe70m06MGroxKxcP4oC1tzPiYX6+nU0+6+1BTk4GVsT7eIivXtaXjQQU/zyofo6VyKNrw93JipfYvmswtiAOV0Yw1CcEtT5mIVGW4dc4LlR/jPaVpMrrBjcIqHyYyB9hVLQuHA/4eKYKmy1e8uJdHcS4c3nGgZps9KDguX7D6GHOVyGnNpa+tH46LIHw+mMVfntoviS61qKrig== 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=fZpCsyTwf3EyAwoM6R+82m4L71YGEiuG7z4Cz/5WX+Q=; b=HHwm0i2caQSxzqvJJU3VCN0kfYX0N2PkDlmQofJDTazlQH2veBCOJYlAqCLOhDigHscf3/YNyF3cHljxQ78gH+teH1AK+105ifP1p24/rMOI+S2CMPZPa6/RN+oYwi/hADM1lWwHJ9mhxfjf0VPyf27a3xNQAhBYLB6bSMjKb5sD6Ig5eUxfyN3Cvn2bevG248Sj1rm3g2rtk/rsU075SQMk9tEgk1R61o4YCnilYGXWvbAhsGwpscoyNjWZ5GczQ3241pUKaT0LX0apAvI0vLPwVoAXxZ93cydF+UdSDLa+o/5CIbURzFfnKTw93CoNFrIAj6OlRGhft7njHx2Qew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=fZpCsyTwf3EyAwoM6R+82m4L71YGEiuG7z4Cz/5WX+Q=; b=yZRQDVJyb4/SBHgz3R/zWsUxEJThDHX3fajb/i0Jyhiw8OE/tl+AyOB3N34uvbBbQA0Iyf8tUwnYimzSZ5nGACSQiWH64eWpGgckHquvhl7qtL1z59XVutHxKnqnlUg910OhaNS4M9PsyyvW2idDAOuN/yQm5ir8nEVlviK0/6A= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YQXPR01MB6124.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:29::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Tue, 25 Jan 2022 16:54:36 +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.020; Tue, 25 Jan 2022 16:54:36 +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 v4 1/3] net: phy: at803x: move page selection fix to config_init Date: Tue, 25 Jan 2022 10:54:08 -0600 Message-Id: <20220125165410.252903-2-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220125165410.252903-1-robert.hancock@calian.com> References: <20220125165410.252903-1-robert.hancock@calian.com> X-ClientProxiedBy: MW4PR03CA0193.namprd03.prod.outlook.com (2603:10b6:303:b8::18) 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: a9c4dcb0-a3a9-4b31-ad82-08d9e0235e58 X-MS-TrafficTypeDiagnostic: YQXPR01MB6124: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: O96fTNpx8DxS408VfDVP1dUbUQBXKj76jdpi1utQwJR540HfEnCuaFNI8n1jPwMQBv1PMbtY2cpqSR/dTQfHmDPa8fVcCOKSOwUw28Ga01Xvup9v3cSWmdYnISXq2FUOrMINk2F/LXhH7OCwje3D98D/g0qdco0gkntzo7wDtvSMdwpApUds+JmWKPU2BLljzgiFsHTq1yvQ1K4G1fYxeP/7ttC1RsLiKt/ItlxBg4Y8PzEc8fFcww2bXG+2VYvtxb93h05SQ2aET17y8jWiyugSIVTBdn/YTyyMfTv9DTpS6RFDhuZuN/LXO2K4EOZRfHNxnZ2QepSzx4/mdX9nPMJSpOgMPxpsOFV2Og4nBksWT2CVqXqvFrEf+QmjVIEf1ZU3CFGK6N82geb3Zn9MKsQVK5Pk7Y3eKjiiVoM5lPL+dJ4pzDMI0ScPIN+1GOVpJgTFOOMpS7ygppmlFkJ1+ZNGMKT4zYc5zP005USAeKQc/C+xrdAHNOFzcy6ogZBIfeJiNs+ZyNms1hhfd3rcGRTpf7hQ7XPBNk7SanLVTm12rUYR0LH0YTaXqsFgzY7lm4aAxm5gfAyOB0OEOm6m1JRMXcD3BM7xjPaDKu7XDyPPQSBV9W79LLyqLpp+kPOk4PObdEwDqZc+uuw6csdo8ZDz2FgmSsZMj24vNLNteCZURyvb1EV7vyG37q5pvk6Foxm99/3hpAaxWTMTVFlO2g== 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)(2906002)(26005)(107886003)(8676002)(86362001)(508600001)(6916009)(5660300002)(44832011)(186003)(4326008)(52116002)(6506007)(2616005)(83380400001)(38350700002)(38100700002)(36756003)(6666004)(66946007)(6486002)(66476007)(1076003)(8936002)(66556008)(316002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HPTZ2JuOM7AfFINeBwvc3swkruw4ht52QvjA6dhmlEG1YyLxq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YCAkJYcUyZGUa7GoRY/pIQnLWkkxAQx+g4agMr5DB35UPsFwLWFg0qe0NrMCUkhygcv5XYWnMivVIg5Fepujj5Cg5X/hb0MdsHK9xIjYlqgaWj9RuoxlSbsm6iYKIktpLrg+IU3LHjDuN09UVhcXL22ra2y8ll1P1smtwaJPLKyY4a15EUqSkJGLdwtwtXnGjYh8OYpLa8XlVj+fQoUT35+WT6rEzGWm28HFj3HCglzyhnQoCsXVtrk+WWQ0Tjky49b9Wsw0KzWYvm//Hy6Vsm1Z21Y23U5zYPhVk3Uy/WsMhQUkDR370yA5/mIUS2ZBOxfmPv0yfJ4XRs5PrbV3yb9RBSB8XX4N6ByJTPyRXMmFn3oxzmVvVbttb/Lqe0ZhIZTKxaQEMv1PpcLbFWL6K1ODHmqfA20+zoYGWXCx8qI9bh9R7Iutu1NTagRvDhkjhJkZbN9o4mBE+GoC3oQ3/1tCVtDGNL9IvXo342Apo4zQZvlaFfqa48APRTgnqCFtzMWtCbpxAW8uwFCfn8Nr7PwixXcY7JsV5tw95GND+yE7b7dBWPufOGRkhWhaYTFItqWdefJtTG4cFXa+D8= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9c4dcb0-a3a9-4b31-ad82-08d9e0235e58 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 16:54:36.2545 (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: 6QjpUDwcR6XiD/LeyyuTH6kApxtmx7HsBSgSTKUYPWjDTv/j6iVtmGhpg2PbD5deppTixw4ZAEfxy6dE5dn7SLuGD7QOEPK5u4HcIZrxRMI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQXPR01MB6124 X-Proofpoint-ORIG-GUID: s9UKxEcI5ytc928KdOk4LxIqD9K9ORjd X-Proofpoint-GUID: s9UKxEcI5ytc928KdOk4LxIqD9K9ORjd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-25_03,2022-01-25_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 clxscore=1015 spamscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 phishscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201250106 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 5b6c0d120e09..052b2eb9f101 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 25 16:54:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12724034 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 67618C433EF for ; Tue, 25 Jan 2022 16:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356278AbiAYQ6a (ORCPT ); Tue, 25 Jan 2022 11:58:30 -0500 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]:56800 "EHLO mx0d-0054df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231327AbiAYQzH (ORCPT ); Tue, 25 Jan 2022 11:55:07 -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 20PBfHPh020266; Tue, 25 Jan 2022 11:54:39 -0500 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2054.outbound.protection.outlook.com [104.47.60.54]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dsyrhrj15-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jan 2022 11:54:39 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AFeG3CmFWfX+I++Vqng5CJ7AO1vCjeF8nVCfdUwkSWdng49q827MSnigSa8RAef6v8CJWX8+LuxQ5f0BNNTEQkyM2fDm9F6NCnMra+wzRTzJEdM9/TsH5l8RIh6PJra/hSZZEY7eqtKBKkv4PgpEqtn/Q2FYB+URqpcrUmQg02rtUhNVKNc+SYgikJqAz+4GdrREqG2qWQE5G+oU328wg3cBAMcIHNuTcEmPsz7qkGa+A9/hQHdRiDD6yAexXmE1IOheLmMLbzccZlAP0WeuCRhmrrIxaG3+6pjCGK7JVqzcZglAiDcjUv6BAwYXAYntQnhmgAwxL+mYXR5KqDX9ug== 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=nqCpLUeei2OgNC7ml3FC2a092V7OZpuFb6NcCys6+bg=; b=A/HjWIv3rDeuyp6qmwSjcUkHEv7jv50t4iFviWfAoAA64QPE/VFh7OxUxdq2RO8D6rrfIb8U65gL1aCy/uA4IEW8UoO5NX/P2cBa0nNueXxsHRjECdmtq6wBF+vLC6u3qP5uYCMTwn9ZfXUnVnkVqnCl+CRN1Ef72UKTJJZbSUeQlWizM2ZN/XJ2tylGM8E0Gk70io48HAhaDQaih41rAz3moxcepxd7A8gsZPJxcCUiN62SU4x8uDffuMiTO40rRP7Mc5blLeF+IpsIvZ4dzBJjkScgPy1fxlM+e/wx/JqcK57lnBxQIWEoRNejrtia+sOpsr6cmoPvIR9ldTuBLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=nqCpLUeei2OgNC7ml3FC2a092V7OZpuFb6NcCys6+bg=; b=T2DjAxb8yiNAj+FHxMTE7F031JWqAHEKHeXSwD6yTc3kbpg58s7MzcJykun415mD8UP0tiubJmgVeUbWEyxGIkBS9fpXdWE9ZWOiMLI61W1zQJhOLCgz39x2RbUoLFhTVLOr6JfP6LepgknGMEmDlH7t5VIfRUdwckNj/qQzvsM= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YT2PR01MB8631.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Tue, 25 Jan 2022 16:54:37 +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.020; Tue, 25 Jan 2022 16:54:37 +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 v4 2/3] net: phy: at803x: add fiber support Date: Tue, 25 Jan 2022 10:54:09 -0600 Message-Id: <20220125165410.252903-3-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220125165410.252903-1-robert.hancock@calian.com> References: <20220125165410.252903-1-robert.hancock@calian.com> X-ClientProxiedBy: MW4PR03CA0193.namprd03.prod.outlook.com (2603:10b6:303:b8::18) 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: 4ca14faf-886b-460e-8e24-08d9e0235f55 X-MS-TrafficTypeDiagnostic: YT2PR01MB8631: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: EyDac00YkfSK25iQ8188LX4F0fRIDkpLyWZ2z2vQk/deUd+lhZ/3d7HLYR9JhQtvaT0GXb1v6/85BiV4bs5IE5NlfUqKfKGXIRGdnVBZIsOBbsd8vSeYnPBSzosyl5sYpedX9d7lMbjGspwkQB05IBBPIKvaYV1V03YMdQrwOWIbe3Lf2B+Gr3dFQcEB/K5lwWbH1vObdPO7hI75nJBwSQEfcpzcUlFMFyHqNRBI8FAhLnxe2eTDo05t4yFQyNxPgF2uF5Sz8ha7DvRqr4ZTlZ+HVQtQDjesrmV5IYTBVIHlz2EP155tisGVrpuPRMD3QPassiBuwm39xQws8da4UKrU6JVkdqx6I6cuep/5xr+/RJoREy6mgyM4vGRDmYHJJ5XHop1XDw9TJITK//9sjAMWCbUTpv5Mp8JsG1LKDJU6Wo+l8wtKERI9VNn7sOZWtgAUYOmOFJXfC/jmjHjhoUbowj189ekyxhcvdRw9rsIDO4gd1hqWbti+Uy6BwH+ZSlhDCVbtvsAIz/CQpkejjPF8QQdP2yvOkLiIuJ7sxKNTlH+1CMKBMHBtgsn2rs4ghtwLvQIUjbjeZKCfqUMrBvNEZ7Hi6pRsOcJX8UfYm2MQrPgg2E6uE7FwH4PSI9UX1vx006fGjFJ9M17FAOjDYs18CfrxW9LIf04H1HTLgtE/hLzyboF/NAjUw8zY5H6CiGWPmCPjg6LOHfZZ7xDzVw== 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)(6666004)(52116002)(6512007)(86362001)(66556008)(66476007)(6486002)(6916009)(2616005)(5660300002)(316002)(66946007)(44832011)(1076003)(38350700002)(2906002)(83380400001)(4326008)(38100700002)(26005)(508600001)(8936002)(36756003)(8676002)(6506007)(107886003)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zmAOkooMWqMUAYUTD46sHh4OoNqINbi44YDQQ1qk0psL8E3qmcES2QnQV/QqlVmhsh/V4wetiOZ5Ez8Zzfo9XMpzFNNNNlzD0BwHqhuW3svlahOta6+JxrofMsFh1iIIa1Llac466nzJNv+ikukSySY6pueGRXkc1t2prTlWS8bKFtf+uXm5co2kSh2cFXXD2eWekxn1hz+iWq3sDbvfZvH/OkptWkHsO0djgX96Kf1X++uPkVzykzIKTwAiMnWwRbCRRFV1R//+37upJd94rPVuIf1zBs211a7nFMs1nw5sVRWlTLqWEnh2qGGt6gLoA0m6RsRc0kC+yy8fY/V7Rx+qWobkH+QBo+132pO4Zki5LBPkgLgDbewgaKgMvwoo4efghU/8onBiFDMSIOyrLZaoHwb8JPHX/AXzsB7kaRCk3YaXOWRjfJnaLmW5IFjIdaFpQnQVYn3FZfDLxPjbKV50zL/h06ZQDIc/Adq8suWztaIvCZYfCGyyRG8yoNJm3ZBAp6WWLk7dQkhRCqun6zzuJLykv6Fiw8K/SkUY3xZ7g2sIsQYJ3K+xyW4fYqtlhwZFu9wp1UhCzgO1OJyCuatQJdmp3JdhNZkfg8xC15SYsX7dgFrHKLVhx44MleWv7YP8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X-MS-Exchange-CrossTenant-Network-Message-Id: 4ca14faf-886b-460e-8e24-08d9e0235f55 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 16:54:37.8961 (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: PoahYrlA+UQ4glUSsH8ajqELcy2qGexA2+PIRtaH54Gm7t7J3LQ0wOoI68nmofm91tNS47zqFhJBgyv35ZBKDJFeGrKWVmpFZyoRx4SAIl4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT2PR01MB8631 X-Proofpoint-ORIG-GUID: hGNwb0W6W7LU_JvJjmrxDz5jMve4czQl X-Proofpoint-GUID: hGNwb0W6W7LU_JvJjmrxDz5jMve4czQl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-25_03,2022-01-25_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 bulkscore=0 priorityscore=1501 adultscore=0 impostorscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201250106 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 052b2eb9f101..3f3d4c164df4 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_50OHM 0x02 +#define AT803X_MODE_CFG_BX1000_RGMII_75OHM 0x03 +#define AT803X_MODE_CFG_BX1000_CONV_50OHM 0x04 +#define AT803X_MODE_CFG_BX1000_CONV_75OHM 0x05 +#define AT803X_MODE_CFG_FX100_RGMII_50OHM 0x06 +#define AT803X_MODE_CFG_FX100_CONV_50OHM 0x07 +#define AT803X_MODE_CFG_RGMII_AUTO_MDET 0x0B +#define AT803X_MODE_CFG_FX100_RGMII_75OHM 0x0E +#define AT803X_MODE_CFG_FX100_CONV_75OHM 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_50OHM: + case AT803X_MODE_CFG_BX1000_RGMII_75OHM: + priv->is_1000basex = true; + fallthrough; + case AT803X_MODE_CFG_FX100_RGMII_50OHM: + case AT803X_MODE_CFG_FX100_RGMII_75OHM: + 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 Tue Jan 25 16:54:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12724032 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 75A2DC433FE for ; Tue, 25 Jan 2022 16:58:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1586488AbiAYQ5N (ORCPT ); Tue, 25 Jan 2022 11:57:13 -0500 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]:56684 "EHLO mx0d-0054df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237131AbiAYQzG (ORCPT ); Tue, 25 Jan 2022 11:55:06 -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 20PBfHPi020266; Tue, 25 Jan 2022 11:54:40 -0500 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2054.outbound.protection.outlook.com [104.47.60.54]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dsyrhrj15-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Jan 2022 11:54:40 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=moIFgqgr7azZheWIdNiEYf+9Bvs2BfS5qVywwbWgk+mIF1A3wjPDDN2aUpMIMi6vV/wviWnOmWndg6jLgTyVCRCLSNK2kzNExYSgA2434rj1e1Ag8yU241FICavtqDKJVh10Obk1EhoOvxvC3TVmLus1TiX484751pammp1m/gAo8ui6iHxGuJsIgbIjIDod5xYd8iRnjgy6+W1WletJdRcq2OzhxKnTd5bWXEhySHm4iBqV0V7wcP7c/7+WO7232tD7cXS5rjVvbrP4QsyrwYtX1NyzSjEF+tMlTVZzXv92xbI0Pa4osfzMNTfndEoLXwA2WKE8MThrH+wvT0Pn0Q== 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=7PMOcvq/RJSohh4g5+J7bO9/fUMk03CiM3MUABB3JrY=; b=avasUk/4Y4LrZzVds+Qe2cR/5vCyqMc+r5elr16nvbGzhIPqSz5q8HER9E4QVN5X1pZLtuAsAy/zFpzOKhUlt206kImC0GjmOX9fLL4rTkpFgjati7IUqy6cZUCNtQ5C/lh1FaiHnict7fO7x5suJv0lLESgz4jZtWS7dxaAfA3/fZLFJWBvT3uTy128Co2iSSIygO88ylDrRaiYGDk8EMPL0YbVBLJwZkyfu2zpMjWzvftuXOjpd2Fy/ytsT2JlSPcBb/Q8Cv3l0i+0TkP/sd5s8l2zyVhH1dtkDIEiPbOclx2xPZZchdnq9E1Td7uweUfBcxEH0uy4q0xihrkzTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=7PMOcvq/RJSohh4g5+J7bO9/fUMk03CiM3MUABB3JrY=; b=2YjhjgizZPA6/JLxu7Ww56sr4Ao+vKHFM0p+cyCMapav+15zTmonHAXO5axxp0uu733xNxLou5xuKfx2MkJ4kgWLN0IBMcz6YEt2tkag6nyPV3h6n08Hs/BbJTxuO9pQCkU46gOYNUJdHjezeRln5aPhA5ShOdSyN1Qu4/0jdp0= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YT2PR01MB8631.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Tue, 25 Jan 2022 16:54:39 +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.020; Tue, 25 Jan 2022 16:54:39 +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 v4 3/3] net: phy: at803x: Support downstream SFP cage Date: Tue, 25 Jan 2022 10:54:10 -0600 Message-Id: <20220125165410.252903-4-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220125165410.252903-1-robert.hancock@calian.com> References: <20220125165410.252903-1-robert.hancock@calian.com> X-ClientProxiedBy: MW4PR03CA0193.namprd03.prod.outlook.com (2603:10b6:303:b8::18) 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: e03fd901-7184-40b5-78ee-08d9e023603a X-MS-TrafficTypeDiagnostic: YT2PR01MB8631: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: 24O/us7n8guQ/WLXhQcYlr9yZGOnhOcTj0jGp62CaRbJX5CS09j+gzdW8zGuy+dysQjJm4USH3y77oQyxLC/btELj4k5Nfu00bGz+mOLxvcoGqTKK8sRu+eRTNks620u/yyihASmy+aNX3n9YNA78PgfpfrylJyOz1lrSfvj5oM4zrsUPuAHTkY8pNYZXUw7VC8S2lmzj/1cZ885f1zUQkic1a0fErCD70PL5Ycexg37L4kFFso34E10r/LWKdf/WzDhN/7EttyYmC5hoY0Bg8jOlYVvLhZmdLHYm5tplpw80MOHGjDoPdgElVLLzxd14xlQ4vW8cfSlU8Wg1zwmTYRerDTIPa4xy2BzlD35QQSUOCdhBr/eWfNcCu2DTwe2zL6QnBl55Nu1iir4kKsJsI51clOLVXPbavPlpi1z8IPvXT3mS57LU4fLF/Qqw4oSsVZvS56GMLwctE6FmiA76+yoxRJ0eb9gC2t/46uUMF0Cl/VD9z0iprYWd9cMHKZBuM7cLd7F76qTTBX5t02ZWZR1Ym9SeIFv5I/llc/huRLv3PU6q6ysN5+hZaVviM4C7rovRkfVRWPYosRGhi8+XTJB61qwLr20aTL6MW4e61d9fSgyjt8PxzA7h2Sk8TgJ2cxL7CDvceLvb5LFZJmIUwOBjkNYJmsYUwNtacNNqL/BNSfJXUJlR/+zCZb49w7ya6D96QqzhyzNTV/eVrrYGg== 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)(6666004)(52116002)(6512007)(86362001)(66556008)(66476007)(6486002)(6916009)(2616005)(5660300002)(316002)(66946007)(44832011)(1076003)(38350700002)(2906002)(83380400001)(4326008)(38100700002)(26005)(508600001)(8936002)(36756003)(8676002)(6506007)(107886003)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XQeLn9c1WvKAS2SxysYPI0pSeG7NYvQ6FbvJL9Qci9z+0ij9ksiJc88ErAPIO928RtBD9wV5VbcSp9JyHUldJNzgf/aKgetYc1L0VMnTqLfEYA371/trPr7dsoyU5tqiimBMxWJ4K2F4P960QTv1bSGmlHtzkwLYZOrX0lJHg5KD9V9YTQ+TRkVBbZmG3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Elg6fa+TniQHWoybGZvBU0f+I7ZMvXPX9SzSikna1vEmXggONUnq/p/8pisFRjL13tTImuyKb4EICeJZZq62ppYMgUpfxF3YM6hOaTYEKXjKtDvZMUiYn1Vy4twc7rLe1GfBVVIZrcSJV4QKF6PnM6ZHScbeK2fp1OW9xQp6xJat+e8gkVH4DOOc/IefxrZJOG8/YKFlXLPSRVx3/O4yK3E0DT+puCIITxf9uxKMhj/jXb41OM53nRhjvSUbESmCLP/aJHmQ560jmw4WNGG/jvFS/9ss1AUY5e1DOkd/tBNGNyf2SirPtS3+GPa1+mXFRNiDHFSkS2S1THHtV0cO1vBetHFllrosn5CbLRg3D/5NnQjUSEtcvN+iwDc01sBmRw/Om790S4iJmbVkXQsE9RRjoQ1cyMFPr1k+eVUGdlu+qzTK7aSarSvGn2M= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: e03fd901-7184-40b5-78ee-08d9e023603a X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 16:54:39.3964 (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: XaSvmxc68BzyicE3pMRvR/sLZNDedpmnphoAS0nEX0kor0gESUo19fbKaHspxRWir6XwsYkINTsLBSNBSuVTwv/yKY119CRkbIeTaRlchCY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT2PR01MB8631 X-Proofpoint-ORIG-GUID: XFy3i8BlDj23LPAHQE27xsDNROPKuL-7 X-Proofpoint-GUID: XFy3i8BlDj23LPAHQE27xsDNROPKuL-7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-25_03,2022-01-25_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 bulkscore=0 priorityscore=1501 adultscore=0 impostorscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201250106 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 3f3d4c164df4..f504fe536fe4 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;