ptp: Add a driver for InES time stamping IP core.
Subsystems (3)
Richard Cochran
maintainerPATCH v3 6/6 ptp: Add a driver for InES time stamping IP core.
The InES at the ZHAW offers a PTP time stamping IP core. The FPGA logic recognizes and time stamps PTP frames on the MII bus. This patch adds a driver for the core along with a device tree binding to allow hooking the driver to MII buses.
--- drivers/ptp/Kconfig | 10 + drivers/ptp/Makefile | 1 + drivers/ptp/ptp_ines.c | 870 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 881 insertions(+) create mode 100644 drivers/ptp/ptp_ines.c
drivers/ptp/Kconfig +10 -0
@@ -88,6 +88,16 @@ config DP83640_PHY In order for this to work, your MAC driver must also implement the skb_tx_timestamp() function. +config PTP_1588_CLOCK_INES + tristate "ZHAW InES PTP time stamping IP core" + depends on NETWORK_PHY_TIMESTAMPING + depends on PHYLIB + depends on PTP_1588_CLOCK + help + This driver adds support for using the ZHAW InES 1588 IP + core. This clock is only useful if the MII bus of your MAC + is wired up to the core. + config PTP_1588_CLOCK_PCH tristate "Intel PCH EG20T as PTP clock" depends on X86_32 || COMPILE_TEST
drivers/ptp/Makefile +1 -0
@@ -6,6 +6,7 @@ ptp-y := ptp_clock.o ptp_chardev.o ptp_sysfs.o obj-$(CONFIG_PTP_1588_CLOCK) += ptp.o obj-$(CONFIG_PTP_1588_CLOCK_DTE) += ptp_dte.o +obj-$(CONFIG_PTP_1588_CLOCK_INES) += ptp_ines.o obj-$(CONFIG_PTP_1588_CLOCK_IXP46X) += ptp_ixp46x.o obj-$(CONFIG_PTP_1588_CLOCK_PCH) += ptp_pch.o obj-$(CONFIG_PTP_1588_CLOCK_KVM) += ptp_kvm.o
drivers/ptp/ptp_ines.c new file +870 -0
870 lines not on this page · raw message
Signature · 1 line
2.11.0
drivers/ptp/ptp_ines.c line 185
Quoted 9 lines
drivers/ptp/ptp_ines.c new file +9
-0+static bool ines_match (struct sk_buff *skb,unsigned int ptp_class, +struct ines_timestamp *ts); +static int ines_rxfifo_read (struct ines_port *port); +static u64 ines_rxts64 (struct ines_port *port,unsigned int words); +static bool ines_timestamp_expired (struct ines_timestamp *ts); +static u64 ines_txts64 (struct ines_port *port,unsigned int words); +static void ines_txtstamp_work (struct work_struct *work); +static bool is_sync_pdelay_resp (struct sk_buff *skb,int type); +static u8 tag_to_msgtype (u8 tag);
Hi Richard
I don't know about the PTP subsystem, but in general, forward declarations are frowned upon, and it is generally requested to reorder the functions to remove them.
Quoted 8 lines
drivers/ptp/ptp_ines.c new file +8
-0+static struct platform_driver ines_ptp_ctrl_driver = { + .probe = ines_ptp_ctrl_probe, + .remove = ines_ptp_ctrl_remove, + .driver = { + .name ="ines_ptp_ctrl" , + .of_match_table =of_match_ptr (ines_ptp_ctrl_of_match), + }, +};
drivers/ptp/ptp_ines.c line 867
Quoted 10 lines
drivers/ptp/ptp_ines.c new file +10
-0+ +static int __init ines_ptp_init (void ) +{ +return platform_driver_register (&ines_ptp_ctrl_driver); +} + +static void __exit ines_ptp_cleanup(void) +{ +platform_driver_unregister (&ines_ptp_ctrl_driver); +}
include/linux/platform_device.h:
/* module_platform_driver() - Helper macro for drivers that don't do
* anything special in module init/exit. This eliminates a lot of
* boilerplate. Each module may only use this macro once, and
* calling it replaces module_init() and module_exit()
*/
#define module_platform_driver(__platform_driver) \
module_driver(__platform_driver, platform_driver_register, \
platform_driver_unregister)
AndrewRichard Cochran
maintainerQuoted 3 lines · Andrew Lunn
I don't know about the PTP subsystem, but in general, forward declarations are frowned upon, and it is generally requested to reorder the functions to remove them.
I am not aware of any general coding style rule or even defacto practice in this area, but there is a method to this driver. The functions are in alphabetical order. This makes it easier to find your way around the driver.
Thanks,
Richard