Re: (EXT) Re: [PATCH net-next 2/2] net: phy: dp83867: apply ti, led-function and ti, led-ctrl to registers

2020-08-24 Thread Matthias Schiffer
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  > >
> 
> 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



Re: [PATCH net-next 2/2] net: phy: dp83867: apply ti,led-function and ti,led-ctrl to registers

2020-08-22 Thread Andrew Lunn
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 

Sorry, but NACK.

Please look at the work Marek BehĂșn is doing

https://lkml.org/lkml/2020/7/28/765

Andrew



[PATCH net-next 2/2] net: phy: dp83867: apply ti,led-function and ti,led-ctrl to registers

2020-08-21 Thread 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 
---
 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_ISR0x13
 #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",
+  >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", >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