Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ptp_qoriq: support FIPER3

The FIPER3 (fixed interval period pulse generator) is supported on
DPAA2 and ENETC network controller hardware. This patch is to support
it in ptp_qoriq driver.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Acked-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Yangbo Lu and committed by
David S. Miller
6d23d831 8725e9fc

+22 -1
+19 -1
drivers/ptp/ptp_qoriq.c
··· 72 72 set_alarm(ptp_qoriq); 73 73 ptp_qoriq->write(&regs->fiper_regs->tmr_fiper1, ptp_qoriq->tmr_fiper1); 74 74 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); 75 79 } 76 80 77 81 int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index, bool update_event) ··· 370 366 * "fsl,tmr-add" 371 367 * "fsl,tmr-fiper1" 372 368 * "fsl,tmr-fiper2" 369 + * "fsl,tmr-fiper3" (required only for DPAA2 and ENETC hardware) 373 370 * "fsl,max-adj" 374 371 * 375 372 * Return 0 if success ··· 417 412 ptp_qoriq->tmr_add = freq_comp; 418 413 ptp_qoriq->tmr_fiper1 = DEFAULT_FIPER1_PERIOD - ptp_qoriq->tclk_period; 419 414 ptp_qoriq->tmr_fiper2 = DEFAULT_FIPER2_PERIOD - ptp_qoriq->tclk_period; 415 + ptp_qoriq->tmr_fiper3 = DEFAULT_FIPER3_PERIOD - ptp_qoriq->tclk_period; 420 416 421 417 /* max_adj = 1000000000 * (freq_ratio - 1.0) - 1 422 418 * freq_ratio = reference_clock_freq / nominal_freq ··· 452 446 else 453 447 ptp_qoriq->extts_fifo_support = false; 454 448 449 + if (of_device_is_compatible(node, "fsl,dpaa2-ptp") || 450 + of_device_is_compatible(node, "fsl,enetc-ptp")) 451 + ptp_qoriq->fiper3_support = true; 452 + 455 453 if (of_property_read_u32(node, 456 454 "fsl,tclk-period", &ptp_qoriq->tclk_period) || 457 455 of_property_read_u32(node, ··· 467 457 of_property_read_u32(node, 468 458 "fsl,tmr-fiper2", &ptp_qoriq->tmr_fiper2) || 469 459 of_property_read_u32(node, 470 - "fsl,max-adj", &ptp_qoriq->caps.max_adj)) { 460 + "fsl,max-adj", &ptp_qoriq->caps.max_adj) || 461 + (ptp_qoriq->fiper3_support && 462 + of_property_read_u32(node, "fsl,tmr-fiper3", 463 + &ptp_qoriq->tmr_fiper3))) { 471 464 pr_warn("device tree node missing required elements, try automatic configuration\n"); 472 465 473 466 if (ptp_qoriq_auto_config(ptp_qoriq, node)) ··· 515 502 ptp_qoriq->write(&regs->ctrl_regs->tmr_prsc, ptp_qoriq->tmr_prsc); 516 503 ptp_qoriq->write(&regs->fiper_regs->tmr_fiper1, ptp_qoriq->tmr_fiper1); 517 504 ptp_qoriq->write(&regs->fiper_regs->tmr_fiper2, ptp_qoriq->tmr_fiper2); 505 + 506 + if (ptp_qoriq->fiper3_support) 507 + ptp_qoriq->write(&regs->fiper_regs->tmr_fiper3, 508 + ptp_qoriq->tmr_fiper3); 509 + 518 510 set_alarm(ptp_qoriq); 519 511 ptp_qoriq->write(&regs->ctrl_regs->tmr_ctrl, 520 512 tmr_ctrl|FIPERST|RTPE|TE|FRD);
+3
include/linux/fsl/ptp_qoriq.h
··· 136 136 #define DEFAULT_TMR_PRSC 2 137 137 #define DEFAULT_FIPER1_PERIOD 1000000000 138 138 #define DEFAULT_FIPER2_PERIOD 1000000000 139 + #define DEFAULT_FIPER3_PERIOD 1000000000 139 140 140 141 struct ptp_qoriq { 141 142 void __iomem *base; ··· 148 147 struct dentry *debugfs_root; 149 148 struct device *dev; 150 149 bool extts_fifo_support; 150 + bool fiper3_support; 151 151 int irq; 152 152 int phc_index; 153 153 u32 tclk_period; /* nanoseconds */ ··· 157 155 u32 cksel; 158 156 u32 tmr_fiper1; 159 157 u32 tmr_fiper2; 158 + u32 tmr_fiper3; 160 159 u32 (*read)(unsigned __iomem *addr); 161 160 void (*write)(unsigned __iomem *addr, u32 val); 162 161 };