All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxime Coquelin <mcoquelin.stm32@gmail.com>
To: Daniel Thompson <daniel.thompson@linaro.org>,
	Mike Turquette <mturquette@linaro.org>,
	Stephen Boyd <sboyd@codeaurora.org>
Cc: Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Russell King <linux@arm.linux.org.uk>, Kamil Lulko <rev13@wp.pl>,
	Andreas Farber <afaerber@suse.de>,
	linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, patches@linaro.org,
	linaro-kernel@lists.linaro.org
Subject: Re: [PATCH v2 3/4] clk: stm32: Add clock driver for STM32F4[23]xxx devices
Date: Sat, 30 May 2015 11:15:58 +0200	[thread overview]
Message-ID: <55697FCE.9040003@gmail.com> (raw)
In-Reply-To: <1432972448-10332-4-git-send-email-daniel.thompson@linaro.org>

Hi Daniel,

     Nice driver, please find my comments below.

     Once fixed, you can add:
Reviewed-by: Maxime Coquelin <mcoquelin.stm32@gmail.com>


On 05/30/2015 09:54 AM, Daniel Thompson wrote:
> The driver supports decoding and statically modelling PLL state (i.e.
> we inherit state from bootloader) and provides support for all
> peripherals that support simple one-bit gated clocks. The covers all
> peripherals whose clocks come from the AHB, APB1 or APB2 buses.
>
> It has been tested (for non-regression only) on an STM32F429I-Discovery
> boards. The clock counts for TIM2, USART1 and SYSTICK are all set correctly
> and time and the wall clock looks OK when checked with a stopwatch.
>
> Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
> ---
>   drivers/clk/Makefile      |   1 +
>   drivers/clk/clk-stm32f4.c | 364 ++++++++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 365 insertions(+)
>   create mode 100644 drivers/clk/clk-stm32f4.c
...
> diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c
> new file mode 100644
> index 0000000..68f9962
> --- /dev/null
> +++ b/drivers/clk/clk-stm32f4.c
> @@ -0,0 +1,364 @@
...
> +/*
> + * Converts the primary and secondary indices (as they appear in DT) to an
> + * offset into our struct clock array.
> + */
> +static unsigned int stm32f4_rcc_lookup_clk_idx(u8 primary, u8 secondary)
> +{
> +	u64 table[ARRAY_SIZE(stm32f42xx_gate_map)];
> +
> +	if (primary == 1) {
> +		BUG_ON(secondary > FCLK);
Maybe the function could return a signed int, an propagate errors 
instead of using BUG_ON?
> +		return secondary;
> +	}
> +
> +	memcpy(table, stm32f42xx_gate_map, sizeof(table));
> +
> +	/* only bits set in table can be used as indices */
> +	BUG_ON(secondary > 8 * sizeof(table) ||
> +	       0 == (table[BIT_ULL_WORD(secondary)] & BIT_ULL_MASK(secondary)));
Ditto.
> +
> +	/* mask out bits above our current index */
> +	table[BIT_ULL_WORD(secondary)] &=
> +	    GENMASK_ULL(secondary % BITS_PER_LONG_LONG, 0);
> +
> +	return FCLK + hweight64(table[0]) +
> +	       (BIT_ULL_WORD(secondary) >= 1 ? hweight64(table[1]) : 0) +
> +	       (BIT_ULL_WORD(secondary) >= 2 ? hweight64(table[2]) : 0);
> +}
> +
> +struct clk *stm32f4_rcc_lookup_clk(struct of_phandle_args *clkspec, void *data)
> +{
> +	return clks[stm32f4_rcc_lookup_clk_idx(clkspec->args[0],
> +					       clkspec->args[1])];
If stm32f4_rcc_lookup_clk_idx() returns an error, you could propagate it 
using ERR_PTR().
> +}
> +
> +static const char __initdata *sys_parents[] =   { "hsi", NULL, "pll" };
> +
> +static struct clk_div_table ahb_div_table[] = {
Should be const.
> +	{ 0x0,   1 }, { 0x1,   1 }, { 0x2,   1 }, { 0x3,   1 },
> +	{ 0x4,   1 }, { 0x5,   1 }, { 0x6,   1 }, { 0x7,   1 },
> +	{ 0x8,   2 }, { 0x9,   4 }, { 0xa,   8 }, { 0xb,  16 },
> +	{ 0xc,  64 }, { 0xd, 128 }, { 0xe, 256 }, { 0xf, 512 },
> +	{ 0 },
> +};
> +
> +static struct clk_div_table apb_div_table[] = {
Ditto.
> +	{ 0,  1 }, { 0,  1 }, { 0,  1 }, { 0,  1 },
> +	{ 4,  2 }, { 5,  4 }, { 6,  8 }, { 7, 16 },
> +	{ 0 },
> +};
>

Thanks!
Maxime

WARNING: multiple messages have this Message-ID (diff)
From: mcoquelin.stm32@gmail.com (Maxime Coquelin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/4] clk: stm32: Add clock driver for STM32F4[23]xxx devices
Date: Sat, 30 May 2015 11:15:58 +0200	[thread overview]
Message-ID: <55697FCE.9040003@gmail.com> (raw)
In-Reply-To: <1432972448-10332-4-git-send-email-daniel.thompson@linaro.org>

Hi Daniel,

     Nice driver, please find my comments below.

     Once fixed, you can add:
Reviewed-by: Maxime Coquelin <mcoquelin.stm32@gmail.com>


On 05/30/2015 09:54 AM, Daniel Thompson wrote:
> The driver supports decoding and statically modelling PLL state (i.e.
> we inherit state from bootloader) and provides support for all
> peripherals that support simple one-bit gated clocks. The covers all
> peripherals whose clocks come from the AHB, APB1 or APB2 buses.
>
> It has been tested (for non-regression only) on an STM32F429I-Discovery
> boards. The clock counts for TIM2, USART1 and SYSTICK are all set correctly
> and time and the wall clock looks OK when checked with a stopwatch.
>
> Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
> ---
>   drivers/clk/Makefile      |   1 +
>   drivers/clk/clk-stm32f4.c | 364 ++++++++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 365 insertions(+)
>   create mode 100644 drivers/clk/clk-stm32f4.c
...
> diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c
> new file mode 100644
> index 0000000..68f9962
> --- /dev/null
> +++ b/drivers/clk/clk-stm32f4.c
> @@ -0,0 +1,364 @@
...
> +/*
> + * Converts the primary and secondary indices (as they appear in DT) to an
> + * offset into our struct clock array.
> + */
> +static unsigned int stm32f4_rcc_lookup_clk_idx(u8 primary, u8 secondary)
> +{
> +	u64 table[ARRAY_SIZE(stm32f42xx_gate_map)];
> +
> +	if (primary == 1) {
> +		BUG_ON(secondary > FCLK);
Maybe the function could return a signed int, an propagate errors 
instead of using BUG_ON?
> +		return secondary;
> +	}
> +
> +	memcpy(table, stm32f42xx_gate_map, sizeof(table));
> +
> +	/* only bits set in table can be used as indices */
> +	BUG_ON(secondary > 8 * sizeof(table) ||
> +	       0 == (table[BIT_ULL_WORD(secondary)] & BIT_ULL_MASK(secondary)));
Ditto.
> +
> +	/* mask out bits above our current index */
> +	table[BIT_ULL_WORD(secondary)] &=
> +	    GENMASK_ULL(secondary % BITS_PER_LONG_LONG, 0);
> +
> +	return FCLK + hweight64(table[0]) +
> +	       (BIT_ULL_WORD(secondary) >= 1 ? hweight64(table[1]) : 0) +
> +	       (BIT_ULL_WORD(secondary) >= 2 ? hweight64(table[2]) : 0);
> +}
> +
> +struct clk *stm32f4_rcc_lookup_clk(struct of_phandle_args *clkspec, void *data)
> +{
> +	return clks[stm32f4_rcc_lookup_clk_idx(clkspec->args[0],
> +					       clkspec->args[1])];
If stm32f4_rcc_lookup_clk_idx() returns an error, you could propagate it 
using ERR_PTR().
> +}
> +
> +static const char __initdata *sys_parents[] =   { "hsi", NULL, "pll" };
> +
> +static struct clk_div_table ahb_div_table[] = {
Should be const.
> +	{ 0x0,   1 }, { 0x1,   1 }, { 0x2,   1 }, { 0x3,   1 },
> +	{ 0x4,   1 }, { 0x5,   1 }, { 0x6,   1 }, { 0x7,   1 },
> +	{ 0x8,   2 }, { 0x9,   4 }, { 0xa,   8 }, { 0xb,  16 },
> +	{ 0xc,  64 }, { 0xd, 128 }, { 0xe, 256 }, { 0xf, 512 },
> +	{ 0 },
> +};
> +
> +static struct clk_div_table apb_div_table[] = {
Ditto.
> +	{ 0,  1 }, { 0,  1 }, { 0,  1 }, { 0,  1 },
> +	{ 4,  2 }, { 5,  4 }, { 6,  8 }, { 7, 16 },
> +	{ 0 },
> +};
>

Thanks!
Maxime

  reply	other threads:[~2015-05-30  9:16 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 20:41 [RFC PATCH 0/3] clk: stm32: Add clock driver for STM32F4[23]xxx devices Daniel Thompson
2015-05-22 20:41 ` Daniel Thompson
2015-05-22 20:41 ` [RFC PATCH 1/3] dt-bindings: Document the STM32F4 clock bindings Daniel Thompson
2015-05-22 20:41   ` Daniel Thompson
2015-05-22 20:41   ` Daniel Thompson
2015-05-22 20:41 ` [RFC PATCH 2/3] clk: stm32: Add clock driver for STM32F4[23]xxx devices Daniel Thompson
2015-05-22 20:41   ` Daniel Thompson
2015-06-04 22:07   ` Stephen Boyd
2015-06-04 22:07     ` Stephen Boyd
2015-06-05  9:36     ` Daniel Thompson
2015-06-05  9:36       ` Daniel Thompson
2015-06-06  0:10       ` Stephen Boyd
2015-06-06  0:10         ` Stephen Boyd
2015-05-22 20:41 ` [RFC PATCH 3/3] ARM: dts: stm32f429: Adopt STM32F4 clock driver Daniel Thompson
2015-05-22 20:41   ` Daniel Thompson
2015-05-26 16:41 ` [RFC PATCH 0/3] clk: stm32: Add clock driver for STM32F4[23]xxx devices Maxime Coquelin
2015-05-26 16:41   ` Maxime Coquelin
2015-05-26 16:41   ` Maxime Coquelin
2015-05-27  8:36   ` Daniel Thompson
2015-05-27  8:36     ` Daniel Thompson
2015-05-27  8:36     ` Daniel Thompson
2015-05-27  8:36     ` Daniel Thompson
2015-05-30  7:54 ` [PATCH v2 0/4] " Daniel Thompson
2015-05-30  7:54   ` Daniel Thompson
2015-05-30  7:54   ` Daniel Thompson
2015-05-30  7:54   ` [PATCH v2 1/4] ARM: stm32: Enable clock source Daniel Thompson
2015-05-30  7:54     ` Daniel Thompson
2015-05-30  7:54   ` [PATCH v2 2/4] dt-bindings: Document the STM32F4 clock bindings Daniel Thompson
2015-05-30  7:54     ` Daniel Thompson
2015-05-30  7:54     ` Daniel Thompson
2015-05-30  9:21     ` Maxime Coquelin
2015-05-30  9:21       ` Maxime Coquelin
2015-05-30  9:21       ` Maxime Coquelin
2015-06-01  7:46       ` Daniel Thompson
2015-06-01  7:46         ` Daniel Thompson
2015-06-01  7:46         ` Daniel Thompson
2015-05-30  7:54   ` [PATCH v2 3/4] clk: stm32: Add clock driver for STM32F4[23]xxx devices Daniel Thompson
2015-05-30  7:54     ` Daniel Thompson
2015-05-30  7:54     ` Daniel Thompson
2015-05-30  9:15     ` Maxime Coquelin [this message]
2015-05-30  9:15       ` Maxime Coquelin
2015-06-01  7:18       ` Daniel Thompson
2015-06-01  7:18         ` Daniel Thompson
2015-06-01  7:18         ` Daniel Thompson
2015-05-30  7:54   ` [PATCH v2 4/4] ARM: dts: stm32f429: Adopt STM32F4 clock driver Daniel Thompson
2015-05-30  7:54     ` Daniel Thompson
2015-05-30  7:54     ` Daniel Thompson
2015-05-30  9:38     ` Maxime Coquelin
2015-05-30  9:38       ` Maxime Coquelin
2015-05-30  8:40   ` [PATCH v2 0/4] clk: stm32: Add clock driver for STM32F4[23]xxx devices Maxime Coquelin
2015-05-30  8:40     ` Maxime Coquelin
2015-06-10 20:09 ` [PATCH v3 0/3] " Daniel Thompson
2015-06-10 20:09   ` Daniel Thompson
2015-06-10 20:09   ` Daniel Thompson
2015-06-10 20:09   ` [PATCH v3 1/3] dt-bindings: Document the STM32F4 clock bindings Daniel Thompson
2015-06-10 20:09     ` Daniel Thompson
2015-06-10 20:09     ` Daniel Thompson
2015-06-12  7:25     ` Maxime Coquelin
2015-06-12  7:25       ` Maxime Coquelin
2015-06-12  7:25       ` Maxime Coquelin
2015-06-22 22:47     ` Stephen Boyd
2015-06-22 22:47       ` Stephen Boyd
2015-06-22 22:47       ` Stephen Boyd
2015-06-10 20:09   ` [PATCH v3 2/3] clk: stm32: Add clock driver for STM32F4[23]xxx devices Daniel Thompson
2015-06-10 20:09     ` Daniel Thompson
2015-06-10 20:09     ` Daniel Thompson
2015-06-22 22:48     ` Stephen Boyd
2015-06-22 22:48       ` Stephen Boyd
2015-06-22 22:48       ` Stephen Boyd
2015-06-22 22:48       ` Stephen Boyd
2015-06-22 23:21     ` Stephen Boyd
2015-06-22 23:21       ` Stephen Boyd
2015-06-22 23:21       ` Stephen Boyd
2015-06-23  8:25       ` Daniel Thompson
2015-06-23  8:25         ` Daniel Thompson
2015-06-23  8:25         ` Daniel Thompson
2015-06-10 20:09   ` [PATCH v3 3/3] ARM: dts: stm32f429: Adopt STM32F4 clock driver Daniel Thompson
2015-06-10 20:09     ` Daniel Thompson
2015-07-07  9:38     ` Maxime Coquelin
2015-07-07  9:38       ` Maxime Coquelin
2015-07-07  9:38       ` Maxime Coquelin
2015-06-22 22:48   ` [PATCH v3 0/3] clk: stm32: Add clock driver for STM32F4[23]xxx devices Stephen Boyd
2015-06-22 22:48     ` Stephen Boyd
2015-06-22 22:48     ` Stephen Boyd
2015-06-22 22:48     ` Stephen Boyd
2015-06-23  8:22     ` Daniel Thompson
2015-06-23  8:22       ` Daniel Thompson
2015-06-23  8:22       ` Daniel Thompson
2015-06-23  9:24       ` Maxime Coquelin
2015-06-23  9:24         ` Maxime Coquelin
2015-06-23  9:24         ` Maxime Coquelin

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=55697FCE.9040003@gmail.com \
    --to=mcoquelin.stm32@gmail.com \
    --cc=afaerber@suse.de \
    --cc=daniel.thompson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@linaro.org \
    --cc=patches@linaro.org \
    --cc=pawel.moll@arm.com \
    --cc=rev13@wp.pl \
    --cc=robh+dt@kernel.org \
    --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 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.