From patchwork Mon Aug 26 05:27:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13777100 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2078.outbound.protection.outlook.com [40.107.21.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BD7480BF8 for ; Mon, 26 Aug 2024 05:41:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724650895; cv=fail; b=H0ilwcwV4f46yMj2r9Vw7ZEp3FOZenTXMUfZzVZEsocrSdYG70+KVMoFLuqd4SBYMhO35i0ZOhQ5XjwAhzTMfLlm3JJ62gcOOG6EJqOqoAaYzZyEjajP33tGo1uQyJM0vs/XTLDIff+h7W/qJ+ypA6nSrpf7BYOxYuaErkhnwvs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724650895; c=relaxed/simple; bh=dTh6wJYUtBEZKl9qoBzB8sYAYbFee47xoW3jN6rzvNE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fH0Wx5aEG1VvQIcHVWo9/VEr0kByVbHEdfSugZL+JhosC4saP4+sCD6KzyGnij5PSXrFJXOS6gx5mMOmZlYwt7Xll8H6yA2prEwz92suS3Jl84s1ODGXp5VngGqZTl1HXaOvbZpUZXruwLjvVRGXol4Zu3h4KDxvuog4zjPuopk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=bXMq8d8x; arc=fail smtp.client-ip=40.107.21.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="bXMq8d8x" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G/Nbq94NsjzY2uXYf0Wp+m47zUcFaPEY9cLa8b98fWFBIanRfygPG4eEqXhP5K+ogfos9N/B/ZmXbUptSrmg6/yqiNrrBNtc3QqaxjwUpjhs40KaQYmbl75xYg/OPSnS5mpqLxaT97HCd/MoMEP1EYAdqJJAS0+dUsSl3u24CpymgvaD7D94BTv51jgTmwx/F1Wemc68gFwNlo0GKMoc09RfC0l2EjAuop9UQVGvJpmDMXMu5FvtDBJ/dWxqAP4Z3LKv4SoH1Uc0L2uVMfS+yezt3XZ849NEmLwqbkO0h16024LSGwXr6cj4p3fu19ObQ2kEjNpOKWYYNXysyNGSHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=zxcxAgBuaO9j+hcxrrxig7XYuhzpSqsDRdxv+wGjRRc=; b=XJH8OYDRvL2S0QEfM7QeQe0T1ZZKrqKu9GzfDkAWjQnrm04XYNR2wmVVkKSl9MOMOlIuS/8hlL9VPxoNh7BVDc8vBxGJPkv9q3FDGSjnMFatV/op52ZOphmLOSRacPL1TOgfrDswY0iC+CeEePBPe21NbpYX9NB5eh7enEPmy6KAbgE4u07fUosC1WVkhyMjm5MXVIIkIaItTUjyHqhdV0Irq6bIJUCQe7UIVl9GJjFX/aOEWZE/GyLf96WGBGRHWKrCsToHIAhiBEYaofVPm73ZenE0NK2QJnBs8/3RavaW+4/LmmRVeIw/7r88i441YJjUOkbZbeXv+yfLJgPA+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zxcxAgBuaO9j+hcxrrxig7XYuhzpSqsDRdxv+wGjRRc=; b=bXMq8d8xdULC2K0d9bCXRZyJB8BcroJT45SKnBZ+Lk8HySL9QrQsV7yLkI+xM5IBgMx0Q8YsY7iCrMvIHagSDG8TAWDUPBGKH2lbLPPLMO5q5kc/kjOZohRGkUYyd3i42YYRqnHu1Y238vEvxna/H+83HS4DZUVAFpvbT4q4cTK7yAD3u94fp7HWRpIP8gOeAdDliib5j2Dme2pDfp7iSWBjKJSctiJVgPsMXYNDRX4ENEQ/kRRCqhX5GFpMeePflgsfGtIMmEXzMKaG2C3VRpy2BtC3Sy8xNsmGv7G39WaU79yUCm8LT/TU5/WxPDEFxtCNQDvFFLvOHABZY2zHUg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) by PAXPR04MB9075.eurprd04.prod.outlook.com (2603:10a6:102:229::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24; Mon, 26 Aug 2024 05:41:30 +0000 Received: from PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db]) by PAXPR04MB8510.eurprd04.prod.outlook.com ([fe80::a7c2:e2fa:8e04:40db%6]) with mapi id 15.20.7897.021; Mon, 26 Aug 2024 05:41:30 +0000 From: Wei Fang To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, andrei.botila@oss.nxp.com Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH v3 net-next 2/2] net: phy: c45-tja11xx: add support for outputing RMII reference clock Date: Mon, 26 Aug 2024 13:27:00 +0800 Message-Id: <20240826052700.232453-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240826052700.232453-1-wei.fang@nxp.com> References: <20240826052700.232453-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR01CA0156.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::36) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|PAXPR04MB9075:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b6ee90b-dcfd-44dc-8814-08dcc591bc7b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|376014|1800799024|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: hkBHz8jdCEYvmaIN7avpgNW3oCJ23P5JLRYyNsnDDu+h1Al7z8kr7gKRHqeV4mVlQN/K1Knk2s/TQo5mEv3Az1eKgr0wTXn7X7vilIw5UqOW2h8o7a7xeaAtgHCdDjwrnvaSkmpVRsVhHa7JzReyloqOW9g1f+R01xEGoftQIrj4vDKtMFM+Q++dgVQNUr6EDvELsDmQjQJlPvrbPzhnibHsaj87oFFEGrHNG7jrLeoJwYBJmlTjpy8s4CttMV/W36rCg7GNnFAMTzyf3LjrbdOcj5vO6YJiqQbN3G2VVTY6N80e2Y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XeGsMNEfaqDJIoHxuA+5M24tLeUs+n996OXPJ6sftqyb8QgoKLkQdQ8Q= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8510.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(376014)(1800799024)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b6ARr1nIVw0HwVX9eKOK8SY+3wV25akODtJ9HNprtixZp9pznvOgX1plTKMEjmYlKw8HsFU603706VmxWoENdkemXi6GJ9EBgaq6QHM63QAB0YYBEHx1+6YxoduWFnw2lAT7PqGR/LUHEaueqGXPl51gtp93j5UM9LHGrS2p52Bapm2o4dysI3uIxQOtkMXhmE0Jvy7KSkXwaHyotqDR01i6IZt86Gk0GQFt+mEt0eai04hEgHsZ4kDyvLuoUU2fvnzZjIHZq8zWQvEzRhRVrRGQ0vEudjtcOokP5qQw1OaqdFsmyRVKzEEROhS0dJnsGEl0M+UZD5onSyWYfexeKFPgARiTR7YcUvBW9gQIb1uLrnLuiZ+eioQAJhycsDjdphe8JUIgBzeKNseaYDiVNcMPIRzp+p3JN0lHf1XmTUaxS4wlIBxr5fqCz41lmy/cIvqnC5kXhWKLiKQkhVJSb1updgX07Aisrprdh9+yD2EuKcYuISU4dJLO85aY+GIZY9htXLEjtk7dJYPxJGgD7QnmDS4fkEsyR/Z9s/3KdreSgSQw/R6w6HsA6o9MH4rQn7ZxeusxD7zMa9riryZo3p4wf29Ydm9gOUHxdGO0WwPUSOCfliTyjRHtt5aRGQYpVV1Jc59WjQ72j7juy8AmGVU+FszSEYXvMYCuRijdhG1rSoO2KFX0OGZQ8D9Sp3WutnTeTb65ITU5tXvKzz0AMzXsbz65olaocf707TKEVLD2TrYRKISWJwHF7BmPflNr4enkPP7ktlRAhsLfwt3SCzrhRdyBXaatV4QvnnM3XzeaKs368FhBWYyRI2gBdbicEVIVY4zolvt297TBJihOWucy/UUBj4iIEnRA+ap7IhGE1WfdeXjHlN5+PTPkjp38aT0BuNKPs4LbiDR964cNPvl4337fq6IxC4WvgSSGtE/de4lqPMEiMfj0arb+oHG0QYFO88Qk7VMiQ515B2myNF7m4RbHTon79TmJqMR/ZA1WDY0ASdQKVl/ZVq+mfECgCZsRryBVpt+UtjYkFrcZwuYiBIIMaf0y+5mn3bya94AQ5kEdxSHgFcBsT7HZrOt6aeSRBlfPxkxVd0aC9RNS/BoZ73QNe9BK0rkqVqbsVU/M/2aMjbnajJ2BTTsVTVTtquIPNgW6VnglbZP6B9d0eFzxqUXtrmnq7Bm+RwsrEwxybbYrPlVXHyadlK4IgUFFmFmSbcscfhg7GBskrWUdl2e++TSCRTcMcpHwP8PE4m9UmBJkUCjrnz2WUR5cAqjY+GNp/LS63TGn5Z0zwjPBIl05dD14G+XHt4wrp6QnU4W0sLqxU9nS6LGdJh3snrgWfpxw9KGI/HRshwRvEGL2OWc5fZ0ievT1WKjshcIGKVEVBLfkWeUwttKOpkMMOU9DflUQnCgqfR4WitX0rYHuDiJQvFypqtqLTm+cAYF2jiSyCR5vvFRjgJN1JaPpPaVIjrMQ6HCyxJqKZIEIxxy/9fPtWVSvwkpD8ntg2CIgq41txWdtIAb5ZfRChRm+fi/cGs6Gs9KSmscUFQOaYus+ABShf2V3azTI7YO3vwfNmdNfGAThCMIXqQGkGGtYWjGf X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b6ee90b-dcfd-44dc-8814-08dcc591bc7b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2024 05:41:30.4414 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HzZeTTWmvsTW7s0MkC3WJ+ROm9eaHbcN8HgBaIXQKGrM/KkzGdW6kFFBkJ5LDNFgmoD0bTuEEyVBbWRA5ifRLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9075 For TJA11xx PHYs, they have the capability to output 50MHz reference clock on REF_CLK pin in RMII mode, which is called "revRMII" mode in the PHY data sheet. Signed-off-by: Wei Fang --- V2 changes: 1. Change tihe property name. 2. Modify the subject and commit message. V3 changes: No changes. --- drivers/net/phy/nxp-c45-tja11xx.c | 29 +++++++++++++++++++++++++++-- drivers/net/phy/nxp-c45-tja11xx.h | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 5af5ade4fc64..880d4ca883a8 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -185,6 +186,8 @@ #define NXP_C45_SKB_CB(skb) ((struct nxp_c45_skb_cb *)(skb)->cb) +#define TJA11XX_REVERSE_MODE BIT(0) + struct nxp_c45_phy; struct nxp_c45_skb_cb { @@ -1510,6 +1513,7 @@ static int nxp_c45_get_delays(struct phy_device *phydev) static int nxp_c45_set_phy_mode(struct phy_device *phydev) { + struct nxp_c45_phy *priv = phydev->priv; int ret; ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_ABILITIES); @@ -1561,8 +1565,13 @@ static int nxp_c45_set_phy_mode(struct phy_device *phydev) phydev_err(phydev, "rmii mode not supported\n"); return -EINVAL; } - phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_MII_BASIC_CONFIG, - MII_BASIC_CONFIG_RMII); + + if (priv->flags & TJA11XX_REVERSE_MODE) + phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_MII_BASIC_CONFIG, + MII_BASIC_CONFIG_RMII | MII_BASIC_CONFIG_REV); + else + phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_MII_BASIC_CONFIG, + MII_BASIC_CONFIG_RMII); break; case PHY_INTERFACE_MODE_SGMII: if (!(ret & SGMII_ABILITY)) { @@ -1623,6 +1632,20 @@ static int nxp_c45_get_features(struct phy_device *phydev) return genphy_c45_pma_read_abilities(phydev); } +static int nxp_c45_parse_dt(struct phy_device *phydev) +{ + struct device_node *node = phydev->mdio.dev.of_node; + struct nxp_c45_phy *priv = phydev->priv; + + if (!IS_ENABLED(CONFIG_OF_MDIO)) + return 0; + + if (of_property_read_bool(node, "nxp,phy-output-refclk")) + priv->flags |= TJA11XX_REVERSE_MODE; + + return 0; +} + static int nxp_c45_probe(struct phy_device *phydev) { struct nxp_c45_phy *priv; @@ -1642,6 +1665,8 @@ static int nxp_c45_probe(struct phy_device *phydev) phydev->priv = priv; + nxp_c45_parse_dt(phydev); + mutex_init(&priv->ptp_lock); phy_abilities = phy_read_mmd(phydev, MDIO_MMD_VEND1, diff --git a/drivers/net/phy/nxp-c45-tja11xx.h b/drivers/net/phy/nxp-c45-tja11xx.h index f364fca68f0b..8b5fc383752b 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.h +++ b/drivers/net/phy/nxp-c45-tja11xx.h @@ -28,6 +28,7 @@ struct nxp_c45_phy { int extts_index; bool extts; struct nxp_c45_macsec *macsec; + u32 flags; }; #if IS_ENABLED(CONFIG_MACSEC)