diff --git a/drivers/rtc/rtc-bd70528.c b/drivers/rtc/rtc-bd70528.c
index 6454afc..59b627f 100644
--- a/drivers/rtc/rtc-bd70528.c
+++ b/drivers/rtc/rtc-bd70528.c
@@ -2,10 +2,9 @@
//
// Copyright (C) 2018 ROHM Semiconductors
//
-// RTC driver for ROHM BD70528 PMIC
+// RTC driver for ROHM BD71828 and BD71815 PMIC
#include <linux/bcd.h>
-#include <linux/mfd/rohm-bd70528.h>
#include <linux/mfd/rohm-bd71815.h>
#include <linux/mfd/rohm-bd71828.h>
#include <linux/module.h>
@@ -39,11 +38,6 @@ struct bd70528_rtc_data {
u8 year;
} __packed;
-struct bd70528_rtc_wake {
- struct bd70528_rtc_day time;
- u8 ctrl;
-} __packed;
-
struct bd71828_rtc_alm {
struct bd70528_rtc_data alm0;
struct bd70528_rtc_data alm1;
@@ -51,141 +45,14 @@ struct bd71828_rtc_alm {
u8 alm1_mask;
} __packed;
-struct bd70528_rtc_alm {
- struct bd70528_rtc_data data;
- u8 alm_mask;
- u8 alm_repeat;
-} __packed;
-
struct bd70528_rtc {
struct rohm_regmap_dev *parent;
struct regmap *regmap;
struct device *dev;
u8 reg_time_start;
u8 bd718xx_alm_block_start;
- bool has_rtc_timers;
};
-static int bd70528_set_wake(struct rohm_regmap_dev *bd70528,
- int enable, int *old_state)
-{
- int ret;
- unsigned int ctrl_reg;
-
- ret = regmap_read(bd70528->regmap, BD70528_REG_WAKE_EN, &ctrl_reg);
- if (ret)
- return ret;
-
- if (old_state) {
- if (ctrl_reg & BD70528_MASK_WAKE_EN)
- *old_state |= BD70528_WAKE_STATE_BIT;
- else
- *old_state &= ~BD70528_WAKE_STATE_BIT;
-
- if (!enable == !(*old_state & BD70528_WAKE_STATE_BIT))
- return 0;
- }
-
- if (enable)
- ctrl_reg |= BD70528_MASK_WAKE_EN;
- else
- ctrl_reg &= ~BD70528_MASK_WAKE_EN;
-
- return regmap_write(bd70528->regmap, BD70528_REG_WAKE_EN,
- ctrl_reg);
-}
-
-static int bd70528_set_elapsed_tmr(struct rohm_regmap_dev *bd70528,
- int enable, int *old_state)
-{
- int ret;
- unsigned int ctrl_reg;
-
- /*
- * TBD
- * What is the purpose of elapsed timer ?
- * Is the timeout registers counting down, or is the disable - re-enable
- * going to restart the elapsed-time counting? If counting is restarted
- * the timeout should be decreased by the amount of time that has
- * elapsed since starting the timer. Maybe we should store the monotonic
- * clock value when timer is started so that if RTC is set while timer
- * is armed we could do the compensation. This is a hack if RTC/system
- * clk are drifting. OTOH, RTC controlled via I2C is in any case
- * inaccurate...
- */
- ret = regmap_read(bd70528->regmap, BD70528_REG_ELAPSED_TIMER_EN,
- &ctrl_reg);
- if (ret)
- return ret;
-
- if (old_state) {
- if (ctrl_reg & BD70528_MASK_ELAPSED_TIMER_EN)
- *old_state |= BD70528_ELAPSED_STATE_BIT;
- else
- *old_state &= ~BD70528_ELAPSED_STATE_BIT;
-
- if ((!enable) == (!(*old_state & BD70528_ELAPSED_STATE_BIT)))
- return 0;
- }
-
- if (enable)
- ctrl_reg |= BD70528_MASK_ELAPSED_TIMER_EN;
- else
- ctrl_reg &= ~BD70528_MASK_ELAPSED_TIMER_EN;
-
- return regmap_write(bd70528->regmap, BD70528_REG_ELAPSED_TIMER_EN,
- ctrl_reg);
-}
-
-static int bd70528_set_rtc_based_timers(struct bd70528_rtc *r, int new_state,
- int *old_state)
-{
- int ret;
-
- ret = bd70528_wdt_set(r->parent, new_state & BD70528_WDT_STATE_BIT,
- old_state);
- if (ret) {
- dev_err(r->dev,
- "Failed to disable WDG for RTC setting (%d)\n", ret);
- return ret;
- }
- ret = bd70528_set_elapsed_tmr(r->parent,
- new_state & BD70528_ELAPSED_STATE_BIT,
- old_state);
- if (ret) {
- dev_err(r->dev,
- "Failed to disable 'elapsed timer' for RTC setting\n");
- return ret;
- }
- ret = bd70528_set_wake(r->parent, new_state & BD70528_WAKE_STATE_BIT,
- old_state);
- if (ret) {
- dev_err(r->dev,
- "Failed to disable 'wake timer' for RTC setting\n");
- return ret;
- }
-
- return ret;
-}
-
-static int bd70528_re_enable_rtc_based_timers(struct bd70528_rtc *r,
- int old_state)
-{
- if (!r->has_rtc_timers)
- return 0;
-
- return bd70528_set_rtc_based_timers(r, old_state, NULL);
-}
-
-static int bd70528_disable_rtc_based_timers(struct bd70528_rtc *r,
- int *old_state)
-{
- if (!r->has_rtc_timers)
- return 0;
-
- return bd70528_set_rtc_based_timers(r, 0, old_state);
-}
-
static inline void tmday2rtc(struct rtc_time *t, struct bd70528_rtc_day *d)
{
d->sec &= ~BD70528_MASK_RTC_SEC;
@@ -267,52 +134,6 @@ static int bd71828_set_alarm(struct device *dev, struct rtc_wkalrm *a)
}
-static int bd70528_set_alarm(struct device *dev, struct rtc_wkalrm *a)
-{
- struct bd70528_rtc_wake wake;
- struct bd70528_rtc_alm alm;
- int ret;
- struct bd70528_rtc *r = dev_get_drvdata(dev);
-
- ret = regmap_bulk_read(r->regmap, BD70528_REG_RTC_WAKE_START, &wake,
- sizeof(wake));
- if (ret) {
- dev_err(dev, "Failed to read wake regs\n");
- return ret;
- }
-
- ret = regmap_bulk_read(r->regmap, BD70528_REG_RTC_ALM_START, &alm,
- sizeof(alm));
- if (ret) {
- dev_err(dev, "Failed to read alarm regs\n");
- return ret;
- }
-
- tm2rtc(&a->time, &alm.data);
- tmday2rtc(&a->time, &wake.time);
-
- if (a->enabled) {
- alm.alm_mask &= ~BD70528_MASK_ALM_EN;
- wake.ctrl |= BD70528_MASK_WAKE_EN;
- } else {
- alm.alm_mask |= BD70528_MASK_ALM_EN;
- wake.ctrl &= ~BD70528_MASK_WAKE_EN;
- }
-
- ret = regmap_bulk_write(r->regmap, BD70528_REG_RTC_WAKE_START, &wake,
- sizeof(wake));
- if (ret) {
- dev_err(dev, "Failed to set wake time\n");
- return ret;
- }
- ret = regmap_bulk_write(r->regmap, BD70528_REG_RTC_ALM_START, &alm,
- sizeof(alm));
- if (ret)
- dev_err(dev, "Failed to set alarm time\n");
-
- return ret;
-}
-
static int bd71828_read_alarm(struct device *dev, struct rtc_wkalrm *a)
{
int ret;
@@ -336,78 +157,28 @@ static int bd71828_read_alarm(struct device *dev, struct rtc_wkalrm *a)
return 0;
}
-static int bd70528_read_alarm(struct device *dev, struct rtc_wkalrm *a)
+static int bd71828_set_time(struct device *dev, struct rtc_time *t)
{
- struct bd70528_rtc_alm alm;
int ret;
- struct bd70528_rtc *r = dev_get_drvdata(dev);
-
- ret = regmap_bulk_read(r->regmap, BD70528_REG_RTC_ALM_START, &alm,
- sizeof(alm));
- if (ret) {
- dev_err(dev, "Failed to read alarm regs\n");
- return ret;
- }
-
- rtc2tm(&alm.data, &a->time);
- a->time.tm_mday = -1;
- a->time.tm_mon = -1;
- a->time.tm_year = -1;
- a->enabled = !(alm.alm_mask & BD70528_MASK_ALM_EN);
- a->pending = 0;
-
- return 0;
-}
-