Skip to content

Commit 0247743

Browse files
committed
Merge branch 'dpaa2-ptp-support-external-trigger-event'
Yangbo Lu says: ==================== dpaa2-ptp: support external trigger event This patch-set is to add external trigger event support for dpaa2-ptp driver since MC firmware has supported external trigger interrupt with a new v2 dprtc_set_irq_mask() API. And extts_clean_up() function in ptp_qoriq driver needs to be exported with minor fixes for dpaa2-ptp reusing. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 0e62719 + 17568c6 commit 0247743

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ static int dpaa2_ptp_enable(struct ptp_clock_info *ptp,
2727
mc_dev = to_fsl_mc_device(dev);
2828

2929
switch (rq->type) {
30+
case PTP_CLK_REQ_EXTTS:
31+
switch (rq->extts.index) {
32+
case 0:
33+
bit = DPRTC_EVENT_ETS1;
34+
break;
35+
case 1:
36+
bit = DPRTC_EVENT_ETS2;
37+
break;
38+
default:
39+
return -EINVAL;
40+
}
41+
if (on)
42+
extts_clean_up(ptp_qoriq, rq->extts.index, false);
43+
break;
3044
case PTP_CLK_REQ_PPS:
3145
bit = DPRTC_EVENT_PPS;
3246
break;
@@ -96,6 +110,12 @@ static irqreturn_t dpaa2_ptp_irq_handler_thread(int irq, void *priv)
96110
ptp_clock_event(ptp_qoriq->clock, &event);
97111
}
98112

113+
if (status & DPRTC_EVENT_ETS1)
114+
extts_clean_up(ptp_qoriq, 0, true);
115+
116+
if (status & DPRTC_EVENT_ETS2)
117+
extts_clean_up(ptp_qoriq, 1, true);
118+
99119
err = dprtc_clear_irq_status(mc_dev->mc_io, 0, mc_dev->mc_handle,
100120
DPRTC_IRQ_INDEX, status);
101121
if (unlikely(err)) {

drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@
99

1010
/* Command versioning */
1111
#define DPRTC_CMD_BASE_VERSION 1
12+
#define DPRTC_CMD_VERSION_2 2
1213
#define DPRTC_CMD_ID_OFFSET 4
1314

1415
#define DPRTC_CMD(id) (((id) << DPRTC_CMD_ID_OFFSET) | DPRTC_CMD_BASE_VERSION)
16+
#define DPRTC_CMD_V2(id) (((id) << DPRTC_CMD_ID_OFFSET) | DPRTC_CMD_VERSION_2)
1517

1618
/* Command IDs */
1719
#define DPRTC_CMDID_CLOSE DPRTC_CMD(0x800)
1820
#define DPRTC_CMDID_OPEN DPRTC_CMD(0x810)
1921

2022
#define DPRTC_CMDID_SET_IRQ_ENABLE DPRTC_CMD(0x012)
2123
#define DPRTC_CMDID_GET_IRQ_ENABLE DPRTC_CMD(0x013)
22-
#define DPRTC_CMDID_SET_IRQ_MASK DPRTC_CMD(0x014)
24+
#define DPRTC_CMDID_SET_IRQ_MASK DPRTC_CMD_V2(0x014)
2325
#define DPRTC_CMDID_GET_IRQ_MASK DPRTC_CMD(0x015)
2426
#define DPRTC_CMDID_GET_IRQ_STATUS DPRTC_CMD(0x016)
2527
#define DPRTC_CMDID_CLEAR_IRQ_STATUS DPRTC_CMD(0x017)

drivers/net/ethernet/freescale/dpaa2/dprtc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct fsl_mc_io;
2020
#define DPRTC_IRQ_INDEX 0
2121

2222
#define DPRTC_EVENT_PPS 0x08000000
23+
#define DPRTC_EVENT_ETS1 0x00800000
24+
#define DPRTC_EVENT_ETS2 0x00400000
2325

2426
int dprtc_open(struct fsl_mc_io *mc_io,
2527
u32 cmd_flags,

drivers/ptp/ptp_qoriq.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,13 @@ static void set_fipers(struct ptp_qoriq *ptp_qoriq)
7474
ptp_qoriq->write(&regs->fiper_regs->tmr_fiper2, ptp_qoriq->tmr_fiper2);
7575
}
7676

77-
static int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index,
78-
bool update_event)
77+
int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index, bool update_event)
7978
{
8079
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
8180
struct ptp_clock_event event;
8281
void __iomem *reg_etts_l;
8382
void __iomem *reg_etts_h;
84-
u32 valid, stat, lo, hi;
83+
u32 valid, lo, hi;
8584

8685
switch (index) {
8786
case 0:
@@ -101,6 +100,10 @@ static int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index,
101100
event.type = PTP_CLOCK_EXTTS;
102101
event.index = index;
103102

103+
if (ptp_qoriq->extts_fifo_support)
104+
if (!(ptp_qoriq->read(&regs->ctrl_regs->tmr_stat) & valid))
105+
return 0;
106+
104107
do {
105108
lo = ptp_qoriq->read(reg_etts_l);
106109
hi = ptp_qoriq->read(reg_etts_h);
@@ -111,11 +114,13 @@ static int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index,
111114
ptp_clock_event(ptp_qoriq->clock, &event);
112115
}
113116

114-
stat = ptp_qoriq->read(&regs->ctrl_regs->tmr_stat);
115-
} while (ptp_qoriq->extts_fifo_support && (stat & valid));
117+
if (!ptp_qoriq->extts_fifo_support)
118+
break;
119+
} while (ptp_qoriq->read(&regs->ctrl_regs->tmr_stat) & valid);
116120

117121
return 0;
118122
}
123+
EXPORT_SYMBOL_GPL(extts_clean_up);
119124

120125
/*
121126
* Interrupt service routine

include/linux/fsl/ptp_qoriq.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ int ptp_qoriq_settime(struct ptp_clock_info *ptp,
192192
const struct timespec64 *ts);
193193
int ptp_qoriq_enable(struct ptp_clock_info *ptp,
194194
struct ptp_clock_request *rq, int on);
195+
int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index, bool update_event);
195196
#ifdef CONFIG_DEBUG_FS
196197
void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq);
197198
void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq);

0 commit comments

Comments
 (0)