Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH net-next 1/2] dt-bindings: dp83867: add ti,led-function and ti,led-ctrl properties
@ 2020-08-21 7:21 Matthias Schiffer
2020-08-21 7:21 ` [PATCH net-next 2/2] net: phy: dp83867: apply ti,led-function and ti,led-ctrl to registers Matthias Schiffer
0 siblings, 1 reply; 4+ messages in thread
From: Matthias Schiffer @ 2020-08-21 7:21 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Rob Herring, Andrew Lunn,
Florian Fainelli, Heiner Kallweit, Russell King
Cc: Dan Murphy, netdev, devicetree, linux-kernel, Matthias Schiffer
With the TQ-Systems MBa7x (imx7-mba7.dtsi), a user of these properties
already sneaked in before they were properly specified. Add them to the
binding docs.
On top of the existing use (requiring to specify the raw register value
in the DTS), we propose a few convenience macros and defines.
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
.../devicetree/bindings/net/ti,dp83867.yaml | 18 ++++++
include/dt-bindings/net/ti-dp83867.h | 60 +++++++++++++++++++
2 files changed, 78 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/ti,dp83867.yaml b/Documentation/devicetree/bindings/net/ti,dp83867.yaml
index c6716ac6cbcc..f91d40edab39 100644
--- a/Documentation/devicetree/bindings/net/ti,dp83867.yaml
+++ b/Documentation/devicetree/bindings/net/ti,dp83867.yaml
@@ -106,6 +106,18 @@ properties:
Transmitt FIFO depth- see dt-bindings/net/ti-dp83867.h for applicable
values.
+ ti,led-function:
+ $ref: /schemas/types.yaml#definitions/uint32
+ description: |
+ Value of LED configuration register 1, controlling the triggers for the
+ PHY LED outputs. See dt-bindings/net/ti-dp83867.h.
+
+ ti,led-ctrl:
+ $ref: /schemas/types.yaml#definitions/uint32
+ description: |
+ Value of LED configuration register 2, controlling polarity and related
+ settings for the PHY LED outputs. See dt-bindings/net/ti-dp83867.h.
+
required:
- reg
@@ -123,5 +135,11 @@ examples:
ti,clk-output-sel = <DP83867_CLK_O_SEL_CHN_A_RCLK>;
ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_25_NS>;
ti,tx-internal-delay = <DP83867_RGMIIDCTL_2_75_NS>;
+ ti,led-function = <(DP83867_LED0(FUNC_LINK_ACT) |
+ DP83867_LED1(FUNC_LINK_1000))>;
+ ti,led-ctrl = <(DP83867_LED0(CTRL_ACTIVE_HIGH) |
+ DP83867_LED1(CTRL_ACTIVE_HIGH) |
+ DP83867_LED2(CTRL_FORCE_LOW) |
+ DP83867_LED3(CTRL_FORCE_LOW))>;
};
};
diff --git a/include/dt-bindings/net/ti-dp83867.h b/include/dt-bindings/net/ti-dp83867.h
index 6fc4b445d3a1..f3e3866d26ee 100644
--- a/include/dt-bindings/net/ti-dp83867.h
+++ b/include/dt-bindings/net/ti-dp83867.h
@@ -50,4 +50,64 @@
#define DP83867_CLK_O_SEL_REF_CLK 0xC
/* Special flag to indicate clock should be off */
#define DP83867_CLK_O_SEL_OFF 0xFFFFFFFF
+
+/*
+ * Register values and helper macros for ti,led-function and ti,led-ctrl
+ *
+ * Example:
+ *
+ * ti,led-function = <(DP83867_LED0(FUNC_LINK_ACT) |
+ * DP83867_LED1(FUNC_LINK_1000))>;
+ * ti,led-ctrl = <(DP83867_LED0(CTRL_ACTIVE_HIGH) |
+ * DP83867_LED1(CTRL_ACTIVE_HIGH) |
+ * DP83867_LED2(CTRL_FORCE_LOW) |
+ * DP83867_LED3(CTRL_FORCE_LOW))>;
+ *
+ * It is recommended to force all unused LED pins to high or low level via
+ * led-ctrl (led-function is ignored in this case). LEDs that are missing from
+ * the configured value will be set to value 0x0 (FUNC_LINK and
+ * CTRL_ACTIVE_LOW).
+ */
+
+/* Link established */
+#define DP83867_LED_FUNC_LINK 0x0
+/* Receive or transmit activity */
+#define DP83867_LED_FUNC_ACT 0x1
+/* Transmit activity */
+#define DP83867_LED_FUNC_ACT_TX 0x2
+/* Receive activity */
+#define DP83867_LED_FUNC_ACT_RX 0x3
+/* Collision detected */
+#define DP83867_LED_FUNC_COLLISION 0x4
+/* 1000BT link established */
+#define DP83867_LED_FUNC_LINK_1000 0x5
+/* 100BTX link established */
+#define DP83867_LED_FUNC_LINK_100 0x6
+/* 10BT link established */
+#define DP83867_LED_FUNC_LINK_10 0x7
+/* 10/100BT link established */
+#define DP83867_LED_FUNC_LINK_10_100 0x8
+/* 100/1000BT link established */
+#define DP83867_LED_FUNC_LINK_100_1000 0x9
+/* Full duplex */
+#define DP83867_LED_FUNC_FULL_DUPLEX 0xa
+/* Link established, blink for transmit or receive activity */
+#define DP83867_LED_FUNC_LINK_ACT 0xb
+/* Receive Error or Transmit Error */
+#define DP83867_LED_FUNC_ERR 0xd
+/* Receive Error */
+#define DP83867_LED_FUNC_ERR_RX 0xe
+
+#define DP83867_LED_CTRL_ACTIVE_HIGH 0x4
+#define DP83867_LED_CTRL_ACTIVE_LOW 0x0
+#define DP83867_LED_CTRL_FORCE_HIGH 0x3
+#define DP83867_LED_CTRL_FORCE_LOW 0x1
+
+#define DP83867_LED_SHIFT(v, s) ((DP83867_LED_##v) << (s))
+
+#define DP83867_LED0(v) DP83867_LED_SHIFT(v, 0)
+#define DP83867_LED1(v) DP83867_LED_SHIFT(v, 4)
+#define DP83867_LED2(v) DP83867_LED_SHIFT(v, 8)
+#define DP83867_LED3(v) DP83867_LED_SHIFT(v, 12)
+
#endif
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next 2/2] net: phy: dp83867: apply ti,led-function and ti,led-ctrl to registers
2020-08-21 7:21 [PATCH net-next 1/2] dt-bindings: dp83867: add ti,led-function and ti,led-ctrl properties Matthias Schiffer
@ 2020-08-21 7:21 ` Matthias Schiffer
2020-08-22 16:08 ` Andrew Lunn
0 siblings, 1 reply; 4+ messages in thread
From: Matthias Schiffer @ 2020-08-21 7:21 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Rob Herring, Andrew Lunn,
Florian Fainelli, Heiner Kallweit, Russell King
Cc: Dan Murphy, netdev, devicetree, linux-kernel, Matthias Schiffer
These DT bindings are already in use by the imx7-mba7 DTS, but they were
not supported by the PHY driver so far.
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
drivers/net/phy/dp83867.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index f3c04981b8da..972824e25c1c 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -26,6 +26,8 @@
#define MII_DP83867_MICR 0x12
#define MII_DP83867_ISR 0x13
#define DP83867_CFG2 0x14
+#define DP83867_LEDCR1 0x18
+#define DP83867_LEDCR2 0x19
#define DP83867_CFG3 0x1e
#define DP83867_CTRL 0x1f
@@ -163,6 +165,8 @@ struct dp83867_private {
u32 rx_fifo_depth;
int io_impedance;
int port_mirroring;
+ u32 led_function;
+ u32 led_ctrl;
bool rxctrl_strap_quirk;
bool set_clk_output;
u32 clk_output_sel;
@@ -583,6 +587,27 @@ static int dp83867_of_init(struct phy_device *phydev)
return -EINVAL;
}
+ ret = of_property_read_u32(of_node, "ti,led-function",
+ &dp83867->led_function);
+ if (ret) {
+ dp83867->led_function = U32_MAX;
+ } else if (dp83867->led_function > U16_MAX) {
+ phydev_err(phydev,
+ "ti,led-function value %x out of range\n",
+ dp83867->led_function);
+ return -EINVAL;
+ }
+
+ ret = of_property_read_u32(of_node, "ti,led-ctrl", &dp83867->led_ctrl);
+ if (ret) {
+ dp83867->led_ctrl = U32_MAX;
+ } else if (dp83867->led_ctrl > U16_MAX) {
+ phydev_err(phydev,
+ "ti,led-ctrl value %x out of range\n",
+ dp83867->led_ctrl);
+ return -EINVAL;
+ }
+
return 0;
}
#else
@@ -788,6 +813,11 @@ static int dp83867_config_init(struct phy_device *phydev)
mask, val);
}
+ if (dp83867->led_function != U32_MAX)
+ phy_write(phydev, DP83867_LEDCR1, dp83867->led_function);
+ if (dp83867->led_ctrl != U32_MAX)
+ phy_write(phydev, DP83867_LEDCR2, dp83867->led_ctrl);
+
return 0;
}
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 2/2] net: phy: dp83867: apply ti,led-function and ti,led-ctrl to registers
2020-08-21 7:21 ` [PATCH net-next 2/2] net: phy: dp83867: apply ti,led-function and ti,led-ctrl to registers Matthias Schiffer
@ 2020-08-22 16:08 ` Andrew Lunn
2020-08-24 8:09 ` (EXT) Re: [PATCH net-next 2/2] net: phy: dp83867: apply ti, led-function and ti, led-ctrl " Matthias Schiffer
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2020-08-22 16:08 UTC (permalink / raw)
To: Matthias Schiffer
Cc: David S. Miller, Jakub Kicinski, Rob Herring, Florian Fainelli,
Heiner Kallweit, Russell King, Dan Murphy, netdev, devicetree,
linux-kernel
On Fri, Aug 21, 2020 at 09:21:46AM +0200, Matthias Schiffer wrote:
> These DT bindings are already in use by the imx7-mba7 DTS, but they were
> not supported by the PHY driver so far.
>
> Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Sorry, but NACK.
Please look at the work Marek Behún is doing
https://lkml.org/lkml/2020/7/28/765
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: (EXT) Re: [PATCH net-next 2/2] net: phy: dp83867: apply ti, led-function and ti, led-ctrl to registers
2020-08-22 16:08 ` Andrew Lunn
@ 2020-08-24 8:09 ` Matthias Schiffer
0 siblings, 0 replies; 4+ messages in thread
From: Matthias Schiffer @ 2020-08-24 8:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: David S. Miller, Jakub Kicinski, Rob Herring, Florian Fainelli,
Heiner Kallweit, Russell King, Dan Murphy, netdev, devicetree,
linux-kernel
On Sat, 2020-08-22 at 18:08 +0200, Andrew Lunn wrote:
> On Fri, Aug 21, 2020 at 09:21:46AM +0200, Matthias Schiffer wrote:
> > These DT bindings are already in use by the imx7-mba7 DTS, but they
> > were
> > not supported by the PHY driver so far.
> >
> > Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com
> > >
>
> Sorry, but NACK.
>
> Please look at the work Marek Behún is doing
>
> https://lkml.org/lkml/2020/7/28/765
>
> Andrew
>
Thanks, this is looking quite nice. I hope Marek's patches are
finalized soon.
Matthias
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-24 8:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 7:21 [PATCH net-next 1/2] dt-bindings: dp83867: add ti,led-function and ti,led-ctrl properties Matthias Schiffer
2020-08-21 7:21 ` [PATCH net-next 2/2] net: phy: dp83867: apply ti,led-function and ti,led-ctrl to registers Matthias Schiffer
2020-08-22 16:08 ` Andrew Lunn
2020-08-24 8:09 ` (EXT) Re: [PATCH net-next 2/2] net: phy: dp83867: apply ti, led-function and ti, led-ctrl " Matthias Schiffer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).