rtc: Add prescalar configuration option
This patch adds a prescaler configuration option that denotes the number of RTC ticks per second. This is used to calculate the value for 1 second. Signed-off-by: Andy Gross <agross@kernel.org>
This commit is contained in:
parent
4aaaccc739
commit
27bdb83308
@ -18,4 +18,12 @@ config RTC_QMSI_API_REENTRANCY
|
||||
default n
|
||||
help
|
||||
Enable support for RTC shim driver API reentrancy.
|
||||
|
||||
config RTC_PRESCALER
|
||||
int
|
||||
default 1
|
||||
prompt "Prescaler size"
|
||||
help
|
||||
RTC prescaler used to determine ticks per second
|
||||
|
||||
endif
|
||||
|
||||
@ -93,7 +93,7 @@ static int rtc_qmsi_set_config(struct device *dev, struct rtc_config *cfg)
|
||||
* values defined by clk_rtc_div and by QMSI's clk_rtc_div_t match for
|
||||
* both D2000 and SE.
|
||||
*/
|
||||
qm_cfg.prescaler = (clk_rtc_div_t)RTC_DIVIDER;
|
||||
qm_cfg.prescaler = (clk_rtc_div_t)CONFIG_RTC_PRESCALER;
|
||||
|
||||
if (IS_ENABLED(CONFIG_RTC_QMSI_API_REENTRANCY)) {
|
||||
k_sem_take(RP_GET(dev), K_FOREVER);
|
||||
|
||||
@ -14,29 +14,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum clk_rtc_div {
|
||||
RTC_CLK_DIV_1,
|
||||
RTC_CLK_DIV_2,
|
||||
RTC_CLK_DIV_4,
|
||||
RTC_CLK_DIV_8,
|
||||
RTC_CLK_DIV_16,
|
||||
RTC_CLK_DIV_32,
|
||||
RTC_CLK_DIV_64,
|
||||
RTC_CLK_DIV_128,
|
||||
RTC_CLK_DIV_256,
|
||||
RTC_CLK_DIV_512,
|
||||
RTC_CLK_DIV_1024,
|
||||
RTC_CLK_DIV_2048,
|
||||
RTC_CLK_DIV_4096,
|
||||
RTC_CLK_DIV_8192,
|
||||
RTC_CLK_DIV_16384,
|
||||
RTC_CLK_DIV_32768
|
||||
};
|
||||
|
||||
#define RTC_DIVIDER RTC_CLK_DIV_1
|
||||
|
||||
/** Number of RTC ticks in a second */
|
||||
#define RTC_ALARM_SECOND (32768 / (1UL << RTC_DIVIDER))
|
||||
#define RTC_ALARM_SECOND (32768 / CONFIG_RTC_PRESCALER)
|
||||
|
||||
/** Number of RTC ticks in a minute */
|
||||
#define RTC_ALARM_MINUTE (RTC_ALARM_SECOND * 60)
|
||||
|
||||
@ -42,7 +42,7 @@ static int test_task(void)
|
||||
k_sleep(2000);
|
||||
val_2 = rtc_read(rtc);
|
||||
|
||||
TC_PRINT("val_1: %u, val_2: %u, delta: %lu:%lu\n",
|
||||
TC_PRINT("val_1: %u, val_2: %u, delta: %u:%u\n",
|
||||
val_1, val_2,
|
||||
(val_2 - val_1) / RTC_ALARM_SECOND,
|
||||
(val_2 - val_1) % RTC_ALARM_SECOND);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user