diff mbox series

[V2,4/4] net: ethernet: ravb: Enable optional refclk

Message ID 20210115201953.443710-4-aford173@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [V2,1/4] dt-bindings: net: renesas,etheravb: Add additional clocks | expand

Checks

Context Check Description
netdev/cover_letter warning Series does not have a cover letter
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 5 maintainers not CCed: ashiduka@fujitsu.com s.shtylyov@omprussia.ru yoshihiro.shimoda.uh@renesas.com f.fainelli@gmail.com rikard.falkeborn@gmail.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 21 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Adam Ford Jan. 15, 2021, 8:19 p.m. UTC
For devices that use a programmable clock for the avb reference clock,
the driver may need to enable them.  Add code to find the optional clock
and enable it when available.

Signed-off-by: Adam Ford <aford173@gmail.com>
---
 drivers/net/ethernet/renesas/ravb.h      | 1 +
 drivers/net/ethernet/renesas/ravb_main.c | 8 ++++++++
 2 files changed, 9 insertions(+)

V2:  The previous patch to fetch the fclk was dropped.  In its place
     is code to enable the refclk

Comments

Sergey Shtylyov Jan. 16, 2021, 9:55 a.m. UTC | #1
Hello!

On 15.01.2021 23:19, Adam Ford wrote:

> For devices that use a programmable clock for the avb reference clock,

    AVB.

> the driver may need to enable them.  Add code to find the optional clock
> and enable it when available.
> 
> Signed-off-by: Adam Ford <aford173@gmail.com>
[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index bd30505fbc57..739e30f45daa 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -2148,6 +2148,14 @@ static int ravb_probe(struct platform_device *pdev)
>   		goto out_release;
>   	}
>   
> +	priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk");
> +	if (IS_ERR(priv->refclk)) {
> +		error = PTR_ERR(priv->refclk);
> +		goto out_release;
> +	} else {

    No need for *else* after *goto*.

> +		(void)clk_prepare_enable(priv->refclk);

    You can really omit (void)...
    Also, I'm not seeing where do you call clk_disable_unprepare()...

[...]

MBR, Sergei
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 7453b17a37a2..ff363797bd2b 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -994,6 +994,7 @@  struct ravb_private {
 	struct platform_device *pdev;
 	void __iomem *addr;
 	struct clk *clk;
+	struct clk *refclk;
 	struct mdiobb_ctrl mdiobb;
 	u32 num_rx_ring[NUM_RX_QUEUE];
 	u32 num_tx_ring[NUM_TX_QUEUE];
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index bd30505fbc57..739e30f45daa 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2148,6 +2148,14 @@  static int ravb_probe(struct platform_device *pdev)
 		goto out_release;
 	}
 
+	priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk");
+	if (IS_ERR(priv->refclk)) {
+		error = PTR_ERR(priv->refclk);
+		goto out_release;
+	} else {
+		(void)clk_prepare_enable(priv->refclk);
+	}
+
 	ndev->max_mtu = 2048 - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN);
 	ndev->min_mtu = ETH_MIN_MTU;