diff mbox

[v1,1/2] dt-binding: ptp: add bindings document for dte based ptp clock

Message ID 1497299161-6458-2-git-send-email-arun.parameswaran@broadcom.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Arun Parameswaran June 12, 2017, 8:26 p.m. UTC
Add device tree binding documentation for the Broadcom DTE
PTP clock driver.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt

Comments

Richard Cochran June 13, 2017, 5:09 a.m. UTC | #1
On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
> +Example:
> +
> +ptp_dte: ptp_dte@180af650 {
> +	compatible = "brcm,ptp-dte";
> +	reg = <0x180af650 0x10>;
> +	status = "okay";
> +};

This patch set looks okay, as far as it goes, but how does one
actually use the clock?

How does one connect this node to an Ethernet MAC, for example?

Thanks,
Richard
Arun Parameswaran June 13, 2017, 5:46 p.m. UTC | #2
Hi Richard,

On 17-06-12 10:09 PM, Richard Cochran wrote:
> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>> +Example:
>> +
>> +ptp_dte: ptp_dte@180af650 {
>> +	compatible = "brcm,ptp-dte";
>> +	reg = <0x180af650 0x10>;
>> +	status = "okay";
>> +};
> This patch set looks okay, as far as it goes, but how does one
> actually use the clock?
>
> How does one connect this node to an Ethernet MAC, for example?
In some of the SoC's, the DTE's NCO is synced in hardware with the Ethernet's
1588 Shim NCO (used for time-stamping the packets). We are working on getting
all the future SoC's synced this way (for Ethernet).

In other scenarios, we use an user-space app to perform the sync based on
time-stamps from external hardware sources like the Wi-Fi.
> Thanks,
> Richard
Ray Jui June 14, 2017, 6:18 p.m. UTC | #3
On 6/13/17 10:46 AM, Arun Parameswaran wrote:
> 
> Hi Richard,
> 
> On 17-06-12 10:09 PM, Richard Cochran wrote:
>> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>>> +Example:
>>> +
>>> +ptp_dte: ptp_dte@180af650 {
>>> +	compatible = "brcm,ptp-dte";
>>> +	reg = <0x180af650 0x10>;
>>> +	status = "okay";
>>> +};
>> This patch set looks okay, as far as it goes, but how does one
>> actually use the clock?
>>
>> How does one connect this node to an Ethernet MAC, for example?
> In some of the SoC's, the DTE's NCO is synced in hardware with the Ethernet's
> 1588 Shim NCO (used for time-stamping the packets). We are working on getting
> all the future SoC's synced this way (for Ethernet).
> 

So apparently you do not need any phandle based DT binding defined for
the connection between the Ethernet device node and the PTP device node?

> In other scenarios, we use an user-space app to perform the sync based on
> time-stamps from external hardware sources like the Wi-Fi.
>> Thanks,
>> Richard
>
Arun Parameswaran June 14, 2017, 6:33 p.m. UTC | #4
On 17-06-14 11:18 AM, Ray Jui wrote:
> 
> 
> On 6/13/17 10:46 AM, Arun Parameswaran wrote:
>>
>> Hi Richard,
>>
>> On 17-06-12 10:09 PM, Richard Cochran wrote:
>>> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>>>> +Example:
>>>> +
>>>> +ptp_dte: ptp_dte@180af650 {
>>>> +	compatible = "brcm,ptp-dte";
>>>> +	reg = <0x180af650 0x10>;
>>>> +	status = "okay";
>>>> +};
>>> This patch set looks okay, as far as it goes, but how does one
>>> actually use the clock?
>>>
>>> How does one connect this node to an Ethernet MAC, for example?
>> In some of the SoC's, the DTE's NCO is synced in hardware with the Ethernet's
>> 1588 Shim NCO (used for time-stamping the packets). We are working on getting
>> all the future SoC's synced this way (for Ethernet).
>>
> 
> So apparently you do not need any phandle based DT binding defined for
> the connection between the Ethernet device node and the PTP device node?
> 
Correct. This driver doesn't need any phandle.

The Ethernet/Switch driver, in the SoC's where the hardware link is not
available, might need the phandle to this driver.

>> In other scenarios, we use an user-space app to perform the sync based on
>> time-stamps from external hardware sources like the Wi-Fi.
>>> Thanks,
>>> Richard
>>
Arun Parameswaran June 14, 2017, 6:39 p.m. UTC | #5
On 17-06-14 11:18 AM, Ray Jui wrote:
> 
> 
> On 6/13/17 10:46 AM, Arun Parameswaran wrote:
>>
>> Hi Richard,
>>
>> On 17-06-12 10:09 PM, Richard Cochran wrote:
>>> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>>>> +Example:
>>>> +
>>>> +ptp_dte: ptp_dte@180af650 {
>>>> +	compatible = "brcm,ptp-dte";
>>>> +	reg = <0x180af650 0x10>;
>>>> +	status = "okay";
>>>> +};
>>> This patch set looks okay, as far as it goes, but how does one
>>> actually use the clock?
>>>
>>> How does one connect this node to an Ethernet MAC, for example?
>> In some of the SoC's, the DTE's NCO is synced in hardware with the Ethernet's
>> 1588 Shim NCO (used for time-stamping the packets). We are working on getting
>> all the future SoC's synced this way (for Ethernet).
>>
> 
> So apparently you do not need any phandle based DT binding defined for
> the connection between the Ethernet device node and the PTP device node?
> 
Correct. This driver doesn't need any phandle.

The Ethernet driver, in SoC's where the hardware link is not available,
might need the phandle to this driver.

>> In other scenarios, we use an user-space app to perform the sync based on
>> time-stamps from external hardware sources like the Wi-Fi.
>>> Thanks,
>>> Richard
>>
Rob Herring June 18, 2017, 2:04 p.m. UTC | #6
On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
> Add device tree binding documentation for the Broadcom DTE
> PTP clock driver.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
> ---
>  Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
> 
> diff --git a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
> new file mode 100644
> index 0000000..07590bc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
> @@ -0,0 +1,13 @@
> +* Broadcom Digital Timing Engine(DTE) based PTP clock driver

Bindings describe h/w, not drivers.

> +
> +Required properties:
> +- compatible: should be "brcm,ptp-dte"

Looks too generic. You need SoC specific compatible strings.

> +- reg: address and length of the DTE block's NCO registers
> +
> +Example:
> +
> +ptp_dte: ptp_dte@180af650 {

Don't use '_' in node names.

> +	compatible = "brcm,ptp-dte";
> +	reg = <0x180af650 0x10>;
> +	status = "okay";
> +};
> -- 
> 1.9.1
>
Arun Parameswaran June 19, 2017, 4:50 p.m. UTC | #7
Hi David, Rob,
I will address all of Rob's comments below.

Since a part of the patch was applied to 'net-next', would you like me to
send a new patch (based on the applied one), or a 'V2' of this patch ?

Thanks
Arun

On 17-06-18 07:04 AM, Rob Herring wrote:
> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>> Add device tree binding documentation for the Broadcom DTE
>> PTP clock driver.
>>
>> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
>> ---
>>  Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt | 13 +++++++++++++
>>  1 file changed, 13 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>
>> diff --git a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>> new file mode 100644
>> index 0000000..07590bc
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>> @@ -0,0 +1,13 @@
>> +* Broadcom Digital Timing Engine(DTE) based PTP clock driver
> 
> Bindings describe h/w, not drivers.
> 
>> +
>> +Required properties:
>> +- compatible: should be "brcm,ptp-dte"
> 
> Looks too generic. You need SoC specific compatible strings.
> 
>> +- reg: address and length of the DTE block's NCO registers
>> +
>> +Example:
>> +
>> +ptp_dte: ptp_dte@180af650 {
> 
> Don't use '_' in node names.
> 
>> +	compatible = "brcm,ptp-dte";
>> +	reg = <0x180af650 0x10>;
>> +	status = "okay";
>> +};
>> -- 
>> 1.9.1
>>
Scott Branden June 20, 2017, 8:48 p.m. UTC | #8
Hi Rob,


On 17-06-18 07:04 AM, Rob Herring wrote:
> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>> Add device tree binding documentation for the Broadcom DTE
>> PTP clock driver.
>>
>> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
>> ---
>>   Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt | 13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>
>> diff --git a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>> new file mode 100644
>> index 0000000..07590bc
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>> @@ -0,0 +1,13 @@
>> +* Broadcom Digital Timing Engine(DTE) based PTP clock driver
> Bindings describe h/w, not drivers.
>
>> +
>> +Required properties:
>> +- compatible: should be "brcm,ptp-dte"
> Looks too generic. You need SoC specific compatible strings.

Rob, could you please help me understand the use of adding SoC specific 
compatible strings.
I still don't get it.

It's my understanding that the SoC compatibility string is to future 
proof against bugs/incompatibilities
between different versions of the hardware block due to integration 
issues or any other reason.
You can then compare in your driver because the strings were already 
used in the dtb.

That would make sense if you can't already differentiate what SoC you 
are running on.
But the SoC is already specified in the root of the device tree in the 
compatible string?
Why can't you just use of_machine_is_compatible inside your driver when 
needed?

Please explain what I'm missing.  I see other drivers already following 
the of_machine_is_compatible
approach and it makes more sense to me than adding SoC specific 
compatible strings into every
driver.

Regards,
  Scott
Rob Herring June 22, 2017, 3:19 a.m. UTC | #9
On Tue, Jun 20, 2017 at 3:48 PM, Scott Branden
<scott.branden@broadcom.com> wrote:
> Hi Rob,
>
>
> On 17-06-18 07:04 AM, Rob Herring wrote:
>>
>> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>>>
>>> Add device tree binding documentation for the Broadcom DTE
>>> PTP clock driver.
>>>
>>> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
>>> ---
>>>   Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt | 13
>>> +++++++++++++
>>>   1 file changed, 13 insertions(+)
>>>   create mode 100644
>>> Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>
>>> diff --git a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>> b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>> new file mode 100644
>>> index 0000000..07590bc
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>> @@ -0,0 +1,13 @@
>>> +* Broadcom Digital Timing Engine(DTE) based PTP clock driver
>>
>> Bindings describe h/w, not drivers.
>>
>>> +
>>> +Required properties:
>>> +- compatible: should be "brcm,ptp-dte"
>>
>> Looks too generic. You need SoC specific compatible strings.
>
>
> Rob, could you please help me understand the use of adding SoC specific
> compatible strings.
> I still don't get it.
>
> It's my understanding that the SoC compatibility string is to future proof
> against bugs/incompatibilities
> between different versions of the hardware block due to integration issues
> or any other reason.
> You can then compare in your driver because the strings were already used in
> the dtb.
>
> That would make sense if you can't already differentiate what SoC you are
> running on.
> But the SoC is already specified in the root of the device tree in the
> compatible string?
> Why can't you just use of_machine_is_compatible inside your driver when
> needed?

Use of of_machine_is_compatible in drivers will result in the same
mess we had with machine_is_X defines pre-DT. It practically
guarantees that you must update the driver for a new SoC (with
fallback compatibles you don't). Plus the matching logic for
of_machine_is_compatible is open coded logic in every driver which is
worse IMO than having a standard match table.

>
> Please explain what I'm missing.  I see other drivers already following the
> of_machine_is_compatible
> approach and it makes more sense to me than adding SoC specific compatible
> strings into every
> driver.

If the IP blocks are all the same, you don't have to add them to any
drivers, just add fallback compatibles.

Rob
Scott Branden June 23, 2017, 12:42 a.m. UTC | #10
On 17-06-21 08:19 PM, Rob Herring wrote:
> On Tue, Jun 20, 2017 at 3:48 PM, Scott Branden
> <scott.branden@broadcom.com> wrote:
>> Hi Rob,
>>
>>
>> On 17-06-18 07:04 AM, Rob Herring wrote:
>>> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>>>> Add device tree binding documentation for the Broadcom DTE
>>>> PTP clock driver.
>>>>
>>>> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
>>>> ---
>>>>    Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt | 13
>>>> +++++++++++++
>>>>    1 file changed, 13 insertions(+)
>>>>    create mode 100644
>>>> Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>> b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>> new file mode 100644
>>>> index 0000000..07590bc
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>> @@ -0,0 +1,13 @@
>>>> +* Broadcom Digital Timing Engine(DTE) based PTP clock driver
>>> Bindings describe h/w, not drivers.
>>>
>>>> +
>>>> +Required properties:
>>>> +- compatible: should be "brcm,ptp-dte"
>>> Looks too generic. You need SoC specific compatible strings.
>>
>> Rob, could you please help me understand the use of adding SoC specific
>> compatible strings.
>> I still don't get it.
>>
>> It's my understanding that the SoC compatibility string is to future proof
>> against bugs/incompatibilities
>> between different versions of the hardware block due to integration issues
>> or any other reason.
>> You can then compare in your driver because the strings were already used in
>> the dtb.
>>
>> That would make sense if you can't already differentiate what SoC you are
>> running on.
>> But the SoC is already specified in the root of the device tree in the
>> compatible string?
>> Why can't you just use of_machine_is_compatible inside your driver when
>> needed?
> Use of of_machine_is_compatible in drivers will result in the same
> mess we had with machine_is_X defines pre-DT. It practically
> guarantees that you must update the driver for a new SoC (with
> fallback compatibles you don't). Plus the matching logic for
> of_machine_is_compatible is open coded logic in every driver which is
> worse IMO than having a standard match table.
I don't understand what you mean by fallback compatible then.

Let's say I have 3 SoCs that each contain the same ip block.
You want us to add a fallback compatibility per SoC, is that correct?

Then, if there is a workaround discovered in a particular SoC the driver 
can be updated in the future without changing the dtb.

Then, the block gets added to a 4th SoC.
You want us to another new compatibility string for the new SoC?
If the new SoC has a bug then the driver has to be updated whether it is 
in uses the fallback compatible or machine_is_compatible string.

There is no difference in amount of code added to a driver when a new 
SoC is introduced into the system that has bugs that need to be handled 
by the driver.

The difference is in your recommendation we need to go through all the 
drivers used by the new SoC and add fallback compatibility strings.
Then, we have to modify all the devicetree documentation for all the 
drivers.  Then, we have to ensure that all dts files populate this new 
fallback string (even if it is unused).  We don't see the benefit in 
doing any of that.  Using machine_is_compatible and having less 
compatibility strings to deal appears much cleaner and more foolproof 
for all situations.
>> Please explain what I'm missing.  I see other drivers already following the
>> of_machine_is_compatible
>> approach and it makes more sense to me than adding SoC specific compatible
>> strings into every
>> driver.
> If the IP blocks are all the same, you don't have to add them to any
> drivers, just add fallback compatibles.

> Rob
Regards,
Scott
Florian Fainelli June 23, 2017, 1:04 a.m. UTC | #11
On 06/22/2017 05:42 PM, Scott Branden wrote:
> 
> 
> On 17-06-21 08:19 PM, Rob Herring wrote:
>> On Tue, Jun 20, 2017 at 3:48 PM, Scott Branden
>> <scott.branden@broadcom.com> wrote:
>>> Hi Rob,
>>>
>>>
>>> On 17-06-18 07:04 AM, Rob Herring wrote:
>>>> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>>>>> Add device tree binding documentation for the Broadcom DTE
>>>>> PTP clock driver.
>>>>>
>>>>> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
>>>>> ---
>>>>>    Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt | 13
>>>>> +++++++++++++
>>>>>    1 file changed, 13 insertions(+)
>>>>>    create mode 100644
>>>>> Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>> b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>> new file mode 100644
>>>>> index 0000000..07590bc
>>>>> --- /dev/null
>>>>> +++ b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>> @@ -0,0 +1,13 @@
>>>>> +* Broadcom Digital Timing Engine(DTE) based PTP clock driver
>>>> Bindings describe h/w, not drivers.
>>>>
>>>>> +
>>>>> +Required properties:
>>>>> +- compatible: should be "brcm,ptp-dte"
>>>> Looks too generic. You need SoC specific compatible strings.
>>>
>>> Rob, could you please help me understand the use of adding SoC specific
>>> compatible strings.
>>> I still don't get it.
>>>
>>> It's my understanding that the SoC compatibility string is to future
>>> proof
>>> against bugs/incompatibilities
>>> between different versions of the hardware block due to integration
>>> issues
>>> or any other reason.
>>> You can then compare in your driver because the strings were already
>>> used in
>>> the dtb.
>>>
>>> That would make sense if you can't already differentiate what SoC you
>>> are
>>> running on.
>>> But the SoC is already specified in the root of the device tree in the
>>> compatible string?
>>> Why can't you just use of_machine_is_compatible inside your driver when
>>> needed?
>> Use of of_machine_is_compatible in drivers will result in the same
>> mess we had with machine_is_X defines pre-DT. It practically
>> guarantees that you must update the driver for a new SoC (with
>> fallback compatibles you don't). Plus the matching logic for
>> of_machine_is_compatible is open coded logic in every driver which is
>> worse IMO than having a standard match table.
> I don't understand what you mean by fallback compatible then.
> 
> Let's say I have 3 SoCs that each contain the same ip block.
> You want us to add a fallback compatibility per SoC, is that correct?

I think Rob meant a fallback compatibility for the particular block.
E.g: brcm,iproc-ptp is the fallback compatible string, but in your
SoC-specific DTS, you would have at least:

compatible = "brcm,cygnus-ptp", "brcm,iproc-ptp";

Where cygnus-ptp is more specific than iproc-ptp

> 
> Then, if there is a workaround discovered in a particular SoC the driver
> can be updated in the future without changing the dtb.
> 
> Then, the block gets added to a 4th SoC.
> You want us to another new compatibility string for the new SoC?
> If the new SoC has a bug then the driver has to be updated whether it is
> in uses the fallback compatible or machine_is_compatible string.
> 
> There is no difference in amount of code added to a driver when a new
> SoC is introduced into the system that has bugs that need to be handled
> by the driver.
> 
> The difference is in your recommendation we need to go through all the
> drivers used by the new SoC and add fallback compatibility strings.

Not really, the fallback is what the driver should be matching by
default (hence the name fallback) and if and only if you need to have a
SoC-specific behavior in your driver (because of bugs, or slight
differences) would you be matching this SoC-specific compatible string
to capture that and key the driver behavior based off that.

> Then, we have to modify all the devicetree documentation for all the
> drivers.  Then, we have to ensure that all dts files populate this new
> fallback string (even if it is unused).  We don't see the benefit in
> doing any of that.  Using machine_is_compatible and having less
> compatibility strings to deal appears much cleaner and more foolproof
> for all situations.

When you introduce a new SoC, you would update all the bindings for the
devices (not drivers) that are susceptible to be used by this SoC. If
all goes well, your SoC has little bugs, and your drivers don't even
need to see an update because they are already matching the fallback
compatible string.

That's what I understand from the suggestion but I may be totally off
rails here.
Scott Branden June 27, 2017, 5:10 a.m. UTC | #12
Hi Rob/Florian,

Thanks for input but still don't see any need for SoC specific
compatible stings.  IP revision specific yes.

On 17-06-22 06:04 PM, Florian Fainelli wrote:
> On 06/22/2017 05:42 PM, Scott Branden wrote:
>>
>> On 17-06-21 08:19 PM, Rob Herring wrote:
>>> On Tue, Jun 20, 2017 at 3:48 PM, Scott Branden
>>> <scott.branden@broadcom.com> wrote:
>>>> Hi Rob,
>>>>
>>>>
>>>> On 17-06-18 07:04 AM, Rob Herring wrote:
>>>>> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>>>>>> Add device tree binding documentation for the Broadcom DTE
>>>>>> PTP clock driver.
>>>>>>
>>>>>> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
>>>>>> ---
>>>>>>     Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt | 13
>>>>>> +++++++++++++
>>>>>>     1 file changed, 13 insertions(+)
>>>>>>     create mode 100644
>>>>>> Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>>
>>>>>> diff --git a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>> b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>> new file mode 100644
>>>>>> index 0000000..07590bc
>>>>>> --- /dev/null
>>>>>> +++ b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>> @@ -0,0 +1,13 @@
>>>>>> +* Broadcom Digital Timing Engine(DTE) based PTP clock driver
>>>>> Bindings describe h/w, not drivers.
>>>>>
>>>>>> +
>>>>>> +Required properties:
>>>>>> +- compatible: should be "brcm,ptp-dte"
>>>>> Looks too generic. You need SoC specific compatible strings.
>>>> Rob, could you please help me understand the use of adding SoC specific
>>>> compatible strings.
>>>> I still don't get it.
>>>>
>>>> It's my understanding that the SoC compatibility string is to future
>>>> proof
>>>> against bugs/incompatibilities
>>>> between different versions of the hardware block due to integration
>>>> issues
>>>> or any other reason.
>>>> You can then compare in your driver because the strings were already
>>>> used in
>>>> the dtb.
>>>>
>>>> That would make sense if you can't already differentiate what SoC you
>>>> are
>>>> running on.
>>>> But the SoC is already specified in the root of the device tree in the
>>>> compatible string?
>>>> Why can't you just use of_machine_is_compatible inside your driver when
>>>> needed?
>>> Use of of_machine_is_compatible in drivers will result in the same
>>> mess we had with machine_is_X defines pre-DT. It practically
>>> guarantees that you must update the driver for a new SoC (with
>>> fallback compatibles you don't). Plus the matching logic for
>>> of_machine_is_compatible is open coded logic in every driver which is
>>> worse IMO than having a standard match table.
>> I don't understand what you mean by fallback compatible then.
>>
>> Let's say I have 3 SoCs that each contain the same ip block.
>> You want us to add a fallback compatibility per SoC, is that correct?
> I think Rob meant a fallback compatibility for the particular block.
> E.g: brcm,iproc-ptp is the fallback compatible string, but in your
> SoC-specific DTS, you would have at least:
>
> compatible = "brcm,cygnus-ptp", "brcm,iproc-ptp";
>
> Where cygnus-ptp is more specific than iproc-ptp
>> Then, if there is a workaround discovered in a particular SoC the driver
>> can be updated in the future without changing the dtb.
>>
>> Then, the block gets added to a 4th SoC.
>> You want us to another new compatibility string for the new SoC?
>> If the new SoC has a bug then the driver has to be updated whether it is
>> in uses the fallback compatible or machine_is_compatible string.
>>
>> There is no difference in amount of code added to a driver when a new
>> SoC is introduced into the system that has bugs that need to be handled
>> by the driver.
>>
>> The difference is in your recommendation we need to go through all the
>> drivers used by the new SoC and add fallback compatibility strings.
> Not really, the fallback is what the driver should be matching by
> default (hence the name fallback) and if and only if you need to have a
> SoC-specific behavior in your driver (because of bugs, or slight
> differences) would you be matching this SoC-specific compatible string
> to capture that and key the driver behavior based off that.
>
>> Then, we have to modify all the devicetree documentation for all the
>> drivers.  Then, we have to ensure that all dts files populate this new
>> fallback string (even if it is unused).  We don't see the benefit in
>> doing any of that.  Using machine_is_compatible and having less
>> compatibility strings to deal appears much cleaner and more foolproof
>> for all situations.
> When you introduce a new SoC, you would update all the bindings for the
> devices (not drivers) that are susceptible to be used by this SoC. If
> all goes well, your SoC has little bugs, and your drivers don't even
> need to see an update because they are already matching the fallback
> compatible string.
>
> That's what I understand from the suggestion but I may be totally off
> rails here.
In this particular case, the IP is integrated within and outside a 
family of SoCs
(the exact same block is in Capri for example).
The only fallback compatablity string that makes sense is "brcm, 
dte-ptp-v1".
When we integrate a new version of this IP we would add "brcm, dte-ptp-v2".

Rob, I still see no need to define any other compatablity strings.

Everything else can be handled with machine_is_compatible
with the exact same amount of code change to the driver?
Adding the additional strings simply
adds a need to change documentation and changes to dts that are otherwise
completely unnecessary.  machine_is_compatible appears to be the cleaner
and simpler solution?

Regards,
  Scott
Rob Herring June 29, 2017, 10:40 p.m. UTC | #13
On Tue, Jun 27, 2017 at 12:10 AM, Scott Branden
<scott.branden@broadcom.com> wrote:
> Hi Rob/Florian,
>
> Thanks for input but still don't see any need for SoC specific
> compatible stings.  IP revision specific yes.
>
>
> On 17-06-22 06:04 PM, Florian Fainelli wrote:
>>
>> On 06/22/2017 05:42 PM, Scott Branden wrote:
>>>
>>>
>>> On 17-06-21 08:19 PM, Rob Herring wrote:
>>>>
>>>> On Tue, Jun 20, 2017 at 3:48 PM, Scott Branden
>>>> <scott.branden@broadcom.com> wrote:
>>>>>
>>>>> Hi Rob,
>>>>>
>>>>>
>>>>> On 17-06-18 07:04 AM, Rob Herring wrote:
>>>>>>
>>>>>> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>>>>>>>
>>>>>>> Add device tree binding documentation for the Broadcom DTE
>>>>>>> PTP clock driver.
>>>>>>>
>>>>>>> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
>>>>>>> ---
>>>>>>>     Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt | 13
>>>>>>> +++++++++++++
>>>>>>>     1 file changed, 13 insertions(+)
>>>>>>>     create mode 100644
>>>>>>> Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>>>
>>>>>>> diff --git a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>>> b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>>> new file mode 100644
>>>>>>> index 0000000..07590bc
>>>>>>> --- /dev/null
>>>>>>> +++ b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>>> @@ -0,0 +1,13 @@
>>>>>>> +* Broadcom Digital Timing Engine(DTE) based PTP clock driver
>>>>>>
>>>>>> Bindings describe h/w, not drivers.
>>>>>>
>>>>>>> +
>>>>>>> +Required properties:
>>>>>>> +- compatible: should be "brcm,ptp-dte"
>>>>>>
>>>>>> Looks too generic. You need SoC specific compatible strings.
>>>>>
>>>>> Rob, could you please help me understand the use of adding SoC specific
>>>>> compatible strings.
>>>>> I still don't get it.
>>>>>
>>>>> It's my understanding that the SoC compatibility string is to future
>>>>> proof
>>>>> against bugs/incompatibilities
>>>>> between different versions of the hardware block due to integration
>>>>> issues
>>>>> or any other reason.
>>>>> You can then compare in your driver because the strings were already
>>>>> used in
>>>>> the dtb.
>>>>>
>>>>> That would make sense if you can't already differentiate what SoC you
>>>>> are
>>>>> running on.
>>>>> But the SoC is already specified in the root of the device tree in the
>>>>> compatible string?
>>>>> Why can't you just use of_machine_is_compatible inside your driver when
>>>>> needed?
>>>>
>>>> Use of of_machine_is_compatible in drivers will result in the same
>>>> mess we had with machine_is_X defines pre-DT. It practically
>>>> guarantees that you must update the driver for a new SoC (with
>>>> fallback compatibles you don't). Plus the matching logic for
>>>> of_machine_is_compatible is open coded logic in every driver which is
>>>> worse IMO than having a standard match table.
>>>
>>> I don't understand what you mean by fallback compatible then.
>>>
>>> Let's say I have 3 SoCs that each contain the same ip block.
>>> You want us to add a fallback compatibility per SoC, is that correct?
>>
>> I think Rob meant a fallback compatibility for the particular block.
>> E.g: brcm,iproc-ptp is the fallback compatible string, but in your
>> SoC-specific DTS, you would have at least:
>>
>> compatible = "brcm,cygnus-ptp", "brcm,iproc-ptp";
>>
>> Where cygnus-ptp is more specific than iproc-ptp
>>>
>>> Then, if there is a workaround discovered in a particular SoC the driver
>>> can be updated in the future without changing the dtb.
>>>
>>> Then, the block gets added to a 4th SoC.
>>> You want us to another new compatibility string for the new SoC?
>>> If the new SoC has a bug then the driver has to be updated whether it is
>>> in uses the fallback compatible or machine_is_compatible string.
>>>
>>> There is no difference in amount of code added to a driver when a new
>>> SoC is introduced into the system that has bugs that need to be handled
>>> by the driver.
>>>
>>> The difference is in your recommendation we need to go through all the
>>> drivers used by the new SoC and add fallback compatibility strings.
>>
>> Not really, the fallback is what the driver should be matching by
>> default (hence the name fallback) and if and only if you need to have a
>> SoC-specific behavior in your driver (because of bugs, or slight
>> differences) would you be matching this SoC-specific compatible string
>> to capture that and key the driver behavior based off that.
>>
>>> Then, we have to modify all the devicetree documentation for all the
>>> drivers.  Then, we have to ensure that all dts files populate this new
>>> fallback string (even if it is unused).  We don't see the benefit in
>>> doing any of that.  Using machine_is_compatible and having less
>>> compatibility strings to deal appears much cleaner and more foolproof
>>> for all situations.
>>
>> When you introduce a new SoC, you would update all the bindings for the
>> devices (not drivers) that are susceptible to be used by this SoC. If
>> all goes well, your SoC has little bugs, and your drivers don't even
>> need to see an update because they are already matching the fallback
>> compatible string.
>>
>> That's what I understand from the suggestion but I may be totally off
>> rails here.
>
> In this particular case, the IP is integrated within and outside a family of
> SoCs
> (the exact same block is in Capri for example).
> The only fallback compatablity string that makes sense is "brcm,
> dte-ptp-v1".
> When we integrate a new version of this IP we would add "brcm, dte-ptp-v2".

Unless you have strong version control of IP versions, version numbers
aren't generally reliable. Also, in my experience doing time at Si
companies, h/w designers can't be trusted regarding what changed or
not.

There are some exceptions. We accept version numbers mainly for FPGA
IP as in that case, the FPGA vendor is making releases of IP with end
users picking versions and the version numbering is well defined. v1
and v2 does not look well defined to me. What happens when you have an
ECO fix for example?

> Rob, I still see no need to define any other compatablity strings.
>
> Everything else can be handled with machine_is_compatible
> with the exact same amount of code change to the driver?

How is a static table with driver data per compatible the same as coding:

if (of_machine_is_compatible("soc1"))
  ...
else if (of_machine_is_compatible("soc2"))
  ...
else if (of_machine_is_compatible("soc3") || of_machine_is_compatible("soc4"))
 ...
and so on...

As I mentioned previously, we don't want this mess in drivers.

The static table matching guarantees that you don't have to update the
driver for a new SoC when a block is "exactly the same". Just have the
existing block compatible string as a fallback compatible. If you have
something like above, then you may have to update the driver depending
on how the logic is written. For example, if you add soc5 which has
the same IP block as soc1, then you have to update the driver unless
soc5 can claim to be compatible with soc1 at the top-level (which only
works when the new SoC is a pure superset).

> Adding the additional strings simply
> adds a need to change documentation and changes to dts that are otherwise
> completely unnecessary.  machine_is_compatible appears to be the cleaner
> and simpler solution?

The documentation changes should be oneliners.

Why do you need dts changes? The dts for a new SoC should be correct
from the start with the new compatibles and appropriate fallback
compatibles.

The bottom line is this is how DT was designed to work and is what
everyone else follows. Broadcom is not special.

Rob
Scott Branden June 30, 2017, 1:05 a.m. UTC | #14
Hi Rob,


On 17-06-29 03:40 PM, Rob Herring wrote:
> On Tue, Jun 27, 2017 at 12:10 AM, Scott Branden
> <scott.branden@broadcom.com> wrote:
>> Hi Rob/Florian,
>>
>> Thanks for input but still don't see any need for SoC specific
>> compatible stings.  IP revision specific yes.
>>
>>
>> On 17-06-22 06:04 PM, Florian Fainelli wrote:
>>> On 06/22/2017 05:42 PM, Scott Branden wrote:
>>>>
>>>> On 17-06-21 08:19 PM, Rob Herring wrote:
>>>>> On Tue, Jun 20, 2017 at 3:48 PM, Scott Branden
>>>>> <scott.branden@broadcom.com> wrote:
>>>>>> Hi Rob,
>>>>>>
>>>>>>
>>>>>> On 17-06-18 07:04 AM, Rob Herring wrote:
>>>>>>> On Mon, Jun 12, 2017 at 01:26:00PM -0700, Arun Parameswaran wrote:
>>>>>>>> Add device tree binding documentation for the Broadcom DTE
>>>>>>>> PTP clock driver.
>>>>>>>>
>>>>>>>> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
>>>>>>>> ---
>>>>>>>>      Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt | 13
>>>>>>>> +++++++++++++
>>>>>>>>      1 file changed, 13 insertions(+)
>>>>>>>>      create mode 100644
>>>>>>>> Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>>>>
>>>>>>>> diff --git a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>>>> b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>>>> new file mode 100644
>>>>>>>> index 0000000..07590bc
>>>>>>>> --- /dev/null
>>>>>>>> +++ b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
>>>>>>>> @@ -0,0 +1,13 @@
>>>>>>>> +* Broadcom Digital Timing Engine(DTE) based PTP clock driver
>>>>>>> Bindings describe h/w, not drivers.
>>>>>>>
>>>>>>>> +
>>>>>>>> +Required properties:
>>>>>>>> +- compatible: should be "brcm,ptp-dte"
>>>>>>> Looks too generic. You need SoC specific compatible strings.
>>>>>> Rob, could you please help me understand the use of adding SoC specific
>>>>>> compatible strings.
>>>>>> I still don't get it.
>>>>>>
>>>>>> It's my understanding that the SoC compatibility string is to future
>>>>>> proof
>>>>>> against bugs/incompatibilities
>>>>>> between different versions of the hardware block due to integration
>>>>>> issues
>>>>>> or any other reason.
>>>>>> You can then compare in your driver because the strings were already
>>>>>> used in
>>>>>> the dtb.
>>>>>>
>>>>>> That would make sense if you can't already differentiate what SoC you
>>>>>> are
>>>>>> running on.
>>>>>> But the SoC is already specified in the root of the device tree in the
>>>>>> compatible string?
>>>>>> Why can't you just use of_machine_is_compatible inside your driver when
>>>>>> needed?
>>>>> Use of of_machine_is_compatible in drivers will result in the same
>>>>> mess we had with machine_is_X defines pre-DT. It practically
>>>>> guarantees that you must update the driver for a new SoC (with
>>>>> fallback compatibles you don't). Plus the matching logic for
>>>>> of_machine_is_compatible is open coded logic in every driver which is
>>>>> worse IMO than having a standard match table.
>>>> I don't understand what you mean by fallback compatible then.
>>>>
>>>> Let's say I have 3 SoCs that each contain the same ip block.
>>>> You want us to add a fallback compatibility per SoC, is that correct?
>>> I think Rob meant a fallback compatibility for the particular block.
>>> E.g: brcm,iproc-ptp is the fallback compatible string, but in your
>>> SoC-specific DTS, you would have at least:
>>>
>>> compatible = "brcm,cygnus-ptp", "brcm,iproc-ptp";
>>>
>>> Where cygnus-ptp is more specific than iproc-ptp
>>>> Then, if there is a workaround discovered in a particular SoC the driver
>>>> can be updated in the future without changing the dtb.
>>>>
>>>> Then, the block gets added to a 4th SoC.
>>>> You want us to another new compatibility string for the new SoC?
>>>> If the new SoC has a bug then the driver has to be updated whether it is
>>>> in uses the fallback compatible or machine_is_compatible string.
>>>>
>>>> There is no difference in amount of code added to a driver when a new
>>>> SoC is introduced into the system that has bugs that need to be handled
>>>> by the driver.
>>>>
>>>> The difference is in your recommendation we need to go through all the
>>>> drivers used by the new SoC and add fallback compatibility strings.
>>> Not really, the fallback is what the driver should be matching by
>>> default (hence the name fallback) and if and only if you need to have a
>>> SoC-specific behavior in your driver (because of bugs, or slight
>>> differences) would you be matching this SoC-specific compatible string
>>> to capture that and key the driver behavior based off that.
>>>
>>>> Then, we have to modify all the devicetree documentation for all the
>>>> drivers.  Then, we have to ensure that all dts files populate this new
>>>> fallback string (even if it is unused).  We don't see the benefit in
>>>> doing any of that.  Using machine_is_compatible and having less
>>>> compatibility strings to deal appears much cleaner and more foolproof
>>>> for all situations.
>>> When you introduce a new SoC, you would update all the bindings for the
>>> devices (not drivers) that are susceptible to be used by this SoC. If
>>> all goes well, your SoC has little bugs, and your drivers don't even
>>> need to see an update because they are already matching the fallback
>>> compatible string.
>>>
>>> That's what I understand from the suggestion but I may be totally off
>>> rails here.
>> In this particular case, the IP is integrated within and outside a family of
>> SoCs
>> (the exact same block is in Capri for example).
>> The only fallback compatablity string that makes sense is "brcm,
>> dte-ptp-v1".
>> When we integrate a new version of this IP we would add "brcm, dte-ptp-v2".
> Unless you have strong version control of IP versions, version numbers
> aren't generally reliable. Also, in my experience doing time at Si
> companies, h/w designers can't be trusted regarding what changed or
> not.
>
> There are some exceptions. We accept version numbers mainly for FPGA
> IP as in that case, the FPGA vendor is making releases of IP with end
> users picking versions and the version numbering is well defined. v1
> and v2 does not look well defined to me. What happens when you have an
> ECO fix for example?
When you have an ECO fix that would be a new version.  So v1.1, 1.2, etc.
Appropriate compatibility string would be:
"brcm, dte-ptp-v1.1", "brcm, dte-ptp-v1"

What else would you like us to do in this case?
Do you want us to add Soc specific revision compatibility strings?
>> Rob, I still see no need to define any other compatablity strings.
>>
>> Everything else can be handled with machine_is_compatible
>> with the exact same amount of code change to the driver?
> How is a static table with driver data per compatible the same as coding:
The static table with driver data is used with the compatibility string
"brcm, dte-ptp-v1", etc.  It is only the odd case where machine specific
is used to handle a bug (due to silicon designers lying to us that the 
version was the same
or they integrated something differently somehow).
> if (of_machine_is_compatible("soc1"))
>    ...
> else if (of_machine_is_compatible("soc2"))
>    ...
> else if (of_machine_is_compatible("soc3") || of_machine_is_compatible("soc4"))
>   ...
> and so on...
>
> As I mentioned previously, we don't want this mess in drivers.
Investigating drivers:
I see the use of of_machine_is_compatible to handle SoC specific cases.
I see the use of of_device_is_compatible to handle some SoC specific 
cases as well.
If there is a bug discovered that needs to be handle in a driver for an 
SoC specific case then code
needs to be added that would use either of those 2 checks to handle it.

Based on that - I don't see the benefit of adding the soc specific 
compatibility strings in the dts
files.

if (of_machine_is_compatible("brcm,soc1")
seems much cleaner than:
if (of_device_is_compatible("brcm,soc1-ptp-dte")

I see no mess in that and I see both cases of if statements in use today 
in various drivers.

If you really have a problem with the existing drivers calling either of 
the above 2 functions,
then adding the machine into the lookup of your data driven table would 
be a cleaner solution than
adding all these soc specific compatibility strings?  This would also solve
all the inconsistencies present today.
> The static table matching guarantees that you don't have to update the
> driver for a new SoC when a block is "exactly the same". Just have the
> existing block compatible string as a fallback compatible. If you have
> something like above, then you may have to update the driver depending
> on how the logic is written. For example, if you add soc5 which has
> the same IP block as soc1, then you have to update the driver unless
> soc5 can claim to be compatible with soc1 at the top-level (which only
> works when the new SoC is a pure superset).
>
>> Adding the additional strings simply
>> adds a need to change documentation and changes to dts that are otherwise
>> completely unnecessary.  machine_is_compatible appears to be the cleaner
>> and simpler solution?
> The documentation changes should be oneliners.
>
> Why do you need dts changes? The dts for a new SoC should be correct
> from the start with the new compatibles and appropriate fallback
> compatibles.
> The bottom line is this is how DT was designed to work and is what
> everyone else follows. Broadcom is not special.
Could you please point me at the design your are referring to?
I have been searching for details on the use of the fallback string and 
have yet to find it documented.
There really is no consistency.  That is what I'm trying to understand 
here.  Broadcom is not special.

I would like to have the proper understanding as devicetree is a loose 
mess in general.

Also, I find many places where dts files
are using the same compatibility strings for different SoCs because they 
use the same IP block.
People are not create fallback compatibility per SoC everywhere.
> Rob
Regards,
   Scott
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
new file mode 100644
index 0000000..07590bc
--- /dev/null
+++ b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt
@@ -0,0 +1,13 @@ 
+* Broadcom Digital Timing Engine(DTE) based PTP clock driver
+
+Required properties:
+- compatible: should be "brcm,ptp-dte"
+- reg: address and length of the DTE block's NCO registers
+
+Example:
+
+ptp_dte: ptp_dte@180af650 {
+	compatible = "brcm,ptp-dte";
+	reg = <0x180af650 0x10>;
+	status = "okay";
+};