From patchwork Thu Aug 15 05:51:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 13764423 X-Patchwork-Delegate: kuba@kernel.org Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013067.outbound.protection.outlook.com [52.101.67.67]) (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 7439317A58A; Thu, 15 Aug 2024 06:05:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723701953; cv=fail; b=JQQ6IumRgiINL0LETqghWwUyKSbwl47i9GrcQtx6jPfFo1yMoaI7Ju1k1j2oVVsXJcXr9t+yLeY3fnoVYCnldInI268IyPinSOeUzOGODPKvo+6eqFz1/syXNK53RM4n0or8cxRXbwyaD64pZfCDtq550MbEBx7XGiUr2vSBXZQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723701953; c=relaxed/simple; bh=QZgYJN86zmk3hXiZCOc/KTDuTbWRqnQPlSXUV4XSmQc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jsKCUrF9aJQoy9+f6qVwEAuTQK80mu0T7fcVjTn5kiqP5Y5FN59qas3anFOmdyCPeti1WgwNdqrIiFXy/Y6RDlPiEmDE/JoWdUA1+rAlZWWsVAn7l4Ygxk3/y9XQhWmKvHI9f5XdbWdPNiB0jmXoUmfsoE7qIgSLiPf4izSekKs= 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=eQpRpURu; arc=fail smtp.client-ip=52.101.67.67 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="eQpRpURu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fpqJ2puJTcfIuu7kno1zBDZwCCaEtMyo/qwFEUWGIZpZU+xmRl7KIaxhONclmh75LWZH4M/crbJPyXgWoemOUZmAluYoWiqFuzAuGYYogdGSR/EJKT7zvnhIxm18zyoGjeejde4gAqIpGY8p3WSjisgHVUIuHW3PQdgIP/4wdauOY5iKc18i2J+z+PB15+eJ5BQzOpWKx81Jj/oK6w+PpBl0X738PUmNQtHKIbYiE9OOWQuUClPBT9kFNtxiMskNJ6tAZyn4pif4aQN+zVXE40YxHpDIkXknWJ7oNksJ1nZ6d+7wyPxI2eAH94XLdNjtfi/l/TsCL6su5dwidhE5UQ== 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=COyCIIfhCurzhPjKt1L8CkqRierS1FI6OtXAVcSRF2A=; b=R2kYkTT3R9xXgTsZaUaX2QX4RQRufEPEbjln5y4oFhMde2okNz4sJtaa9VaGvwckLWT91/t1PrReRIY1MyebFjALRmqBrDfrPzdffCOfAIzVTA2aIcV5GrA/TiqBj5FZqc6DnhPChDaSG6fWliUmZjsFiYcLCFUDp4smo2DSA4063nB8GcPAdJGffuQNP5MUCdmtIf1KVXOeqMSDbqlADLmljSNX436nTUekG9QMbg/FeHsxBjDhbqtuRhV9iWC/u2Kg819tZtX07XDzXP8nlHFc0VJy0JT7+reeJTSU1yaDvjaosIwrqLcHHAIeWLrzP4uVVG4exeTiuC1QR9LnnQ== 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=COyCIIfhCurzhPjKt1L8CkqRierS1FI6OtXAVcSRF2A=; b=eQpRpURuwhpJaXtTTz7iOArYyrfrS4bc5FkLWEmGiMsCQWnP8G3EDdHQg+af03KQz/b50gWk1zZZO2knYxFztgtIhLJJos063XsTwhxdNCUaYIbWn2hQTUrR+nVcrG2/zoZhSRN09m74QKB38xMhloFUJLLJZpd+ifHDPKl5ErPIKr+53nO8DyZCG/MZKEqWY9l7GvVLuj0rUCoGGFVL569mp1jw3s7xypZbEyB/SMMqLhFApv5qZnmDTSup4bZCAh5LLn7K9cXQ4beJSFJrGRY7o588Egxx8PcqtiaOjqp86n8cFr4yJfdH7EldAnwmsmOMNQz2UhYa6VXE+pFetA== 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 VI0PR04MB10805.eurprd04.prod.outlook.com (2603:10a6:800:25f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 06:05:48 +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.7875.016; Thu, 15 Aug 2024 06:05:48 +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 Subject: [PATCH net-next 3/3] net: phy: c45-tja11xx: add revRMII mode support Date: Thu, 15 Aug 2024 13:51:26 +0800 Message-Id: <20240815055126.137437-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815055126.137437-1-wei.fang@nxp.com> References: <20240815055126.137437-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR02CA0097.apcprd02.prod.outlook.com (2603:1096:4:92::13) To PAXPR04MB8510.eurprd04.prod.outlook.com (2603:10a6:102:211::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8510:EE_|VI0PR04MB10805:EE_ X-MS-Office365-Filtering-Correlation-Id: de0df6fe-fbde-49d4-ddfe-08dcbcf04f2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: Qaw6wnXyR7eB3rQtLyKXxdxu1qyZfUEghE6mAk3tXBUVC+10VCLvdHPffuXmzO38OP5yS+xJ9wMMioT0qdS3UnB4/yRjH7lr7JENZWPuvL/RHzg9M9htN5SSxVBT6ZDIMGr0bijAX1hRbloqbpcq5ye32cBOuE2veBvEcvA1Amb64N92yr0gdSL0/YtY0yL79rLUavjQnq5nPfbJo1K0PT+UE9XoCsANVNQiHNVcX4XUd3T2XBHWvGFP79vfcVZRchoOCt9y8r4PCanZ5PrKP/qsnbRf57AojbxtuAdykhOtjfN6mZXRMOJIlgbuOub85NHlHh7wb9gQ1VnZU+hkQ2rly4NqiY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nPSK8KEDHjfUD+IOE= 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)(1800799024)(52116014)(376014)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 79wjKj6jv1kdvFBWy2Wk4ZpcX5dfQ8+ymRDjkcfdm5LIyS1pHIicv7ok7FI8ESVOaJCsycmMCK7xOVUQPRi0UKbcFgiEWBCrabgeKiqJ58dpPu/L3e8E+HIogOEQw/j9zVLJpaTnvRHCeMDcEfTv18VXDzAxeDSA+En1mjUHxpTh27Nbg4lb3pToYHLJy5jca7gS46cpWHWqfgnfwmfm4KwqANQUzVYRe1QfzA5LxTa9I7eZ2VaIdqeT0C3+R/W5DbcQMyEWZenvshvAPp2Yp5aoA2QmalO9K6HfrtFLEW6ObNM9BOCGYRmoopyqvwfaXjimQOiZ83aLIeJwgpqGcMTviUUY02u/4CcKnx1vt9+sjQr1mfRZxoybnW7HR0QK83EvxpjUUVEB4ADQxRkMalSnyp+YUI1taV4hsF7lAstWj+O0VwM9hRr8HVjnV/1ALThdvjXHgaUKHLYfOD9im/5aREjsclr1f2EhDgIt97M5jk8GNOuVav8cR8l2e3BFWTPvgLw7wJ+QnIKx/7ieijbTGGX0t2gGxq60/F674oBD5O57AAr9/KE1jabcKgY6OUHCdhBAPbOM6lp+hHPqLbXD1g9PwIzqYzgtWLDrLuD0ud9VMRiWHh2CViCWEeOUuyIrypZH9q3QHu0xVF2ntviySIeQVIOsF98TxHzKzdEP5DGhFYDdAaPKNbtSc9LYfr6t69FHADXlfslxK4kWj3ZpzdW3GCVBz8W4UTG2FGeyGwPNcBIryZ0qsLSPsQabJnCDvKoUCS6OeFyHlTw6ortiuJE7T3t29auqdhH8uadT5llPP5ocgteItSfdqkzX39WT7Q1gOg/o61LJasjCdWVkrvujgsFt7A+NbjVQvjzV2sGVl0XBY0evXEYbesbcQb76LdcOuLTt4q14yJmN+gjF6iGvuRbBh6mnlgi/M9JvqrteTsaaOEEzqrlR9TZ7a+fWT3VSGtvqG5S1fVHbVoEGALaY3ZXhp/FV73/JQvk9TOD0AnR6tupJVFmzgAaW4E6cgKB7VaYOrKgFujIQbg5H9VDkXKb6fr0Myf3Yu2COUZPmXNa3r7MuAdV2plhWOrwbNoncdTBOW13w6HeZwl/Grr4ES2PKkcOX9UXaC8FkB1dnUBdX1o7QHg1Wbww8zPjHRI2bi5P+MUL/zfZK4dIqGQ/IWq8n7GkVuYwsje6VIMDTz3K4LrGcF7tohZitXrc+d3/wljFib0qe3X0feQ87E9VzqvSE5js9u31lYNv+vGG44QYYuUHCAIsIGYT7oxbn/1bF2rwWEWgzur2+731A5IfhhD15bmfUR1svRESueSWXlZ6ZaIz5Ugu+tt+9M1o8Ey8RYYwphBCPIw03g7naajhrSNGBOzGk/HGsZFFopcT6KavojXfIe4sDrjhYXCCtz7alzsepiwQhevG9NmRjH0JR+R7EJYOucADddPZg+3QB8284d/xIaiq7pr1OxFXxM6ar2JRZgmBUFoRlV5/lIVif5HdSYgz1xgY46wqB9T40KMDKjvApWqLDJKIH/imnIr90hfYFIGjDpRVCNLyScyA//RebXT7DVKgKBn+FTDCZAjPGwEZyu86qW4xI X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: de0df6fe-fbde-49d4-ddfe-08dcbcf04f2c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8510.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 06:05:48.8723 (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: 2g7XfP1QzD40kKRFU9WB8Fm28mJfGN+JeV4RQRyup8/QbJxBkn4pVKyuSUuy0+aUb/3NGpdVAK3UMkTYHLdgzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10805 X-Patchwork-Delegate: kuba@kernel.org For TJA11xx PHYs, they have the capability to make REF_CLK as output in RMII mode, which is called revRMII mode in the data sheet, so add the revRMII mode support. Signed-off-by: Wei Fang --- 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..571ecdbd49d9 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,reverse-mode")) + 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)