Skip to content

Commit d1cbfd7

Browse files
Nicolas PitreKAGA-KOKO
authored andcommitted
ptp_clock: Allow for it to be optional
In order to break the hard dependency between the PTP clock subsystem and ethernet drivers capable of being clock providers, this patch provides simple PTP stub functions to allow linkage of those drivers into the kernel even when the PTP subsystem is configured out. Drivers must be ready to accept NULL from ptp_clock_register() in that case. And to make it possible for PTP to be configured out, the select statement in those driver's Kconfig menu entries is converted to the new "imply" statement. This way the PTP subsystem may have Kconfig dependencies of its own, such as POSIX_TIMERS, without having to make those ethernet drivers unavailable if POSIX timers are cconfigured out. And when support for POSIX timers is selected again then the default config option for PTP clock support will automatically be adjusted accordingly. The pch_gbe driver is a bit special as it relies on extra code in drivers/ptp/ptp_pch.c. Therefore we let the make process descend into drivers/ptp/ even if PTP_1588_CLOCK is unselected. Signed-off-by: Nicolas Pitre <[email protected]> Acked-by: Richard Cochran <[email protected]> Acked-by: Edward Cree <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Reviewed-by: Josh Triplett <[email protected]> Cc: Paul Bolle <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Michal Marek <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 32ce5ac commit d1cbfd7

File tree

18 files changed

+69
-50
lines changed

18 files changed

+69
-50
lines changed

drivers/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ obj-$(CONFIG_INPUT) += input/
107107
obj-$(CONFIG_RTC_LIB) += rtc/
108108
obj-y += i2c/ media/
109109
obj-$(CONFIG_PPS) += pps/
110-
obj-$(CONFIG_PTP_1588_CLOCK) += ptp/
110+
obj-y += ptp/
111111
obj-$(CONFIG_W1) += w1/
112112
obj-y += power/
113113
obj-$(CONFIG_HWMON) += hwmon/

drivers/net/ethernet/adi/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ config BFIN_RX_DESC_NUM
5858
config BFIN_MAC_USE_HWSTAMP
5959
bool "Use IEEE 1588 hwstamp"
6060
depends on BFIN_MAC && BF518
61-
select PTP_1588_CLOCK
61+
imply PTP_1588_CLOCK
6262
default y
6363
---help---
6464
To support the IEEE 1588 Precision Time Protocol (PTP), select y here

drivers/net/ethernet/amd/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ config AMD_XGBE
177177
depends on ARM64 || COMPILE_TEST
178178
select BITREVERSE
179179
select CRC32
180-
select PTP_1588_CLOCK
180+
imply PTP_1588_CLOCK
181181
---help---
182182
This driver supports the AMD 10GbE Ethernet device found on an
183183
AMD SoC.

drivers/net/ethernet/amd/xgbe/xgbe-main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ static int xgbe_probe(struct platform_device *pdev)
773773
goto err_wq;
774774
}
775775

776-
xgbe_ptp_register(pdata);
776+
if (IS_REACHABLE(CONFIG_PTP_1588_CLOCK))
777+
xgbe_ptp_register(pdata);
777778

778779
xgbe_debugfs_init(pdata);
779780

@@ -812,7 +813,8 @@ static int xgbe_remove(struct platform_device *pdev)
812813

813814
xgbe_debugfs_exit(pdata);
814815

815-
xgbe_ptp_unregister(pdata);
816+
if (IS_REACHABLE(CONFIG_PTP_1588_CLOCK))
817+
xgbe_ptp_unregister(pdata);
816818

817819
flush_workqueue(pdata->an_workqueue);
818820
destroy_workqueue(pdata->an_workqueue);

drivers/net/ethernet/broadcom/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ config TIGON3
110110
depends on PCI
111111
select PHYLIB
112112
select HWMON
113-
select PTP_1588_CLOCK
113+
imply PTP_1588_CLOCK
114114
---help---
115115
This driver supports Broadcom Tigon3 based gigabit Ethernet cards.
116116

@@ -120,7 +120,7 @@ config TIGON3
120120
config BNX2X
121121
tristate "Broadcom NetXtremeII 10Gb support"
122122
depends on PCI
123-
select PTP_1588_CLOCK
123+
imply PTP_1588_CLOCK
124124
select FW_LOADER
125125
select ZLIB_INFLATE
126126
select LIBCRC32C

drivers/net/ethernet/cavium/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ config THUNDER_NIC_RGX
5353
config LIQUIDIO
5454
tristate "Cavium LiquidIO support"
5555
depends on 64BIT
56-
select PTP_1588_CLOCK
56+
imply PTP_1588_CLOCK
5757
select FW_LOADER
5858
select LIBCRC32C
5959
---help---

drivers/net/ethernet/freescale/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ config FEC
2525
ARCH_MXC || SOC_IMX28)
2626
default ARCH_MXC || SOC_IMX28 if ARM
2727
select PHYLIB
28-
select PTP_1588_CLOCK
28+
imply PTP_1588_CLOCK
2929
---help---
3030
Say Y here if you want to use the built-in 10/100 Fast ethernet
3131
controller on some Motorola ColdFire and Freescale i.MX processors.

drivers/net/ethernet/intel/Kconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ config E1000E
5858
tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support"
5959
depends on PCI && (!SPARC32 || BROKEN)
6060
select CRC32
61-
select PTP_1588_CLOCK
61+
imply PTP_1588_CLOCK
6262
---help---
6363
This driver supports the PCI-Express Intel(R) PRO/1000 gigabit
6464
ethernet family of adapters. For PCI or PCI-X e1000 adapters,
@@ -83,7 +83,7 @@ config E1000E_HWTS
8383
config IGB
8484
tristate "Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support"
8585
depends on PCI
86-
select PTP_1588_CLOCK
86+
imply PTP_1588_CLOCK
8787
select I2C
8888
select I2C_ALGOBIT
8989
---help---
@@ -156,7 +156,7 @@ config IXGBE
156156
tristate "Intel(R) 10GbE PCI Express adapters support"
157157
depends on PCI
158158
select MDIO
159-
select PTP_1588_CLOCK
159+
imply PTP_1588_CLOCK
160160
---help---
161161
This driver supports Intel(R) 10GbE PCI Express family of
162162
adapters. For more information on how to identify your adapter, go
@@ -213,7 +213,7 @@ config IXGBEVF
213213

214214
config I40E
215215
tristate "Intel(R) Ethernet Controller XL710 Family support"
216-
select PTP_1588_CLOCK
216+
imply PTP_1588_CLOCK
217217
depends on PCI
218218
---help---
219219
This driver supports Intel(R) Ethernet Controller XL710 Family of
@@ -264,7 +264,7 @@ config FM10K
264264
tristate "Intel(R) FM10000 Ethernet Switch Host Interface Support"
265265
default n
266266
depends on PCI_MSI
267-
select PTP_1588_CLOCK
267+
imply PTP_1588_CLOCK
268268
---help---
269269
This driver supports Intel(R) FM10000 Ethernet Switch Host
270270
Interface. For more information on how to identify your adapter,

drivers/net/ethernet/mellanox/mlx4/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ config MLX4_EN
77
depends on MAY_USE_DEVLINK
88
depends on PCI
99
select MLX4_CORE
10-
select PTP_1588_CLOCK
10+
imply PTP_1588_CLOCK
1111
---help---
1212
This driver supports Mellanox Technologies ConnectX Ethernet
1313
devices.

drivers/net/ethernet/mellanox/mlx5/core/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ config MLX5_CORE
1414
config MLX5_CORE_EN
1515
bool "Mellanox Technologies ConnectX-4 Ethernet support"
1616
depends on NETDEVICES && ETHERNET && PCI && MLX5_CORE
17-
select PTP_1588_CLOCK
17+
imply PTP_1588_CLOCK
1818
default n
1919
---help---
2020
Ethernet support in Mellanox Technologies ConnectX-4 NIC.

drivers/net/ethernet/renesas/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ config RAVB
3737
select MII
3838
select MDIO_BITBANG
3939
select PHYLIB
40-
select PTP_1588_CLOCK
40+
imply PTP_1588_CLOCK
4141
help
4242
Renesas Ethernet AVB device driver.
4343
This driver supports the following SoCs:

drivers/net/ethernet/samsung/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ config SXGBE_ETH
2121
depends on HAS_IOMEM && HAS_DMA
2222
select PHYLIB
2323
select CRC32
24-
select PTP_1588_CLOCK
24+
imply PTP_1588_CLOCK
2525
---help---
2626
This is the driver for the SXGBE 10G Ethernet IP block found on
2727
Samsung platforms.

drivers/net/ethernet/sfc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ config SFC
55
select CRC32
66
select I2C
77
select I2C_ALGOBIT
8-
select PTP_1588_CLOCK
8+
imply PTP_1588_CLOCK
99
---help---
1010
This driver supports 10/40-gigabit Ethernet cards based on
1111
the Solarflare SFC4000, SFC9000-family and SFC9100-family

drivers/net/ethernet/stmicro/stmmac/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ config STMMAC_ETH
44
select MII
55
select PHYLIB
66
select CRC32
7-
select PTP_1588_CLOCK
7+
imply PTP_1588_CLOCK
88
select RESET_CONTROLLER
99
---help---
1010
This is the driver for the Ethernet IPs are built around a

drivers/net/ethernet/ti/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ config TI_CPSW
7676
config TI_CPTS
7777
bool "TI Common Platform Time Sync (CPTS) Support"
7878
depends on TI_CPSW
79-
select PTP_1588_CLOCK
79+
imply PTP_1588_CLOCK
8080
---help---
8181
This driver supports the Common Platform Time Sync unit of
8282
the CPSW Ethernet Switch. The unit can time stamp PTP UDP/IPv4

drivers/net/ethernet/tile/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ config TILE_NET
99
select CRC32
1010
select TILE_GXIO_MPIPE if TILEGX
1111
select HIGH_RES_TIMERS if TILEGX
12-
select PTP_1588_CLOCK if TILEGX
12+
imply PTP_1588_CLOCK if TILEGX
1313
---help---
1414
This is a standard Linux network device driver for the
1515
on-chip Tilera Gigabit Ethernet and XAUI interfaces.

drivers/ptp/Kconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ config PTP_1588_CLOCK
2828
config PTP_1588_CLOCK_GIANFAR
2929
tristate "Freescale eTSEC as PTP clock"
3030
depends on GIANFAR
31-
select PTP_1588_CLOCK
31+
depends on PTP_1588_CLOCK
3232
default y
3333
help
3434
This driver adds support for using the eTSEC as a PTP
@@ -42,7 +42,7 @@ config PTP_1588_CLOCK_GIANFAR
4242
config PTP_1588_CLOCK_IXP46X
4343
tristate "Intel IXP46x as PTP clock"
4444
depends on IXP4XX_ETH
45-
select PTP_1588_CLOCK
45+
depends on PTP_1588_CLOCK
4646
default y
4747
help
4848
This driver adds support for using the IXP46X as a PTP
@@ -60,7 +60,7 @@ config DP83640_PHY
6060
tristate "Driver for the National Semiconductor DP83640 PHYTER"
6161
depends on NETWORK_PHY_TIMESTAMPING
6262
depends on PHYLIB
63-
select PTP_1588_CLOCK
63+
depends on PTP_1588_CLOCK
6464
---help---
6565
Supports the DP83640 PHYTER with IEEE 1588 features.
6666

@@ -76,7 +76,7 @@ config PTP_1588_CLOCK_PCH
7676
tristate "Intel PCH EG20T as PTP clock"
7777
depends on X86_32 || COMPILE_TEST
7878
depends on HAS_IOMEM && NET
79-
select PTP_1588_CLOCK
79+
imply PTP_1588_CLOCK
8080
help
8181
This driver adds support for using the PCH EG20T as a PTP
8282
clock. The hardware supports time stamping of PTP packets

include/linux/ptp_clock_kernel.h

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -122,30 +122,6 @@ struct ptp_clock_info {
122122

123123
struct ptp_clock;
124124

125-
/**
126-
* ptp_clock_register() - register a PTP hardware clock driver
127-
*
128-
* @info: Structure describing the new clock.
129-
* @parent: Pointer to the parent device of the new clock.
130-
*
131-
* Returns a valid pointer on success or PTR_ERR on failure. If PHC
132-
* support is missing at the configuration level, this function
133-
* returns NULL, and drivers are expected to gracefully handle that
134-
* case separately.
135-
*/
136-
137-
extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
138-
struct device *parent);
139-
140-
/**
141-
* ptp_clock_unregister() - unregister a PTP hardware clock driver
142-
*
143-
* @ptp: The clock to remove from service.
144-
*/
145-
146-
extern int ptp_clock_unregister(struct ptp_clock *ptp);
147-
148-
149125
enum ptp_clock_events {
150126
PTP_CLOCK_ALARM,
151127
PTP_CLOCK_EXTTS,
@@ -171,6 +147,31 @@ struct ptp_clock_event {
171147
};
172148
};
173149

150+
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
151+
152+
/**
153+
* ptp_clock_register() - register a PTP hardware clock driver
154+
*
155+
* @info: Structure describing the new clock.
156+
* @parent: Pointer to the parent device of the new clock.
157+
*
158+
* Returns a valid pointer on success or PTR_ERR on failure. If PHC
159+
* support is missing at the configuration level, this function
160+
* returns NULL, and drivers are expected to gracefully handle that
161+
* case separately.
162+
*/
163+
164+
extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
165+
struct device *parent);
166+
167+
/**
168+
* ptp_clock_unregister() - unregister a PTP hardware clock driver
169+
*
170+
* @ptp: The clock to remove from service.
171+
*/
172+
173+
extern int ptp_clock_unregister(struct ptp_clock *ptp);
174+
174175
/**
175176
* ptp_clock_event() - notify the PTP layer about an event
176177
*
@@ -202,4 +203,20 @@ extern int ptp_clock_index(struct ptp_clock *ptp);
202203
int ptp_find_pin(struct ptp_clock *ptp,
203204
enum ptp_pin_function func, unsigned int chan);
204205

206+
#else
207+
static inline struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
208+
struct device *parent)
209+
{ return NULL; }
210+
static inline int ptp_clock_unregister(struct ptp_clock *ptp)
211+
{ return 0; }
212+
static inline void ptp_clock_event(struct ptp_clock *ptp,
213+
struct ptp_clock_event *event)
214+
{ }
215+
static inline int ptp_clock_index(struct ptp_clock *ptp)
216+
{ return -1; }
217+
static inline int ptp_find_pin(struct ptp_clock *ptp,
218+
enum ptp_pin_function func, unsigned int chan)
219+
{ return -1; }
220+
#endif
221+
205222
#endif

0 commit comments

Comments
 (0)