[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aLmSSC90dWDfhGkL@hoboy.vegasvil.org>
Date: Thu, 4 Sep 2025 06:21:12 -0700
From: Richard Cochran <richardcochran@...il.com>
To: Wei Fang <wei.fang@....com>
Cc: robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org,
claudiu.manoil@....com, vladimir.oltean@....com,
xiaoning.wang@....com, andrew+netdev@...n.ch, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
vadim.fedorenko@...ux.dev, Frank.Li@....com, shawnguo@...nel.org,
fushi.peng@....com, devicetree@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
imx@...ts.linux.dev
Subject: Re: [PATCH v6 net-next 03/17] ptp: add helpers to get the phc_index
by of_node or dev
On Wed, Aug 27, 2025 at 02:33:18PM +0800, Wei Fang wrote:
> Some Ethernet controllers do not have an integrated PTP timer function.
> Instead, the PTP timer is a separated device and provides PTP hardware
> clock to the Ethernet controller to use. Therefore, the Ethernet
> controller driver needs to obtain the PTP clock's phc_index in its
> ethtool_ops::get_ts_info(). Currently, most drivers implement this in
> the following ways.
>
> 1. The PTP device driver adds a custom API and exports it to the Ethernet
> controller driver.
> 2. The PTP device driver adds private data to its device structure. So
> the private data structure needs to be exposed to the Ethernet controller
> driver.
>
> When registering the ptp clock, ptp_clock_register() always saves the
> ptp_clock pointer to the private data of ptp_clock::dev. Therefore, as
> long as ptp_clock::dev is obtained, the phc_index can be obtained. So
> the following generic APIs can be added to the ptp driver to obtain the
> phc_index.
>
> 1. ptp_clock_index_by_dev(): Obtain the phc_index by the device pointer
> of the PTP device.
> 2.ptp_clock_index_by_of_node(): Obtain the phc_index by the of_node
> pointer of the PTP device.
>
> Also, we can add another API like ptp_clock_index_by_fwnode() to get the
> phc_index by fwnode of PTP device. However, this API is not used in this
> patch set, so it is better to add it when needed.
>
> Suggested-by: Vladimir Oltean <vladimir.oltean@....com>
> Signed-off-by: Wei Fang <wei.fang@....com>
> Reviewed-by: Frank Li <Frank.Li@....com>
Acked-by: Richard Cochran <richardcochran@...il.com>
Powered by blists - more mailing lists