Commit f178812d authored by Paolo Abeni's avatar Paolo Abeni
Browse files

Merge branch 'net-fec-add-pps-channel-configuration'

Francesco Dolcini says:

====================
net: fec: add PPS channel configuration

Make the FEC Ethernet PPS channel configurable from device tree.
====================

Link: https://patch.msgid.link/20241004152419.79465-1-francesco@dolcini.it


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 5d6a8aea 566c2d83
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -183,6 +183,13 @@ properties:
    description:
      Register bits of stop mode control, the format is <&gpr req_gpr req_bit>.

  fsl,pps-channel:
    $ref: /schemas/types.yaml#/definitions/uint32
    default: 0
    description:
      Specifies to which timer instance the PPS signal is routed.
    enum: [0, 1, 2, 3]

  mdio:
    $ref: mdio.yaml#
    unevaluatedProperties: false
+6 −5
Original line number Diff line number Diff line
@@ -84,8 +84,7 @@
#define FEC_CC_MULT	(1 << 31)
#define FEC_COUNTER_PERIOD	(1 << 31)
#define PPS_OUPUT_RELOAD_PERIOD	NSEC_PER_SEC
#define FEC_CHANNLE_0		0
#define DEFAULT_PPS_CHANNEL	FEC_CHANNLE_0
#define DEFAULT_PPS_CHANNEL	0

#define FEC_PTP_MAX_NSEC_PERIOD		4000000000ULL
#define FEC_PTP_MAX_NSEC_COUNTER	0x80000000ULL
@@ -525,7 +524,6 @@ static int fec_ptp_enable(struct ptp_clock_info *ptp,
	int ret = 0;

	if (rq->type == PTP_CLK_REQ_PPS) {
		fep->pps_channel = DEFAULT_PPS_CHANNEL;
		fep->reload_period = PPS_OUPUT_RELOAD_PERIOD;

		ret = fec_ptp_enable_pps(fep, on);
@@ -536,10 +534,9 @@ static int fec_ptp_enable(struct ptp_clock_info *ptp,
		if (rq->perout.flags)
			return -EOPNOTSUPP;

		if (rq->perout.index != DEFAULT_PPS_CHANNEL)
		if (rq->perout.index != fep->pps_channel)
			return -EOPNOTSUPP;

		fep->pps_channel = DEFAULT_PPS_CHANNEL;
		period.tv_sec = rq->perout.period.sec;
		period.tv_nsec = rq->perout.period.nsec;
		period_ns = timespec64_to_ns(&period);
@@ -707,12 +704,16 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx)
{
	struct net_device *ndev = platform_get_drvdata(pdev);
	struct fec_enet_private *fep = netdev_priv(ndev);
	struct device_node *np = fep->pdev->dev.of_node;
	int irq;
	int ret;

	fep->ptp_caps.owner = THIS_MODULE;
	strscpy(fep->ptp_caps.name, "fec ptp", sizeof(fep->ptp_caps.name));

	fep->pps_channel = DEFAULT_PPS_CHANNEL;
	of_property_read_u32(np, "fsl,pps-channel", &fep->pps_channel);

	fep->ptp_caps.max_adj = 250000000;
	fep->ptp_caps.n_alarm = 0;
	fep->ptp_caps.n_ext_ts = 0;