mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>,
	Michael Grzeschik <mgr@pengutronix.de>
Subject: [PATCH] ARM: at91: support sama5 low level clock setup with oscillator
Date: Mon, 28 Sep 2020 12:08:09 +0200	[thread overview]
Message-ID: <20200928100809.25868-1-a.fatoum@pengutronix.de> (raw)

AT91Bootstrap has a CONFIG_MCK_BYPASS option with following help text:

  "Use external 8 to 24 Mhz clock signal as source of main clock
  instead of an external crystal oscillator.
  This option disables the internal driving on the XOUT pin.
  The external source has to provide a stable clock on the XIN pin.
  If this option is disabled, the SoC expects a crystal oscillator
  that needs driving on both XIN and XOUT lines."

When the low level clock setup was ported over from AT91Bootstrap,
this config option was dropped. It wasn't necessary for the xplained
boards that have a crystal, but for ones with an oscillator, it's
required. Add the bit flag back.

Suggested-by: Michael Grzeschik <mgr@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/mach-at91/at91_pmc_ll.c              | 2 ++
 arch/arm/mach-at91/include/mach/at91_pmc_ll.h | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/arch/arm/mach-at91/at91_pmc_ll.c b/arch/arm/mach-at91/at91_pmc_ll.c
index 9205322db972..e561f207551d 100644
--- a/arch/arm/mach-at91/at91_pmc_ll.c
+++ b/arch/arm/mach-at91/at91_pmc_ll.c
@@ -88,6 +88,8 @@ void at91_pmc_init(void __iomem *pmc_base, unsigned int flags)
 		tmp &= ~AT91_PMC_OSCBYPASS;
 		tmp &= ~AT91_PMC_KEY_MASK;
 		tmp |= AT91_PMC_KEY;
+		if (flags & AT91_PMC_LL_FLAG_MCK_BYPASS)
+			tmp |= AT91_PMC_OSCBYPASS;
 		at91_pmc_write(AT91_CKGR_MOR, tmp);
 
 		tmp = at91_pmc_read(AT91_CKGR_MOR);
diff --git a/arch/arm/mach-at91/include/mach/at91_pmc_ll.h b/arch/arm/mach-at91/include/mach/at91_pmc_ll.h
index 6ec3ae0852c6..85896a01d5b5 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc_ll.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc_ll.h
@@ -16,6 +16,7 @@
 #define AT91_PMC_LL_FLAG_H32MXDIV	(1 << 3)
 #define AT91_PMC_LL_FLAG_PMC_UTMI	(1 << 4)
 #define AT91_PMC_LL_FLAG_GCSR		(1 << 5)
+#define AT91_PMC_LL_FLAG_MCK_BYPASS	(1 << 6)
 
 #define AT91_PMC_LL_AT91RM9200	(0)
 #define AT91_PMC_LL_AT91SAM9260	(0)
@@ -30,6 +31,10 @@
 #define AT91_PMC_LL_SAMA5D2	(AT91_PMC_LL_FLAG_SAM9X5_PMC | \
 				 AT91_PMC_LL_FLAG_MEASURE_XTAL | \
 				 AT91_PMC_LL_FLAG_PMC_UTMI)
+/* This assumes a crystal on both XIN and XOUT. If your board
+ * instead has an extenal oscillator on XIN only,
+ * AT91_PMC_LL_FLAG_MCK_BYPASS needs to be OR`ed in as well
+ */
 #define AT91_PMC_LL_SAMA5D3	(AT91_PMC_LL_FLAG_SAM9X5_PMC | \
 				 AT91_PMC_LL_FLAG_DISABLE_RC | \
 				 AT91_PMC_LL_FLAG_PMC_UTMI)
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2020-09-28 10:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 10:08 Ahmad Fatoum [this message]
2020-09-29  7:01 ` Sascha Hauer

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=20200928100809.25868-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=mgr@pengutronix.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