linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/3] Add Samsung s2dos05 pmic support
@ 2024-09-26  9:47 Dzmitry Sankouski
  2024-09-26  9:47 ` [PATCH v5 1/3] dt-bindings: mfd: add samsung,s2dos05 Dzmitry Sankouski
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Dzmitry Sankouski @ 2024-09-26  9:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Rob Herring, Conor Dooley,
	Liam Girdwood, Mark Brown
  Cc: linux-kernel, linux-samsung-soc, devicetree, Dzmitry Sankouski

The S2DOS05 is a companion power management IC for the panel and touchscreen
in smart phones. Provides voltage regulators and
ADC for power/current measurements.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
Changes in v5:
- Split patchset per subsystem
- Rewrite cover letter
- Link to v4: https://lore.kernel.org/r/20240913-starqltechn_integration_upstream-v4-0-2d2efd5c5877@gmail.com

Changes in v4:
- Rewrite max77705, max77705_charger, max77705_fuel_gauge from scratch
- Reorder patches:
  - squash max77705 subdevice bindings in core file because
    no resources there
  - split device tree changes
- Use _ as space for filenames in power/supply like the majority
- Replace gcc-845 freq_tbl frequencies patch with new approach,
  based on automatic m/n/pre_div value generation
- Link to v3: https://lore.kernel.org/r/20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com

Changes in version 3:
- s2dos05 driver converted to MFD

Changes in version 2:
- s2dos05 regulator:
  - hex to decimal in regulator values
  - fix compatible value
  - remove interrupt specific code, because it's
    empty in vendor kernel, and I cannot test it on
    available hardware anyway.

---
Dzmitry Sankouski (3):
      dt-bindings: mfd: add samsung,s2dos05
      mfd: sec-core: add s2dos05 support
      regulator: add s2dos05 regulator support

 Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml |  99 ++++++++++++++++++++++++++++++++++++++
 MAINTAINERS                                                |   4 +-
 drivers/mfd/sec-core.c                                     |  11 +++++
 drivers/regulator/Kconfig                                  |   8 ++++
 drivers/regulator/Makefile                                 |   1 +
 drivers/regulator/s2dos05-regulator.c                      | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/samsung/core.h                           |   1 +
 include/linux/regulator/s2dos05.h                          |  73 ++++++++++++++++++++++++++++
 8 files changed, 371 insertions(+), 2 deletions(-)
---
base-commit: 92fc9636d1471b7f68bfee70c776f7f77e747b97
change-id: 20240617-starqltechn_integration_upstream-bc86850b2fe3

Best regards,
-- 
Dzmitry Sankouski <dsankouski@gmail.com>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v5 1/3] dt-bindings: mfd: add samsung,s2dos05
  2024-09-26  9:47 [PATCH v5 0/3] Add Samsung s2dos05 pmic support Dzmitry Sankouski
@ 2024-09-26  9:47 ` Dzmitry Sankouski
  2024-09-27  8:48   ` Krzysztof Kozlowski
  2024-09-26  9:47 ` [PATCH v5 2/3] mfd: sec-core: add s2dos05 support Dzmitry Sankouski
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Dzmitry Sankouski @ 2024-09-26  9:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Rob Herring, Conor Dooley,
	Liam Girdwood, Mark Brown
  Cc: linux-kernel, linux-samsung-soc, devicetree, Dzmitry Sankouski

Add samsung,s2dos05 MFD module binding.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>

---
Changes in v4:
- split long(>80) lines
- fix indentation
- merge with regulators binding
- drop pmic suffix
- drop unused labels in example
- correct description

Changes in v5:
- simplify regulator-name in examples
- remove index from single buck regulator
- fix example indentation
- replace example hex numbers to decimal
---
 Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 MAINTAINERS                                                |  2 +-
 2 files changed, 100 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml b/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml
new file mode 100644
index 000000000000..b85285720c16
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/samsung,s2dos05.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Samsung S2DOS05 Power Management IC
+
+maintainers:
+  - Dzmitry Sankouski <dsankouski@gmail.com>
+
+description:
+  This is a device tree bindings for S2DOS family of Power Management IC (PMIC).
+
+  The S2DOS05 is a companion power management IC for the panel and touchscreen
+  in smart phones. Provides voltage regulators and
+  ADC for power/current measurements.
+
+  Regulator section has 4 LDO and 1 BUCK regulators and also
+  provides ELVDD, ELVSS, AVDD lines.
+
+properties:
+  compatible:
+    const: samsung,s2dos05
+
+  reg:
+    maxItems: 1
+
+  regulators:
+    patternProperties:
+      "^buck|ldo[1-4]$":
+        type: object
+        $ref: /schemas/regulator/regulator.yaml#
+        unevaluatedProperties: false
+
+        required:
+          - regulator-name
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - regulators
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pmic@60 {
+            compatible = "samsung,s2dos05";
+            reg = <0x60>;
+
+            regulators {
+                ldo1 {
+                    regulator-active-discharge = <1>;
+                    regulator-min-microvolt = <1500000>;
+                    regulator-max-microvolt = <2000000>;
+                    regulator-name = "ldo1";
+                };
+
+                ldo2 {
+                    regulator-active-discharge = <1>;
+                    regulator-boot-on;
+                    regulator-min-microvolt = <1800000>;
+                    regulator-max-microvolt = <1800000>;
+                    regulator-name = "ldo2";
+                };
+
+                ldo3 {
+                    regulator-active-discharge = <1>;
+                    regulator-boot-on;
+                    regulator-min-microvolt = <3000000>;
+                    regulator-max-microvolt = <3000000>;
+                    regulator-name = "ldo3";
+                };
+
+                ldo4 {
+                    regulator-active-discharge = <1>;
+                    regulator-min-microvolt = <2700000>;
+                    regulator-max-microvolt = <3775000>;
+                    regulator-name = "ldo4";
+                };
+
+                buck {
+                    regulator-active-discharge = <1>;
+                    regulator-min-microvolt = <850000>;
+                    regulator-max-microvolt = <2100000>;
+                    regulator-name = "buck";
+                };
+            };
+        };
+    };
+
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 5e467ba71e3b..6a6c769a341a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -20468,7 +20468,7 @@ L:	linux-samsung-soc@vger.kernel.org
 S:	Maintained
 B:	mailto:linux-samsung-soc@vger.kernel.org
 F:	Documentation/devicetree/bindings/clock/samsung,s2mps11.yaml
-F:	Documentation/devicetree/bindings/mfd/samsung,s2m*.yaml
+F:	Documentation/devicetree/bindings/mfd/samsung,s2*.yaml
 F:	Documentation/devicetree/bindings/mfd/samsung,s5m*.yaml
 F:	Documentation/devicetree/bindings/regulator/samsung,s2m*.yaml
 F:	Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v5 2/3] mfd: sec-core: add s2dos05 support
  2024-09-26  9:47 [PATCH v5 0/3] Add Samsung s2dos05 pmic support Dzmitry Sankouski
  2024-09-26  9:47 ` [PATCH v5 1/3] dt-bindings: mfd: add samsung,s2dos05 Dzmitry Sankouski
@ 2024-09-26  9:47 ` Dzmitry Sankouski
  2024-09-26  9:47 ` [PATCH v5 3/3] regulator: add s2dos05 regulator support Dzmitry Sankouski
  2024-10-09 14:29 ` (subset) [PATCH v5 0/3] Add Samsung s2dos05 pmic support Lee Jones
  3 siblings, 0 replies; 13+ messages in thread
From: Dzmitry Sankouski @ 2024-09-26  9:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Rob Herring, Conor Dooley,
	Liam Girdwood, Mark Brown
  Cc: linux-kernel, linux-samsung-soc, devicetree, Dzmitry Sankouski

S2DOS05 is a panel/touchscreen PMIC, often found in
Samsung phones. We define regulator sub-device for which driver will
be added in subsequent patch. The device also has ADC for power and
current measurements.

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
Changes in v5:
- fix commit description: S2DOS05 in capital letters
- fix commit description: only 1 sub device will be
  added in subsequent patches.
---
 drivers/mfd/sec-core.c           | 11 +++++++++++
 include/linux/mfd/samsung/core.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index a6b0d7300b2d..cdfe738e1d76 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -34,6 +34,10 @@ static const struct mfd_cell s5m8767_devs[] = {
 	},
 };
 
+static const struct mfd_cell s2dos05_devs[] = {
+	{ .name = "s2dos05-regulator", },
+};
+
 static const struct mfd_cell s2mps11_devs[] = {
 	{ .name = "s2mps11-regulator", },
 	{ .name = "s2mps14-rtc", },
@@ -83,6 +87,9 @@ static const struct of_device_id sec_dt_match[] = {
 	{
 		.compatible = "samsung,s5m8767-pmic",
 		.data = (void *)S5M8767X,
+	}, {
+		.compatible = "samsung,s2dos05",
+		.data = (void *)S2DOS05,
 	}, {
 		.compatible = "samsung,s2mps11-pmic",
 		.data = (void *)S2MPS11X,
@@ -339,6 +346,10 @@ static int sec_pmic_probe(struct i2c_client *i2c)
 		sec_devs = s5m8767_devs;
 		num_sec_devs = ARRAY_SIZE(s5m8767_devs);
 		break;
+	case S2DOS05:
+		sec_devs = s2dos05_devs;
+		num_sec_devs = ARRAY_SIZE(s2dos05_devs);
+		break;
 	case S2MPA01:
 		sec_devs = s2mpa01_devs;
 		num_sec_devs = ARRAY_SIZE(s2mpa01_devs);
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index a212b9f72bc9..750274d41fc0 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -37,6 +37,7 @@ struct gpio_desc;
 
 enum sec_device_type {
 	S5M8767X,
+	S2DOS05,
 	S2MPA01,
 	S2MPS11X,
 	S2MPS13X,

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v5 3/3] regulator: add s2dos05 regulator support
  2024-09-26  9:47 [PATCH v5 0/3] Add Samsung s2dos05 pmic support Dzmitry Sankouski
  2024-09-26  9:47 ` [PATCH v5 1/3] dt-bindings: mfd: add samsung,s2dos05 Dzmitry Sankouski
  2024-09-26  9:47 ` [PATCH v5 2/3] mfd: sec-core: add s2dos05 support Dzmitry Sankouski
@ 2024-09-26  9:47 ` Dzmitry Sankouski
  2024-09-27  8:51   ` Krzysztof Kozlowski
  2025-07-17  7:28   ` Ivaylo Ivanov
  2024-10-09 14:29 ` (subset) [PATCH v5 0/3] Add Samsung s2dos05 pmic support Lee Jones
  3 siblings, 2 replies; 13+ messages in thread
From: Dzmitry Sankouski @ 2024-09-26  9:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Rob Herring, Conor Dooley,
	Liam Girdwood, Mark Brown
  Cc: linux-kernel, linux-samsung-soc, devicetree, Dzmitry Sankouski

S2DOS05 has 1 buck and 4 LDO regulators, used for powering
panel/touchscreen.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>

---
Changes in v4:
- remove excessive linux/module.h import
- use generic regulator helpers
- use of_match
- use devm_* for mem allocations
- use // style comment
- drop all junk Samsung code
- adjust to depend on sec-core

Changes in v5:
- fix Kconfig and module description to be the same
- make regulators const
- code refactoring
- replace s2m* pattern on s2* to include s2dos05
---
 MAINTAINERS                           |   2 +-
 drivers/regulator/Kconfig             |   8 ++++
 drivers/regulator/Makefile            |   1 +
 drivers/regulator/s2dos05-regulator.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/regulator/s2dos05.h     |  73 +++++++++++++++++++++++++++++++++++++
 5 files changed, 259 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6a6c769a341a..0b9fca1030a8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -20474,7 +20474,7 @@ F:	Documentation/devicetree/bindings/regulator/samsung,s2m*.yaml
 F:	Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml
 F:	drivers/clk/clk-s2mps11.c
 F:	drivers/mfd/sec*.c
-F:	drivers/regulator/s2m*.c
+F:	drivers/regulator/s2*.c
 F:	drivers/regulator/s5m*.c
 F:	drivers/rtc/rtc-s5m.c
 F:	include/linux/mfd/samsung/
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 39297f7d8177..249933d6388d 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -1322,6 +1322,14 @@ config REGULATOR_RTQ2208
 	  and two ldos. It features wide output voltage range from 0.4V to 2.05V
 	  and the capability to configure the corresponding power stages.
 
+config REGULATOR_S2DOS05
+	tristate "Samsung S2DOS05 voltage regulator"
+	depends on MFD_SEC_CORE || COMPILE_TEST
+	help
+	  This driver provides support for the voltage regulators of the S2DOS05.
+	  The S2DOS05 is a companion power management IC for the smart phones.
+	  The S2DOS05 has 4 LDOs and 1 BUCK outputs.
+
 config REGULATOR_S2MPA01
 	tristate "Samsung S2MPA01 voltage regulator"
 	depends on MFD_SEC_CORE || COMPILE_TEST
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 3d5a803dce8a..9b69546fb3f6 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -154,6 +154,7 @@ obj-$(CONFIG_REGULATOR_RTMV20)	+= rtmv20-regulator.o
 obj-$(CONFIG_REGULATOR_RTQ2134) += rtq2134-regulator.o
 obj-$(CONFIG_REGULATOR_RTQ6752)	+= rtq6752-regulator.o
 obj-$(CONFIG_REGULATOR_RTQ2208) += rtq2208-regulator.o
+obj-$(CONFIG_REGULATOR_S2DOS05) += s2dos05-regulator.o
 obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
 obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
 obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
diff --git a/drivers/regulator/s2dos05-regulator.c b/drivers/regulator/s2dos05-regulator.c
new file mode 100644
index 000000000000..258cabf104ce
--- /dev/null
+++ b/drivers/regulator/s2dos05-regulator.c
@@ -0,0 +1,176 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// s2dos05.c - Regulator driver for the Samsung s2dos05
+//
+// Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
+
+#include <linux/bug.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
+#include <linux/mfd/samsung/core.h>
+#include <linux/regulator/s2dos05.h>
+#include <linux/i2c.h>
+
+struct s2dos05_data {
+	struct regmap *regmap;
+	struct device *dev;
+};
+
+#define _BUCK(macro)	S2DOS05_BUCK##macro
+#define _buck_ops(num)	s2dos05_ops##num
+#define _LDO(macro)	S2DOS05_LDO##macro
+#define _REG(ctrl)	S2DOS05_REG##ctrl
+#define _ldo_ops(num)	s2dos05_ops##num
+#define _MASK(macro)	S2DOS05_ENABLE_MASK##macro
+#define _TIME(macro)	S2DOS05_ENABLE_TIME##macro
+
+#define BUCK_DESC(_name, _id, _ops, m, s, v, e, em, t, a) {	\
+	.name		= _name,				\
+	.id		= _id,					\
+	.ops		= _ops,					\
+	.of_match = of_match_ptr(_name),			\
+	.of_match_full_name = true,				\
+	.regulators_node = of_match_ptr("regulators"),		\
+	.type		= REGULATOR_VOLTAGE,			\
+	.owner		= THIS_MODULE,				\
+	.min_uV		= m,					\
+	.uV_step	= s,					\
+	.n_voltages	= S2DOS05_BUCK_N_VOLTAGES,		\
+	.vsel_reg	= v,					\
+	.vsel_mask	= S2DOS05_BUCK_VSEL_MASK,		\
+	.enable_reg	= e,					\
+	.enable_mask	= em,					\
+	.enable_time	= t,					\
+	.active_discharge_off = 0,				\
+	.active_discharge_on = S2DOS05_BUCK_FD_MASK,		\
+	.active_discharge_reg	= a,				\
+	.active_discharge_mask	= S2DOS05_BUCK_FD_MASK		\
+}
+
+#define LDO_DESC(_name, _id, _ops, m, s, v, e, em, t, a) {	\
+	.name		= _name,				\
+	.id		= _id,					\
+	.ops		= _ops,					\
+	.of_match = of_match_ptr(_name),			\
+	.of_match_full_name = true,				\
+	.regulators_node = of_match_ptr("regulators"),		\
+	.type		= REGULATOR_VOLTAGE,			\
+	.owner		= THIS_MODULE,				\
+	.min_uV		= m,					\
+	.uV_step	= s,					\
+	.n_voltages	= S2DOS05_LDO_N_VOLTAGES,		\
+	.vsel_reg	= v,					\
+	.vsel_mask	= S2DOS05_LDO_VSEL_MASK,		\
+	.enable_reg	= e,					\
+	.enable_mask	= em,					\
+	.enable_time	= t,					\
+	.active_discharge_off = 0,				\
+	.active_discharge_on = S2DOS05_LDO_FD_MASK,		\
+	.active_discharge_reg	= a,				\
+	.active_discharge_mask	= S2DOS05_LDO_FD_MASK		\
+}
+
+static const struct regulator_ops s2dos05_ops = {
+	.list_voltage		= regulator_list_voltage_linear,
+	.map_voltage		= regulator_map_voltage_linear,
+	.is_enabled		= regulator_is_enabled_regmap,
+	.enable			= regulator_enable_regmap,
+	.disable		= regulator_disable_regmap,
+	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
+	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
+	.set_voltage_time_sel	= regulator_set_voltage_time_sel,
+	.set_active_discharge	= regulator_set_active_discharge_regmap,
+};
+
+static const struct regulator_desc regulators[S2DOS05_REGULATOR_MAX] = {
+		// name, id, ops, min_uv, uV_step, vsel_reg, enable_reg
+		LDO_DESC("ldo1", _LDO(1), &_ldo_ops(), _LDO(_MIN1),
+			_LDO(_STEP1), _REG(_LDO1_CFG),
+			_REG(_EN), _MASK(_L1), _TIME(_LDO), _REG(_LDO1_CFG)),
+		LDO_DESC("ldo2", _LDO(2), &_ldo_ops(), _LDO(_MIN1),
+			_LDO(_STEP1), _REG(_LDO2_CFG),
+			_REG(_EN), _MASK(_L2), _TIME(_LDO), _REG(_LDO2_CFG)),
+		LDO_DESC("ldo3", _LDO(3), &_ldo_ops(), _LDO(_MIN2),
+			_LDO(_STEP1), _REG(_LDO3_CFG),
+			_REG(_EN), _MASK(_L3), _TIME(_LDO), _REG(_LDO3_CFG)),
+		LDO_DESC("ldo4", _LDO(4), &_ldo_ops(), _LDO(_MIN2),
+			_LDO(_STEP1), _REG(_LDO4_CFG),
+			_REG(_EN), _MASK(_L4), _TIME(_LDO), _REG(_LDO4_CFG)),
+		BUCK_DESC("buck", _BUCK(1), &_buck_ops(), _BUCK(_MIN1),
+			_BUCK(_STEP1), _REG(_BUCK_VOUT),
+			_REG(_EN), _MASK(_B1), _TIME(_BUCK), _REG(_BUCK_CFG)),
+};
+
+static int s2dos05_pmic_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
+	struct of_regulator_match *rdata = NULL;
+	struct s2dos05_data *s2dos05;
+	struct regulator_config config = { };
+	unsigned int rdev_num = ARRAY_SIZE(regulators);
+	int i, ret;
+
+	s2dos05 = devm_kzalloc(dev, sizeof(*s2dos05), GFP_KERNEL);
+	if (!s2dos05)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, s2dos05);
+
+	rdata = devm_kcalloc(dev, rdev_num, sizeof(*rdata), GFP_KERNEL);
+	if (!rdata)
+		return -ENOMEM;
+
+	for (i = 0; i < rdev_num; i++)
+		rdata[i].name = regulators[i].name;
+
+	s2dos05->regmap = iodev->regmap_pmic;
+	s2dos05->dev = dev;
+	if (!dev->of_node)
+		dev->of_node = dev->parent->of_node;
+
+	for (i = 0; i < rdev_num; i++) {
+		struct regulator_dev *regulator;
+
+		config.init_data = rdata[i].init_data;
+		config.of_node = rdata[i].of_node;
+		config.dev = dev;
+		config.driver_data = s2dos05;
+		regulator = devm_regulator_register(&pdev->dev,
+						&regulators[i], &config);
+		if (IS_ERR(regulator)) {
+			ret = PTR_ERR(regulator);
+			dev_err(&pdev->dev, "regulator init failed for %d\n",
+				i);
+		}
+	}
+
+	return ret;
+}
+
+static const struct platform_device_id s2dos05_pmic_id[] = {
+	{ "s2dos05-regulator" },
+	{ },
+};
+MODULE_DEVICE_TABLE(platform, s2dos05_pmic_id);
+
+static struct platform_driver s2dos05_platform_driver = {
+	.driver = {
+		.name = "s2dos05",
+	},
+	.probe = s2dos05_pmic_probe,
+	.id_table = s2dos05_pmic_id,
+};
+module_platform_driver(s2dos05_platform_driver);
+
+MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
+MODULE_DESCRIPTION("Samsung S2DOS05 Regulator Driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/regulator/s2dos05.h b/include/linux/regulator/s2dos05.h
new file mode 100644
index 000000000000..2e89fcbce769
--- /dev/null
+++ b/include/linux/regulator/s2dos05.h
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+// s2dos05.h
+//
+// Copyright (c) 2016 Samsung Electronics Co., Ltd
+//              http://www.samsung.com
+// Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
+
+#ifndef __LINUX_S2DOS05_H
+#define __LINUX_S2DOS05_H
+
+// S2DOS05 registers
+// Slave Addr : 0xC0
+enum S2DOS05_reg {
+	S2DOS05_REG_DEV_ID,
+	S2DOS05_REG_TOPSYS_STAT,
+	S2DOS05_REG_STAT,
+	S2DOS05_REG_EN,
+	S2DOS05_REG_LDO1_CFG,
+	S2DOS05_REG_LDO2_CFG,
+	S2DOS05_REG_LDO3_CFG,
+	S2DOS05_REG_LDO4_CFG,
+	S2DOS05_REG_BUCK_CFG,
+	S2DOS05_REG_BUCK_VOUT,
+	S2DOS05_REG_IRQ_MASK = 0x0D,
+	S2DOS05_REG_SSD_TSD = 0x0E,
+	S2DOS05_REG_OCL = 0x10,
+	S2DOS05_REG_IRQ = 0x11
+};
+
+// S2DOS05 regulator ids
+enum S2DOS05_regulators {
+	S2DOS05_LDO1,
+	S2DOS05_LDO2,
+	S2DOS05_LDO3,
+	S2DOS05_LDO4,
+	S2DOS05_BUCK1,
+	S2DOS05_REG_MAX,
+};
+
+#define S2DOS05_IRQ_PWRMT_MASK	BIT(5)
+#define S2DOS05_IRQ_TSD_MASK	BIT(4)
+#define S2DOS05_IRQ_SSD_MASK	BIT(3)
+#define S2DOS05_IRQ_SCP_MASK	BIT(2)
+#define S2DOS05_IRQ_UVLO_MASK	BIT(1)
+#define S2DOS05_IRQ_OCD_MASK	BIT(0)
+
+#define S2DOS05_BUCK_MIN1	506250
+#define S2DOS05_LDO_MIN1	1500000
+#define S2DOS05_LDO_MIN2	2700000
+#define S2DOS05_BUCK_STEP1	6250
+#define S2DOS05_LDO_STEP1	25000
+#define S2DOS05_LDO_VSEL_MASK	0x7F
+#define S2DOS05_LDO_FD_MASK	0x80
+#define S2DOS05_BUCK_VSEL_MASK	0xFF
+#define S2DOS05_BUCK_FD_MASK	0x08
+
+#define S2DOS05_ENABLE_MASK_L1	BIT(0)
+#define S2DOS05_ENABLE_MASK_L2	BIT(1)
+#define S2DOS05_ENABLE_MASK_L3	BIT(2)
+#define S2DOS05_ENABLE_MASK_L4	BIT(3)
+#define S2DOS05_ENABLE_MASK_B1	BIT(4)
+
+#define S2DOS05_RAMP_DELAY	12000
+
+#define S2DOS05_ENABLE_TIME_LDO		50
+#define S2DOS05_ENABLE_TIME_BUCK	350
+
+#define S2DOS05_LDO_N_VOLTAGES	(S2DOS05_LDO_VSEL_MASK + 1)
+#define S2DOS05_BUCK_N_VOLTAGES (S2DOS05_BUCK_VSEL_MASK + 1)
+
+#define S2DOS05_REGULATOR_MAX	(S2DOS05_REG_MAX)
+
+#endif // __LINUX_S2DOS05_H

-- 
2.39.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 1/3] dt-bindings: mfd: add samsung,s2dos05
  2024-09-26  9:47 ` [PATCH v5 1/3] dt-bindings: mfd: add samsung,s2dos05 Dzmitry Sankouski
@ 2024-09-27  8:48   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2024-09-27  8:48 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Lee Jones, Rob Herring, Conor Dooley, Liam Girdwood, Mark Brown,
	linux-kernel, linux-samsung-soc, devicetree

On Thu, Sep 26, 2024 at 12:47:30PM +0300, Dzmitry Sankouski wrote:
> Add samsung,s2dos05 MFD module binding.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> 

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 3/3] regulator: add s2dos05 regulator support
  2024-09-26  9:47 ` [PATCH v5 3/3] regulator: add s2dos05 regulator support Dzmitry Sankouski
@ 2024-09-27  8:51   ` Krzysztof Kozlowski
  2024-09-27  8:54     ` Krzysztof Kozlowski
  2025-07-17  7:28   ` Ivaylo Ivanov
  1 sibling, 1 reply; 13+ messages in thread
From: Krzysztof Kozlowski @ 2024-09-27  8:51 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Lee Jones, Rob Herring, Conor Dooley, Liam Girdwood, Mark Brown,
	linux-kernel, linux-samsung-soc, devicetree

On Thu, Sep 26, 2024 at 12:47:32PM +0300, Dzmitry Sankouski wrote:
> +static int s2dos05_pmic_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> +	struct of_regulator_match *rdata = NULL;
> +	struct s2dos05_data *s2dos05;
> +	struct regulator_config config = { };
> +	unsigned int rdev_num = ARRAY_SIZE(regulators);
> +	int i, ret;
> +
> +	s2dos05 = devm_kzalloc(dev, sizeof(*s2dos05), GFP_KERNEL);
> +	if (!s2dos05)
> +		return -ENOMEM;
> +
> +	platform_set_drvdata(pdev, s2dos05);
> +
> +	rdata = devm_kcalloc(dev, rdev_num, sizeof(*rdata), GFP_KERNEL);
> +	if (!rdata)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < rdev_num; i++)
> +		rdata[i].name = regulators[i].name;
> +
> +	s2dos05->regmap = iodev->regmap_pmic;
> +	s2dos05->dev = dev;
> +	if (!dev->of_node)
> +		dev->of_node = dev->parent->of_node;
> +
> +	for (i = 0; i < rdev_num; i++) {
> +		struct regulator_dev *regulator;
> +
> +		config.init_data = rdata[i].init_data;
> +		config.of_node = rdata[i].of_node;
> +		config.dev = dev;
> +		config.driver_data = s2dos05;
> +		regulator = devm_regulator_register(&pdev->dev,
> +						&regulators[i], &config);
> +		if (IS_ERR(regulator)) {
> +			ret = PTR_ERR(regulator);
> +			dev_err(&pdev->dev, "regulator init failed for %d\n",
> +				i);
> +		}
> +	}
> +
> +	return ret;

ret is uninitialized. Please test your code with smatch and sparse.

Since I expect a new version, I will have a comment on the bindings as well.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 3/3] regulator: add s2dos05 regulator support
  2024-09-27  8:51   ` Krzysztof Kozlowski
@ 2024-09-27  8:54     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2024-09-27  8:54 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Lee Jones, Rob Herring, Conor Dooley, Liam Girdwood, Mark Brown,
	linux-kernel, linux-samsung-soc, devicetree

On Fri, Sep 27, 2024 at 10:51:08AM +0200, Krzysztof Kozlowski wrote:
> On Thu, Sep 26, 2024 at 12:47:32PM +0300, Dzmitry Sankouski wrote:
> > +static int s2dos05_pmic_probe(struct platform_device *pdev)
> > +{
> > +	struct device *dev = &pdev->dev;
> > +	struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> > +	struct of_regulator_match *rdata = NULL;
> > +	struct s2dos05_data *s2dos05;
> > +	struct regulator_config config = { };
> > +	unsigned int rdev_num = ARRAY_SIZE(regulators);
> > +	int i, ret;
> > +
> > +	s2dos05 = devm_kzalloc(dev, sizeof(*s2dos05), GFP_KERNEL);
> > +	if (!s2dos05)
> > +		return -ENOMEM;
> > +
> > +	platform_set_drvdata(pdev, s2dos05);
> > +
> > +	rdata = devm_kcalloc(dev, rdev_num, sizeof(*rdata), GFP_KERNEL);
> > +	if (!rdata)
> > +		return -ENOMEM;
> > +
> > +	for (i = 0; i < rdev_num; i++)
> > +		rdata[i].name = regulators[i].name;
> > +
> > +	s2dos05->regmap = iodev->regmap_pmic;
> > +	s2dos05->dev = dev;
> > +	if (!dev->of_node)
> > +		dev->of_node = dev->parent->of_node;
> > +
> > +	for (i = 0; i < rdev_num; i++) {
> > +		struct regulator_dev *regulator;
> > +
> > +		config.init_data = rdata[i].init_data;
> > +		config.of_node = rdata[i].of_node;
> > +		config.dev = dev;
> > +		config.driver_data = s2dos05;
> > +		regulator = devm_regulator_register(&pdev->dev,
> > +						&regulators[i], &config);
> > +		if (IS_ERR(regulator)) {
> > +			ret = PTR_ERR(regulator);
> > +			dev_err(&pdev->dev, "regulator init failed for %d\n",
> > +				i);
> > +		}
> > +	}
> > +
> > +	return ret;
> 
> ret is uninitialized. Please test your code with smatch and sparse.
> 
> Since I expect a new version, I will have a comment on the bindings as well.

Ah, no, looks fine. I was thinking you missed interrupts, but aparently
device is quite simple and I coould not find interrupts in downstream
source.

Still please investigate above 'ret' and run smatch and sparse.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (subset) [PATCH v5 0/3] Add Samsung s2dos05 pmic support
  2024-09-26  9:47 [PATCH v5 0/3] Add Samsung s2dos05 pmic support Dzmitry Sankouski
                   ` (2 preceding siblings ...)
  2024-09-26  9:47 ` [PATCH v5 3/3] regulator: add s2dos05 regulator support Dzmitry Sankouski
@ 2024-10-09 14:29 ` Lee Jones
  3 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2024-10-09 14:29 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Rob Herring, Conor Dooley,
	Liam Girdwood, Mark Brown, Dzmitry Sankouski
  Cc: linux-kernel, linux-samsung-soc, devicetree

On Thu, 26 Sep 2024 12:47:29 +0300, Dzmitry Sankouski wrote:
> The S2DOS05 is a companion power management IC for the panel and touchscreen
> in smart phones. Provides voltage regulators and
> ADC for power/current measurements.
> 
> 

Applied, thanks!

[1/3] dt-bindings: mfd: add samsung,s2dos05
      commit: 7bde7326deeaab9ae9345e01b4e321218c4679dd
[2/3] mfd: sec-core: add s2dos05 support
      commit: 176b2e5b80c845a6717122afff7eabcb999cec07

--
Lee Jones [李琼斯]


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 3/3] regulator: add s2dos05 regulator support
  2024-09-26  9:47 ` [PATCH v5 3/3] regulator: add s2dos05 regulator support Dzmitry Sankouski
  2024-09-27  8:51   ` Krzysztof Kozlowski
@ 2025-07-17  7:28   ` Ivaylo Ivanov
  2025-07-17  8:12     ` Dzmitry Sankouski
  1 sibling, 1 reply; 13+ messages in thread
From: Ivaylo Ivanov @ 2025-07-17  7:28 UTC (permalink / raw)
  To: Dzmitry Sankouski, Krzysztof Kozlowski, Lee Jones, Rob Herring,
	Conor Dooley, Liam Girdwood, Mark Brown
  Cc: linux-kernel, linux-samsung-soc, devicetree

On 9/26/24 12:47, Dzmitry Sankouski wrote:
> S2DOS05 has 1 buck and 4 LDO regulators, used for powering
> panel/touchscreen.
>
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>

When is this going to get merged? This patch brings the regulators
functionality of the pmic, so not having it merged is odd. This PMIC is
used on other devices too, like the Galaxy S22.

It seems like this has been hanging for almost an year at this point.
If the author won't, will somebody resend it?

Regards,
Ivaylo

> ---
> Changes in v4:
> - remove excessive linux/module.h import
> - use generic regulator helpers
> - use of_match
> - use devm_* for mem allocations
> - use // style comment
> - drop all junk Samsung code
> - adjust to depend on sec-core
>
> Changes in v5:
> - fix Kconfig and module description to be the same
> - make regulators const
> - code refactoring
> - replace s2m* pattern on s2* to include s2dos05
> ---
>  MAINTAINERS                           |   2 +-
>  drivers/regulator/Kconfig             |   8 ++++
>  drivers/regulator/Makefile            |   1 +
>  drivers/regulator/s2dos05-regulator.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/regulator/s2dos05.h     |  73 +++++++++++++++++++++++++++++++++++++
>  5 files changed, 259 insertions(+), 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6a6c769a341a..0b9fca1030a8 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -20474,7 +20474,7 @@ F:	Documentation/devicetree/bindings/regulator/samsung,s2m*.yaml
>  F:	Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml
>  F:	drivers/clk/clk-s2mps11.c
>  F:	drivers/mfd/sec*.c
> -F:	drivers/regulator/s2m*.c
> +F:	drivers/regulator/s2*.c
>  F:	drivers/regulator/s5m*.c
>  F:	drivers/rtc/rtc-s5m.c
>  F:	include/linux/mfd/samsung/
> diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
> index 39297f7d8177..249933d6388d 100644
> --- a/drivers/regulator/Kconfig
> +++ b/drivers/regulator/Kconfig
> @@ -1322,6 +1322,14 @@ config REGULATOR_RTQ2208
>  	  and two ldos. It features wide output voltage range from 0.4V to 2.05V
>  	  and the capability to configure the corresponding power stages.
>  
> +config REGULATOR_S2DOS05
> +	tristate "Samsung S2DOS05 voltage regulator"
> +	depends on MFD_SEC_CORE || COMPILE_TEST
> +	help
> +	  This driver provides support for the voltage regulators of the S2DOS05.
> +	  The S2DOS05 is a companion power management IC for the smart phones.
> +	  The S2DOS05 has 4 LDOs and 1 BUCK outputs.
> +
>  config REGULATOR_S2MPA01
>  	tristate "Samsung S2MPA01 voltage regulator"
>  	depends on MFD_SEC_CORE || COMPILE_TEST
> diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
> index 3d5a803dce8a..9b69546fb3f6 100644
> --- a/drivers/regulator/Makefile
> +++ b/drivers/regulator/Makefile
> @@ -154,6 +154,7 @@ obj-$(CONFIG_REGULATOR_RTMV20)	+= rtmv20-regulator.o
>  obj-$(CONFIG_REGULATOR_RTQ2134) += rtq2134-regulator.o
>  obj-$(CONFIG_REGULATOR_RTQ6752)	+= rtq6752-regulator.o
>  obj-$(CONFIG_REGULATOR_RTQ2208) += rtq2208-regulator.o
> +obj-$(CONFIG_REGULATOR_S2DOS05) += s2dos05-regulator.o
>  obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
>  obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
>  obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
> diff --git a/drivers/regulator/s2dos05-regulator.c b/drivers/regulator/s2dos05-regulator.c
> new file mode 100644
> index 000000000000..258cabf104ce
> --- /dev/null
> +++ b/drivers/regulator/s2dos05-regulator.c
> @@ -0,0 +1,176 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +//
> +// s2dos05.c - Regulator driver for the Samsung s2dos05
> +//
> +// Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
> +
> +#include <linux/bug.h>
> +#include <linux/delay.h>
> +#include <linux/err.h>
> +#include <linux/slab.h>
> +#include <linux/module.h>
> +#include <linux/regmap.h>
> +#include <linux/interrupt.h>
> +#include <linux/platform_device.h>
> +#include <linux/regulator/driver.h>
> +#include <linux/regulator/machine.h>
> +#include <linux/regulator/of_regulator.h>
> +#include <linux/mfd/samsung/core.h>
> +#include <linux/regulator/s2dos05.h>
> +#include <linux/i2c.h>
> +
> +struct s2dos05_data {
> +	struct regmap *regmap;
> +	struct device *dev;
> +};
> +
> +#define _BUCK(macro)	S2DOS05_BUCK##macro
> +#define _buck_ops(num)	s2dos05_ops##num
> +#define _LDO(macro)	S2DOS05_LDO##macro
> +#define _REG(ctrl)	S2DOS05_REG##ctrl
> +#define _ldo_ops(num)	s2dos05_ops##num
> +#define _MASK(macro)	S2DOS05_ENABLE_MASK##macro
> +#define _TIME(macro)	S2DOS05_ENABLE_TIME##macro
> +
> +#define BUCK_DESC(_name, _id, _ops, m, s, v, e, em, t, a) {	\
> +	.name		= _name,				\
> +	.id		= _id,					\
> +	.ops		= _ops,					\
> +	.of_match = of_match_ptr(_name),			\
> +	.of_match_full_name = true,				\
> +	.regulators_node = of_match_ptr("regulators"),		\
> +	.type		= REGULATOR_VOLTAGE,			\
> +	.owner		= THIS_MODULE,				\
> +	.min_uV		= m,					\
> +	.uV_step	= s,					\
> +	.n_voltages	= S2DOS05_BUCK_N_VOLTAGES,		\
> +	.vsel_reg	= v,					\
> +	.vsel_mask	= S2DOS05_BUCK_VSEL_MASK,		\
> +	.enable_reg	= e,					\
> +	.enable_mask	= em,					\
> +	.enable_time	= t,					\
> +	.active_discharge_off = 0,				\
> +	.active_discharge_on = S2DOS05_BUCK_FD_MASK,		\
> +	.active_discharge_reg	= a,				\
> +	.active_discharge_mask	= S2DOS05_BUCK_FD_MASK		\
> +}
> +
> +#define LDO_DESC(_name, _id, _ops, m, s, v, e, em, t, a) {	\
> +	.name		= _name,				\
> +	.id		= _id,					\
> +	.ops		= _ops,					\
> +	.of_match = of_match_ptr(_name),			\
> +	.of_match_full_name = true,				\
> +	.regulators_node = of_match_ptr("regulators"),		\
> +	.type		= REGULATOR_VOLTAGE,			\
> +	.owner		= THIS_MODULE,				\
> +	.min_uV		= m,					\
> +	.uV_step	= s,					\
> +	.n_voltages	= S2DOS05_LDO_N_VOLTAGES,		\
> +	.vsel_reg	= v,					\
> +	.vsel_mask	= S2DOS05_LDO_VSEL_MASK,		\
> +	.enable_reg	= e,					\
> +	.enable_mask	= em,					\
> +	.enable_time	= t,					\
> +	.active_discharge_off = 0,				\
> +	.active_discharge_on = S2DOS05_LDO_FD_MASK,		\
> +	.active_discharge_reg	= a,				\
> +	.active_discharge_mask	= S2DOS05_LDO_FD_MASK		\
> +}
> +
> +static const struct regulator_ops s2dos05_ops = {
> +	.list_voltage		= regulator_list_voltage_linear,
> +	.map_voltage		= regulator_map_voltage_linear,
> +	.is_enabled		= regulator_is_enabled_regmap,
> +	.enable			= regulator_enable_regmap,
> +	.disable		= regulator_disable_regmap,
> +	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
> +	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
> +	.set_voltage_time_sel	= regulator_set_voltage_time_sel,
> +	.set_active_discharge	= regulator_set_active_discharge_regmap,
> +};
> +
> +static const struct regulator_desc regulators[S2DOS05_REGULATOR_MAX] = {
> +		// name, id, ops, min_uv, uV_step, vsel_reg, enable_reg
> +		LDO_DESC("ldo1", _LDO(1), &_ldo_ops(), _LDO(_MIN1),
> +			_LDO(_STEP1), _REG(_LDO1_CFG),
> +			_REG(_EN), _MASK(_L1), _TIME(_LDO), _REG(_LDO1_CFG)),
> +		LDO_DESC("ldo2", _LDO(2), &_ldo_ops(), _LDO(_MIN1),
> +			_LDO(_STEP1), _REG(_LDO2_CFG),
> +			_REG(_EN), _MASK(_L2), _TIME(_LDO), _REG(_LDO2_CFG)),
> +		LDO_DESC("ldo3", _LDO(3), &_ldo_ops(), _LDO(_MIN2),
> +			_LDO(_STEP1), _REG(_LDO3_CFG),
> +			_REG(_EN), _MASK(_L3), _TIME(_LDO), _REG(_LDO3_CFG)),
> +		LDO_DESC("ldo4", _LDO(4), &_ldo_ops(), _LDO(_MIN2),
> +			_LDO(_STEP1), _REG(_LDO4_CFG),
> +			_REG(_EN), _MASK(_L4), _TIME(_LDO), _REG(_LDO4_CFG)),
> +		BUCK_DESC("buck", _BUCK(1), &_buck_ops(), _BUCK(_MIN1),
> +			_BUCK(_STEP1), _REG(_BUCK_VOUT),
> +			_REG(_EN), _MASK(_B1), _TIME(_BUCK), _REG(_BUCK_CFG)),
> +};
> +
> +static int s2dos05_pmic_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> +	struct of_regulator_match *rdata = NULL;
> +	struct s2dos05_data *s2dos05;
> +	struct regulator_config config = { };
> +	unsigned int rdev_num = ARRAY_SIZE(regulators);
> +	int i, ret;
> +
> +	s2dos05 = devm_kzalloc(dev, sizeof(*s2dos05), GFP_KERNEL);
> +	if (!s2dos05)
> +		return -ENOMEM;
> +
> +	platform_set_drvdata(pdev, s2dos05);
> +
> +	rdata = devm_kcalloc(dev, rdev_num, sizeof(*rdata), GFP_KERNEL);
> +	if (!rdata)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < rdev_num; i++)
> +		rdata[i].name = regulators[i].name;
> +
> +	s2dos05->regmap = iodev->regmap_pmic;
> +	s2dos05->dev = dev;
> +	if (!dev->of_node)
> +		dev->of_node = dev->parent->of_node;
> +
> +	for (i = 0; i < rdev_num; i++) {
> +		struct regulator_dev *regulator;
> +
> +		config.init_data = rdata[i].init_data;
> +		config.of_node = rdata[i].of_node;
> +		config.dev = dev;
> +		config.driver_data = s2dos05;
> +		regulator = devm_regulator_register(&pdev->dev,
> +						&regulators[i], &config);
> +		if (IS_ERR(regulator)) {
> +			ret = PTR_ERR(regulator);
> +			dev_err(&pdev->dev, "regulator init failed for %d\n",
> +				i);
> +		}
> +	}
> +
> +	return ret;
> +}
> +
> +static const struct platform_device_id s2dos05_pmic_id[] = {
> +	{ "s2dos05-regulator" },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(platform, s2dos05_pmic_id);
> +
> +static struct platform_driver s2dos05_platform_driver = {
> +	.driver = {
> +		.name = "s2dos05",
> +	},
> +	.probe = s2dos05_pmic_probe,
> +	.id_table = s2dos05_pmic_id,
> +};
> +module_platform_driver(s2dos05_platform_driver);
> +
> +MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
> +MODULE_DESCRIPTION("Samsung S2DOS05 Regulator Driver");
> +MODULE_LICENSE("GPL");
> diff --git a/include/linux/regulator/s2dos05.h b/include/linux/regulator/s2dos05.h
> new file mode 100644
> index 000000000000..2e89fcbce769
> --- /dev/null
> +++ b/include/linux/regulator/s2dos05.h
> @@ -0,0 +1,73 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +// s2dos05.h
> +//
> +// Copyright (c) 2016 Samsung Electronics Co., Ltd
> +//              http://www.samsung.com
> +// Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
> +
> +#ifndef __LINUX_S2DOS05_H
> +#define __LINUX_S2DOS05_H
> +
> +// S2DOS05 registers
> +// Slave Addr : 0xC0
> +enum S2DOS05_reg {
> +	S2DOS05_REG_DEV_ID,
> +	S2DOS05_REG_TOPSYS_STAT,
> +	S2DOS05_REG_STAT,
> +	S2DOS05_REG_EN,
> +	S2DOS05_REG_LDO1_CFG,
> +	S2DOS05_REG_LDO2_CFG,
> +	S2DOS05_REG_LDO3_CFG,
> +	S2DOS05_REG_LDO4_CFG,
> +	S2DOS05_REG_BUCK_CFG,
> +	S2DOS05_REG_BUCK_VOUT,
> +	S2DOS05_REG_IRQ_MASK = 0x0D,
> +	S2DOS05_REG_SSD_TSD = 0x0E,
> +	S2DOS05_REG_OCL = 0x10,
> +	S2DOS05_REG_IRQ = 0x11
> +};
> +
> +// S2DOS05 regulator ids
> +enum S2DOS05_regulators {
> +	S2DOS05_LDO1,
> +	S2DOS05_LDO2,
> +	S2DOS05_LDO3,
> +	S2DOS05_LDO4,
> +	S2DOS05_BUCK1,
> +	S2DOS05_REG_MAX,
> +};
> +
> +#define S2DOS05_IRQ_PWRMT_MASK	BIT(5)
> +#define S2DOS05_IRQ_TSD_MASK	BIT(4)
> +#define S2DOS05_IRQ_SSD_MASK	BIT(3)
> +#define S2DOS05_IRQ_SCP_MASK	BIT(2)
> +#define S2DOS05_IRQ_UVLO_MASK	BIT(1)
> +#define S2DOS05_IRQ_OCD_MASK	BIT(0)
> +
> +#define S2DOS05_BUCK_MIN1	506250
> +#define S2DOS05_LDO_MIN1	1500000
> +#define S2DOS05_LDO_MIN2	2700000
> +#define S2DOS05_BUCK_STEP1	6250
> +#define S2DOS05_LDO_STEP1	25000
> +#define S2DOS05_LDO_VSEL_MASK	0x7F
> +#define S2DOS05_LDO_FD_MASK	0x80
> +#define S2DOS05_BUCK_VSEL_MASK	0xFF
> +#define S2DOS05_BUCK_FD_MASK	0x08
> +
> +#define S2DOS05_ENABLE_MASK_L1	BIT(0)
> +#define S2DOS05_ENABLE_MASK_L2	BIT(1)
> +#define S2DOS05_ENABLE_MASK_L3	BIT(2)
> +#define S2DOS05_ENABLE_MASK_L4	BIT(3)
> +#define S2DOS05_ENABLE_MASK_B1	BIT(4)
> +
> +#define S2DOS05_RAMP_DELAY	12000
> +
> +#define S2DOS05_ENABLE_TIME_LDO		50
> +#define S2DOS05_ENABLE_TIME_BUCK	350
> +
> +#define S2DOS05_LDO_N_VOLTAGES	(S2DOS05_LDO_VSEL_MASK + 1)
> +#define S2DOS05_BUCK_N_VOLTAGES (S2DOS05_BUCK_VSEL_MASK + 1)
> +
> +#define S2DOS05_REGULATOR_MAX	(S2DOS05_REG_MAX)
> +
> +#endif // __LINUX_S2DOS05_H
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 3/3] regulator: add s2dos05 regulator support
  2025-07-17  7:28   ` Ivaylo Ivanov
@ 2025-07-17  8:12     ` Dzmitry Sankouski
  2025-07-17 11:33       ` Ivaylo Ivanov
  0 siblings, 1 reply; 13+ messages in thread
From: Dzmitry Sankouski @ 2025-07-17  8:12 UTC (permalink / raw)
  To: Ivaylo Ivanov
  Cc: Krzysztof Kozlowski, Lee Jones, Rob Herring, Conor Dooley,
	Liam Girdwood, Mark Brown, linux-kernel, linux-samsung-soc,
	devicetree

чт, 17 июл. 2025 г. в 10:28, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>:
>
> On 9/26/24 12:47, Dzmitry Sankouski wrote:
> > S2DOS05 has 1 buck and 4 LDO regulators, used for powering
> > panel/touchscreen.
> >
> > Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
>
> When is this going to get merged? This patch brings the regulators
> functionality of the pmic, so not having it merged is odd. This PMIC is
> used on other devices too, like the Galaxy S22.
>
> It seems like this has been hanging for almost an year at this point.
> If the author won't, will somebody resend it?


It's already merged, see
https://lore.kernel.org/all/20240617-starqltechn_integration_upstream-v5-2-ea1109029ba5@gmail.com/

-- 

Best regards,
Dzmitry

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 3/3] regulator: add s2dos05 regulator support
  2025-07-17  8:12     ` Dzmitry Sankouski
@ 2025-07-17 11:33       ` Ivaylo Ivanov
  2025-07-17 14:36         ` Dzmitry Sankouski
  0 siblings, 1 reply; 13+ messages in thread
From: Ivaylo Ivanov @ 2025-07-17 11:33 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Krzysztof Kozlowski, Lee Jones, Rob Herring, Conor Dooley,
	Liam Girdwood, Mark Brown, linux-kernel, linux-samsung-soc,
	devicetree

On 7/17/25 11:12, Dzmitry Sankouski wrote:
> чт, 17 июл. 2025 г. в 10:28, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>:
>> On 9/26/24 12:47, Dzmitry Sankouski wrote:
>>> S2DOS05 has 1 buck and 4 LDO regulators, used for powering
>>> panel/touchscreen.
>>>
>>> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
>> When is this going to get merged? This patch brings the regulators
>> functionality of the pmic, so not having it merged is odd. This PMIC is
>> used on other devices too, like the Galaxy S22.
>>
>> It seems like this has been hanging for almost an year at this point.
>> If the author won't, will somebody resend it?
>
> It's already merged, see
> https://lore.kernel.org/all/20240617-starqltechn_integration_upstream-v5-2-ea1109029ba5@gmail.com/

I don't see patch 3/3 being merged anywhere, nor is it in my linux-next clone
from today. Do you _not_ need it anymore?

Best regards,
Ivaylo

>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 3/3] regulator: add s2dos05 regulator support
  2025-07-17 11:33       ` Ivaylo Ivanov
@ 2025-07-17 14:36         ` Dzmitry Sankouski
  2025-07-17 16:07           ` Mark Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Dzmitry Sankouski @ 2025-07-17 14:36 UTC (permalink / raw)
  To: Ivaylo Ivanov
  Cc: Krzysztof Kozlowski, Lee Jones, Rob Herring, Conor Dooley,
	Liam Girdwood, Mark Brown, linux-kernel, linux-samsung-soc,
	devicetree

чт, 17 июл. 2025 г. в 14:33, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>:
>
> On 7/17/25 11:12, Dzmitry Sankouski wrote:
> > чт, 17 июл. 2025 г. в 10:28, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>:
> >> On 9/26/24 12:47, Dzmitry Sankouski wrote:
> >>> S2DOS05 has 1 buck and 4 LDO regulators, used for powering
> >>> panel/touchscreen.
> >>>
> >>> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> >> When is this going to get merged? This patch brings the regulators
> >> functionality of the pmic, so not having it merged is odd. This PMIC is
> >> used on other devices too, like the Galaxy S22.
> >>
> >> It seems like this has been hanging for almost an year at this point.
> >> If the author won't, will somebody resend it?
> >
> > It's already merged, see
> > https://lore.kernel.org/all/20240617-starqltechn_integration_upstream-v5-2-ea1109029ba5@gmail.com/
>
> I don't see patch 3/3 being merged anywhere, nor is it in my linux-next clone
> from today. Do you _not_ need it anymore?
>

Indeed, that commit is not present, that's strange. I'll reset that patch later.

-- 

Best regards,
Dzmitry

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 3/3] regulator: add s2dos05 regulator support
  2025-07-17 14:36         ` Dzmitry Sankouski
@ 2025-07-17 16:07           ` Mark Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2025-07-17 16:07 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Ivaylo Ivanov, Krzysztof Kozlowski, Lee Jones, Rob Herring,
	Conor Dooley, Liam Girdwood, linux-kernel, linux-samsung-soc,
	devicetree

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

On Thu, Jul 17, 2025 at 05:36:45PM +0300, Dzmitry Sankouski wrote:
> чт, 17 июл. 2025 г. в 14:33, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>:
> > On 7/17/25 11:12, Dzmitry Sankouski wrote:

> > > It's already merged, see
> > > https://lore.kernel.org/all/20240617-starqltechn_integration_upstream-v5-2-ea1109029ba5@gmail.com/

> > I don't see patch 3/3 being merged anywhere, nor is it in my linux-next clone
> > from today. Do you _not_ need it anymore?

> Indeed, that commit is not present, that's strange. I'll reset that patch later.

There's outstanding review comments to fix...

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-07-17 16:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26  9:47 [PATCH v5 0/3] Add Samsung s2dos05 pmic support Dzmitry Sankouski
2024-09-26  9:47 ` [PATCH v5 1/3] dt-bindings: mfd: add samsung,s2dos05 Dzmitry Sankouski
2024-09-27  8:48   ` Krzysztof Kozlowski
2024-09-26  9:47 ` [PATCH v5 2/3] mfd: sec-core: add s2dos05 support Dzmitry Sankouski
2024-09-26  9:47 ` [PATCH v5 3/3] regulator: add s2dos05 regulator support Dzmitry Sankouski
2024-09-27  8:51   ` Krzysztof Kozlowski
2024-09-27  8:54     ` Krzysztof Kozlowski
2025-07-17  7:28   ` Ivaylo Ivanov
2025-07-17  8:12     ` Dzmitry Sankouski
2025-07-17 11:33       ` Ivaylo Ivanov
2025-07-17 14:36         ` Dzmitry Sankouski
2025-07-17 16:07           ` Mark Brown
2024-10-09 14:29 ` (subset) [PATCH v5 0/3] Add Samsung s2dos05 pmic support Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).