All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramon Fried <rfried.dev@gmail.com>
To: Adam Ford <aford173@gmail.com>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>,
	Joe Hershberger <joe.hershberger@ni.com>,
	 charles.stevens@logicpd.com, aford@beaconembedded.com
Subject: Re: [PATCH] net: ravb: Add additional refclk
Date: Wed, 26 May 2021 10:28:23 +0300	[thread overview]
Message-ID: <CAGi-RU+xyRHHqiHKKVsNhbXhKfbenObRWS1HJYtntndY_QHwaQ@mail.gmail.com> (raw)
In-Reply-To: <20210525175240.380140-1-aford173@gmail.com>

On Tue, May 25, 2021 at 8:52 PM Adam Ford <aford173@gmail.com> wrote:
>
> The ethernet requires an external reference clock, and the driver
> currently assumes the clock is always running.  For devices using
> a programmable clock, this may not be true.  Add an optional clock
> called 'refclk' to open and enable the refclk for hardware running
> with programmable clocks.
>
> Signed-off-by: Adam Ford <aford173@gmail.com>
> ---
> This was also done in the Linux kernel, see:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/net/ethernet/renesas/ravb_main.c?id=8ef7adc6beb2ef0bce83513dc9e4505e7b21e8c2
>
> diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
> index 6953b7286a..ced80485de 100644
> --- a/drivers/net/ravb.c
> +++ b/drivers/net/ravb.c
> @@ -130,6 +130,7 @@ struct ravb_priv {
>         struct mii_dev          *bus;
>         void __iomem            *iobase;
>         struct clk              clk;
> +       struct clk              *refclk;
>         struct gpio_desc        reset_gpio;
>  };
>
> @@ -489,6 +490,8 @@ static int ravb_probe(struct udevice *dev)
>         if (ret < 0)
>                 goto err_mdio_alloc;
>
> +       eth->refclk = devm_clk_get_optional(dev, "refclk");
> +
>         ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, &phandle_args);
>         if (!ret) {
>                 gpio_request_by_name_nodev(phandle_args.node, "reset-gpios", 0,
> @@ -522,6 +525,10 @@ static int ravb_probe(struct udevice *dev)
>         if (ret)
>                 goto err_mdio_register;
>
> +       ret = clk_enable(eth->refclk);
> +       if (ret)
> +               goto err_disable_clk;
> +
>         ret = ravb_reset(dev);
>         if (ret)
>                 goto err_mdio_reset;
> @@ -533,6 +540,8 @@ static int ravb_probe(struct udevice *dev)
>         return 0;
>
>  err_mdio_reset:
> +       clk_disable(eth->refclk);
> +err_disable_clk:
>         clk_disable(&eth->clk);
>  err_mdio_register:
>         mdio_free(mdiodev);
> @@ -545,6 +554,7 @@ static int ravb_remove(struct udevice *dev)
>  {
>         struct ravb_priv *eth = dev_get_priv(dev);
>
> +       clk_disable(eth->refclk);
>         clk_disable(&eth->clk);
>
>         free(eth->phydev);
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

      reply	other threads:[~2021-05-26  7:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25 17:52 [PATCH] net: ravb: Add additional refclk Adam Ford
2021-05-26  7:28 ` Ramon Fried [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGi-RU+xyRHHqiHKKVsNhbXhKfbenObRWS1HJYtntndY_QHwaQ@mail.gmail.com \
    --to=rfried.dev@gmail.com \
    --cc=aford173@gmail.com \
    --cc=aford@beaconembedded.com \
    --cc=charles.stevens@logicpd.com \
    --cc=joe.hershberger@ni.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.