Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions drivers/mfd/sec-acpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ static const struct regmap_config s2mpg14_regmap_config_common = {
};

static const struct regmap_range s2mpg14_pmic_rd_registers[] = {
regmap_reg_range(S2MPG14_PMIC_STATUS2, S2MPG14_PMIC_STATUS2), /* RTC alarm flag */
regmap_reg_range(S2MPG14_PMIC_L4M_CTRL, S2MPG14_PMIC_L4M_CTRL),
regmap_reg_range(S2MPG14_PMIC_L8M_CTRL, S2MPG14_PMIC_L9M_CTRL),
regmap_reg_range(S2MPG14_PMIC_L19M_CTRL, S2MPG14_PMIC_L19M_CTRL),
Expand Down Expand Up @@ -624,6 +625,41 @@ static const struct regmap_config s2mpg14_regmap_config_pmic = {
.wr_table = &s2mpg14_pmic_wr_table,
};

/*
* The RTC: everything up to the oscillator control may be read. Writes
* only where rtc-s5m writes: CTRL, UPDATE, the time and alarm 0. SMPL,
* WTSR, CAP_SEL and OSC_CTRL (the power-loss and watchdog-reset
* protections and the oscillator tuning) stay read-only.
*/
static const struct regmap_range s2mpg14_rtc_rd_registers[] = {
regmap_reg_range(S2MPG10_RTC_CTRL, S2MPG10_RTC_OSC_CTRL),
};

static const struct regmap_access_table s2mpg14_rtc_rd_table = {
.yes_ranges = s2mpg14_rtc_rd_registers,
.n_yes_ranges = ARRAY_SIZE(s2mpg14_rtc_rd_registers),
};

static const struct regmap_range s2mpg14_rtc_wr_registers[] = {
regmap_reg_range(S2MPG10_RTC_CTRL, S2MPG10_RTC_UPDATE),
regmap_reg_range(S2MPG10_RTC_SEC, S2MPG10_RTC_A0YEAR),
};

static const struct regmap_access_table s2mpg14_rtc_wr_table = {
.yes_ranges = s2mpg14_rtc_wr_registers,
.n_yes_ranges = ARRAY_SIZE(s2mpg14_rtc_wr_registers),
};

static const struct regmap_config s2mpg14_regmap_config_rtc = {
.name = "rtc",
.reg_bits = ACPM_ADDR_BITS,
.val_bits = 8,
.max_register = S2MPG10_RTC_OSC_CTRL,
.rd_table = &s2mpg14_rtc_rd_table,
.wr_table = &s2mpg14_rtc_wr_table,
.cache_type = REGCACHE_NONE,
};

struct sec_pmic_acpm_shared_bus_context {
struct acpm_handle *acpm;
unsigned int acpm_chan_id;
Expand Down Expand Up @@ -858,6 +894,7 @@ static const struct sec_pmic_acpm_platform_data s2mpg14_data = {
.speedy_channel = 0,
.regmap_cfg_common = &s2mpg14_regmap_config_common,
.regmap_cfg_pmic = &s2mpg14_regmap_config_pmic,
.regmap_cfg_rtc = &s2mpg14_regmap_config_rtc,
.no_irq = true,
};

Expand Down
6 changes: 5 additions & 1 deletion drivers/mfd/sec-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ static const struct mfd_cell s2mpg13_devs[] = {
MFD_CELL_OF("s2mpg13-gpio", NULL, NULL, 0, 0, "samsung,s2mpg13-gpio"),
};

/* Only the qualified LDOs; no RTC, interrupt, GPIO or protection writes. */
/*
* The qualified LDOs and the RTC. No interrupt line is described yet, so
* the RTC keeps time without an alarm; no GPIO or protection writes.
*/
static const struct mfd_cell s2mpg14_devs[] = {
MFD_CELL_NAME("s2mpg14-regulator"),
MFD_CELL_NAME("s2mpg14-rtc"),
};

static const struct resource s2mps11_rtc_resources[] = {
Expand Down
20 changes: 18 additions & 2 deletions drivers/rtc/rtc-s5m.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/mfd/samsung/core.h>
#include <linux/mfd/samsung/rtc.h>
#include <linux/mfd/samsung/s2mpg12.h>
#include <linux/mfd/samsung/s2mpg14.h>
#include <linux/mfd/samsung/s2mps14.h>

/*
Expand Down Expand Up @@ -259,6 +260,11 @@ static int s5m_check_pending_alarm_interrupt(struct s5m_rtc_info *info,
&val);
val &= S2MPG12_STATUS2_RTCA0E;
break;
case S2MPG14:
ret = regmap_read(info->s5m87xx->regmap_pmic, S2MPG14_PMIC_STATUS2,
&val);
val &= S2MPG14_STATUS2_RTCA0E;
break;
case S2MPG10:
case S2MPS15X:
case S2MPS14X:
Expand Down Expand Up @@ -309,6 +315,7 @@ static int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info *info)
break;
case S2MPG10:
case S2MPG12:
case S2MPG14:
case S2MPS15X:
case S2MPS14X:
case S2MPS13X:
Expand Down Expand Up @@ -361,6 +368,7 @@ static int s5m_rtc_read_time(struct device *dev, struct rtc_time *tm)
case S5M8767X:
case S2MPG10:
case S2MPG12:
case S2MPG14:
case S2MPS15X:
case S2MPS14X:
case S2MPS13X:
Expand All @@ -386,6 +394,7 @@ static int s5m_rtc_set_time(struct device *dev, struct rtc_time *tm)
case S5M8767X:
case S2MPG10:
case S2MPG12:
case S2MPG14:
case S2MPS15X:
case S2MPS14X:
case S2MPS13X:
Expand Down Expand Up @@ -425,6 +434,7 @@ static int s5m_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
case S5M8767X:
case S2MPG10:
case S2MPG12:
case S2MPG14:
case S2MPS15X:
case S2MPS14X:
case S2MPS13X:
Expand Down Expand Up @@ -465,6 +475,7 @@ static int s5m_rtc_stop_alarm(struct s5m_rtc_info *info)
case S5M8767X:
case S2MPG10:
case S2MPG12:
case S2MPG14:
case S2MPS15X:
case S2MPS14X:
case S2MPS13X:
Expand Down Expand Up @@ -505,6 +516,7 @@ static int s5m_rtc_start_alarm(struct s5m_rtc_info *info)
case S5M8767X:
case S2MPG10:
case S2MPG12:
case S2MPG14:
case S2MPS15X:
case S2MPS14X:
case S2MPS13X:
Expand Down Expand Up @@ -544,6 +556,7 @@ static int s5m_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
case S5M8767X:
case S2MPG10:
case S2MPG12:
case S2MPG14:
case S2MPS15X:
case S2MPS14X:
case S2MPS13X:
Expand Down Expand Up @@ -626,6 +639,7 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info)

case S2MPG10:
case S2MPG12:
case S2MPG14:
case S2MPS15X:
case S2MPS14X:
case S2MPS13X:
Expand Down Expand Up @@ -726,8 +740,9 @@ static int s5m_rtc_probe(struct platform_device *pdev)
if (IS_ERR(info->regmap))
return dev_err_probe(&pdev->dev, PTR_ERR(info->regmap),
"Failed to allocate regmap\n");
} else if (device_type == S2MPG10 || device_type == S2MPG12) {
/* S2MPG12's RTC has the same registers as S2MPG10's */
} else if (device_type == S2MPG10 || device_type == S2MPG12 ||
device_type == S2MPG14) {
/* S2MPG12's and S2MPG14's RTCs have S2MPG10's registers */
info->regs = &s2mpg10_rtc_regs;
} else {
return dev_err_probe(&pdev->dev, -ENODEV,
Expand Down Expand Up @@ -825,6 +840,7 @@ static const struct platform_device_id s5m_rtc_id[] = {
{ .name = "s5m-rtc", .driver_data = S5M8767X },
{ .name = "s2mpg10-rtc", .driver_data = S2MPG10 },
{ .name = "s2mpg12-rtc", .driver_data = S2MPG12 },
{ .name = "s2mpg14-rtc", .driver_data = S2MPG14 },
{ .name = "s2mps13-rtc", .driver_data = S2MPS13X },
{ .name = "s2mps14-rtc", .driver_data = S2MPS14X },
{ .name = "s2mps15-rtc", .driver_data = S2MPS15X },
Expand Down
12 changes: 12 additions & 0 deletions include/linux/mfd/samsung/s2mpg14.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@
#ifndef __LINUX_MFD_S2MPG14_H
#define __LINUX_MFD_S2MPG14_H

#include <linux/bits.h>

#define S2MPG14_COMMON_CHIPID 0x0b
#define S2MPG14_PMIC_STATUS2 0x0b
#define S2MPG14_PMIC_L4M_CTRL 0x2e
#define S2MPG14_PMIC_L8M_CTRL 0x32
#define S2MPG14_PMIC_L9M_CTRL 0x33
#define S2MPG14_PMIC_L19M_CTRL 0x3d
#define S2MPG14_PMIC_L25M_CTRL 0x43
#define S2MPG14_PMIC_LDO_CTRL1 0x44

/* S2MPG14_PMIC_STATUS2: the alarm flag sits where it does on S2MPG12 */
#define S2MPG14_STATUS2_RTCA0E BIT(2)

/*
* The RTC block has S2MPG10's register layout (S2MPG10_RTC_* in rtc.h):
* CTRL at 0x00 through OSC_CTRL at 0x1b, then two nonces to 0x2b and
* five scratch registers to 0x30.
*/

#endif /* __LINUX_MFD_S2MPG14_H */