public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Olliver Schinagl <oliver@schinagl.nl>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/9] sunxi: initial sun7i clocks and timer support.
Date: Mon, 24 Mar 2014 23:42:17 +0100	[thread overview]
Message-ID: <5330B4C9.10302@schinagl.nl> (raw)
In-Reply-To: <201403242152.38910.marex@denx.de>

On 03/24/2014 09:52 PM, Marek Vasut wrote:
> On Friday, March 21, 2014 at 10:54:18 PM, Ian Campbell wrote:
>> This has been stripped back for mainlining and supports only sun7i. These
>> changes are not useful by themselves but are split out to make the patch
>> sizes more manageable.
> [...]
>
>> +int clock_init(void)
>> +{
>> +	struct sunxi_ccm_reg *const ccm =
>> +		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
>> +
>> +#ifdef CONFIG_SPL_BUILD
>> +	clock_init_safe();
>> +#endif
>> +
>> +	/* uart clock source is apb1 */
>> +	sr32(&ccm->apb1_clk_div_cfg, 24, 2, APB1_CLK_SRC_OSC24M);
>> +	sr32(&ccm->apb1_clk_div_cfg, 16, 2, APB1_FACTOR_N);
>> +	sr32(&ccm->apb1_clk_div_cfg, 0, 5, APB1_FACTOR_M);
>
> sr32() is not defined anywhere.
it should be defined in
arch/arm/include/asm/arch-sunxi/sys_proto.h
and comes from
arch/arm/cpu/armv7/syslib.c

it was added for the ti omap's

I've got a local cleanup patch set where I fixed this already to 
clrsetbits_le32
>
>> +	/* open the clock for uart */
>> +	sr32(&ccm->apb1_gate, 16 + CONFIG_CONS_INDEX - 1, 1, CLK_GATE_OPEN);
>> +
>> +	return 0;
>> +}
>> +
>> +/* Return PLL5 frequency in Hz
>> + * Note: Assumes PLL5 reference is 24MHz clock
>> + */
>> +unsigned int clock_get_pll5(void)
>> +{
>> +	struct sunxi_ccm_reg *const ccm =
>> +		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
>> +	uint32_t rval = readl(&ccm->pll5_cfg);
>> +	int n = (rval >> 8) & 0x1f;
>> +	int k = ((rval >> 4) & 3) + 1;
>> +	int p = 1 << ((rval >> 16) & 3);
>> +	return 24000000 * n * k / p;
> Please fix the magic values here.
> [...]
Same here, got that in my local tree too
>
>> +#ifdef CONFIG_SPL_BUILD
>> +#define PLL1_CFG(N, K, M, P)	(1 << 31 | 0 << 30 | 8 << 26 | 0 << 25 |
> \
>> +				 16 << 20 | (P) << 16 | 2 << 13 | (N) << 8 | \
>> +				 (K) << 4 | 0 << 3 | 0 << 2 | (M) << 0)
> Here is well.
dito :)
>
>> +#define RDIV(a, b)		((a + (b) - 1) / (b))
> This is some kind of DIV_ROUND_UP() from include/common.h ?
>
> [...]
That one i didn't have;

Ian, I guess you can verify that generic macro works for here?
>
>> +	/* Map divisors to register values */
>> +	axi = axi - 1;
>> +	if (ahb > 4)
>> +		ahb = 3;
>> +	else if (ahb > 2)
>> +		ahb = 2;
>> +	else if (ahb > 1)
>> +		ahb = 1;
>> +	else
>> +		ahb = 0;
>> +
>> +	apb0 = apb0 - 1;
>> +
>> +	/* Switch to 24MHz clock while changing PLL1 */
>> +	writel(AXI_DIV_1 << AXI_DIV_SHIFT |
>> +	       AHB_DIV_2 << AHB_DIV_SHIFT |
>> +	       APB0_DIV_1 << APB0_DIV_SHIFT |
>> +	       CPU_CLK_SRC_OSC24M << CPU_CLK_SRC_SHIFT,
>> +	       &ccm->cpu_ahb_apb0_cfg);
>> +	sdelay(20);
> What is sdelay() function all about ?
It also is from
arch/arm/include/asm/arch-sunxi/sys_proto.h
and I thought all where replaced with udelays

With the sr32 and sdelays gone everywhere, sunxi/sys_proto.h can even go!
>
> [...]
>
>> +static struct sunxi_timer *timer_base =
>> +	&((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->timer[TIMER_NUM];
>> +
>> +/* macro to read the 32 bit timer: since it decrements, we invert read
>> value */ +#define READ_TIMER() (~readl(&timer_base->val))
> This macro has to go, just use ~readl() in place. But still, why do you use that
> negation in "~readl()" anyway ?
>
> [...]
Olliver

  reply	other threads:[~2014-03-24 22:42 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-21 21:54 [U-Boot] [PATCH v2 0/9] sunxi: initial upstreamining effort Ian Campbell
2014-03-21 21:54 ` [U-Boot] [PATCH v2 1/9] sunxi: initial sun7i clocks and timer support Ian Campbell
2014-03-24 20:52   ` Marek Vasut
2014-03-24 22:42     ` Olliver Schinagl [this message]
2014-03-25  0:57       ` Marek Vasut
2014-03-25  6:35       ` Wolfgang Denk
2014-03-26  8:23       ` Ian Campbell
2014-04-13 19:55       ` Ian Campbell
2014-04-13 21:00         ` Marek Vasut
2014-03-26  8:23     ` Ian Campbell
2014-03-27 21:29     ` Ian Campbell
2014-03-27 22:00       ` Marek Vasut
2014-03-27 22:12         ` Ian Campbell
2014-03-27 22:36           ` Marek Vasut
2014-03-28  8:20             ` Ian Campbell
2014-03-28  8:24               ` Marek Vasut
2014-03-28  8:25               ` Hans de Goede
2014-03-28  8:39                 ` Marek Vasut
2014-03-21 21:54 ` [U-Boot] [PATCH v2 2/9] sunxi: initial sun7i pinmux and gpio support Ian Campbell
2014-03-24 20:54   ` Marek Vasut
2014-03-26  8:30     ` Ian Campbell
2014-03-26  8:59       ` Marek Vasut
2014-03-26  9:01       ` Wolfgang Denk
2014-03-27 21:52         ` Ian Campbell
2014-03-26  8:33     ` Ian Campbell
2014-03-26  9:01       ` Marek Vasut
2014-03-26  9:03       ` Wolfgang Denk
2014-03-26  9:39         ` Ian Campbell
2014-03-26 10:03           ` Marek Vasut
2014-03-26 14:57           ` Wolfgang Denk
2014-03-21 21:54 ` [U-Boot] [PATCH v2 3/9] sunxi: initial sun7i dram setup support Ian Campbell
2014-03-21 21:54 ` [U-Boot] [PATCH v2 4/9] sunxi: initial generic sun7i cpu, board and start of day support Ian Campbell
2014-03-22  6:52   ` Wolfgang Denk
2014-03-22  7:08     ` mrnuke
2014-03-22  9:04     ` Hans de Goede
2014-03-22  9:37       ` Ian Campbell
2014-03-22 12:27       ` Wolfgang Denk
2014-03-22 15:28         ` Ian Campbell
2014-03-21 21:54 ` [U-Boot] [PATCH v2 5/9] sunxi: generic sun7i build infrastructure Ian Campbell
2014-03-22  6:46   ` Wolfgang Denk
2014-03-22 10:04     ` Ian Campbell
2014-03-22 12:33       ` Wolfgang Denk
2014-03-22 15:12         ` Hans de Goede
2014-03-22 15:26           ` Ian Campbell
2014-03-22 19:31           ` Wolfgang Denk
2014-03-22 20:07             ` Hans de Goede
2014-03-24 21:01   ` Marek Vasut
2014-03-27 22:05     ` Ian Campbell
2014-03-27 22:37       ` Marek Vasut
2014-03-28  8:26         ` Ian Campbell
2014-03-28  8:37           ` Marek Vasut
2014-03-21 21:54 ` [U-Boot] [PATCH v2 6/9] sunxi: add support for Cubietruck booting in FEL mode Ian Campbell
2014-03-21 21:54 ` [U-Boot] [PATCH v2 7/9] sunxi: add gmac Ethernet support Ian Campbell
2014-03-21 21:54 ` [U-Boot] [PATCH v2 8/9] sunxi: mmc support Ian Campbell
2014-03-24 21:14   ` Marek Vasut
2014-03-21 21:54 ` [U-Boot] [PATCH v2 9/9] sunxi: non-FEL SPL boot support for sun7i Ian Campbell
2014-03-22  6:54 ` [U-Boot] [PATCH v2 0/9] sunxi: initial upstreamining effort Wolfgang Denk
2014-03-24  0:14 ` [U-Boot] [linux-sunxi] " Henrik Nordström
2014-03-24  8:05   ` Ian Campbell

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=5330B4C9.10302@schinagl.nl \
    --to=oliver@schinagl.nl \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox