Skip to content
Merged
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
27 changes: 27 additions & 0 deletions Documentation/devicetree/bindings/mfd/samsung,s2mpg14-pmic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,27 @@ description: |
Its LDO4M and LDO25M outputs supply the analog and digital touchscreen
power rails.

It has no interrupt line of its own: it reports events in-band, and the
SoC's VGPIO2AP system registers turn them into one level interrupt with a
pending latch that the host acknowledges, as for the S2MPG12. The
interrupt is optional: without it the PMIC still supplies its rails, but
none of its events, the RTC alarm among them, reach the host.

properties:
compatible:
const: samsung,s2mpg14-pmic

interrupts:
maxItems: 1

google,vgpio2ap-sysreg:
$ref: /schemas/types.yaml#/definitions/phandle
description:
Phandle to the VGPIO2AP system registers, which latch the PMIC's
in-band interrupt.

wakeup-source: true

regulators:
type: object
$ref: /schemas/regulator/samsung,s2mpg14-regulator.yaml
Expand All @@ -26,12 +43,22 @@ required:
- compatible
- regulators

dependencies:
interrupts: [ 'google,vgpio2ap-sysreg' ]
wakeup-source: [ interrupts ]

additionalProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/interrupt-controller/irq.h>

pmic-1 {
compatible = "samsung,s2mpg14-pmic";
interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>;
google,vgpio2ap-sysreg = <&sysreg_vgpio2ap>;
wakeup-source;

regulators {
ldo4m {
Expand Down
73 changes: 66 additions & 7 deletions drivers/mfd/sec-acpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ struct sec_pmic_acpm_platform_data {

/* No interrupt line is wired up for this PMIC (yet). */
bool no_irq;
/* The device tree may leave the interrupt line out. */
bool irq_optional;
};

static const struct regmap_range s2mpg10_common_registers[] = {
Expand Down Expand Up @@ -564,42 +566,47 @@ static const struct regmap_config s2mpg13_regmap_config_gpio = {
.cache_type = REGCACHE_NONE,
};

/* Expose only the touchscreen and eUSB2 supply controls. */
/* The revision and the in-band interrupt mask the driver writes. */
static const struct regmap_range s2mpg14_common_registers[] = {
regmap_reg_range(S2MPG14_COMMON_CHIPID, S2MPG14_COMMON_CHIPID),
regmap_reg_range(S2MPG14_COMMON_IBIM1, S2MPG14_COMMON_IBIM1),
};

static const struct regmap_access_table s2mpg14_common_rd_table = {
.yes_ranges = s2mpg14_common_registers,
.n_yes_ranges = ARRAY_SIZE(s2mpg14_common_registers),
};

static const struct regmap_range s2mpg14_common_no_writes[] = {
regmap_reg_range(0, S2MPG14_COMMON_CHIPID),
static const struct regmap_range s2mpg14_common_wr_registers[] = {
regmap_reg_range(S2MPG14_COMMON_IBIM1, S2MPG14_COMMON_IBIM1),
};

static const struct regmap_access_table s2mpg14_common_wr_table = {
.no_ranges = s2mpg14_common_no_writes,
.n_no_ranges = ARRAY_SIZE(s2mpg14_common_no_writes),
.yes_ranges = s2mpg14_common_wr_registers,
.n_yes_ranges = ARRAY_SIZE(s2mpg14_common_wr_registers),
};

static const struct regmap_config s2mpg14_regmap_config_common = {
.name = "common",
.reg_bits = ACPM_ADDR_BITS,
.val_bits = 8,
.max_register = S2MPG14_COMMON_CHIPID,
.max_register = S2MPG14_COMMON_IBIM1,
.rd_table = &s2mpg14_common_rd_table,
.wr_table = &s2mpg14_common_wr_table,
};

/* The interrupt block, the RTC alarm flag and the touchscreen and eUSB2 supply controls. */
static const struct regmap_range s2mpg14_pmic_rd_registers[] = {
regmap_reg_range(S2MPG14_PMIC_INT1, S2MPG14_PMIC_INT5M), /* interrupts and their masks */
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),
regmap_reg_range(S2MPG14_PMIC_L25M_CTRL, S2MPG14_PMIC_LDO_CTRL1),
};

static const struct regmap_range s2mpg14_pmic_wr_registers[] = {
regmap_reg_range(S2MPG14_PMIC_INT1M, S2MPG14_PMIC_INT5M),
regmap_reg_range(S2MPG14_PMIC_L4M_CTRL, S2MPG14_PMIC_L4M_CTRL),
regmap_reg_range(S2MPG14_PMIC_L9M_CTRL, S2MPG14_PMIC_L9M_CTRL),
regmap_reg_range(S2MPG14_PMIC_L19M_CTRL, S2MPG14_PMIC_L19M_CTRL),
Expand All @@ -616,13 +623,58 @@ static const struct regmap_access_table s2mpg14_pmic_wr_table = {
.n_yes_ranges = ARRAY_SIZE(s2mpg14_pmic_wr_registers),
};

static const struct regmap_range s2mpg14_pmic_precious_registers[] = {
regmap_reg_range(S2MPG14_PMIC_INT1, S2MPG14_PMIC_INT5), /* clear on read */
};

static const struct regmap_access_table s2mpg14_pmic_precious_table = {
.yes_ranges = s2mpg14_pmic_precious_registers,
.n_yes_ranges = ARRAY_SIZE(s2mpg14_pmic_precious_registers),
};

static const struct regmap_config s2mpg14_regmap_config_pmic = {
.name = "pmic",
.reg_bits = ACPM_ADDR_BITS,
.val_bits = 8,
.max_register = S2MPG14_PMIC_LDO_CTRL1,
.rd_table = &s2mpg14_pmic_rd_table,
.wr_table = &s2mpg14_pmic_wr_table,
.precious_table = &s2mpg14_pmic_precious_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,
};

/* The sub-PMIC's revision and the LDO controls its consumers use. */
Expand Down Expand Up @@ -806,6 +858,12 @@ static int sec_pmic_acpm_probe(struct platform_device *pdev)

if (pdata->no_irq) {
irq = 0;
} else if (pdata->irq_optional) {
irq = platform_get_irq_optional(pdev, 0);
if (irq == -ENXIO)
irq = 0;
else if (irq < 0)
return irq;
} else {
irq = platform_get_irq(pdev, 0);
if (irq < 0)
Expand Down Expand Up @@ -911,7 +969,8 @@ 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,
.no_irq = true,
.regmap_cfg_rtc = &s2mpg14_regmap_config_rtc,
.irq_optional = true,
};

static const struct sec_pmic_acpm_platform_data s2mpg15_data = {
Expand Down
25 changes: 22 additions & 3 deletions drivers/mfd/sec-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,23 @@ 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. */
static const struct resource s2mpg14_rtc_resources[] = {
DEFINE_RES_IRQ_NAMED(S2MPG14_IRQ_RTCA0, "alarm"),
};

/* The qualified LDOs and the RTC with its alarm; no GPIO or protection writes. */
static const struct mfd_cell s2mpg14_devs[] = {
MFD_CELL_NAME("s2mpg14-regulator"),
MFD_CELL_RES("s2mpg14-rtc", s2mpg14_rtc_resources),
};

/*
* Without an interrupt line there is no IRQ domain to map the alarm into,
* so the RTC comes up without the resource and keeps time without an alarm.
*/
static const struct mfd_cell s2mpg14_devs_no_irq[] = {
MFD_CELL_NAME("s2mpg14-regulator"),
MFD_CELL_NAME("s2mpg14-rtc"),
};

/* The sub-PMIC's LDOs; no interrupt, meter, GPIO or RTC. */
Expand Down Expand Up @@ -289,8 +303,13 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
num_sec_devs = ARRAY_SIZE(s2mpg13_devs);
break;
case S2MPG14:
sec_devs = s2mpg14_devs;
num_sec_devs = ARRAY_SIZE(s2mpg14_devs);
if (irq_data) {
sec_devs = s2mpg14_devs;
num_sec_devs = ARRAY_SIZE(s2mpg14_devs);
} else {
sec_devs = s2mpg14_devs_no_irq;
num_sec_devs = ARRAY_SIZE(s2mpg14_devs_no_irq);
}
break;
case S2MPG15:
sec_devs = s2mpg15_devs;
Expand Down
Loading