From 01be95eee0d625e4b8a194f6664d2bae20765355 Mon Sep 17 00:00:00 2001 From: Yu-An Chen Date: Wed, 23 Nov 2022 15:13:18 +0800 Subject: zephyr: pcf85063a: Support oscillator capacitor selection Support to select the internal oscillator capacitor to 12.5 pF for PCF85063A, default setting is 7 pF. BUG=b:260165217 BRANCH=none TEST=zmake build evoker LOW_COVERAGE_REASON=RTC driver currently has no tests Signed-off-by: Yu-An Chen Change-Id: I3418adb08fb4f56bba06a0844acec7806b2bc35d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050010 Commit-Queue: Wai-Hong Tam Reviewed-by: Bob Moragues Code-Coverage: Zoss Reviewed-by: Sam Hurst --- zephyr/drivers/cros_rtc/Kconfig | 7 +++++++ zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c | 10 ++++++++++ zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h | 1 + 3 files changed, 18 insertions(+) diff --git a/zephyr/drivers/cros_rtc/Kconfig b/zephyr/drivers/cros_rtc/Kconfig index fb84416d70..2f064b4db8 100644 --- a/zephyr/drivers/cros_rtc/Kconfig +++ b/zephyr/drivers/cros_rtc/Kconfig @@ -45,4 +45,11 @@ config CROS_RTC_RENESAS_IDT1337AG endchoice # CROS_RTC_TYPE +config PLATFORM_EC_PCF85063A_CAP_SEL + bool "Set CAP_SEL of PCF85063A" + depends on CROS_RTC_NXP_PCF85063A + help + This option select the internal oscillator capacitor to 12.5 pF, + default is 7 pF. + endif # PLATFORM_EC_RTC diff --git a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c index 34c2cbe0a7..298c8cd64f 100644 --- a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c +++ b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c @@ -363,6 +363,16 @@ static int nxp_rtc_pcf85063a_init(const struct device *dev) } } +#ifdef CONFIG_PLATFORM_EC_PCF85063A_CAP_SEL + ret = pcf85063a_write_reg(dev, REG_CONTROL_1, + (CONTROL_1_DEFAULT_VALUE | CAP_SEL)); + + if (ret < 0) { + LOG_ERR("PCF85063A set CAP_SEL Fail!"); + return ret; + } +#endif + /* * Read Seconds register and check if oscillator is stopped. * If so, clear the bit. diff --git a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h index 54b1fbd2ea..c0139db631 100644 --- a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h +++ b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h @@ -10,6 +10,7 @@ #define SOFT_RESET 0x58 #define CONTROL_1_DEFAULT_VALUE 0 #define OS_BIT 0x80 +#define CAP_SEL 0x01 #define DISABLE_ALARM 0x80 #define ENABLE_ALARM_INTERRUPT 0x80 #define RTC_STOP_CLOCKS 0x20 -- cgit v1.2.1