From: "Andreas Bießmann" <andreas.devel@googlemail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH 5/7] arm: atmel: add plla and mck initialize function
Date: Wed, 30 Oct 2013 12:21:57 +0100 [thread overview]
Message-ID: <5270EBD5.4010909@gmail.com> (raw)
In-Reply-To: <1383124508-8413-6-git-send-email-voice.shen@atmel.com>
Hi Bo,
On 10/30/2013 10:15 AM, Bo Shen wrote:
> Add plla and mck initialize function.
>
> Signed-off-by: Bo Shen <voice.shen@atmel.com>
> ---
> arch/arm/cpu/armv7/at91/clock.c | 27 ++++++++++++++++++++++++++
> arch/arm/include/asm/arch-at91/at91_common.h | 2 ++
> 2 files changed, 29 insertions(+)
>
> diff --git a/arch/arm/cpu/armv7/at91/clock.c b/arch/arm/cpu/armv7/at91/clock.c
> index 1588e0c..ec92950 100644
> --- a/arch/arm/cpu/armv7/at91/clock.c
> +++ b/arch/arm/cpu/armv7/at91/clock.c
> @@ -120,3 +120,30 @@ void at91_periph_clk_enable(int id)
> else
> writel(1 << id, &pmc->pcer);
> }
> +
> +void at91_plla_init(u32 pllar, int timeout)
> +{
> + struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> +
> + writel(pllar, &pmc->pllar);
> + while (!(readl(&pmc->sr) & (AT91_PMC_LOCKA | AT91_PMC_MCKRDY)))
> + timeout--;
I do not understand use of this timeout here ... You do not check it nor
return something ... It would make sense to add an check into the wile()
and return upon the state of timeout true/false.
This however is not needed here cause we either succeed to setup the PLL
or not. If not we could not proceed anyways, so why check it here?
In connection with a watchdog it could make sense to kick it while
waiting for PLL initialisation.
> +}
> +
> +void at91_mck_init(u32 mckr, int timeout)
I wonder if it would make sense to abstract the functionality of mckr to
the function parameters. Something like 'I want to set 400MHz, do it for
me'. Maybe this doesn't make any sense, lets discuss.
> +{
> + struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> + u32 tmp;
> +
> + tmp = readl(&pmc->mckr);
> + tmp &= ~(AT91_PMC_MCKR_PRES_MASK |
> + AT91_PMC_MCKR_MDIV_MASK |
> + AT91_PMC_MCKR_PLLADIV_2);
> + tmp |= mckr & (AT91_PMC_MCKR_PRES_MASK |
> + AT91_PMC_MCKR_MDIV_MASK |
> + AT91_PMC_MCKR_PLLADIV_2);
> + writel(tmp, &pmc->mckr);
> +
> + while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
> + timeout--;
> +}
> diff --git a/arch/arm/include/asm/arch-at91/at91_common.h b/arch/arm/include/asm/arch-at91/at91_common.h
> index abcb97d..a692275 100644
> --- a/arch/arm/include/asm/arch-at91/at91_common.h
> +++ b/arch/arm/include/asm/arch-at91/at91_common.h
> @@ -22,5 +22,7 @@ void at91_spi1_hw_init(unsigned long cs_mask);
> void at91_udp_hw_init(void);
> void at91_uhp_hw_init(void);
> void at91_lcd_hw_init(void);
> +void at91_plla_init(u32 pllar, int timeout);
> +void at91_mck_init(u32 mckr, int timeout);
>
> #endif /* AT91_COMMON_H */
>
next prev parent reply other threads:[~2013-10-30 11:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-30 9:15 [U-Boot] [RFC PATCH 0/7] arm: atmel: sama5d3: enable spl boot from SD card Bo Shen
2013-10-30 9:15 ` [U-Boot] [RFC PATCH 1/7] arm: atmel: sama5d3: early enable PIO peripherals Bo Shen
2013-10-30 10:12 ` Heiko Schocher
2013-10-30 11:11 ` Andreas Bießmann
2013-10-31 2:02 ` Bo Shen
2013-10-30 9:15 ` [U-Boot] [RFC PATCH 2/7] arm: atmel: sama5d3: correct the ID for DBGU and PIT Bo Shen
2013-10-30 11:12 ` Andreas Bießmann
2013-10-31 1:32 ` Bo Shen
2013-10-30 9:15 ` [U-Boot] [RFC PATCH 3/7] arm: atmel: the offset of MULA is 18 in sama5d3 Bo Shen
2013-10-30 9:15 ` [U-Boot] [RFC PATCH 4/7] arm: atmel: sama5: correct the error define of DIV Bo Shen
2013-10-30 9:15 ` [U-Boot] [RFC PATCH 5/7] arm: atmel: add plla and mck initialize function Bo Shen
2013-10-30 11:21 ` Andreas Bießmann [this message]
2013-10-31 1:38 ` Bo Shen
2013-10-30 9:15 ` [U-Boot] [RFC PATCH 6/7] arm: atmel: add ddr2 initialization function Bo Shen
2013-10-30 9:15 ` [U-Boot] [RFC PATCH 7/7] spl: mmc: FAT support boot u-boot Bo Shen
2013-10-30 10:15 ` Heiko Schocher
2013-10-30 10:43 ` Andreas Bießmann
2013-10-30 10:57 ` Heiko Schocher
2013-10-30 11:02 ` Andreas Bießmann
2013-10-31 1:30 ` Bo Shen
2013-10-31 7:42 ` Heiko Schocher
2013-10-31 7:50 ` Bo Shen
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=5270EBD5.4010909@gmail.com \
--to=andreas.devel@googlemail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox