ravb: Add support for optional txc_refclk
Subsystems (3)
RFC 1/1 ravb: Add support for optional txc_refclk
The SoC expects the txv_refclk is provided, but if it is provided by a programmable clock, there needs to be a way to get and enable this clock to operate. It needs to be optional since it's only necessary for those with programmable clocks.
drivers/net/ethernet/renesas/ravb.h +1 -0
@@ -994,6 +994,7 @@ struct ravb_private {struct platform_device *pdev;void __iomem *addr;struct clk *clk; +struct clk *ref_clk;struct mdiobb_ctrl mdiobb;u32 num_rx_ring[NUM_RX_QUEUE ];u32 num_tx_ring[NUM_TX_QUEUE ];
drivers/net/ethernet/renesas/ravb_main.c +12 -0
@@ -2148,6 +2148,18 @@ static int ravb_probe(struct platform_device *pdev) goto out_release; } + priv->ref_clk =devm_clk_get (&pdev->dev,"txc_refclk" ); +if (IS_ERR (priv->ref_clk)) { +if (PTR_ERR (priv->ref_clk) == -EPROBE_DEFER ) { +/* for Probe defer return error */ + error =PTR_ERR (priv->ref_clk); + goto out_release; + } +/* Ignore other errors since it's optional */ + }else { + (void )clk_prepare_enable (priv->ref_clk); + } + ndev->max_mtu =2048 - (ETH_HLEN +VLAN_HLEN +ETH_FCS_LEN ); ndev->min_mtu =ETH_MIN_MTU ;
Signature · 1 line
2.25.1
Hello!
Quoted 6 lines · Adam Ford
The SoC expects the
txv_refclkis provided, but if it is provided by a programmable clock, there needs to be a way to get and enable this clock to operate. It needs to be optional since it's only necessary for those with programmable clocks.Signed-off-by Adam Ford <[email protected]>
[...]
drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2151
Quoted 9 lines
drivers/net/ethernet/renesas/ravb_main.c +1
-0@@ -2148,6 +2148,18 @@ static int ravb_probe(struct platform_device *pdev) goto out_release; } + priv->ref_clk =devm_clk_get (&pdev->dev,"txc_refclk" );
Why not devm_clk_get_optional()?
Quoted 4 lines
drivers/net/ethernet/renesas/ravb_main.c +4
-0+if (IS_ERR (priv->ref_clk)) { +if (PTR_ERR (priv->ref_clk) == -EPROBE_DEFER ) { +/* for Probe defer return error */ + error =PTR_ERR (priv->ref_clk);
drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2165
Quoted 10 lines
drivers/net/ethernet/renesas/ravb_main.c +7
-0+ goto out_release; + } +/* Ignore other errors since it's optional */ + }else { + (void )clk_prepare_enable (priv->ref_clk); + } + ndev->max_mtu =2048 - (ETH_HLEN +VLAN_HLEN +ETH_FCS_LEN ); ndev->min_mtu =ETH_MIN_MTU ;
MBR, Sergei
Quoted 20 lines · Sergei Shtylyov
Hello!
Quoted 6 lines · Adam Ford
The SoC expects the
txv_refclkis provided, but if it is provided by a programmable clock, there needs to be a way to get and enable this clock to operate. It needs to be optional since it's only necessary for those with programmable clocks.Signed-off-by Adam Ford <[email protected]>[...]
Quoted 8 lines
drivers/net/ethernet/renesas/ravb_main.c +0
-0@@ -2148,6 +2148,18 @@ static int ravb_probe(struct platform_device *pdev) goto out_release; }
Quoted 3 lines
drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2151
Quoted 1 line
drivers/net/ethernet/renesas/ravb_main.c +1
-0+ priv->ref_clk =devm_clk_get (&pdev->dev,"txc_refclk" );Why not
devm_clk_get_optional()?
I am not that familiar with the clock API. I'll look into that function. It looks like it makes more sense. I'll send a V2.
adam
Quoted 17 lines
Quoted 5 lines
drivers/net/ethernet/renesas/ravb_main.c +4
-0+if (IS_ERR (priv->ref_clk)) { +if (PTR_ERR (priv->ref_clk) == -EPROBE_DEFER ) { +/* for Probe defer return error */ + error =PTR_ERR (priv->ref_clk);drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2165
Quoted 10 lines
drivers/net/ethernet/renesas/ravb_main.c +7
-0+ goto out_release; + } +/* Ignore other errors since it's optional */ + }else { + (void )clk_prepare_enable (priv->ref_clk); + } + ndev->max_mtu =2048 - (ETH_HLEN +VLAN_HLEN +ETH_FCS_LEN ); ndev->min_mtu =ETH_MIN_MTU ;MBR, Sergei
Hi Adam,
Quoted 6 lines · Adam Ford
The SoC expects the
txv_refclkis provided, but if it is provided by a programmable clock, there needs to be a way to get and enable this clock to operate. It needs to be optional since it's only necessary for those with programmable clocks.Signed-off-by Adam Ford <[email protected]>
Thanks for your patch!
Quoted 15 lines
drivers/net/ethernet/renesas/ravb.h +1
-0@@ -994,6 +994,7 @@ struct ravb_private {struct platform_device *pdev;void __iomem *addr;struct clk *clk; +struct clk *ref_clk;struct mdiobb_ctrl mdiobb;u32 num_rx_ring[NUM_RX_QUEUE ];u32 num_tx_ring[NUM_TX_QUEUE ];drivers/net/ethernet/renesas/ravb_main.c +0
-0
drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2151
Quoted 4 lines
drivers/net/ethernet/renesas/ravb_main.c +1
-0@@ -2148,6 +2148,18 @@ static int ravb_probe(struct platform_device *pdev) goto out_release; } + priv->ref_clk =devm_clk_get (&pdev->dev,"txc_refclk" );
Please also update the DT bindings[1], to document the optional presence of the clock.
drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2160
Quoted 9 lines
drivers/net/ethernet/renesas/ravb_main.c +9
-0+if (IS_ERR (priv->ref_clk)) { +if (PTR_ERR (priv->ref_clk) == -EPROBE_DEFER ) { +/* for Probe defer return error */ + error =PTR_ERR (priv->ref_clk); + goto out_release; + } +/* Ignore other errors since it's optional */ + }else { + (void )clk_prepare_enable (priv->ref_clk);
This can fail.
Does this clock need to be enabled all the time?
At least it should be disabled in the probe failure path, and in ravb_remove().
[1] Documentation/devicetree/bindings/net/renesas,etheravb.yaml
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 31 lines · Geert Uytterhoeven
Hi Adam,
Quoted 6 lines · Adam Ford
The SoC expects the
txv_refclkis provided, but if it is provided by a programmable clock, there needs to be a way to get and enable this clock to operate. It needs to be optional since it's only necessary for those with programmable clocks.Signed-off-by Adam Ford <[email protected]>Thanks for your patch!
Quoted 18 lines
drivers/net/ethernet/renesas/ravb.h +1
-0@@ -994,6 +994,7 @@ struct ravb_private {struct platform_device *pdev;void __iomem *addr;struct clk *clk; +struct clk *ref_clk;struct mdiobb_ctrl mdiobb;u32 num_rx_ring[NUM_RX_QUEUE ];u32 num_tx_ring[NUM_TX_QUEUE ];drivers/net/ethernet/renesas/ravb_main.c +0
-0@@ -2148,6 +2148,18 @@ static int ravb_probe(struct platform_device *pdev) goto out_release; }
Quoted 4 lines
drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2151
Quoted 1 line
drivers/net/ethernet/renesas/ravb_main.c +1
-0+ priv->ref_clk =devm_clk_get (&pdev->dev,"txc_refclk" );Please also update the DT bindings[1], to document the optional presence of the clock.
I am not all that familiar with the YAML syntax, but right now, the clock-names property isn't in the binding, and the driver doesn't use a name when requesting the single clock it's expecting. Since the txc_refclk is optional, can the clock-names property allow for 0-2 names while the number of clocks be 1-2?
clocks:
minItems: 1
maxItems: 2
clock-names:
minItems: 0
maxItems: 2
items:
enum:
- fck # AVB functional clock (optional if it is the only clock)
- txc_refclk # TXC reference clock
With the above proposal, the clock-names would only be necessary when using the txc_refclk.
Quoted 11 lines
drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2160
Quoted 10 lines
drivers/net/ethernet/renesas/ravb_main.c +9
-0+if (IS_ERR (priv->ref_clk)) { +if (PTR_ERR (priv->ref_clk) == -EPROBE_DEFER ) { +/* for Probe defer return error */ + error =PTR_ERR (priv->ref_clk); + goto out_release; + } +/* Ignore other errors since it's optional */ + }else { + (void )clk_prepare_enable (priv->ref_clk);
Quoted 4 lines
This can fail.
Does this clock need to be enabled all the time?
At least it should be disabled in the probe failure path, and inravb_remove().
I'll do that for the next rev.
thanks,
adam
Quoted 13 lines
[1]
Documentation/devicetree/bindings/net/renesas,etheravb.yamlGr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Adam,
CC devicetree
Quoted 44 lines · Adam Ford
Quoted 28 lines · Geert Uytterhoeven
Quoted 6 lines · Adam Ford
The SoC expects the
txv_refclkis provided, but if it is provided by a programmable clock, there needs to be a way to get and enable this clock to operate. It needs to be optional since it's only necessary for those with programmable clocks.Signed-off-by Adam Ford <[email protected]>Thanks for your patch!
Quoted 18 lines
drivers/net/ethernet/renesas/ravb.h +1
-0@@ -994,6 +994,7 @@ struct ravb_private {struct platform_device *pdev;void __iomem *addr;struct clk *clk; +struct clk *ref_clk;struct mdiobb_ctrl mdiobb;u32 num_rx_ring[NUM_RX_QUEUE ];u32 num_tx_ring[NUM_TX_QUEUE ];drivers/net/ethernet/renesas/ravb_main.c +0
-0@@ -2148,6 +2148,18 @@ static int ravb_probe(struct platform_device *pdev) goto out_release; }Quoted 4 lines
drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2151
Quoted 1 line
drivers/net/ethernet/renesas/ravb_main.c +1
-0+ priv->ref_clk =devm_clk_get (&pdev->dev,"txc_refclk" );Please also update the DT bindings[1], to document the optional presence of the clock.
I am not all that familiar with the YAML syntax, but right now, the clock-names property isn't in the binding, and the driver doesn't use a name when requesting the single clock it's expecting. Since the
txc_refclkis optional, can the clock-names property allow for 0-2 names while the number of clocks be 1-2?clocks:
minItems: 1
maxItems: 2
Quoted 7 lines
clock-names:
minItems: 0
maxItems: 2
items:
enum:
- fck # AVB functional clock (optional if it is the only clock)
-txc_refclk# TXC reference clock
With "enum", it accepts any order. But for compatibility, we want to force "fck" first.
Something like:
clocks:
minItems: 1
items:
- description: AVB functional clock
- description: Optional TXC reference clock
clock-names:
items:
- const: fck
- const: txc_refclk
Quoted 2 lines
With the above proposal, the clock-names would only be necessary when using the
txc_refclk.
I think that's difficult to express: either make clock-names optional (i.e. don't list it under "required"), or make it required in all cases (which need fixups for the existing users, and "minItems: 1" for "clock-names", too).
Quoted 15 lines
Quoted 10 lines
drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2160
Quoted 9 lines
drivers/net/ethernet/renesas/ravb_main.c +9
-0+if (IS_ERR (priv->ref_clk)) { +if (PTR_ERR (priv->ref_clk) == -EPROBE_DEFER ) { +/* for Probe defer return error */ + error =PTR_ERR (priv->ref_clk); + goto out_release; + } +/* Ignore other errors since it's optional */ + }else { + (void )clk_prepare_enable (priv->ref_clk);Quoted 4 lines
This can fail.
Does this clock need to be enabled all the time?
At least it should be disabled in the probe failure path, and inravb_remove().
Quoted 7 lines
I'll do that for the next rev.
thanks,
adam
Quoted 2 lines
[1]
Documentation/devicetree/bindings/net/renesas,etheravb.yaml
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds