Skip to content

Commit

Permalink
Merge branch 'net-fec-add-pps-channel-configuration'
Browse files Browse the repository at this point in the history
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: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Paolo Abeni committed Oct 8, 2024
2 parents 5d6a8ae + 566c2d8 commit f178812
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 7 additions & 0 deletions Documentation/devicetree/bindings/net/fsl,fec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions drivers/net/ethernet/freescale/fec_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f178812

Please sign in to comment.