Commit 24412be8 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-phy-nxp-c45-tja11xx-add-support-for-tja1121'

Andrei Botila says:

====================
net: phy: nxp-c45-tja11xx: add support for TJA1121

This patch series adds .match_phy_device for the existing TJAs
to differentiate between TJA1103/TJA1104 and TJA1120/TJA1121.
TJA1103 and TJA1104 share the same PHY_ID but TJA1104 has MACsec
capabilities while TJA1103 doesn't.
Also add support for TJA1121 which is based on TJA1120 hardware
with additional MACsec IP.
====================

Link: https://patch.msgid.link/20250228154320.2979000-1-andrei.botila@oss.nxp.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 39e912a9 7215e937
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ config NXP_C45_TJA11XX_PHY
	depends on MACSEC || !MACSEC
	help
	  Enable support for NXP C45 TJA11XX PHYs.
	  Currently supports the TJA1103, TJA1104 and TJA1120 PHYs.
	  Currently supports the TJA1103, TJA1104, TJA1120 and TJA1121 PHYs.

config NXP_TJA11XX_PHY
	tristate "NXP TJA11xx PHYs support"
+91 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/* NXP C45 PHY driver
 * Copyright 2021-2023 NXP
 * Copyright 2021-2025 NXP
 * Author: Radu Pirea <radu-nicolae.pirea@oss.nxp.com>
 */

@@ -19,7 +19,10 @@

#include "nxp-c45-tja11xx.h"

#define PHY_ID_MASK			GENMASK(31, 4)
/* Same id: TJA1103, TJA1104 */
#define PHY_ID_TJA_1103			0x001BB010
/* Same id: TJA1120, TJA1121 */
#define PHY_ID_TJA_1120			0x001BB031

#define VEND1_DEVICE_CONTROL		0x0040
@@ -1888,6 +1891,42 @@ static void tja1120_nmi_handler(struct phy_device *phydev,
	}
}

static int nxp_c45_macsec_ability(struct phy_device *phydev)
{
	bool macsec_ability;
	int phy_abilities;

	phy_abilities = phy_read_mmd(phydev, MDIO_MMD_VEND1,
				     VEND1_PORT_ABILITIES);
	macsec_ability = !!(phy_abilities & MACSEC_ABILITY);

	return macsec_ability;
}

static int tja1103_match_phy_device(struct phy_device *phydev)
{
	return phy_id_compare(phydev->phy_id, PHY_ID_TJA_1103, PHY_ID_MASK) &&
	       !nxp_c45_macsec_ability(phydev);
}

static int tja1104_match_phy_device(struct phy_device *phydev)
{
	return phy_id_compare(phydev->phy_id, PHY_ID_TJA_1103, PHY_ID_MASK) &&
	       nxp_c45_macsec_ability(phydev);
}

static int tja1120_match_phy_device(struct phy_device *phydev)
{
	return phy_id_compare(phydev->phy_id, PHY_ID_TJA_1120, PHY_ID_MASK) &&
	       !nxp_c45_macsec_ability(phydev);
}

static int tja1121_match_phy_device(struct phy_device *phydev)
{
	return phy_id_compare(phydev->phy_id, PHY_ID_TJA_1120, PHY_ID_MASK) &&
	       nxp_c45_macsec_ability(phydev);
}

static const struct nxp_c45_regmap tja1120_regmap = {
	.vend1_ptp_clk_period	= 0x1020,
	.vend1_event_msg_filt	= 0x9010,
@@ -1958,7 +1997,6 @@ static const struct nxp_c45_phy_data tja1120_phy_data = {

static struct phy_driver nxp_c45_driver[] = {
	{
		PHY_ID_MATCH_MODEL(PHY_ID_TJA_1103),
		.name			= "NXP C45 TJA1103",
		.get_features		= nxp_c45_get_features,
		.driver_data		= &tja1103_phy_data,
@@ -1980,9 +2018,33 @@ static struct phy_driver nxp_c45_driver[] = {
		.get_sqi		= nxp_c45_get_sqi,
		.get_sqi_max		= nxp_c45_get_sqi_max,
		.remove			= nxp_c45_remove,
		.match_phy_device	= tja1103_match_phy_device,
	},
	{
		.name			= "NXP C45 TJA1104",
		.get_features		= nxp_c45_get_features,
		.driver_data		= &tja1103_phy_data,
		.probe			= nxp_c45_probe,
		.soft_reset		= nxp_c45_soft_reset,
		.config_aneg		= genphy_c45_config_aneg,
		.config_init		= nxp_c45_config_init,
		.config_intr		= tja1103_config_intr,
		.handle_interrupt	= nxp_c45_handle_interrupt,
		.read_status		= genphy_c45_read_status,
		.suspend		= genphy_c45_pma_suspend,
		.resume			= genphy_c45_pma_resume,
		.get_sset_count		= nxp_c45_get_sset_count,
		.get_strings		= nxp_c45_get_strings,
		.get_stats		= nxp_c45_get_stats,
		.cable_test_start	= nxp_c45_cable_test_start,
		.cable_test_get_status	= nxp_c45_cable_test_get_status,
		.set_loopback		= genphy_c45_loopback,
		.get_sqi		= nxp_c45_get_sqi,
		.get_sqi_max		= nxp_c45_get_sqi_max,
		.remove			= nxp_c45_remove,
		.match_phy_device	= tja1104_match_phy_device,
	},
	{
		PHY_ID_MATCH_MODEL(PHY_ID_TJA_1120),
		.name			= "NXP C45 TJA1120",
		.get_features		= nxp_c45_get_features,
		.driver_data		= &tja1120_phy_data,
@@ -2005,6 +2067,32 @@ static struct phy_driver nxp_c45_driver[] = {
		.get_sqi		= nxp_c45_get_sqi,
		.get_sqi_max		= nxp_c45_get_sqi_max,
		.remove			= nxp_c45_remove,
		.match_phy_device	= tja1120_match_phy_device,
	},
	{
		.name			= "NXP C45 TJA1121",
		.get_features		= nxp_c45_get_features,
		.driver_data		= &tja1120_phy_data,
		.probe			= nxp_c45_probe,
		.soft_reset		= nxp_c45_soft_reset,
		.config_aneg		= genphy_c45_config_aneg,
		.config_init		= nxp_c45_config_init,
		.config_intr		= tja1120_config_intr,
		.handle_interrupt	= nxp_c45_handle_interrupt,
		.read_status		= genphy_c45_read_status,
		.link_change_notify	= tja1120_link_change_notify,
		.suspend		= genphy_c45_pma_suspend,
		.resume			= genphy_c45_pma_resume,
		.get_sset_count		= nxp_c45_get_sset_count,
		.get_strings		= nxp_c45_get_strings,
		.get_stats		= nxp_c45_get_stats,
		.cable_test_start	= nxp_c45_cable_test_start,
		.cable_test_get_status	= nxp_c45_cable_test_get_status,
		.set_loopback		= genphy_c45_loopback,
		.get_sqi		= nxp_c45_get_sqi,
		.get_sqi_max		= nxp_c45_get_sqi_max,
		.remove			= nxp_c45_remove,
		.match_phy_device	= tja1121_match_phy_device,
	},
};