public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Heiko Stübner" <heiko@sntech.de>
To: Mike Turquette <mturquette@linaro.org>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	devicetree-discuss@lists.ozlabs.org,
	Matt Sealey <neko@bakuhatsu.net>,
	Stephen Boyd <sboyd@codeaurora.org>
Subject: Re: [PATCH v2 3/5] clk: dt: binding for basic multiplexer clock
Date: Tue, 18 Jun 2013 02:53:59 +0200	[thread overview]
Message-ID: <201306180253.59691.heiko@sntech.de> (raw)
In-Reply-To: <1371437905-15567-4-git-send-email-mturquette@linaro.org>

Am Montag, 17. Juni 2013, 04:58:23 schrieb Mike Turquette:
> Device Tree binding for the basic clock multiplexer, plus the setup
> function to register the clock.  Based on the existing fixed-clock
> binding.
> 
> Includes minor beautification of clk-provider.h where some whitespace is
> added and of_fixed_factor_clock_setup is relocated to maintain a
> consistent style.
> 
> Signed-off-by: Mike Turquette <mturquette@linaro.org>
> ---

> +void of_mux_clk_setup(struct device_node *node)
> +{
> +	struct clk *clk;
> +	const char *clk_name = node->name;
> +	void __iomem *reg;
> +	int num_parents;
> +	const char **parent_names;
> +	int i;
> +	u8 clk_mux_flags = 0;
> +	u32 mask = 0;
> +	u8 shift = 0;
> +
> +	of_property_read_string(node, "clock-output-names", &clk_name);
> +
> +	num_parents = of_clk_get_parent_count(node);
> +	if (num_parents < 1) {
> +		pr_err("%s: mux-clock %s must have parent(s)\n",
> +				__func__, node->name);
> +		return;
> +	}
> +
> +	parent_names = kzalloc((sizeof(char*) * num_parents),
> +			GFP_KERNEL);
> +
> +	for (i = 0; i < num_parents; i++)
> +		parent_names[i] = of_clk_get_parent_name(node, i);
> +
> +	reg = of_iomap(node, 0);
> +
> +	if (of_property_read_u32(node, "bit-mask", &mask)) {
> +		pr_err("%s: missing bit-mask property for %s\n", __func__, node-
>name);
> +		return;
> +	}
> +
> +	if (of_property_read_u8(node, "bit-shift", &shift)) {
> +		shift = __ffs(mask);
> +		pr_debug("%s: bit-shift property defaults to 0x%x for %s\n",
> +				__func__, shift, node->name);
> +	}

I'm not really sure if either I am or the code is doing something wrong.
For me here of_property_read_u8 is always setting shift to 0, with bit-shift 
values normally being <8>, <15> etc.

When I change the type of shift to u32 and use the corresponding 
of_property_read_u32 everything works fine.

And when I switch both function and var back to u8 again, it again reads 0 for 
everything.


For reference one of my muxes looks like:

		mux_uart2: mux-uart2@20000080 {
			compatible = "mux-clock";
			reg = <0x20000080 0x04>;
			clocks = <&clk_gates1 12>, <&dummy>, <&xin24m>;
			bit-mask = <0x3>;
			bit-shift = <8>;
			hiword-mask;
			#clock-cells = <0>;
		};

Same is of course also true for the divider-clock.


Very confused,
Heiko


> +
> +	if (of_property_read_bool(node, "index-starts-at-one"))
> +		clk_mux_flags |= CLK_MUX_INDEX_ONE;
> +
> +	clk = clk_register_mux_table(NULL, clk_name, parent_names, num_parents,
> +			0, reg, shift, mask, clk_mux_flags,
> +			NULL, NULL);
> +
> +	if (!IS_ERR(clk))
> +		of_clk_add_provider(node, of_clk_src_simple_get, clk);
> +}
> +EXPORT_SYMBOL_GPL(of_mux_clk_setup);
> +CLK_OF_DECLARE(mux_clk, "mux-clock", of_mux_clk_setup);
> +#endif
> diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
> index 8730cb9..24a04b8 100644
> --- a/include/linux/clk-provider.h
> +++ b/include/linux/clk-provider.h
> @@ -340,7 +340,7 @@ struct clk *clk_register_mux_table(struct device *dev,
> const char *name, void __iomem *reg, u8 shift, u32 mask,
>  		u8 clk_mux_flags, u32 *table, spinlock_t *lock);
> 
> -void of_fixed_factor_clk_setup(struct device_node *node);
> +void of_mux_clk_setup(struct device_node *node);
> 
>  /**
>   * struct clk_fixed_factor - fixed multiplier and divider clock
> @@ -361,10 +361,13 @@ struct clk_fixed_factor {
>  };
> 
>  extern struct clk_ops clk_fixed_factor_ops;
> +
>  struct clk *clk_register_fixed_factor(struct device *dev, const char
> *name, const char *parent_name, unsigned long flags,
>  		unsigned int mult, unsigned int div);
> 
> +void of_fixed_factor_clk_setup(struct device_node *node);
> +
>  /***
>   * struct clk_composite - aggregate clock of mux, divider and gate clocks
>   *


  reply	other threads:[~2013-06-18  0:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-17  2:58 [PATCH v2 0/5] clk: dt: bindings for mux, divider & gate clocks Mike Turquette
2013-06-17  2:58 ` [PATCH v2 1/5] clk: divider: replace bitfield width with mask Mike Turquette
2013-06-17 15:22   ` Shawn Guo
2013-06-17  2:58 ` [PATCH v2 2/5] clk: of: helper for determining number of parent clocks Mike Turquette
2013-06-17  2:58 ` [PATCH v2 3/5] clk: dt: binding for basic multiplexer clock Mike Turquette
2013-06-18  0:53   ` Heiko Stübner [this message]
2013-06-20 21:25     ` Heiko Stübner
2013-06-17  2:58 ` [PATCH v2 4/5] clk: dt: binding for basic divider clock Mike Turquette
2013-06-20 21:22   ` Heiko Stübner
2013-06-17  2:58 ` [PATCH v2 5/5] clk: dt: binding for basic gate clock Mike Turquette
2014-08-15 14:55 ` [PATCH v2 0/5] clk: dt: bindings for mux, divider & gate clocks Florian Fainelli
2014-09-18 18:57   ` Mike Turquette

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=201306180253.59691.heiko@sntech.de \
    --to=heiko@sntech.de \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=neko@bakuhatsu.net \
    --cc=sboyd@codeaurora.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox