From patchwork Wed Jun 30 18:01:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12352651 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 X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE56EC11F65 for ; Wed, 30 Jun 2021 18:21:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B607B61468 for ; Wed, 30 Jun 2021 18:21:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233199AbhF3SYL (ORCPT ); Wed, 30 Jun 2021 14:24:11 -0400 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]:14858 "EHLO mx0d-0054df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232694AbhF3SYL (ORCPT ); Wed, 30 Jun 2021 14:24:11 -0400 X-Greylist: delayed 1164 seconds by postgrey-1.27 at vger.kernel.org; Wed, 30 Jun 2021 14:24:11 EDT 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 SMTP id 15UASanm002486; Wed, 30 Jun 2021 14:02:14 -0400 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2056.outbound.protection.outlook.com [104.47.60.56]) by mx0c-0054df01.pphosted.com with ESMTP id 39g3ve0s3k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Jun 2021 14:02:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HjTriUkXPHf9tzBHbmzR8yMixR4jdE58GctkohrQ/7DmywO2Rm91m6hqrp2bA3zvS0lN/K7hsbPOmicWdgra5Z6VZAsoPhDMBKLfdJ4VQ8hrb+6nz3J2aBejY71XxRTb4Ez7ASOAsCEup0dtWGKWQ71GBpiH+L5NkahN4QcD4+L8y4zUOLSQwwrRrsKz0MHx6Xwm0uRW/fUGfhLo0iP5VOmjZbhr6fkRE1Qz32srXpoPSmMaopktZbKP1EQNpzXCoW3NzN3KCjNERhPgUAXp48PGw9nFfgTlte/gCxPxrkbxh6nhOg6/9kO23g41gc/xvW3/bwcb1xpOWt+exZ2Qrw== 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-SenderADCheck; bh=sWc6V2+PPKBVDqY+32B1uelob0EbtcK0Kda7TYwKQaE=; b=J4ekhbTQOjfeiVrGE3vyvHfE57S8dhamZIPLkyfqrqi/wvLNVx1FgeHfJRgkV7tShW+XSSK4RkYQe1LO1qsx+ZT0r8vVYQnSP/8O5BaFKaE9xRzwDhSfPim6Rbt1RIe7C5PNLZkWJbmSn/9w+GdsAqPbC7iql9W09ZlNx2GcGEdguV3gPCmSr7yF3AviX/BferYtl0jXZdtyaKk2HbKrY3U+6lGIzu/ioAXKQlgwwqQxTfebo+3CMi/RKWbo4YkY/qJw2QZdhIoWzb4jnllBtYFJQkpV9toIZL4g6Li6aSgVJBybFb3iQnV6uJTR6NHeVg8V75fZrFmU1Dhva1jlNw== 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=sWc6V2+PPKBVDqY+32B1uelob0EbtcK0Kda7TYwKQaE=; b=5kJeCfNdCojrC30iigMjA9lttHRffA6IpcoEiJ/PYBwQGrQSzlpnlWalmYdN21NiItJ9F+ql81Vsuik6/emzuxXpgkfu/WZjUTsu/s3RdY0TuFQiSAUfBLz6cGd7K0yuv+QhLDv77gxdj81U5IA9BjyOxou0yHXVOIUMkkBFj1g= Authentication-Results: lunn.ch; dkim=none (message not signed) header.d=none;lunn.ch; dmarc=none action=none header.from=calian.com; Received: from YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:27::23) by YQBPR0101MB4569.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:14::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.19; Wed, 30 Jun 2021 18:02:12 +0000 Received: from YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM ([fe80::88bb:860e:2f3a:e007]) by YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM ([fe80::88bb:860e:2f3a:e007%5]) with mapi id 15.20.4287.023; Wed, 30 Jun 2021 18:02:12 +0000 From: Robert Hancock To: andrew@lunn.ch, hkallweit1@gmail.com Cc: linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, Robert Hancock Subject: [PATCH net-next 1/2] net: phy: at803x: add fiber support Date: Wed, 30 Jun 2021 12:01:45 -0600 Message-Id: <20210630180146.1121925-2-robert.hancock@calian.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210630180146.1121925-1-robert.hancock@calian.com> References: <20210630180146.1121925-1-robert.hancock@calian.com> X-Originating-IP: [204.83.154.189] X-ClientProxiedBy: MWHPR08CA0047.namprd08.prod.outlook.com (2603:10b6:300:c0::21) To YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:27::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from eng-hw-cstream8.sedsystems.ca (204.83.154.189) by MWHPR08CA0047.namprd08.prod.outlook.com (2603:10b6:300:c0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Wed, 30 Jun 2021 18:02:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 40ffe92b-53f9-448d-11c5-08d93bf12f99 X-MS-TrafficTypeDiagnostic: YQBPR0101MB4569: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D/O9vmEhvV2S8E657kQMgI4IbYbdkP/LdY8WhSPbubcpCdgNrW/mAWJv9UWP0OxnjVSix+hlmce984dtY19xiKdV/GwtJzx7q/QdWBRRdauM1G472N2N/wJZ13lY7TWo9QJTyZPTEtJ4fUWjFZEaEXO68zBjRIWEbtR3LQKSsfOnEvZk4FY3ezrmmqqKZ0Lm87yGnT5fVVpAeE02j8WYX/rZ0zrcZysLXb6sle8NJoRFHwii/1SmtnrnAZ3Czf5wsHQh1iyh+IWujUllNKufqyA6qcPNEepVaB9NGG/utj4+O/pzMq/VGlnc6eLQ/ssRrDFELbLouOu+D+5OKQrNQA6O14V/tE2/j7giPilTFSFtqFP3fS6uvR5Q8/sxqSaxdXbqBhn3w1s7xNg6m2ppVX7KlOe1YwY65iTkjQBR60CsWqroyp2T+It4sWwi6NRjIWrXoBvC39gAYlRlKYoOsdjkizJ45G4x9Bi87Dza3DXjWOAthXfXA1v9AD1j4TSt40yjcvnqC9g3oZ3zbaG1TjeAiE9bVtNGYI1rlzEjdSxEp/j/tykybmngy+12rvLJh8QQcp2gCDMaSomHrenCi0oX3/6rr70VJIscDPFeGYP7BwfkOc4znZLAoQ9uTLWL888vPmFPqrJVksp/jCKoYoOdc+EcYQRRtZ3z4od8hS8VMGBphRKH93RwVGSLxWedigJeZ+I8HsfPBobbY0Gm2g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(136003)(346002)(39850400004)(376002)(396003)(5660300002)(16526019)(86362001)(186003)(956004)(2616005)(1076003)(478600001)(6486002)(38100700002)(66476007)(44832011)(6666004)(83380400001)(36756003)(66946007)(66556008)(8676002)(38350700002)(4326008)(2906002)(52116002)(107886003)(6512007)(8936002)(26005)(316002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ug2MqNGXS/805zvIE56PzXE4NJdqdkPuMjHOhlt0seWnpUjGe9/dzEt4P9tG1k4b+mK+eDLicbPxzKxC6Fy+VanxYiJ+xzITa/GahzURJ04m343c/CWlaVAKkKutfdpEUusuV7RfKuUTOvtx4i1HMpjoHgH6Rl/3XJr83eKFx1m7WEYJYZB7FwyEp1jHJxdaAB5rwG4Zg3XA/WwK8V++trZoy5vd2I/7OnBDksNQyKsrIAtULIcw+nOJvwtorzM8NHdz7uUqSox2Ak/dlwVGsiForI6kmHaYfHLgEzbTdJ1clBmeStbpEy5G30mY5ubGHyxpEkkqQJ79BkwNjX2hVuXX0dRLkl5Vw8jotvVTT+E3Zhyad5BLdCELvv1F6fwmmq2zGc2Is0c6aGG7LTfNHt2t0vWKN73W6lTNJo9PXduZbGJYNRRDmrFcXjG6XmIEa8HdMjvMQH3Q6B0mXewp5639s7+LIWjTAsGONiJZkj1+SMl3Uao5JQLo5iLQACCoCJ2Rmyk9UtTEXPoq02yfxhoQoXvswAFk1VvqbejOgeUQM2/6t+2Jl1GParYwDUyYo9sqL1v6jW/tyvDSlKXm+b0f/jeNStdOt1cqJ6hkTLkZ5VD0fqwK3hX3BKmdOw4vqiC/gpYiUxPAyTtaB/AEh8lKdSdTLaqhRfxOnN4maTyqTqJBZrJ9D7O46XJQt+wtraOsvaMapk8JxiwWal/0Xc39q7vgRX/N7QDep5HXND54402LkP7NPmP4aKiNAoLt/Btlsa2upnubNeJOyNUNaPvo2UGKHTM/8OJPNSQQ1tW4fXfyadLcwGlMkkWvD26X5RMr1RhczEpWRheseiQ4ZBbeGev7CcEe8fqcYHLBBwW6rfxLTsb4G8N6f0EFPeW4GX7RBk8Mw+mAaBwjM56atU9vTBbjspawQG8Jljy065dAmaMI+38WEk1DZ1CnEAQVv/r5vatify2lHyXe2m4AQMda0G1XKQ0NMPVnUHwqyTy4SELwgnBXcqoKtCk7PnuAZTUkH+kDRZLu3/JXMaFGlo4qOXcCxYjkyvhN/Diy5xy7hzNqY8+bwhkH5psRM/Ga3FIIbdMloyEiHiU2Zx8O54TAivnP8GWtFNXzyvzKPPs23OXJvDCZWLL9+6sPehmDecA4ln50zRzNPpSPzebZIl6OXGJSWolNeovRciHtPVzcwvvRPMWioMaINYL3eh8EGcKIOoWblX/mQvREUIldPFvbGx3v3UQZ9PU15uc5iBHY8YH6LOOrXB3d0bK9w/ZiQan0kaTO3TO8RFvK9z4FYmeAmqRjxMFp/5humX4eQ3b0Rs9J3ZxZFDubrEa3F4CP X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40ffe92b-53f9-448d-11c5-08d93bf12f99 X-MS-Exchange-CrossTenant-AuthSource: YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2021 18:02:12.2827 (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: dm3qWDxxfqBuDWU0wVdg+QN9Z5VONIrFusrihfexEEx/tyqzlJ/JEKmpEwVKxy82AvQ4VUNH3ReP0HoWJQbRD9A9lFK4+K5wXNSY+E9ez6o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQBPR0101MB4569 X-Proofpoint-ORIG-GUID: zFgCO-kJjYeK3Az4i1X0FyHYCHZa9-F5 X-Proofpoint-GUID: zFgCO-kJjYeK3Az4i1X0FyHYCHZa9-F5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-06-30_08,2021-06-30_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 priorityscore=1501 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106300099 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 | 69 ++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 10 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 5d62b85a4024..65f546eca5f4 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -48,6 +48,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) @@ -81,7 +83,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 @@ -191,6 +203,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; @@ -673,12 +687,32 @@ static int at803x_probe(struct phy_device *phydev) } /* 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. */ if (at803x_match_phy_id(phydev, ATH8031_PHY_ID)) { + int mode_cfg; + + ret = phy_read(phydev, AT803X_REG_CHIP_CONFIG); + if (ret < 0) + goto err; + mode_cfg = ret & 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; + } + 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) goto err; @@ -703,6 +737,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); @@ -720,12 +755,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 the device is configured for copper operation. */ - 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; } @@ -846,6 +882,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; @@ -862,6 +899,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 { @@ -929,8 +970,12 @@ static void at803x_link_change_notify(struct phy_device *phydev) static int at803x_read_status(struct phy_device *phydev) { + struct at803x_priv *priv = phydev->priv; int ss, 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) @@ -1029,6 +1074,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); @@ -1045,7 +1091,10 @@ static int at803x_config_aneg(struct phy_device *phydev) return ret; } - return genphy_config_aneg(phydev); + if (priv->is_1000basex) + return genphy_c37_config_aneg(phydev); + else + return genphy_config_aneg(phydev); } static int at803x_get_downshift(struct phy_device *phydev, u8 *d) From patchwork Wed Jun 30 18:01:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 12352653 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 X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2737C11F66 for ; Wed, 30 Jun 2021 18:25:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD6F16113B for ; Wed, 30 Jun 2021 18:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233278AbhF3S2L (ORCPT ); Wed, 30 Jun 2021 14:28:11 -0400 Received: from mx0d-0054df01.pphosted.com ([67.231.150.19]:6695 "EHLO mx0d-0054df01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233223AbhF3S2K (ORCPT ); Wed, 30 Jun 2021 14:28:10 -0400 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 SMTP id 15UASann002486; Wed, 30 Jun 2021 14:02:14 -0400 Received: from can01-qb1-obe.outbound.protection.outlook.com (mail-qb1can01lp2056.outbound.protection.outlook.com [104.47.60.56]) by mx0c-0054df01.pphosted.com with ESMTP id 39g3ve0s3k-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Jun 2021 14:02:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j8rZ58q8LnJS1TkbiWKi3lr29OBWRIWSZqI4FNmN0vzOpcWbVN5X4VZp24wCe2B67rRm4UyzG1k0WgcNnJU/SngD+FtInhrEtgOZuQgVM/yCni1O5ZZIKW9ik45lIOcQRLd9n6N3xvPVmO+LF5NBYECKhb/2NarhMcXaueawZBEUNhgDAQS+juMTV4qG5U+9O3XgRGTXApNr6j8VEVbijpzkxIfiXcFPh8yPV8uGCCbFTvfL6q8xAIJNNCtjTBLTdLUWRbvQmeXaEhE42srTIHQI1nr4tXPSbKyJyoI7rjRQANVAVxsqNyK+z6S/Y62lvZMx06cLOGYQ8dotw6zyFg== 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-SenderADCheck; bh=YnbXZKk3VHBztxlcQZZPIJ35CKH7EIxGsRlQMBbbWmk=; b=LCk2yAC9nG/CBrDd64UWnOKbajqwro8p4TPtZ1CkIGZSg4BfZftmcnQUV8Y0lw/6N/mRM/niwJRfkgdxDfi1LxH5vWL4u3342oJBxLgF8BlNvy89hMCIOzl7FBBH45aq59aVi+07gEEc37z0MsuwwebU4IPu5HCsVAzB/flBEQQKSzapA9oKkcvd2WWhgldjQCg1Fo1aRffxkiUjHbqc7jNBeoAYCirSxq/cNCUpFE+pgo8p8pXCyjnupsEQHeA+QaZhTobsjvj1stKaUeNLLqlHQ3dnCq3dFfWSD32Xi9J7PlDn5EaapI5SweaFBO3njjrn8ir/AZwglBqaEceHqQ== 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=YnbXZKk3VHBztxlcQZZPIJ35CKH7EIxGsRlQMBbbWmk=; b=m5XQ8DgVhjLoSaaR6MzJyuRrKxno8ce+JFsrkstWJPR+69w4y9RfRvUH0TadO0HtjAvLsafqqCu+ZWX5fnvOtk/MrlzLaUdIP6gOeSjpO0rG/nja9Y317mZze7tducFjCPtFI28ybU5XvC4dr1kJmn11y67yiz2KhKYcSScdetw= Authentication-Results: lunn.ch; dkim=none (message not signed) header.d=none;lunn.ch; dmarc=none action=none header.from=calian.com; Received: from YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:27::23) by YQBPR0101MB4569.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:14::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.19; Wed, 30 Jun 2021 18:02:13 +0000 Received: from YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM ([fe80::88bb:860e:2f3a:e007]) by YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM ([fe80::88bb:860e:2f3a:e007%5]) with mapi id 15.20.4287.023; Wed, 30 Jun 2021 18:02:13 +0000 From: Robert Hancock To: andrew@lunn.ch, hkallweit1@gmail.com Cc: linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, Robert Hancock Subject: [PATCH net-next 2/2] net: phy: at803x: Support downstream SFP cage Date: Wed, 30 Jun 2021 12:01:46 -0600 Message-Id: <20210630180146.1121925-3-robert.hancock@calian.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210630180146.1121925-1-robert.hancock@calian.com> References: <20210630180146.1121925-1-robert.hancock@calian.com> X-Originating-IP: [204.83.154.189] X-ClientProxiedBy: MWHPR08CA0047.namprd08.prod.outlook.com (2603:10b6:300:c0::21) To YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:27::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from eng-hw-cstream8.sedsystems.ca (204.83.154.189) by MWHPR08CA0047.namprd08.prod.outlook.com (2603:10b6:300:c0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Wed, 30 Jun 2021 18:02:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 61c7500b-614f-4943-1988-08d93bf1307d X-MS-TrafficTypeDiagnostic: YQBPR0101MB4569: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fKj2UzXf3orgs4m6rypxuF8vajnexvcbYTZkSPBrD5ATA9pt+i9t4qOaqNuTneBIjZTDsi4cNYrNzkkuCiBMCCtxXZ+G196NJC3TtBfsasLhp8U8tuQjfjbccPgbaH9M1KZg0Gu8VF5+gbTW9usz1V8vonXVe+UB62pkWPZNhRVGUhtdrcW0AP5Q94AXTJCqykeflAfiWaKkb7o2WrvuUV9/T930xiFSZ/kiMt8gSHMvXAmGuQ7nlFdoQtW3rxVqFNaNdl23McuY8ptc7Zf1OMd3FjW7HtJ96RqCkq1yeRXkRl05zM3ffddmhKk7/i7EE5X6yEgC4kM96NaIH97rU5gWW5JRLe384uECuxccEng15rfy2UMauIsFnJcjXWjpbTNsjYesYEqN2L0k9P4BsYSen2Zptx5i3U2rcTB0RFjj2WZK+8E7xoevGMt6dpizXDZ5AxLdZ7OFS7zHtx43wrPfx+rxsVwoVprmU4GuQ/fl/VcnvfZIfcLFYRZRWRK+6YOxgfvIzncHx3ji8NN7n1v3JC4Ry1K3BzVfsf1j1fKJvSkhNwv9Ygd2NRshPKiSvWGbhntZtKcgrsJAI6V0IoBrQbwwMUrble7DnyX9jtGcMOv0QZAw52LctAKeKJelh4eM/BT3pj/KJwR5P/fmBfQZ3qv3rBowLFTO0RpXPyY2x91kKGZxjokYkJSUEf+DEm/nnXpLm516htrrgkMS4g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(136003)(346002)(39850400004)(376002)(396003)(5660300002)(16526019)(86362001)(186003)(956004)(2616005)(1076003)(478600001)(6486002)(38100700002)(66476007)(44832011)(6666004)(83380400001)(36756003)(66946007)(66556008)(8676002)(38350700002)(4326008)(2906002)(52116002)(107886003)(6512007)(8936002)(26005)(316002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cCB3l2kQ9bLmXvcuzhMXpX+Wi6qbq7gSrGRVGYg5G0eO/K54mh2VkJtCtaGvWs3sR/ZGB1+fjuM4CocOO/oZ8EVTEAQn4XbtXjf12PkkpzJFIhXfy4rYQdZjZ0cdzdA0xMXQjYrmBPNmgIlI2gCGv0fLNIIfUJa/gc3nM+OC68JA6OwgTGZ5OZ0sJf4oJWf7JlVdlqgTgBjHr4wEfCK62UVQeK6e0tsPl5T9WiQht9b2IsbwHOD06hh+yhwFRehtykV6/dCYr9BKH9Mp56oVgBPhf54FpCh9s7oPzKt/ODDD/dUqESW5vvYk/KV0EPHpxIFO2Vb/F2TVyH4GlvC1+E6AY8qEKIeJYkk+aVCdqSlkTWiN+Uw3z5PYCJjNYTbGzKRENgrlvXLepSGFBfWgmaAJZoifa8x5iY28y37DAoXYilPaeJTHhlPlgPjYy+DsjIpHSQmwlNEl006vVT5/GXfh3TgXIttmhlCncToY+9hl0OWp0yvoAowtGL2zsa07WKx2XZqQj7fLM0WWZL/T0ia8Xwez2A9fFJCHgC3hKOMX2EOCWCQo0Qz0Qv/QhquPNo4Xv8UCRYmNQGDkOjRYgDQX2SS3HIj+kq0CGggZjgitZxCFq+qgQMrnq7+MQXjKILz9hBy8usbNp65vzSuC/Oh4URpkWg9RYoA7Ff1mhQNwqWk5mk3keZICTEPTzZEqVAPykhyYZ5iZw5g2Nl8uysDEg3ayYFRX2qQb4aYLtT79qfH0K5SnctKUyuku4g1Cew8ZlfX5qwhvC1MBVXTgEh6ImBo5CtzroU42CGVO1wOpb0IgpAsNVqnrUvRD1xQlMVEq0tXOLgu5VW8HFOgoY0CM4eGhdOwaD2TbmyVlHBnV2SJE+bqgzMgeqI1YFi5EvIjbEBc+yXDE+A0MbbUIn0sS5N4trllaunmj5MZRNYApJ42cmiTGL5FplMALwBFYV7xS+pyUh+dNg1wfoHlp7mVBByXJRPTYHz+cxG0HIZpTJjS5ySw4nWj21Aeuliiczo/qiyu40EMCCK6iwYRu8vLGoRolO9bG35jogkDGtqQDuDTWbM4Xs0Yu+x9N96mJdS+s9M3Kb5Wg2O5iKM4DPRHZIUXky99jQXo+pt8rV9l0DgZv5d/qPRehxV9C5ZV6TsRtgurmq+7ktSP9EpPGoLv4z30e9IcF/AekJZXEvt0ymTuzazrbg8fLgYjoGREVYnF+YEAadIGrKZDgobKTGIjMZSNOAmYarbqrycpB0Yq44x1uf6WWY3aJ9xvNFdSnaKg6VO9l6111QtW3TfSt4/uy3GH+NwS7O9g6xHv/M1pnGQFYQ5ThOb/8aiusL1da X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61c7500b-614f-4943-1988-08d93bf1307d X-MS-Exchange-CrossTenant-AuthSource: YQXPR01MB5049.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2021 18:02:13.7880 (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: nPRelmKuB0WDQoc6c7yeePAu/GJNOQj5c6tyNSHcc/JA1NwJgpJWB9qms/YVNY1I3hNqzB/B6bQGOIraMYbcfBQm4VQKVI6iIPFSWLsJGng= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQBPR0101MB4569 X-Proofpoint-ORIG-GUID: 70_K49KY1iSSgqudUQ978bYcsHPY3pcX X-Proofpoint-GUID: 70_K49KY1iSSgqudUQ978bYcsHPY3pcX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-06-30_08,2021-06-30_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 priorityscore=1501 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106300099 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 | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 65f546eca5f4..b613e26b6b16 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 @@ -552,6 +554,51 @@ static bool at803x_match_phy_id(struct phy_device *phydev, u32 phy_id) == (phy_id & phydev->drv->phy_id_mask); } +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); + + 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) { + dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); + 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; @@ -716,6 +763,12 @@ static int at803x_probe(struct phy_device *phydev) phy_unlock_mdio_bus(phydev); if (ret) goto err; + + if (priv->is_1000basex) { + ret = phy_sfp_probe(phydev, &at803x_sfp_ops); + if (ret < 0) + goto err; + } } return 0;