diff mbox series

[net-next,v2,1/2] dt-bindings: net: adin: add property for link-status pin polarity

Message ID 20240420-adin-pin-polarity-v2-1-bf9714da7648@solid-run.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: phy: adin: add support for setting led-, link-status-pin polarity | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: krzk+dt@kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-21--03-00 (tests: 995)

Commit Message

Josua Mayer April 20, 2024, 11:23 a.m. UTC
ADIN1200/1300 support software control over LINK_ST pin polarity.
This is a fixed function output reflecting phy link-status that is not
otherwise controllable by software.

Add new property adi,link-st-polarity for specifying polarity as either
active-high (reset-default) or active-low.

Signed-off-by: Josua Mayer <josua@solid-run.com>
---
 Documentation/devicetree/bindings/net/adi,adin.yaml | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Andrew Lunn April 20, 2024, 4:10 p.m. UTC | #1
> +  adi,link-st-polarity:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description:
> +      LINK_ST pin polarity.
> +    enum:
> +      - 0 # active high
> +      - 1 # active low
> +    default: 0
> +

How does this differ from:

Documentation/devicetree/bindings/leds/common.yaml

+  active-low:
+    type: boolean
+    description:
+      Makes LED active low. To turn the LED ON, line needs to be
+      set to low voltage instead of high.


Why do we need a vendor property when there is a generic property?

	Andrew
Josua Mayer April 20, 2024, 4:56 p.m. UTC | #2
Am 20.04.24 um 18:10 schrieb Andrew Lunn:
>> +  adi,link-st-polarity:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description:
>> +      LINK_ST pin polarity.
>> +    enum:
>> +      - 0 # active high
>> +      - 1 # active low
>> +    default: 0
>> +
> How does this differ from:
>
> Documentation/devicetree/bindings/leds/common.yaml
>
> +  active-low:
> +    type: boolean
> +    description:
> +      Makes LED active low. To turn the LED ON, line needs to be
> +      set to low voltage instead of high.
>
>
> Why do we need a vendor property when there is a generic property?
It differs in tree depth and naming.
To use led binding we need to add a leds node with a led node inside,
and decide on an index for this not-an-led pin.
Sure, could be done but  maybe should be documented somewhere
as it is not intuitive.

Main reason for having a vendor-specific and non-led property
is that this pin is not a led, it is merely a signal.
The PHY can  be configured to provide via this signal either:
- link-status
- collision detection
- carrier sense
- tx packet start
- rx packet start

The purpose of the binding I propose is just polarity of this signal.
A more complete binding would also allow selection from the
above listed functions.
This kind of configuration is much more like pinctrl than led.
Andrew Lunn April 20, 2024, 5:09 p.m. UTC | #3
> Main reason for having a vendor-specific and non-led property
> is that this pin is not a led.

So you are not driving an LED with its? What are you using it for?

> This kind of configuration is much more like pinctrl than led.
 
So what is the pinctrl way of describing this? You should not be
inventing something new if there is an existing mechanism to describe
it. We want consistency, not 42 different ways of doing one thing.

	Andrew
Josua Mayer April 21, 2024, 9:07 a.m. UTC | #4
Am 20.04.24 um 19:09 schrieb Andrew Lunn:
>> Main reason for having a vendor-specific and non-led property
>> is that this pin is not a led.
> So you are not driving an LED with its? What are you using it for?

The unit I am currently working on connects an LED, yes.

Therefore I agree with you that it could be described adequately
by an led node with active-low property.

I merely don't like the idea that this makes no sense for the other
possible pin functions.
Once somebody uses this pin for different use-case, they will need
to solve it again.

>> This kind of configuration is much more like pinctrl than led.
>  
> So what is the pinctrl way of describing this? You should not be
> inventing something new if there is an existing mechanism to describe
> it. We want consistency, not 42 different ways of doing one thing.
I am mostly familiar with the
#define PIN_FUNCTION magic-numbers
pins = <PIN_FUNCTION more-magic-numbers>;

But on Marvell platforms there is:
marvell,pins =  "mpp1";
marvell,function = "gpio";

I also found more generic???:
Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml
Documentation/devicetree/bindings/pinctrl/pinmux-node.yaml
which have output-high/output-low, function, pin.

Interestingly LED_0 supports some non-led functions, too:
- collision detection
- carrier sense
- tx/rx start
- tx error
so polarity is also relevant to non-led usage of LED_0 pin.

Might be I am not seeing the big picture how this fits a generic structure.
Andrew Lunn April 21, 2024, 5:54 p.m. UTC | #5
> I merely don't like the idea that this makes no sense for the other
> possible pin functions.
> Once somebody uses this pin for different use-case, they will need
> to solve it again.

There are not too many different uses of this pin. The data sheet
indicates you can connect it to the MAC to indicate link. You might
also be able to use it with an external PTP stamper, using the start
of frame indication.

I don't know of any bindings for such use case, but something will be
needed to describe how the pin is connected to the other device. And
at that point, the active low property could be used.

> >> This kind of configuration is much more like pinctrl than led.
> >  
> > So what is the pinctrl way of describing this? You should not be
> > inventing something new if there is an existing mechanism to describe
> > it. We want consistency, not 42 different ways of doing one thing.
> I am mostly familiar with the
> #define PIN_FUNCTION magic-numbers
> pins = <PIN_FUNCTION more-magic-numbers>;
> 
> But on Marvell platforms there is:
> marvell,pins =  "mpp1";
> marvell,function = "gpio";
> 
> I also found more generic???:
> Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml
> Documentation/devicetree/bindings/pinctrl/pinmux-node.yaml
> which have output-high/output-low, function, pin.

So that is probably your alternative if you want to not use the LED
binding.

> 
> Interestingly LED_0 supports some non-led functions, too:
> - collision detection
> - carrier sense
> - tx/rx start
> - tx error
> so polarity is also relevant to non-led usage of LED_0 pin.

Collision detection is an LED usage, you just don't see it very often
since half duplex is pretty unusual this century. Carrier sense is
also similar age, from when Ethernet was CSMA/CD.

Since they are not really used any more we don't have them in the LED
framework, but i think we could implement them if somebody actually
wanted them. My intention was to keep the LED framework KISS, since
vendors tend to implement all sorts of odd LED blink reasons. But if
nobody wants them, nobody has a good end user use case for them, why
support them?

       Andrew
Josua Mayer April 29, 2024, 9:54 a.m. UTC | #6
Am 21.04.24 um 19:54 schrieb Andrew Lunn:
>> I merely don't like the idea that this makes no sense for the other
>> possible pin functions.
>> Once somebody uses this pin for different use-case, they will need
>> to solve it again.
> There are not too many different uses of this pin. The data sheet
> indicates you can connect it to the MAC to indicate link. You might
> also be able to use it with an external PTP stamper, using the start
> of frame indication.
>
> I don't know of any bindings for such use case, but something will be
> needed to describe how the pin is connected to the other device. And
> at that point, the active low property could be used.
>
>>>> This kind of configuration is much more like pinctrl than led.
>>>  
>>> So what is the pinctrl way of describing this? You should not be
>>> inventing something new if there is an existing mechanism to describe
>>> it. We want consistency, not 42 different ways of doing one thing.
>> I am mostly familiar with the
>> #define PIN_FUNCTION magic-numbers
>> pins = <PIN_FUNCTION more-magic-numbers>;
>>
>> But on Marvell platforms there is:
>> marvell,pins =  "mpp1";
>> marvell,function = "gpio";
>>
>> I also found more generic???:
>> Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml
>> Documentation/devicetree/bindings/pinctrl/pinmux-node.yaml
>> which have output-high/output-low, function, pin.
> So that is probably your alternative if you want to not use the LED
> binding.
I will consider using pincfg/-mux
>
>> Interestingly LED_0 supports some non-led functions, too:
>> - collision detection
>> - carrier sense
>> - tx/rx start
>> - tx error
>> so polarity is also relevant to non-led usage of LED_0 pin.
> Collision detection is an LED usage, you just don't see it very often
> since half duplex is pretty unusual this century. Carrier sense is
> also similar age, from when Ethernet was CSMA/CD.
>
> Since they are not really used any more we don't have them in the LED
> framework, but i think we could implement them if somebody actually
> wanted them. My intention was to keep the LED framework KISS, since
> vendors tend to implement all sorts of odd LED blink reasons. But if
> nobody wants them, nobody has a good end user use case for them, why
> support them?
I see. So in fact most functions I wanted to enable muxing are LED functions,
leaving only some specifically for pinmux.

I believe pinmux is more correct, but there is overlap with led function.

I will  try to find some time for
1. describing both signals as LEDs, taking care of active-low
2. look into using pinmux (lower priority).
I think this would be more interesting to bigger phys with more muxable signals,
adin1300 is rather small.

Thank you for all the comments!
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/net/adi,adin.yaml b/Documentation/devicetree/bindings/net/adi,adin.yaml
index 929cf8c0b0fd..cf195e070b26 100644
--- a/Documentation/devicetree/bindings/net/adi,adin.yaml
+++ b/Documentation/devicetree/bindings/net/adi,adin.yaml
@@ -52,6 +52,15 @@  properties:
     description: Enable 25MHz reference clock output on CLK25_REF pin.
     type: boolean
 
+  adi,link-st-polarity:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      LINK_ST pin polarity.
+    enum:
+      - 0 # active high
+      - 1 # active low
+    default: 0
+
 unevaluatedProperties: false
 
 examples: