Skip to content

Commit 42ccf1c

Browse files
committed
Merge branch 'ptp_qoriq-support-FIPER3'
Yangbo Lu says: ==================== ptp_qoriq: support FIPER3 The FIPER3 (fixed interval period pulse generator) is supported on DPAA2 and ENETC network controller hardware. This patch-set is to support it in ptp_qoriq driver and dt-binding. Changes for v2: - Some improvement in code. - Added ACK from Vladimir. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 5e43df1 + 6d23d83 commit 42ccf1c

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎Documentation/devicetree/bindings/ptp/ptp-qoriq.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Clock Properties:
1818
- fsl,tmr-add Frequency compensation value.
1919
- fsl,tmr-fiper1 Fixed interval period pulse generator.
2020
- fsl,tmr-fiper2 Fixed interval period pulse generator.
21+
- fsl,tmr-fiper3 Fixed interval period pulse generator.
22+
Supported only on DPAA2 and ENETC hardware.
2123
- fsl,max-adj Maximum frequency adjustment in parts per billion.
2224
- fsl,extts-fifo The presence of this property indicates hardware
2325
support for the external trigger stamp FIFO.

‎drivers/ptp/ptp_qoriq.c‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ static void set_fipers(struct ptp_qoriq *ptp_qoriq)
7272
set_alarm(ptp_qoriq);
7373
ptp_qoriq->write(&regs->fiper_regs->tmr_fiper1, ptp_qoriq->tmr_fiper1);
7474
ptp_qoriq->write(&regs->fiper_regs->tmr_fiper2, ptp_qoriq->tmr_fiper2);
75+
76+
if (ptp_qoriq->fiper3_support)
77+
ptp_qoriq->write(&regs->fiper_regs->tmr_fiper3,
78+
ptp_qoriq->tmr_fiper3);
7579
}
7680

7781
int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index, bool update_event)
@@ -366,6 +370,7 @@ static u32 ptp_qoriq_nominal_freq(u32 clk_src)
366370
* "fsl,tmr-add"
367371
* "fsl,tmr-fiper1"
368372
* "fsl,tmr-fiper2"
373+
* "fsl,tmr-fiper3" (required only for DPAA2 and ENETC hardware)
369374
* "fsl,max-adj"
370375
*
371376
* Return 0 if success
@@ -412,6 +417,7 @@ static int ptp_qoriq_auto_config(struct ptp_qoriq *ptp_qoriq,
412417
ptp_qoriq->tmr_add = freq_comp;
413418
ptp_qoriq->tmr_fiper1 = DEFAULT_FIPER1_PERIOD - ptp_qoriq->tclk_period;
414419
ptp_qoriq->tmr_fiper2 = DEFAULT_FIPER2_PERIOD - ptp_qoriq->tclk_period;
420+
ptp_qoriq->tmr_fiper3 = DEFAULT_FIPER3_PERIOD - ptp_qoriq->tclk_period;
415421

416422
/* max_adj = 1000000000 * (freq_ratio - 1.0) - 1
417423
* freq_ratio = reference_clock_freq / nominal_freq
@@ -446,6 +452,10 @@ int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base,
446452
else
447453
ptp_qoriq->extts_fifo_support = false;
448454

455+
if (of_device_is_compatible(node, "fsl,dpaa2-ptp") ||
456+
of_device_is_compatible(node, "fsl,enetc-ptp"))
457+
ptp_qoriq->fiper3_support = true;
458+
449459
if (of_property_read_u32(node,
450460
"fsl,tclk-period", &ptp_qoriq->tclk_period) ||
451461
of_property_read_u32(node,
@@ -457,7 +467,10 @@ int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base,
457467
of_property_read_u32(node,
458468
"fsl,tmr-fiper2", &ptp_qoriq->tmr_fiper2) ||
459469
of_property_read_u32(node,
460-
"fsl,max-adj", &ptp_qoriq->caps.max_adj)) {
470+
"fsl,max-adj", &ptp_qoriq->caps.max_adj) ||
471+
(ptp_qoriq->fiper3_support &&
472+
of_property_read_u32(node, "fsl,tmr-fiper3",
473+
&ptp_qoriq->tmr_fiper3))) {
461474
pr_warn("device tree node missing required elements, try automatic configuration\n");
462475

463476
if (ptp_qoriq_auto_config(ptp_qoriq, node))
@@ -502,6 +515,11 @@ int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base,
502515
ptp_qoriq->write(&regs->ctrl_regs->tmr_prsc, ptp_qoriq->tmr_prsc);
503516
ptp_qoriq->write(&regs->fiper_regs->tmr_fiper1, ptp_qoriq->tmr_fiper1);
504517
ptp_qoriq->write(&regs->fiper_regs->tmr_fiper2, ptp_qoriq->tmr_fiper2);
518+
519+
if (ptp_qoriq->fiper3_support)
520+
ptp_qoriq->write(&regs->fiper_regs->tmr_fiper3,
521+
ptp_qoriq->tmr_fiper3);
522+
505523
set_alarm(ptp_qoriq);
506524
ptp_qoriq->write(&regs->ctrl_regs->tmr_ctrl,
507525
tmr_ctrl|FIPERST|RTPE|TE|FRD);

‎include/linux/fsl/ptp_qoriq.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ struct ptp_qoriq_registers {
136136
#define DEFAULT_TMR_PRSC 2
137137
#define DEFAULT_FIPER1_PERIOD 1000000000
138138
#define DEFAULT_FIPER2_PERIOD 1000000000
139+
#define DEFAULT_FIPER3_PERIOD 1000000000
139140

140141
struct ptp_qoriq {
141142
void __iomem *base;
@@ -147,6 +148,7 @@ struct ptp_qoriq {
147148
struct dentry *debugfs_root;
148149
struct device *dev;
149150
bool extts_fifo_support;
151+
bool fiper3_support;
150152
int irq;
151153
int phc_index;
152154
u32 tclk_period; /* nanoseconds */
@@ -155,6 +157,7 @@ struct ptp_qoriq {
155157
u32 cksel;
156158
u32 tmr_fiper1;
157159
u32 tmr_fiper2;
160+
u32 tmr_fiper3;
158161
u32 (*read)(unsigned __iomem *addr);
159162
void (*write)(unsigned __iomem *addr, u32 val);
160163
};

0 commit comments

Comments
 (0)