From 850ef52982b92afbcb3eacb2f69a597731303ed3 Mon Sep 17 00:00:00 2001 From: Kevin K Wong Date: Tue, 1 Jul 2014 15:38:39 -0700 Subject: mec1322: Added support to use crystal vs oscillator based on board's clock circuitry. BUG=None TEST=make -j buildall BRANCH=None Change-Id: I88fa219cd9e573c1544400d24d00c4fdec93840f Signed-off-by: Kevin K Wong Reviewed-on: https://chromium-review.googlesource.com/237272 Reviewed-by: Vic Yang --- board/strago/board.h | 1 + chip/mec1322/clock.c | 13 ++++++++++++- include/config.h | 7 +++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/board/strago/board.h b/board/strago/board.h index 4e965b791f..b67d2d2886 100644 --- a/board/strago/board.h +++ b/board/strago/board.h @@ -12,6 +12,7 @@ /* Optional features */ #define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands */ #define CONFIG_WATCHDOG_HELP +#define CONFIG_CLOCK_CRYSTAL #define CONFIG_CHIPSET_BRASWELL #define CONFIG_KEYBOARD_PROTOCOL_8042 #define CONFIG_KEYBOARD_IRQ_GPIO GPIO_KBD_IRQ_L diff --git a/chip/mec1322/clock.c b/chip/mec1322/clock.c index 512627b184..f838dd0197 100644 --- a/chip/mec1322/clock.c +++ b/chip/mec1322/clock.c @@ -30,9 +30,20 @@ int clock_get_freq(void) void clock_init(void) { - /* XOSEL = Single ended clock source */ +#ifdef CONFIG_CLOCK_CRYSTAL + /* XOSEL: 0 = Parallel resonant crystal */ + MEC1322_VBAT_CE &= ~0x1; +#else + /* XOSEL: 1 = Single ended clock source */ MEC1322_VBAT_CE |= 0x1; +#endif /* 32K clock enable */ MEC1322_VBAT_CE |= 0x2; + +#ifdef CONFIG_CLOCK_CRYSTAL + /* Wait for crystal to stabilize (OSC_LOCK == 1) */ + while (!(MEC1322_PCR_CHIP_OSC_ID & 0x100)) + ; +#endif } diff --git a/include/config.h b/include/config.h index 5013901fee..7013a7db0a 100644 --- a/include/config.h +++ b/include/config.h @@ -299,6 +299,13 @@ #define CONFIG_CHIPSET_HAS_PP1350 #define CONFIG_CHIPSET_HAS_PP5000 +/*****************************************************************************/ +/* + * Chip config for clock circuitry + * define = crystal / undef = oscillator + */ +#undef CONFIG_CLOCK_CRYSTAL + /*****************************************************************************/ /* PMIC config */ -- cgit v1.2.1