All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RESEND PATCH 3/5] clk: add function to get peripheral ID
Date: Mon, 28 Dec 2015 07:20:49 -0700	[thread overview]
Message-ID: <CAPnjgZ26G6bKCk2GhHuMx8R9XT50LaQHKQ54kWfStEyQvXY8Ew@mail.gmail.com> (raw)
In-Reply-To: <1450778671-21134-4-git-send-email-yamada.masahiro@socionext.com>

Hi Masahiro,

On 22 December 2015 at 03:04, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Currently, this framework does not provide the systematic way
> to get the peripheral ID (clock index).
>
> I assume that the functions added by this commit are mainly used to
> get the ID from "clocks" properties in device trees although they are
> not limited to that use.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  drivers/clk/clk-uclass.c | 10 ++++++++++
>  include/clk.h            | 34 ++++++++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+)
>
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> index 73dfd7d..8078b0f 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c
> @@ -52,6 +52,16 @@ ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate)
>         return ops->set_periph_rate(dev, periph, rate);
>  }
>
> +int clk_get_id(struct udevice *dev, int args_count, uint32_t *args)
> +{
> +       struct clk_ops *ops = clk_get_ops(dev);
> +
> +       if (!ops->get_id)
> +               return -ENOSYS;
> +
> +       return ops->get_id(dev, args_count, args);
> +}
> +
>  UCLASS_DRIVER(clk) = {
>         .id             = UCLASS_CLK,
>         .name           = "clk",
> diff --git a/include/clk.h b/include/clk.h
> index 371784a..1efbaf2 100644
> --- a/include/clk.h
> +++ b/include/clk.h
> @@ -49,6 +49,16 @@ struct clk_ops {
>          * @return new clock rate in Hz, or -ve error code
>          */
>         ulong (*set_periph_rate)(struct udevice *dev, int periph, ulong rate);
> +
> +       /**
> +        * get_id() - Get peripheral ID
> +        *
> +        * @dev:        clock provider
> +        * @args_count: number of arguments
> +        * @args:       arguments.  The meaning is driver specific.
> +        * @return peripheral ID, or -ve error code
> +        */
> +       int (*get_id)(struct udevice *dev, int args_count, uint32_t *args);

What are the arguments for? Who will use them? I wonder if the simple
case you have is the only useful case for now?

I think it would be better for the device tree parsing to happen
within the uclass rather than requiring the caller to understand how
it works. Here, we must obtain the arguments after the phandle and
pass them to this function.

>  };
>
>  #define clk_get_ops(dev)       ((struct clk_ops *)(dev)->driver->ops)
> @@ -87,4 +97,28 @@ ulong clk_get_periph_rate(struct udevice *dev, int periph);
>   */
>  ulong clk_set_periph_rate(struct udevice *dev, int periph, ulong rate);
>
> +/**
> + * clk_get_id() - Get peripheral ID
> + *
> + * @dev:       clock provider
> + * @args_count:        number of arguments
> + * @args:      arguments.  The meaning is driver specific.
> + * @return peripheral ID, or -ve error code
> + */
> +int clk_get_id(struct udevice *dev, int args_count, uint32_t *args);
> +
> +/**
> + * clk_get_id_simple() - Simple implementation of get_id() callback
> + *
> + * @dev:       clock provider
> + * @args_count:        number of arguments
> + * @args:      arguments.
> + * @return peripheral ID, or -ve error code
> + */
> +static inline int clk_get_id_simple(struct udevice *dev, int args_count,
> +                                   uint32_t *args)
> +{
> +       return args_count > 0 ? args[0] : 0;
> +}
> +
>  #endif /* _CLK_H_ */
> --
> 1.9.1
>

Regards,
Simon

  reply	other threads:[~2015-12-28 14:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 10:04 [U-Boot] [RESEND PATCH 0/5] clk: some fixes, device tree support, new features Masahiro Yamada
2015-12-22 10:04 ` [U-Boot] [RESEND PATCH 1/5] clk: fix comments in include/clk.h Masahiro Yamada
2015-12-28  4:19   ` Simon Glass
2015-12-22 10:04 ` [U-Boot] [RESEND PATCH 2/5] clk: add needed include and declaration to include/clk.h Masahiro Yamada
2015-12-28  4:19   ` Simon Glass
2015-12-22 10:04 ` [U-Boot] [RESEND PATCH 3/5] clk: add function to get peripheral ID Masahiro Yamada
2015-12-28 14:20   ` Simon Glass [this message]
2015-12-28 17:05     ` Masahiro Yamada
2015-12-22 10:04 ` [U-Boot] [RESEND PATCH 4/5] clk: add device tree support for clock framework Masahiro Yamada
2015-12-28  4:23   ` Simon Glass
2015-12-28 14:20     ` Simon Glass
2015-12-28 17:06       ` Masahiro Yamada
2016-01-15 13:22         ` Simon Glass
2015-12-22 10:04 ` [U-Boot] [RESEND PATCH 5/5] clk: add enable() callback Masahiro Yamada
2015-12-28 14:20   ` Simon Glass
2015-12-28 17:06     ` Masahiro Yamada
2015-12-22 20:27 ` [U-Boot] [RESEND PATCH 0/5] clk: some fixes, device tree support, new features Simon Glass

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=CAPnjgZ26G6bKCk2GhHuMx8R9XT50LaQHKQ54kWfStEyQvXY8Ew@mail.gmail.com \
    --to=sjg@chromium.org \
    --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.