diff --git a/Documentation/devicetree/bindings/mfd/samsung,s2mpg15-pmic.yaml b/Documentation/devicetree/bindings/mfd/samsung,s2mpg15-pmic.yaml new file mode 100644 index 0000000000..90d7e84423 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/samsung,s2mpg15-pmic.yaml @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/samsung,s2mpg15-pmic.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S2MPG15 Power Management IC + +maintainers: + - W4HO <87742609+W4HO-ham@users.noreply.github.com> + +description: | + S2MPG15 is the sub PMIC paired with Google's Tensor G4 and is reached + through ACPM. Its LDOs supply the AoC sensors, the GNSS receiver, the + camera sensors and the fingerprint sensor. + Interrupt, meter, GPIO and RTC functions are not described here. + +properties: + compatible: + const: samsung,s2mpg15-pmic + + regulators: + type: object + $ref: /schemas/regulator/samsung,s2mpg15-regulator.yaml + +required: + - compatible + - regulators + +additionalProperties: false + +examples: + - | + pmic-2 { + compatible = "samsung,s2mpg15-pmic"; + + regulators { + ldo5s { + regulator-name = "sensor-3v3"; + }; + + ldo7s { + regulator-name = "sensor-1v8"; + }; + }; + }; diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2mpg15-regulator.yaml b/Documentation/devicetree/bindings/regulator/samsung,s2mpg15-regulator.yaml new file mode 100644 index 0000000000..4134157536 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/samsung,s2mpg15-regulator.yaml @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/samsung,s2mpg15-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S2MPG15 Power Management IC regulators + +maintainers: + - W4HO <87742609+W4HO-ham@users.noreply.github.com> + +description: | + The sub-PMIC paired with Google's Tensor G4. LDO5S and LDO7S supply the + AoC sensors, LDO9S, LDO10S and LDO11S the GNSS receiver's core, RF front + end and auxiliary supply, LDO12S the camera sensors' 1.8 V and LDO15S the + fingerprint sensor's 3.3 V. Enable control and voltage readback are + supported; the firmware's voltage selections are preserved. + +patternProperties: + "^ldo(5|7|9|10|11|12|15)s$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + properties: + regulator-ramp-delay: false + +additionalProperties: false diff --git a/drivers/mfd/sec-acpm.c b/drivers/mfd/sec-acpm.c index 05efc8cf5d..ef1834d7b0 100644 --- a/drivers/mfd/sec-acpm.c +++ b/drivers/mfd/sec-acpm.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -624,6 +625,58 @@ static const struct regmap_config s2mpg14_regmap_config_pmic = { .wr_table = &s2mpg14_pmic_wr_table, }; +/* The sub-PMIC's revision and the LDO controls its consumers use. */ +static const struct regmap_range s2mpg15_common_registers[] = { + regmap_reg_range(S2MPG15_COMMON_CHIPID, S2MPG15_COMMON_CHIPID), +}; + +static const struct regmap_access_table s2mpg15_common_rd_table = { + .yes_ranges = s2mpg15_common_registers, + .n_yes_ranges = ARRAY_SIZE(s2mpg15_common_registers), +}; + +static const struct regmap_range s2mpg15_common_no_writes[] = { + regmap_reg_range(0, S2MPG15_COMMON_CHIPID), +}; + +static const struct regmap_access_table s2mpg15_common_wr_table = { + .no_ranges = s2mpg15_common_no_writes, + .n_no_ranges = ARRAY_SIZE(s2mpg15_common_no_writes), +}; + +static const struct regmap_config s2mpg15_regmap_config_common = { + .name = "common", + .reg_bits = ACPM_ADDR_BITS, + .val_bits = 8, + .max_register = S2MPG15_COMMON_CHIPID, + .rd_table = &s2mpg15_common_rd_table, + .wr_table = &s2mpg15_common_wr_table, + .cache_type = REGCACHE_NONE, +}; + +static const struct regmap_range s2mpg15_pmic_registers[] = { + regmap_reg_range(S2MPG15_PMIC_L5S_CTRL, S2MPG15_PMIC_L5S_CTRL), + regmap_reg_range(S2MPG15_PMIC_L7S_CTRL, S2MPG15_PMIC_L7S_CTRL), + regmap_reg_range(S2MPG15_PMIC_L9S_CTRL, S2MPG15_PMIC_L11S_CTRL), + regmap_reg_range(S2MPG15_PMIC_L12S_CTRL, S2MPG15_PMIC_L12S_CTRL), + regmap_reg_range(S2MPG15_PMIC_L15S_CTRL, S2MPG15_PMIC_L15S_CTRL), +}; + +static const struct regmap_access_table s2mpg15_pmic_table = { + .yes_ranges = s2mpg15_pmic_registers, + .n_yes_ranges = ARRAY_SIZE(s2mpg15_pmic_registers), +}; + +static const struct regmap_config s2mpg15_regmap_config_pmic = { + .name = "pmic", + .reg_bits = ACPM_ADDR_BITS, + .val_bits = 8, + .max_register = S2MPG15_PMIC_L15S_CTRL, + .rd_table = &s2mpg15_pmic_table, + .wr_table = &s2mpg15_pmic_table, + .cache_type = REGCACHE_NONE, +}; + struct sec_pmic_acpm_shared_bus_context { struct acpm_handle *acpm; unsigned int acpm_chan_id; @@ -861,12 +914,22 @@ static const struct sec_pmic_acpm_platform_data s2mpg14_data = { .no_irq = true, }; +static const struct sec_pmic_acpm_platform_data s2mpg15_data = { + .device_type = S2MPG15, + .acpm_chan_id = 2, + .speedy_channel = 1, + .regmap_cfg_common = &s2mpg15_regmap_config_common, + .regmap_cfg_pmic = &s2mpg15_regmap_config_pmic, + .no_irq = true, +}; + static const struct of_device_id sec_pmic_acpm_of_match[] = { { .compatible = "samsung,s2mpg10-pmic", .data = &s2mpg10_data, }, { .compatible = "samsung,s2mpg11-pmic", .data = &s2mpg11_data, }, { .compatible = "samsung,s2mpg12-pmic", .data = &s2mpg12_data, }, { .compatible = "samsung,s2mpg13-pmic", .data = &s2mpg13_data, }, { .compatible = "samsung,s2mpg14-pmic", .data = &s2mpg14_data, }, + { .compatible = "samsung,s2mpg15-pmic", .data = &s2mpg15_data, }, { }, }; MODULE_DEVICE_TABLE(of, sec_pmic_acpm_of_match); diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c index a81ed6cb00..e6660b6aaf 100644 --- a/drivers/mfd/sec-common.c +++ b/drivers/mfd/sec-common.c @@ -80,6 +80,11 @@ static const struct mfd_cell s2mpg14_devs[] = { MFD_CELL_NAME("s2mpg14-regulator"), }; +/* The sub-PMIC's LDOs; no interrupt, meter, GPIO or RTC. */ +static const struct mfd_cell s2mpg15_devs[] = { + MFD_CELL_NAME("s2mpg15-regulator"), +}; + static const struct resource s2mps11_rtc_resources[] = { DEFINE_RES_IRQ_NAMED(S2MPS11_IRQ_RTCA0, "alarm"), }; @@ -152,6 +157,7 @@ static void sec_pmic_dump_rev(struct sec_pmic_dev *sec_pmic) case S2MPG12: case S2MPG13: case S2MPG14: + case S2MPG15: /* For s2mpg1x, the revision is in a different regmap */ return; case S2MU005: @@ -286,6 +292,10 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq, sec_devs = s2mpg14_devs; num_sec_devs = ARRAY_SIZE(s2mpg14_devs); break; + case S2MPG15: + sec_devs = s2mpg15_devs; + num_sec_devs = ARRAY_SIZE(s2mpg15_devs); + break; case S2MPS11X: sec_devs = s2mps11_devs; num_sec_devs = ARRAY_SIZE(s2mps11_devs); diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c index 9eb38cf7ab..dc6114b149 100644 --- a/drivers/mfd/sec-irq.c +++ b/drivers/mfd/sec-irq.c @@ -615,6 +615,7 @@ struct regmap_irq_chip_data *sec_irq_init(struct sec_pmic_dev *sec_pmic) return sec_irq_init_s2mpg12(sec_pmic); case S2MPG13: case S2MPG14: + case S2MPG15: /* No interrupt line described for it yet: LDOs only. */ return NULL; case S2MPS11X: diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index e8ddc34aee..647b46c75a 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -2365,6 +2366,139 @@ static const struct regulator_desc s2mpg14_regulators[] = { }, }; +/* + * S2MPG15 (the Tensor G4's sub-PMIC): the LDOs Linux consumers use, from + * Google's GPL s2mpg15-regulator.c (voltage groups 7, 6, 5, 6, 6, 6 and 7). + */ +static const struct regulator_desc s2mpg15_regulators[] = { + { + /* AoC sensors, 3.3 V */ + .name = "ldo5s", + .id = 4, + .of_match = of_match_ptr("ldo5s"), + .regulators_node = of_match_ptr("regulators"), + .ops = &s2mpg14_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .min_uV = 1800000, + .uV_step = 25000, + .n_voltages = 64, + .vsel_reg = S2MPG15_PMIC_L5S_CTRL, + .vsel_mask = GENMASK(5, 0), + .enable_reg = S2MPG15_PMIC_L5S_CTRL, + .enable_mask = BIT(7), + .enable_time = 128, + }, + { + /* AoC sensors, 1.8 V */ + .name = "ldo7s", + .id = 6, + .of_match = of_match_ptr("ldo7s"), + .regulators_node = of_match_ptr("regulators"), + .ops = &s2mpg14_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .min_uV = 700000, + .uV_step = 25000, + .n_voltages = 64, + .vsel_reg = S2MPG15_PMIC_L7S_CTRL, + .vsel_mask = GENMASK(5, 0), + .enable_reg = S2MPG15_PMIC_L7S_CTRL, + .enable_mask = BIT(7), + .enable_time = 128, + }, + { + /* the GNSS core */ + .name = "ldo9s", + .id = 8, + .of_match = of_match_ptr("ldo9s"), + .regulators_node = of_match_ptr("regulators"), + .ops = &s2mpg14_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .min_uV = 725000, + .uV_step = 12500, + .n_voltages = 64, + .vsel_reg = S2MPG15_PMIC_L9S_CTRL, + .vsel_mask = GENMASK(5, 0), + .enable_reg = S2MPG15_PMIC_L9S_CTRL, + .enable_mask = BIT(7), + .enable_time = 128, + }, + { + /* the GNSS RF front end */ + .name = "ldo10s", + .id = 9, + .of_match = of_match_ptr("ldo10s"), + .regulators_node = of_match_ptr("regulators"), + .ops = &s2mpg14_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .min_uV = 700000, + .uV_step = 25000, + .n_voltages = 64, + .vsel_reg = S2MPG15_PMIC_L10S_CTRL, + .vsel_mask = GENMASK(5, 0), + .enable_reg = S2MPG15_PMIC_L10S_CTRL, + .enable_mask = BIT(7), + .enable_time = 128, + }, + { + /* the GNSS auxiliary supply */ + .name = "ldo11s", + .id = 10, + .of_match = of_match_ptr("ldo11s"), + .regulators_node = of_match_ptr("regulators"), + .ops = &s2mpg14_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .min_uV = 700000, + .uV_step = 25000, + .n_voltages = 64, + .vsel_reg = S2MPG15_PMIC_L11S_CTRL, + .vsel_mask = GENMASK(5, 0), + .enable_reg = S2MPG15_PMIC_L11S_CTRL, + .enable_mask = BIT(7), + .enable_time = 128, + }, + { + /* the camera sensors' shared 1.8 V */ + .name = "ldo12s", + .id = 11, + .of_match = of_match_ptr("ldo12s"), + .regulators_node = of_match_ptr("regulators"), + .ops = &s2mpg14_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .min_uV = 700000, + .uV_step = 25000, + .n_voltages = 64, + .vsel_reg = S2MPG15_PMIC_L12S_CTRL, + .vsel_mask = GENMASK(5, 0), + .enable_reg = S2MPG15_PMIC_L12S_CTRL, + .enable_mask = BIT(7), + .enable_time = 128, + }, + { + /* the fingerprint sensor's 3.3 V */ + .name = "ldo15s", + .id = 14, + .of_match = of_match_ptr("ldo15s"), + .regulators_node = of_match_ptr("regulators"), + .ops = &s2mpg14_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .min_uV = 1800000, + .uV_step = 25000, + .n_voltages = 64, + .vsel_reg = S2MPG15_PMIC_L15S_CTRL, + .vsel_mask = GENMASK(5, 0), + .enable_reg = S2MPG15_PMIC_L15S_CTRL, + .enable_mask = BIT(7), + .enable_time = 128, + }, +}; + static int s2mps11_handle_ext_control(struct s2mps11_info *s2mps11, struct regulator_dev *rdev) { @@ -2452,6 +2586,10 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) rdev_num = ARRAY_SIZE(s2mpg14_regulators); regulators = s2mpg14_regulators; break; + case S2MPG15: + rdev_num = ARRAY_SIZE(s2mpg15_regulators); + regulators = s2mpg15_regulators; + break; case S2MPS11X: rdev_num = ARRAY_SIZE(s2mps11_regulators); regulators = s2mps11_regulators; @@ -2515,7 +2653,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) else rdesc = ®ulators[i]; - if (s2mps11->dev_type == S2MPG14 && + if ((s2mps11->dev_type == S2MPG14 || s2mps11->dev_type == S2MPG15) && !s2mpg14_regulator_is_described(&pdev->dev, rdesc)) continue; @@ -2540,6 +2678,7 @@ static const struct platform_device_id s2mps11_pmic_id[] = { { .name = "s2mpg12-regulator", .driver_data = S2MPG12 }, { .name = "s2mpg13-regulator", .driver_data = S2MPG13 }, { .name = "s2mpg14-regulator", .driver_data = S2MPG14 }, + { .name = "s2mpg15-regulator", .driver_data = S2MPG15 }, { .name = "s2mps11-regulator", .driver_data = S2MPS11X }, { .name = "s2mps13-regulator", .driver_data = S2MPS13X }, { .name = "s2mps14-regulator", .driver_data = S2MPS14X }, diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h index 4c66784451..bc5ffa61f9 100644 --- a/include/linux/mfd/samsung/core.h +++ b/include/linux/mfd/samsung/core.h @@ -44,6 +44,7 @@ enum sec_device_type { S2MPG12, S2MPG13, S2MPG14, + S2MPG15, S2MPS11X, S2MPS13X, S2MPS14X, diff --git a/include/linux/mfd/samsung/s2mpg15.h b/include/linux/mfd/samsung/s2mpg15.h new file mode 100644 index 0000000000..de66ce7f91 --- /dev/null +++ b/include/linux/mfd/samsung/s2mpg15.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * S2MPG15 register definitions derived from Google's GPL Samsung driver. + * Copyright (C) 2022 Samsung Electronics + */ +#ifndef __LINUX_MFD_S2MPG15_H +#define __LINUX_MFD_S2MPG15_H + +#define S2MPG15_COMMON_CHIPID 0x0b +#define S2MPG15_PMIC_L5S_CTRL 0x33 +#define S2MPG15_PMIC_L7S_CTRL 0x35 +#define S2MPG15_PMIC_L9S_CTRL 0x37 +#define S2MPG15_PMIC_L10S_CTRL 0x38 +#define S2MPG15_PMIC_L11S_CTRL 0x39 +#define S2MPG15_PMIC_L12S_CTRL 0x3a +#define S2MPG15_PMIC_L15S_CTRL 0x3d + +#endif /* __LINUX_MFD_S2MPG15_H */