diff options
author | Chuanhua Han <chuanhua.han@nxp.com> | 2019-07-26 19:24:00 +0800 |
---|---|---|
committer | Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> | 2019-08-22 09:07:36 +0530 |
commit | db07c447caacd5f9003a57ef2802afa8a4c81348 (patch) | |
tree | 03bd2a7657d4cfecd4a9684fbc87c7c29eac1da0 /drivers/rtc/ds3231.c | |
parent | 6672ab1628a7837361524ebbc5e2119be9202fa7 (diff) |
rtc: ds3232/ds3231: Add support to generate 32KHz output for driver module
Add an implementation of the rtc_enable_32khz_output() that uses the
driver model i2c APIs.
Also put code related to rtc_enable_32khz_output
under CONFIG_RTC_ENABLE_32KHZ_OUTPUT.
Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
Reviewed-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Diffstat (limited to 'drivers/rtc/ds3231.c')
-rw-r--r-- | drivers/rtc/ds3231.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/rtc/ds3231.c b/drivers/rtc/ds3231.c index 79b026af4b..fde4d860ec 100644 --- a/drivers/rtc/ds3231.c +++ b/drivers/rtc/ds3231.c @@ -148,11 +148,13 @@ void rtc_reset (void) /* * Enable 32KHz output */ +#ifdef CONFIG_RTC_ENABLE_32KHZ_OUTPUT void rtc_enable_32khz_output(void) { rtc_write(RTC_STAT_REG_ADDR, RTC_STAT_BIT_BB32KHZ | RTC_STAT_BIT_EN32KHZ); } +#endif /* * Helper functions @@ -251,6 +253,21 @@ static int ds3231_probe(struct udevice *dev) return 0; } +#ifdef CONFIG_RTC_ENABLE_32KHZ_OUTPUT +int rtc_enable_32khz_output(int busnum, int chip_addr) +{ + int ret; + struct udevice *dev; + + ret = i2c_get_chip_for_busnum(busnum, chip_addr, 1, &dev); + if (!ret) + ret = dm_i2c_reg_write(dev, RTC_STAT_REG_ADDR, + RTC_STAT_BIT_BB32KHZ | + RTC_STAT_BIT_EN32KHZ); + return ret; +} +#endif + static const struct rtc_ops ds3231_rtc_ops = { .get = ds3231_rtc_get, .set = ds3231_rtc_set, |