ptp: add ToD device driver for Intel FPGA cards
Subsystems (5)
PATCH v3 1/1 ptp: add ToD device driver for Intel FPGA cards
Adding a DFL (Device Feature List) device driver of ToD device for Intel FPGA cards.
The Intel FPGA Time of Day(ToD) IP within the FPGA DFL bus is exposed as PTP Hardware clock(PHC) device to the Linux PTP stack to synchronize the system clock to its ToD information using phc2sys utility of the Linux PTP stack. The DFL is a hardware List within FPGA, which defines a linked list of feature headers within the device MMIO space to provide an extensible way of adding subdevice features.
---
v3:
- add PTP_1588_CLOCK dependency for PTP_DFL_TOD in Kconfig file.
- don't need handle NULL case for ptp_clock_register() after adding PTP_1588_CLOCK dependency.
- wrap the code at 80 characters.
v2:
- handle NULL for ptp_clock_register().
- use readl_poll_timeout_atomic() instead of readl_poll_timeout(), and change the interval timeout to 10us.
- fix the uninitialized variable.
--- MAINTAINERS | 7 + drivers/ptp/Kconfig | 14 ++ drivers/ptp/Makefile | 1 + drivers/ptp/ptp_dfl_tod.c | 332 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 354 insertions(+) create mode 100644 drivers/ptp/ptp_dfl_tod.c
MAINTAINERS +7 -0
@@ -15623,6 +15623,13 @@ L: [email protected] S: Maintained F: drivers/ptp/ptp_ocp.c +INTEL PTP DFL ToD DRIVER +M: Tianfei Zhang <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: drivers/ptp/ptp_dfl_tod.c + OPENCORES I2C BUS DRIVER M: Peter Korsgaard <[email protected]> M: Andrew Lunn <[email protected]>
drivers/ptp/Kconfig +14 -0
@@ -186,4 +186,18 @@ config PTP_1588_CLOCK_OCP More information is available at http://www.timingcard.com/ +config PTP_DFL_TOD + tristate "FPGA DFL ToD Driver" + depends on FPGA_DFL + depends on PTP_1588_CLOCK + help + The DFL (Device Feature List) device driver for the Intel ToD + (Time-of-Day) device in FPGA card. The ToD IP within the FPGA + is exposed as PTP Hardware Clock (PHC) device to the Linux PTP + stack to synchronize the system clock to its ToD information + using phc2sys utility of the Linux PTP stack. + + To compile this driver as a module, choose M here: the module + will be called ptp_dfl_tod. + endmenu
drivers/ptp/Makefile +1 -0
@@ -18,3 +18,4 @@ obj-$(CONFIG_PTP_1588_CLOCK_IDTCM) += ptp_clockmatrix.o obj-$(CONFIG_PTP_1588_CLOCK_IDT82P33) += ptp_idt82p33.o obj-$(CONFIG_PTP_1588_CLOCK_VMW) += ptp_vmw.o obj-$(CONFIG_PTP_1588_CLOCK_OCP) += ptp_ocp.o +obj-$(CONFIG_PTP_DFL_TOD) += ptp_dfl_tod.o
drivers/ptp/ptp_dfl_tod.c new file +332 -0
332 lines not on this page · raw message
Signature · 1 line
2.38.1
Richard Cochran
maintainerCCing Arnd...
Quoted 4 lines · Tianfei Zhang
v3:
- addPTP_1588_CLOCKdependency forPTP_DFL_TODinKconfigfile.
- don't need handle NULL case forptp_clock_register()after addingPTP_1588_CLOCKdependency.
Sorry, but this isn't how it is done...
drivers/ptp/Kconfig config PTP_1588_CLOCK_OCP · line 192
Quoted 4 lines
drivers/ptp/Kconfig +4
-0+config PTP_DFL_TOD + tristate "FPGA DFL ToD Driver" + depends on FPGA_DFL + depends on PTP_1588_CLOCK
Try these commands:
git grep "depends on PTP_1588_CLOCK_OPTIONAL"
git grep "depends on PTP_1588_CLOCK_OPTIONAL" | grep -v OPTIONAL
Driver must depend on PTP_1588_CLOCK_OPTIONAL and then handle the NULL case correctly.
Thanks,
Richard
Quoted 16 lines · Richard Cochran
Quoted 4 lines · Tianfei Zhang
v3:
- addPTP_1588_CLOCKdependency forPTP_DFL_TODinKconfigfile.
- don't need handle NULL case forptp_clock_register()after addingPTP_1588_CLOCKdependency.Sorry, but this isn't how it is done...
drivers/ptp/Kconfig config PTP_1588_CLOCK_OCP · line 192
Quoted 4 lines
drivers/ptp/Kconfig +4
-0+config PTP_DFL_TOD + tristate "FPGA DFL ToD Driver" + depends on FPGA_DFL + depends on PTP_1588_CLOCKTry these commands:
Quoted 5 lines
git grep "depends on
PTP_1588_CLOCK_OPTIONAL"
git grep "depends onPTP_1588_CLOCK_OPTIONAL" | grep -v OPTIONALDriver must depend on
PTP_1588_CLOCK_OPTIONALand then handle the NULL case correctly.
I think this one is one of the (few) cases where the 'depends on PTP_1588_CLOCK' is correct and 'depends on PTP_1588_CLOCK_OPTIONAL' would be wrong:
Using PTP_1588_CLOCK_OPTIONAL as a dependency for PTP_DFL_TOD would allow enabling the driver even when PTP_1588_CLOCK is completely disabled, which would cleanly build but not do anything useful because the driver only handles PTP and not also networking.
Arnd
Richard Cochran
maintainerQuoted 4 lines · Arnd Bergmann
Using
PTP_1588_CLOCK_OPTIONALas a dependency forPTP_DFL_TODwould allow enabling the driver even whenPTP_1588_CLOCKis completely disabled, which would cleanly build but not do anything useful because the driver only handles PTP and not also networking.
Okay, thanks for the explanation,
Richard
Quoted 10 lines · Tianfei Zhang
Adding a DFL (Device Feature List) device driver of ToD device for Intel FPGA cards.
The Intel FPGA Time of Day(ToD) IP within the FPGA DFL bus is exposed as PTP Hardware clock(PHC) device to the Linux PTP stack to synchronize the system clock to its ToD information using phc2sys utility of the Linux PTP stack. The DFL is a hardware List within FPGA, which defines a linked list of feature headers within the device MMIO space to provide an extensible way of adding subdevice features.
Quoted 2 lines
Signed-off-by Raghavendra Khadatare <[email protected]>Signed-off-by Tianfei Zhang <[email protected]>
Quoted 39 lines · Tianfei Zhang
Adding a DFL (Device Feature List) device driver of ToD device for Intel FPGA cards.
The Intel FPGA Time of Day(ToD) IP within the FPGA DFL bus is exposed as PTP Hardware clock(PHC) device to the Linux PTP stack to synchronize the system clock to its ToD information using phc2sys utility of the Linux PTP stack. The DFL is a hardware List within FPGA, which defines a linked list of feature headers within the device MMIO space to provide an extensible way of adding subdevice features.
Signed-off-by Raghavendra Khadatare <[email protected]>Signed-off-by Tianfei Zhang <[email protected]>---
v3:
- addPTP_1588_CLOCKdependency forPTP_DFL_TODinKconfigfile.
- don't need handle NULL case forptp_clock_register()after addingPTP_1588_CLOCKdependency.
- wrap the code at 80 characters.v2:
- handle NULL forptp_clock_register().
- usereadl_poll_timeout_atomic()instead ofreadl_poll_timeout(), and change the interval timeout to 10us.
- fix the uninitialized variable.
---drivers/ptp/ptp_dfl_tod.c new file +6
-0@@ -0,0 +1,332 @@ +#include <linux/bitfield.h> +#include <linux/delay.h> +#include <linux/dfl.h> +#include <linux/gcd.h> +#include <linux/iopoll.h> +#include <linux/module.h>
drivers/ptp/ptp_dfl_tod.c
Quoted 10 lines
drivers/ptp/ptp_dfl_tod.c new file +9
-0+#include <linux/ptp_clock_kernel.h> +#include <linux/spinlock.h> +#include <linux/units.h> +static int dfl_tod_probe (struct dfl_device *ddev) +{ +struct device *dev = &ddev->dev; +struct dfl_tod *dt; + + dt =devm_kzalloc (dev,sizeof (*dt),GFP_KERNEL );
+ #include <linux/device.h>
Other than that,
Signature · 1 line
i.
Quoted 59 lines
-----Original Message-----
From: Ilpo Järvinen <[email protected]>
Sent: Wednesday, March 29, 2023 6:57 PM
To: Zhang, Tianfei <[email protected]>
Cc: [email protected]; Netdev <[email protected]>; linux- [email protected]; Andy Shevchenko <[email protected]>; Gomes, Vinicius <[email protected]>; [email protected]; Pagani, Marco <[email protected]>; Weight, Russell H <[email protected]>; [email protected]; [email protected]; Khadatare, RaghavendraX Anand <[email protected]>
Subject: Re: [PATCH v3] ptp: add ToD device driver for Intel FPGA cardsQuoted 42 lines · Tianfei Zhang
Adding a DFL (Device Feature List) device driver of ToD device for Intel FPGA cards.
The Intel FPGA Time of Day(ToD) IP within the FPGA DFL bus is exposed as PTP Hardware clock(PHC) device to the Linux PTP stack to synchronize the system clock to its ToD information using phc2sys utility of the Linux PTP stack. The DFL is a hardware List within FPGA, which defines a linked list of feature headers within the device MMIO space to provide an extensible way of adding subdevice features.
Signed-off-by: Raghavendra Khadatare
<[email protected]>Signed-off-by Tianfei Zhang <[email protected]>---
v3:
- addPTP_1588_CLOCKdependency forPTP_DFL_TODinKconfigfile.
- don't need handle NULL case forptp_clock_register()after addingPTP_1588_CLOCKdependency.
- wrap the code at 80 characters.v2:
- handle NULL forptp_clock_register().
- usereadl_poll_timeout_atomic()instead ofreadl_poll_timeout(), and change the interval timeout to 10us.
- fix the uninitialized variable.
---drivers/ptp/ptp_dfl_tod.c new renamed from drivers/ptp/ptp_dfl_tod.c +0
-0file mode 100644 index 000000000000..f699d541b360
drivers/ptp/ptp_dfl_tod.c new file +9
-0@@ -0,0 +1,332 @@ +#include <linux/bitfield.h> +#include <linux/delay.h> +#include <linux/dfl.h> +#include <linux/gcd.h> +#include <linux/iopoll.h> +#include <linux/module.h> +#include <linux/ptp_clock_kernel.h> +#include <linux/spinlock.h> +#include <linux/units.h>
Quoted 7 lines
drivers/ptp/ptp_dfl_tod.c line 285
Quoted 5 lines
drivers/ptp/ptp_dfl_tod.c new file +5
-0+static int dfl_tod_probe (struct dfl_device *ddev) { +struct device *dev = &ddev->dev; +struct dfl_tod *dt; + + dt =devm_kzalloc (dev,sizeof (*dt),GFP_KERNEL );+ #include <
linux/device.h>
I will add it on v4 patch, thanks.
Quoted 7 lines
Other than that,
Reviewed-by Ilpo Järvinen <[email protected]>--
i.
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Tue, 28 Mar 2023 10:24:55 -0400 you wrote:
Adding a DFL (Device Feature List) device driver of ToD device for Intel FPGA cards.
The Intel FPGA Time of Day(ToD) IP within the FPGA DFL bus is exposed as PTP Hardware clock(PHC) device to the Linux PTP stack to synchronize the system clock to its ToD information using phc2sys utility of the Linux PTP stack. The DFL is a hardware List within FPGA, which defines a linked list of feature headers within the device MMIO space to provide an extensible way of adding subdevice features.
[...]
Here is the summary with links:
- [v3] ptp: add ToD device driver for Intel FPGA cards
https://git.kernel.org/netdev/net-next/c/615927f1a487
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html