The RTC on the S2MPA01 is largely the same as that on other Samsung PMIC devices, so adding support for it just involves configuring it and describing the interrupt registers. Signed-off-by: Stuart Menefy <stuart.menefy@xxxxxxxxxxxxxxxx> --- drivers/mfd/sec-core.c | 2 ++ drivers/mfd/sec-irq.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/rtc/rtc-s5m.c | 15 ++++++++ 3 files changed, 114 insertions(+) diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c index e0835c9df7a1..911381414334 100644 --- a/drivers/mfd/sec-core.c +++ b/drivers/mfd/sec-core.c @@ -103,6 +103,8 @@ static const struct mfd_cell s2mps15_devs[] = { static const struct mfd_cell s2mpa01_devs[] = { { .name = "s2mpa01-pmic", + }, { + .name = "s2mpa01-rtc", }, }; diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c index ad0099077e7e..7cc863b07384 100644 --- a/drivers/mfd/sec-irq.c +++ b/drivers/mfd/sec-irq.c @@ -11,12 +11,96 @@ #include <linux/mfd/samsung/core.h> #include <linux/mfd/samsung/irq.h> +#include <linux/mfd/samsung/s2mpa01.h> #include <linux/mfd/samsung/s2mps11.h> #include <linux/mfd/samsung/s2mps14.h> #include <linux/mfd/samsung/s2mpu02.h> #include <linux/mfd/samsung/s5m8763.h> #include <linux/mfd/samsung/s5m8767.h> +static struct regmap_irq s2mpa01_irqs[] = { + [S2MPA01_IRQ_PWRONF] = { + .reg_offset = 0, + .mask = S2MPA01_IRQ_PWRONF_MASK, + }, + [S2MPA01_IRQ_PWRONR] = { + .reg_offset = 0, + .mask = S2MPA01_IRQ_PWRONR_MASK, + }, + [S2MPA01_IRQ_JIGONBF] = { + .reg_offset = 0, + .mask = S2MPA01_IRQ_JIGONBF_MASK, + }, + [S2MPA01_IRQ_JIGONBR] = { + .reg_offset = 0, + .mask = S2MPA01_IRQ_JIGONBR_MASK, + }, + [S2MPA01_IRQ_ACOKBF] = { + .reg_offset = 0, + .mask = S2MPA01_IRQ_ACOKBF_MASK, + }, + [S2MPA01_IRQ_ACOKBR] = { + .reg_offset = 0, + .mask = S2MPA01_IRQ_ACOKBR_MASK, + }, + [S2MPA01_IRQ_PWRON1S] = { + .reg_offset = 0, + .mask = S2MPA01_IRQ_PWRON1S_MASK, + }, + [S2MPA01_IRQ_MRB] = { + .reg_offset = 0, + .mask = S2MPA01_IRQ_MRB_MASK, + }, + [S2MPA01_IRQ_RTC60S] = { + .reg_offset = 1, + .mask = S2MPA01_IRQ_RTC60S_MASK, + }, + [S2MPA01_IRQ_RTCA1] = { + .reg_offset = 1, + .mask = S2MPA01_IRQ_RTCA1_MASK, + }, + [S2MPA01_IRQ_RTCA0] = { + .reg_offset = 1, + .mask = S2MPA01_IRQ_RTCA0_MASK, + }, + [S2MPA01_IRQ_SMPL] = { + .reg_offset = 1, + .mask = S2MPA01_IRQ_SMPL_MASK, + }, + [S2MPA01_IRQ_RTC1S] = { + .reg_offset = 1, + .mask = S2MPA01_IRQ_RTC1S_MASK, + }, + [S2MPA01_IRQ_WTSR] = { + .reg_offset = 1, + .mask = S2MPA01_IRQ_WTSR_MASK, + }, + [S2MPA01_IRQ_INT120C] = { + .reg_offset = 2, + .mask = S2MPA01_IRQ_INT120C_MASK, + }, + [S2MPA01_IRQ_INT140C] = { + .reg_offset = 2, + .mask = S2MPA01_IRQ_INT140C_MASK, + }, + [S2MPA01_IRQ_LDO3_TSD] = { + .reg_offset = 2, + .mask = S2MPA01_IRQ_LDO3_TSD_MASK, + }, + [S2MPA01_IRQ_B16_TSD] = { + .reg_offset = 2, + .mask = S2MPA01_IRQ_B16_TSD_MASK, + }, + [S2MPA01_IRQ_B24_TSD] = { + .reg_offset = 2, + .mask = S2MPA01_IRQ_B24_TSD_MASK, + }, + [S2MPA01_IRQ_B35_TSD] = { + .reg_offset = 2, + .mask = S2MPA01_IRQ_B35_TSD_MASK, + }, +}; + static const struct regmap_irq s2mps11_irqs[] = { [S2MPS11_IRQ_PWRONF] = { .reg_offset = 0, @@ -372,6 +456,16 @@ static const struct regmap_irq s5m8763_irqs[] = { }, }; +static struct regmap_irq_chip s2mpa01_irq_chip = { + .name = "s2mpa01", + .irqs = s2mpa01_irqs, + .num_irqs = ARRAY_SIZE(s2mpa01_irqs), + .num_regs = 3, + .status_base = S2MPA01_REG_INT1, + .mask_base = S2MPA01_REG_INT1M, + .ack_base = S2MPA01_REG_INT1, +}; + static const struct regmap_irq_chip s2mps11_irq_chip = { .name = "s2mps11", .irqs = s2mps11_irqs, @@ -455,6 +549,9 @@ int sec_irq_init(struct sec_pmic_dev *sec_pmic) case S5M8767X: sec_irq_chip = &s5m8767_irq_chip; break; + case S2MPA01: + sec_irq_chip = &s2mpa01_irq_chip; + break; case S2MPS11X: sec_irq_chip = &s2mps11_irq_chip; break; diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c index c7f1bf823ea0..0f7623a57e74 100644 --- a/drivers/rtc/rtc-s5m.c +++ b/drivers/rtc/rtc-s5m.c @@ -246,6 +246,7 @@ static int s5m_check_peding_alarm_interrupt(struct s5m_rtc_info *info, ret = regmap_read(info->regmap, S5M_RTC_STATUS, &val); val &= S5M_ALARM0_STATUS; break; + case S2MPA01: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -309,6 +310,7 @@ static int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info *info) case S5M8767X: data &= ~S5M_RTC_TIME_EN_MASK; break; + case S2MPA01: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -396,6 +398,7 @@ static int s5m_rtc_read_time(struct device *dev, struct rtc_time *tm) break; case S5M8767X: + case S2MPA01: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -422,6 +425,7 @@ static int s5m_rtc_set_time(struct device *dev, struct rtc_time *tm) s5m8763_tm_to_data(tm, data); break; case S5M8767X: + case S2MPA01: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -469,6 +473,7 @@ static int s5m_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) break; case S5M8767X: + case S2MPA01: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -513,6 +518,7 @@ static int s5m_rtc_stop_alarm(struct s5m_rtc_info *info) break; case S5M8767X: + case S2MPA01: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -557,6 +563,7 @@ static int s5m_rtc_start_alarm(struct s5m_rtc_info *info) break; case S5M8767X: + case S2MPA01: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -598,6 +605,7 @@ static int s5m_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) break; case S5M8767X: + case S2MPA01: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -679,6 +687,7 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info) ret = regmap_raw_write(info->regmap, S5M_ALARM0_CONF, data, 2); break; + case S2MPA01: case S2MPS15X: case S2MPS14X: case S2MPS13X: @@ -728,6 +737,11 @@ static int s5m_rtc_probe(struct platform_device *pdev) return -ENOMEM; switch (platform_get_device_id(pdev)->driver_data) { + case S2MPA01: + regmap_cfg = &s2mps14_rtc_regmap_config; + info->regs = &s2mps14_rtc_regs; + alarm_irq = S2MPA01_IRQ_RTCA0; + break; case S2MPS15X: regmap_cfg = &s2mps14_rtc_regmap_config; info->regs = &s2mps15_rtc_regs; @@ -861,6 +875,7 @@ static SIMPLE_DEV_PM_OPS(s5m_rtc_pm_ops, s5m_rtc_suspend, s5m_rtc_resume); static const struct platform_device_id s5m_rtc_id[] = { { "s5m-rtc", S5M8767X }, + { "s2mpa01-rtc", S2MPA01 }, { "s2mps13-rtc", S2MPS13X }, { "s2mps14-rtc", S2MPS14X }, { "s2mps15-rtc", S2MPS15X }, -- 2.13.6