Reuse ptp_qoriq driver for dpaa2-ptp
Subsystems (7)
Yangbo Lu
maintainerv2 cover Reuse ptp_qoriq driver for dpaa2-ptp
Although dpaa2-ptp.c driver is a fsl_mc_driver which is using MC APIs for register accessing, it's same IP block with eTSEC/DPAA/ENETC 1588 timer.
This patch-set is to convert to reuse ptp_qoriq driver by using register ioremap and dropping related MC APIs. However the interrupts could only be handled by MC which fires MSIs to ARM cores. So the interrupt enabling and handling still rely on MC APIs. MC APIs for interrupt and PPS event support are also added by this patch-set.
---
Changes for v2:
- Allowed to compile with COMPILE_TEST.
Yangbo Lu (6):
ptp: add QorIQ PTP support for DPAA2
dpaa2-ptp: reuse ptp_qoriq driver
dt-binding: ptp_qoriq: support DPAA2 PTP compatible
arm64: dts: fsl: add ptp timer node for dpaa2 platforms
dpaa2-ptp: add interrupt support
MAINTAINERS: maintain DPAA2 PTP driver in QorIQ PTP entry
.../devicetree/bindings/ptp/ptp-qoriq.txt | 3 +- MAINTAINERS | 9 +- arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 8 + arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi | 8 + arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 8 + drivers/net/ethernet/freescale/dpaa2/Kconfig | 3 +- drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c | 242 +++++++++++---------- drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h | 48 +++- drivers/net/ethernet/freescale/dpaa2/dprtc.c | 191 ++++++++++++---- drivers/net/ethernet/freescale/dpaa2/dprtc.h | 62 ++++-- drivers/ptp/Kconfig | 2 +- 11 files changed, 386 insertions(+), 198 deletions(-)
Signature · 1 line
2.7.4
Yangbo Lu
maintainerPATCH v2 1/6 ptp: add QorIQ PTP support for DPAA2
This patch is to add QorIQ PTP support for DPAA2. Although dpaa2-ptp.c driver is a fsl_mc_driver which is using MC APIs for register accessing, it's same IP block with eTSEC/DPAA/ENETC 1588 timer. We will convert to reuse ptp_qoriq driver by using register ioremap and dropping related MC APIs.
Also allow to compile ptp_qoriq with COMPILE_TEST.
---
Changes for v2:
- Allowed to compile with COMPILE_TEST.
--- drivers/ptp/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ptp/Kconfig +1 -1
@@ -44,7 +44,7 @@ config PTP_1588_CLOCK_DTE config PTP_1588_CLOCK_QORIQ tristate "Freescale QorIQ 1588 timer as PTP clock" - depends on GIANFAR || FSL_DPAA_ETH || FSL_ENETC || FSL_ENETC_VF + depends on GIANFAR || FSL_DPAA_ETH || FSL_DPAA2_ETH || FSL_ENETC || FSL_ENETC_VF || COMPILE_TEST depends on PTP_1588_CLOCK default y help
Signature · 1 line
2.7.4
Yangbo Lu
maintainerPATCH v2 2/6 dpaa2-ptp: reuse ptp_qoriq driver
In reply to Yangbo LuAlthough dpaa2-ptp.c driver is a fsl_mc_driver which is using MC APIs for register accessing, it's same IP block with eTSEC/DPAA/ENETC 1588 timer.
This patch is to convert to reuse ptp_qoriq driver by using register ioremap and dropping related MC APIs. However the interrupts could only be handled by MC which fires MSIs to ARM cores. So the interrupt enabling and handling still rely on MC APIs.
---
Changes for v2:
- None.
--- drivers/net/ethernet/freescale/dpaa2/Kconfig | 3 +- drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c | 160 +++++------------------ drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h | 13 -- drivers/net/ethernet/freescale/dpaa2/dprtc.c | 120 ----------------- drivers/net/ethernet/freescale/dpaa2/dprtc.h | 20 --- 5 files changed, 34 insertions(+), 282 deletions(-)
drivers/net/ethernet/freescale/dpaa2/Kconfig +1 -2
@@ -10,8 +10,7 @@ config FSL_DPAA2_ETH config FSL_DPAA2_PTP_CLOCK tristate "Freescale DPAA2 PTP Clock" - depends on FSL_DPAA2_ETH - imply PTP_1588_CLOCK + depends on FSL_DPAA2_ETH && PTP_1588_CLOCK_QORIQ default y help This driver adds support for using the DPAA2 1588 timer module
drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +33 -127
209 lines not on this page · raw message
drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h +0 -13
@@ -17,24 +17,11 @@#define DPRTC_CMDID_CLOSE DPRTC_CMD(0x800)#define DPRTC_CMDID_OPEN DPRTC_CMD(0x810) -#define DPRTC_CMDID_SET_FREQ_COMPENSATION DPRTC_CMD(0x1d1) -#define DPRTC_CMDID_GET_FREQ_COMPENSATION DPRTC_CMD(0x1d2) -#define DPRTC_CMDID_GET_TIME DPRTC_CMD(0x1d3) -#define DPRTC_CMDID_SET_TIME DPRTC_CMD(0x1d4) -#pragma pack(push, 1)struct dprtc_cmd_open {__le32 dprtc_id; }; -struct dprtc_get_freq_compensation { -__le32 freq_compensation; -}; - -struct dprtc_time { -__le64 time; -}; -#pragma pack(pop)#endif /* _FSL_DPRTC_CMD_H */
drivers/net/ethernet/freescale/dpaa2/dprtc.c +0 -120
123 lines not on this page · raw message
drivers/net/ethernet/freescale/dpaa2/dprtc.h +0 -20
@@ -22,24 +22,4 @@ int dprtc_close(struct fsl_mc_io *mc_io,u32 cmd_flags, u16 token); -int dprtc_set_freq_compensation (struct fsl_mc_io *mc_io, -u32 cmd_flags, -u16 token, -u32 freq_compensation); - -int dprtc_get_freq_compensation (struct fsl_mc_io *mc_io, -u32 cmd_flags, -u16 token, -u32 *freq_compensation); - -int dprtc_get_time (struct fsl_mc_io *mc_io, -u32 cmd_flags, -u16 token, -uint64_t *time); - -int dprtc_set_time (struct fsl_mc_io *mc_io, -u32 cmd_flags, -u16 token, -uint64_t time); -#endif /* __FSL_DPRTC_H */
Signature · 1 line
2.7.4
Yangbo Lu
maintainerPATCH v2 3/6 dt-binding: ptp_qoriq: support DPAA2 PTP compatible
In reply to Yangbo LuAdd a new compatible for DPAA2 PTP.
---
Changes for v2:
- None.
--- Documentation/devicetree/bindings/ptp/ptp-qoriq.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/ptp/ptp-qoriq.txt +2 -1
@@ -4,7 +4,8 @@ General Properties: - compatible Should be "fsl,etsec-ptp" for eTSEC Should be "fsl,fman-ptp-timer" for DPAA FMan - Should be "fsl,enetc-ptp" for ENETC + Should be "fsl,dpaa2-ptp" for DPAA2 + Should be "fsl,enetc-ptp" for ENETC - reg Offset and length of the register set for the device - interrupts There should be at least two interrupts. Some devices have as many as four PTP related interrupts.
Signature · 1 line
2.7.4
Yangbo Lu
maintainerPATCH v2 4/6 arm64: dts: fsl: add ptp timer node for dpaa2 platforms
In reply to Yangbo LuThis patch is to add ptp timer device tree node for dpaa2 platforms(ls1088a/ls208xa/lx2160a).
---
Changes for v2:
- None.
--- arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 8 ++++++++ arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi | 8 ++++++++ arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 8 ++++++++ 3 files changed, 24 insertions(+)
arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi +8 -0
@@ -609,6 +609,14 @@ <GIC_SPI 209 IRQ_TYPE_LEVEL_HIGH>; }; + ptp-timer@8b95000 { + compatible = "fsl,dpaa2-ptp"; + reg = <0x0 0x8b95000 0x0 0x100>; + clocks = <&clockgen 4 0>; + little-endian; + fsl,extts-fifo; + }; + cluster1_core0_watchdog: wdt@c000000 { compatible = "arm,sp805-wdt", "arm,primecell"; reg = <0x0 0xc000000 0x0 0x1000>;
arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi +8 -0
@@ -321,6 +321,14 @@ }; }; + ptp-timer@8b95000 { + compatible = "fsl,dpaa2-ptp"; + reg = <0x0 0x8b95000 0x0 0x100>; + clocks = <&clockgen 4 1>; + little-endian; + fsl,extts-fifo; + }; + fsl_mc: fsl-mc@80c000000 { compatible = "fsl,qoriq-mc"; reg = <0x00000008 0x0c000000 0 0x40>, /* MC portal base */
arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi +8 -0
@@ -848,6 +848,14 @@ dma-coherent; }; + ptp-timer@8b95000 { + compatible = "fsl,dpaa2-ptp"; + reg = <0x0 0x8b95000 0x0 0x100>; + clocks = <&clockgen 4 1>; + little-endian; + fsl,extts-fifo; + }; + fsl_mc: fsl-mc@80c000000 { compatible = "fsl,qoriq-mc"; reg = <0x00000008 0x0c000000 0 0x40>,
Signature · 1 line
2.7.4
Yangbo Lu
maintainerPATCH v2 5/6 dpaa2-ptp: add interrupt support
In reply to Yangbo LuThis patch is to add interrupt support for dpaa2 ptp clock, including MC APIs and PPS interrupt support. Other events haven't been supported in MC by now.
---
Changes for v2:
- None.
--- drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c | 110 +++++++++++- drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h | 45 +++++ drivers/net/ethernet/freescale/dpaa2/dprtc.c | 219 +++++++++++++++++++++++ drivers/net/ethernet/freescale/dpaa2/dprtc.h | 44 +++++ 4 files changed, 417 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +109 -1
@@ -7,11 +7,55 @@#include <linux/module.h> #include <linux/of.h> #include <linux/of_address.h> +#include <linux/msi.h> #include <linux/fsl/mc.h> #include <linux/fsl/ptp_qoriq.h> #include "dpaa2-ptp.h" +static int dpaa2_ptp_enable (struct ptp_clock_info *ptp, +struct ptp_clock_request *rq,int on) +{ + struct ptp_qoriq *ptp_qoriq = container_of(ptp, struct ptp_qoriq, caps); +struct fsl_mc_device *mc_dev; +struct device *dev; +u32 mask =0 ; +u32 bit; +int err; + + dev = ptp_qoriq->dev; + mc_dev =to_fsl_mc_device (dev); + +switch (rq->type) { +case PTP_CLK_REQ_PPS : + bit =DPRTC_EVENT_PPS ; +break ; +default : +return -EOPNOTSUPP ; + } + + err =dprtc_get_irq_mask (mc_dev->mc_io,0 , mc_dev->mc_handle, +DPRTC_IRQ_INDEX , &mask); +if (err <0 ) { +dev_err (dev,"dprtc_get_irq_mask(): %d\n" , err); +return err; + } + +if (on) + mask |= bit; +else + mask &= ~bit; + + err =dprtc_set_irq_mask (mc_dev->mc_io,0 , mc_dev->mc_handle, +DPRTC_IRQ_INDEX , mask); +if (err <0 ) { +dev_err (dev,"dprtc_set_irq_mask(): %d\n" , err); +return err; + } + +return 0 ; +} +static const struct ptp_clock_info dpaa2_ptp_caps = { .owner =THIS_MODULE , .name ="DPAA2 PTP Clock" ,
@@ -25,11 +69,47 @@ static const struct ptp_clock_info dpaa2_ptp_caps = { .adjtime = ptp_qoriq_adjtime, .gettime64 = ptp_qoriq_gettime, .settime64 = ptp_qoriq_settime, + .enable = dpaa2_ptp_enable, }; +static irqreturn_t dpaa2_ptp_irq_handler_thread (int irq,void *priv) +{ +struct ptp_qoriq *ptp_qoriq = priv; +struct ptp_clock_event event; +struct fsl_mc_device *mc_dev; +struct device *dev; +u32 status =0 ; +int err; + + dev = ptp_qoriq->dev; + mc_dev =to_fsl_mc_device (dev); + + err =dprtc_get_irq_status (mc_dev->mc_io,0 , mc_dev->mc_handle, +DPRTC_IRQ_INDEX , &status); +if (unlikely (err)) { +dev_err (dev,"dprtc_get_irq_status err %d\n" , err); +return IRQ_NONE ; + } + +if (status &DPRTC_EVENT_PPS ) { + event.type =PTP_CLOCK_PPS ; +ptp_clock_event (ptp_qoriq->clock, &event); + } + + err =dprtc_clear_irq_status (mc_dev->mc_io,0 , mc_dev->mc_handle, +DPRTC_IRQ_INDEX , status); +if (unlikely (err)) { +dev_err (dev,"dprtc_clear_irq_status err %d\n" , err); +return IRQ_NONE ; + } + +return IRQ_HANDLED ; +} +static int dpaa2_ptp_probe (struct fsl_mc_device *mc_dev) {struct device *dev = &mc_dev->dev; +struct fsl_mc_device_irq *irq;struct ptp_qoriq *ptp_qoriq;struct device_node *node;void __iomem *base;
@@ -71,15 +151,42 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev) goto err_close; } + err =fsl_mc_allocate_irqs (mc_dev); +if (err) { +dev_err (dev,"MC irqs allocation failed\n" ); + goto err_unmap; + } + + irq = mc_dev->irqs[0 ]; + ptp_qoriq->irq = irq->msi_desc->irq; + + err =devm_request_threaded_irq (dev, ptp_qoriq->irq,NULL , + dpaa2_ptp_irq_handler_thread, +IRQF_NO_SUSPEND |IRQF_ONESHOT , +dev_name (dev), ptp_qoriq); +if (err <0 ) { +dev_err (dev,"devm_request_threaded_irq(): %d\n" , err); + goto err_free_mc_irq; + } + + err =dprtc_set_irq_enable (mc_dev->mc_io,0 , mc_dev->mc_handle, +DPRTC_IRQ_INDEX ,1 ); +if (err <0 ) { +dev_err (dev,"dprtc_set_irq_enable(): %d\n" , err); + goto err_free_mc_irq; + } + err =ptp_qoriq_init (ptp_qoriq, base, &dpaa2_ptp_caps);if (err) - goto err_unmap; + goto err_free_mc_irq; dpaa2_phc_index = ptp_qoriq->phc_index;dev_set_drvdata (dev, ptp_qoriq);return 0 ; +err_free_mc_irq: +fsl_mc_free_irqs (mc_dev); err_unmap:iounmap (base); err_close:
@@ -100,6 +207,7 @@ static int dpaa2_ptp_remove(struct fsl_mc_device *mc_dev) dpaa2_phc_index =-1 ;ptp_qoriq_free (ptp_qoriq); +fsl_mc_free_irqs (mc_dev);dprtc_close (mc_dev->mc_io,0 , mc_dev->mc_handle);fsl_mc_portal_free (mc_dev->mc_io);
drivers/net/ethernet/freescale/dpaa2/dprtc-cmd.h +45 -0
56 lines not on this page · raw message
drivers/net/ethernet/freescale/dpaa2/dprtc.c +219 -0
222 lines not on this page · raw message
drivers/net/ethernet/freescale/dpaa2/dprtc.h +44 -0
54 lines not on this page · raw message
Signature · 1 line
2.7.4
Yangbo Lu
maintainerPATCH v2 6/6 MAINTAINERS: maintain DPAA2 PTP driver in QorIQ PTP entry
In reply to Yangbo LuMaintain DPAA2 PTP driver in QorIQ PTP entry.
---
Changes for v2:
- None.
--- MAINTAINERS | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
MAINTAINERS +2 -7
@@ -4922,13 +4922,6 @@ L: [email protected] S: Maintained F: drivers/staging/fsl-dpaa2/ethsw -DPAA2 PTP CLOCK DRIVER -M: Yangbo Lu <[email protected]> -L: [email protected] -S: Maintained -F: drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp* -F: drivers/net/ethernet/freescale/dpaa2/dprtc* - DPT_I2O SCSI RAID DRIVER M: Adaptec OEM Raid Solutions <[email protected]> L: [email protected]
@@ -6371,6 +6364,8 @@ FREESCALE QORIQ PTP CLOCK DRIVER M: Yangbo Lu <[email protected]> L: [email protected] S: Maintained +F: drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp* +F: drivers/net/ethernet/freescale/dpaa2/dprtc* F: drivers/net/ethernet/freescale/enetc/enetc_ptp.c F: drivers/ptp/ptp_qoriq.c F: drivers/ptp/ptp_qoriq_debugfs.c
Signature · 1 line
2.7.4
David Miller
maintainerFrom: Yangbo Lu <[email protected]>
Date: Fri, 14 Jun 2019 18:40:49 +0800
Quoted 10 lines
Although
dpaa2-ptp.cdriver is afsl_mc_driverwhich is using MC APIs for register accessing, it's same IP block with eTSEC/DPAA/ENETC 1588 timer.
This patch-set is to convert to reuseptp_qoriqdriver by using register ioremap and dropping related MC APIs. However the interrupts could only be handled by MC which fires MSIs to ARM cores. So the interrupt enabling and handling still rely on MC APIs. MC APIs for interrupt and PPS event support are also added by this patch-set.
Quoted 3 lines
---
Changes for v2:
- Allowed to compile withCOMPILE_TEST.
Series applied, thanks.