aboutsummaryrefslogtreecommitdiff
path: root/src/soc/mediatek/common
diff options
context:
space:
mode:
authorYidi Lin <yidi.lin@mediatek.com>2021-01-06 15:27:13 +0800
committerHung-Te Lin <hungte@chromium.org>2021-01-07 02:02:51 +0000
commit54f8b9ee7428068f0acb27d43d70d95c64b1a7ba (patch)
treee3ffe11b4f78a2643c8bef51b38d4a2288438c5a /src/soc/mediatek/common
parent9990a172004354b6ccae7bca10bdab2b4b7b0bd9 (diff)
soc/mediatek: rtc: Use `bool` as return type
BUG=b:176307061 TEST=emerge-asurada coreboot; emerge-kukui coreboot emerge-oak coreboot boot to shell on Asurada Signed-off-by: Yidi Lin <yidi.lin@mediatek.com> Change-Id: Id31fa04edc2920c1767d9f08ab7af0ab4a15bc24 Reviewed-on: https://review.coreboot.org/c/coreboot/+/49137 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Diffstat (limited to 'src/soc/mediatek/common')
-rw-r--r--src/soc/mediatek/common/include/soc/rtc_common.h14
-rw-r--r--src/soc/mediatek/common/rtc.c40
2 files changed, 27 insertions, 27 deletions
diff --git a/src/soc/mediatek/common/include/soc/rtc_common.h b/src/soc/mediatek/common/include/soc/rtc_common.h
index 7ddb8df0a9..4a864311d9 100644
--- a/src/soc/mediatek/common/include/soc/rtc_common.h
+++ b/src/soc/mediatek/common/include/soc/rtc_common.h
@@ -6,6 +6,7 @@
#include <bcd.h>
#include <console/console.h>
#include <rtc.h>
+#include <stdbool.h>
#define RTCTAG "[RTC]"
#define rtc_info(fmt, arg ...) printk(BIOS_INFO, RTCTAG "%s,%d: " fmt, \
@@ -94,14 +95,13 @@ enum {
};
/* external API */
-int rtc_busy_wait(void);
-int rtc_write_trigger(void);
-int rtc_writeif_unlock(void);
-int rtc_xosc_write(u16 val);
-int rtc_lpen(u16 con);
-int rtc_reg_init(void);
+bool rtc_write_trigger(void);
+bool rtc_writeif_unlock(void);
+bool rtc_xosc_write(u16 val);
+bool rtc_lpen(u16 con);
+bool rtc_reg_init(void);
void rtc_osc_init(void);
-int rtc_powerkey_init(void);
+bool rtc_powerkey_init(void);
void rtc_boot_common(void);
#endif /* SOC_MEDIATEK_RTC_COMMON_H */
diff --git a/src/soc/mediatek/common/rtc.c b/src/soc/mediatek/common/rtc.c
index 95bd13b892..f36bbc57e4 100644
--- a/src/soc/mediatek/common/rtc.c
+++ b/src/soc/mediatek/common/rtc.c
@@ -5,7 +5,7 @@
#include <timer.h>
/* ensure rtc write success */
-int rtc_busy_wait(void)
+static bool rtc_busy_wait(void)
{
struct stopwatch sw;
u16 bbpu;
@@ -17,30 +17,30 @@ int rtc_busy_wait(void)
/* Time > 1sec, time out and set recovery mode enable.*/
if (stopwatch_expired(&sw)) {
rtc_info("BBPU CBUSY time out !!\n");
- return 0;
+ return false;
}
} while (bbpu & RTC_BBPU_CBUSY);
- return 1;
+ return true;
}
-int rtc_write_trigger(void)
+bool rtc_write_trigger(void)
{
rtc_write(RTC_WRTGR, 1);
return rtc_busy_wait();
}
/* unlock rtc write interface */
-int rtc_writeif_unlock(void)
+bool rtc_writeif_unlock(void)
{
rtc_write(RTC_PROT, RTC_PROT_UNLOCK1);
if (!rtc_write_trigger())
- return 0;
+ return false;
rtc_write(RTC_PROT, RTC_PROT_UNLOCK2);
if (!rtc_write_trigger())
- return 0;
+ return false;
- return 1;
+ return true;
}
/* set rtc time */
@@ -71,20 +71,20 @@ int rtc_get(struct rtc_time *time)
}
/* set rtc xosc setting */
-int rtc_xosc_write(u16 val)
+bool rtc_xosc_write(u16 val)
{
u16 bbpu;
rtc_write(RTC_OSC32CON, RTC_OSC32CON_UNLOCK1);
if (!rtc_busy_wait())
- return 0;
+ return false;
rtc_write(RTC_OSC32CON, RTC_OSC32CON_UNLOCK2);
if (!rtc_busy_wait())
- return 0;
+ return false;
rtc_write(RTC_OSC32CON, val);
if (!rtc_busy_wait())
- return 0;
+ return false;
rtc_read(RTC_BBPU, &bbpu);
bbpu |= RTC_BBPU_KEY | RTC_BBPU_RELOAD;
@@ -94,31 +94,31 @@ int rtc_xosc_write(u16 val)
}
/* enable lpd subroutine */
-int rtc_lpen(u16 con)
+bool rtc_lpen(u16 con)
{
con &= ~RTC_CON_LPRST;
rtc_write(RTC_CON, con);
if (!rtc_write_trigger())
- return 0;
+ return false;
con |= RTC_CON_LPRST;
rtc_write(RTC_CON, con);
if (!rtc_write_trigger())
- return 0;
+ return false;
con &= ~RTC_CON_LPRST;
rtc_write(RTC_CON, con);
if (!rtc_write_trigger())
- return 0;
+ return false;
- return 1;
+ return true;
}
/* initialize rtc related registers */
-int rtc_reg_init(void)
+bool rtc_reg_init(void)
{
u16 irqsta;
@@ -136,7 +136,7 @@ int rtc_reg_init(void)
rtc_write(RTC_DIFF, 0);
rtc_write(RTC_CALI, 0);
if (!rtc_write_trigger())
- return 0;
+ return false;
rtc_read(RTC_IRQ_STA, &irqsta); /* read clear */
@@ -153,7 +153,7 @@ int rtc_reg_init(void)
}
/* write powerkeys to enable rtc functions */
-int rtc_powerkey_init(void)
+bool rtc_powerkey_init(void)
{
rtc_write(RTC_POWERKEY1, RTC_POWERKEY1_KEY);
rtc_write(RTC_POWERKEY2, RTC_POWERKEY2_KEY);