Skip to content

Commit ed56d74

Browse files
Eran Ben ElishaSaeed Mahameed
authored andcommitted
net/mlx5: Query PPS pin operational status before registering it
In a special configuration, a ConnectX6-Dx pin pps-out might be activated when driver is loaded. Fix the driver to always read the operational pin mode when registering it, and advertise it accordingly. Fixes: ee7f122 ("net/mlx5e: Implement 1PPS support") Signed-off-by: Eran Ben Elisha <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 2108330 commit ed56d74

File tree

1 file changed

+33
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/lib

1 file changed

+33
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,38 @@ static const struct ptp_clock_info mlx5_ptp_clock_info = {
452452
.verify = NULL,
453453
};
454454

455+
static int mlx5_query_mtpps_pin_mode(struct mlx5_core_dev *mdev, u8 pin,
456+
u32 *mtpps, u32 mtpps_size)
457+
{
458+
u32 in[MLX5_ST_SZ_DW(mtpps_reg)] = {};
459+
460+
MLX5_SET(mtpps_reg, in, pin, pin);
461+
462+
return mlx5_core_access_reg(mdev, in, sizeof(in), mtpps,
463+
mtpps_size, MLX5_REG_MTPPS, 0, 0);
464+
}
465+
466+
static int mlx5_get_pps_pin_mode(struct mlx5_clock *clock, u8 pin)
467+
{
468+
struct mlx5_core_dev *mdev = clock->mdev;
469+
u32 out[MLX5_ST_SZ_DW(mtpps_reg)] = {};
470+
u8 mode;
471+
int err;
472+
473+
err = mlx5_query_mtpps_pin_mode(mdev, pin, out, sizeof(out));
474+
if (err || !MLX5_GET(mtpps_reg, out, enable))
475+
return PTP_PF_NONE;
476+
477+
mode = MLX5_GET(mtpps_reg, out, pin_mode);
478+
479+
if (mode == MLX5_PIN_MODE_IN)
480+
return PTP_PF_EXTTS;
481+
else if (mode == MLX5_PIN_MODE_OUT)
482+
return PTP_PF_PEROUT;
483+
484+
return PTP_PF_NONE;
485+
}
486+
455487
static int mlx5_init_pin_config(struct mlx5_clock *clock)
456488
{
457489
int i;
@@ -471,7 +503,7 @@ static int mlx5_init_pin_config(struct mlx5_clock *clock)
471503
sizeof(clock->ptp_info.pin_config[i].name),
472504
"mlx5_pps%d", i);
473505
clock->ptp_info.pin_config[i].index = i;
474-
clock->ptp_info.pin_config[i].func = PTP_PF_NONE;
506+
clock->ptp_info.pin_config[i].func = mlx5_get_pps_pin_mode(clock, i);
475507
clock->ptp_info.pin_config[i].chan = 0;
476508
}
477509

0 commit comments

Comments
 (0)