dpaa2-ptp: add external trigger event support
authorYangbo Lu <yangbo.lu@nxp.com>
Thu, 12 Dec 2019 10:08:06 +0000 (18:08 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 Dec 2019 23:56:41 +0000 (15:56 -0800)
This patch is to add external trigger event support
for dpaa2-ptp driver with v2 dprtc_set_irq_mask() API.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h
drivers/net/ethernet/freescale/dpaa2/dprtc.h

index a9503aea527f54853720eb8aeb457f4720e7eb5b..a0061e9299088e14337b594e7dc226721fd1ad6a 100644 (file)
@@ -27,6 +27,20 @@ static int dpaa2_ptp_enable(struct ptp_clock_info *ptp,
        mc_dev = to_fsl_mc_device(dev);
 
        switch (rq->type) {
+       case PTP_CLK_REQ_EXTTS:
+               switch (rq->extts.index) {
+               case 0:
+                       bit = DPRTC_EVENT_ETS1;
+                       break;
+               case 1:
+                       bit = DPRTC_EVENT_ETS2;
+                       break;
+               default:
+                       return -EINVAL;
+               }
+               if (on)
+                       extts_clean_up(ptp_qoriq, rq->extts.index, false);
+               break;
        case PTP_CLK_REQ_PPS:
                bit = DPRTC_EVENT_PPS;
                break;
@@ -96,6 +110,12 @@ static irqreturn_t dpaa2_ptp_irq_handler_thread(int irq, void *priv)
                ptp_clock_event(ptp_qoriq->clock, &event);
        }
 
+       if (status & DPRTC_EVENT_ETS1)
+               extts_clean_up(ptp_qoriq, 0, true);
+
+       if (status & DPRTC_EVENT_ETS2)
+               extts_clean_up(ptp_qoriq, 1, true);
+
        err = dprtc_clear_irq_status(mc_dev->mc_io, 0, mc_dev->mc_handle,
                                     DPRTC_IRQ_INDEX, status);
        if (unlikely(err)) {
index 4ac05bfef338098b2bba5f1c697b36f816107ce8..96ffeb948f088a2488a0ebbf3bcc18ac7710c582 100644 (file)
@@ -9,9 +9,11 @@
 
 /* Command versioning */
 #define DPRTC_CMD_BASE_VERSION         1
+#define DPRTC_CMD_VERSION_2            2
 #define DPRTC_CMD_ID_OFFSET            4
 
 #define DPRTC_CMD(id)  (((id) << DPRTC_CMD_ID_OFFSET) | DPRTC_CMD_BASE_VERSION)
+#define DPRTC_CMD_V2(id) (((id) << DPRTC_CMD_ID_OFFSET) | DPRTC_CMD_VERSION_2)
 
 /* Command IDs */
 #define DPRTC_CMDID_CLOSE                      DPRTC_CMD(0x800)
@@ -19,7 +21,7 @@
 
 #define DPRTC_CMDID_SET_IRQ_ENABLE             DPRTC_CMD(0x012)
 #define DPRTC_CMDID_GET_IRQ_ENABLE             DPRTC_CMD(0x013)
-#define DPRTC_CMDID_SET_IRQ_MASK               DPRTC_CMD(0x014)
+#define DPRTC_CMDID_SET_IRQ_MASK               DPRTC_CMD_V2(0x014)
 #define DPRTC_CMDID_GET_IRQ_MASK               DPRTC_CMD(0x015)
 #define DPRTC_CMDID_GET_IRQ_STATUS             DPRTC_CMD(0x016)
 #define DPRTC_CMDID_CLEAR_IRQ_STATUS           DPRTC_CMD(0x017)
index 311c184e1aef675f02ea14892225ce0947d3baee..05c413719e555f8f166eec53258cc77bdf8b8750 100644 (file)
@@ -20,6 +20,8 @@ struct fsl_mc_io;
 #define DPRTC_IRQ_INDEX                0
 
 #define DPRTC_EVENT_PPS                0x08000000
+#define DPRTC_EVENT_ETS1       0x00800000
+#define DPRTC_EVENT_ETS2       0x00400000
 
 int dprtc_open(struct fsl_mc_io *mc_io,
               u32 cmd_flags,