summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/mt8173
diff options
context:
space:
mode:
authorYuchen Huang <yuchen.huang@mediatek.corp-partner.google.com>2020-08-18 16:29:29 +0800
committerHung-Te Lin <hungte@chromium.org>2020-12-28 13:39:01 +0000
commitb0ab41e0279e47d3bb09d6cddc803686859e6985 (patch)
tree08b5681adc26bbf5500b5727a24729424625d840 /src/soc/mediatek/mt8173
parent87c30a064c33071d4494c03c34abf2cdea6ff850 (diff)
soc/mediatek/mt8192: add rtc MT6359P driver
Add rtc MT6359P driver for rtc init and rtc eosc calibration. Refactor mt8173 and mt8183 code by extracting common API. Move rtc_read and rtc_write to each SoC folder, because mt8173 and mt8183 access rtc via pmic wrapper, while mt8192 accesses it via pmif. Reference datasheet: Document No: RH-D-2018-0101. Signed-off-by: Yuchen Huang <yuchen.huang@mediatek.corp-partner.google.com> Change-Id: I57d6738fdec148c7458b2024a0a8225415ca2f3e Reviewed-on: https://review.coreboot.org/c/coreboot/+/46395 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Diffstat (limited to 'src/soc/mediatek/mt8173')
-rw-r--r--src/soc/mediatek/mt8173/include/soc/rtc.h26
-rw-r--r--src/soc/mediatek/mt8173/rtc.c5
2 files changed, 27 insertions, 4 deletions
diff --git a/src/soc/mediatek/mt8173/include/soc/rtc.h b/src/soc/mediatek/mt8173/include/soc/rtc.h
index d0d302366d..bb9425fe8e 100644
--- a/src/soc/mediatek/mt8173/include/soc/rtc.h
+++ b/src/soc/mediatek/mt8173/include/soc/rtc.h
@@ -3,6 +3,7 @@
#ifndef SOC_MEDIATEK_MT8173_RTC_H
#define SOC_MEDIATEK_MT8173_RTC_H
+#include <soc/pmic_wrap_common.h>
#include <soc/rtc_common.h>
#include <stdint.h>
#include "mt6391.h"
@@ -98,8 +99,29 @@ enum {
};
/* external API */
-void rtc_osc_init(void);
-int rtc_init(u8 recover);
+int rtc_init(int recover);
void rtc_boot(void);
+static inline s32 rtc_read(u16 addr, u16 *rdata)
+{
+ s32 ret;
+
+ ret = pwrap_read(addr, rdata);
+ if (ret < 0)
+ rtc_info("pwrap_read failed: ret=%d\n", ret);
+
+ return ret;
+}
+
+static inline s32 rtc_write(u16 addr, u16 wdata)
+{
+ s32 ret;
+
+ ret = pwrap_write(addr, wdata);
+ if (ret < 0)
+ rtc_info("pwrap_write failed: ret=%d\n", ret);
+
+ return ret;
+}
+
#endif /* SOC_MEDIATEK_MT8173_RTC_H */
diff --git a/src/soc/mediatek/mt8173/rtc.c b/src/soc/mediatek/mt8173/rtc.c
index d08de45325..94ec421f0d 100644
--- a/src/soc/mediatek/mt8173/rtc.c
+++ b/src/soc/mediatek/mt8173/rtc.c
@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <delay.h>
-#include <soc/rtc_common.h>
#include <soc/rtc.h>
+#include <soc/rtc_common.h>
#include <soc/mt6391.h>
#include <soc/pmic_wrap.h>
#include <types.h>
@@ -59,7 +59,7 @@ static int rtc_lpd_init(void)
}
/* rtc init check */
-int rtc_init(u8 recover)
+int rtc_init(int recover)
{
int ret;
@@ -84,6 +84,7 @@ int rtc_init(u8 recover)
goto err;
}
+ /* In recovery mode, we need delay for register setting. */
if (recover)
mdelay(1000);