linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn
@ 2024-06-18 13:59 Dzmitry Sankouski
  2024-06-18 13:59 ` [PATCH v3 01/23] power: supply: add undervoltage health status property Dzmitry Sankouski
                   ` (22 more replies)
  0 siblings, 23 replies; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski, Rose Hudson

Add support for new features:
- sound (headphones and mics only)
- gpu
- panel
- buttons
- MAX77705 MFD:
  - charger
  - fuelgauge
  - haptic
  - led

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.

Changes in version 3:
Version 3 has significant changes:
- more drivers added
- s2dos05 driver converted to MFD
- disable crypto patch removed(disabled on distro level)
- dts framebuffer node along with related patches removed,
because panel driver added
- fix 'make O=.output_arm64 CHECK_DTBS=y qcom/sdm845-samsung-starqltechn.dtb'
errors, but it still complains on 'monitored-battery' and
'power-supplies' though I have 'power-supply.yaml' link in charger
and fuel gauge bindings.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
Dzmitry Sankouski (23):
      power: supply: add undervoltage health status property
      gcc-sdm845: Add rates to the GP clocks
      dt-bindings: panel: add Samsung s6e3ha8
      dt-bindings: mfd: add maxim,max77705
      dt-bindings: input: add maxim,max77705-haptic
      dt-bindings: power: supply: add maxim,max77705 charger
      dt-bindings: power: supply: add maxim,max77705
      dt-bindings: led: add maxim,max77705-leds
      dt-bindings: mfd: add samsung,s2dos05
      dt-bindings: regulator: add samsung,s2dos05
      drm/panel: Add support for S6E3HA8 panel driver
      mfd: Add new driver for MAX77705 PMIC
      input: add max77705 haptic driver
      power: supply: max77705: Add charger driver for Maxim 77705
      power: supply: max77705: Add fuel gauge driver for Maxim 77705
      leds: max77705: Add LEDs support
      mfd: add s2dos series core driver
      regulator: add s2dos05 regulator support
      power: supply: s2dos05: Add fuel gauge driver for s2dos05
      arm64: dts: qcom: starqltechn: remove wifi
      arm64: dts: qcom: starqltechn: remove framebuffer
      arm64: dts: qcom: starqltechn: fix usb regulator mistake
      arm64: dts: qcom: starqltechn: add new features

 .../bindings/display/panel/samsung,s6e3ha8.yaml    |  76 ++
 .../devicetree/bindings/input/maxim,max77705.yaml  |  31 +
 .../devicetree/bindings/leds/maxim,max77705.yaml   |  45 ++
 .../devicetree/bindings/mfd/maxim,max77705.yaml    | 112 +++
 .../devicetree/bindings/mfd/samsung,s2dos05.yaml   |  89 +++
 .../power/supply/maxim,max77705-charger.yaml       |  30 +
 .../bindings/power/supply/maxim,max77705-fg.yaml   |  35 +
 .../bindings/regulator/samsung,s2dos05.yaml        |  36 +
 MAINTAINERS                                        |  15 +
 .../boot/dts/qcom/sdm845-samsung-starqltechn.dts   | 607 +++++++++++++++-
 drivers/clk/qcom/gcc-sdm845.c                      |  14 +
 drivers/gpu/drm/panel/Kconfig                      |   7 +
 drivers/gpu/drm/panel/Makefile                     |   1 +
 drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c      | 426 ++++++++++++
 drivers/input/misc/Kconfig                         |  11 +
 drivers/input/misc/Makefile                        |   1 +
 drivers/input/misc/max77705-haptic.c               | 378 ++++++++++
 drivers/leds/Kconfig                               |   6 +
 drivers/leds/Makefile                              |   1 +
 drivers/leds/leds-max77705.c                       | 166 +++++
 drivers/mfd/Kconfig                                |  25 +
 drivers/mfd/Makefile                               |   3 +
 drivers/mfd/max77705-core.c                        | 278 ++++++++
 drivers/mfd/max77705-irq.c                         | 299 ++++++++
 drivers/mfd/s2dos-core.c                           | 141 ++++
 drivers/power/supply/Kconfig                       |  21 +
 drivers/power/supply/Makefile                      |   3 +
 drivers/power/supply/max77705_charger.c            | 772 +++++++++++++++++++++
 drivers/power/supply/max77705_fuelgauge.c          | 624 +++++++++++++++++
 drivers/power/supply/s2dos05-fg.c                  | 427 ++++++++++++
 drivers/regulator/Kconfig                          |   8 +
 drivers/regulator/Makefile                         |   1 +
 drivers/regulator/s2dos05-regulator.c              | 362 ++++++++++
 include/linux/mfd/max77705-private.h               | 281 ++++++++
 include/linux/mfd/max77705.h                       |  20 +
 include/linux/mfd/max77705_charger.h               | 225 ++++++
 include/linux/mfd/s2dos05.h                        | 123 ++++
 include/linux/mfd/samsung/s2dos-core.h             |  21 +
 include/linux/mfd/samsung/s2dos05.h                | 115 +++
 include/linux/power/max77705_fuelgauge.h           | 107 +++
 include/linux/power_supply.h                       |   1 +
 41 files changed, 5927 insertions(+), 17 deletions(-)
---
base-commit: 6906a84c482f098d31486df8dc98cead21cce2d0
change-id: 20240617-starqltechn_integration_upstream-bc86850b2fe3

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


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

* [PATCH v3 01/23] power: supply: add undervoltage health status property
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 13:59 ` [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks Dzmitry Sankouski
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

Add POWER_SUPPLY_HEALTH_UNDERVOLTAGE status for power supply
to report under voltage lockout failures.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 include/linux/power_supply.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 65082ef75692..0f82a5c0ccf4 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -58,6 +58,7 @@ enum {
 	POWER_SUPPLY_HEALTH_OVERHEAT,
 	POWER_SUPPLY_HEALTH_DEAD,
 	POWER_SUPPLY_HEALTH_OVERVOLTAGE,
+	POWER_SUPPLY_HEALTH_UNDERVOLTAGE,
 	POWER_SUPPLY_HEALTH_UNSPEC_FAILURE,
 	POWER_SUPPLY_HEALTH_COLD,
 	POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE,

-- 
2.39.2


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

* [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
  2024-06-18 13:59 ` [PATCH v3 01/23] power: supply: add undervoltage health status property Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 17:50   ` Dmitry Baryshkov
  2024-06-18 13:59 ` [PATCH v3 03/23] dt-bindings: panel: add Samsung s6e3ha8 Dzmitry Sankouski
                   ` (20 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

sdm845 has "General Purpose" clocks that can be muxed to
SoC pins.

Those clocks may be used as e.g. PWM sources for external peripherals.
Add more frequencies to the table for those clocks so it's possible
for arbitrary peripherals to make use of them.

See also: bf8bb8eaccf(clk: qcom: gcc-msm8916: Add rates to the GP clocks)

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 drivers/clk/qcom/gcc-sdm845.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/clk/qcom/gcc-sdm845.c b/drivers/clk/qcom/gcc-sdm845.c
index ea4c3bf4fb9b..0efd3364e8f5 100644
--- a/drivers/clk/qcom/gcc-sdm845.c
+++ b/drivers/clk/qcom/gcc-sdm845.c
@@ -283,7 +283,21 @@ static struct clk_rcg2 gcc_sdm670_cpuss_rbcpr_clk_src = {
 	},
 };
 
+/*
+ * This is a frequency table for "General Purpose" clocks.
+ * These clocks can be muxed to the SoC pins and may be used by
+ * external devices. They're often used as PWM source.
+ *
+ * See comment in gcc-mam8916.c at ftbl_gcc_gp1_3_clk.
+ */
 static const struct freq_tbl ftbl_gcc_gp1_clk_src[] = {
+	F(10000,   P_BI_TCXO,    16,  1, 120),
+	F(20000,   P_BI_TCXO,    16,  1, 60),
+	F(100000,  P_BI_TCXO,    16,  1,  12),
+	F(500000,  P_GPLL0_OUT_EVEN, 12, 1, 100),
+	F(1000000, P_GPLL0_OUT_EVEN, 12, 1, 50),
+	F(2500000, P_GPLL0_OUT_EVEN, 12, 1, 10),
+	F(5000000, P_GPLL0_OUT_EVEN, 12, 1, 5),
 	F(19200000, P_BI_TCXO, 1, 0, 0),
 	F(25000000, P_GPLL0_OUT_EVEN, 12, 0, 0),
 	F(50000000, P_GPLL0_OUT_EVEN, 6, 0, 0),

-- 
2.39.2


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

* [PATCH v3 03/23] dt-bindings: panel: add Samsung s6e3ha8
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
  2024-06-18 13:59 ` [PATCH v3 01/23] power: supply: add undervoltage health status property Dzmitry Sankouski
  2024-06-18 13:59 ` [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-20 15:44   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705 Dzmitry Sankouski
                   ` (19 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

Add binding for the Samsung s6e3ha8 panel found in the Samsung S9.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 .../bindings/display/panel/samsung,s6e3ha8.yaml    | 76 ++++++++++++++++++++++
 MAINTAINERS                                        |  5 ++
 2 files changed, 81 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml b/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml
new file mode 100644
index 000000000000..9d7d747264dd
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/samsung,s6e3ha8.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Samsung s6e3ha8 AMOLED DSI panel
+
+description: The s6e3ha8 is a 1440x2960 DPI display panel from Samsung Mobile
+  Displays (SMD).
+
+maintainers:
+  - Dzmitry Sankouski <dsankouski@gmail.com>
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+    const: samsung,s6e3ha8
+
+  reg:
+    maxItems: 1
+
+  reset-gpios:
+    description: reset gpio
+
+  port: true
+
+  vdd3-supply:
+    description: VDD regulator
+
+  vci-supply:
+    description: VCI regulator
+
+  vddr-supply:
+    description: VDDR regulator
+
+required:
+  - compatible
+  - reset-gpios
+  - vdd3-supply
+  - vddr-supply
+  - vci-supply
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    dsi {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      panel@0 {
+      	compatible = "samsung,s6e3ha8";
+      	reg = <0>;
+      	vci-supply = <&s2dos05_ldo4>;
+      	vddr-supply = <&s2dos05_buck1>;
+      	vdd3-supply = <&s2dos05_ldo1>;
+      	te-gpios = <&tlmm 10 GPIO_ACTIVE_HIGH>;
+      	reset-gpios = <&tlmm 6 GPIO_ACTIVE_HIGH>;
+      	pinctrl-0 = <&sde_dsi_active &sde_te_active_sleep>;
+      	pinctrl-1 = <&sde_dsi_suspend &sde_te_active_sleep>;
+      	pinctrl-names = "default", "sleep";
+
+      	port {
+      		panel_in: endpoint {
+      			remote-endpoint = <&mdss_dsi0_out>;
+      		};
+      	};
+      };
+    };
+
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index a2f416e4a7c6..fddbd50f7685 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7150,6 +7150,11 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/display/panel/samsung,s6d7aa0.yaml
 F:	drivers/gpu/drm/panel/panel-samsung-s6d7aa0.c
 
+DRM DRIVER FOR SAMSUNG S6E3HA8 PANELS
+M:	Dzmitry Sankouski <dsankouski@gmail.com>
+S:	Maintained
+F:	Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml
+
 DRM DRIVER FOR SITRONIX ST7586 PANELS
 M:	David Lechner <david@lechnology.com>
 S:	Maintained

-- 
2.39.2


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

* [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (2 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 03/23] dt-bindings: panel: add Samsung s6e3ha8 Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 16:53   ` Rob Herring (Arm)
  2024-06-20 15:45   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 05/23] dt-bindings: input: add maxim,max77705-haptic Dzmitry Sankouski
                   ` (18 subsequent siblings)
  22 siblings, 2 replies; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

maxim,max77705 is MAX77705 pmic binding part

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 .../devicetree/bindings/mfd/maxim,max77705.yaml    | 112 +++++++++++++++++++++
 MAINTAINERS                                        |   1 +
 2 files changed, 113 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml
new file mode 100644
index 000000000000..b54408e3d792
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml
@@ -0,0 +1,112 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim MAX77705 Companion Power Management IC and USB Type-C interface IC
+
+maintainers:
+  - Dzmitry Sankouski <dsankouski@gmail.com>
+
+description: |
+  This is a part of device tree bindings for Maxim MAX77705 multi functional device.
+
+  The Maxim MAX77705 is a Companion Power Management and Type-C interface IC which
+  includes charger, fuelgauge, LED, haptic motor driver and Type-C management IC.
+
+properties:
+  compatible:
+    const: maxim,max77705
+
+  reg:
+    description:
+      I2C device address.
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-names:
+    description:
+      MAX77705 shared irq.
+    items:
+      - const: max77705_irq
+
+  charger:
+    $ref: /schemas/power/supply/maxim,max77705-charger.yaml
+
+  fuelgauge:
+    $ref: /schemas/power/supply/maxim,max77705-fg.yaml
+
+  haptic:
+    $ref: /schemas/input/maxim,max77705.yaml
+
+  leds:
+    $ref: /schemas/leds/maxim,max77705.yaml
+
+
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/leds/common.h>
+
+    i2c14 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+    	pmic@66 {
+    		compatible = "maxim,max77705";
+    		reg = <0x66>;
+    		interrupt-parent = <&pm8998_gpios>;
+    		interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+    		interrupt-names = "max77705_irq";
+    		pinctrl-0 = <&chg_int_default>;
+    		pinctrl-names = "default";
+
+    		leds {
+    			compatible = "maxim,max77705-led";
+    			#address-cells = <1>;
+    			#size-cells = <0>;
+
+    			led@1 {
+    				reg = <1>;
+    				label = "red:usr1";
+    			};
+
+    			led@2 {
+    				reg = <2>;
+    				label = "green:usr2";
+    			};
+
+    			led@3 {
+    				reg = <3>;
+    				label = "blue:usr3";
+    			};
+    		};
+
+    		max77705_charger: charger {
+    			compatible = "maxim,max77705-charger";
+    			monitored-battery = <&battery>;
+    		};
+
+    		fuelgauge {
+    			compatible = "maxim,max77705-fg";
+    			monitored-battery = <&battery>;
+    			power-supplies = <&max77705_charger>;
+    			rsense = <5>;
+    		};
+
+
+    		haptic {
+    			compatible = "maxim,max77705-haptic";
+    			haptic-supply = <&vib_regulator>;
+    			pwms = <&vib_pwm 0 50000>;
+    		};
+    	};
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index fddbd50f7685..f008429033c9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13682,6 +13682,7 @@ B:	mailto:linux-samsung-soc@vger.kernel.org
 F:	Documentation/devicetree/bindings/*/maxim,max14577.yaml
 F:	Documentation/devicetree/bindings/*/maxim,max77686.yaml
 F:	Documentation/devicetree/bindings/*/maxim,max77693.yaml
+F:	Documentation/devicetree/bindings/*/maxim,max77705*.yaml
 F:	Documentation/devicetree/bindings/*/maxim,max77843.yaml
 F:	Documentation/devicetree/bindings/clock/maxim,max77686.txt
 F:	drivers/*/*max77843.c

-- 
2.39.2


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

* [PATCH v3 05/23] dt-bindings: input: add maxim,max77705-haptic
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (3 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705 Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-20 15:47   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 06/23] dt-bindings: power: supply: add maxim,max77705 charger Dzmitry Sankouski
                   ` (17 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

maxim,max77705-haptic is MAX77705 pmic binding part

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 .../devicetree/bindings/input/maxim,max77705.yaml  | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/maxim,max77705.yaml b/Documentation/devicetree/bindings/input/maxim,max77705.yaml
new file mode 100644
index 000000000000..8f065a2fe7bd
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/maxim,max77705.yaml
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/maxim,max77705.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim MAX77705 Companion Power Management IC haptic
+
+maintainers:
+  - Dzmitry Sankouski <dsankouski@gmail.com>
+
+description: |
+  This is a part of device tree bindings for Maxim MAX77705 multi functional device.
+
+  See also Documentation/devicetree/bindings/mfd/maxim,max77705.yaml for
+  additional information and example.
+
+properties:
+  compatible:
+    const: maxim,max77705-haptic
+
+  haptic-supply: true
+
+  pwms: true
+
+required:
+  - compatible
+  - haptic-supply
+  - pwms
+
+additionalProperties: false

-- 
2.39.2


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

* [PATCH v3 06/23] dt-bindings: power: supply: add maxim,max77705 charger
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (4 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 05/23] dt-bindings: input: add maxim,max77705-haptic Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-20 15:47   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 07/23] dt-bindings: power: supply: add maxim,max77705 Dzmitry Sankouski
                   ` (16 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

add maxim,max77705 charger binding part

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 .../power/supply/maxim,max77705-charger.yaml       | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml
new file mode 100644
index 000000000000..2b805da2a328
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/maxim,max77705-charger.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim MAX77705 and Companion Power Management IC charger
+
+maintainers:
+  - Dzmitry Sankouski <dsankouski@gmail.com>
+
+description: |
+  This is a part of device tree bindings for Maxim MAX77705 multi functional device.
+
+  See also Documentation/devicetree/bindings/mfd/maxim,max77705.yaml for
+  additional information and example.
+
+allOf:
+  - $ref: power-supply.yaml#
+
+properties:
+  compatible:
+    const: maxim,max77705-charger
+
+required:
+  - compatible
+
+additionalProperties: false
+
+...

-- 
2.39.2


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

* [PATCH v3 07/23] dt-bindings: power: supply: add maxim,max77705
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (5 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 06/23] dt-bindings: power: supply: add maxim,max77705 charger Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 16:53   ` Rob Herring (Arm)
  2024-06-20 16:14   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 08/23] dt-bindings: led: add maxim,max77705-leds Dzmitry Sankouski
                   ` (15 subsequent siblings)
  22 siblings, 2 replies; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

add maxim,max77705 fuel gauge binding part

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 .../bindings/power/supply/maxim,max77705-fg.yaml   | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml
new file mode 100644
index 000000000000..b24db0aba0d7
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/maxim,max77705-fg.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim MAX77705 Companion Power Management IC fuelgauge
+
+maintainers:
+  - Dzmitry Sankouski <dsankouski@gmail.com>
+
+description: |
+  This is a part of device tree bindings for Maxim MAX77705 multi functional device.
+
+  MAX77705 fuelgauge with ModelGauge m5 EZ algorithm support.
+
+  See also Documentation/devicetree/bindings/mfd/maxim,max77705.yaml for
+  additional information and example.
+
+allOf:
+  - $ref: power-supply.yaml#
+
+properties:
+  compatible:
+    const: maxim,max77705-fg
+
+  rsense:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      Sense resistor value in mOhm
+
+required:
+  - compatible
+
+additionalProperties: false

-- 
2.39.2


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

* [PATCH v3 08/23] dt-bindings: led: add maxim,max77705-leds
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (6 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 07/23] dt-bindings: power: supply: add maxim,max77705 Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 13:59 ` [PATCH v3 09/23] dt-bindings: mfd: add samsung,s2dos05 Dzmitry Sankouski
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

add maxim,max77705 leds binding part

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 .../devicetree/bindings/leds/maxim,max77705.yaml   | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/maxim,max77705.yaml b/Documentation/devicetree/bindings/leds/maxim,max77705.yaml
new file mode 100644
index 000000000000..7c512545788a
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/maxim,max77705.yaml
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/maxim,max77705.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim MAX77705 Companion Power Management IC and USB Type-C interface IC LEDs
+
+maintainers:
+  - Dzmitry Sankouski <dsankouski@gmail.com>
+
+description: |
+  This is a part of device tree bindings for Maxim MAX77705 multi functional device.
+
+  Up to 4 LEDs supported. One LED is represented by one child node.
+
+  See also Documentation/devicetree/bindings/mfd/maxim,max77705.yaml for
+  additional information and example.
+
+properties:
+  compatible:
+    const: maxim,max77705-led
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+patternProperties:
+  "^led@[0-3]$":
+    type: object
+    $ref: common.yaml#
+    properties:
+      reg:
+        description:
+          LED index.
+    unevaluatedProperties: false
+    required:
+      - reg
+
+required:
+  - compatible
+
+additionalProperties: false

-- 
2.39.2


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

* [PATCH v3 09/23] dt-bindings: mfd: add samsung,s2dos05
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (7 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 08/23] dt-bindings: led: add maxim,max77705-leds Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 16:53   ` Rob Herring (Arm)
  2024-06-20 15:49   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 10/23] dt-bindings: regulator: " Dzmitry Sankouski
                   ` (13 subsequent siblings)
  22 siblings, 2 replies; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

add samsung,s2dos05 core MFD module binding

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 .../devicetree/bindings/mfd/samsung,s2dos05.yaml   | 89 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 90 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml b/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml
new file mode 100644
index 000000000000..f2ef5171cc40
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml
@@ -0,0 +1,89 @@
+# 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 part of device tree bindings for S2M and S5M family of Power
+  Management IC (PMIC).
+
+  The S2DOS05 is a companion power management IC for the panel and touchscreen
+  in smart phones. Provides voltage and current regulators and adc for power/current
+  measurements.
+
+properties:
+  compatible:
+    const: samsung,s2dos05-pmic
+
+  reg:
+    maxItems: 1
+
+  regulators:
+    $ref: /schemas/regulator/samsung,s2dos05.yaml
+    description: List of regulators and its properties
+
+required:
+  - compatible
+  - reg
+  - regulators
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      pmic@60 {
+      	compatible = "samsung,s2dos05";
+      	reg = <0x60>;
+
+      	regulators {
+      		s2dos05_ldo1: s2dos05-ldo1 {
+      			regulator-name = "s2dos05-ldo1";
+      			regulator-min-microvolt = <1500000>;
+      			regulator-max-microvolt = <2000000>;
+      			regulator-active-discharge = <0x1>;
+      		};
+
+      		s2dos05_ldo2: s2dos05-ldo2 {
+      			regulator-name = "s2dos05-ldo2";
+      			regulator-min-microvolt = <1800000>;
+      			regulator-max-microvolt = <1800000>;
+      			regulator-active-discharge = <0x1>;
+      			regulator-boot-on;
+      		};
+
+      		s2dos05_ldo3: s2dos05-ldo3 {
+      			regulator-name = "s2dos05-ldo3";
+      			regulator-min-microvolt = <3000000>;
+      			regulator-max-microvolt = <3000000>;
+      			regulator-active-discharge = <0x1>;
+      			regulator-boot-on;
+      		};
+
+      		s2dos05_ldo4: s2dos05-ldo4 {
+      			regulator-name = "s2dos05-ldo4";
+      			regulator-min-microvolt = <2700000>;
+      			regulator-max-microvolt = <3775000>;
+      			regulator-active-discharge = <0x1>;
+      		};
+
+      		s2dos05_buck1: s2dos05-buck1 {
+      			regulator-name = "s2dos05-buck1";
+      			regulator-min-microvolt = <850000>;
+      			regulator-max-microvolt = <2100000>;
+      			regulator-active-discharge = <0x1>;
+      		};
+      	};
+      };
+    };
+
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index f008429033c9..3ab41e53c9fc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19897,6 +19897,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,s2dos*.yaml
 F:	Documentation/devicetree/bindings/mfd/samsung,s2m*.yaml
 F:	Documentation/devicetree/bindings/mfd/samsung,s5m*.yaml
 F:	Documentation/devicetree/bindings/regulator/samsung,s2m*.yaml

-- 
2.39.2


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

* [PATCH v3 10/23] dt-bindings: regulator: add samsung,s2dos05
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (8 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 09/23] dt-bindings: mfd: add samsung,s2dos05 Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-20 15:51   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver Dzmitry Sankouski
                   ` (12 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

add samsung,s2dos05 regulator binding part

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 .../bindings/regulator/samsung,s2dos05.yaml        | 36 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 37 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml b/Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml
new file mode 100644
index 000000000000..4b8e4389329c
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/samsung,s2dos05.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Samsung S2DOS05 Power Management IC Regulators
+
+maintainers:
+  - Dzmitry Sankouski <dsankouski@gmail.com>
+
+description:
+  This is a part of device tree bindings for S2M and S5M family of Power
+  Management IC (PMIC).
+
+  Has 4 LDO and 1 BUCK regulators, provides ELVDD, ELVSS, AVDD lines.
+
+  See also Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml for
+  additional information and example.
+
+properties:
+  compatible:
+    const: samsung,s2dos05-regulator
+
+patternProperties:
+  "^buck1|ldo[1-4]$":
+    type: object
+    $ref: regulator.yaml#
+    unevaluatedProperties: false
+
+    required:
+      - regulator-name
+
+additionalProperties: false
+
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 3ab41e53c9fc..92a5d0a56353 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19900,6 +19900,7 @@ F:	Documentation/devicetree/bindings/clock/samsung,s2mps11.yaml
 F:	Documentation/devicetree/bindings/mfd/samsung,s2dos*.yaml
 F:	Documentation/devicetree/bindings/mfd/samsung,s2m*.yaml
 F:	Documentation/devicetree/bindings/mfd/samsung,s5m*.yaml
+F:	Documentation/devicetree/bindings/regulator/samsung,s2dos*.yaml
 F:	Documentation/devicetree/bindings/regulator/samsung,s2m*.yaml
 F:	Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml
 F:	drivers/clk/clk-s2mps11.c

-- 
2.39.2


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

* [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (9 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 10/23] dt-bindings: regulator: " Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 18:39   ` Dmitry Baryshkov
  2024-06-18 13:59 ` [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC Dzmitry Sankouski
                   ` (11 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

Add support for MIPI-DSI based S6E3HA8 AMOLED panel
driver. This panel has 1440x2960 resolution, 5.8-inch physical
size, and can be found in starqltechn device.
Brightness regulation is not yet supported.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 MAINTAINERS                                   |   1 +
 drivers/gpu/drm/panel/Kconfig                 |   7 +
 drivers/gpu/drm/panel/Makefile                |   1 +
 drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c | 426 ++++++++++++++++++++++++++
 4 files changed, 435 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 92a5d0a56353..fae3b8ea9ce4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7154,6 +7154,7 @@ DRM DRIVER FOR SAMSUNG S6E3HA8 PANELS
 M:	Dzmitry Sankouski <dsankouski@gmail.com>
 S:	Maintained
 F:	Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml
+F:	drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c
 
 DRM DRIVER FOR SITRONIX ST7586 PANELS
 M:	David Lechner <david@lechnology.com>
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 2ae0eb0638f3..903fc8c155c0 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -651,6 +651,13 @@ config DRM_PANEL_SAMSUNG_S6E3HA2
 	depends on BACKLIGHT_CLASS_DEVICE
 	select VIDEOMODE_HELPERS
 
+config DRM_PANEL_SAMSUNG_S6E3HA8
+	tristate "Samsung S6E3HA8 DSI video mode panel"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	select VIDEOMODE_HELPERS
+
 config DRM_PANEL_SAMSUNG_S6E63J0X03
 	tristate "Samsung S6E63J0X03 DSI command mode panel"
 	depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index f0203f6e02f4..71774cc5820a 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6D27A1) += panel-samsung-s6d27a1.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6D7AA0) += panel-samsung-s6d7aa0.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3FA7) += panel-samsung-s6e3fa7.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
+obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA8) += panel-samsung-s6e3ha8.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03) += panel-samsung-s6e63j0x03.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += panel-samsung-s6e63m0.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_SPI) += panel-samsung-s6e63m0-spi.o
diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c b/drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c
new file mode 100644
index 000000000000..49d629643171
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c
@@ -0,0 +1,426 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Generated with linux-mdss-dsi-panel-driver-generator from vendor device tree:
+ *  Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/regulator/consumer.h>
+
+#include <drm/display/drm_dsc.h>
+#include <drm/display/drm_dsc_helper.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
+
+struct s6e3ha8 {
+	struct drm_panel panel;
+	struct mipi_dsi_device *dsi;
+	struct drm_dsc_config dsc;
+	struct gpio_desc *reset_gpio;
+	struct regulator_bulk_data supplies[3];
+};
+
+static inline
+struct s6e3ha8 *to_s6e3ha8_amb577px01_wqhd(struct drm_panel *panel)
+{
+	return container_of(panel, struct s6e3ha8, panel);
+}
+
+#define s6e3ha8_call_write_func(ret, func) do {	\
+	ret = (func);				\
+	if (ret < 0)				\
+		return ret;			\
+} while (0)
+
+static int s6e3ha8_test_key_on_lvl1(struct mipi_dsi_device *dsi)
+{
+	static const u8 d[] = { 0x9f, 0xa5, 0xa5 };
+
+	return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));
+	return 0;
+}
+
+static int s6e3ha8_test_key_off_lvl1(struct mipi_dsi_device *dsi)
+{
+	static const u8 d[] = { 0x9f, 0x5a, 0x5a };
+
+	return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));
+	return 0;
+}
+
+static int s6e3ha8_test_key_on_lvl2(struct mipi_dsi_device *dsi)
+{
+	static const u8 d[] = { 0xf0, 0x5a, 0x5a };
+
+	return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));
+}
+
+static int s6e3ha8_test_key_off_lvl2(struct mipi_dsi_device *dsi)
+{
+	static const u8 d[] = { 0xf0, 0xa5, 0xa5 };
+
+	return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));
+}
+
+static int s6e3ha8_test_key_on_lvl3(struct mipi_dsi_device *dsi)
+{
+	static const u8 d[] = { 0xfc, 0x5a, 0x5a };
+
+	return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));
+}
+
+static int s6e3ha8_test_key_off_lvl3(struct mipi_dsi_device *dsi)
+{
+	static const u8 d[] = { 0xfc, 0xa5, 0xa5 };
+
+	return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));
+}
+
+static int s6e3ha8_afc_off(struct mipi_dsi_device *dsi)
+{
+	static const u8 d[] = { 0xe2, 0x00, 0x00 };
+
+	return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));
+	return 0;
+}
+
+static int s6e3ha8_power_on(struct s6e3ha8 *ctx)
+{
+	int ret;
+
+	ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+static int s6e3ha8_power_off(struct s6e3ha8 *ctx)
+{
+	return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+}
+
+static void s6e3ha8_amb577px01_wqhd_reset(struct s6e3ha8 *ctx)
+{
+	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+	usleep_range(5000, 6000);
+	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
+	usleep_range(5000, 6000);
+	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+	usleep_range(5000, 6000);
+}
+
+static int s6e3ha8_amb577px01_wqhd_on(struct s6e3ha8 *ctx)
+{
+	struct mipi_dsi_device *dsi = ctx->dsi;
+	struct device *dev = &dsi->dev;
+	int ret;
+
+	dsi->mode_flags |= MIPI_DSI_MODE_LPM;
+
+	s6e3ha8_test_key_on_lvl1(dsi);
+	s6e3ha8_test_key_on_lvl2(dsi);
+
+	ret = mipi_dsi_compression_mode(dsi, true);
+	if (ret < 0) {
+		dev_err(dev, "Failed to set compression mode: %d\n", ret);
+		return ret;
+	}
+
+	s6e3ha8_test_key_off_lvl2(dsi);
+
+	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to exit sleep mode: %d\n", ret);
+		return ret;
+	}
+	usleep_range(5000, 6000);
+
+	s6e3ha8_test_key_on_lvl2(dsi);
+	mipi_dsi_generic_write_seq(dsi, 0xf2, 0x13);
+	s6e3ha8_test_key_off_lvl2(dsi);
+
+	usleep_range(10000, 11000);
+
+	s6e3ha8_test_key_on_lvl2(dsi);
+	mipi_dsi_generic_write_seq(dsi, 0xf2, 0x13);
+	s6e3ha8_test_key_off_lvl2(dsi);
+
+	/* OMOK setting 1 (Initial setting) - Scaler Latch Setting Guide */
+	s6e3ha8_test_key_on_lvl2(dsi);
+	mipi_dsi_generic_write_seq(dsi, 0xb0, 0x07);
+	/* latch setting 1 : Scaler on/off & address setting & PPS setting -> Image update latch */
+	mipi_dsi_generic_write_seq(dsi, 0xf2, 0x3c, 0x10);
+	mipi_dsi_generic_write_seq(dsi, 0xb0, 0x0b);
+	/* latch setting 2 : Ratio change mode -> Image update latch */
+	mipi_dsi_generic_write_seq(dsi, 0xf2, 0x30);
+	/* OMOK setting 2 - Seamless setting guide : WQHD */
+	mipi_dsi_generic_write_seq(dsi, 0x2a, 0x00, 0x00, 0x05, 0x9f); /* CASET */
+	mipi_dsi_generic_write_seq(dsi, 0x2b, 0x00, 0x00, 0x0b, 0x8f); /* PASET */
+	mipi_dsi_generic_write_seq(dsi, 0xba, 0x01); /* scaler setup : scaler off */
+	s6e3ha8_test_key_off_lvl2(dsi);
+	mipi_dsi_generic_write_seq(dsi, 0x35, 0x00); /* TE Vsync ON */
+	s6e3ha8_test_key_on_lvl2(dsi);
+	mipi_dsi_generic_write_seq(dsi, 0xed, 0x4c); /* ERR_FG */
+	s6e3ha8_test_key_off_lvl2(dsi);
+	s6e3ha8_test_key_on_lvl3(dsi);
+	/* FFC Setting 897.6Mbps */
+	mipi_dsi_generic_write_seq(dsi, 0xc5, 0x0d, 0x10, 0xb4, 0x3e, 0x01);
+	s6e3ha8_test_key_off_lvl3(dsi);
+	s6e3ha8_test_key_on_lvl2(dsi);
+	mipi_dsi_generic_write_seq(dsi, 0xb9,
+				   0x00, 0xb0, 0x81, 0x09, 0x00, 0x00, 0x00,
+				   0x11, 0x03); /* TSP HSYNC Setting */
+	s6e3ha8_test_key_off_lvl2(dsi);
+	s6e3ha8_test_key_on_lvl2(dsi);
+	mipi_dsi_generic_write_seq(dsi, 0xb0, 0x03);
+	mipi_dsi_generic_write_seq(dsi, 0xf6, 0x43);
+	s6e3ha8_test_key_off_lvl2(dsi);
+	s6e3ha8_test_key_on_lvl2(dsi);
+	/* Brightness condition set */
+	mipi_dsi_generic_write_seq(dsi, 0xca,
+				   0x07, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
+				   0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
+				   0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
+				   0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
+				   0x80, 0x80, 0x80, 0x00, 0x00, 0x00);
+	mipi_dsi_generic_write_seq(dsi, 0xb1, 0x00, 0x0c); /* AID Set : 0% */
+	mipi_dsi_generic_write_seq(dsi, 0xb5,
+				   0x19, 0xdc, 0x16, 0x01, 0x34, 0x67, 0x9a,
+				   0xcd, 0x01, 0x22, 0x33, 0x44, 0x00, 0x00,
+				   0x05, 0x55, 0xcc, 0x0c, 0x01, 0x11, 0x11,
+				   0x10); /* MPS/ELVSS Setting */
+	mipi_dsi_generic_write_seq(dsi, 0xf4, 0xeb, 0x28); /* VINT */
+	mipi_dsi_generic_write_seq(dsi, 0xf7, 0x03); /* Gamma, LTPS(AID) update */
+	s6e3ha8_test_key_off_lvl2(dsi);
+	s6e3ha8_test_key_off_lvl1(dsi);
+
+	return 0;
+}
+
+static int s6e3ha8_enable(struct drm_panel *panel)
+{
+	struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel);
+	struct mipi_dsi_device *dsi = ctx->dsi;
+	int ret;
+
+	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_on_lvl1(dsi));
+	s6e3ha8_call_write_func(ret, mipi_dsi_dcs_set_display_on(dsi));
+	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_off_lvl1(dsi));
+
+	return 0;
+}
+
+static int s6e3ha8_disable(struct drm_panel *panel)
+{
+	struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel);
+	struct mipi_dsi_device *dsi = ctx->dsi;
+	int ret;
+
+	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_on_lvl1(dsi));
+	s6e3ha8_call_write_func(ret, mipi_dsi_dcs_set_display_off(dsi));
+	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_off_lvl1(dsi));
+	msleep(20);
+
+	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_on_lvl2(dsi));
+	s6e3ha8_call_write_func(ret, s6e3ha8_afc_off(dsi));
+	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_off_lvl2(dsi));
+
+	msleep(160);
+
+	return 0;
+}
+
+static int s6e3ha8_amb577px01_wqhd_prepare(struct drm_panel *panel)
+{
+	struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel);
+	struct mipi_dsi_device *dsi = ctx->dsi;
+	struct device *dev = &dsi->dev;
+	struct drm_dsc_picture_parameter_set pps;
+	int ret;
+
+	s6e3ha8_power_on(ctx);
+	msleep(120);
+	s6e3ha8_amb577px01_wqhd_reset(ctx);
+	ret = s6e3ha8_amb577px01_wqhd_on(ctx);
+
+	if (ret < 0) {
+		dev_err(dev, "Failed to initialize panel: %d\n", ret);
+		gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+		goto err;
+	}
+
+	drm_dsc_pps_payload_pack(&pps, &ctx->dsc);
+
+	s6e3ha8_test_key_on_lvl1(dsi);
+	ret = mipi_dsi_picture_parameter_set(ctx->dsi, &pps);
+	if (ret < 0) {
+		dev_err(panel->dev, "failed to transmit PPS: %d\n", ret);
+		return ret;
+	}
+	s6e3ha8_test_key_off_lvl1(dsi);
+
+	ret = mipi_dsi_compression_mode(ctx->dsi, true);
+	if (ret < 0) {
+		dev_err(dev, "failed to enable compression mode: %d\n", ret);
+		return ret;
+	}
+
+
+	msleep(28);
+
+	return 0;
+err:
+	s6e3ha8_power_off(ctx);
+	return ret;
+}
+
+static int s6e3ha8_amb577px01_wqhd_unprepare(struct drm_panel *panel)
+{
+	struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel);
+
+	return s6e3ha8_power_off(ctx);
+}
+
+static const struct drm_display_mode s6e3ha8_amb577px01_wqhd_mode = {
+	.clock = (1440 + 116 + 44 + 120) * (2960 + 120 + 80 + 124) * 60 / 1000,
+	.hdisplay = 1440,
+	.hsync_start = 1440 + 116,
+	.hsync_end = 1440 + 116 + 44,
+	.htotal = 1440 + 116 + 44 + 120,
+	.vdisplay = 2960,
+	.vsync_start = 2960 + 120,
+	.vsync_end = 2960 + 120 + 80,
+	.vtotal = 2960 + 120 + 80 + 124,
+	.width_mm = 64,
+	.height_mm = 132,
+};
+
+static int s6e3ha8_amb577px01_wqhd_get_modes(struct drm_panel *panel,
+					     struct drm_connector *connector)
+{
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_duplicate(connector->dev, &s6e3ha8_amb577px01_wqhd_mode);
+	if (!mode)
+		return -ENOMEM;
+
+	drm_mode_set_name(mode);
+
+	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
+	connector->display_info.width_mm = mode->width_mm;
+	connector->display_info.height_mm = mode->height_mm;
+	drm_mode_probed_add(connector, mode);
+
+	return 1;
+}
+
+static const struct drm_panel_funcs s6e3ha8_amb577px01_wqhd_panel_funcs = {
+	.prepare = s6e3ha8_amb577px01_wqhd_prepare,
+	.unprepare = s6e3ha8_amb577px01_wqhd_unprepare,
+	.get_modes = s6e3ha8_amb577px01_wqhd_get_modes,
+	.enable = s6e3ha8_enable,
+	.disable = s6e3ha8_disable,
+};
+
+static int s6e3ha8_amb577px01_wqhd_probe(struct mipi_dsi_device *dsi)
+{
+	struct device *dev = &dsi->dev;
+	struct s6e3ha8 *ctx;
+	int ret;
+
+	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	ctx->supplies[0].supply = "vdd3";
+	ctx->supplies[1].supply = "vci";
+	ctx->supplies[2].supply = "vddr";
+
+	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies),
+				      ctx->supplies);
+	if (ret < 0) {
+		dev_err(dev, "failed to get regulators: %d\n", ret);
+		return ret;
+	}
+
+	ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(ctx->reset_gpio))
+		return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio),
+				     "Failed to get reset-gpios\n");
+
+	ctx->dsi = dsi;
+	mipi_dsi_set_drvdata(dsi, ctx);
+
+	dsi->lanes = 4;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS |
+		MIPI_DSI_MODE_VIDEO_NO_HFP | MIPI_DSI_MODE_VIDEO_NO_HBP |
+		MIPI_DSI_MODE_VIDEO_NO_HSA | MIPI_DSI_MODE_NO_EOT_PACKET;
+
+	drm_panel_init(&ctx->panel, dev, &s6e3ha8_amb577px01_wqhd_panel_funcs,
+		       DRM_MODE_CONNECTOR_DSI);
+	ctx->panel.prepare_prev_first = true;
+
+	drm_panel_add(&ctx->panel);
+
+	/* This panel only supports DSC; unconditionally enable it */
+	dsi->dsc = &ctx->dsc;
+
+	ctx->dsc.dsc_version_major = 1;
+	ctx->dsc.dsc_version_minor = 1;
+
+	ctx->dsc.slice_height = 40;
+	ctx->dsc.slice_width = 720;
+	WARN_ON(1440 % ctx->dsc.slice_width);
+	ctx->dsc.slice_count = 1440 / ctx->dsc.slice_width;
+	ctx->dsc.bits_per_component = 8;
+	ctx->dsc.bits_per_pixel = 8 << 4; /* 4 fractional bits */
+	ctx->dsc.block_pred_enable = true;
+
+	ret = mipi_dsi_attach(dsi);
+	if (ret < 0) {
+		dev_err(dev, "Failed to attach to DSI host: %d\n", ret);
+		drm_panel_remove(&ctx->panel);
+		return ret;
+	}
+
+	return 0;
+}
+
+static void s6e3ha8_amb577px01_wqhd_remove(struct mipi_dsi_device *dsi)
+{
+	struct s6e3ha8 *ctx = mipi_dsi_get_drvdata(dsi);
+	int ret;
+
+	ret = mipi_dsi_detach(dsi);
+	if (ret < 0)
+		dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret);
+
+	drm_panel_remove(&ctx->panel);
+}
+
+static const struct of_device_id s6e3ha8_amb577px01_wqhd_of_match[] = {
+	{ .compatible = "samsung,s6e3ha8" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, s6e3ha8_amb577px01_wqhd_of_match);
+
+static struct mipi_dsi_driver s6e3ha8_amb577px01_wqhd_driver = {
+	.probe = s6e3ha8_amb577px01_wqhd_probe,
+	.remove = s6e3ha8_amb577px01_wqhd_remove,
+	.driver = {
+		.name = "panel-s6e3ha8",
+		.of_match_table = s6e3ha8_amb577px01_wqhd_of_match,
+	},
+};
+module_mipi_dsi_driver(s6e3ha8_amb577px01_wqhd_driver);
+
+MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
+MODULE_DESCRIPTION("DRM driver for S6E3HA8 panel");
+MODULE_LICENSE("GPL");

-- 
2.39.2


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

* [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (10 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-20 16:02   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 13/23] input: add max77705 haptic driver Dzmitry Sankouski
                   ` (10 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski, Rose Hudson

Add the core MFD driver for max77705 PMIC. We define five sub-devices
for which the drivers will be added in subsequent patches.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
Co-authored-by: Rose Hudson <rose@krx.sh>
---
 MAINTAINERS                          |   2 +
 drivers/mfd/Kconfig                  |  12 ++
 drivers/mfd/Makefile                 |   3 +
 drivers/mfd/max77705-core.c          | 278 ++++++++++++++++++++++++++++++++
 drivers/mfd/max77705-irq.c           | 299 +++++++++++++++++++++++++++++++++++
 include/linux/mfd/max77705-private.h | 281 ++++++++++++++++++++++++++++++++
 include/linux/mfd/max77705.h         |  20 +++
 7 files changed, 895 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index fae3b8ea9ce4..f66f08825db9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13690,6 +13690,7 @@ F:	drivers/*/*max77843.c
 F:	drivers/*/max14577*.c
 F:	drivers/*/max77686*.c
 F:	drivers/*/max77693*.c
+F:	drivers/*/max77705*.c
 F:	drivers/clk/clk-max77686.c
 F:	drivers/extcon/extcon-max14577.c
 F:	drivers/extcon/extcon-max77693.c
@@ -13697,6 +13698,7 @@ F:	drivers/rtc/rtc-max77686.c
 F:	include/linux/mfd/max14577*.h
 F:	include/linux/mfd/max77686*.h
 F:	include/linux/mfd/max77693*.h
+F:	include/linux/mfd/max77705*.h
 
 MAXIRADIO FM RADIO RECEIVER DRIVER
 M:	Hans Verkuil <hverkuil@xs4all.nl>
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 266b4f54af60..c4eb8ff2dcad 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -880,6 +880,18 @@ config MFD_MAX77693
 	  additional drivers must be enabled in order to use the functionality
 	  of the device.
 
+config MFD_MAX77705
+	tristate "Maxim Semiconductor MAX77705 PMIC Support"
+	depends on I2C
+	select MFD_CORE
+	help
+	  Say yes here to add support for Maxim Semiconductor MAX77705.
+	  This is a Power Management IC with Charger, safe LDOs, Flash, Haptic
+	  and MUIC controls on chip.
+	  This driver provides common support for accessing the device;
+	  additional drivers must be enabled in order to use the functionality
+	  of the device.
+
 config MFD_MAX77714
 	tristate "Maxim Semiconductor MAX77714 PMIC Support"
 	depends on I2C
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index db1ba39de3b5..bf65cc36d59c 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -162,6 +162,8 @@ obj-$(CONFIG_MFD_MAX77620)	+= max77620.o
 obj-$(CONFIG_MFD_MAX77650)	+= max77650.o
 obj-$(CONFIG_MFD_MAX77686)	+= max77686.o
 obj-$(CONFIG_MFD_MAX77693)	+= max77693.o
+max77705-objs := max77705-core.o max77705-irq.o
+obj-$(CONFIG_MFD_MAX77705)	+= max77705.o
 obj-$(CONFIG_MFD_MAX77714)	+= max77714.o
 obj-$(CONFIG_MFD_MAX77843)	+= max77843.o
 obj-$(CONFIG_MFD_MAX8907)	+= max8907.o
@@ -226,6 +228,7 @@ obj-$(CONFIG_MFD_RK8XX_I2C)	+= rk8xx-i2c.o
 obj-$(CONFIG_MFD_RK8XX_SPI)	+= rk8xx-spi.o
 obj-$(CONFIG_MFD_RN5T618)	+= rn5t618.o
 obj-$(CONFIG_MFD_SEC_CORE)	+= sec-core.o sec-irq.o
+obj-$(CONFIG_MFD_S2DOS05)	+= s2dos05.o
 obj-$(CONFIG_MFD_SYSCON)	+= syscon.o
 obj-$(CONFIG_MFD_LM3533)	+= lm3533-core.o lm3533-ctrlbank.o
 obj-$(CONFIG_MFD_VEXPRESS_SYSREG)	+= vexpress-sysreg.o
diff --git a/drivers/mfd/max77705-core.c b/drivers/mfd/max77705-core.c
new file mode 100644
index 000000000000..7cb71a0a9688
--- /dev/null
+++ b/drivers/mfd/max77705-core.c
@@ -0,0 +1,278 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * max77705.c - mfd core driver for the Maxim 77705
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/mutex.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/max77705.h>
+#include <linux/mfd/max77705-private.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/debugfs.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+
+#define I2C_ADDR_PMIC	(0xCC >> 1)	/* Top sys, Haptic */
+#define I2C_ADDR_MUIC	(0x4A >> 1)
+#define I2C_ADDR_CHG    (0xD2 >> 1)
+#define I2C_ADDR_FG     (0x6C >> 1)
+#define I2C_ADDR_DEBUG  (0xC4 >> 1)
+
+static struct dentry *debugfs_file;
+
+static int max77705_debugfs_show(struct seq_file *s, void *data)
+{
+	struct max77705_dev *max77705 = s->private;
+	struct regmap *regmap = max77705->regmap;
+	unsigned int i, reg, reg_data, pmic_id, pmic_rev;
+	int regs[] = {
+		MAX77705_PMIC_REG_MAINCTRL1,
+		MAX77705_PMIC_REG_MCONFIG,
+		MAX77705_PMIC_REG_MCONFIG2,
+		MAX77705_PMIC_REG_INTSRC,
+		MAX77705_PMIC_REG_INTSRC_MASK,
+		MAX77705_PMIC_REG_SYSTEM_INT,
+		MAX77705_PMIC_REG_SYSTEM_INT_MASK,
+		MAX77705_RGBLED_REG_LEDEN,
+		MAX77705_RGBLED_REG_LED0BRT,
+		MAX77705_RGBLED_REG_LED1BRT,
+		MAX77705_RGBLED_REG_LED2BRT,
+		MAX77705_RGBLED_REG_LED3BRT,
+		MAX77705_RGBLED_REG_LEDBLNK
+	};
+
+	regmap_read(regmap, MAX77705_PMIC_REG_PMICID1, &pmic_id);
+	regmap_read(regmap, MAX77705_PMIC_REG_PMICREV, &pmic_rev);
+	seq_printf(s, "MAX77705, pmic id: %d, pmic rev: %d\n",
+		   pmic_id, pmic_rev);
+	seq_puts(s, "===================\n");
+	for (i = 0; i < ARRAY_SIZE(regs); i++) {
+		reg = regs[i];
+		regmap_read(regmap, reg, &reg_data);
+		seq_printf(s, "0x%02x:\t0x%02x\n", reg, reg_data);
+	}
+
+	seq_puts(s, "\n");
+	return 0;
+}
+
+DEFINE_SHOW_ATTRIBUTE(max77705_debugfs);
+
+static const struct regmap_config max77705_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = MAX77705_PMIC_REG_END,
+};
+
+static const struct regmap_config max77705_leds_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = MAX77705_LED_REG_END,
+};
+
+static const struct regmap_config max77705_fg_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = MAX77705_FG_END,
+};
+
+static struct mfd_cell max77705_devs[] = {
+	{
+		.name = "leds-max77705-rgb",
+		.of_compatible = "maxim,max77705-led",
+	},
+	{
+		.name = "max77705-fuelgauge",
+		.of_compatible = "maxim,max77705-fg",
+	},
+	{
+		.name = "max77705-charger",
+		.of_compatible = "maxim,max77705-charger",
+	},
+	{
+		.name = "max77705-haptic",
+		.of_compatible = "maxim,max77705-haptic",
+	},
+};
+
+static int max77705_i2c_probe(struct i2c_client *i2c)
+{
+	struct max77705_dev *max77705;
+	struct max77705_platform_data *pdata = i2c->dev.platform_data;
+
+	unsigned int reg_data;
+	int ret = 0;
+
+	max77705 = kzalloc(sizeof(struct max77705_dev), GFP_KERNEL);
+	if (!max77705)
+		return -ENOMEM;
+
+	max77705->pdata = pdata;
+	max77705->dev = &i2c->dev;
+	max77705->i2c = i2c;
+	max77705->irq = i2c->irq;
+
+	max77705->regmap = devm_regmap_init_i2c(max77705->i2c, &max77705_regmap_config);
+	if (IS_ERR(max77705->regmap)) {
+		ret = PTR_ERR(max77705->regmap);
+		dev_err(max77705->dev, "failed to allocate register map: %d\n",
+				ret);
+		return ret;
+	}
+
+	max77705->regmap_leds = devm_regmap_init_i2c(max77705->i2c, &max77705_leds_regmap_config);
+	if (IS_ERR(max77705->regmap_leds)) {
+		ret = PTR_ERR(max77705->regmap_leds);
+		dev_err(max77705->dev, "failed to allocate register map: %d\n",
+				ret);
+		return ret;
+	}
+
+	i2c_set_clientdata(i2c, max77705);
+
+	if (regmap_read(max77705->regmap, MAX77705_PMIC_REG_PMICREV, &reg_data) < 0) {
+		dev_err(max77705->dev,
+			"device not found on this channel (this is not an error)\n");
+		ret = -ENODEV;
+		goto err;
+	} else {
+		/* print rev */
+		max77705->pmic_rev = (reg_data & MAX77705_REVISION_MASK);
+		max77705->pmic_ver = ((reg_data & MAX77705_VERSION_MASK) >> MAX77705_VERSION_SHIFT);
+		dev_info(max77705->dev, "%s device found: rev.0x%x, ver.0x%x\n",
+				__func__, max77705->pmic_rev, max77705->pmic_ver);
+	}
+
+	max77705->charger = devm_i2c_new_dummy_device(max77705->dev, i2c->adapter, I2C_ADDR_CHG);
+	i2c_set_clientdata(max77705->charger, max77705);
+	max77705->regmap_charger = devm_regmap_init_i2c(max77705->charger, &max77705_regmap_config);
+	if (IS_ERR(max77705->regmap)) {
+		ret = PTR_ERR(max77705->regmap);
+		dev_err(max77705->dev, "failed to allocate register map: %d\n",
+				ret);
+		return ret;
+	}
+
+	max77705->fuelgauge = devm_i2c_new_dummy_device(max77705->dev, i2c->adapter, I2C_ADDR_FG);
+	i2c_set_clientdata(max77705->fuelgauge, max77705);
+	max77705->regmap_fg = devm_regmap_init_i2c(max77705->fuelgauge, &max77705_fg_regmap_config);
+	if (IS_ERR(max77705->regmap_fg)) {
+		ret = PTR_ERR(max77705->regmap_fg);
+		dev_err(max77705->dev, "failed to allocate register map: %d\n",
+				ret);
+		return ret;
+	}
+
+	if (likely(i2c->irq > 0))
+		max77705->irq = i2c->irq;
+	else {
+		dev_err(max77705->dev, "failed to get irq number\n");
+		return -EINVAL;
+	}
+
+	max77705->irq_base = irq_alloc_descs(-1, 0, MAX77705_IRQ_NR, -1);
+	if (unlikely(max77705->irq_base < 0)) {
+		dev_err(max77705->dev, "irq_alloc_descs fail: %d\n", max77705->irq_base);
+		ret = -EINVAL;
+		goto err;
+	}
+
+	disable_irq(max77705->irq);
+	ret = max77705_irq_init(max77705);
+	if (ret) {
+		dev_err(max77705->dev, "failed to init irq system: %d\n", ret);
+		return ret;
+	}
+
+	ret = mfd_add_devices(max77705->dev, -1, max77705_devs,
+			ARRAY_SIZE(max77705_devs), NULL, 0, NULL);
+	if (ret < 0)
+		goto err_mfd;
+
+	debugfs_file = debugfs_create_file("max77705-regs",
+				0664, NULL, (void *)max77705,
+				  &max77705_debugfs_fops);
+	if (!debugfs_file)
+		dev_err(max77705->dev, "Failed to create debugfs file\n");
+
+	device_init_wakeup(max77705->dev, true);
+
+	return ret;
+
+err_mfd:
+	mfd_remove_devices(max77705->dev);
+err:
+	kfree(max77705);
+	return ret;
+}
+
+static void max77705_i2c_remove(struct i2c_client *i2c)
+{
+	struct max77705_dev *max77705 = i2c_get_clientdata(i2c);
+
+	if (debugfs_file)
+		debugfs_remove(debugfs_file);
+
+	device_init_wakeup(max77705->dev, 0);
+	mfd_remove_devices(max77705->dev);
+}
+
+static int __maybe_unused max77705_suspend(struct device *dev)
+{
+	struct i2c_client *i2c = to_i2c_client(dev);
+	struct max77705_dev *max77705 = i2c_get_clientdata(i2c);
+
+	disable_irq(max77705->irq);
+	if (device_may_wakeup(dev))
+		enable_irq_wake(max77705->irq);
+
+	return 0;
+}
+
+static int __maybe_unused max77705_resume(struct device *dev)
+{
+	struct i2c_client *i2c = to_i2c_client(dev);
+	struct max77705_dev *max77705 = i2c_get_clientdata(i2c);
+
+	if (device_may_wakeup(dev))
+		disable_irq_wake(max77705->irq);
+	enable_irq(max77705->irq);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(max77705_pm, max77705_suspend, max77705_resume);
+
+static const struct of_device_id max77705_i2c_dt_ids[] = {
+	{ .compatible = "maxim,max77705" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, max77705_i2c_dt_ids);
+
+static struct i2c_driver max77705_i2c_driver = {
+	.driver		= {
+		.name	= MFD_DEV_NAME,
+		.pm = &max77705_pm,
+		.of_match_table	= max77705_i2c_dt_ids,
+		.suppress_bind_attrs = true,
+	},
+	.probe		= max77705_i2c_probe,
+	.remove		= max77705_i2c_remove,
+};
+module_i2c_driver(max77705_i2c_driver);
+
+MODULE_DESCRIPTION("MAXIM 77705 multi-function core driver");
+MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
+MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/max77705-irq.c b/drivers/mfd/max77705-irq.c
new file mode 100644
index 000000000000..0da17fc95e18
--- /dev/null
+++ b/drivers/mfd/max77705-irq.c
@@ -0,0 +1,299 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * max77705-irq.c - Interrupt controller support for MAX77705
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
+ */
+
+#include <linux/err.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/mfd/max77705.h>
+#include <linux/mfd/max77705-private.h>
+#include <linux/regmap.h>
+
+static const u8 max77705_mask_reg[] = {
+	[SYS_INT] = MAX77705_PMIC_REG_SYSTEM_INT_MASK,
+	[CHG_INT] = MAX77705_CHG_REG_INT_MASK,
+	[FUEL_INT] = MAX77705_REG_INVALID,
+};
+
+static struct regmap *get_i2c(struct max77705_dev *max77705,
+				enum max77705_irq_source src)
+{
+	switch (src) {
+	case SYS_INT:
+		return max77705->regmap;
+	case FUEL_INT:
+		return max77705->regmap_fg;
+	case CHG_INT:
+		return max77705->regmap_charger;
+	default:
+		return ERR_PTR(-EINVAL);
+	}
+}
+
+struct max77705_irq_data {
+	int mask;
+	enum max77705_irq_source group;
+};
+
+static const struct max77705_irq_data max77705_irqs[] = {
+	[MAX77705_SYSTEM_IRQ_BSTEN_INT] = { .group = SYS_INT, .mask = BIT(3) },
+	[MAX77705_SYSTEM_IRQ_SYSUVLO_INT] = { .group = SYS_INT, .mask = BIT(4) },
+	[MAX77705_SYSTEM_IRQ_SYSOVLO_INT] = { .group = SYS_INT, .mask = BIT(5) },
+	[MAX77705_SYSTEM_IRQ_TSHDN_INT] = { .group = SYS_INT, .mask = BIT(6) },
+	[MAX77705_SYSTEM_IRQ_TM_INT] = { .group = SYS_INT, .mask = BIT(7) },
+
+	[MAX77705_CHG_IRQ_BYP_I] = { .group = CHG_INT, .mask = BIT(0) },
+	[MAX77705_CHG_IRQ_BAT_I] = { .group = CHG_INT, .mask = BIT(3) },
+	[MAX77705_CHG_IRQ_CHG_I] = { .group = CHG_INT, .mask = BIT(4) },
+	[MAX77705_CHG_IRQ_WCIN_I] = { .group = CHG_INT, .mask = BIT(5) },
+	[MAX77705_CHG_IRQ_CHGIN_I] = { .group = CHG_INT, .mask = BIT(6) },
+	[MAX77705_CHG_IRQ_AICL_I] = { .group = CHG_INT, .mask = BIT(7) },
+
+	[MAX77705_FG_IRQ_ALERT] = { .group = FUEL_INT, .mask = BIT(1) },
+};
+
+static void max77705_irq_lock(struct irq_data *data)
+{
+	struct max77705_dev *max77705 = irq_get_chip_data(data->irq);
+
+	mutex_lock(&max77705->irqlock);
+}
+
+static void max77705_irq_sync_unlock(struct irq_data *data)
+{
+	struct max77705_dev *max77705 = irq_get_chip_data(data->irq);
+	int i;
+
+	for (i = 0; i < MAX77705_IRQ_GROUP_NR; i++) {
+		u8 mask_reg = max77705_mask_reg[i];
+		struct regmap *i2c = get_i2c(max77705, i);
+
+		if (mask_reg == MAX77705_REG_INVALID ||
+				IS_ERR_OR_NULL(i2c))
+			continue;
+		max77705->irq_masks_cache[i] = max77705->irq_masks_cur[i];
+
+		regmap_write(i2c, max77705_mask_reg[i],
+				max77705->irq_masks_cur[i]);
+	}
+
+	mutex_unlock(&max77705->irqlock);
+}
+
+static inline void max77705_read_irq_reg(struct regmap *regmap, unsigned int pmic_rev,
+					unsigned int reg, unsigned int *irq_src) {
+	u8 dummy[2] = {0, }; /* for pass1 intr reg clear issue */
+
+	switch (pmic_rev) {
+	case MAX77705_PASS1:
+		regmap_noinc_read(regmap, reg - 1,
+				dummy, sizeof(dummy));
+		*irq_src = (unsigned int) dummy[1];
+		break;
+	case MAX77705_PASS2:
+	case MAX77705_PASS3:
+		regmap_read(regmap, reg,
+				irq_src);
+		break;
+	default:
+		pr_err("%s: PMIC_REVISION(SRC_CHG) isn't valid\n", __func__);
+		break;
+	}
+}
+
+static inline const struct max77705_irq_data *
+irq_to_max77705_irq(struct max77705_dev *max77705, int irq)
+{
+	return &max77705_irqs[irq - max77705->irq_base];
+}
+
+static void max77705_irq_mask(struct irq_data *data)
+{
+	struct max77705_dev *max77705 = irq_get_chip_data(data->irq);
+	const struct max77705_irq_data *irq_data =
+	    irq_to_max77705_irq(max77705, data->irq);
+
+	if (irq_data->group >= MAX77705_IRQ_GROUP_NR)
+		return;
+
+	max77705->irq_masks_cur[irq_data->group] |= irq_data->mask;
+}
+
+static void max77705_irq_unmask(struct irq_data *data)
+{
+	struct max77705_dev *max77705 = irq_get_chip_data(data->irq);
+	const struct max77705_irq_data *irq_data =
+	    irq_to_max77705_irq(max77705, data->irq);
+
+	if (irq_data->group >= MAX77705_IRQ_GROUP_NR)
+		return;
+
+	max77705->irq_masks_cur[irq_data->group] &= ~irq_data->mask;
+}
+
+inline int max77705_irq_mask_subdevice(struct max77705_dev *max77705, unsigned int mask)
+{
+	int ret;
+	unsigned int data;
+
+	ret = regmap_read(max77705->regmap, MAX77705_PMIC_REG_INTSRC_MASK,
+			  &data);
+	if (ret) {
+		dev_err(max77705->dev, "fail to read MAX77705_PMIC_REG_INTSRC_MASK reg\n");
+		return ret;
+	}
+	data |= mask;
+
+	regmap_write(max77705->regmap, MAX77705_PMIC_REG_INTSRC_MASK,
+			   data);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(max77705_irq_mask_subdevice);
+
+inline int max77705_irq_unmask_subdevice(struct max77705_dev *max77705, unsigned int mask)
+{
+	int ret;
+	unsigned int data;
+
+	ret = regmap_read(max77705->regmap, MAX77705_PMIC_REG_INTSRC_MASK,
+			  &data);
+	if (ret) {
+		dev_err(max77705->dev, "fail to read MAX77705_PMIC_REG_INTSRC_MASK reg\n");
+		return ret;
+	}
+	data &= ~(mask);
+
+	regmap_write(max77705->regmap, MAX77705_PMIC_REG_INTSRC_MASK,
+			   data);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(max77705_irq_unmask_subdevice);
+
+static void max77705_irq_disable(struct irq_data *data)
+{
+	max77705_irq_mask(data);
+}
+
+static struct irq_chip max77705_irq_chip = {
+	.name			= MFD_DEV_NAME,
+	.irq_bus_lock		= max77705_irq_lock,
+	.irq_bus_sync_unlock	= max77705_irq_sync_unlock,
+	.irq_mask		= max77705_irq_mask,
+	.irq_unmask		= max77705_irq_unmask,
+	.irq_disable            = max77705_irq_disable,
+};
+
+static irqreturn_t max77705_irq_thread(int irq, void *data)
+{
+	struct max77705_dev *max77705 = data;
+	unsigned int irq_reg[MAX77705_IRQ_GROUP_NR] = {0};
+	unsigned int irq_src;
+	int i, ret;
+	u8 pmic_rev = max77705->pmic_rev;
+
+	max77705->doing_irq = 1;
+
+	ret = regmap_read(max77705->regmap,
+					MAX77705_PMIC_REG_INTSRC, &irq_src);
+	if (ret) {
+		pr_err("%s:%s Failed to read interrupt source: %d\n",
+			MFD_DEV_NAME, __func__, ret);
+
+		max77705->doing_irq = 0;
+		return IRQ_NONE;
+	}
+
+	if (irq_src & MAX77705_IRQSRC_CHG) {
+		max77705_read_irq_reg(max77705->regmap_charger, pmic_rev,
+					MAX77705_CHG_REG_INT, &irq_reg[CHG_INT]);
+		pr_info("%s: charger interrupt(0x%02x)\n",
+				__func__, irq_reg[CHG_INT]);
+	}
+
+	/* Apply masking */
+	for (i = 0; i < MAX77705_IRQ_GROUP_NR; i++)
+		irq_reg[i] &= ~max77705->irq_masks_cur[i];
+
+	/* Report */
+	for (i = 0; i < MAX77705_IRQ_NR; i++) {
+		if (irq_reg[max77705_irqs[i].group] & max77705_irqs[i].mask)
+			handle_nested_irq(max77705->irq_base + i);
+	}
+
+	max77705->doing_irq = 0;
+
+	return IRQ_HANDLED;
+}
+
+int max77705_irq_init(struct max77705_dev *max77705)
+{
+	int i;
+	int ret = 0;
+	int cur_irq;
+
+	if (!max77705->irq_base) {
+		dev_err(max77705->dev, "No interrupt base specified.\n");
+		return 0;
+	}
+
+	mutex_init(&max77705->irqlock);
+
+	/* Mask individual interrupt sources */
+	for (i = 0; i < MAX77705_IRQ_GROUP_NR; i++) {
+		struct regmap *i2c;
+		/* MUIC IRQ  0:MASK 1:NOT MASK => NOT USE */
+		/* Other IRQ 1:MASK 0:NOT MASK */
+		max77705->irq_masks_cur[i] = 0xff;
+		max77705->irq_masks_cache[i] = 0xff;
+
+		i2c = get_i2c(max77705, i);
+
+		if (IS_ERR_OR_NULL(i2c))
+			continue;
+		if (max77705_mask_reg[i] == MAX77705_REG_INVALID)
+			continue;
+		regmap_write(i2c, max77705_mask_reg[i], 0xff);
+	}
+
+	/* Register with genirq */
+	for (i = 0; i < MAX77705_IRQ_NR; i++) {
+		cur_irq = i + max77705->irq_base;
+		irq_set_chip_data(cur_irq, max77705);
+		irq_set_chip_and_handler(cur_irq, &max77705_irq_chip,
+					 handle_level_irq);
+		irq_set_nested_thread(cur_irq, 1);
+#ifdef CONFIG_ARM
+		set_irq_flags(cur_irq, IRQF_VALID);
+#else
+		irq_set_noprobe(cur_irq);
+#endif
+	}
+
+	ret = max77705_irq_mask_subdevice(max77705, MAX77705_IRQSRC_CHG | MAX77705_IRQSRC_TOP |
+					  MAX77705_IRQSRC_FG | MAX77705_IRQSRC_USBC);
+	if (ret) {
+		dev_err(max77705->dev, "Failed to mask subdevice irqs\n");
+		return ret;
+	}
+
+	ret = devm_request_threaded_irq(max77705->dev, max77705->irq, NULL, max77705_irq_thread,
+					IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+					"max77705-irq", max77705);
+	if (ret) {
+		dev_err(max77705->dev, "Failed to request IRQ %d: %d\n",
+				max77705->irq, ret);
+	}
+
+	return ret;
+}
+
+MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/max77705-private.h b/include/linux/mfd/max77705-private.h
new file mode 100644
index 000000000000..bd6ab9c582b8
--- /dev/null
+++ b/include/linux/mfd/max77705-private.h
@@ -0,0 +1,281 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * max77705-private.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_MFD_MAX77705_PRIV_H
+#define __LINUX_MFD_MAX77705_PRIV_H
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/gpio.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+
+#define MAX77705_REG_INVALID		(0xff)
+#define MAX77705_IRQSRC_CHG			BIT(0)
+#define MAX77705_IRQSRC_TOP			BIT(1)
+#define MAX77705_IRQSRC_FG			BIT(2)
+#define MAX77705_IRQSRC_USBC		BIT(3)
+
+/* STATUS_REG */
+#define MAX77705_BAT_ABSENT_MASK	BIT(3)
+/* MAX77705 MAINCTRL1 register */
+#define MAX77705_MAINCTRL1_BIASEN_SHIFT		7
+#define MAX77705_MAINCTRL1_BIASEN_MASK		BIT(MAX77705_MAINCTRL1_BIASEN_SHIFT)
+
+/* max77705-haptic configuration register */
+#define MAX77705_CONFIG2_MEN_SHIFT		6
+#define MAX77705_CONFIG2_MODE_SHIFT		7
+#define MAX77705_CONFIG2_HTYP_SHIFT		5
+
+#define MAX77705_REVISION_MASK	7
+#define MAX77705_VERSION_MASK	0xF8
+#define MAX77705_VERSION_SHIFT	3
+
+enum max77705_hw_rev {
+	MAX77705_PASS1 = 1,
+	MAX77705_PASS2,
+	MAX77705_PASS3,
+};
+
+enum max77705_reg {
+	/* Slave addr = 0xCC */
+	/* PMIC Top-Level Registers */
+	MAX77705_PMIC_REG_PMICID1		= 0x00,
+	MAX77705_PMIC_REG_PMICREV		= 0x01,
+	MAX77705_PMIC_REG_MAINCTRL1		= 0x02,
+	MAX77705_PMIC_REG_INTSRC		= 0x22,
+	MAX77705_PMIC_REG_INTSRC_MASK		= 0x23,
+	MAX77705_PMIC_REG_SYSTEM_INT		= 0x24,
+	MAX77705_PMIC_REG_RESERVED_25		= 0x25,
+	MAX77705_PMIC_REG_SYSTEM_INT_MASK	= 0x26,
+	MAX77705_PMIC_REG_RESERVED_27		= 0x27,
+	MAX77705_PMIC_REG_RESERVED_28		= 0x28,
+	MAX77705_PMIC_REG_RESERVED_29		= 0x29,
+	MAX77705_PMIC_REG_BOOSTCONTROL1		= 0x4C,
+	MAX77705_PMIC_REG_BSTOUT_MASK		= 0x03,
+	MAX77705_PMIC_REG_BOOSTCONTROL2		= 0x4F,
+	MAX77705_PMIC_REG_FORCE_EN_MASK		= 0x08,
+	MAX77705_PMIC_REG_SW_RESET		= 0x50,
+	MAX77705_PMIC_REG_USBC_RESET		= 0x51,
+
+	/* Haptic motor driver Registers */
+	MAX77705_PMIC_REG_MCONFIG		= 0x10,
+	MAX77705_PMIC_REG_MCONFIG2		= 0x11,
+
+	MAX77705_CHG_REG_INT			= 0xB0,
+	MAX77705_CHG_REG_INT_MASK		= 0xB1,
+	MAX77705_CHG_REG_INT_OK			= 0xB2,
+	MAX77705_CHG_REG_DETAILS_00		= 0xB3,
+	MAX77705_CHG_REG_DETAILS_01		= 0xB4,
+	MAX77705_CHG_REG_DETAILS_02		= 0xB5,
+	MAX77705_CHG_REG_DTLS_03		= 0xB6,
+	MAX77705_CHG_REG_CNFG_00		= 0xB7,
+	MAX77705_CHG_REG_CNFG_01		= 0xB8,
+	MAX77705_CHG_REG_CNFG_02		= 0xB9,
+	MAX77705_CHG_REG_CNFG_03		= 0xBA,
+	MAX77705_CHG_REG_CNFG_04		= 0xBB,
+	MAX77705_CHG_REG_CNFG_05		= 0xBC,
+	MAX77705_CHG_REG_CNFG_06		= 0xBD,
+	MAX77705_CHG_REG_CNFG_07		= 0xBE,
+	MAX77705_CHG_REG_CNFG_08		= 0xBF,
+	MAX77705_CHG_REG_CNFG_09		= 0xC0,
+	MAX77705_CHG_REG_CNFG_10		= 0xC1,
+	MAX77705_CHG_REG_CNFG_11		= 0xC2,
+	MAX77705_CHG_REG_CNFG_12		= 0xC3,
+	MAX77705_CHG_REG_CNFG_13		= 0xC4,
+	MAX77705_CHG_REG_CNFG_14		= 0xC5,
+	MAX77705_CHG_REG_SAFEOUT_CTRL		= 0xC6,
+
+	MAX77705_PMIC_REG_END,
+};
+
+enum max77705_charger_battery_state {
+	MAX77705_BATTERY_NOBAT,
+	MAX77705_BATTERY_PREQUALIFICATION,
+	MAX77705_BATTERY_DEAD,
+	MAX77705_BATTERY_GOOD,
+	MAX77705_BATTERY_LOWVOLTAGE,
+	MAX77705_BATTERY_OVERVOLTAGE,
+	MAX77705_BATTERY_RESERVED,
+};
+
+enum max77705_charger_charge_type {
+	MAX77705_CHARGER_CONSTANT_CURRENT	= 1,
+	MAX77705_CHARGER_CONSTANT_VOLTAGE,
+	MAX77705_CHARGER_END_OF_CHARGE,
+	MAX77705_CHARGER_DONE,
+};
+
+/* Slave addr = 0x6C : Fuelgauge */
+enum max77705_fuelgauge_reg {
+	STATUS_REG				= 0x00,
+	VALRT_THRESHOLD_REG			= 0x01,
+	TALRT_THRESHOLD_REG			= 0x02,
+	SALRT_THRESHOLD_REG			= 0x03,
+	REMCAP_REP_REG				= 0x05,
+	SOCREP_REG				= 0x06,
+	TEMPERATURE_REG				= 0x08,
+	VCELL_REG				= 0x09,
+	TIME_TO_EMPTY_REG			= 0x11,
+	FULLSOCTHR_REG				= 0x13,
+	CURRENT_REG				= 0x0A,
+	AVG_CURRENT_REG				= 0x0B,
+	SOCMIX_REG				= 0x0D,
+	SOCAV_REG				= 0x0E,
+	REMCAP_MIX_REG				= 0x0F,
+	FULLCAP_REG				= 0x10,
+	RFAST_REG				= 0x15,
+	AVR_TEMPERATURE_REG			= 0x16,
+	CYCLES_REG				= 0x17,
+	DESIGNCAP_REG				= 0x18,
+	AVR_VCELL_REG				= 0x19,
+	TIME_TO_FULL_REG			= 0x20,
+	CONFIG_REG				= 0x1D,
+	ICHGTERM_REG				= 0x1E,
+	REMCAP_AV_REG				= 0x1F,
+	FULLCAP_NOM_REG				= 0x23,
+	LEARN_CFG_REG				= 0x28,
+	FILTER_CFG_REG				= 0x29,
+	MISCCFG_REG				= 0x2B,
+	QRTABLE20_REG				= 0x32,
+	FULLCAP_REP_REG				= 0x35,
+	RCOMP_REG				= 0x38,
+	VEMPTY_REG				= 0x3A,
+	FSTAT_REG				= 0x3D,
+	DISCHARGE_THRESHOLD_REG			= 0x40,
+	QRTABLE30_REG				= 0x42,
+	ISYS_REG				= 0x43,
+	DQACC_REG				= 0x45,
+	DPACC_REG				= 0x46,
+	AVGISYS_REG				= 0x4B,
+	QH_REG					= 0x4D,
+	VSYS_REG				= 0xB1,
+	TALRTTH2_REG				= 0xB2,
+	/* "not used REG(0xB2)" is for checking fuelgague init result. */
+	FG_INIT_RESULT_REG			= TALRTTH2_REG,
+	VBYP_REG				= 0xB3,
+	CONFIG2_REG				= 0xBB,
+	IIN_REG					= 0xD0,
+	OCV_REG					= 0xEE,
+	VFOCV_REG				= 0xFB,
+	VFSOC_REG				= 0xFF,
+
+	MAX77705_FG_END,
+};
+
+enum max77705_irq_source {
+	SYS_INT = 0,
+	CHG_INT,
+	FUEL_INT,
+	MAX77705_IRQ_GROUP_NR,
+};
+
+
+#define MAX77705_REG_MAINCTRL1_BIASEN		BIT(7)
+
+/* Slave addr = 0x94: RGB LED */
+enum max77705_led_reg {
+	MAX77705_RGBLED_REG_LEDEN			= 0x30,
+	MAX77705_RGBLED_REG_LED0BRT			= 0x31,
+	MAX77705_RGBLED_REG_LED1BRT			= 0x32,
+	MAX77705_RGBLED_REG_LED2BRT			= 0x33,
+	MAX77705_RGBLED_REG_LED3BRT			= 0x34,
+	MAX77705_RGBLED_REG_LEDRMP			= 0x36,
+	MAX77705_RGBLED_REG_LEDBLNK			= 0x38,
+	MAX77705_LED_REG_END,
+};
+
+enum max77705_irq {
+	/* PMIC; TOPSYS */
+	MAX77705_SYSTEM_IRQ_BSTEN_INT,
+	MAX77705_SYSTEM_IRQ_SYSUVLO_INT,
+	MAX77705_SYSTEM_IRQ_SYSOVLO_INT,
+	MAX77705_SYSTEM_IRQ_TSHDN_INT,
+	MAX77705_SYSTEM_IRQ_TM_INT,
+
+	/* PMIC; Charger */
+	MAX77705_CHG_IRQ_BYP_I,
+	MAX77705_CHG_IRQ_BAT_I,
+	MAX77705_CHG_IRQ_CHG_I,
+	MAX77705_CHG_IRQ_WCIN_I,
+	MAX77705_CHG_IRQ_CHGIN_I,
+	MAX77705_CHG_IRQ_AICL_I,
+
+	/* Fuelgauge */
+	MAX77705_FG_IRQ_ALERT,
+
+	MAX77705_IRQ_NR,
+};
+
+struct max77705_dev {
+	struct device *dev;
+	struct i2c_client *i2c; /* 0xCC; Haptic, PMIC */
+	struct i2c_client *charger; /* 0xD2; Charger */
+	struct i2c_client *fuelgauge; /* 0x6C; Fuelgauge */
+	struct i2c_client *muic; /* 0x4A; MUIC */
+	struct i2c_client *debug; /* 0xC4; Debug */
+	struct mutex i2c_lock;
+
+	struct regmap *regmap;
+	struct regmap *regmap_fg;
+	struct regmap *regmap_charger;
+	struct regmap *regmap_leds;
+
+	int type;
+
+	int irq;
+	int irq_base;
+	int irq_masks_cur[MAX77705_IRQ_GROUP_NR];
+	int irq_masks_cache[MAX77705_IRQ_GROUP_NR];
+	bool wakeup;
+	struct mutex irqlock;
+
+#ifdef CONFIG_HIBERNATION
+	/* For hibernation */
+	u8 reg_pmic_dump[MAX77705_PMIC_REG_END];
+	u8 reg_muic_dump[MAX77705_USBC_REG_END];
+	u8 reg_led_dump[MAX77705_LED_REG_END];
+#endif
+
+	/* pmic VER/REV register */
+	u8 pmic_rev;	/* pmic Rev */
+	u8 pmic_ver;	/* pmic version */
+
+	u8 cc_booting_complete;
+
+	wait_queue_head_t queue_empty_wait_q;
+	int doing_irq;
+	int is_usbc_queue;
+
+	struct max77705_platform_data *pdata;
+};
+
+enum max77705_types {
+	TYPE_MAX77705,
+};
+
+
+/**
+ * Unmask sub device interrupts on device level
+ *
+ * @param max77705 - device structure
+ * @param mask - sub device interrupts to unmask
+ */
+extern inline int max77705_irq_unmask_subdevice(struct max77705_dev *max77705, unsigned int mask);
+
+/**
+ * Same as max77705_irq_unmask_device, but for masking.
+ */
+extern inline int max77705_irq_mask_subdevice(struct max77705_dev *max77705, unsigned int mask);
+
+
+extern int max77705_irq_init(struct max77705_dev *max77705);
+
+#endif /* __LINUX_MFD_MAX77705_PRIV_H */
diff --git a/include/linux/mfd/max77705.h b/include/linux/mfd/max77705.h
new file mode 100644
index 000000000000..e2d757c77973
--- /dev/null
+++ b/include/linux/mfd/max77705.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * max77705.h - Driver for the Maxim 77705
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __MAX77705_H__
+#define __MAX77705_H__
+
+#define MFD_DEV_NAME "max77705"
+
+struct max77705_platform_data {
+	struct power_supply_battery_info *bat_info;
+};
+
+#endif /* __MAX77705_H__ */
+

-- 
2.39.2


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

* [PATCH v3 13/23] input: add max77705 haptic driver
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (11 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-20 16:04   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 14/23] power: supply: max77705: Add charger driver for Maxim 77705 Dzmitry Sankouski
                   ` (9 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

Add support for haptic controller on MAX77705 Multifunction
device.

This driver supports external pwm and LRA (Linear Resonant Actuator) motor.
User can control the haptic device via force feedback framework.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 drivers/input/misc/Kconfig           |  11 +
 drivers/input/misc/Makefile          |   1 +
 drivers/input/misc/max77705-haptic.c | 378 +++++++++++++++++++++++++++++++++++
 3 files changed, 390 insertions(+)

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 6ba984d7f0b1..26f7b25a0b42 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -233,6 +233,17 @@ config INPUT_MAX77693_HAPTIC
 	  To compile this driver as module, choose M here: the
 	  module will be called max77693-haptic.
 
+config INPUT_MAX77705_HAPTIC
+	tristate "MAXIM MAX77705 haptic controller support"
+	depends on MFD_MAX77705 && PWM
+	select INPUT_FF_MEMLESS
+	help
+	  This option enables support for the haptic controller on
+	  MAXIM MAX77705 chip.
+
+	  To compile this driver as module, choose M here: the
+	  module will be called max77705-haptic.
+
 config INPUT_MAX8925_ONKEY
 	tristate "MAX8925 ONKEY support"
 	depends on MFD_MAX8925
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 04296a4abe8e..4dea2720b757 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_INPUT_KXTJ9)		+= kxtj9.o
 obj-$(CONFIG_INPUT_M68K_BEEP)		+= m68kspkr.o
 obj-$(CONFIG_INPUT_MAX77650_ONKEY)	+= max77650-onkey.o
 obj-$(CONFIG_INPUT_MAX77693_HAPTIC)	+= max77693-haptic.o
+obj-$(CONFIG_INPUT_MAX77705_HAPTIC)	+= max77705-haptic.o
 obj-$(CONFIG_INPUT_MAX8925_ONKEY)	+= max8925_onkey.o
 obj-$(CONFIG_INPUT_MAX8997_HAPTIC)	+= max8997_haptic.o
 obj-$(CONFIG_INPUT_MC13783_PWRBUTTON)	+= mc13783-pwrbutton.o
diff --git a/drivers/input/misc/max77705-haptic.c b/drivers/input/misc/max77705-haptic.c
new file mode 100644
index 000000000000..e92dcb4fff37
--- /dev/null
+++ b/drivers/input/misc/max77705-haptic.c
@@ -0,0 +1,378 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Based on max77693-haptic.c:
+ *	Copyright (C) 2014,2015 Samsung Electronics
+ *      Jaewon Kim <jaewon02.kim@samsung.com>
+ *      Krzysztof Kozlowski <krzk@kernel.org>
+ *
+ * Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
+ *
+ * This program is not provided / owned by Maxim Integrated Products.
+ */
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/regmap.h>
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/pwm.h>
+#include <linux/slab.h>
+#include <linux/workqueue.h>
+#include <linux/regulator/consumer.h>
+#include <linux/mfd/max77705.h>
+#include <linux/mfd/max77705-private.h>
+
+#define MAX_MAGNITUDE_SHIFT	16
+
+enum max77705_haptic_motor_type {
+	MAX77705_HAPTIC_ERM = 0,
+	MAX77705_HAPTIC_LRA,
+};
+
+enum max77705_haptic_pulse_mode {
+	MAX77705_HAPTIC_EXTERNAL_MODE = 0,
+	MAX77705_HAPTIC_INTERNAL_MODE,
+};
+
+enum max77705_haptic_pwm_divisor {
+	MAX77705_HAPTIC_PWM_DIVISOR_32 = 0,
+	MAX77705_HAPTIC_PWM_DIVISOR_64,
+	MAX77705_HAPTIC_PWM_DIVISOR_128,
+	MAX77705_HAPTIC_PWM_DIVISOR_256,
+};
+
+struct max77705_haptic {
+	enum max77705_types dev_type;
+
+	struct regmap *regmap_pmic;
+	struct regmap *regmap_haptic;
+	struct device *dev;
+	struct input_dev *input_dev;
+	struct pwm_device *pwm_dev;
+	struct regulator *motor_reg;
+
+	bool enabled;
+	bool suspend_state;
+	unsigned int magnitude;
+	unsigned int pwm_duty;
+	enum max77705_haptic_motor_type type;
+	enum max77705_haptic_pulse_mode mode;
+
+	struct work_struct work;
+};
+
+static int max77705_haptic_set_duty_cycle(struct max77705_haptic *haptic)
+{
+	struct pwm_args pargs;
+	int delta;
+	int error;
+
+	pwm_get_args(haptic->pwm_dev, &pargs);
+	delta = (pargs.period + haptic->pwm_duty) / 2;
+	error = pwm_config(haptic->pwm_dev, delta, pargs.period);
+	if (error) {
+		dev_err(haptic->dev, "failed to configure pwm: %d\n", error);
+		return error;
+	}
+
+	return 0;
+}
+
+static int max77705_haptic_bias(struct max77705_haptic *haptic, bool on)
+{
+	int error;
+
+	error = regmap_update_bits(haptic->regmap_haptic,
+							   MAX77705_PMIC_REG_MAINCTRL1,
+							   MAX77705_MAINCTRL1_BIASEN_MASK,
+							   on << MAX77705_MAINCTRL1_BIASEN_SHIFT);
+
+	if (error) {
+		dev_err(haptic->dev, "failed to %s bias: %d\n",
+			on ? "enable" : "disable", error);
+		return error;
+	}
+
+	return 0;
+}
+
+static int max77705_haptic_configure(struct max77705_haptic *haptic,
+				     bool enable)
+{
+	unsigned int value, config_reg;
+	int error;
+
+	value = ((haptic->type << MAX77705_CONFIG2_MODE_SHIFT) |
+		(enable << MAX77705_CONFIG2_MEN_SHIFT) |
+		(haptic->mode << MAX77705_CONFIG2_HTYP_SHIFT) |
+		MAX77705_HAPTIC_PWM_DIVISOR_128);
+	config_reg = MAX77705_PMIC_REG_MCONFIG;
+
+	error = regmap_write(haptic->regmap_haptic,
+			     config_reg, value);
+	if (error) {
+		dev_err(haptic->dev,
+			"failed to update haptic config: %d\n", error);
+		return error;
+	}
+
+	return 0;
+}
+
+static void max77705_haptic_enable(struct max77705_haptic *haptic)
+{
+	int error;
+
+	if (haptic->enabled)
+		return;
+
+	error = pwm_enable(haptic->pwm_dev);
+	if (error) {
+		dev_err(haptic->dev,
+			"failed to enable haptic pwm device: %d\n", error);
+		return;
+	}
+
+	error = max77705_haptic_configure(haptic, true);
+	if (error)
+		goto err_enable_config;
+
+	haptic->enabled = true;
+
+	return;
+
+err_enable_config:
+	pwm_disable(haptic->pwm_dev);
+}
+
+static void max77705_haptic_disable(struct max77705_haptic *haptic)
+{
+	int error;
+
+	if (!haptic->enabled)
+		return;
+
+	error = max77705_haptic_configure(haptic, false);
+	if (error)
+		return;
+
+	pwm_disable(haptic->pwm_dev);
+	haptic->enabled = false;
+}
+
+static void max77705_haptic_play_work(struct work_struct *work)
+{
+	struct max77705_haptic *haptic =
+			container_of(work, struct max77705_haptic, work);
+	int error;
+
+	error = max77705_haptic_set_duty_cycle(haptic);
+	if (error) {
+		dev_err(haptic->dev, "failed to set duty cycle: %d\n", error);
+		return;
+	}
+
+	if (haptic->magnitude)
+		max77705_haptic_enable(haptic);
+	else
+		max77705_haptic_disable(haptic);
+}
+
+static int max77705_haptic_play_effect(struct input_dev *dev, void *data,
+				       struct ff_effect *effect)
+{
+	struct max77705_haptic *haptic = input_get_drvdata(dev);
+	struct pwm_args pargs;
+	u64 period_mag_multi;
+
+	haptic->magnitude = effect->u.rumble.strong_magnitude;
+	if (!haptic->magnitude)
+		haptic->magnitude = effect->u.rumble.weak_magnitude;
+
+	/*
+	 * The magnitude comes from force-feedback interface.
+	 * The formula to convert magnitude to pwm_duty as follows:
+	 * - pwm_duty = (magnitude * pwm_period) / MAX_MAGNITUDE(0xFFFF)
+	 */
+	pr_info("magnitude: %d(%x)", haptic->magnitude, haptic->magnitude);
+	pwm_get_args(haptic->pwm_dev, &pargs);
+	period_mag_multi = (u64)pargs.period * haptic->magnitude;
+	haptic->pwm_duty = (unsigned int)(period_mag_multi >>
+						MAX_MAGNITUDE_SHIFT);
+
+	schedule_work(&haptic->work);
+
+	return 0;
+}
+
+static int max77705_haptic_open(struct input_dev *dev)
+{
+	struct max77705_haptic *haptic = input_get_drvdata(dev);
+	int error;
+
+	error = max77705_haptic_bias(haptic, true);
+	if (error)
+		return error;
+
+	error = regulator_enable(haptic->motor_reg);
+	if (error) {
+		dev_err(haptic->dev,
+			"failed to enable regulator: %d\n", error);
+		return error;
+	}
+
+	return 0;
+}
+
+static void max77705_haptic_close(struct input_dev *dev)
+{
+	struct max77705_haptic *haptic = input_get_drvdata(dev);
+	int error;
+
+	cancel_work_sync(&haptic->work);
+	max77705_haptic_disable(haptic);
+
+	error = regulator_disable(haptic->motor_reg);
+	if (error)
+		dev_err(haptic->dev,
+			"failed to disable regulator: %d\n", error);
+
+	max77705_haptic_bias(haptic, false);
+}
+
+static int max77705_haptic_probe(struct platform_device *pdev)
+{
+	struct max77705_dev *max77705 = dev_get_drvdata(pdev->dev.parent);
+	struct max77705_haptic *haptic;
+	int error;
+
+	haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL);
+	if (!haptic)
+		return -ENOMEM;
+
+	haptic->regmap_pmic = max77705->regmap;
+	haptic->dev = &pdev->dev;
+	haptic->type = MAX77705_HAPTIC_LRA;
+	haptic->mode = MAX77705_HAPTIC_EXTERNAL_MODE;
+	haptic->suspend_state = false;
+
+	/* Variant-specific init */
+	haptic->dev_type = max77705->type;
+	haptic->regmap_haptic = max77705->regmap;
+
+	INIT_WORK(&haptic->work, max77705_haptic_play_work);
+
+	/* Get pwm and regulatot for haptic device */
+	haptic->pwm_dev = devm_pwm_get(&pdev->dev, NULL);
+	if (IS_ERR(haptic->pwm_dev)) {
+		dev_err(&pdev->dev, "failed to get pwm device\n");
+		return PTR_ERR(haptic->pwm_dev);
+	}
+
+	/*
+	 * FIXME: pwm_apply_args() should be removed when switching to the
+	 * atomic PWM API.
+	 */
+	pwm_apply_args(haptic->pwm_dev);
+
+	haptic->motor_reg = devm_regulator_get(&pdev->dev, "haptic");
+	if (IS_ERR(haptic->motor_reg)) {
+		dev_err(&pdev->dev, "failed to get regulator\n");
+		return PTR_ERR(haptic->motor_reg);
+	}
+
+	/* Initialize input device for haptic device */
+	haptic->input_dev = devm_input_allocate_device(&pdev->dev);
+	if (!haptic->input_dev) {
+		dev_err(&pdev->dev, "failed to allocate input device\n");
+		return -ENOMEM;
+	}
+
+	haptic->input_dev->name = "max77705-haptic";
+	haptic->input_dev->id.version = 1;
+	haptic->input_dev->dev.parent = &pdev->dev;
+	haptic->input_dev->open = max77705_haptic_open;
+	haptic->input_dev->close = max77705_haptic_close;
+	input_set_drvdata(haptic->input_dev, haptic);
+	input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE);
+
+	error = input_ff_create_memless(haptic->input_dev, NULL,
+				max77705_haptic_play_effect);
+	if (error) {
+		dev_err(&pdev->dev, "failed to create force-feedback\n");
+		return error;
+	}
+
+	error = input_register_device(haptic->input_dev);
+	if (error) {
+		dev_err(&pdev->dev, "failed to register input device\n");
+		return error;
+	}
+
+	platform_set_drvdata(pdev, haptic);
+
+	return 0;
+}
+
+static void max77705_haptic_remove(struct platform_device *pdev)
+{
+	struct max77705_haptic *haptic = platform_get_drvdata(pdev);
+
+	if (haptic->enabled)
+		max77705_haptic_disable(haptic);
+}
+
+static int max77705_haptic_suspend(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct max77705_haptic *haptic = platform_get_drvdata(pdev);
+
+	if (haptic->enabled) {
+		max77705_haptic_disable(haptic);
+		haptic->suspend_state = true;
+	}
+
+	return 0;
+}
+
+static int max77705_haptic_resume(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct max77705_haptic *haptic = platform_get_drvdata(pdev);
+
+	if (haptic->suspend_state) {
+		max77705_haptic_enable(haptic);
+		haptic->suspend_state = false;
+	}
+
+	return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(max77705_haptic_pm_ops,
+				max77705_haptic_suspend,
+				max77705_haptic_resume);
+
+static const struct of_device_id of_max77705_haptic_dt_match[] = {
+	{ .compatible = "maxim,max77705-haptic", },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, of_max77705_haptic_dt_match);
+
+static struct platform_driver max77705_haptic_driver = {
+	.driver		= {
+		.name	= "max77705-haptic",
+		.pm	= pm_sleep_ptr(&max77705_haptic_pm_ops),
+		.of_match_table = of_max77705_haptic_dt_match,
+	},
+	.probe		= max77705_haptic_probe,
+	.remove_new	= max77705_haptic_remove,
+};
+module_platform_driver(max77705_haptic_driver);
+
+MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
+MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
+MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>");
+MODULE_DESCRIPTION("MAXIM 77705/77705 Haptic driver");
+MODULE_LICENSE("GPL");

-- 
2.39.2


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

* [PATCH v3 14/23] power: supply: max77705: Add charger driver for Maxim 77705
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (12 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 13/23] input: add max77705 haptic driver Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-20 16:06   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 15/23] power: supply: max77705: Add fuel gauge " Dzmitry Sankouski
                   ` (8 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

Add driver for Maxim 77705 switch-mode charger (part of max77705
MFD driver) providing power supply class information to userspace.

The driver is configured through DTS (battery and system related
settings). Also, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE property
is writable, which allows to configure charge end at less than 100%

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 drivers/power/supply/Kconfig            |   6 +
 drivers/power/supply/Makefile           |   1 +
 drivers/power/supply/max77705_charger.c | 772 ++++++++++++++++++++++++++++++++
 include/linux/mfd/max77705_charger.h    | 225 ++++++++++
 4 files changed, 1004 insertions(+)

diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index 3e31375491d5..47ca8cc00a80 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -552,6 +552,12 @@ config CHARGER_MAX77693
 	help
 	  Say Y to enable support for the Maxim MAX77693 battery charger.
 
+config CHARGER_MAX77705
+	tristate "Maxim MAX77705 battery charger driver"
+	depends on MFD_MAX77705
+	help
+	  Say Y to enable support for the Maxim MAX77705 battery charger.
+
 config CHARGER_MAX77976
 	tristate "Maxim MAX77976 battery charger driver"
 	depends on I2C
diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile
index 58b567278034..dbec648c78c9 100644
--- a/drivers/power/supply/Makefile
+++ b/drivers/power/supply/Makefile
@@ -77,6 +77,7 @@ obj-$(CONFIG_CHARGER_MAX14577)	+= max14577_charger.o
 obj-$(CONFIG_CHARGER_DETECTOR_MAX14656)	+= max14656_charger_detector.o
 obj-$(CONFIG_CHARGER_MAX77650)	+= max77650-charger.o
 obj-$(CONFIG_CHARGER_MAX77693)	+= max77693_charger.o
+obj-$(CONFIG_CHARGER_MAX77705)	+= max77705_charger.o
 obj-$(CONFIG_CHARGER_MAX77976)	+= max77976_charger.o
 obj-$(CONFIG_CHARGER_MAX8997)	+= max8997_charger.o
 obj-$(CONFIG_CHARGER_MAX8998)	+= max8998_charger.o
diff --git a/drivers/power/supply/max77705_charger.c b/drivers/power/supply/max77705_charger.c
new file mode 100644
index 000000000000..2b3e836d4c55
--- /dev/null
+++ b/drivers/power/supply/max77705_charger.c
@@ -0,0 +1,772 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * max77705_charger.c - Battery charger driver for the Maxim 77705
+ *
+ * Copyright (C) 2014 Samsung Electronics
+ * Krzysztof Kozlowski <krzk@kernel.org>
+ * Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.org>
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/debugfs.h>
+#include <linux/power_supply.h>
+#include <linux/regmap.h>
+
+#include <linux/mfd/max77705.h>
+#include <linux/mfd/max77705_charger.h>
+#include <linux/mfd/max77705-private.h>
+
+#define MAX77705_CHARGER_NAME				"max77705-charger"
+static const char *max77705_charger_model		= "max77705";
+static const char *max77705_charger_manufacturer	= "Maxim Integrated";
+static struct dentry *debugfs_file;
+
+static enum power_supply_property max77705_charger_props[] = {
+	POWER_SUPPLY_PROP_ONLINE,
+	POWER_SUPPLY_PROP_PRESENT,
+	POWER_SUPPLY_PROP_STATUS,
+	POWER_SUPPLY_PROP_CHARGE_TYPE,
+	POWER_SUPPLY_PROP_HEALTH,
+	POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
+	POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
+	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT,
+	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
+};
+
+static int max77705_get_online(struct regmap *regmap, int *val)
+{
+	unsigned int data;
+	int ret;
+
+	ret = regmap_read(regmap, MAX77705_CHG_REG_INT_OK, &data);
+	if (ret < 0)
+		return ret;
+
+	*val = !!(data & MAX77705_CHGIN_OK);
+
+	return 0;
+}
+
+static int max77705_get_charger_state(struct max77705_charger_data *charger)
+{
+	struct regmap *regmap = charger->max77705->regmap_charger;
+	int status = POWER_SUPPLY_STATUS_UNKNOWN;
+	unsigned int reg_data;
+
+	regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, &reg_data);
+
+	pr_debug("%s: charger status (0x%02x)\n", __func__, reg_data);
+
+	reg_data &= 0x0f;
+
+	switch (reg_data) {
+	case 0x0:
+	case MAX77705_CHARGER_CONSTANT_CURRENT:
+	case MAX77705_CHARGER_CONSTANT_VOLTAGE:
+		status = POWER_SUPPLY_STATUS_CHARGING;
+		break;
+	case MAX77705_CHARGER_END_OF_CHARGE:
+	case MAX77705_CHARGER_DONE:
+		status = POWER_SUPPLY_STATUS_FULL;
+		break;
+	case 0x05:
+	case 0x06:
+	case 0x07:
+		status = POWER_SUPPLY_STATUS_NOT_CHARGING;
+		break;
+	case 0x08:
+	case 0xA:
+	case 0xB:
+		status = POWER_SUPPLY_STATUS_DISCHARGING;
+		break;
+	default:
+		status = POWER_SUPPLY_STATUS_UNKNOWN;
+		break;
+	}
+
+	return (int)status;
+}
+
+static int max77705_get_battery_health(struct regmap *regmap, int *value)
+{
+	unsigned int bat_dtls;
+
+	regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, &bat_dtls);
+	bat_dtls = ((bat_dtls & MAX77705_BAT_DTLS) >> MAX77705_BAT_DTLS_SHIFT);
+
+	pr_debug("%s: bat_dtls(0x%x)\n", __func__, bat_dtls);
+
+	switch (bat_dtls) {
+	case MAX77705_BATTERY_NOBAT:
+		pr_debug("%s: No battery and the charger is suspended\n", __func__);
+		*value = POWER_SUPPLY_HEALTH_NO_BATTERY;
+		break;
+	case MAX77705_BATTERY_PREQUALIFICATION:
+		pr_debug("%s: battery is okay but its voltage is low(~VPQLB)\n", __func__);
+		break;
+	case MAX77705_BATTERY_DEAD:
+		pr_debug("%s: battery dead\n", __func__);
+		*value = POWER_SUPPLY_HEALTH_DEAD;
+		break;
+	case MAX77705_BATTERY_GOOD:
+	case MAX77705_BATTERY_LOWVOLTAGE:
+		*value = POWER_SUPPLY_HEALTH_GOOD;
+		break;
+	case MAX77705_BATTERY_OVERVOLTAGE:
+		pr_debug("%s: battery ovp\n", __func__);
+		*value = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
+		break;
+	default:
+		pr_debug("%s: battery unknown\n", __func__);
+		*value = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
+		break;
+	}
+
+	return 0;
+}
+
+static int max77705_get_vbus_state(struct regmap *regmap, int *value)
+{
+	int ret;
+	unsigned int charge_dtls;
+
+	ret = regmap_read(regmap, MAX77705_CHG_REG_DETAILS_00, &charge_dtls);
+	if (ret)
+		return ret;
+
+	charge_dtls = ((charge_dtls & MAX77705_CHGIN_DTLS) >>
+			MAX77705_CHGIN_DTLS_SHIFT);
+
+	switch (charge_dtls) {
+	case 0x00:
+		*value = POWER_SUPPLY_HEALTH_UNDERVOLTAGE;
+		break;
+	case 0x01:
+		*value = POWER_SUPPLY_HEALTH_UNDERVOLTAGE;
+		break;
+	case 0x02:
+		*value = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
+		break;
+	case 0x03:
+		*value = POWER_SUPPLY_HEALTH_GOOD;
+		break;
+	default:
+		return 0;
+	}
+	return 0;
+}
+
+static int max77705_get_health(struct regmap *regmap, int *value)
+{
+	int ret, is_online = 0;
+
+	ret = max77705_get_online(regmap, &is_online);
+	if (ret)
+		return ret;
+	if (is_online) {
+		ret = max77705_get_vbus_state(regmap, value);
+		if (ret || (*value != POWER_SUPPLY_HEALTH_GOOD))
+			return ret;
+	}
+	ret = max77705_get_battery_health(regmap, value);
+	if (ret)
+		return ret;
+	return ret;
+}
+
+static int max77705_get_input_current(struct max77705_charger_data *charger)
+{
+	unsigned int reg_data;
+	int get_current = 0;
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+	regmap_read(regmap,
+			  MAX77705_CHG_REG_CNFG_09, &reg_data);
+	/* AND operation for removing the formal 1bit  */
+	reg_data &= MAX77705_CHG_CHGIN_LIM_MASK;
+
+	if (reg_data <= 0x3)
+		get_current = 100;
+	else if (reg_data >= 0x7F)
+		get_current = 3200;
+	else
+		get_current = (reg_data + 0x01) * 25;
+
+	dev_dbg(charger->dev, "reg:(0x%x), charging_current:(%d)\n",
+			reg_data, get_current);
+
+	return get_current;
+}
+
+static void max77705_set_input_current(struct max77705_charger_data *charger,
+					int input_current)
+{
+	int curr_step = 25;
+	u8 set_reg, set_mask, reg_data = 0;
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+	mutex_lock(&charger->charger_mutex);
+
+
+	set_reg = MAX77705_CHG_REG_CNFG_09;
+	set_mask = MAX77705_CHG_CHGIN_LIM_MASK;
+
+	if (input_current < 100) {
+		reg_data = 0x00;
+		regmap_update_bits(regmap, set_reg, set_mask, reg_data);
+	} else {
+		input_current = (input_current > 3200) ? 3200 : input_current;
+		reg_data = (input_current / curr_step) - 0x01;
+		regmap_update_bits(regmap, set_reg, set_mask, reg_data);
+	}
+
+	mutex_unlock(&charger->charger_mutex);
+	dev_dbg(charger->dev, "REG(0x%02x) DATA(0x%02x), CURRENT(%d)\n",
+		set_reg, reg_data, input_current);
+}
+
+static int max77705_get_float_voltage(struct max77705_charger_data *charger)
+{
+	unsigned int reg_data = 0;
+	int float_voltage;
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+	regmap_read(regmap, MAX77705_CHG_REG_CNFG_04, &reg_data);
+	reg_data &= 0x3F;
+	float_voltage = reg_data <= 0x04 ? reg_data * 50 + 4000 :
+					(reg_data - 4) * 10 + 4200;
+	dev_dbg(charger->dev, "battery cv reg : 0x%x, float voltage val : %d\n",
+		reg_data, float_voltage);
+
+	return float_voltage;
+}
+
+static void max77705_set_float_voltage(struct max77705_charger_data *charger,
+					int float_voltage)
+{
+	int float_voltage_mv;
+	unsigned int reg_data = 0;
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+	float_voltage_mv = float_voltage / 1000;
+	reg_data = float_voltage_mv <= 4000 ? 0x0 :
+		float_voltage_mv >= 4500 ? 0x23 :
+		(float_voltage_mv <= 4200) ? (float_voltage_mv - 4000) / 50 :
+		(((float_voltage_mv - 4200) / 10) + 0x04);
+
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_04,
+				CHG_CNFG_04_CHG_CV_PRM_MASK,
+				(reg_data << CHG_CNFG_04_CHG_CV_PRM_SHIFT));
+
+	regmap_read(regmap, MAX77705_CHG_REG_CNFG_04, &reg_data);
+	dev_dbg(charger->dev, "battery cv voltage 0x%x\n", reg_data);
+}
+
+static bool max77705_check_battery(struct max77705_charger_data *charger)
+{
+	unsigned int reg_data;
+	unsigned int reg_data2;
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+
+	regmap_read(regmap, MAX77705_CHG_REG_INT_OK, &reg_data);
+
+	dev_dbg(charger->dev, "CHG_INT_OK(0x%x)\n", reg_data);
+
+	regmap_read(regmap,
+			  MAX77705_CHG_REG_DETAILS_00, &reg_data2);
+
+	dev_dbg(charger->dev, "CHG_DETAILS00(0x%x)\n", reg_data2);
+
+	if ((reg_data & MAX77705_BATP_OK) || !(reg_data2 & MAX77705_BATP_DTLS))
+		return true;
+	else
+		return false;
+}
+
+static int max77705_get_charge_type(struct regmap *regmap,
+					union power_supply_propval *val)
+{
+	unsigned int reg_data;
+
+	regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, &reg_data);
+	reg_data &= 0x0F;
+	switch (reg_data) {
+	case MAX77705_CHARGER_CONSTANT_CURRENT:
+		val->strval = "CC Mode";
+		break;
+	case MAX77705_CHARGER_CONSTANT_VOLTAGE:
+		val->strval = "CV Mode";
+		break;
+	case MAX77705_CHARGER_END_OF_CHARGE:
+		val->strval = "EOC";
+		break;
+	case MAX77705_CHARGER_DONE:
+		val->strval = "DONE";
+		break;
+	default:
+		val->strval = "NONE";
+		break;
+	}
+
+	return 0;
+}
+
+static int max77705_get_charge_current(struct max77705_charger_data *charger)
+{
+	unsigned int reg_data;
+	int get_current = 0;
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+
+	regmap_read(regmap, MAX77705_CHG_REG_CNFG_02, &reg_data);
+	reg_data &= MAX77705_CHG_CC;
+
+	get_current = reg_data <= 0x2 ? 100 : reg_data * 50;
+
+	dev_dbg(charger->dev, "reg:(0x%x), charging_current:(%d)\n",
+			reg_data, get_current);
+	return get_current;
+}
+
+static void max77705_set_charge_current(struct max77705_charger_data *charger,
+					int fast_charging_current)
+{
+	int curr_step = 50;
+	u8 set_mask, reg_data = 0;
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+	set_mask = MAX77705_CHG_CC;
+
+	if (fast_charging_current < 100) {
+		regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_02, set_mask, 0x00);
+	} else {
+		fast_charging_current =
+			(fast_charging_current > 3150) ? 3150 : fast_charging_current;
+
+		reg_data |= (fast_charging_current / curr_step);
+		regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_02, set_mask, reg_data);
+	}
+
+	dev_dbg(charger->dev, "REG(0x%02x) DATA(0x%02x), CURRENT(%d)\n",
+		MAX77705_CHG_REG_CNFG_02,
+		reg_data, fast_charging_current);
+}
+
+static int max77705_chg_set_wdtmr_en(struct max77705_charger_data *charger, bool enable)
+{
+	dev_dbg(charger->dev, "WDT en = %d\n", enable);
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+	if (enable) {
+		regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00,
+					CHG_CNFG_00_WDTEN_MASK, CHG_CNFG_00_WDTEN_MASK);
+	} else {
+		regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00,
+					 CHG_CNFG_00_WDTEN_MASK, 0);
+	}
+
+	return 0;
+}
+
+static void max77705_charger_initialize(struct max77705_charger_data *charger)
+{
+	u8 reg_data;
+	struct power_supply_battery_info *info;
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+	if (power_supply_get_battery_info(charger->psy_chg, &info) < 0)
+		return;
+
+	charger->bat_info = info;
+
+	/* unlock charger setting protect
+	 * slowest LX slope
+	 */
+	reg_data = MAX77705_CHGPROT_MASK | MAX77705_SLOWEST_LX_SLOPE;
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_06, reg_data,
+						reg_data);
+
+	/*
+	 * fast charge timer disable
+	 * restart threshold disable
+	 * pre-qual charge disable
+	 */
+	reg_data = (MAX77705_FCHGTIME_DISABLE << CHG_CNFG_01_FCHGTIME_SHIFT) |
+			(MAX77705_CHG_RSTRT_DISABLE << CHG_CNFG_01_CHG_RSTRT_SHIFT) |
+			(MAX77705_CHG_PQEN_DISABLE << CHG_CNFG_01_PQEN_SHIFT);
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_01,
+						(CHG_CNFG_01_FCHGTIME_MASK |
+						CHG_CNFG_01_CHG_RSTRT_MASK |
+						CHG_CNFG_01_PQEN_MASK),
+						reg_data);
+
+	/*
+	 * OTG off(UNO on), boost off
+	 */
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00,
+				CHG_CNFG_00_OTG_CTRL, 0);
+
+	/*
+	 * charge current 450mA(default)
+	 * otg current limit 900mA
+	 */
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_02,
+				CHG_CNFG_02_OTG_ILIM_MASK,
+				MAX77705_OTG_ILIM_900 << CHG_CNFG_02_OTG_ILIM_SHIFT);
+
+	/* BAT to SYS OCP 4.80A */
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_05,
+				CHG_CNFG_05_REG_B2SOVRC_MASK,
+				MAX77705_B2SOVRC_4_8A << CHG_CNFG_05_REG_B2SOVRC_SHIFT);
+	/*
+	 * top off current 150mA
+	 * top off timer 30min
+	 */
+	reg_data = (MAX77705_TO_ITH_150MA << CHG_CNFG_03_TO_ITH_SHIFT) |
+			(MAX77705_TO_TIME_30M << CHG_CNFG_03_TO_TIME_SHIFT) |
+			(MAX77705_SYS_TRACK_DISABLE << CHG_CNFG_03_SYS_TRACK_DIS_SHIFT);
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_03,
+			   (CHG_CNFG_03_TO_ITH_MASK |
+			   CHG_CNFG_03_TO_TIME_MASK |
+			   CHG_CNFG_03_SYS_TRACK_DIS_MASK), reg_data);
+
+	/*
+	 * cv voltage 4.2V or 4.35V
+	 * MINVSYS 3.6V(default)
+	 */
+	if (info->voltage_max_design_uv < 0) {
+		dev_warn(charger->dev, "missing battery:voltage-max-design-microvolt\n");
+		max77705_set_float_voltage(charger, 4200000);
+	} else {
+		max77705_set_float_voltage(charger, info->voltage_max_design_uv);
+	}
+
+	/* VCHGIN : REG=4.5V, UVLO=4.7V, WCHGIN : REG=4.5V, UVLO=4.7V */
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12,
+				CHG_CNFG_12_VCHGIN_REG_MASK | CHG_CNFG_12_WCIN_REG_MASK, 0);
+
+	/* Boost mode possible in FACTORY MODE */
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_07,
+				CHG_CNFG_07_REG_FMBST_MASK, MAX77705_CHG_FMBST);
+
+	/* Watchdog timer */
+	max77705_chg_set_wdtmr_en(charger, 0);
+
+	/* Active Discharge Enable */
+	regmap_update_bits(regmap, MAX77705_PMIC_REG_MAINCTRL1, 1, 1);
+
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_09, MAX77705_CHG_EN, MAX77705_CHG_EN);
+
+	/* VBYPSET=5.0V */
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_11, CHG_CNFG_11_VBYPSET_MASK, 0);
+
+	/* Switching Frequency : 1.5MHz */
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_08, CHG_CNFG_08_REG_FSW_MASK,
+				(MAX77705_CHG_FSW_1_5MHz << CHG_CNFG_08_REG_FSW_SHIFT));
+
+	/* Auto skip mode */
+	regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, CHG_CNFG_12_REG_DISKIP_MASK,
+				(MAX77705_AUTO_SKIP << CHG_CNFG_12_REG_DISKIP_SHIFT));
+}
+
+static bool max77705_charger_unlock(struct max77705_charger_data *charger)
+{
+	unsigned int reg_data;
+	unsigned int chgprot;
+	int retry_cnt = 0;
+	bool need_init = false;
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+	do {
+		regmap_read(regmap, MAX77705_CHG_REG_CNFG_06,
+				  &reg_data);
+		chgprot = (reg_data & MAX77705_CHGPROT_MASK);
+		if (chgprot != MAX77705_CHGPROT_UNLOCKED) {
+			dev_err(charger->dev, "unlock err, chgprot(0x%x), retry(%d)\n",
+					chgprot, retry_cnt);
+			regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_06,
+						MAX77705_CHGPROT_MASK, MAX77705_CHGPROT_MASK);
+			need_init = true;
+			msleep(20);
+		} else
+			break;
+	} while ((chgprot != MAX77705_CHGPROT_UNLOCKED) && (++retry_cnt < 10));
+
+	return need_init;
+}
+
+static int max77705_prop_writeable(struct power_supply *psy,
+					  enum power_supply_property psp)
+{
+	return (psp == POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT) ||
+		(psp == POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN) ||
+		(psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT) ||
+		(psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE);
+}
+
+static int max77705_chg_set_property(struct power_supply *psy,
+					enum power_supply_property psp,
+					const union power_supply_propval *val)
+{
+	struct max77705_charger_data *charger = power_supply_get_drvdata(psy);
+
+	/* check unlock status before does set the register */
+	max77705_charger_unlock(charger);
+	switch (psp) {
+	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
+		max77705_set_input_current(charger, val->intval);
+		break;
+	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
+		max77705_set_charge_current(charger, val->intval);
+		break;
+	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
+		if (val->intval > charger->bat_info->voltage_max_design_uv) {
+			dev_err(charger->dev, "%d voltage higher than max",
+				val->intval);
+			return -EINVAL;
+		}
+		max77705_set_float_voltage(charger, val->intval);
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static int max77705_chg_get_property(struct power_supply *psy,
+					enum power_supply_property psp,
+					union power_supply_propval *val)
+{
+	int ret = 0;
+	struct max77705_charger_data *charger = power_supply_get_drvdata(psy);
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_ONLINE:
+		max77705_get_online(regmap, &val->intval);
+		break;
+	case POWER_SUPPLY_PROP_PRESENT:
+		val->intval = max77705_check_battery(charger);
+		break;
+	case POWER_SUPPLY_PROP_STATUS:
+		val->intval = max77705_get_charger_state(charger);
+		break;
+	case POWER_SUPPLY_PROP_HEALTH:
+		ret = max77705_get_health(regmap, &val->intval);
+		break;
+	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
+		val->intval = max77705_get_input_current(charger);
+		break;
+	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
+		val->intval = max77705_get_charge_current(charger);
+		break;
+	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
+		val->intval = max77705_get_float_voltage(charger);
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
+		val->intval = charger->bat_info->voltage_max_design_uv;
+		break;
+	case POWER_SUPPLY_PROP_CHARGE_TYPE:
+		ret = max77705_get_charge_type(regmap, val);
+		break;
+	case POWER_SUPPLY_PROP_MODEL_NAME:
+		val->strval = max77705_charger_model;
+		break;
+	case POWER_SUPPLY_PROP_MANUFACTURER:
+		val->strval = max77705_charger_manufacturer;
+		break;
+	default:
+		return -EINVAL;
+	}
+	return ret;
+}
+
+static void max77705_chgin_isr_work(struct work_struct *work)
+{
+	struct max77705_charger_data *charger =
+		container_of(work, struct max77705_charger_data, chgin_work);
+	regmap_update_bits(charger->max77705->regmap_charger,
+						MAX77705_CHG_REG_INT_MASK,
+						MAX77705_CHGIN_IM, MAX77705_CHGIN_IM);
+	power_supply_changed(charger->psy_chg);
+	regmap_update_bits(charger->max77705->regmap_charger,
+						MAX77705_CHG_REG_INT_MASK,
+						MAX77705_CHGIN_IM, 0);
+}
+
+static irqreturn_t max77705_chgin_irq(int irq, void *data)
+{
+	struct max77705_charger_data *charger = data;
+
+	queue_work(charger->wqueue, &charger->chgin_work);
+
+	return IRQ_HANDLED;
+}
+
+static int max77705_debugfs_show(struct seq_file *s, void *data)
+{
+	struct max77705_charger_data *charger = s->private;
+	struct regmap *regmap = charger->max77705->regmap_charger;
+	unsigned int reg, reg_data;
+
+	seq_printf(s, "MAX77705 CHARGER IC, ver.0x%x\n", charger->pmic_ver);
+	seq_puts(s, "===================\n");
+	for (reg = 0xB0; reg <= 0xC3; reg++) {
+		regmap_read(regmap, reg, &reg_data);
+		seq_printf(s, "0x%02x:\t0x%02x\n", reg, reg_data);
+	}
+
+	seq_puts(s, "\n");
+	return 0;
+}
+
+static int max77705_debugfs_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, max77705_debugfs_show, inode->i_private);
+}
+
+static const struct file_operations max77705_debugfs_fops = {
+	.open = max77705_debugfs_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
+static const struct power_supply_desc max77705_charger_power_supply_desc = {
+	.name = MAX77705_CHARGER_NAME,
+	.type		= POWER_SUPPLY_TYPE_BATTERY,
+	.properties = max77705_charger_props,
+	.num_properties = ARRAY_SIZE(max77705_charger_props),
+	.get_property = max77705_chg_get_property,
+	.set_property = max77705_chg_set_property,
+	.property_is_writeable = max77705_prop_writeable,
+};
+
+static int max77705_charger_probe(struct platform_device *pdev)
+{
+	struct max77705_dev *max77705 = dev_get_drvdata(pdev->dev.parent);
+	struct max77705_platform_data *pdata = dev_get_platdata(max77705->dev);
+	struct max77705_charger_data *charger;
+	struct regmap *regmap = max77705->regmap_charger;
+	struct power_supply_config charger_cfg = { };
+	int ret = 0;
+	unsigned int reg_data;
+
+	charger = kzalloc(sizeof(*charger), GFP_KERNEL);
+	if (!charger)
+		return -ENOMEM;
+
+	mutex_init(&charger->charger_mutex);
+
+	charger->dev = &pdev->dev;
+	charger->max77705 = max77705;
+	charger->max77705_pdata = pdata;
+
+	platform_set_drvdata(pdev, charger);
+
+	regmap_read(regmap, MAX77705_CHG_REG_INT_OK, &reg_data);
+
+	if (regmap_read
+		(max77705->regmap, MAX77705_PMIC_REG_PMICREV, &reg_data) < 0) {
+		dev_err(charger->dev,
+			"device not found on this channel (this is not an error)\n");
+		ret = -ENOMEM;
+	} else {
+		charger->pmic_ver = (reg_data & 0x7);
+		dev_dbg(charger->dev, "device found : ver.0x%x\n", charger->pmic_ver);
+	}
+
+	debugfs_file = debugfs_create_file("max77705-charger-regs",
+				0664, NULL, (void *)charger,
+				  &max77705_debugfs_fops);
+	if (!debugfs_file)
+		dev_err(charger->dev, "Failed to create debugfs file\n");
+
+	charger_cfg.drv_data = charger;
+	charger_cfg.of_node = charger->dev->of_node;
+
+	charger->psy_chg =
+		devm_power_supply_register(&pdev->dev,
+				  &max77705_charger_power_supply_desc,
+				  &charger_cfg);
+	if (IS_ERR(charger->psy_chg)) {
+		dev_err(charger->dev, "Failed to Register psy_chg\n");
+		goto err_free;
+	}
+
+	max77705_charger_initialize(charger);
+
+	charger->wqueue = create_singlethread_workqueue(dev_name(&pdev->dev));
+	if (!charger->wqueue) {
+		pr_err("%s: Fail to Create Workqueue\n", __func__);
+		goto err_free;
+	}
+	INIT_WORK(&charger->chgin_work, max77705_chgin_isr_work);
+
+	charger->irq_chgin = max77705->irq_base + MAX77705_CHG_IRQ_CHGIN_I;
+	ret = devm_request_threaded_irq(charger->dev, charger->irq_chgin, NULL,
+					max77705_chgin_irq, 0, "chgin-irq", charger);
+	if (ret < 0) {
+		pr_err("%s: fail to request chgin IRQ: %d: %d\n",
+				__func__, charger->irq_chgin, ret);
+	} else {
+		max77705_irq_unmask_subdevice(max77705, MAX77705_IRQSRC_CHG);
+	}
+
+	return 0;
+
+err_free:
+	kfree(charger);
+
+	return ret;
+}
+
+static void max77705_charger_remove(struct platform_device *pdev)
+{
+	struct max77705_charger_data *charger = platform_get_drvdata(pdev);
+	struct regmap *regmap = charger->max77705->regmap_charger;
+
+	max77705_irq_mask_subdevice(charger->max77705, MAX77705_IRQSRC_CHG);
+
+	if (regmap) {
+		u8 reg_data;
+
+		reg_data = CHG_CNFG_00_BUCK_MASK;
+		regmap_write(regmap, MAX77705_CHG_REG_CNFG_00, reg_data);
+		reg_data = max77705_convert_ma_to_chgin_ilim_value(500);
+		regmap_write(regmap, MAX77705_CHG_REG_CNFG_09, reg_data);
+		reg_data = max77705_convert_ma_to_wcin_ilim_value(320);
+		regmap_write(regmap, MAX77705_CHG_REG_CNFG_10, reg_data);
+		reg_data = CHG_CNFG_12_CHGINSEL_MASK | CHG_CNFG_12_WCINSEL_MASK;
+		regmap_write(regmap, MAX77705_CHG_REG_CNFG_12, reg_data);
+	} else {
+		dev_err(charger->dev, "no max77705 i2c client\n");
+	}
+
+	if (debugfs_file)
+		debugfs_remove(debugfs_file);
+
+	kfree(charger);
+}
+
+static const struct platform_device_id max77705_charger_id[] = {
+	{ "max77705-charger", 0, },
+	{ }
+};
+MODULE_DEVICE_TABLE(platform, max77705_charger_id);
+
+static struct platform_driver max77705_charger_driver = {
+	.driver = {
+		.name = "max77705-charger",
+	},
+	.probe = max77705_charger_probe,
+	.remove_new = max77705_charger_remove,
+	.id_table	= max77705_charger_id,
+};
+module_platform_driver(max77705_charger_driver);
+
+MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
+MODULE_DESCRIPTION("Maxim 77705 charger driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/max77705_charger.h b/include/linux/mfd/max77705_charger.h
new file mode 100644
index 000000000000..816bb63d9583
--- /dev/null
+++ b/include/linux/mfd/max77705_charger.h
@@ -0,0 +1,225 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * max77705_charger.h
+ * Samsung max77705 Charger Header
+ *
+ * Copyright (C) 2015 Samsung Electronics, Inc.
+ *
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __MAX77705_CHARGER_H
+#define __MAX77705_CHARGER_H __FILE__
+
+#include <linux/mfd/core.h>
+#include <linux/mfd/max77705.h>
+#include <linux/mfd/max77705-private.h>
+#include <linux/regulator/machine.h>
+
+/* MAX77705_CHG_REG_CHG_INT */
+#define MAX77705_BYP_I                  BIT(0)
+#define MAX77705_INP_LIMIT_I		BIT(1)
+#define MAX77705_BATP_I                 BIT(2)
+#define MAX77705_BAT_I                  BIT(3)
+#define MAX77705_CHG_I                  BIT(4)
+#define MAX77705_WCIN_I                 BIT(5)
+#define MAX77705_CHGIN_I                BIT(6)
+#define MAX77705_AICL_I                 BIT(7)
+
+/* MAX77705_CHG_REG_CHG_INT_MASK */
+#define MAX77705_BYP_IM                 BIT(0)
+#define MAX77705_INP_LIMIT_IM		BIT(1)
+#define MAX77705_BATP_IM                BIT(2)
+#define MAX77705_BAT_IM                 BIT(3)
+#define MAX77705_CHG_IM                 BIT(4)
+#define MAX77705_WCIN_IM                BIT(5)
+#define MAX77705_CHGIN_IM               BIT(6)
+#define MAX77705_AICL_IM                BIT(7)
+
+/* MAX77705_CHG_REG_CHG_INT_OK */
+#define MAX77705_BYP_OK                 BIT(0)
+#define MAX77705_DISQBAT_OK		BIT(1)
+#define MAX77705_BATP_OK		BIT(2)
+#define MAX77705_BAT_OK                 BIT(3)
+#define MAX77705_CHG_OK                 BIT(4)
+#define MAX77705_WCIN_OK		BIT(5)
+#define MAX77705_CHGIN_OK               BIT(6)
+#define MAX77705_AICL_OK                BIT(7)
+
+/* MAX77705_CHG_REG_CHG_DTLS_00 */
+#define MAX77705_BATP_DTLS		BIT(0)
+#define MAX77705_WCIN_DTLS		(BIT(3) | BIT(4))
+#define MAX77705_WCIN_DTLS_SHIFT	3
+#define MAX77705_CHGIN_DTLS             (BIT(5) | BIT(6))
+#define MAX77705_CHGIN_DTLS_SHIFT       5
+
+/* MAX77705_CHG_REG_CHG_DTLS_01 */
+#define MAX77705_CHG_DTLS               (BIT(0) | BIT(1) | BIT(2) | BIT(3))
+#define MAX77705_CHG_DTLS_SHIFT         0
+#define MAX77705_BAT_DTLS               (BIT(4) | BIT(5) | BIT(6))
+#define MAX77705_BAT_DTLS_SHIFT         4
+
+/* MAX77705_CHG_REG_CHG_DTLS_02 */
+#define MAX77705_BYP_DTLS               (BIT(0) | BIT(1) | BIT(2) | BIT(3))
+#define MAX77705_BYP_DTLS_SHIFT         0
+
+/* MAX77705_CHG_REG_CHG_CNFG_00 */
+#define CHG_CNFG_00_MODE_SHIFT		        0
+#define CHG_CNFG_00_CHG_SHIFT		        0
+#define CHG_CNFG_00_UNO_SHIFT		        1
+#define CHG_CNFG_00_OTG_SHIFT		        1
+#define CHG_CNFG_00_BUCK_SHIFT		        2
+#define CHG_CNFG_00_BOOST_SHIFT		        3
+#define CHG_CNFG_00_WDTEN_SHIFT		        4
+#define CHG_CNFG_00_MODE_MASK		        (0x0F << CHG_CNFG_00_MODE_SHIFT)
+#define CHG_CNFG_00_CHG_MASK		        BIT(CHG_CNFG_00_CHG_SHIFT)
+#define CHG_CNFG_00_UNO_MASK		        BIT(CHG_CNFG_00_UNO_SHIFT)
+#define CHG_CNFG_00_OTG_MASK		        BIT(CHG_CNFG_00_OTG_SHIFT)
+#define CHG_CNFG_00_BUCK_MASK		        BIT(CHG_CNFG_00_BUCK_SHIFT)
+#define CHG_CNFG_00_BOOST_MASK		        BIT(CHG_CNFG_00_BOOST_SHIFT)
+#define CHG_CNFG_00_WDTEN_MASK		        BIT(CHG_CNFG_00_WDTEN_SHIFT)
+#define CHG_CNFG_00_UNO_CTRL			(CHG_CNFG_00_UNO_MASK | CHG_CNFG_00_BOOST_MASK)
+#define CHG_CNFG_00_OTG_CTRL			(CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK)
+
+/* MAX77705_CHG_REG_CHG_CNFG_01 */
+#define CHG_CNFG_01_FCHGTIME_SHIFT			0
+#define CHG_CNFG_01_FCHGTIME_MASK			(0x7 << CHG_CNFG_01_FCHGTIME_SHIFT)
+#define MAX77705_FCHGTIME_DISABLE			0x0
+
+#define CHG_CNFG_01_CHG_RSTRT_SHIFT	4
+#define CHG_CNFG_01_CHG_RSTRT_MASK	(0x3 << CHG_CNFG_01_CHG_RSTRT_SHIFT)
+#define MAX77705_CHG_RSTRT_DISABLE	0x3
+
+#define CHG_CNFG_01_PQEN_SHIFT			7
+#define CHG_CNFG_01_PQEN_MASK			(0x1 << CHG_CNFG_01_PQEN_SHIFT)
+#define MAX77705_CHG_PQEN_DISABLE		0x0
+#define MAX77705_CHG_PQEN_ENABLE		0x1
+
+/* MAX77705_CHG_REG_CHG_CNFG_02 */
+#define CHG_CNFG_02_OTG_ILIM_SHIFT		6
+#define CHG_CNFG_02_OTG_ILIM_MASK		(0x3 << CHG_CNFG_02_OTG_ILIM_SHIFT)
+#define MAX77705_OTG_ILIM_500		0x0
+#define MAX77705_OTG_ILIM_900		0x1
+#define MAX77705_OTG_ILIM_1200		0x2
+#define MAX77705_OTG_ILIM_1500		0x3
+#define MAX77705_CHG_CC                         0x3F
+
+/* MAX77705_CHG_REG_CHG_CNFG_03 */
+#define CHG_CNFG_03_TO_ITH_SHIFT		0
+#define CHG_CNFG_03_TO_ITH_MASK			(0x7 << CHG_CNFG_03_TO_ITH_SHIFT)
+#define MAX77705_TO_ITH_150MA			0x0
+
+#define CHG_CNFG_03_TO_TIME_SHIFT		3
+#define CHG_CNFG_03_TO_TIME_MASK			(0x7 << CHG_CNFG_03_TO_TIME_SHIFT)
+#define MAX77705_TO_TIME_30M			0x3
+
+#define CHG_CNFG_03_SYS_TRACK_DIS_SHIFT		7
+#define CHG_CNFG_03_SYS_TRACK_DIS_MASK		(0x1 << CHG_CNFG_03_SYS_TRACK_DIS_SHIFT)
+#define MAX77705_SYS_TRACK_ENABLE	        0x0
+#define MAX77705_SYS_TRACK_DISABLE	        0x1
+
+/* MAX77705_CHG_REG_CHG_CNFG_04 */
+#define MAX77705_CHG_MINVSYS_MASK               0xC0
+#define MAX77705_CHG_MINVSYS_SHIFT		6
+#define MAX77705_CHG_PRM_MASK                   0x1F
+#define MAX77705_CHG_PRM_SHIFT                  0
+
+#define CHG_CNFG_04_CHG_CV_PRM_SHIFT            0
+#define CHG_CNFG_04_CHG_CV_PRM_MASK             (0x3F << CHG_CNFG_04_CHG_CV_PRM_SHIFT)
+
+/* MAX77705_CHG_REG_CHG_CNFG_05 */
+#define CHG_CNFG_05_REG_B2SOVRC_SHIFT	0
+#define CHG_CNFG_05_REG_B2SOVRC_MASK	(0xF << CHG_CNFG_05_REG_B2SOVRC_SHIFT)
+#define MAX77705_B2SOVRC_DISABLE	0x0
+#define MAX77705_B2SOVRC_4_5A		0x6
+#define MAX77705_B2SOVRC_4_8A		0x8
+#define MAX77705_B2SOVRC_5_0A		0x9
+
+/* MAX77705_CHG_CNFG_06 */
+#define CHG_CNFG_01_WDTCLR_SHIFT		0
+#define CHG_CNFG_01_WDTCLR_MASK			(0x3 << CHG_CNFG_01_WDTCLR_SHIFT)
+#define MAX77705_WDTCLR				0x01
+#define MAX77705_CHGPROT_MASK	(BIT(2) | BIT(3))
+#define MAX77705_CHGPROT_UNLOCKED	(BIT(2) | BIT(3))
+#define MAX77705_SLOWEST_LX_SLOPE	(BIT(5) | BIT(6))
+
+/* MAX77705_CHG_REG_CHG_CNFG_07 */
+#define MAX77705_CHG_FMBST			0x04
+#define CHG_CNFG_07_REG_FMBST_SHIFT		2
+#define CHG_CNFG_07_REG_FMBST_MASK		(0x1 << CHG_CNFG_07_REG_FMBST_SHIFT)
+#define CHG_CNFG_07_REG_FGSRC_SHIFT		1
+#define CHG_CNFG_07_REG_FGSRC_MASK		(0x1 << CHG_CNFG_07_REG_FGSRC_SHIFT)
+
+/* MAX77705_CHG_REG_CHG_CNFG_08 */
+#define CHG_CNFG_08_REG_FSW_SHIFT	0
+#define CHG_CNFG_08_REG_FSW_MASK	(0x3 << CHG_CNFG_08_REG_FSW_SHIFT)
+#define MAX77705_CHG_FSW_3MHz		0x00
+#define MAX77705_CHG_FSW_2MHz		0x01
+#define MAX77705_CHG_FSW_1_5MHz		0x02
+
+/* MAX77705_CHG_REG_CHG_CNFG_09 */
+#define MAX77705_CHG_CHGIN_LIM_MASK     0x7F
+#define MAX77705_CHG_EN                         0x80
+
+/* MAX77705_CHG_REG_CHG_CNFG_10 */
+#define MAX77705_CHG_WCIN_LIM                   0x3F
+
+/* MAX77705_CHG_REG_CHG_CNFG_11 */
+#define CHG_CNFG_11_VBYPSET_SHIFT		0
+#define CHG_CNFG_11_VBYPSET_MASK		(0x7F << CHG_CNFG_11_VBYPSET_SHIFT)
+
+/* MAX77705_CHG_REG_CHG_CNFG_12 */
+#define CHG_CNFG_12_CHGINSEL_SHIFT		5
+#define MAX77705_CHG_WCINSEL			BIT(CHG_CNFG_12_CHGINSEL_SHIFT)
+#define CHG_CNFG_12_CHGINSEL_MASK		BIT(CHG_CNFG_12_CHGINSEL_SHIFT)
+#define CHG_CNFG_12_WCINSEL_SHIFT		6
+#define CHG_CNFG_12_WCINSEL_MASK		BIT(CHG_CNFG_12_WCINSEL_SHIFT)
+#define CHG_CNFG_12_VCHGIN_REG_MASK		(0x3 << 3)
+#define CHG_CNFG_12_WCIN_REG_MASK		(0x3 << 1)
+#define CHG_CNFG_12_REG_DISKIP_SHIFT		0
+#define CHG_CNFG_12_REG_DISKIP_MASK		(0x1 << CHG_CNFG_12_REG_DISKIP_SHIFT)
+#define MAX77705_DISABLE_SKIP			0x1
+#define MAX77705_AUTO_SKIP			0x0
+
+/* Convert current in mA to corresponding CNFG09 value */
+inline u8 max77705_convert_ma_to_chgin_ilim_value(int cur)
+{
+	if (unlikely(cur < 0 && cur > 4000))
+		return 0;
+	return (((cur - 100) / 33) + 3);
+}
+
+/* Convert current in mA to corresponding CNFG10 value */
+inline u8 max77705_convert_ma_to_wcin_ilim_value(int cur)
+{
+	if (unlikely(cur < 0 && cur > 4000))
+		return 0;
+	return (((cur - 60) / 20) + 3);
+}
+
+struct max77705_charger_data {
+	struct device           *dev;
+	struct mutex            charger_mutex;
+
+	struct max77705_platform_data *max77705_pdata;
+	struct max77705_dev	*max77705;
+	struct power_supply_battery_info *bat_info;
+	struct workqueue_struct *wqueue;
+	struct work_struct	chgin_work;
+	int		irq_chgin;
+
+	struct power_supply	*psy_chg;
+
+	int pmic_ver;
+};
+
+#endif /* __MAX77705_CHARGER_H */

-- 
2.39.2


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

* [PATCH v3 15/23] power: supply: max77705: Add fuel gauge driver for Maxim 77705
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (13 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 14/23] power: supply: max77705: Add charger driver for Maxim 77705 Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 13:59 ` [PATCH v3 16/23] leds: max77705: Add LEDs support Dzmitry Sankouski
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

Add driver for Maxim 77705 fuel gauge (part of max77705
MFD driver) providing power supply class information to userspace.

The driver is configured through DTS (battery and system related
settings).

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 drivers/power/supply/Kconfig              |   7 +
 drivers/power/supply/Makefile             |   1 +
 drivers/power/supply/max77705_fuelgauge.c | 624 ++++++++++++++++++++++++++++++
 include/linux/power/max77705_fuelgauge.h  | 107 +++++
 4 files changed, 739 insertions(+)

diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index 47ca8cc00a80..a3fdfcb5aa64 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -558,6 +558,13 @@ config CHARGER_MAX77705
 	help
 	  Say Y to enable support for the Maxim MAX77705 battery charger.
 
+config FUEL_GAUGE_MAX77705
+	tristate "MAX77705 fuel gauge driver"
+	depends on MFD_MAX77705
+	default n
+	help
+	  Say Y to enable support for MAXIM MAX77705 fuel gauge driver.
+
 config CHARGER_MAX77976
 	tristate "Maxim MAX77976 battery charger driver"
 	depends on I2C
diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile
index dbec648c78c9..e1abad8b6b75 100644
--- a/drivers/power/supply/Makefile
+++ b/drivers/power/supply/Makefile
@@ -78,6 +78,7 @@ obj-$(CONFIG_CHARGER_DETECTOR_MAX14656)	+= max14656_charger_detector.o
 obj-$(CONFIG_CHARGER_MAX77650)	+= max77650-charger.o
 obj-$(CONFIG_CHARGER_MAX77693)	+= max77693_charger.o
 obj-$(CONFIG_CHARGER_MAX77705)	+= max77705_charger.o
+obj-$(CONFIG_FUEL_GAUGE_MAX77705)	+= max77705_fuelgauge.o
 obj-$(CONFIG_CHARGER_MAX77976)	+= max77976_charger.o
 obj-$(CONFIG_CHARGER_MAX8997)	+= max8997_charger.o
 obj-$(CONFIG_CHARGER_MAX8998)	+= max8998_charger.o
diff --git a/drivers/power/supply/max77705_fuelgauge.c b/drivers/power/supply/max77705_fuelgauge.c
new file mode 100644
index 000000000000..108a829421d7
--- /dev/null
+++ b/drivers/power/supply/max77705_fuelgauge.c
@@ -0,0 +1,624 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  max77705_fuelgauge.c
+ *  Samsung max77705 Fuel Gauge Driver
+ *
+ *  Copyright (C) 2015 Samsung Electronics
+ *  Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
+ */
+
+#include <linux/of_gpio.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+#include <linux/power_supply.h>
+#include <linux/regmap.h>
+#include <linux/power/max77705_fuelgauge.h>
+#include <linux/mfd/max77705-private.h>
+
+static const char *max77705_fuelgauge_model		= "max77705";
+static const char *max77705_fuelgauge_manufacturer	= "Maxim Integrated";
+static struct dentry *debugfs_file;
+
+static enum power_supply_property max77705_fuelgauge_props[] = {
+	POWER_SUPPLY_PROP_STATUS,
+	POWER_SUPPLY_PROP_PRESENT,
+	POWER_SUPPLY_PROP_VOLTAGE_NOW,
+	POWER_SUPPLY_PROP_VOLTAGE_OCV,
+	POWER_SUPPLY_PROP_VOLTAGE_AVG,
+	POWER_SUPPLY_PROP_CURRENT_NOW,
+	POWER_SUPPLY_PROP_CURRENT_AVG,
+	POWER_SUPPLY_PROP_CHARGE_NOW,
+	POWER_SUPPLY_PROP_CHARGE_FULL,
+	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+	POWER_SUPPLY_PROP_CAPACITY,
+	POWER_SUPPLY_PROP_TEMP,
+	POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
+	POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
+};
+
+static int max77705_fg_read_vcell(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2];
+	u16 w_data;
+
+	if (regmap_noinc_read(regmap, VCELL_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to read VCELL_REG\n", __func__);
+		return -1;
+	}
+
+	w_data = (data[1] << 8) | data[0];
+
+	return max77705_fg_vs_convert(w_data);
+}
+
+static int max77705_fg_read_vfocv(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2];
+	u16 w_data;
+
+	if (regmap_noinc_read(regmap, VFOCV_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to read VFOCV_REG\n", __func__);
+		return -1;
+	}
+
+	w_data = (data[1] << 8) | data[0];
+
+	return max77705_fg_vs_convert(w_data);
+}
+
+static int max77705_fg_read_avg_vcell(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2];
+	u16 w_data;
+
+	if (regmap_noinc_read(regmap, AVR_VCELL_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to read AVR_VCELL_REG\n", __func__);
+		return -1;
+	}
+
+	w_data = (data[1] << 8) | data[0];
+	return max77705_fg_vs_convert(w_data);
+}
+
+static int max77705_fg_check_battery_present(struct max77705_fuelgauge_data
+					     *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 status_data[2];
+
+	if (regmap_noinc_read(regmap, STATUS_REG, status_data, sizeof(status_data)) < 0) {
+		dev_err(fuelgauge->dev, "Failed to read STATUS_REG\n");
+		return 0;
+	}
+
+	return !(status_data[0] & MAX77705_BAT_ABSENT_MASK);
+}
+
+static int max77705_fg_read_temp(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2] = { 0, 0 };
+	int temper = 0;
+
+	if (regmap_noinc_read(regmap, TEMPERATURE_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to read TEMPERATURE_REG\n", __func__);
+		return -1;
+	}
+
+	if (data[1] & BIT(7))
+		temper = ((~(data[1])) & 0xFF) + 1;
+	else
+		temper = data[1] & 0x7f;
+
+	temper *= 10;
+	temper += data[0] * 10 / 256;
+
+	return temper;
+}
+
+static int max77705_fg_read_socrep(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2];
+	int soc;
+
+	if (regmap_noinc_read(regmap, SOCREP_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to read SOCREP_REG\n", __func__);
+		return -1;
+	}
+
+	soc = data[1];
+
+	return min(soc, 100);
+}
+
+static int max77705_fg_read_fullcaprep(struct max77705_fuelgauge_data
+				       *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2];
+	int ret;
+
+	if (regmap_noinc_read(regmap, FULLCAP_REP_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to read FULLCAP_REP_REG\n", __func__);
+		return -1;
+	}
+
+	ret = (data[1] << 8) + data[0];
+
+	return ret * 1000;
+}
+
+static int max77705_fg_read_repcap(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2];
+	int ret;
+
+	if (regmap_noinc_read(regmap, REMCAP_REP_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to read REMCAP_REP_REG\n", __func__);
+		return -1;
+	}
+
+	ret = (data[1] << 8) + data[0];
+
+	return ret * 1000;
+}
+
+static int max77705_fg_read_charge_design(struct max77705_fuelgauge_data
+				       *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2];
+	int reg;
+
+	if (regmap_noinc_read(regmap, DESIGNCAP_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to read DESIGNCAP_REG\n", __func__);
+		return -1;
+	}
+
+	reg = (data[1] << 8) | (data[0]);
+
+	return reg * 1000;
+}
+
+static int max77705_fg_set_charge_design(struct regmap *regmap, int value)
+{
+	u8 data[2];
+	int value_mah;
+
+	value_mah = value / 1000;
+	data[0] = value_mah & 0xFF;
+	data[1] = (value_mah >> 8) & 0xFF;
+
+	if (regmap_noinc_write(regmap, DESIGNCAP_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to write DESIGNCAP_REG\n", __func__);
+		return -1;
+	}
+
+	return 0;
+}
+
+static int max77705_fg_read_current(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 reg_data[2];
+	s16 reg_value;
+	s32 i_current;
+
+	if (regmap_noinc_read(regmap, CURRENT_REG, reg_data, sizeof(reg_data)) < 0) {
+		pr_err("%s: Failed to read CURRENT\n", __func__);
+		return -1;
+	}
+
+	reg_value = ((reg_data[1] << 8) | reg_data[0]);
+	i_current = max77705_fg_cs_convert(reg_value, fuelgauge->rsense_conductance);
+
+	return i_current;
+}
+
+static int max77705_fg_read_avg_current(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 reg_data[2];
+	u32 reg_value;
+	s32 avg_current;
+
+	if (regmap_noinc_read(regmap, AVG_CURRENT_REG, reg_data, sizeof(reg_data)) < 0) {
+		pr_err("%s: Failed to read AVG_CURRENT_REG\n", __func__);
+		return -1;
+	}
+
+	reg_value = ((reg_data[1] << 8) | reg_data[0]);
+	avg_current = max77705_fg_cs_convert(reg_value, fuelgauge->rsense_conductance);
+
+	return avg_current;
+}
+
+static int max77705_fg_read_tte(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2];
+	int reg;
+
+	if (regmap_noinc_read(regmap, TIME_TO_EMPTY_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to read TIME_TO_EMPTY_REG\n", __func__);
+		return -1;
+	}
+
+	reg = (data[1] << 8) | (data[0]);
+
+	return reg;
+}
+
+static int max77705_fg_read_ttf(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2];
+	int reg;
+
+	if (regmap_noinc_read(regmap, TIME_TO_FULL_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to read TIME_TO_FULL_REG\n", __func__);
+		return -1;
+	}
+
+	reg = (data[1] << 8) | (data[0]);
+
+	return reg;
+}
+
+static int max77705_fg_read_cycle(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2];
+	int ret;
+
+	if (regmap_noinc_read(regmap, CYCLES_REG, data, sizeof(data)) < 0) {
+		pr_err("%s: Failed to read CYCLES_REG\n", __func__);
+		return -1;
+	}
+
+	ret = (data[1] << 8) + data[0];
+
+	return ret;
+}
+
+static int max77705_battery_get_status(struct max77705_fuelgauge_data *fuelgauge)
+{
+	int current_now;
+	int am_i_supplied;
+
+	am_i_supplied = power_supply_am_i_supplied(fuelgauge->psy_fg);
+	if (am_i_supplied) {
+		if (am_i_supplied == -ENODEV)
+			dev_err(fuelgauge->dev,
+				"power supply not found, fall back to current-based status checking\n");
+		else
+			return POWER_SUPPLY_STATUS_CHARGING;
+	}
+	if (max77705_fg_read_socrep(fuelgauge) < 100) {
+		current_now = max77705_fg_read_current(fuelgauge);
+		if (current_now > 0)
+			return POWER_SUPPLY_STATUS_CHARGING;
+		else if (current_now < 0)
+			return POWER_SUPPLY_STATUS_DISCHARGING;
+		else
+			return POWER_SUPPLY_STATUS_NOT_CHARGING;
+	} else {
+		return POWER_SUPPLY_STATUS_FULL;
+	}
+	return POWER_SUPPLY_STATUS_DISCHARGING;
+}
+
+static bool max77705_fg_init(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	u8 data[2] = { 0, 0 };
+	u32 volt_threshold = 0;
+	u32 temp_threshold = 0;
+
+	if (fuelgauge->auto_discharge_en) {
+		/* Auto discharge EN & Alert Enable */
+		regmap_noinc_read(regmap, CONFIG2_REG, data, sizeof(data));
+		data[1] |= MAX77705_AUTO_DISCHARGE_EN_MASK >> 8;
+		regmap_noinc_write(regmap, CONFIG2_REG, data, sizeof(data));
+
+		/* Set Auto Discharge temperature & Voltage threshold */
+		volt_threshold =
+		    fuelgauge->discharge_volt_threshold < 3900 ? 0x0 :
+		    fuelgauge->discharge_volt_threshold > 4540 ? 0x20 :
+		    (fuelgauge->discharge_volt_threshold - 3900) / 20;
+
+		temp_threshold =
+		    fuelgauge->discharge_temp_threshold < 470 ? 0x0 :
+		    fuelgauge->discharge_temp_threshold > 630 ? 0x20 :
+		    (fuelgauge->discharge_temp_threshold - 470) / 5;
+
+		regmap_noinc_read(regmap, DISCHARGE_THRESHOLD_REG, data, sizeof(data));
+		data[1] &= ~MAX77705_AUTO_DISCHARGE_VALUE_MASK;
+		data[1] |= volt_threshold << MAX77705_AUTO_DISCHARGE_VALUE_SHIFT;
+
+		data[0] &= ~MAX77705_AUTO_DISCHARGE_VALUE_MASK;
+		data[0] |= temp_threshold << MAX77705_AUTO_DISCHARGE_VALUE_SHIFT;
+
+		regmap_noinc_write(regmap, DISCHARGE_THRESHOLD_REG, data, sizeof(data));
+
+		pr_info("%s: DISCHARGE_THRESHOLD Value : 0x%x\n",
+			__func__, (data[1] << 8) | data[0]);
+	}
+
+	return true;
+}
+
+static int max77705_fg_get_property(struct power_supply *psy,
+				    enum power_supply_property psp,
+				    union power_supply_propval *val)
+{
+	struct max77705_fuelgauge_data *fuelgauge =
+	    power_supply_get_drvdata(psy);
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_STATUS:
+		val->intval = max77705_battery_get_status(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_PRESENT:
+		val->intval = max77705_fg_check_battery_present(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+		val->intval = max77705_fg_read_vcell(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+		val->intval = max77705_fg_read_vfocv(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+		val->intval = max77705_fg_read_avg_vcell(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_CURRENT_NOW:
+		val->intval = max77705_fg_read_current(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_CURRENT_AVG:
+		val->intval = max77705_fg_read_avg_current(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_CHARGE_NOW:
+		val->intval = max77705_fg_read_repcap(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_CHARGE_FULL:
+		val->intval = max77705_fg_read_fullcaprep(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
+		val->intval = max77705_fg_read_charge_design(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_CAPACITY:
+		val->intval = max77705_fg_read_socrep(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_TEMP:
+		val->intval = max77705_fg_read_temp(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
+		val->intval = max77705_fg_read_tte(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
+		val->intval = max77705_fg_read_ttf(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_CYCLE_COUNT:
+		val->intval = max77705_fg_read_cycle(fuelgauge);
+		break;
+	case POWER_SUPPLY_PROP_MODEL_NAME:
+		val->strval = max77705_fuelgauge_model;
+		break;
+	case POWER_SUPPLY_PROP_MANUFACTURER:
+		val->strval = max77705_fuelgauge_manufacturer;
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static int max77705_fuelgauge_debugfs_show(struct seq_file *s, void *data)
+{
+	struct max77705_fuelgauge_data *fuelgauge = s->private;
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+	int i;
+	u16 reg_data;
+	int regs[] = { 0x00, 0x01, 0x02, 0x03, 0x05, 0x06, 0x08, 0x09, 0x11, 0x13, 0x0A,
+			0x0B, 0x0D, 0x0E, 0x0F, 0x10, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20,
+			0x1D, 0x1E, 0x1F, 0x23, 0x28, 0x29, 0x2B, 0x32, 0x35, 0x38, 0x3A,
+			0x3D, 0x40, 0x42, 0x43, 0x45, 0x46, 0x4B, 0x4D, 0xB1, 0xB2, 0xB3,
+			0xBB, 0xD0, 0xEE, 0xFB, 0xFF, };
+
+	seq_puts(s, "MAX77705 FUELGAUGE IC :\n");
+	seq_puts(s, "===================\n");
+	for (i = 0; i < ARRAY_SIZE(regs); i++) {
+		regmap_noinc_read(regmap, regs[i], &reg_data, 2);
+		seq_printf(s, "0x%02x:\t0x%02x\n", regs[i], reg_data);
+	}
+	seq_puts(s, "\n");
+	return 0;
+}
+
+static int max77705_fuelgauge_debugfs_open(struct inode *inode,
+					   struct file *file)
+{
+	return single_open(file, max77705_fuelgauge_debugfs_show, inode->i_private);
+}
+
+static const struct file_operations max77705_fuelgauge_debugfs_fops = {
+	.open = max77705_fuelgauge_debugfs_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
+static void max77705_battery_settings(struct max77705_fuelgauge_data *fuelgauge)
+{
+	struct power_supply_battery_info *info;
+	struct regmap *regmap = fuelgauge->max77705->regmap_fg;
+
+	if (power_supply_get_battery_info(fuelgauge->psy_fg, &info) < 0)
+		return;
+
+	fuelgauge->bat_info = info;
+
+	if (!regmap) {
+		dev_warn(fuelgauge->dev, "data memory update not supported for chip\n");
+		return;
+	}
+
+	if (info->energy_full_design_uwh != info->charge_full_design_uah) {
+		if (info->charge_full_design_uah == -EINVAL)
+			dev_warn(fuelgauge->dev, "missing battery:charge-full-design-microamp-hours\n");
+		max77705_fg_set_charge_design(regmap, info->charge_full_design_uah);
+	}
+}
+
+static int max77705_fuelgauge_parse_dt(struct max77705_fuelgauge_data
+				       *fuelgauge)
+{
+	struct device *dev = fuelgauge->dev;
+	struct device_node *np = dev->of_node;
+	unsigned int rsense;
+
+	if (!np) {
+		dev_err(dev, "no fuelgauge OF node\n");
+		return -EINVAL;
+	}
+
+	int ret;
+
+	if (np == NULL) {
+		pr_err("%s np NULL\n", __func__);
+		return -EINVAL;
+	}
+
+	ret = of_property_read_u32(np, "rsense",
+				   &rsense);
+	if (ret < 0) {
+		pr_err("%s error reading rsense %d\n",
+		       __func__, ret);
+		fuelgauge->rsense_conductance = 100;
+	} else
+		fuelgauge->rsense_conductance = 1000 / rsense; /* rsense in Ohm^-1 */
+
+	fuelgauge->auto_discharge_en = of_property_read_bool(np,
+							     "auto_discharge_en");
+	if (fuelgauge->auto_discharge_en) {
+		ret = of_property_read_u32(np,
+						"discharge_temp_threshold",
+						&fuelgauge->discharge_temp_threshold);
+		if (ret < 0) {
+			dev_err(dev, "error reading rsense_conductance %d\n", ret);
+			fuelgauge->discharge_temp_threshold = 600;
+		}
+
+		ret = of_property_read_u32(np,
+						"discharge_volt_threshold",
+						&fuelgauge->discharge_volt_threshold);
+		if (ret < 0)
+			fuelgauge->discharge_volt_threshold = 4200;
+	}
+
+	return 0;
+}
+
+static const struct power_supply_desc max77705_fuelgauge_power_supply_desc = {
+	.name = "max77705-fuelgauge",
+	.type = POWER_SUPPLY_TYPE_BATTERY,
+	.properties = max77705_fuelgauge_props,
+	.num_properties = ARRAY_SIZE(max77705_fuelgauge_props),
+	.get_property = max77705_fg_get_property,
+};
+
+static int max77705_fuelgauge_probe(struct platform_device *pdev)
+{
+	struct max77705_dev *max77705 = dev_get_drvdata(pdev->dev.parent);
+	struct max77705_platform_data *pdata = dev_get_platdata(max77705->dev);
+	struct max77705_fuelgauge_data *fuelgauge;
+	struct power_supply_config fuelgauge_cfg = { };
+	int ret = 0;
+
+	fuelgauge = kzalloc(sizeof(*fuelgauge), GFP_KERNEL);
+	if (!fuelgauge)
+		return -ENOMEM;
+
+	mutex_init(&fuelgauge->fg_lock);
+
+	fuelgauge->dev = &pdev->dev;
+	fuelgauge->max77705 = max77705;
+	fuelgauge->max77705_pdata = pdata;
+
+	ret = max77705_fuelgauge_parse_dt(fuelgauge);
+	if (ret < 0)
+		pr_err("%s not found charger dt! ret[%d]\n", __func__, ret);
+
+	platform_set_drvdata(pdev, fuelgauge);
+
+
+	debugfs_file = debugfs_create_file("max77705-fuelgauge-regs",
+				0664, NULL, (void *)fuelgauge,
+				  &max77705_fuelgauge_debugfs_fops);
+	if (!debugfs_file)
+		dev_err(fuelgauge->dev, "Failed to create debugfs file\n");
+
+	fuelgauge_cfg.drv_data = fuelgauge;
+	fuelgauge_cfg.of_node = fuelgauge->dev->of_node;
+
+	fuelgauge->psy_fg =
+	    devm_power_supply_register(&pdev->dev,
+				  &max77705_fuelgauge_power_supply_desc,
+				  &fuelgauge_cfg);
+
+	if (IS_ERR(fuelgauge->psy_fg)) {
+		pr_err("%s: Failed to Register psy_fg\n", __func__);
+		goto err_data_free;
+	}
+
+	fuelgauge->fg_irq = max77705->irq_base + MAX77705_FG_IRQ_ALERT;
+	pr_info("[%s]IRQ_BASE(%d) FG_IRQ(%d)\n",
+		__func__, max77705->irq_base, fuelgauge->fg_irq);
+
+	if (!max77705_fg_init(fuelgauge)) {
+		pr_err("%s: Failed to Initialize Fuelgauge\n", __func__);
+		goto err_supply_unreg;
+	}
+
+	max77705_battery_settings(fuelgauge);
+
+	return 0;
+
+err_supply_unreg:
+	power_supply_unregister(fuelgauge->psy_fg);
+	kfree(fuelgauge->bat_info);
+err_data_free:
+	mutex_destroy(&fuelgauge->fg_lock);
+
+	return ret;
+}
+
+static void max77705_fuelgauge_remove(struct platform_device *pdev)
+{
+	if (debugfs_file)
+		debugfs_remove(debugfs_file);
+}
+static const struct platform_device_id max77705_fuelgauge_id[] = {
+	{ "max77705-fuelgauge", 0, },
+	{ }
+};
+MODULE_DEVICE_TABLE(platform, max77705_fuelgauge_id);
+
+static struct platform_driver max77705_fuelgauge_driver = {
+	.driver = {
+		.name = "max77705-fuelgauge",
+	},
+	.probe = max77705_fuelgauge_probe,
+	.remove_new = max77705_fuelgauge_remove,
+	.id_table	= max77705_fuelgauge_id,
+};
+module_platform_driver(max77705_fuelgauge_driver);
+
+MODULE_DESCRIPTION("Samsung max77705 Fuel Gauge Driver");
+MODULE_AUTHOR("Samsung Electronics");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/power/max77705_fuelgauge.h b/include/linux/power/max77705_fuelgauge.h
new file mode 100644
index 000000000000..718cd47bc7b6
--- /dev/null
+++ b/include/linux/power/max77705_fuelgauge.h
@@ -0,0 +1,107 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * max77705_fuelgauge.h
+ * Samsung max77705 Fuel Gauge Header
+ *
+ * Copyright (C) 2015 Samsung Electronics, Inc.
+ *
+ * This software is 77854 under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __MAX77705_FUELGAUGE_H
+#define __MAX77705_FUELGAUGE_H __FILE__
+
+#include <linux/mfd/core.h>
+#include <linux/mfd/max77705.h>
+#include <linux/mfd/max77705-private.h>
+#include <linux/regulator/machine.h>
+
+#define ALERT_EN 0x04
+#define CAPACITY_SCALE_DEFAULT_CURRENT 1000
+#define CAPACITY_SCALE_HV_CURRENT 600
+/*
+ * Current and capacity values are displayed as a voltage
+ * and must be divided by the sense resistor to determine Amps or Amp-hours.
+ * This should be applied to all current, charge, energy registers,
+ * except ModelGauge m5 Algorithm related ones.
+ */
+/* current sense resolution */
+#define MAX77705_FG_CS_ADC_RESOLUTION 15625 /* 1.5625 microvolts */
+/* voltage sense resolution */
+#define MAX77705_FG_VS_ADC_RESOLUTION 78125 /* 78.125 microvolts */
+/* CONFIG register */
+#define MAX77705_SOC_ALERT_EN_MASK		BIT(2)
+/* When set to 1, external temperature measurements should be written from the host */
+#define MAX77705_TEX_MASK		BIT(8)
+/* Enable Thermistor */
+#define MAX77705_ETHRM_MASK		BIT(5)
+/* CONFIG2 register */
+#define MAX77705_AUTO_DISCHARGE_EN_MASK BIT(9)
+/* DISCHARGE register*/
+#define MAX77705_AUTO_DISCHARGE_VALUE_SHIFT 3
+#define MAX77705_AUTO_DISCHARGE_VALUE_MASK 0xF8
+
+#define MAX77705_FG_CS_MASK BIT(15)
+/* MISCCFG register */
+#define MAX77705_AUTO_DISCHARGE_VALUE_MASK 0xF8
+
+/* adc resolution for voltage sensing is 78.125 microvolts */
+inline u64 max77705_fg_vs_convert(u16 reg_val)
+{
+	u64 result = (u64)reg_val * MAX77705_FG_VS_ADC_RESOLUTION;
+
+	return result / 1000;
+}
+
+/* adc resolution for current sensing is 1.5625 microvolts */
+inline s32 max77705_fg_cs_convert(s16 reg_val, u32 rsense_conductance)
+{
+	s64 result = (s64)reg_val * rsense_conductance * MAX77705_FG_CS_ADC_RESOLUTION;
+
+	return result / 10000;
+}
+
+struct max77705_fuelgauge_data {
+	struct device           *dev;
+	struct i2c_client       *i2c;
+	struct i2c_client       *pmic;
+	struct mutex            fuelgauge_mutex;
+	struct max77705_dev	*max77705;
+	struct max77705_platform_data *max77705_pdata;
+	struct power_supply	      *psy_fg;
+	struct delayed_work isr_work;
+
+	int cable_type;
+	bool is_charging;
+
+	struct power_supply_battery_info *bat_info;
+
+	struct mutex fg_lock;
+
+	/* register programming */
+	int reg_addr;
+	u8 reg_data[2];
+
+	unsigned int pre_soc;
+	int fg_irq;
+
+	int temperature;
+	int low_temp_limit;
+
+	bool auto_discharge_en;
+	u32 discharge_temp_threshold;
+	u32 discharge_volt_threshold;
+
+	u32 rsense_conductance;
+	u32 fuel_alert_soc;
+};
+
+#endif /* __MAX77705_FUELGAUGE_H */

-- 
2.39.2


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

* [PATCH v3 16/23] leds: max77705: Add LEDs support
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (14 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 15/23] power: supply: max77705: Add fuel gauge " Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-20 20:14   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 17/23] mfd: add s2dos series core driver Dzmitry Sankouski
                   ` (6 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

This adds basic support for LEDs for the max77705 PMIC.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 MAINTAINERS                  |   1 +
 drivers/leds/Kconfig         |   6 ++
 drivers/leds/Makefile        |   1 +
 drivers/leds/leds-max77705.c | 166 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 174 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index f66f08825db9..f3c245d432d9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13691,6 +13691,7 @@ F:	drivers/*/max14577*.c
 F:	drivers/*/max77686*.c
 F:	drivers/*/max77693*.c
 F:	drivers/*/max77705*.c
+F:	drivers/leds/leds-max77705.c
 F:	drivers/clk/clk-max77686.c
 F:	drivers/extcon/extcon-max14577.c
 F:	drivers/extcon/extcon-max77693.c
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 05e6af88b88c..14d483011308 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -728,6 +728,12 @@ config LEDS_MAX77650
 	help
 	  LEDs driver for MAX77650 family of PMICs from Maxim Integrated.
 
+config LEDS_MAX77705
+	tristate "LED support for Maxim MAX77705 RGB"
+	depends on MFD_MAX77705 && LEDS_CLASS && I2C
+	help
+	  LED driver for MAX77705 MFD chip from Maxim Integrated.
+
 config LEDS_MAX8997
 	tristate "LED support for MAX8997 PMIC"
 	depends on LEDS_CLASS && MFD_MAX8997
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index effdfc6f1e95..be064e3d678e 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_LP8860)		+= leds-lp8860.o
 obj-$(CONFIG_LEDS_LT3593)		+= leds-lt3593.o
 obj-$(CONFIG_LEDS_MAX5970)		+= leds-max5970.o
 obj-$(CONFIG_LEDS_MAX77650)		+= leds-max77650.o
+obj-$(CONFIG_LEDS_MAX77705)		+= leds-max77705.o
 obj-$(CONFIG_LEDS_MAX8997)		+= leds-max8997.o
 obj-$(CONFIG_LEDS_MC13783)		+= leds-mc13783.o
 obj-$(CONFIG_LEDS_MENF21BMC)		+= leds-menf21bmc.o
diff --git a/drivers/leds/leds-max77705.c b/drivers/leds/leds-max77705.c
new file mode 100644
index 000000000000..f91c0e41056c
--- /dev/null
+++ b/drivers/leds/leds-max77705.c
@@ -0,0 +1,166 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Based on leds-max77650 driver:
+ *		Copyright (C) 2018 BayLibre SAS
+ *		Author: Bartosz Golaszewski <bgolaszewski@baylibre.com>
+ *
+ * LED driver for MAXIM 77705 MFD.
+ * Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.org>
+ */
+
+#include <linux/i2c.h>
+#include <linux/leds.h>
+#include <linux/mfd/max77705.h>
+#include <linux/mfd/max77705-private.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+#define MAX77705_LED_NUM_LEDS		4
+#define MAX77705_LED_EN_MASK		GENMASK(1, 0)
+#define MAX77705_LED_MAX_BRIGHTNESS	0xff
+
+#define LEDBLNK_ON(time)	((time < 100) ? 0 :			\
+				(time < 500) ? time/100-1 :		\
+				(time < 3250) ? (time-500)/250+4 : 15)
+
+#define LEDBLNK_OFF(time)	((time < 1) ? 0x00 :			\
+				(time < 500) ? 0x01 :			\
+				(time < 5000) ? time/500 :		\
+				(time < 8000) ? (time-5000)/1000+10 :	 \
+				(time < 12000) ? (time-8000)/2000+13 : 15)
+
+struct max77705_led {
+	struct led_classdev cdev;
+	struct regmap *regmap;
+	unsigned int en_shift;
+	unsigned int reg_brightness;
+	unsigned int regB;
+};
+
+static struct max77705_led *max77705_to_led(struct led_classdev *cdev)
+{
+	return container_of(cdev, struct max77705_led, cdev);
+}
+
+static int max77705_rgb_blink(struct led_classdev *cdev,
+								unsigned long *delay_on,
+								unsigned long *delay_off)
+{
+	struct max77705_led *led = max77705_to_led(cdev);
+	int value;
+
+	value = (LEDBLNK_ON(*delay_on) << 4) | LEDBLNK_OFF(*delay_off);
+	return regmap_write(led->regmap, MAX77705_RGBLED_REG_LEDBLNK, value);
+}
+
+static int max77705_led_brightness_set(struct led_classdev *cdev,
+					enum led_brightness brightness)
+{
+	struct max77705_led *led = max77705_to_led(cdev);
+	int ret;
+	unsigned long blink_default = 0;
+
+	if (brightness == LED_OFF) {
+		/* Flash OFF */
+		ret = regmap_update_bits(led->regmap,
+					MAX77705_RGBLED_REG_LEDEN,
+					MAX77705_LED_EN_MASK << led->en_shift, 0);
+		max77705_rgb_blink(cdev, &blink_default, &blink_default);
+	} else {
+		/* Set current */
+		ret = regmap_write(led->regmap,
+				   led->reg_brightness, brightness);
+		if (ret < 0)
+			return ret;
+
+		ret = regmap_update_bits(led->regmap,
+					MAX77705_RGBLED_REG_LEDEN, LED_ON << led->en_shift,
+					MAX77705_LED_EN_MASK << led->en_shift);
+	}
+
+	return ret;
+}
+
+static int max77705_led_probe(struct platform_device *pdev)
+{
+	struct fwnode_handle *child;
+	struct max77705_led *leds, *led;
+	struct device *dev;
+	struct regmap *map;
+	int rv, num_leds;
+	u32 reg;
+
+	dev = &pdev->dev;
+
+	leds = devm_kcalloc(dev, sizeof(*leds),
+				MAX77705_LED_NUM_LEDS, GFP_KERNEL);
+	if (!leds)
+		return -ENOMEM;
+
+	map = dev_get_regmap(dev->parent, NULL);
+	if (!map)
+		return -ENODEV;
+
+	num_leds = device_get_child_node_count(dev);
+	if (!num_leds || num_leds > MAX77705_LED_NUM_LEDS)
+		return -ENODEV;
+
+	device_for_each_child_node(dev, child) {
+		struct led_init_data init_data = {};
+
+		rv = fwnode_property_read_u32(child, "reg", &reg);
+		if (rv || reg >= MAX77705_LED_NUM_LEDS) {
+			rv = -EINVAL;
+			goto err_node_put;
+		}
+
+		led = &leds[reg];
+		led->regmap = map;
+		led->reg_brightness = MAX77705_RGBLED_REG_LED0BRT + reg;
+		led->en_shift = 2 * reg;
+		led->cdev.brightness_set_blocking = max77705_led_brightness_set;
+		led->cdev.blink_set = max77705_rgb_blink;
+		led->cdev.max_brightness = MAX77705_LED_MAX_BRIGHTNESS;
+
+		init_data.fwnode = child;
+		init_data.devicename = "max77705";
+		/* for backwards compatibility if `label` is not present */
+		init_data.default_label = ":";
+
+		rv = devm_led_classdev_register_ext(dev, &led->cdev,
+							&init_data);
+		if (rv)
+			goto err_node_put;
+
+		rv = max77705_led_brightness_set(&led->cdev, LED_OFF);
+		if (rv)
+			goto err_node_put;
+	}
+
+	return 0;
+err_node_put:
+	fwnode_handle_put(child);
+	return rv;
+}
+
+static const struct of_device_id max77705_led_of_match[] = {
+	{ .compatible = "maxim,max77705-led" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, max77705_led_of_match);
+
+static struct platform_driver max77705_led_driver = {
+	.driver = {
+		.name = "max77705-led",
+		.of_match_table = max77705_led_of_match,
+	},
+	.probe = max77705_led_probe,
+};
+module_platform_driver(max77705_led_driver);
+
+MODULE_DESCRIPTION("MAXIM 77705 LED driver");
+MODULE_AUTHOR("Bartosz Golaszewski <bgolaszewski@baylibre.com>");
+MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:max77705-led");

-- 
2.39.2


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

* [PATCH v3 17/23] mfd: add s2dos series core driver
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (15 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 16/23] leds: max77705: Add LEDs support Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-20 16:07   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 18/23] regulator: add s2dos05 regulator support Dzmitry Sankouski
                   ` (5 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

S2DOS05 is a panel/touchscreen PMIC, often found in
Samsung phones. We define 2 sub-devices for which drivers will
be added in subsequent patches.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 MAINTAINERS                            |   1 +
 drivers/mfd/Kconfig                    |  13 +++
 drivers/mfd/Makefile                   |   2 +-
 drivers/mfd/s2dos-core.c               | 141 +++++++++++++++++++++++++++++++++
 include/linux/mfd/samsung/s2dos-core.h |  21 +++++
 include/linux/mfd/samsung/s2dos05.h    | 115 +++++++++++++++++++++++++++
 6 files changed, 292 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index f3c245d432d9..b53462684a30 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19908,6 +19908,7 @@ F:	Documentation/devicetree/bindings/regulator/samsung,s2dos*.yaml
 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/s2dos*.c
 F:	drivers/mfd/sec*.c
 F:	drivers/regulator/s2m*.c
 F:	drivers/regulator/s5m*.c
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index c4eb8ff2dcad..517d8778d7a8 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1278,6 +1278,19 @@ config MFD_RN5T618
 	  additional drivers must be enabled in order to use the
 	  functionality of the device.
 
+config MFD_S2DOS_CORE
+	tristate "Samsung Electronics PMIC Series Support"
+	depends on I2C=y
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  Support for the Samsung Electronics PMIC devices
+	  usually used to power displays.
+	  This driver provides common support for accessing the device,
+	  additional drivers must be enabled in order to use the functionality
+	  of the device.
+
 config MFD_SEC_CORE
 	tristate "Samsung Electronics PMIC Series Support"
 	depends on I2C=y
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index bf65cc36d59c..37c51aab0205 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -228,7 +228,7 @@ obj-$(CONFIG_MFD_RK8XX_I2C)	+= rk8xx-i2c.o
 obj-$(CONFIG_MFD_RK8XX_SPI)	+= rk8xx-spi.o
 obj-$(CONFIG_MFD_RN5T618)	+= rn5t618.o
 obj-$(CONFIG_MFD_SEC_CORE)	+= sec-core.o sec-irq.o
-obj-$(CONFIG_MFD_S2DOS05)	+= s2dos05.o
+obj-$(CONFIG_MFD_S2DOS_CORE)	+= s2dos-core.o
 obj-$(CONFIG_MFD_SYSCON)	+= syscon.o
 obj-$(CONFIG_MFD_LM3533)	+= lm3533-core.o lm3533-ctrlbank.o
 obj-$(CONFIG_MFD_VEXPRESS_SYSREG)	+= vexpress-sysreg.o
diff --git a/drivers/mfd/s2dos-core.c b/drivers/mfd/s2dos-core.c
new file mode 100644
index 000000000000..a04363b15a2a
--- /dev/null
+++ b/drivers/mfd/s2dos-core.c
@@ -0,0 +1,141 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * s2dos05.c - mfd core driver for the s2dos05 chip
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/mutex.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/samsung/s2dos-core.h>
+#include <linux/mfd/samsung/s2dos05.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/debugfs.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+
+static struct dentry *debugfs_file;
+
+static int s2dos05_debugfs_show(struct seq_file *s, void *data)
+{
+	struct s2dos_core *s2dos05 = s->private;
+	struct regmap *regmap = s2dos05->regmap;
+	unsigned int i, reg, reg_data, pmic_id;
+	int regs[] = {
+		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,
+		S2DOS05_REG_SSD_TSD,
+		S2DOS05_REG_OCL,
+		S2DOS05_REG_IRQ
+	};
+	regmap_read(regmap, S2DOS05_REG_DEV_ID, &pmic_id);
+	seq_printf(s, "S2DOS05, id: %d\n", pmic_id);
+	seq_puts(s, "===================\n");
+	for (i = 0; i < ARRAY_SIZE(regs); i++) {
+		reg = regs[i];
+		regmap_read(regmap, reg, &reg_data);
+		seq_printf(s, "0x%02x:\t0x%02x\n", reg, reg_data);
+	}
+
+	seq_puts(s, "\n");
+	return 0;
+}
+
+DEFINE_SHOW_ATTRIBUTE(s2dos05_debugfs);
+
+static const struct regmap_config s2dos05_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = S2DOS05_REG_IRQ,
+};
+
+static struct mfd_cell s2dos05_devs[] = {
+	{ .name = "s2dos05-fg" },
+	{
+		.name = "s2dos05-regulator",
+		.of_compatible = "samsung,s2dos05-regulator",
+	},
+};
+
+
+static int s2dos05_i2c_probe(struct i2c_client *i2c)
+{
+	struct s2dos_core *s2dos05;
+	struct regmap *regmap;
+	struct device *dev = &i2c->dev;
+
+	unsigned int reg_data;
+	int ret = 0;
+
+	s2dos05 = kzalloc(sizeof(struct s2dos_core), GFP_KERNEL);
+	if (!s2dos05)
+		return -ENOMEM;
+
+	regmap = devm_regmap_init_i2c(i2c, &s2dos05_regmap_config);
+	if (IS_ERR(regmap)) {
+		dev_err(dev, "Unable to initialise I2C Regmap\n");
+		return PTR_ERR(regmap);
+	}
+	s2dos05->regmap = regmap;
+
+	if (regmap_read(regmap, S2DOS05_REG_DEV_ID, &reg_data) < 0) {
+		dev_err(dev,
+			"device not found on this channel (this is not an error)\n");
+		ret = -ENODEV;
+	} else {
+		dev_info(dev, "%s device found with id: .0x%x\n",
+				__func__, reg_data);
+	}
+
+	i2c_set_clientdata(i2c, s2dos05);
+
+	debugfs_file = debugfs_create_file("s2dos05-regs",
+				0664, NULL, (void *)s2dos05,
+				  &s2dos05_debugfs_fops);
+	if (!debugfs_file)
+		dev_err(dev, "Failed to create debugfs file\n");
+
+	return mfd_add_devices(dev, -1, s2dos05_devs,
+			ARRAY_SIZE(s2dos05_devs), NULL, 0, NULL);
+}
+
+static const struct of_device_id s2dos05_i2c_dt_ids[] = {
+	{ .compatible = "samsung,s2dos05-pmic" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, s2dos05_i2c_dt_ids);
+
+static struct i2c_driver s2dos05_i2c_driver = {
+	.driver		= {
+		.name	= "s2dos-core",
+		.owner	= THIS_MODULE,
+		.of_match_table	= s2dos05_i2c_dt_ids,
+	},
+	.probe		= s2dos05_i2c_probe,
+};
+
+module_i2c_driver(s2dos05_i2c_driver);
+
+MODULE_DESCRIPTION("s2dos core driver");
+MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/samsung/s2dos-core.h b/include/linux/mfd/samsung/s2dos-core.h
new file mode 100644
index 000000000000..7e84b387063c
--- /dev/null
+++ b/include/linux/mfd/samsung/s2dos-core.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * s2dos-core.h
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd
+ *              http://www.samsung.com
+ * Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
+ *
+ */
+
+#ifndef __LINUX_MFD_S2DOS_CORE_H
+#define __LINUX_MFD_S2DOS_CORE_H
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+struct s2dos_core {
+	struct device *dev;
+	struct regmap *regmap;
+};
+
+#endif /*  __LINUX_MFD_S2DOS_CORE_H */
diff --git a/include/linux/mfd/samsung/s2dos05.h b/include/linux/mfd/samsung/s2dos05.h
new file mode 100644
index 000000000000..0317dbe56f10
--- /dev/null
+++ b/include/linux/mfd/samsung/s2dos05.h
@@ -0,0 +1,115 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * s2dos05.h
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd
+ *              http://www.samsung.com
+ *
+ */
+
+#ifndef __LINUX_MFD_S2DOS05_H
+#define __LINUX_MFD_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	BIT(7)
+#define S2DOS05_BUCK_VSEL_MASK	0xFF
+#define S2DOS05_BUCK_FD_MASK	BIT(3)
+
+#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_ENABLE_SHIFT	0x06
+#define S2DOS05_LDO_N_VOLTAGES	(S2DOS05_LDO_VSEL_MASK + 1)
+#define S2DOS05_BUCK_N_VOLTAGES (S2DOS05_BUCK_VSEL_MASK + 1)
+
+#define S2DOS05_PMIC_EN_SHIFT	6
+#define S2DOS05_REGULATOR_MAX (S2DOS05_REG_MAX)
+
+/* ----------power meter ----------*/
+#define S2DOS05_REG_PWRMT_CTRL1		0x0A
+#define S2DOS05_REG_PWRMT_CTRL2		0x0B
+#define S2DOS05_REG_PWRMT_DATA	0x0C
+#define S2DOS05_REG_IRQ_MASK	0x0D
+
+#define CHANNEL_ELVDD	0
+#define CHANNEL_ELVSS	1
+#define CHANNEL_AVDD	2
+#define CHANNEL_BUCK	3
+#define CHANNEL_L1	4
+#define CHANNEL_L2	5
+#define CHANNEL_L3	6
+#define CHANNEL_L4	7
+
+#define POWER_ELVDD			24500
+#define POWER_ELVSS			24500
+#define POWER_AVDD			3060
+#define POWER_BUCK			1525
+#define POWER_L1			5000
+#define POWER_L2			5000
+#define POWER_L3			5000
+#define POWER_L4			5000
+
+/* S2DOS05_REG_OCL */
+#define ADC_VALID_MASK			BIT(7)
+/* S2DOS05_REG_PWRMT_CTRL1 */
+#define ADC_ASYNCRD_MASK		BIT(7)
+#define PWRMT_EN_CHK			BIT(6)
+#define SMPNUM_MASK			0x0F
+/* S2DOS05_REG_PWRMT_CTRL2 */
+#define ADC_EN_MASK			BIT(7)
+#define ADC_PTR_MASK			0x0F
+#define POWER_MODE			BIT(4)
+#define RAWCURRENT_MODE			BIT(5)
+
+#define S2DOS05_MAX_ADC_CHANNEL		8
+
+#endif /*  __LINUX_MFD_S2DOS05_H */

-- 
2.39.2


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

* [PATCH v3 18/23] regulator: add s2dos05 regulator support
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (16 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 17/23] mfd: add s2dos series core driver Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 14:08   ` Mark Brown
  2024-06-20 16:08   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 19/23] power: supply: s2dos05: Add fuel gauge driver for s2dos05 Dzmitry Sankouski
                   ` (4 subsequent siblings)
  22 siblings, 2 replies; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

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

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 MAINTAINERS                           |   1 +
 drivers/regulator/Kconfig             |   8 +
 drivers/regulator/Makefile            |   1 +
 drivers/regulator/s2dos05-regulator.c | 362 ++++++++++++++++++++++++++++++++++
 4 files changed, 372 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index b53462684a30..bee700a5e648 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19910,6 +19910,7 @@ F:	Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml
 F:	drivers/clk/clk-s2mps11.c
 F:	drivers/mfd/s2dos*.c
 F:	drivers/mfd/sec*.c
+F:	drivers/regulator/s2dos*.c
 F:	drivers/regulator/s2m*.c
 F:	drivers/regulator/s5m*.c
 F:	drivers/rtc/rtc-s5m.c
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index d333be2bea3b..d6d6f571a65d 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -1297,6 +1297,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 "SLSI S2DOS05 regulator"
+	depends on MFD_S2DOS_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 ba15fa5f30ad..80f889404597 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -151,6 +151,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..3c58a1bd2262
--- /dev/null
+++ b/drivers/regulator/s2dos05-regulator.c
@@ -0,0 +1,362 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * s2dos05.c - Regulator driver for the Samsung s2dos05
+ *
+ * Copyright (C) 2016 Samsung Electronics
+ * Copyright (C) 2023 Dzmitry Sankouski <dsankouski@gmail.com>
+ *
+ */
+
+#include <linux/module.h>
+#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/s2dos-core.h>
+#include <linux/mfd/samsung/s2dos05.h>
+#include <linux/i2c.h>
+#include <linux/debugfs.h>
+
+struct s2dos05_data {
+	struct regmap *regmap;
+	struct device *dev;
+};
+
+static int s2m_enable(struct regulator_dev *rdev)
+{
+	struct s2dos05_data *info = rdev_get_drvdata(rdev);
+	struct regmap *regmap = info->regmap;
+
+	return regmap_update_bits(regmap, rdev->desc->enable_reg,
+				  rdev->desc->enable_mask,
+					rdev->desc->enable_mask);
+}
+
+static int s2m_disable_regmap(struct regulator_dev *rdev)
+{
+	struct s2dos05_data *info = rdev_get_drvdata(rdev);
+	struct regmap *regmap = info->regmap;
+	u8 val;
+
+	if (rdev->desc->enable_is_inverted)
+		val = rdev->desc->enable_mask;
+	else
+		val = 0;
+
+	return regmap_update_bits(regmap, rdev->desc->enable_reg, rdev->desc->enable_mask,
+				   val);
+}
+
+static int s2m_is_enabled_regmap(struct regulator_dev *rdev)
+{
+	struct s2dos05_data *info = rdev_get_drvdata(rdev);
+	struct regmap *regmap = info->regmap;
+	int ret;
+	unsigned int val;
+
+	ret = regmap_read(regmap, rdev->desc->enable_reg, &val);
+	if (ret < 0)
+		return ret;
+
+	if (rdev->desc->enable_is_inverted)
+		return (val & rdev->desc->enable_mask) == 0;
+	else
+		return (val & rdev->desc->enable_mask) != 0;
+}
+
+static int s2m_get_voltage_sel_regmap(struct regulator_dev *rdev)
+{
+	struct s2dos05_data *info = rdev_get_drvdata(rdev);
+	struct regmap *regmap = info->regmap;
+	int ret;
+	unsigned int val;
+
+	ret = regmap_read(regmap, rdev->desc->vsel_reg, &val);
+	if (ret < 0)
+		return ret;
+
+	val &= rdev->desc->vsel_mask;
+
+	return val;
+}
+
+static int s2m_set_voltage_sel_regmap(struct regulator_dev *rdev,
+					unsigned int sel)
+{
+	struct s2dos05_data *info = rdev_get_drvdata(rdev);
+	struct regmap *regmap = info->regmap;
+	int ret;
+
+	ret = regmap_update_bits(regmap, rdev->desc->vsel_reg, rdev->desc->vsel_mask,
+				sel);
+	if (ret < 0)
+		goto out;
+
+	if (rdev->desc->apply_bit)
+		ret = regmap_update_bits(regmap, rdev->desc->apply_reg,
+					 rdev->desc->apply_bit,
+					 rdev->desc->apply_bit);
+	return ret;
+out:
+	pr_warn("%s: failed to set voltage_sel_regmap\n", rdev->desc->name);
+	return ret;
+}
+
+static int s2m_set_voltage_sel_regmap_buck(struct regulator_dev *rdev,
+					unsigned int sel)
+{
+	struct s2dos05_data *info = rdev_get_drvdata(rdev);
+	struct regmap *regmap = info->regmap;
+	int ret;
+
+	ret = regmap_write(regmap, rdev->desc->vsel_reg, sel);
+	if (ret < 0)
+		goto out;
+
+	if (rdev->desc->apply_bit)
+		ret = regmap_update_bits(regmap, rdev->desc->apply_reg,
+					 rdev->desc->apply_bit,
+					 rdev->desc->apply_bit);
+	return ret;
+out:
+	pr_warn("%s: failed to set voltage_sel_regmap\n", rdev->desc->name);
+	return ret;
+}
+
+static int s2m_set_voltage_time_sel(struct regulator_dev *rdev,
+				   unsigned int old_selector,
+				   unsigned int new_selector)
+{
+	int old_volt, new_volt;
+
+	/* sanity check */
+	if (!rdev->desc->ops->list_voltage)
+		return -EINVAL;
+
+	old_volt = rdev->desc->ops->list_voltage(rdev, old_selector);
+	new_volt = rdev->desc->ops->list_voltage(rdev, new_selector);
+
+	if (old_selector < new_selector)
+		return DIV_ROUND_UP(new_volt - old_volt, S2DOS05_RAMP_DELAY);
+
+	return 0;
+}
+
+static int s2m_set_active_discharge(struct regulator_dev *rdev,
+					bool enable)
+{
+	struct s2dos05_data *info = rdev_get_drvdata(rdev);
+	struct regmap *regmap = info->regmap;
+	int ret;
+	u8 val;
+
+	if (enable)
+		val = rdev->desc->active_discharge_on;
+	else
+		val = rdev->desc->active_discharge_off;
+
+	ret = regmap_update_bits(regmap, rdev->desc->active_discharge_reg,
+				rdev->desc->active_discharge_mask, val);
+	return ret;
+}
+
+static const struct regulator_ops s2dos05_ldo_ops = {
+	.list_voltage		= regulator_list_voltage_linear,
+	.map_voltage		= regulator_map_voltage_linear,
+	.is_enabled		= s2m_is_enabled_regmap,
+	.enable			= s2m_enable,
+	.disable		= s2m_disable_regmap,
+	.get_voltage_sel	= s2m_get_voltage_sel_regmap,
+	.set_voltage_sel	= s2m_set_voltage_sel_regmap,
+	.set_voltage_time_sel	= s2m_set_voltage_time_sel,
+	.set_active_discharge	= s2m_set_active_discharge,
+};
+
+static const struct regulator_ops s2dos05_buck_ops = {
+	.list_voltage		= regulator_list_voltage_linear,
+	.map_voltage		= regulator_map_voltage_linear,
+	.is_enabled		= s2m_is_enabled_regmap,
+	.enable			= s2m_enable,
+	.disable		= s2m_disable_regmap,
+	.get_voltage_sel	= s2m_get_voltage_sel_regmap,
+	.set_voltage_sel	= s2m_set_voltage_sel_regmap_buck,
+	.set_voltage_time_sel	= s2m_set_voltage_time_sel,
+	.set_active_discharge	= s2m_set_active_discharge,
+};
+
+#define _BUCK(macro)	S2DOS05_BUCK##macro
+#define _buck_ops(num)	s2dos05_buck_ops##num
+
+#define _LDO(macro)	S2DOS05_LDO##macro
+#define _REG(ctrl)	S2DOS05_REG##ctrl
+#define _ldo_ops(num)	s2dos05_ldo_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,					\
+	.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,					\
+	.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 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("buck1", _BUCK(1), &_buck_ops(), _BUCK(_MIN1),
+			_BUCK(_STEP1), _REG(_BUCK_VOUT),
+			_REG(_EN), _MASK(_B1), _TIME(_BUCK), _REG(_BUCK_CFG)),
+};
+
+static int s2dos05_pmic_dt_parse_pdata(struct device *dev,
+					struct of_regulator_match *rdata,
+					unsigned int rdev_num)
+{
+	struct device_node *reg_np;
+	int err;
+
+	reg_np = of_get_child_by_name(dev->parent->of_node, "regulators");
+	if (!reg_np) {
+		dev_err(dev, "could not find regulators sub-node\n");
+		return -EINVAL;
+	}
+
+	err = of_regulator_match(dev, reg_np, rdata, rdev_num);
+	of_node_put(reg_np);
+
+	return err;
+}
+
+static int s2dos05_pmic_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct s2dos_core *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;
+	int ret, err = 0;
+
+	s2dos05 = devm_kzalloc(dev, sizeof(struct s2dos05_data),
+				GFP_KERNEL);
+	if (!s2dos05) {
+		ret = -ENOMEM;
+		goto err_data;
+	}
+	platform_set_drvdata(pdev, s2dos05);
+
+	rdata = kcalloc(rdev_num, sizeof(*rdata), GFP_KERNEL);
+	if (!rdata)
+		return -ENOMEM;
+
+	for (i = 0; i < rdev_num; i++)
+		rdata[i].name = regulators[i].name;
+
+	err = s2dos05_pmic_dt_parse_pdata(dev, rdata, rdev_num);
+	if (err < 0) {
+		dev_err(dev, "Failed to parse regulators device of_node\n");
+		goto err_data;
+	}
+
+	s2dos05->regmap = iodev->regmap;
+	s2dos05->dev = dev;
+
+	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);
+			goto out;
+		}
+	}
+
+out:
+	kfree(rdata);
+
+	return ret;
+
+err_data:
+	devm_kfree(dev, (void *)s2dos05);
+	kfree(s2dos05);
+
+	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");

-- 
2.39.2


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

* [PATCH v3 19/23] power: supply: s2dos05: Add fuel gauge driver for s2dos05
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (17 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 18/23] regulator: add s2dos05 regulator support Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-20 16:11   ` Krzysztof Kozlowski
  2024-06-18 13:59 ` [PATCH v3 20/23] arm64: dts: qcom: starqltechn: remove wifi Dzmitry Sankouski
                   ` (3 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

Add fuel gauge driver for s2dos05 PMIC. It uses adc to measure power
on each power output s2dos05 provides, including regulator outputs
and AVDD, ELVSS, ELVDD lines. Driver registers power supply for each
corresponding power line.

Adc can be disabled and enabled via sysfs.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 MAINTAINERS                       |   1 +
 drivers/power/supply/Kconfig      |   8 +
 drivers/power/supply/Makefile     |   1 +
 drivers/power/supply/s2dos05-fg.c | 427 ++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/s2dos05.h       | 123 +++++++++++
 5 files changed, 560 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index bee700a5e648..2c5d9a74f977 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19910,6 +19910,7 @@ F:	Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml
 F:	drivers/clk/clk-s2mps11.c
 F:	drivers/mfd/s2dos*.c
 F:	drivers/mfd/sec*.c
+F:	drivers/power/supply/s2dos*.c
 F:	drivers/regulator/s2dos*.c
 F:	drivers/regulator/s2m*.c
 F:	drivers/regulator/s5m*.c
diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index a3fdfcb5aa64..22090b150885 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -964,6 +964,14 @@ config CHARGER_SURFACE
 	  Microsoft Surface devices, i.e. Surface Pro 7, Surface Laptop 3,
 	  Surface Book 3, and Surface Laptop Go.
 
+config FUEL_GAUGE_S2DOS05
+	tristate "Power measurement driver for s2dos05 pmic"
+	depends on MFD_S2DOS_CORE
+	help
+	  This driver measures power consumption of s2dos05 regulator consumers.
+
+	  Say M or Y here to include power measurement ability in s2dos05 pmic.
+
 config BATTERY_UG3105
 	tristate "uPI uG3105 battery monitor driver"
 	depends on I2C
diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile
index e1abad8b6b75..fcea83c8aa79 100644
--- a/drivers/power/supply/Makefile
+++ b/drivers/power/supply/Makefile
@@ -113,6 +113,7 @@ obj-$(CONFIG_RN5T618_POWER)	+= rn5t618_power.o
 obj-$(CONFIG_BATTERY_ACER_A500)	+= acer_a500_battery.o
 obj-$(CONFIG_BATTERY_SURFACE)	+= surface_battery.o
 obj-$(CONFIG_CHARGER_SURFACE)	+= surface_charger.o
+obj-$(CONFIG_FUEL_GAUGE_S2DOS05)	+= s2dos05-fg.o
 obj-$(CONFIG_BATTERY_UG3105)	+= ug3105_battery.o
 obj-$(CONFIG_CHARGER_QCOM_SMB2)	+= qcom_pmi8998_charger.o
 obj-$(CONFIG_FUEL_GAUGE_MM8013)	+= mm8013.o
diff --git a/drivers/power/supply/s2dos05-fg.c b/drivers/power/supply/s2dos05-fg.c
new file mode 100644
index 000000000000..d2070f90c80c
--- /dev/null
+++ b/drivers/power/supply/s2dos05-fg.c
@@ -0,0 +1,427 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * s2dos05-fg.c
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd
+ *              http://www.samsung.com
+ * Copyright (c) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
+ *
+ */
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+#include <linux/power_supply.h>
+#include <linux/mfd/samsung/s2dos-core.h>
+#include <linux/mfd/samsung/s2dos05.h>
+
+#define SYNC_MODE	1
+#define ASYNC_MODE	2
+
+struct s2dos05_fg {
+	struct regmap *regmap;
+	struct device *dev;
+	u8 adc_sync_mode;
+	struct power_supply	*psy_elvdd;
+	struct power_supply	*psy_elvss;
+	struct power_supply	*psy_avdd;
+	struct power_supply	*psy_buck;
+	struct power_supply	*psy_ldo1;
+	struct power_supply	*psy_ldo2;
+	struct power_supply	*psy_ldo3;
+	struct power_supply	*psy_ldo4;
+};
+
+static const unsigned int power_coeffs[8] = {POWER_ELVDD, POWER_ELVSS, POWER_AVDD,
+	POWER_BUCK, POWER_L1, POWER_L2, POWER_L3, POWER_L4};
+
+static void s2dos05_is_online(struct s2dos05_fg *drv_data, int *val)
+{
+	unsigned int adc_ctrl2;
+
+	regmap_read(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, &adc_ctrl2);
+	if ((adc_ctrl2 & ADC_EN_MASK) > 0)
+		*val = 1;
+	else
+		*val = 0;
+}
+
+static void s2dos05_start_measurement_if_async(struct s2dos05_fg *drv_data, unsigned int channel)
+{
+	unsigned int temp;
+
+	if (drv_data->adc_sync_mode == ASYNC_MODE) {
+		regmap_read(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL1, &temp);
+		if (!(temp & PWRMT_EN_CHK))
+			return;
+
+		regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL1,
+							ADC_ASYNCRD_MASK, ADC_ASYNCRD_MASK);
+		usleep_range(2000, 2100);
+	}
+}
+
+static void s2dos05_adc_read_power(struct s2dos05_fg *drv_data, unsigned int channel, int *val)
+{
+	unsigned int data_l, data_h, adc_val;
+
+	regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, ADC_PTR_MASK,
+				2*channel);
+	regmap_read(drv_data->regmap, S2DOS05_REG_PWRMT_DATA,
+				&data_l);
+
+	regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, ADC_PTR_MASK,
+				2*channel+1);
+	regmap_read(drv_data->regmap, S2DOS05_REG_PWRMT_DATA,
+				&data_h);
+
+	adc_val = ((data_h & 0xff) << 8) | (data_l & 0xff);
+	*val = adc_val * power_coeffs[channel] / 100;
+}
+
+static int s2dos05_get_adc_validity(struct s2dos05_fg *drv_data)
+{
+	unsigned int adc_validity;
+
+	regmap_read(drv_data->regmap, S2DOS05_REG_OCL, &adc_validity);
+	return !!(adc_validity | ADC_VALID_MASK);
+}
+
+static ssize_t adc_en_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct s2dos05_fg *drv_data = dev_get_drvdata(dev);
+	unsigned int adc_ctrl3;
+
+	regmap_read(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, &adc_ctrl3);
+	if ((adc_ctrl3 & ADC_EN_MASK) > 0)
+		return snprintf(buf, PAGE_SIZE, "ADC enable (%x)\n", adc_ctrl3);
+	else
+		return snprintf(buf, PAGE_SIZE, "ADC disable (%x)\n", adc_ctrl3);
+}
+
+static ssize_t adc_en_store(struct device *dev, struct device_attribute *attr,
+				const char *buf, size_t count)
+{
+	struct s2dos05_fg *drv_data = dev_get_drvdata(dev);
+	int ret;
+	unsigned int temp, val;
+
+	ret = kstrtouint(buf, 16, &temp);
+	if (ret)
+		return -EINVAL;
+
+	switch (temp) {
+	case 0:
+		val = 0x00;
+		break;
+	case 1:
+		val = 0x80;
+		break;
+	default:
+		val = 0x00;
+		break;
+	}
+
+	regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, ADC_EN_MASK,
+				val);
+	return count;
+}
+
+static ssize_t adc_sync_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct s2dos05_fg *drv_data = dev_get_drvdata(dev);
+
+	switch (drv_data->adc_sync_mode) {
+	case SYNC_MODE:
+		return snprintf(buf, PAGE_SIZE, "SYNC_MODE (%d)\n", drv_data->adc_sync_mode);
+	case ASYNC_MODE:
+		return snprintf(buf, PAGE_SIZE, "ASYNC_MODE (%d)\n", drv_data->adc_sync_mode);
+	default:
+		return snprintf(buf, PAGE_SIZE, "error (%d)\n", drv_data->adc_sync_mode);
+	}
+}
+
+static ssize_t adc_sync_mode_store(struct device *dev, struct device_attribute *attr,
+				const char *buf, size_t count)
+{
+	struct s2dos05_fg *drv_data = dev_get_drvdata(dev);
+	int ret;
+	u8 temp;
+
+	ret = kstrtou8(buf, 16, &temp);
+	if (ret)
+		return -EINVAL;
+
+	switch (temp) {
+	case SYNC_MODE:
+		drv_data->adc_sync_mode = 1;
+		break;
+	case ASYNC_MODE:
+		drv_data->adc_sync_mode = 2;
+		break;
+	default:
+		drv_data->adc_sync_mode = 1;
+		break;
+	}
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(adc_en);
+static DEVICE_ATTR_RW(adc_sync_mode);
+
+static int s2dos05_fg_get_property(struct power_supply *psy,
+					 enum power_supply_property psp,
+					 union power_supply_propval *val,
+					 unsigned int channel
+					 )
+{
+	struct s2dos05_fg *drv_data = power_supply_get_drvdata(psy);
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_ONLINE:
+		s2dos05_is_online(drv_data, &val->intval);
+		break;
+	case POWER_SUPPLY_PROP_STATUS:
+		if (s2dos05_get_adc_validity(drv_data))
+			val->intval = POWER_SUPPLY_HEALTH_GOOD;
+		else
+			val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
+		break;
+	case POWER_SUPPLY_PROP_POWER_NOW:
+		s2dos05_start_measurement_if_async(drv_data, channel);
+		s2dos05_adc_read_power(drv_data, channel, &val->intval);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int s2dos05_fg_get_property_elvdd(struct power_supply *psy,
+					 enum power_supply_property psp,
+					 union power_supply_propval *val
+					 )
+{
+	return s2dos05_fg_get_property(psy, psp, val, CHANNEL_ELVDD);
+}
+
+static int s2dos05_fg_get_property_elvss(struct power_supply *psy,
+					 enum power_supply_property psp,
+					 union power_supply_propval *val
+					 )
+{
+	return s2dos05_fg_get_property(psy, psp, val, CHANNEL_ELVSS);
+}
+
+static int s2dos05_fg_get_property_avdd(struct power_supply *psy,
+					 enum power_supply_property psp,
+					 union power_supply_propval *val
+					 )
+{
+	return s2dos05_fg_get_property(psy, psp, val, CHANNEL_AVDD);
+}
+
+static int s2dos05_fg_get_property_buck(struct power_supply *psy,
+					 enum power_supply_property psp,
+					 union power_supply_propval *val
+					 )
+{
+	return s2dos05_fg_get_property(psy, psp, val, CHANNEL_BUCK);
+}
+
+static int s2dos05_fg_get_property_ldo1(struct power_supply *psy,
+					 enum power_supply_property psp,
+					 union power_supply_propval *val
+					 )
+{
+	return s2dos05_fg_get_property(psy, psp, val, CHANNEL_L1);
+}
+
+static int s2dos05_fg_get_property_ldo2(struct power_supply *psy,
+					 enum power_supply_property psp,
+					 union power_supply_propval *val
+					 )
+{
+	return s2dos05_fg_get_property(psy, psp, val, CHANNEL_L2);
+}
+
+static int s2dos05_fg_get_property_ldo3(struct power_supply *psy,
+					 enum power_supply_property psp,
+					 union power_supply_propval *val
+					 )
+{
+	return s2dos05_fg_get_property(psy, psp, val, CHANNEL_L3);
+}
+
+static int s2dos05_fg_get_property_ldo4(struct power_supply *psy,
+					 enum power_supply_property psp,
+					 union power_supply_propval *val
+					 )
+{
+	return s2dos05_fg_get_property(psy, psp, val, CHANNEL_L4);
+}
+
+static void s2dos05_powermeter_init(struct s2dos05_fg *drv_data)
+{
+	/*  SMP_NUM = 1100(16384) ~16s in case of aync mode */
+	regmap_write(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL1, 0x0C);
+	regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, POWER_MODE,
+			POWER_MODE);
+	/* ADC EN */
+	regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2,
+			ADC_EN_MASK, ADC_EN_MASK);
+
+}
+
+static void s2dos05_powermeter_deinit(struct s2dos05_fg *s2dos05)
+{
+	/* ADC turned off */
+	regmap_write(s2dos05->regmap, S2DOS05_REG_PWRMT_CTRL2, 0);
+}
+
+static enum power_supply_property s2dos05_fg_properties[] = {
+	POWER_SUPPLY_PROP_ONLINE,
+	POWER_SUPPLY_PROP_STATUS,
+	POWER_SUPPLY_PROP_POWER_NOW,
+};
+
+static const struct power_supply_desc s2dos05_elvdd_fg_desc = {
+	.name		= "s2dos05_elvdd",
+	.type		= POWER_SUPPLY_TYPE_UNKNOWN,
+	.get_property	= s2dos05_fg_get_property_elvdd,
+	.properties	= s2dos05_fg_properties,
+	.num_properties	= ARRAY_SIZE(s2dos05_fg_properties),
+};
+
+static const struct power_supply_desc s2dos05_elvss_fg_desc = {
+	.name		= "s2dos05_elvss",
+	.type		= POWER_SUPPLY_TYPE_UNKNOWN,
+	.get_property	= s2dos05_fg_get_property_elvss,
+	.properties	= s2dos05_fg_properties,
+	.num_properties	= ARRAY_SIZE(s2dos05_fg_properties),
+};
+
+static const struct power_supply_desc s2dos05_avdd_fg_desc = {
+	.name		= "s2dos05_avdd",
+	.type		= POWER_SUPPLY_TYPE_UNKNOWN,
+	.get_property	= s2dos05_fg_get_property_avdd,
+	.properties	= s2dos05_fg_properties,
+	.num_properties	= ARRAY_SIZE(s2dos05_fg_properties),
+};
+
+static const struct power_supply_desc s2dos05_buck_fg_desc = {
+	.name		= "s2dos05_buck",
+	.type		= POWER_SUPPLY_TYPE_UNKNOWN,
+	.get_property	= s2dos05_fg_get_property_buck,
+	.properties	= s2dos05_fg_properties,
+	.num_properties	= ARRAY_SIZE(s2dos05_fg_properties),
+};
+
+static const struct power_supply_desc s2dos05_ldo1_fg_desc = {
+	.name		= "s2dos05_ldo1",
+	.type		= POWER_SUPPLY_TYPE_UNKNOWN,
+	.get_property	= s2dos05_fg_get_property_ldo1,
+	.properties	= s2dos05_fg_properties,
+	.num_properties	= ARRAY_SIZE(s2dos05_fg_properties),
+};
+
+static const struct power_supply_desc s2dos05_ldo2_fg_desc = {
+	.name		= "s2dos05_ldo2",
+	.type		= POWER_SUPPLY_TYPE_UNKNOWN,
+	.get_property	= s2dos05_fg_get_property_ldo2,
+	.properties	= s2dos05_fg_properties,
+	.num_properties	= ARRAY_SIZE(s2dos05_fg_properties),
+};
+
+static const struct power_supply_desc s2dos05_ldo3_fg_desc = {
+	.name		= "s2dos05_ldo3",
+	.type		= POWER_SUPPLY_TYPE_UNKNOWN,
+	.get_property	= s2dos05_fg_get_property_ldo3,
+	.properties	= s2dos05_fg_properties,
+	.num_properties	= ARRAY_SIZE(s2dos05_fg_properties),
+};
+
+static const struct power_supply_desc s2dos05_ldo4_fg_desc = {
+	.name		= "s2dos05_ldo4",
+	.type		= POWER_SUPPLY_TYPE_UNKNOWN,
+	.get_property	= s2dos05_fg_get_property_ldo4,
+	.properties	= s2dos05_fg_properties,
+	.num_properties	= ARRAY_SIZE(s2dos05_fg_properties),
+};
+
+static int s2dos05_fuelgauge_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct s2dos_core *iodev = dev_get_drvdata(dev->parent);
+	struct s2dos05_fg	*drv_data;
+	struct power_supply_config pscfg = {};
+	int ret;
+
+	drv_data = devm_kzalloc(dev, sizeof(struct s2dos05_fg),
+							GFP_KERNEL);
+	if (!drv_data)
+		ret = -ENOMEM;
+
+	drv_data->regmap = iodev->regmap;
+	s2dos05_powermeter_init(drv_data);
+	pscfg.drv_data = drv_data;
+
+	drv_data->psy_elvdd = devm_power_supply_register(dev, &s2dos05_elvdd_fg_desc, &pscfg);
+	drv_data->psy_elvss = devm_power_supply_register(dev, &s2dos05_elvss_fg_desc, &pscfg);
+	drv_data->psy_avdd = devm_power_supply_register(dev, &s2dos05_avdd_fg_desc, &pscfg);
+	drv_data->psy_buck = devm_power_supply_register(dev, &s2dos05_buck_fg_desc, &pscfg);
+	drv_data->psy_ldo1 = devm_power_supply_register(dev, &s2dos05_ldo1_fg_desc, &pscfg);
+	drv_data->psy_ldo2 = devm_power_supply_register(dev, &s2dos05_ldo2_fg_desc, &pscfg);
+	drv_data->psy_ldo3 = devm_power_supply_register(dev, &s2dos05_ldo3_fg_desc, &pscfg);
+	drv_data->psy_ldo4 = devm_power_supply_register(dev, &s2dos05_ldo4_fg_desc, &pscfg);
+
+	platform_set_drvdata(pdev, drv_data);
+
+	ret = device_create_file(&pdev->dev, &dev_attr_adc_en);
+	if (ret) {
+		dev_err(dev, "failed: create adc enable sysfs entry\n");
+		goto err;
+	}
+	ret = device_create_file(&pdev->dev, &dev_attr_adc_sync_mode);
+	if (ret) {
+		dev_err(dev, "failed: create adc sync mode sysfs entry\n");
+		goto err;
+	}
+
+err:
+	device_remove_file(dev, &dev_attr_adc_en);
+	device_remove_file(dev, &dev_attr_adc_sync_mode);
+
+	return 0;
+}
+
+static void s2dos05_fuelgauge_remove(struct platform_device *pdev)
+{
+	struct s2dos05_fg *info = platform_get_drvdata(pdev);
+
+	s2dos05_powermeter_deinit(info);
+
+	device_remove_file(&pdev->dev, &dev_attr_adc_en);
+	device_remove_file(&pdev->dev, &dev_attr_adc_sync_mode);
+}
+
+static const struct platform_device_id s2dos05_platform_ids[] = {
+	{"s2dos05-fg", 0},
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(platform, s2dos05_platform_ids);
+
+static struct platform_driver s2dos05_platform_driver = {
+	.driver = {
+		.name = "s2dos05-fg",
+	},
+	.probe = s2dos05_fuelgauge_probe,
+	.id_table = s2dos05_platform_ids,
+	.remove_new = s2dos05_fuelgauge_remove,
+};
+module_platform_driver(s2dos05_platform_driver);
+
+MODULE_DESCRIPTION("s2dos05 power meter");
+MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/s2dos05.h b/include/linux/mfd/s2dos05.h
new file mode 100644
index 000000000000..8d216064bc78
--- /dev/null
+++ b/include/linux/mfd/s2dos05.h
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ * s2dos05.h
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd
+ *              http://www.samsung.com
+ *
+ */
+
+#ifndef __LINUX_MFD_S2DOS05_H
+#define __LINUX_MFD_S2DOS05_H
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+#define MFD_DEV_NAME "s2dos05"
+
+struct s2dos05_dev {
+	struct device *dev;
+	struct regmap *regmap;
+};
+
+/* 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_ENABLE_SHIFT	0x06
+#define S2DOS05_LDO_N_VOLTAGES	(S2DOS05_LDO_VSEL_MASK + 1)
+#define S2DOS05_BUCK_N_VOLTAGES (S2DOS05_BUCK_VSEL_MASK + 1)
+
+#define S2DOS05_PMIC_EN_SHIFT	6
+#define S2DOS05_REGULATOR_MAX (S2DOS05_REG_MAX)
+
+/* ----------power meter ----------*/
+#define S2DOS05_REG_PWRMT_CTRL1		0x0A
+#define S2DOS05_REG_PWRMT_CTRL2		0x0B
+#define S2DOS05_REG_PWRMT_DATA	0x0C
+#define S2DOS05_REG_IRQ_MASK	0x0D
+
+#define CHANNEL_ELVDD	0
+#define CHANNEL_ELVSS	1
+#define CHANNEL_AVDD	2
+#define CHANNEL_BUCK	3
+#define CHANNEL_L1	4
+#define CHANNEL_L2	5
+#define CHANNEL_L3	6
+#define CHANNEL_L4	7
+
+#define POWER_ELVDD			24500
+#define POWER_ELVSS			24500
+#define POWER_AVDD			3060
+#define POWER_BUCK			1525
+#define POWER_L1			5000
+#define POWER_L2			5000
+#define POWER_L3			5000
+#define POWER_L4			5000
+
+/* S2DOS05_REG_OCL */
+#define ADC_VALID_MASK			BIT(7)
+/* S2DOS05_REG_PWRMT_CTRL1 */
+#define ADC_ASYNCRD_MASK		BIT(7)
+#define PWRMT_EN_CHK			BIT(6)
+#define SMPNUM_MASK			0x0F
+/* S2DOS05_REG_PWRMT_CTRL2 */
+#define ADC_EN_MASK			BIT(7)
+#define ADC_PTR_MASK			0x0F
+#define POWER_MODE			BIT(4)
+#define RAWCURRENT_MODE			BIT(5)
+
+#define S2DOS05_MAX_ADC_CHANNEL		8
+
+#endif /*  __LINUX_MFD_S2DOS05_H */

-- 
2.39.2


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

* [PATCH v3 20/23] arm64: dts: qcom: starqltechn: remove wifi
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (18 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 19/23] power: supply: s2dos05: Add fuel gauge driver for s2dos05 Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 14:06   ` Konrad Dybcio
  2024-06-18 13:59 ` [PATCH v3 21/23] arm64: dts: qcom: starqltechn: remove framebuffer Dzmitry Sankouski
                   ` (2 subsequent siblings)
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

Starqltechn has broadcom chip for wifi, so sdm845 wifi part
can be disabled.

Fixes: d711b22eee55 ("arm64: dts: qcom: starqltechn: add initial device tree for starqltechn")

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
index d37a433130b9..6fc30fd1262b 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
@@ -418,14 +418,6 @@ &usb_1_qmpphy {
 	status = "okay";
 };
 
-&wifi {
-	vdd-0.8-cx-mx-supply = <&vreg_l5a_0p8>;
-	vdd-1.8-xo-supply = <&vreg_l7a_1p8>;
-	vdd-1.3-rfa-supply = <&vreg_l17a_1p3>;
-	vdd-3.3-ch0-supply = <&vreg_l25a_3p3>;
-	status = "okay";
-};
-
 &tlmm {
 	gpio-reserved-ranges = <0 4>, <27 4>, <81 4>, <85 4>;
 

-- 
2.39.2


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

* [PATCH v3 21/23] arm64: dts: qcom: starqltechn: remove framebuffer
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (19 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 20/23] arm64: dts: qcom: starqltechn: remove wifi Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 14:06   ` Konrad Dybcio
  2024-06-18 13:59 ` [PATCH v3 22/23] arm64: dts: qcom: starqltechn: fix usb regulator mistake Dzmitry Sankouski
  2024-06-18 13:59 ` [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features Dzmitry Sankouski
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

Remove framebuffer because a panel driver introduced.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
index 6fc30fd1262b..578798704577 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
@@ -19,15 +19,6 @@ / {
 	chosen {
 		#address-cells = <2>;
 		#size-cells = <2>;
-		ranges;
-		framebuffer: framebuffer@9d400000 {
-			compatible = "simple-framebuffer";
-			reg = <0 0x9d400000 0 (2960 * 1440 * 4)>;//2400000
-			width = <1440>;
-			height = <2960>;
-			stride = <(1440 * 4)>;
-			format = "a8r8g8b8";
-		};
 	};
 
 	vph_pwr: vph-pwr-regulator {

-- 
2.39.2


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

* [PATCH v3 22/23] arm64: dts: qcom: starqltechn: fix usb regulator mistake
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (20 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 21/23] arm64: dts: qcom: starqltechn: remove framebuffer Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 14:07   ` Konrad Dybcio
  2024-06-18 13:59 ` [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features Dzmitry Sankouski
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

Usb regulator was wrongly pointed to vreg_l1a_0p875.
However, on starqltechn it's powered from vreg_l5a_0p8.

Fixes: d711b22eee55 ("arm64: dts: qcom: starqltechn: add initial device tree for starqltechn")

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
index 578798704577..bad154b1e894 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
@@ -126,8 +126,6 @@ vdda_pll_cc_ebi23:
 		vdda_sp_sensor:
 		vdda_ufs1_core:
 		vdda_ufs2_core:
-		vdda_usb1_ss_core:
-		vdda_usb2_ss_core:
 		vreg_l1a_0p875: ldo1 {
 			regulator-min-microvolt = <880000>;
 			regulator-max-microvolt = <880000>;
@@ -148,6 +146,7 @@ vreg_l3a_1p0: ldo3 {
 			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
 		};
 
+		vdda_usb1_ss_core:
 		vdd_wcss_cx:
 		vdd_wcss_mx:
 		vdda_wcss_pll:

-- 
2.39.2


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

* [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features
  2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
                   ` (21 preceding siblings ...)
  2024-06-18 13:59 ` [PATCH v3 22/23] arm64: dts: qcom: starqltechn: fix usb regulator mistake Dzmitry Sankouski
@ 2024-06-18 13:59 ` Dzmitry Sankouski
  2024-06-18 14:12   ` Konrad Dybcio
  22 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 13:59 UTC (permalink / raw)
  To: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Dzmitry Sankouski

Add support for new features:
- sound (headphones and mics only)
- gpu
- panel
- buttons
- MAX77705 MFD:
   - charger
   - fuelgauge
   - haptic
   - led

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
---
 .../boot/dts/qcom/sdm845-samsung-starqltechn.dts   | 593 ++++++++++++++++++++-
 1 file changed, 592 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
index bad154b1e894..28a5210e22fb 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
@@ -7,15 +7,40 @@
 
 /dts-v1/;
 
+#include <dt-bindings/input/linux-event-codes.h>
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/regulator/qcom,rpmh-regulator.h>
+#include <dt-bindings/sound/qcom,q6afe.h>
+#include <dt-bindings/sound/qcom,q6asm.h>
+
 #include "sdm845.dtsi"
+#include "pm8998.dtsi"
+#include "sdm845-wcd9340.dtsi"
+
+/delete-node/ &rmtfs_mem;
+/delete-node/ &adsp_mem;
+/delete-node/ &slpi_mem;
+/delete-node/ &spss_mem;
 
 / {
 	chassis-type = "handset";
 	model = "Samsung Galaxy S9 SM-G9600";
 	compatible = "samsung,starqltechn", "qcom,sdm845";
 
+	aliases {
+		serial0 = &uart9;
+	};
+
+	battery: battery {
+		compatible = "simple-battery";
+		constant-charge-current-max-microamp = <2150000>;
+		charge-full-design-microamp-hours = <3000000>;
+
+		over-voltage-threshold-microvolt = <4500000>;
+		voltage-min-design-microvolt = <3400000>;
+		voltage-max-design-microvolt = <4350000>;
+	};
+
 	chosen {
 		#address-cells = <2>;
 		#size-cells = <2>;
@@ -59,9 +84,199 @@ memory@a1300000 {
 			ftrace-size = <0x40000>;
 			pmsg-size = <0x40000>;
 		};
+
+		/* The rmtfs_mem needs to be guarded due to "XPU limitations"
+		 * it is otherwise possible for an allocation adjacent to the
+		 * rmtfs_mem region to trigger an XPU violation, causing a crash.
+		 */
+		rmtfs_lower_guard: memory@fde00000 {
+			no-map;
+			reg = <0 0xfde00000 0 0x1000>;
+		};
+
+		rmtfs_mem: rmtfs-mem@fde01000 {
+			compatible = "qcom,rmtfs-mem";
+			reg = <0 0xfde01000 0 0x200000>;
+			no-map;
+
+			qcom,client-id = <1>;
+			qcom,vmid = <15>;
+		};
+
+		rmtfs_upper_guard: rmtfs-upper-guard@fe001000 {
+			no-map;
+			reg = <0 0xfe001000 0 0x1000>;
+		};
+
+		/*
+		 * It seems like reserving the old rmtfs_mem region is also needed to prevent
+		 * random crashes which are most likely modem related, more testing needed.
+		 */
+		removed_region: removed-region@88f00000 {
+			no-map;
+			reg = <0 0x88f00000 0 0x1c00000>;
+		};
+
+		slpi_mem: slpi@96700000 {
+			reg = <0 0x96700000 0 0xf00000>;
+			no-map;
+		};
+
+		spss_mem: spss@97700000 {
+			reg = <0 0x97700000 0 0x100000>;
+			no-map;
+		};
+
+		adsp_mem: memory@97800000 {
+			reg = <0 0x97800000 0 0x2000000>;
+			no-map;
+		};
+	};
+
+	gpio_keys {
+		compatible = "gpio-keys";
+		autorepeat;
+
+		key-vol-up {
+			label = "volume_up";
+			gpios = <&pm8998_gpios 6 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_VOLUMEUP>;
+			debounce-interval = <15>;
+		};
+
+		key-wink {
+			label = "key_wink";
+			gpios = <&pm8998_gpios 19 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_ENTER>;
+			debounce-interval = <15>;
+		};
+	};
+
+	i2c21 {
+		compatible = "i2c-gpio";
+		sda-gpios = <&tlmm 127 GPIO_ACTIVE_HIGH>;
+		scl-gpios = <&tlmm 128 GPIO_ACTIVE_HIGH>;
+		i2c-gpio,delay-us = <2>;
+		pinctrl-0 = <&i2c21_sda_state &i2c21_scl_state>;
+		pinctrl-names = "default";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		pmic@60 {
+			compatible = "samsung,s2dos05-pmic";
+			reg = <0x60>;
+
+			regulators {
+				s2dos05_ldo1: ldo1 {
+					regulator-name = "s2dos05-ldo1";
+					regulator-min-microvolt = <1500000>;
+					regulator-max-microvolt = <2000000>;
+					regulator-active-discharge = <1>;
+				};
+
+				s2dos05_ldo2: ldo2 {
+					regulator-name = "s2dos05-ldo2";
+					regulator-min-microvolt = <1800000>;
+					regulator-max-microvolt = <1800000>;
+					regulator-active-discharge = <1>;
+					regulator-boot-on;
+				};
+
+				s2dos05_ldo3: ldo3 {
+					regulator-name = "s2dos05-ldo3";
+					regulator-min-microvolt = <3000000>;
+					regulator-max-microvolt = <3000000>;
+					regulator-active-discharge = <1>;
+					regulator-boot-on;
+				};
+
+				s2dos05_ldo4: ldo4 {
+					regulator-name = "s2dos05-ldo4";
+					regulator-min-microvolt = <2700000>;
+					regulator-max-microvolt = <3775000>;
+					regulator-active-discharge = <1>;
+				};
+
+				s2dos05_buck1: buck1 {
+					regulator-name = "s2dos05-buck1";
+					regulator-min-microvolt = <850000>;
+					regulator-max-microvolt = <2100000>;
+					regulator-active-discharge = <1>;
+				};
+			};
+		};
+	};
+
+	vib_regulator: gpio-regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "haptic";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-boot-on;
+		enable-active-high;
+		gpio = <&pm8998_gpios 18 GPIO_ACTIVE_HIGH>;
+	};
+
+	vib_pwm: pwm {
+		#pwm-cells = <2>;
+		compatible = "clk-pwm";
+		clocks = <&gcc GCC_GP1_CLK>;
+		pinctrl-0 = <&motor_pwm_default_state>;
+		pinctrl-1 = <&motor_pwm_suspend_state>;
+		pinctrl-names = "default", "suspend";
+	};
+};
+
+&gmu {
+	status = "okay";
+};
+
+&gpu {
+	status = "okay";
+
+	zap-shader {
+		memory-region = <&gpu_mem>;
+		firmware-name = "qcom/sdm845/starqltechn/a630_zap.mbn";
+	};
+};
+
+&mdss {
+	status = "okay";
+};
+
+&mdss_dsi0 {
+	vdda-supply = <&vreg_l26a_1p2>;
+	status = "okay";
+
+	panel@0 {
+		compatible = "samsung,s6e3ha8";
+		reg = <0>;
+		vci-supply = <&s2dos05_ldo4>;
+		vddr-supply = <&s2dos05_buck1>;
+		vdd3-supply = <&s2dos05_ldo1>;
+		te-gpios = <&tlmm 10 GPIO_ACTIVE_HIGH>;
+		reset-gpios = <&tlmm 6 GPIO_ACTIVE_HIGH>;
+		pinctrl-0 = <&sde_dsi_default &sde_te>;
+		pinctrl-1 = <&sde_dsi_suspend &sde_te>;
+		pinctrl-names = "default", "suspend";
+
+		port {
+			panel_in: endpoint {
+				remote-endpoint = <&mdss_dsi0_out>;
+			};
+		};
 	};
 };
 
+&mdss_dsi0_out {
+	data-lanes = <0 1 2 3>;
+	remote-endpoint = <&panel_in>;
+};
+
+&mdss_dsi0_phy {
+	vdds-supply = <&vdda_mipi_dsi0_pll>;
+	status = "okay";
+};
 
 &apps_rsc {
 	regulators-0 {
@@ -355,10 +570,72 @@ &qupv3_id_1 {
 	status = "okay";
 };
 
+&gpi_dma0 {
+	status = "okay";
+};
+
+&gpi_dma1 {
+	status = "okay";
+};
+
 &uart9 {
 	status = "okay";
 };
 
+&i2c14 {
+	status = "okay";
+
+	pmic@66 {
+		compatible = "maxim,max77705";
+		reg = <0x66>;
+		interrupt-parent = <&pm8998_gpios>;
+		interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
+		interrupt-names = "max77705_irq";
+		pinctrl-0 = <&chg_int_default>;
+		pinctrl-names = "default";
+
+		leds {
+			compatible = "maxim,max77705-led";
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			led@1 {
+				reg = <1>;
+				label = "red:usr1";
+			};
+
+			led@2 {
+				reg = <2>;
+				label = "green:usr2";
+			};
+
+			led@3 {
+				reg = <3>;
+				label = "blue:usr3";
+			};
+		};
+
+		max77705_charger: charger {
+			compatible = "maxim,max77705-charger";
+			monitored-battery = <&battery>;
+		};
+
+		fuelgauge {
+			compatible = "maxim,max77705-fg";
+			monitored-battery = <&battery>;
+			power-supplies = <&max77705_charger>;
+			rsense = <5>;
+		};
+
+
+		haptic {
+			compatible = "maxim,max77705-haptic";
+			haptic-supply = <&vib_regulator>;
+			pwms = <&vib_pwm 0 50000>;
+		};
+	};
+};
+
 &ufs_mem_hc {
 	reset-gpios = <&tlmm 150 GPIO_ACTIVE_LOW>;
 	vcc-supply = <&vreg_l20a_2p95>;
@@ -373,14 +650,241 @@ &ufs_mem_phy {
 };
 
 &sdhc_2 {
-	pinctrl-names = "default";
 	pinctrl-0 = <&sdc2_clk_state &sdc2_cmd_state &sdc2_data_state &sd_card_det_n_state>;
+	pinctrl-names = "default";
 	cd-gpios = <&tlmm 126 GPIO_ACTIVE_LOW>;
 	vmmc-supply = <&vreg_l21a_2p95>;
 	vqmmc-supply = <&vddpx_2>;
 	status = "okay";
 };
 
+&i2c11 {
+	clock-frequency = <400000>;
+	status = "okay";
+
+	touchscreen@48 {
+		compatible = "samsung,s6sy761";
+		reg = <0x48>;
+		interrupt-parent = <&tlmm>;
+		interrupts = <120 IRQ_TYPE_LEVEL_HIGH>;
+		vdd-supply = <&s2dos05_ldo2>;
+		avdd-supply = <&s2dos05_ldo3>;
+
+		pinctrl-0 = <&touch_irq_state>;
+		pinctrl-names = "default";
+	};
+};
+
+&adsp_pas {
+	firmware-name = "qcom/sdm845/starqltechn/adsp.mbn";
+	status = "okay";
+};
+
+&lpasscc {
+	status = "okay";
+};
+
+&wcd9340 {
+	reset-gpios = <&tlmm 64 GPIO_ACTIVE_HIGH>;
+	vdd-buck-supply = <&vreg_s4a_1p8>;
+	vdd-buck-sido-supply = <&vreg_s4a_1p8>;
+	vdd-tx-supply = <&vreg_s4a_1p8>;
+	vdd-rx-supply = <&vreg_s4a_1p8>;
+	vdd-io-supply = <&vreg_s4a_1p8>;
+	qcom,micbias1-microvolt = <1800000>;
+	qcom,micbias2-microvolt = <2700000>;
+	qcom,micbias3-microvolt = <1800000>;
+	qcom,micbias4-microvolt = <1800000>;
+};
+
+&sound {
+	compatible = "qcom,sdm845-sndcard";
+	model = "Samsung Galaxy S9";
+	pinctrl-0 = <&quat_mi2s_active &quat_mi2s_sd0_active &quat_mi2s_sd1_active>;
+	pinctrl-names = "default";
+	status = "okay";
+
+	audio-routing =	"RX_BIAS", "MCLK",
+			"AMIC2", "MIC BIAS2", /* Headset Mic */
+			"AMIC3", "MIC BIAS2", /* FMLeft Tx */
+			"AMIC4", "MIC BIAS2", /* FMRight Tx */
+			"DMIC0", "MIC BIAS1", /* Digital Mic0 */
+			"DMIC5", "MIC BIAS4", /* Digital Mic1 */
+			"DMIC4", "MIC BIAS4", /* Digital Mic2 */
+			"DMIC3", "MIC BIAS3", /* Digital Mic3 */
+			"DMIC2", "MIC BIAS3", /* Digital Mic4 */
+			"DMIC1", "MIC BIAS1"; /* Digital Mic5 */
+
+	mm1-dai-link {
+		link-name = "MultiMedia1";
+		cpu {
+			sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>;
+		};
+	};
+
+	mm2-dai-link {
+		link-name = "MultiMedia2";
+		cpu {
+			sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA2>;
+		};
+	};
+
+	mm3-dai-link {
+		link-name = "MultiMedia3";
+		cpu {
+			sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA3>;
+		};
+	};
+
+	mm4-dai-link {
+		link-name = "MultiMedia4";
+		cpu {
+			sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA4>;
+		};
+	};
+
+	mm5-dai-link {
+		link-name = "MultiMedia5";
+		cpu {
+			sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA5>;
+		};
+	};
+
+	mm6-dai-link {
+		link-name = "MultiMedia6";
+		cpu {
+			sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA6>;
+		};
+	};
+
+	slim-dai-link {
+		link-name = "SLIM Playback 1";
+		cpu {
+			sound-dai = <&q6afedai SLIMBUS_0_RX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+
+		codec {
+			sound-dai = <&wcd9340 0>;
+		};
+	};
+
+	slimcap-dai-link {
+		link-name = "SLIM Capture 1";
+		cpu {
+			sound-dai = <&q6afedai SLIMBUS_0_TX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+
+		codec {
+			sound-dai = <&wcd9340 1>;
+		};
+	};
+
+	slim2-dai-link {
+		link-name = "SLIM Playback 2";
+		cpu {
+			sound-dai = <&q6afedai SLIMBUS_1_RX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+
+		codec {
+			sound-dai = <&wcd9340 2>; /* AIF2_PB */
+		};
+	};
+
+	slimcap2-dai-link {
+		link-name = "SLIM Capture 2";
+		cpu {
+			sound-dai = <&q6afedai SLIMBUS_1_TX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+
+		codec {
+			sound-dai = <&wcd9340 3>; /* AIF2_CAP */
+		};
+	};
+
+	slimcap3-dai-link {
+		link-name = "SLIM Capture 3";
+		cpu {
+			sound-dai = <&q6afedai SLIMBUS_2_TX>;
+		};
+
+		platform {
+			sound-dai = <&q6routing>;
+		};
+
+		codec {
+			sound-dai = <&wcd9340 5>; /* AIF3_CAP */
+		};
+	};
+};
+
+&q6afedai {
+	dai@22 {
+		reg = <22>;
+		qcom,sd-lines = <1>;
+	};
+
+	dai@23 {
+		reg = <23>;
+		qcom,sd-lines = <0>;
+	};
+};
+
+&q6asmdai {
+	dai@0 {
+		reg = <0>;
+	};
+
+	dai@1 {
+		reg = <1>;
+	};
+
+	dai@2 {
+		reg = <2>;
+	};
+
+	dai@3 {
+		reg = <3>;
+	};
+
+	dai@4 {
+		reg = <4>;
+	};
+
+	dai@5 {
+		reg = <5>;
+	};
+};
+
+/* Modem/wifi */
+&mss_pil {
+	firmware-name = "qcom/sdm845/starqltechn/mba.mbn",
+			"qcom/sdm845/starqltechn/modem.mbn";
+	status = "okay";
+};
+
+&ipa {
+	qcom,gsi-loader = "self";
+	memory-region = <&ipa_fw_mem>;
+	firmware-name = "qcom/sdm845/starqltechn/ipa_fws.mbn";
+	status = "okay";
+};
+
 &usb_1 {
 	status = "okay";
 };
@@ -408,9 +912,45 @@ &usb_1_qmpphy {
 	status = "okay";
 };
 
+&pm8998_resin {
+	linux,code = <KEY_VOLUMEDOWN>;
+	status = "okay";
+};
+
+&pm8998_gpios {
+	chg_int_default: chg-int-default-state {
+		pins = "gpio11";
+		function = "normal";
+		input-enable;
+		bias-disable;
+		power-source = <0>;
+	};
+};
+
 &tlmm {
 	gpio-reserved-ranges = <0 4>, <27 4>, <81 4>, <85 4>;
 
+	sde_dsi_default: sde-dsi-default-state {
+		pins = "gpio6";
+		function = "gpio";
+		drive-strength = <8>;
+		bias-disable;
+	};
+
+	sde_dsi_suspend: sde-dsi-suspend-state {
+		pins = "gpio6";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-pull-down;
+	};
+
+	sde_te: sde-te-state {
+		pins = "gpio10";
+		function = "mdp_vsync";
+		drive-strength = <2>;
+		bias-pull-down;
+	};
+
 	sdc2_clk_state: sdc2-clk-state {
 		pins = "sdc2_clk";
 		bias-disable;
@@ -439,4 +979,55 @@ sd_card_det_n_state: sd-card-det-n-state {
 		function = "gpio";
 		bias-pull-up;
 	};
+
+	motor_pwm_default_state: motor-pwm-active-state {
+		pins = "gpio57";
+		function = "gcc_gp1";
+		drive-strength = <2>;
+		bias-disable;
+		output-high;
+	};
+
+	motor_pwm_suspend_state: motor-pwm-suspend-state {
+		pins = "gpio57";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-disable;
+		output-low;
+	};
+
+	i2c21_sda_state: i2c21-sda-state {
+		pins = "gpio127";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-disable;
+	};
+
+	i2c21_scl_state: i2c21-scl-state {
+		pins = "gpio128";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-disable;
+	};
+
+	touch_irq_state: touch-irq-state {
+		pins = "gpio120";
+		function = "gpio";
+		bias-disable;
+	};
+};
+
+&qup_uart9_tx {
+	drive-strength = <2>;
+	bias-pull-up;
+};
+
+&qup_uart9_rx {
+	drive-strength = <2>;
+	bias-pull-up;
+};
+
+&qup_i2c11_default {
+	drive-strength = <2>;
+	bias-disable;
 };

-- 
2.39.2


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

* Re: [PATCH v3 20/23] arm64: dts: qcom: starqltechn: remove wifi
  2024-06-18 13:59 ` [PATCH v3 20/23] arm64: dts: qcom: starqltechn: remove wifi Dzmitry Sankouski
@ 2024-06-18 14:06   ` Konrad Dybcio
  0 siblings, 0 replies; 62+ messages in thread
From: Konrad Dybcio @ 2024-06-18 14:06 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König,
	Krzysztof Kozlowski, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc



On 6/18/24 15:59, Dzmitry Sankouski wrote:
> Starqltechn has broadcom chip for wifi, so sdm845 wifi part
> can be disabled.
> 
> Fixes: d711b22eee55 ("arm64: dts: qcom: starqltechn: add initial device tree for starqltechn")
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad

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

* Re: [PATCH v3 21/23] arm64: dts: qcom: starqltechn: remove framebuffer
  2024-06-18 13:59 ` [PATCH v3 21/23] arm64: dts: qcom: starqltechn: remove framebuffer Dzmitry Sankouski
@ 2024-06-18 14:06   ` Konrad Dybcio
  0 siblings, 0 replies; 62+ messages in thread
From: Konrad Dybcio @ 2024-06-18 14:06 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König,
	Krzysztof Kozlowski, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc



On 6/18/24 15:59, Dzmitry Sankouski wrote:
> Remove framebuffer because a panel driver introduced.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---

Not sure if you want it gone, this still provides framebuffer output
for the first 1 second or so

Konrad

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

* Re: [PATCH v3 22/23] arm64: dts: qcom: starqltechn: fix usb regulator mistake
  2024-06-18 13:59 ` [PATCH v3 22/23] arm64: dts: qcom: starqltechn: fix usb regulator mistake Dzmitry Sankouski
@ 2024-06-18 14:07   ` Konrad Dybcio
  2024-06-18 14:16     ` Dzmitry Sankouski
  0 siblings, 1 reply; 62+ messages in thread
From: Konrad Dybcio @ 2024-06-18 14:07 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König,
	Krzysztof Kozlowski, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc



On 6/18/24 15:59, Dzmitry Sankouski wrote:
> Usb regulator was wrongly pointed to vreg_l1a_0p875.
> However, on starqltechn it's powered from vreg_l5a_0p8.
> 
> Fixes: d711b22eee55 ("arm64: dts: qcom: starqltechn: add initial device tree for starqltechn")
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---

How did you confirm that?

Konrad

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

* Re: [PATCH v3 18/23] regulator: add s2dos05 regulator support
  2024-06-18 13:59 ` [PATCH v3 18/23] regulator: add s2dos05 regulator support Dzmitry Sankouski
@ 2024-06-18 14:08   ` Mark Brown
  2024-06-19 15:49     ` Dzmitry Sankouski
  2024-06-20 16:08   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 62+ messages in thread
From: Mark Brown @ 2024-06-18 14:08 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Uwe Kleine-König, Krzysztof Kozlowski, Konrad Dybcio,
	Chanwoo Choi, phone-devel, linux-pm, linux-kernel, linux-arm-msm,
	linux-clk, dri-devel, devicetree, linux-input, linux-leds,
	linux-pwm, linux-samsung-soc

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

On Tue, Jun 18, 2024 at 04:59:52PM +0300, Dzmitry Sankouski wrote:

> index 000000000000..3c58a1bd2262
> --- /dev/null
> +++ b/drivers/regulator/s2dos05-regulator.c
> @@ -0,0 +1,362 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * s2dos05.c - Regulator driver for the Samsung s2dos05
> + *

Please make the entire comment a C++ one so things look more
intentional.

> +static int s2m_enable(struct regulator_dev *rdev)
> +{
> +	struct s2dos05_data *info = rdev_get_drvdata(rdev);
> +	struct regmap *regmap = info->regmap;
> +
> +	return regmap_update_bits(regmap, rdev->desc->enable_reg,
> +				  rdev->desc->enable_mask,
> +					rdev->desc->enable_mask);
> +}

Please use the generic regmap helpers rather than open coding them.

> +	reg_np = of_get_child_by_name(dev->parent->of_node, "regulators");
> +	if (!reg_np) {
> +		dev_err(dev, "could not find regulators sub-node\n");
> +		return -EINVAL;
> +	}
> +
> +	err = of_regulator_match(dev, reg_np, rdata, rdev_num);
> +	of_node_put(reg_np);

Use of_match for this rather than open coding.

> +	s2dos05 = devm_kzalloc(dev, sizeof(struct s2dos05_data),
> +				GFP_KERNEL);

> +	rdata = kcalloc(rdev_num, sizeof(*rdata), GFP_KERNEL);
> +	if (!rdata)
> +		return -ENOMEM;

Mixing devm_ and regular allocations seems likely to go wrong, please be
consistent.

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

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

* Re: [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features
  2024-06-18 13:59 ` [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features Dzmitry Sankouski
@ 2024-06-18 14:12   ` Konrad Dybcio
  2024-07-08 15:54     ` Dzmitry Sankouski
  0 siblings, 1 reply; 62+ messages in thread
From: Konrad Dybcio @ 2024-06-18 14:12 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König,
	Krzysztof Kozlowski, Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc



On 6/18/24 15:59, Dzmitry Sankouski wrote:
> Add support for new features:
> - sound (headphones and mics only)
> - gpu
> - panel
> - buttons
> - MAX77705 MFD:
>     - charger
>     - fuelgauge
>     - haptic
>     - led
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---

Please split this up

>   .../boot/dts/qcom/sdm845-samsung-starqltechn.dts   | 593 ++++++++++++++++++++-
>   1 file changed, 592 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
> index bad154b1e894..28a5210e22fb 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
> +++ b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts
> @@ -7,15 +7,40 @@
>   
>   /dts-v1/;
>   
> +#include <dt-bindings/input/linux-event-codes.h>
>   #include <dt-bindings/gpio/gpio.h>
>   #include <dt-bindings/regulator/qcom,rpmh-regulator.h>
> +#include <dt-bindings/sound/qcom,q6afe.h>
> +#include <dt-bindings/sound/qcom,q6asm.h>
> +
>   #include "sdm845.dtsi"
> +#include "pm8998.dtsi"
> +#include "sdm845-wcd9340.dtsi"
> +
> +/delete-node/ &rmtfs_mem;
> +/delete-node/ &adsp_mem;
> +/delete-node/ &slpi_mem;
> +/delete-node/ &spss_mem;
>   
>   / {
>   	chassis-type = "handset";
>   	model = "Samsung Galaxy S9 SM-G9600";
>   	compatible = "samsung,starqltechn", "qcom,sdm845";
>   
> +	aliases {
> +		serial0 = &uart9;
> +	};
> +
> +	battery: battery {
> +		compatible = "simple-battery";
> +		constant-charge-current-max-microamp = <2150000>;
> +		charge-full-design-microamp-hours = <3000000>;
> +
> +		over-voltage-threshold-microvolt = <4500000>;
> +		voltage-min-design-microvolt = <3400000>;
> +		voltage-max-design-microvolt = <4350000>;
> +	};
> +
>   	chosen {
>   		#address-cells = <2>;
>   		#size-cells = <2>;
> @@ -59,9 +84,199 @@ memory@a1300000 {
>   			ftrace-size = <0x40000>;
>   			pmsg-size = <0x40000>;
>   		};
> +
> +		/* The rmtfs_mem needs to be guarded due to "XPU limitations"
> +		 * it is otherwise possible for an allocation adjacent to the
> +		 * rmtfs_mem region to trigger an XPU violation, causing a crash.
> +		 */
> +		rmtfs_lower_guard: memory@fde00000 {
> +			no-map;
> +			reg = <0 0xfde00000 0 0x1000>;
> +		};

qcom,use-guard-pages instead


> +
> +		rmtfs_mem: rmtfs-mem@fde01000 {
> +			compatible = "qcom,rmtfs-mem";
> +			reg = <0 0xfde01000 0 0x200000>;
> +			no-map;
> +
> +			qcom,client-id = <1>;
> +			qcom,vmid = <15>;

QCOM_SCM_VMID_MSS_MSA

[...]

> +		/*
> +		 * It seems like reserving the old rmtfs_mem region is also needed to prevent
> +		 * random crashes which are most likely modem related, more testing needed.
> +		 */
> +		removed_region: removed-region@88f00000 {
> +			no-map;
> +			reg = <0 0x88f00000 0 0x1c00000>;

Please keep no-map below reg for consistency

[...]

> +
> +&gmu {
> +	status = "okay";
> +};

Drop this and remove the disablement in 845.dtsi, gmu is only probed when
GPU is

[...]

>   	gpio-reserved-ranges = <0 4>, <27 4>, <81 4>, <85 4>;

Do you know what these are for?

Konrad

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

* Re: [PATCH v3 22/23] arm64: dts: qcom: starqltechn: fix usb regulator mistake
  2024-06-18 14:07   ` Konrad Dybcio
@ 2024-06-18 14:16     ` Dzmitry Sankouski
  0 siblings, 0 replies; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-18 14:16 UTC (permalink / raw)
  To: Konrad Dybcio
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Chanwoo Choi, phone-devel, linux-pm, linux-kernel, linux-arm-msm,
	linux-clk, dri-devel, devicetree, linux-input, linux-leds,
	linux-pwm, linux-samsung-soc

вт, 18 июн. 2024 г. в 17:08, Konrad Dybcio <konrad.dybcio@linaro.org>:
>
>
>
> On 6/18/24 15:59, Dzmitry Sankouski wrote:
> > Usb regulator was wrongly pointed to vreg_l1a_0p875.
> > However, on starqltechn it's powered from vreg_l5a_0p8.
> >
> > Fixes: d711b22eee55 ("arm64: dts: qcom: starqltechn: add initial device tree for starqltechn")
> >
> > Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> > ---
>
> How did you confirm that?
Vendor kernel source code:
https://github.com/klabit87/twrp_android_samsung_kernel_sdm845/blob/e8bb63039008e1704a2f1bde68d39ded9c16ea88/arch/arm64/boot/dts/samsung/sdm845-sec-starqlte-chnhk-r14_v2.1.dts#L10242
https://github.com/klabit87/twrp_android_samsung_kernel_sdm845/blob/e8bb63039008e1704a2f1bde68d39ded9c16ea88/arch/arm64/boot/dts/samsung/sdm845-sec-starqlte-chnhk-r14_v2.1.dts#L23401
>
> Konrad

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

* Re: [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705
  2024-06-18 13:59 ` [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705 Dzmitry Sankouski
@ 2024-06-18 16:53   ` Rob Herring (Arm)
  2024-06-20 15:45   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 62+ messages in thread
From: Rob Herring (Arm) @ 2024-06-18 16:53 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Dmitry Torokhov, Sebastian Reichel, linux-pwm, phone-devel,
	Neil Armstrong, Sam Ravnborg, Uwe Kleine-König, linux-pm,
	Stephen Boyd, Mark Brown, dri-devel, Bjorn Andersson,
	Maxime Ripard, Liam Girdwood, Conor Dooley, Michael Turquette,
	Daniel Vetter, Krzysztof Kozlowski, Krzysztof Kozlowski,
	linux-samsung-soc, linux-kernel, Lee Jones, linux-clk, devicetree,
	Maarten Lankhorst, Thomas Zimmermann, Konrad Dybcio,
	linux-arm-msm, Pavel Machek, David Airlie, Jessica Zhang,
	linux-leds, linux-input, Chanwoo Choi


On Tue, 18 Jun 2024 16:59:38 +0300, Dzmitry Sankouski wrote:
> maxim,max77705 is MAX77705 pmic binding part
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  .../devicetree/bindings/mfd/maxim,max77705.yaml    | 112 +++++++++++++++++++++
>  MAINTAINERS                                        |   1 +
>  2 files changed, 113 insertions(+)
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77705.example.dtb: pmic@66: charger: False schema does not allow {'compatible': ['maxim,max77705-charger'], 'monitored-battery': [[4294967295]], 'phandle': [[2]]}
	from schema $id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77705.example.dtb: pmic@66: fuelgauge: False schema does not allow {'compatible': ['maxim,max77705-fg'], 'monitored-battery': [[4294967295]], 'power-supplies': [[2]], 'rsense': [[5]]}
	from schema $id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77705.example.dtb: pmic@66: haptic: False schema does not allow {'compatible': ['maxim,max77705-haptic'], 'haptic-supply': [[4294967295]], 'pwms': [[4294967295, 0, 50000]]}
	from schema $id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77705.example.dtb: pmic@66: leds: False schema does not allow {'compatible': ['maxim,max77705-led'], '#address-cells': [[1]], '#size-cells': [[0]], 'led@1': {'reg': [[1]], 'label': ['red:usr1']}, 'led@2': {'reg': [[2]], 'label': ['green:usr2']}, 'led@3': {'reg': [[3]], 'label': ['blue:usr3']}}
	from schema $id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml#
Documentation/devicetree/bindings/mfd/maxim,max77705.example.dtb: /example-0/i2c14/pmic@66/leds: failed to match any schema with compatible: ['maxim,max77705-led']
Documentation/devicetree/bindings/mfd/maxim,max77705.example.dtb: /example-0/i2c14/pmic@66/charger: failed to match any schema with compatible: ['maxim,max77705-charger']
Documentation/devicetree/bindings/mfd/maxim,max77705.example.dtb: /example-0/i2c14/pmic@66/fuelgauge: failed to match any schema with compatible: ['maxim,max77705-fg']
Documentation/devicetree/bindings/mfd/maxim,max77705.example.dtb: /example-0/i2c14/pmic@66/haptic: failed to match any schema with compatible: ['maxim,max77705-haptic']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20240618-starqltechn_integration_upstream-v3-4-e3f6662017ac@gmail.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


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

* Re: [PATCH v3 07/23] dt-bindings: power: supply: add maxim,max77705
  2024-06-18 13:59 ` [PATCH v3 07/23] dt-bindings: power: supply: add maxim,max77705 Dzmitry Sankouski
@ 2024-06-18 16:53   ` Rob Herring (Arm)
  2024-06-20 16:14   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 62+ messages in thread
From: Rob Herring (Arm) @ 2024-06-18 16:53 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: linux-input, Maxime Ripard, Liam Girdwood, Mark Brown, devicetree,
	dri-devel, Daniel Vetter, linux-pm, Uwe Kleine-König,
	linux-arm-msm, Pavel Machek, Krzysztof Kozlowski, David Airlie,
	Michael Turquette, Stephen Boyd, Maarten Lankhorst, Conor Dooley,
	Chanwoo Choi, phone-devel, Neil Armstrong, Sam Ravnborg,
	Lee Jones, linux-pwm, linux-kernel, Sebastian Reichel,
	Krzysztof Kozlowski, Thomas Zimmermann, linux-samsung-soc,
	Dmitry Torokhov, linux-leds, Bjorn Andersson, Konrad Dybcio,
	Jessica Zhang, linux-clk


On Tue, 18 Jun 2024 16:59:41 +0300, Dzmitry Sankouski wrote:
> add maxim,max77705 fuel gauge binding part
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  .../bindings/power/supply/maxim,max77705-fg.yaml   | 35 ++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77705.example.dtb: pmic@66: fuelgauge: 'monitored-battery', 'power-supplies' do not match any of the regexes: 'pinctrl-[0-9]+'
	from schema $id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77705.example.dtb: fuelgauge: 'monitored-battery', 'power-supplies' do not match any of the regexes: 'pinctrl-[0-9]+'
	from schema $id: http://devicetree.org/schemas/power/supply/maxim,max77705-fg.yaml#

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20240618-starqltechn_integration_upstream-v3-7-e3f6662017ac@gmail.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


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

* Re: [PATCH v3 09/23] dt-bindings: mfd: add samsung,s2dos05
  2024-06-18 13:59 ` [PATCH v3 09/23] dt-bindings: mfd: add samsung,s2dos05 Dzmitry Sankouski
@ 2024-06-18 16:53   ` Rob Herring (Arm)
  2024-06-20 15:49   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 62+ messages in thread
From: Rob Herring (Arm) @ 2024-06-18 16:53 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Dmitry Torokhov, Neil Armstrong, Pavel Machek, linux-input,
	Jessica Zhang, Mark Brown, Uwe Kleine-König,
	Michael Turquette, Konrad Dybcio, linux-arm-msm, Stephen Boyd,
	Lee Jones, linux-samsung-soc, Liam Girdwood, linux-clk,
	Maxime Ripard, linux-leds, Thomas Zimmermann, Chanwoo Choi,
	Maarten Lankhorst, Sebastian Reichel, Bjorn Andersson,
	phone-devel, Sam Ravnborg, Krzysztof Kozlowski, linux-kernel,
	David Airlie, Krzysztof Kozlowski, linux-pm, devicetree,
	linux-pwm, dri-devel, Conor Dooley, Daniel Vetter


On Tue, 18 Jun 2024 16:59:43 +0300, Dzmitry Sankouski wrote:
> add samsung,s2dos05 core MFD module binding
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  .../devicetree/bindings/mfd/samsung,s2dos05.yaml   | 89 ++++++++++++++++++++++
>  MAINTAINERS                                        |  1 +
>  2 files changed, 90 insertions(+)
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/mfd/samsung,s2dos05.example.dtb: /example-0/i2c/pmic@60: failed to match any schema with compatible: ['samsung,s2dos05']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20240618-starqltechn_integration_upstream-v3-9-e3f6662017ac@gmail.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


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

* Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks
  2024-06-18 13:59 ` [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks Dzmitry Sankouski
@ 2024-06-18 17:50   ` Dmitry Baryshkov
  2024-06-18 18:50     ` Konrad Dybcio
  0 siblings, 1 reply; 62+ messages in thread
From: Dmitry Baryshkov @ 2024-06-18 17:50 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel, linux-pm, linux-kernel,
	linux-arm-msm, linux-clk, dri-devel, devicetree, linux-input,
	linux-leds, linux-pwm, linux-samsung-soc

On Tue, Jun 18, 2024 at 04:59:36PM GMT, Dzmitry Sankouski wrote:
> sdm845 has "General Purpose" clocks that can be muxed to
> SoC pins.
> 
> Those clocks may be used as e.g. PWM sources for external peripherals.
> Add more frequencies to the table for those clocks so it's possible
> for arbitrary peripherals to make use of them.
> 
> See also: bf8bb8eaccf(clk: qcom: gcc-msm8916: Add rates to the GP clocks)

Each time I look at the table attached to the GP CLK, I feel that it's
plain wrong. In the end the GPCLK can in theory have arbitrary value
depending on the usecase.

Bjorn, Konrad, maybe we should add special clk_ops for GP CLK which
allow more flexibility than a default clk_rcg2_ops?

> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  drivers/clk/qcom/gcc-sdm845.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/clk/qcom/gcc-sdm845.c b/drivers/clk/qcom/gcc-sdm845.c
> index ea4c3bf4fb9b..0efd3364e8f5 100644
> --- a/drivers/clk/qcom/gcc-sdm845.c
> +++ b/drivers/clk/qcom/gcc-sdm845.c
> @@ -283,7 +283,21 @@ static struct clk_rcg2 gcc_sdm670_cpuss_rbcpr_clk_src = {
>  	},
>  };
>  
> +/*
> + * This is a frequency table for "General Purpose" clocks.
> + * These clocks can be muxed to the SoC pins and may be used by
> + * external devices. They're often used as PWM source.
> + *
> + * See comment in gcc-mam8916.c at ftbl_gcc_gp1_3_clk.
> + */
>  static const struct freq_tbl ftbl_gcc_gp1_clk_src[] = {
> +	F(10000,   P_BI_TCXO,    16,  1, 120),
> +	F(20000,   P_BI_TCXO,    16,  1, 60),
> +	F(100000,  P_BI_TCXO,    16,  1,  12),
> +	F(500000,  P_GPLL0_OUT_EVEN, 12, 1, 100),
> +	F(1000000, P_GPLL0_OUT_EVEN, 12, 1, 50),
> +	F(2500000, P_GPLL0_OUT_EVEN, 12, 1, 10),
> +	F(5000000, P_GPLL0_OUT_EVEN, 12, 1, 5),
>  	F(19200000, P_BI_TCXO, 1, 0, 0),
>  	F(25000000, P_GPLL0_OUT_EVEN, 12, 0, 0),
>  	F(50000000, P_GPLL0_OUT_EVEN, 6, 0, 0),
> 
> -- 
> 2.39.2
> 

-- 
With best wishes
Dmitry

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

* Re: [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver
  2024-06-18 13:59 ` [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver Dzmitry Sankouski
@ 2024-06-18 18:39   ` Dmitry Baryshkov
  2024-06-19 13:27     ` Dzmitry Sankouski
  0 siblings, 1 reply; 62+ messages in thread
From: Dmitry Baryshkov @ 2024-06-18 18:39 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel, linux-pm, linux-kernel,
	linux-arm-msm, linux-clk, dri-devel, devicetree, linux-input,
	linux-leds, linux-pwm, linux-samsung-soc

On Tue, Jun 18, 2024 at 04:59:45PM GMT, Dzmitry Sankouski wrote:
> Add support for MIPI-DSI based S6E3HA8 AMOLED panel
> driver. This panel has 1440x2960 resolution, 5.8-inch physical
> size, and can be found in starqltechn device.
> Brightness regulation is not yet supported.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  MAINTAINERS                                   |   1 +
>  drivers/gpu/drm/panel/Kconfig                 |   7 +
>  drivers/gpu/drm/panel/Makefile                |   1 +
>  drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c | 426 ++++++++++++++++++++++++++
>  4 files changed, 435 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 92a5d0a56353..fae3b8ea9ce4 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -7154,6 +7154,7 @@ DRM DRIVER FOR SAMSUNG S6E3HA8 PANELS
>  M:	Dzmitry Sankouski <dsankouski@gmail.com>
>  S:	Maintained
>  F:	Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml
> +F:	drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c
>  
>  DRM DRIVER FOR SITRONIX ST7586 PANELS
>  M:	David Lechner <david@lechnology.com>
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index 2ae0eb0638f3..903fc8c155c0 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -651,6 +651,13 @@ config DRM_PANEL_SAMSUNG_S6E3HA2
>  	depends on BACKLIGHT_CLASS_DEVICE
>  	select VIDEOMODE_HELPERS
>  
> +config DRM_PANEL_SAMSUNG_S6E3HA8
> +	tristate "Samsung S6E3HA8 DSI video mode panel"
> +	depends on OF
> +	depends on DRM_MIPI_DSI
> +	depends on BACKLIGHT_CLASS_DEVICE
> +	select VIDEOMODE_HELPERS
> +
>  config DRM_PANEL_SAMSUNG_S6E63J0X03
>  	tristate "Samsung S6E63J0X03 DSI command mode panel"
>  	depends on OF
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index f0203f6e02f4..71774cc5820a 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -66,6 +66,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6D27A1) += panel-samsung-s6d27a1.o
>  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6D7AA0) += panel-samsung-s6d7aa0.o
>  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3FA7) += panel-samsung-s6e3fa7.o
>  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
> +obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA8) += panel-samsung-s6e3ha8.o
>  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03) += panel-samsung-s6e63j0x03.o
>  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += panel-samsung-s6e63m0.o
>  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_SPI) += panel-samsung-s6e63m0-spi.o
> diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c b/drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c
> new file mode 100644
> index 000000000000..49d629643171
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c
> @@ -0,0 +1,426 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Generated with linux-mdss-dsi-panel-driver-generator from vendor device tree:
> + *  Copyright (c) 2013, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/regulator/consumer.h>
> +
> +#include <drm/display/drm_dsc.h>
> +#include <drm/display/drm_dsc_helper.h>
> +#include <drm/drm_mipi_dsi.h>
> +#include <drm/drm_modes.h>
> +#include <drm/drm_panel.h>
> +
> +struct s6e3ha8 {
> +	struct drm_panel panel;
> +	struct mipi_dsi_device *dsi;
> +	struct drm_dsc_config dsc;
> +	struct gpio_desc *reset_gpio;
> +	struct regulator_bulk_data supplies[3];
> +};
> +
> +static inline
> +struct s6e3ha8 *to_s6e3ha8_amb577px01_wqhd(struct drm_panel *panel)
> +{
> +	return container_of(panel, struct s6e3ha8, panel);
> +}
> +
> +#define s6e3ha8_call_write_func(ret, func) do {	\
> +	ret = (func);				\
> +	if (ret < 0)				\
> +		return ret;			\
> +} while (0)

Please rework the driver to use mipi_dsi_*_multi() family of functions.
Using the mipi_dsi_multi_context should make this wrapper obsolete too.

> +
> +static int s6e3ha8_test_key_on_lvl1(struct mipi_dsi_device *dsi)
> +{
> +	static const u8 d[] = { 0x9f, 0xa5, 0xa5 };
> +
> +	return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));
> +	return 0;

Ugh. So which return is it?

> +}
> +

[...]
> +static int s6e3ha8_power_on(struct s6e3ha8 *ctx)
> +{
> +	int ret;
> +
> +	ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);

Inline this function, it's just regulator_bulk_enable() in the end.

> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +
> +static int s6e3ha8_power_off(struct s6e3ha8 *ctx)
> +{
> +	return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
> +}
> +
> +static void s6e3ha8_amb577px01_wqhd_reset(struct s6e3ha8 *ctx)
> +{
> +	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
> +	usleep_range(5000, 6000);
> +	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
> +	usleep_range(5000, 6000);
> +	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
> +	usleep_range(5000, 6000);
> +}
> +
> +static int s6e3ha8_amb577px01_wqhd_on(struct s6e3ha8 *ctx)
> +{
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	struct device *dev = &dsi->dev;
> +	int ret;
> +
> +	dsi->mode_flags |= MIPI_DSI_MODE_LPM;
> +
> +	s6e3ha8_test_key_on_lvl1(dsi);
> +	s6e3ha8_test_key_on_lvl2(dsi);
> +
> +	ret = mipi_dsi_compression_mode(dsi, true);
> +	if (ret < 0) {
> +		dev_err(dev, "Failed to set compression mode: %d\n", ret);
> +		return ret;
> +	}

Interesting, compression mode is being set before the PPS programming?

> +
> +	s6e3ha8_test_key_off_lvl2(dsi);
> +
> +	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
> +	if (ret < 0) {
> +		dev_err(dev, "Failed to exit sleep mode: %d\n", ret);
> +		return ret;
> +	}
> +	usleep_range(5000, 6000);
> +
> +	s6e3ha8_test_key_on_lvl2(dsi);
> +	mipi_dsi_generic_write_seq(dsi, 0xf2, 0x13);
> +	s6e3ha8_test_key_off_lvl2(dsi);
> +
> +	usleep_range(10000, 11000);
> +
> +	s6e3ha8_test_key_on_lvl2(dsi);
> +	mipi_dsi_generic_write_seq(dsi, 0xf2, 0x13);
> +	s6e3ha8_test_key_off_lvl2(dsi);
> +
> +	/* OMOK setting 1 (Initial setting) - Scaler Latch Setting Guide */
> +	s6e3ha8_test_key_on_lvl2(dsi);
> +	mipi_dsi_generic_write_seq(dsi, 0xb0, 0x07);
> +	/* latch setting 1 : Scaler on/off & address setting & PPS setting -> Image update latch */
> +	mipi_dsi_generic_write_seq(dsi, 0xf2, 0x3c, 0x10);
> +	mipi_dsi_generic_write_seq(dsi, 0xb0, 0x0b);
> +	/* latch setting 2 : Ratio change mode -> Image update latch */
> +	mipi_dsi_generic_write_seq(dsi, 0xf2, 0x30);
> +	/* OMOK setting 2 - Seamless setting guide : WQHD */
> +	mipi_dsi_generic_write_seq(dsi, 0x2a, 0x00, 0x00, 0x05, 0x9f); /* CASET */
> +	mipi_dsi_generic_write_seq(dsi, 0x2b, 0x00, 0x00, 0x0b, 0x8f); /* PASET */
> +	mipi_dsi_generic_write_seq(dsi, 0xba, 0x01); /* scaler setup : scaler off */
> +	s6e3ha8_test_key_off_lvl2(dsi);
> +	mipi_dsi_generic_write_seq(dsi, 0x35, 0x00); /* TE Vsync ON */
> +	s6e3ha8_test_key_on_lvl2(dsi);
> +	mipi_dsi_generic_write_seq(dsi, 0xed, 0x4c); /* ERR_FG */
> +	s6e3ha8_test_key_off_lvl2(dsi);
> +	s6e3ha8_test_key_on_lvl3(dsi);
> +	/* FFC Setting 897.6Mbps */
> +	mipi_dsi_generic_write_seq(dsi, 0xc5, 0x0d, 0x10, 0xb4, 0x3e, 0x01);
> +	s6e3ha8_test_key_off_lvl3(dsi);
> +	s6e3ha8_test_key_on_lvl2(dsi);
> +	mipi_dsi_generic_write_seq(dsi, 0xb9,
> +				   0x00, 0xb0, 0x81, 0x09, 0x00, 0x00, 0x00,
> +				   0x11, 0x03); /* TSP HSYNC Setting */
> +	s6e3ha8_test_key_off_lvl2(dsi);
> +	s6e3ha8_test_key_on_lvl2(dsi);
> +	mipi_dsi_generic_write_seq(dsi, 0xb0, 0x03);
> +	mipi_dsi_generic_write_seq(dsi, 0xf6, 0x43);
> +	s6e3ha8_test_key_off_lvl2(dsi);
> +	s6e3ha8_test_key_on_lvl2(dsi);
> +	/* Brightness condition set */
> +	mipi_dsi_generic_write_seq(dsi, 0xca,
> +				   0x07, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
> +				   0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> +				   0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> +				   0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> +				   0x80, 0x80, 0x80, 0x00, 0x00, 0x00);
> +	mipi_dsi_generic_write_seq(dsi, 0xb1, 0x00, 0x0c); /* AID Set : 0% */
> +	mipi_dsi_generic_write_seq(dsi, 0xb5,
> +				   0x19, 0xdc, 0x16, 0x01, 0x34, 0x67, 0x9a,
> +				   0xcd, 0x01, 0x22, 0x33, 0x44, 0x00, 0x00,
> +				   0x05, 0x55, 0xcc, 0x0c, 0x01, 0x11, 0x11,
> +				   0x10); /* MPS/ELVSS Setting */
> +	mipi_dsi_generic_write_seq(dsi, 0xf4, 0xeb, 0x28); /* VINT */
> +	mipi_dsi_generic_write_seq(dsi, 0xf7, 0x03); /* Gamma, LTPS(AID) update */
> +	s6e3ha8_test_key_off_lvl2(dsi);
> +	s6e3ha8_test_key_off_lvl1(dsi);
> +
> +	return 0;
> +}
> +
> +static int s6e3ha8_enable(struct drm_panel *panel)
> +{
> +	struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel);
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	int ret;
> +
> +	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_on_lvl1(dsi));
> +	s6e3ha8_call_write_func(ret, mipi_dsi_dcs_set_display_on(dsi));
> +	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_off_lvl1(dsi));
> +
> +	return 0;
> +}
> +
> +static int s6e3ha8_disable(struct drm_panel *panel)
> +{
> +	struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel);
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	int ret;
> +
> +	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_on_lvl1(dsi));
> +	s6e3ha8_call_write_func(ret, mipi_dsi_dcs_set_display_off(dsi));
> +	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_off_lvl1(dsi));
> +	msleep(20);
> +
> +	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_on_lvl2(dsi));
> +	s6e3ha8_call_write_func(ret, s6e3ha8_afc_off(dsi));
> +	s6e3ha8_call_write_func(ret, s6e3ha8_test_key_off_lvl2(dsi));
> +
> +	msleep(160);
> +
> +	return 0;
> +}
> +
> +static int s6e3ha8_amb577px01_wqhd_prepare(struct drm_panel *panel)
> +{
> +	struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel);
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	struct device *dev = &dsi->dev;
> +	struct drm_dsc_picture_parameter_set pps;
> +	int ret;
> +
> +	s6e3ha8_power_on(ctx);
> +	msleep(120);
> +	s6e3ha8_amb577px01_wqhd_reset(ctx);
> +	ret = s6e3ha8_amb577px01_wqhd_on(ctx);
> +
> +	if (ret < 0) {
> +		dev_err(dev, "Failed to initialize panel: %d\n", ret);
> +		gpiod_set_value_cansleep(ctx->reset_gpio, 1);
> +		goto err;
> +	}
> +
> +	drm_dsc_pps_payload_pack(&pps, &ctx->dsc);
> +
> +	s6e3ha8_test_key_on_lvl1(dsi);
> +	ret = mipi_dsi_picture_parameter_set(ctx->dsi, &pps);
> +	if (ret < 0) {
> +		dev_err(panel->dev, "failed to transmit PPS: %d\n", ret);
> +		return ret;
> +	}
> +	s6e3ha8_test_key_off_lvl1(dsi);
> +
> +	ret = mipi_dsi_compression_mode(ctx->dsi, true);
> +	if (ret < 0) {
> +		dev_err(dev, "failed to enable compression mode: %d\n", ret);
> +		return ret;
> +	}

Again?

> +
> +
> +	msleep(28);
> +
> +	return 0;
> +err:
> +	s6e3ha8_power_off(ctx);
> +	return ret;
> +}
> +
> +static int s6e3ha8_amb577px01_wqhd_unprepare(struct drm_panel *panel)
> +{
> +	struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel);
> +
> +	return s6e3ha8_power_off(ctx);
> +}
> +
> +static const struct drm_display_mode s6e3ha8_amb577px01_wqhd_mode = {
> +	.clock = (1440 + 116 + 44 + 120) * (2960 + 120 + 80 + 124) * 60 / 1000,
> +	.hdisplay = 1440,
> +	.hsync_start = 1440 + 116,
> +	.hsync_end = 1440 + 116 + 44,
> +	.htotal = 1440 + 116 + 44 + 120,
> +	.vdisplay = 2960,
> +	.vsync_start = 2960 + 120,
> +	.vsync_end = 2960 + 120 + 80,
> +	.vtotal = 2960 + 120 + 80 + 124,
> +	.width_mm = 64,
> +	.height_mm = 132,
> +};
> +
> +static int s6e3ha8_amb577px01_wqhd_get_modes(struct drm_panel *panel,
> +					     struct drm_connector *connector)
> +{
> +	struct drm_display_mode *mode;
> +
> +	mode = drm_mode_duplicate(connector->dev, &s6e3ha8_amb577px01_wqhd_mode);
> +	if (!mode)
> +		return -ENOMEM;
> +
> +	drm_mode_set_name(mode);
> +
> +	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
> +	connector->display_info.width_mm = mode->width_mm;
> +	connector->display_info.height_mm = mode->height_mm;
> +	drm_mode_probed_add(connector, mode);

drm_connector_helper_get_modes_fixed()

> +
> +	return 1;
> +}
> +

-- 
With best wishes
Dmitry

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

* Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks
  2024-06-18 17:50   ` Dmitry Baryshkov
@ 2024-06-18 18:50     ` Konrad Dybcio
  2024-06-18 18:55       ` Dmitry Baryshkov
  0 siblings, 1 reply; 62+ messages in thread
From: Konrad Dybcio @ 2024-06-18 18:50 UTC (permalink / raw)
  To: Dmitry Baryshkov, Dzmitry Sankouski
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Chanwoo Choi, phone-devel, linux-pm, linux-kernel, linux-arm-msm,
	linux-clk, dri-devel, devicetree, linux-input, linux-leds,
	linux-pwm, linux-samsung-soc



On 6/18/24 19:50, Dmitry Baryshkov wrote:
> On Tue, Jun 18, 2024 at 04:59:36PM GMT, Dzmitry Sankouski wrote:
>> sdm845 has "General Purpose" clocks that can be muxed to
>> SoC pins.
>>
>> Those clocks may be used as e.g. PWM sources for external peripherals.
>> Add more frequencies to the table for those clocks so it's possible
>> for arbitrary peripherals to make use of them.
>>
>> See also: bf8bb8eaccf(clk: qcom: gcc-msm8916: Add rates to the GP clocks)
> 
> Each time I look at the table attached to the GP CLK, I feel that it's
> plain wrong. In the end the GPCLK can in theory have arbitrary value
> depending on the usecase.
> 
> Bjorn, Konrad, maybe we should add special clk_ops for GP CLK which
> allow more flexibility than a default clk_rcg2_ops?

If we can somehow get max m/n/d values for all possible parents, sure

Konrad

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

* Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks
  2024-06-18 18:50     ` Konrad Dybcio
@ 2024-06-18 18:55       ` Dmitry Baryshkov
  2024-06-18 19:11         ` Konrad Dybcio
  0 siblings, 1 reply; 62+ messages in thread
From: Dmitry Baryshkov @ 2024-06-18 18:55 UTC (permalink / raw)
  To: Konrad Dybcio
  Cc: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König,
	Krzysztof Kozlowski, Chanwoo Choi, phone-devel, linux-pm,
	linux-kernel, linux-arm-msm, linux-clk, dri-devel, devicetree,
	linux-input, linux-leds, linux-pwm, linux-samsung-soc

On Tue, Jun 18, 2024 at 08:50:52PM GMT, Konrad Dybcio wrote:
> 
> 
> On 6/18/24 19:50, Dmitry Baryshkov wrote:
> > On Tue, Jun 18, 2024 at 04:59:36PM GMT, Dzmitry Sankouski wrote:
> > > sdm845 has "General Purpose" clocks that can be muxed to
> > > SoC pins.
> > > 
> > > Those clocks may be used as e.g. PWM sources for external peripherals.
> > > Add more frequencies to the table for those clocks so it's possible
> > > for arbitrary peripherals to make use of them.
> > > 
> > > See also: bf8bb8eaccf(clk: qcom: gcc-msm8916: Add rates to the GP clocks)
> > 
> > Each time I look at the table attached to the GP CLK, I feel that it's
> > plain wrong. In the end the GPCLK can in theory have arbitrary value
> > depending on the usecase.
> > 
> > Bjorn, Konrad, maybe we should add special clk_ops for GP CLK which
> > allow more flexibility than a default clk_rcg2_ops?
> 
> If we can somehow get max m/n/d values for all possible parents, sure

Calculate them at runtime?


-- 
With best wishes
Dmitry

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

* Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks
  2024-06-18 18:55       ` Dmitry Baryshkov
@ 2024-06-18 19:11         ` Konrad Dybcio
  2024-06-19  6:31           ` Dmitry Baryshkov
  2024-07-19  9:01           ` Dzmitry Sankouski
  0 siblings, 2 replies; 62+ messages in thread
From: Konrad Dybcio @ 2024-06-18 19:11 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König,
	Krzysztof Kozlowski, Chanwoo Choi, phone-devel, linux-pm,
	linux-kernel, linux-arm-msm, linux-clk, dri-devel, devicetree,
	linux-input, linux-leds, linux-pwm, linux-samsung-soc



On 6/18/24 20:55, Dmitry Baryshkov wrote:
> On Tue, Jun 18, 2024 at 08:50:52PM GMT, Konrad Dybcio wrote:
>>
>>
>> On 6/18/24 19:50, Dmitry Baryshkov wrote:
>>> On Tue, Jun 18, 2024 at 04:59:36PM GMT, Dzmitry Sankouski wrote:
>>>> sdm845 has "General Purpose" clocks that can be muxed to
>>>> SoC pins.
>>>>
>>>> Those clocks may be used as e.g. PWM sources for external peripherals.
>>>> Add more frequencies to the table for those clocks so it's possible
>>>> for arbitrary peripherals to make use of them.
>>>>
>>>> See also: bf8bb8eaccf(clk: qcom: gcc-msm8916: Add rates to the GP clocks)
>>>
>>> Each time I look at the table attached to the GP CLK, I feel that it's
>>> plain wrong. In the end the GPCLK can in theory have arbitrary value
>>> depending on the usecase.
>>>
>>> Bjorn, Konrad, maybe we should add special clk_ops for GP CLK which
>>> allow more flexibility than a default clk_rcg2_ops?
>>
>> If we can somehow get max m/n/d values for all possible parents, sure
> 
> Calculate them at runtime?

We'd be calculating the mnd values for a frequency that's either equal or
reasonably close to the one requested. My worry is that we somehow need
to get the maximum values they can take (unless they're well-known)

Konrad

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

* Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks
  2024-06-18 19:11         ` Konrad Dybcio
@ 2024-06-19  6:31           ` Dmitry Baryshkov
  2024-07-19  9:01           ` Dzmitry Sankouski
  1 sibling, 0 replies; 62+ messages in thread
From: Dmitry Baryshkov @ 2024-06-19  6:31 UTC (permalink / raw)
  To: Konrad Dybcio
  Cc: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König,
	Krzysztof Kozlowski, Chanwoo Choi, phone-devel, linux-pm,
	linux-kernel, linux-arm-msm, linux-clk, dri-devel, devicetree,
	linux-input, linux-leds, linux-pwm, linux-samsung-soc

On Tue, Jun 18, 2024 at 09:11:58PM GMT, Konrad Dybcio wrote:
> 
> 
> On 6/18/24 20:55, Dmitry Baryshkov wrote:
> > On Tue, Jun 18, 2024 at 08:50:52PM GMT, Konrad Dybcio wrote:
> > > 
> > > 
> > > On 6/18/24 19:50, Dmitry Baryshkov wrote:
> > > > On Tue, Jun 18, 2024 at 04:59:36PM GMT, Dzmitry Sankouski wrote:
> > > > > sdm845 has "General Purpose" clocks that can be muxed to
> > > > > SoC pins.
> > > > > 
> > > > > Those clocks may be used as e.g. PWM sources for external peripherals.
> > > > > Add more frequencies to the table for those clocks so it's possible
> > > > > for arbitrary peripherals to make use of them.
> > > > > 
> > > > > See also: bf8bb8eaccf(clk: qcom: gcc-msm8916: Add rates to the GP clocks)
> > > > 
> > > > Each time I look at the table attached to the GP CLK, I feel that it's
> > > > plain wrong. In the end the GPCLK can in theory have arbitrary value
> > > > depending on the usecase.
> > > > 
> > > > Bjorn, Konrad, maybe we should add special clk_ops for GP CLK which
> > > > allow more flexibility than a default clk_rcg2_ops?
> > > 
> > > If we can somehow get max m/n/d values for all possible parents, sure
> > 
> > Calculate them at runtime?
> 
> We'd be calculating the mnd values for a frequency that's either equal or
> reasonably close to the one requested. My worry is that we somehow need
> to get the maximum values they can take (unless they're well-known)

One of the options might be to force devices to use
assigned-clock-parent to set GP CLK sorource and pwm-clk as an actual
device using the clock.

-- 
With best wishes
Dmitry

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

* Re: [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver
  2024-06-18 18:39   ` Dmitry Baryshkov
@ 2024-06-19 13:27     ` Dzmitry Sankouski
  2024-06-20 20:13       ` Dmitry Baryshkov
  0 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-19 13:27 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel, linux-pm, linux-kernel,
	linux-arm-msm, linux-clk, dri-devel, devicetree, linux-input,
	linux-leds, linux-pwm, linux-samsung-soc

вт, 18 июн. 2024 г. в 21:39, Dmitry Baryshkov <dmitry.baryshkov@linaro.org>:
>
> > +     ret = mipi_dsi_compression_mode(dsi, true);
> > +     if (ret < 0) {
> > +             dev_err(dev, "Failed to set compression mode: %d\n", ret);
> > +             return ret;
> > +     }
>
> Interesting, compression mode is being set before the PPS programming?
>
Yes, as per vendor kernel:
https://github.com/klabit87/twrp_android_samsung_kernel_sdm845/blob/e8bb63039008e1704a2f1bde68d39ded9c16ea88/drivers/gpu/drm/msm/samsung/S6E3HA8_AMB577PX01/dsi_panel_S6E3HA8_AMB577PX01_wqhd_octa_cmd.dtsi#L5508

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

* Re: [PATCH v3 18/23] regulator: add s2dos05 regulator support
  2024-06-18 14:08   ` Mark Brown
@ 2024-06-19 15:49     ` Dzmitry Sankouski
  2024-06-19 15:52       ` Mark Brown
  0 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-06-19 15:49 UTC (permalink / raw)
  To: Mark Brown
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Uwe Kleine-König, Krzysztof Kozlowski, Konrad Dybcio,
	Chanwoo Choi, phone-devel, linux-pm, linux-kernel, linux-arm-msm,
	linux-clk, dri-devel, devicetree, linux-input, linux-leds,
	linux-pwm, linux-samsung-soc

вт, 18 июн. 2024 г. в 17:08, Mark Brown <broonie@kernel.org>:
>
> On Tue, Jun 18, 2024 at 04:59:52PM +0300, Dzmitry Sankouski wrote:
>
> > index 000000000000..3c58a1bd2262
> > --- /dev/null
> > +++ b/drivers/regulator/s2dos05-regulator.c
> > @@ -0,0 +1,362 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * s2dos05.c - Regulator driver for the Samsung s2dos05
> > + *
>
> Please make the entire comment a C++ one so things look more
> intentional.
>
Do you mean enclosing the first line (license identifier) in /* */
style comment?

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

* Re: [PATCH v3 18/23] regulator: add s2dos05 regulator support
  2024-06-19 15:49     ` Dzmitry Sankouski
@ 2024-06-19 15:52       ` Mark Brown
  0 siblings, 0 replies; 62+ messages in thread
From: Mark Brown @ 2024-06-19 15:52 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Uwe Kleine-König, Krzysztof Kozlowski, Konrad Dybcio,
	Chanwoo Choi, phone-devel, linux-pm, linux-kernel, linux-arm-msm,
	linux-clk, dri-devel, devicetree, linux-input, linux-leds,
	linux-pwm, linux-samsung-soc

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

On Wed, Jun 19, 2024 at 06:49:06PM +0300, Dzmitry Sankouski wrote:
> вт, 18 июн. 2024 г. в 17:08, Mark Brown <broonie@kernel.org>:
> > On Tue, Jun 18, 2024 at 04:59:52PM +0300, Dzmitry Sankouski wrote:

> > > +// SPDX-License-Identifier: GPL-2.0+
> > > +/*
> > > + * s2dos05.c - Regulator driver for the Samsung s2dos05
> > > + *

> > Please make the entire comment a C++ one so things look more
> > intentional.

> Do you mean enclosing the first line (license identifier) in /* */
> style comment?

No, that would be a C comment.  Please use C++ style for the rest of the
header as well as the first line.

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

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

* Re: [PATCH v3 03/23] dt-bindings: panel: add Samsung s6e3ha8
  2024-06-18 13:59 ` [PATCH v3 03/23] dt-bindings: panel: add Samsung s6e3ha8 Dzmitry Sankouski
@ 2024-06-20 15:44   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 15:44 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> Add binding for the Samsung s6e3ha8 panel found in the Samsung S9.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  .../bindings/display/panel/samsung,s6e3ha8.yaml    | 76 ++++++++++++++++++++++
>  MAINTAINERS                                        |  5 ++
>  2 files changed, 81 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml b/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml
> new file mode 100644
> index 000000000000..9d7d747264dd
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml
> @@ -0,0 +1,76 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/display/panel/samsung,s6e3ha8.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Samsung s6e3ha8 AMOLED DSI panel
> +
> +description: The s6e3ha8 is a 1440x2960 DPI display panel from Samsung Mobile
> +  Displays (SMD).
> +
> +maintainers:
> +  - Dzmitry Sankouski <dsankouski@gmail.com>
> +
> +allOf:
> +  - $ref: panel-common.yaml#
> +
> +properties:
> +  compatible:
> +    const: samsung,s6e3ha8
> +
> +  reg:
> +    maxItems: 1
> +
> +  reset-gpios:
> +    description: reset gpio

Pointless description. I think this can be reset-gpios: true, because
gpio-consumer-common provides constrain.

> +
> +  port: true
> +
> +  vdd3-supply:
> +    description: VDD regulator
> +
> +  vci-supply:
> +    description: VCI regulator
> +
> +  vddr-supply:
> +    description: VDDR regulator
> +
> +required:
> +  - compatible
> +  - reset-gpios
> +  - vdd3-supply
> +  - vddr-supply
> +  - vci-supply
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +
> +    dsi {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      panel@0 {
> +      	compatible = "samsung,s6e3ha8";
> +      	reg = <0>;

Messed indentation. Keep consistent one.



Best regards,
Krzysztof


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

* Re: [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705
  2024-06-18 13:59 ` [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705 Dzmitry Sankouski
  2024-06-18 16:53   ` Rob Herring (Arm)
@ 2024-06-20 15:45   ` Krzysztof Kozlowski
  2024-09-13 14:51     ` Dzmitry Sankouski
  1 sibling, 1 reply; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 15:45 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> maxim,max77705 is MAX77705 pmic binding part
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  .../devicetree/bindings/mfd/maxim,max77705.yaml    | 112 +++++++++++++++++++++

Your patch order is totally messed. Not tested by automation. Only
limited review follows.


>  MAINTAINERS                                        |   1 +
>  2 files changed, 113 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml
> new file mode 100644
> index 000000000000..b54408e3d792
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml
> @@ -0,0 +1,112 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim MAX77705 Companion Power Management IC and USB Type-C interface IC
> +
> +maintainers:
> +  - Dzmitry Sankouski <dsankouski@gmail.com>
> +
> +description: |
> +  This is a part of device tree bindings for Maxim MAX77705 multi functional device.
> +
> +  The Maxim MAX77705 is a Companion Power Management and Type-C interface IC which
> +  includes charger, fuelgauge, LED, haptic motor driver and Type-C management IC.
> +
> +properties:
> +  compatible:
> +    const: maxim,max77705
> +
> +  reg:
> +    description:
> +      I2C device address.

Drop description, obvious.

> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  interrupt-names:
> +    description:
> +      MAX77705 shared irq.
> +    items:
> +      - const: max77705_irq

Drop entire property, not really useful.

> +
> +  charger:
> +    $ref: /schemas/power/supply/maxim,max77705-charger.yaml
> +
> +  fuelgauge:
> +    $ref: /schemas/power/supply/maxim,max77705-fg.yaml
> +
> +  haptic:
> +    $ref: /schemas/input/maxim,max77705.yaml
> +
> +  leds:
> +    $ref: /schemas/leds/maxim,max77705.yaml
> +
> +
> +required:
> +  - compatible
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +    #include <dt-bindings/leds/common.h>
> +
> +    i2c14 {

i2c

> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +    	pmic@66 {
> +    		compatible = "maxim,max77705";
> +    		reg = <0x66>;

Totally messed indentation. Fix your code.



Best regards,
Krzysztof


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

* Re: [PATCH v3 05/23] dt-bindings: input: add maxim,max77705-haptic
  2024-06-18 13:59 ` [PATCH v3 05/23] dt-bindings: input: add maxim,max77705-haptic Dzmitry Sankouski
@ 2024-06-20 15:47   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 15:47 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> maxim,max77705-haptic is MAX77705 pmic binding part
> 


> +
> +maintainers:
> +  - Dzmitry Sankouski <dsankouski@gmail.com>
> +
> +description: |
> +  This is a part of device tree bindings for Maxim MAX77705 multi functional device.

Wrap according to Linux coding style, so at 80. All your bindings have
the same issue.

> +
> +  See also Documentation/devicetree/bindings/mfd/maxim,max77705.yaml for
> +  additional information and example.
> +
> +properties:
> +  compatible:
> +    const: maxim,max77705-haptic
> +
> +  haptic-supply: true
> +
> +  pwms: true

maxItems


Best regards,
Krzysztof


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

* Re: [PATCH v3 06/23] dt-bindings: power: supply: add maxim,max77705 charger
  2024-06-18 13:59 ` [PATCH v3 06/23] dt-bindings: power: supply: add maxim,max77705 charger Dzmitry Sankouski
@ 2024-06-20 15:47   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 15:47 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> add maxim,max77705 charger binding part

Make it a proper sentence.

> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  .../power/supply/maxim,max77705-charger.yaml       | 30 ++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml
> new file mode 100644
> index 000000000000..2b805da2a328
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml
> @@ -0,0 +1,30 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/power/supply/maxim,max77705-charger.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim MAX77705 and Companion Power Management IC charger
> +
> +maintainers:
> +  - Dzmitry Sankouski <dsankouski@gmail.com>
> +
> +description: |
> +  This is a part of device tree bindings for Maxim MAX77705 multi functional device.
> +
> +  See also Documentation/devicetree/bindings/mfd/maxim,max77705.yaml for
> +  additional information and example.
> +
> +allOf:
> +  - $ref: power-supply.yaml#
> +
> +properties:
> +  compatible:
> +    const: maxim,max77705-charger

Looks pointless. Merge it to parent node.



Best regards,
Krzysztof


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

* Re: [PATCH v3 09/23] dt-bindings: mfd: add samsung,s2dos05
  2024-06-18 13:59 ` [PATCH v3 09/23] dt-bindings: mfd: add samsung,s2dos05 Dzmitry Sankouski
  2024-06-18 16:53   ` Rob Herring (Arm)
@ 2024-06-20 15:49   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 15:49 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> add samsung,s2dos05 core MFD module binding
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  .../devicetree/bindings/mfd/samsung,s2dos05.yaml   | 89 ++++++++++++++++++++++
>  MAINTAINERS                                        |  1 +
>  2 files changed, 90 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml b/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml
> new file mode 100644
> index 000000000000..f2ef5171cc40
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml
> @@ -0,0 +1,89 @@
> +# 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 part of device tree bindings for S2M and S5M family of Power
> +  Management IC (PMIC).

No, it is not.

> +
> +  The S2DOS05 is a companion power management IC for the panel and touchscreen
> +  in smart phones. Provides voltage and current regulators and adc for power/current
> +  measurements.
> +
> +properties:
> +  compatible:
> +    const: samsung,s2dos05-pmic

s2dos05 cannot be anything else than pmic. Drop the suffix.

> +
> +  reg:
> +    maxItems: 1
> +
> +  regulators:
> +    $ref: /schemas/regulator/samsung,s2dos05.yaml
> +    description: List of regulators and its properties
> +
> +required:
> +  - compatible
> +  - reg
> +  - regulators
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    i2c {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      pmic@60 {
> +      	compatible = "samsung,s2dos05";
> +      	reg = <0x60>;
> +
> +      	regulators {

Messed indentation. Everywhere, each of your patch.

> +      		s2dos05_ldo1: s2dos05-ldo1 {

Just "ldo1" and drop unused labels.


Best regards,
Krzysztof


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

* Re: [PATCH v3 10/23] dt-bindings: regulator: add samsung,s2dos05
  2024-06-18 13:59 ` [PATCH v3 10/23] dt-bindings: regulator: " Dzmitry Sankouski
@ 2024-06-20 15:51   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 15:51 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> add samsung,s2dos05 regulator binding part

Make it a proper sentence.

> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  .../bindings/regulator/samsung,s2dos05.yaml        | 36 ++++++++++++++++++++++
>  MAINTAINERS                                        |  1 +
>  2 files changed, 37 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml b/Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml
> new file mode 100644
> index 000000000000..4b8e4389329c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml
> @@ -0,0 +1,36 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/samsung,s2dos05.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Samsung S2DOS05 Power Management IC Regulators
> +
> +maintainers:
> +  - Dzmitry Sankouski <dsankouski@gmail.com>
> +
> +description:
> +  This is a part of device tree bindings for S2M and S5M family of Power
> +  Management IC (PMIC).

No, it's not.

> +
> +  Has 4 LDO and 1 BUCK regulators, provides ELVDD, ELVSS, AVDD lines.
> +
> +  See also Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml for
> +  additional information and example.
> +
> +properties:
> +  compatible:
> +    const: samsung,s2dos05-regulator

Drop the compatible and then squash it in the MFD binding.


> +
> +patternProperties:
> +  "^buck1|ldo[1-4]$":

You did not test the patches.

I will not continue with the review, because testing is a requirement.
Otherwise it is just a waste of my time.


Best regards,
Krzysztof


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

* Re: [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC
  2024-06-18 13:59 ` [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC Dzmitry Sankouski
@ 2024-06-20 16:02   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 16:02 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc,
	Rose Hudson

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> Add the core MFD driver for max77705 PMIC. We define five sub-devices
> for which the drivers will be added in subsequent patches.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> Co-authored-by: Rose Hudson <rose@krx.sh>
> ---
>  MAINTAINERS                          |   2 +
>  drivers/mfd/Kconfig                  |  12 ++
>  drivers/mfd/Makefile                 |   3 +
>  drivers/mfd/max77705-core.c          | 278 ++++++++++++++++++++++++++++++++
>  drivers/mfd/max77705-irq.c           | 299 +++++++++++++++++++++++++++++++++++
>  include/linux/mfd/max77705-private.h | 281 ++++++++++++++++++++++++++++++++
>  include/linux/mfd/max77705.h         |  20 +++
>  7 files changed, 895 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index fae3b8ea9ce4..f66f08825db9 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13690,6 +13690,7 @@ F:	drivers/*/*max77843.c
>  F:	drivers/*/max14577*.c
>  F:	drivers/*/max77686*.c
>  F:	drivers/*/max77693*.c
> +F:	drivers/*/max77705*.c
>  F:	drivers/clk/clk-max77686.c
>  F:	drivers/extcon/extcon-max14577.c
>  F:	drivers/extcon/extcon-max77693.c
> @@ -13697,6 +13698,7 @@ F:	drivers/rtc/rtc-max77686.c
>  F:	include/linux/mfd/max14577*.h
>  F:	include/linux/mfd/max77686*.h
>  F:	include/linux/mfd/max77693*.h
> +F:	include/linux/mfd/max77705*.h
>  
>  MAXIRADIO FM RADIO RECEIVER DRIVER
>  M:	Hans Verkuil <hverkuil@xs4all.nl>
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 266b4f54af60..c4eb8ff2dcad 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -880,6 +880,18 @@ config MFD_MAX77693
>  	  additional drivers must be enabled in order to use the functionality
>  	  of the device.
>  
> +config MFD_MAX77705
> +	tristate "Maxim Semiconductor MAX77705 PMIC Support"
> +	depends on I2C
> +	select MFD_CORE
> +	help
> +	  Say yes here to add support for Maxim Semiconductor MAX77705.
> +	  This is a Power Management IC with Charger, safe LDOs, Flash, Haptic
> +	  and MUIC controls on chip.
> +	  This driver provides common support for accessing the device;
> +	  additional drivers must be enabled in order to use the functionality
> +	  of the device.
> +
>  config MFD_MAX77714
>  	tristate "Maxim Semiconductor MAX77714 PMIC Support"
>  	depends on I2C
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index db1ba39de3b5..bf65cc36d59c 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -162,6 +162,8 @@ obj-$(CONFIG_MFD_MAX77620)	+= max77620.o
>  obj-$(CONFIG_MFD_MAX77650)	+= max77650.o
>  obj-$(CONFIG_MFD_MAX77686)	+= max77686.o
>  obj-$(CONFIG_MFD_MAX77693)	+= max77693.o
> +max77705-objs := max77705-core.o max77705-irq.o
> +obj-$(CONFIG_MFD_MAX77705)	+= max77705.o
>  obj-$(CONFIG_MFD_MAX77714)	+= max77714.o
>  obj-$(CONFIG_MFD_MAX77843)	+= max77843.o
>  obj-$(CONFIG_MFD_MAX8907)	+= max8907.o
> @@ -226,6 +228,7 @@ obj-$(CONFIG_MFD_RK8XX_I2C)	+= rk8xx-i2c.o
>  obj-$(CONFIG_MFD_RK8XX_SPI)	+= rk8xx-spi.o
>  obj-$(CONFIG_MFD_RN5T618)	+= rn5t618.o
>  obj-$(CONFIG_MFD_SEC_CORE)	+= sec-core.o sec-irq.o
> +obj-$(CONFIG_MFD_S2DOS05)	+= s2dos05.o

??? That's not related.

>  obj-$(CONFIG_MFD_SYSCON)	+= syscon.o
>  obj-$(CONFIG_MFD_LM3533)	+= lm3533-core.o lm3533-ctrlbank.o
>  obj-$(CONFIG_MFD_VEXPRESS_SYSREG)	+= vexpress-sysreg.o
> diff --git a/drivers/mfd/max77705-core.c b/drivers/mfd/max77705-core.c
> new file mode 100644
> index 000000000000..7cb71a0a9688
> --- /dev/null
> +++ b/drivers/mfd/max77705-core.c
> @@ -0,0 +1,278 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * max77705.c - mfd core driver for the Maxim 77705
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
> + */
> +
> +#include <linux/module.h>
> +#include <linux/slab.h>
> +#include <linux/i2c.h>
> +#include <linux/irq.h>
> +#include <linux/interrupt.h>
> +#include <linux/mutex.h>
> +#include <linux/mfd/core.h>
> +#include <linux/mfd/max77705.h>
> +#include <linux/mfd/max77705-private.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/debugfs.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
> +
> +#define I2C_ADDR_PMIC	(0xCC >> 1)	/* Top sys, Haptic */
> +#define I2C_ADDR_MUIC	(0x4A >> 1)
> +#define I2C_ADDR_CHG    (0xD2 >> 1)
> +#define I2C_ADDR_FG     (0x6C >> 1)
> +#define I2C_ADDR_DEBUG  (0xC4 >> 1)
> +
> +static struct dentry *debugfs_file;
> +
> +static int max77705_debugfs_show(struct seq_file *s, void *data)
> +{
> +	struct max77705_dev *max77705 = s->private;
> +	struct regmap *regmap = max77705->regmap;
> +	unsigned int i, reg, reg_data, pmic_id, pmic_rev;
> +	int regs[] = {
> +		MAX77705_PMIC_REG_MAINCTRL1,
> +		MAX77705_PMIC_REG_MCONFIG,
> +		MAX77705_PMIC_REG_MCONFIG2,
> +		MAX77705_PMIC_REG_INTSRC,
> +		MAX77705_PMIC_REG_INTSRC_MASK,
> +		MAX77705_PMIC_REG_SYSTEM_INT,
> +		MAX77705_PMIC_REG_SYSTEM_INT_MASK,
> +		MAX77705_RGBLED_REG_LEDEN,
> +		MAX77705_RGBLED_REG_LED0BRT,
> +		MAX77705_RGBLED_REG_LED1BRT,
> +		MAX77705_RGBLED_REG_LED2BRT,
> +		MAX77705_RGBLED_REG_LED3BRT,
> +		MAX77705_RGBLED_REG_LEDBLNK
> +	};
> +
> +	regmap_read(regmap, MAX77705_PMIC_REG_PMICID1, &pmic_id);
> +	regmap_read(regmap, MAX77705_PMIC_REG_PMICREV, &pmic_rev);
> +	seq_printf(s, "MAX77705, pmic id: %d, pmic rev: %d\n",
> +		   pmic_id, pmic_rev);
> +	seq_puts(s, "===================\n");
> +	for (i = 0; i < ARRAY_SIZE(regs); i++) {
> +		reg = regs[i];
> +		regmap_read(regmap, reg, &reg_data);
> +		seq_printf(s, "0x%02x:\t0x%02x\n", reg, reg_data);
> +	}
> +
> +	seq_puts(s, "\n");
> +	return 0;

Why do you need this code? Regmap has its own debugging code.

> +}
> +
> +DEFINE_SHOW_ATTRIBUTE(max77705_debugfs);
> +
> +static const struct regmap_config max77705_regmap_config = {
> +	.reg_bits = 8,
> +	.val_bits = 8,
> +	.max_register = MAX77705_PMIC_REG_END,
> +};
> +
> +static const struct regmap_config max77705_leds_regmap_config = {
> +	.reg_bits = 8,
> +	.val_bits = 8,
> +	.max_register = MAX77705_LED_REG_END,
> +};
> +
> +static const struct regmap_config max77705_fg_regmap_config = {
> +	.reg_bits = 8,
> +	.val_bits = 8,
> +	.max_register = MAX77705_FG_END,
> +};
> +
> +static struct mfd_cell max77705_devs[] = {
> +	{
> +		.name = "leds-max77705-rgb",
> +		.of_compatible = "maxim,max77705-led",
> +	},
> +	{
> +		.name = "max77705-fuelgauge",
> +		.of_compatible = "maxim,max77705-fg",
> +	},
> +	{
> +		.name = "max77705-charger",
> +		.of_compatible = "maxim,max77705-charger",
> +	},
> +	{
> +		.name = "max77705-haptic",
> +		.of_compatible = "maxim,max77705-haptic",
> +	},
> +};
> +
> +static int max77705_i2c_probe(struct i2c_client *i2c)
> +{
> +	struct max77705_dev *max77705;
> +	struct max77705_platform_data *pdata = i2c->dev.platform_data;

This is not used. You need to clean the driver from such obsoletes from
2010.

> +
> +	unsigned int reg_data;
> +	int ret = 0;
> +
> +	max77705 = kzalloc(sizeof(struct max77705_dev), GFP_KERNEL);

sizeof(*)

devm_kzalloc, unless you cannot use it because (missing comment)?

Please take the newest driver as your template. Do not upstream some
old, crappy code. Things changed over last 10 years, conventions changed.

> +	if (!max77705)
> +		return -ENOMEM;
> +
> +	max77705->pdata = pdata;

Drop, not used.

> +	max77705->dev = &i2c->dev;
> +	max77705->i2c = i2c;
> +	max77705->irq = i2c->irq;
> +
> +	max77705->regmap = devm_regmap_init_i2c(max77705->i2c, &max77705_regmap_config);
> +	if (IS_ERR(max77705->regmap)) {
> +		ret = PTR_ERR(max77705->regmap);
> +		dev_err(max77705->dev, "failed to allocate register map: %d\n",
> +				ret);

Not sure if we print allocation errors... but if you print, then:
ret = dev_err_probe

> +		return ret;
> +	}
> +
> +	max77705->regmap_leds = devm_regmap_init_i2c(max77705->i2c, &max77705_leds_regmap_config);
> +	if (IS_ERR(max77705->regmap_leds)) {
> +		ret = PTR_ERR(max77705->regmap_leds);
> +		dev_err(max77705->dev, "failed to allocate register map: %d\n",
> +				ret);
> +		return ret;
> +	}
> +
> +	i2c_set_clientdata(i2c, max77705);
> +
> +	if (regmap_read(max77705->regmap, MAX77705_PMIC_REG_PMICREV, &reg_data) < 0) {
> +		dev_err(max77705->dev,
> +			"device not found on this channel (this is not an error)\n");
> +		ret = -ENODEV;
> +		goto err;
> +	} else {
> +		/* print rev */
> +		max77705->pmic_rev = (reg_data & MAX77705_REVISION_MASK);
> +		max77705->pmic_ver = ((reg_data & MAX77705_VERSION_MASK) >> MAX77705_VERSION_SHIFT);
> +		dev_info(max77705->dev, "%s device found: rev.0x%x, ver.0x%x\n",
> +				__func__, max77705->pmic_rev, max77705->pmic_ver);

dev_dbg

> +	}
> +
> +	max77705->charger = devm_i2c_new_dummy_device(max77705->dev, i2c->adapter, I2C_ADDR_CHG);
> +	i2c_set_clientdata(max77705->charger, max77705);
> +	max77705->regmap_charger = devm_regmap_init_i2c(max77705->charger, &max77705_regmap_config);
> +	if (IS_ERR(max77705->regmap)) {
> +		ret = PTR_ERR(max77705->regmap);
> +		dev_err(max77705->dev, "failed to allocate register map: %d\n",
> +				ret);
> +		return ret;
> +	}
> +
> +	max77705->fuelgauge = devm_i2c_new_dummy_device(max77705->dev, i2c->adapter, I2C_ADDR_FG);
> +	i2c_set_clientdata(max77705->fuelgauge, max77705);
> +	max77705->regmap_fg = devm_regmap_init_i2c(max77705->fuelgauge, &max77705_fg_regmap_config);
> +	if (IS_ERR(max77705->regmap_fg)) {
> +		ret = PTR_ERR(max77705->regmap_fg);
> +		dev_err(max77705->dev, "failed to allocate register map: %d\n",
> +				ret);
> +		return ret;
> +	}
> +
> +	if (likely(i2c->irq > 0))

Drop likely

> +		max77705->irq = i2c->irq;

Why do you need it?

> +	else {
> +		dev_err(max77705->dev, "failed to get irq number\n");
> +		return -EINVAL;
> +	}
> +
> +	max77705->irq_base = irq_alloc_descs(-1, 0, MAX77705_IRQ_NR, -1);

Why this is not using simple regmap_irq_chip?

> +	if (unlikely(max77705->irq_base < 0)) {
> +		dev_err(max77705->dev, "irq_alloc_descs fail: %d\n", max77705->irq_base);
> +		ret = -EINVAL;
> +		goto err;
> +	}
> +
> +	disable_irq(max77705->irq);

Heh?

> +	ret = max77705_irq_init(max77705);
> +	if (ret) {
> +		dev_err(max77705->dev, "failed to init irq system: %d\n", ret);
> +		return ret;
> +	}
> +
> +	ret = mfd_add_devices(max77705->dev, -1, max77705_devs,
> +			ARRAY_SIZE(max77705_devs), NULL, 0, NULL);
> +	if (ret < 0)
> +		goto err_mfd;
> +
> +	debugfs_file = debugfs_create_file("max77705-regs",
> +				0664, NULL, (void *)max77705,
> +				  &max77705_debugfs_fops);
> +	if (!debugfs_file)
> +		dev_err(max77705->dev, "Failed to create debugfs file\n");

Drop dev_err

> +
> +	device_init_wakeup(max77705->dev, true);
> +
> +	return ret;
> +
> +err_mfd:
> +	mfd_remove_devices(max77705->dev);
> +err:
> +	kfree(max77705);
> +	return ret;
> +}
> +
> +static void max77705_i2c_remove(struct i2c_client *i2c)
> +{
> +	struct max77705_dev *max77705 = i2c_get_clientdata(i2c);
> +
> +	if (debugfs_file)
> +		debugfs_remove(debugfs_file);
> +
> +	device_init_wakeup(max77705->dev, 0);
> +	mfd_remove_devices(max77705->dev);

No freeing here? Sorry, this code is really poor.

> +}
> +
> +static int __maybe_unused max77705_suspend(struct device *dev)
> +{
> +	struct i2c_client *i2c = to_i2c_client(dev);
> +	struct max77705_dev *max77705 = i2c_get_clientdata(i2c);
> +
> +	disable_irq(max77705->irq);
> +	if (device_may_wakeup(dev))
> +		enable_irq_wake(max77705->irq);
> +
> +	return 0;
> +}
> +
> +static int __maybe_unused max77705_resume(struct device *dev)
> +{
> +	struct i2c_client *i2c = to_i2c_client(dev);
> +	struct max77705_dev *max77705 = i2c_get_clientdata(i2c);
> +
> +	if (device_may_wakeup(dev))
> +		disable_irq_wake(max77705->irq);
> +	enable_irq(max77705->irq);
> +
> +	return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(max77705_pm, max77705_suspend, max77705_resume);
> +
> +static const struct of_device_id max77705_i2c_dt_ids[] = {
> +	{ .compatible = "maxim,max77705" },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, max77705_i2c_dt_ids);
> +
> +static struct i2c_driver max77705_i2c_driver = {
> +	.driver		= {
> +		.name	= MFD_DEV_NAME,
> +		.pm = &max77705_pm,
> +		.of_match_table	= max77705_i2c_dt_ids,
> +		.suppress_bind_attrs = true,

Nope, drop. Fix the code instead.


> +	},
> +	.probe		= max77705_i2c_probe,
> +	.remove		= max77705_i2c_remove,
> +};
> +module_i2c_driver(max77705_i2c_driver);
> +
> +MODULE_DESCRIPTION("MAXIM 77705 multi-function core driver");
> +MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
> +MODULE_LICENSE("GPL");
> diff --git a/drivers/mfd/max77705-irq.c b/drivers/mfd/max77705-irq.c
> new file mode 100644
> index 000000000000..0da17fc95e18
> --- /dev/null
> +++ b/drivers/mfd/max77705-irq.c
> @@ -0,0 +1,299 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * max77705-irq.c - Interrupt controller support for MAX77705
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.com>
> + */
> +
> +#include <linux/err.h>
> +#include <linux/irq.h>
> +#include <linux/interrupt.h>
> +#include <linux/gpio.h>
> +#include <linux/platform_device.h>
> +#include <linux/mfd/max77705.h>
> +#include <linux/mfd/max77705-private.h>
> +#include <linux/regmap.h>
> +
> +static const u8 max77705_mask_reg[] = {
> +	[SYS_INT] = MAX77705_PMIC_REG_SYSTEM_INT_MASK,
> +	[CHG_INT] = MAX77705_CHG_REG_INT_MASK,
> +	[FUEL_INT] = MAX77705_REG_INVALID,
> +};
> +
> +static struct regmap *get_i2c(struct max77705_dev *max77705,
> +				enum max77705_irq_source src)
> +{
> +	switch (src) {
> +	case SYS_INT:
> +		return max77705->regmap;
> +	case FUEL_INT:
> +		return max77705->regmap_fg;
> +	case CHG_INT:
> +		return max77705->regmap_charger;
> +	default:
> +		return ERR_PTR(-EINVAL);
> +	}
> +}
> +
> +struct max77705_irq_data {
> +	int mask;
> +	enum max77705_irq_source group;
> +};
> +
> +static const struct max77705_irq_data max77705_irqs[] = {
> +	[MAX77705_SYSTEM_IRQ_BSTEN_INT] = { .group = SYS_INT, .mask = BIT(3) },
> +	[MAX77705_SYSTEM_IRQ_SYSUVLO_INT] = { .group = SYS_INT, .mask = BIT(4) },
> +	[MAX77705_SYSTEM_IRQ_SYSOVLO_INT] = { .group = SYS_INT, .mask = BIT(5) },
> +	[MAX77705_SYSTEM_IRQ_TSHDN_INT] = { .group = SYS_INT, .mask = BIT(6) },
> +	[MAX77705_SYSTEM_IRQ_TM_INT] = { .group = SYS_INT, .mask = BIT(7) },
> +
> +	[MAX77705_CHG_IRQ_BYP_I] = { .group = CHG_INT, .mask = BIT(0) },
> +	[MAX77705_CHG_IRQ_BAT_I] = { .group = CHG_INT, .mask = BIT(3) },
> +	[MAX77705_CHG_IRQ_CHG_I] = { .group = CHG_INT, .mask = BIT(4) },
> +	[MAX77705_CHG_IRQ_WCIN_I] = { .group = CHG_INT, .mask = BIT(5) },
> +	[MAX77705_CHG_IRQ_CHGIN_I] = { .group = CHG_INT, .mask = BIT(6) },
> +	[MAX77705_CHG_IRQ_AICL_I] = { .group = CHG_INT, .mask = BIT(7) },
> +
> +	[MAX77705_FG_IRQ_ALERT] = { .group = FUEL_INT, .mask = BIT(1) },
> +};
> +
> +static void max77705_irq_lock(struct irq_data *data)
> +{
> +	struct max77705_dev *max77705 = irq_get_chip_data(data->irq);
> +
> +	mutex_lock(&max77705->irqlock);
> +}
> +
> +static void max77705_irq_sync_unlock(struct irq_data *data)
> +{
> +	struct max77705_dev *max77705 = irq_get_chip_data(data->irq);
> +	int i;
> +
> +	for (i = 0; i < MAX77705_IRQ_GROUP_NR; i++) {
> +		u8 mask_reg = max77705_mask_reg[i];
> +		struct regmap *i2c = get_i2c(max77705, i);
> +
> +		if (mask_reg == MAX77705_REG_INVALID ||
> +				IS_ERR_OR_NULL(i2c))
> +			continue;
> +		max77705->irq_masks_cache[i] = max77705->irq_masks_cur[i];
> +
> +		regmap_write(i2c, max77705_mask_reg[i],
> +				max77705->irq_masks_cur[i]);
> +	}
> +
> +	mutex_unlock(&max77705->irqlock);

Just use regmap_irq_chip.


> +
> +MODULE_LICENSE("GPL");
> diff --git a/include/linux/mfd/max77705-private.h b/include/linux/mfd/max77705-private.h
> new file mode 100644
> index 000000000000..bd6ab9c582b8
> --- /dev/null
> +++ b/include/linux/mfd/max77705-private.h
> @@ -0,0 +1,281 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * max77705-private.h
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.

OMG, how this code is?

I already said but above is the nail to the coffin: sorry, start from
scratch and do not try to upstream junk downstream code.

Amount of work you require from reviewers on silly things which we
solved long time ago, is just tremendous.

That's not how upstreaming works.

> + */
> +
> +#ifndef __LINUX_MFD_MAX77705_PRIV_H
> +#define __LINUX_MFD_MAX77705_PRIV_H
> +
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/slab.h>
> +#include <linux/gpio.h>
> +#include <linux/delay.h>
> +#include <linux/i2c.h>
> +
> +#define MAX77705_REG_INVALID		(0xff)
> +#define MAX77705_IRQSRC_CHG			BIT(0)
> +#define MAX77705_IRQSRC_TOP			BIT(1)
> +#define MAX77705_IRQSRC_FG			BIT(2)
> +#define MAX77705_IRQSRC_USBC		BIT(3)
> +
> +/* STATUS_REG */
> +#define MAX77705_BAT_ABSENT_MASK	BIT(3)
> +/* MAX77705 MAINCTRL1 register */
> +#define MAX77705_MAINCTRL1_BIASEN_SHIFT		7
> +#define MAX77705_MAINCTRL1_BIASEN_MASK		BIT(MAX77705_MAINCTRL1_BIASEN_SHIFT)
> +
> +/* max77705-haptic configuration register */
> +#define MAX77705_CONFIG2_MEN_SHIFT		6
> +#define MAX77705_CONFIG2_MODE_SHIFT		7
> +#define MAX77705_CONFIG2_HTYP_SHIFT		5
> +
> +#define MAX77705_REVISION_MASK	7
> +#define MAX77705_VERSION_MASK	0xF8
> +#define MAX77705_VERSION_SHIFT	3
> +
> +enum max77705_hw_rev {
> +	MAX77705_PASS1 = 1,
> +	MAX77705_PASS2,
> +	MAX77705_PASS3,
> +};
> +
> +enum max77705_reg {
> +	/* Slave addr = 0xCC */
> +	/* PMIC Top-Level Registers */
> +	MAX77705_PMIC_REG_PMICID1		= 0x00,
> +	MAX77705_PMIC_REG_PMICREV		= 0x01,
> +	MAX77705_PMIC_REG_MAINCTRL1		= 0x02,
> +	MAX77705_PMIC_REG_INTSRC		= 0x22,

That's not enum but defines. This applies to all your register definitions.

> +	MAX77705_PMIC_REG_INTSRC_MASK		= 0x23,
> +	MAX77705_PMIC_REG_SYSTEM_INT		= 0x24,
> +	MAX77705_PMIC_REG_RESERVED_25		= 0x25,
> +	MAX77705_PMIC_REG_SYSTEM_INT_MASK	= 0x26,
> +	MAX77705_PMIC_REG_RESERVED_27		= 0x27,
> +	MAX77705_PMIC_REG_RESERVED_28		= 0x28,
> +	MAX77705_PMIC_REG_RESERVED_29		= 0x29,
> +	MAX77705_PMIC_REG_BOOSTCONTROL1		= 0x4C,
> +	MAX77705_PMIC_REG_BSTOUT_MASK		= 0x03,
> +	MAX77705_PMIC_REG_BOOSTCONTROL2		= 0x4F,
> +	MAX77705_PMIC_REG_FORCE_EN_MASK		= 0x08,
> +	MAX77705_PMIC_REG_SW_RESET		= 0x50,
> +	MAX77705_PMIC_REG_USBC_RESET		= 0x51,
> +
> +	/* Haptic motor driver Registers */
> +	MAX77705_PMIC_REG_MCONFIG		= 0x10,
> +	MAX77705_PMIC_REG_MCONFIG2		= 0x11,
> +
> +	MAX77705_CHG_REG_INT			= 0xB0,
> +	MAX77705_CHG_REG_INT_MASK		= 0xB1,
> +	MAX77705_CHG_REG_INT_OK			= 0xB2,
> +	MAX77705_CHG_REG_DETAILS_00		= 0xB3,
> +	MAX77705_CHG_REG_DETAILS_01		= 0xB4,
> +	MAX77705_CHG_REG_DETAILS_02		= 0xB5,
> +	MAX77705_CHG_REG_DTLS_03		= 0xB6,
> +	MAX77705_CHG_REG_CNFG_00		= 0xB7,
> +	MAX77705_CHG_REG_CNFG_01		= 0xB8,
> +	MAX77705_CHG_REG_CNFG_02		= 0xB9,
> +	MAX77705_CHG_REG_CNFG_03		= 0xBA,
> +	MAX77705_CHG_REG_CNFG_04		= 0xBB,
> +	MAX77705_CHG_REG_CNFG_05		= 0xBC,
> +	MAX77705_CHG_REG_CNFG_06		= 0xBD,
> +	MAX77705_CHG_REG_CNFG_07		= 0xBE,
> +	MAX77705_CHG_REG_CNFG_08		= 0xBF,
> +	MAX77705_CHG_REG_CNFG_09		= 0xC0,
> +	MAX77705_CHG_REG_CNFG_10		= 0xC1,
> +	MAX77705_CHG_REG_CNFG_11		= 0xC2,
> +	MAX77705_CHG_REG_CNFG_12		= 0xC3,
> +	MAX77705_CHG_REG_CNFG_13		= 0xC4,
> +	MAX77705_CHG_REG_CNFG_14		= 0xC5,
> +	MAX77705_CHG_REG_SAFEOUT_CTRL		= 0xC6,
> +
> +	MAX77705_PMIC_REG_END,
> +};
> +
> +enum max77705_charger_battery_state {
> +	MAX77705_BATTERY_NOBAT,
> +	MAX77705_BATTERY_PREQUALIFICATION,
> +	MAX77705_BATTERY_DEAD,
> +	MAX77705_BATTERY_GOOD,
> +	MAX77705_BATTERY_LOWVOLTAGE,
> +	MAX77705_BATTERY_OVERVOLTAGE,
> +	MAX77705_BATTERY_RESERVED,
> +};
> +
> +enum max77705_charger_charge_type {
> +	MAX77705_CHARGER_CONSTANT_CURRENT	= 1,
> +	MAX77705_CHARGER_CONSTANT_VOLTAGE,
> +	MAX77705_CHARGER_END_OF_CHARGE,
> +	MAX77705_CHARGER_DONE,
> +};
> +
> +/* Slave addr = 0x6C : Fuelgauge */
> +enum max77705_fuelgauge_reg {
> +	STATUS_REG				= 0x00,
> +	VALRT_THRESHOLD_REG			= 0x01,
> +	TALRT_THRESHOLD_REG			= 0x02,
> +	SALRT_THRESHOLD_REG			= 0x03,
> +	REMCAP_REP_REG				= 0x05,
> +	SOCREP_REG				= 0x06,
> +	TEMPERATURE_REG				= 0x08,
> +	VCELL_REG				= 0x09,
> +	TIME_TO_EMPTY_REG			= 0x11,
> +	FULLSOCTHR_REG				= 0x13,
> +	CURRENT_REG				= 0x0A,
> +	AVG_CURRENT_REG				= 0x0B,
> +	SOCMIX_REG				= 0x0D,
> +	SOCAV_REG				= 0x0E,
> +	REMCAP_MIX_REG				= 0x0F,
> +	FULLCAP_REG				= 0x10,
> +	RFAST_REG				= 0x15,
> +	AVR_TEMPERATURE_REG			= 0x16,
> +	CYCLES_REG				= 0x17,
> +	DESIGNCAP_REG				= 0x18,
> +	AVR_VCELL_REG				= 0x19,
> +	TIME_TO_FULL_REG			= 0x20,
> +	CONFIG_REG				= 0x1D,
> +	ICHGTERM_REG				= 0x1E,
> +	REMCAP_AV_REG				= 0x1F,
> +	FULLCAP_NOM_REG				= 0x23,
> +	LEARN_CFG_REG				= 0x28,
> +	FILTER_CFG_REG				= 0x29,
> +	MISCCFG_REG				= 0x2B,
> +	QRTABLE20_REG				= 0x32,
> +	FULLCAP_REP_REG				= 0x35,
> +	RCOMP_REG				= 0x38,
> +	VEMPTY_REG				= 0x3A,
> +	FSTAT_REG				= 0x3D,
> +	DISCHARGE_THRESHOLD_REG			= 0x40,
> +	QRTABLE30_REG				= 0x42,
> +	ISYS_REG				= 0x43,
> +	DQACC_REG				= 0x45,
> +	DPACC_REG				= 0x46,
> +	AVGISYS_REG				= 0x4B,
> +	QH_REG					= 0x4D,
> +	VSYS_REG				= 0xB1,
> +	TALRTTH2_REG				= 0xB2,
> +	/* "not used REG(0xB2)" is for checking fuelgague init result. */
> +	FG_INIT_RESULT_REG			= TALRTTH2_REG,
> +	VBYP_REG				= 0xB3,
> +	CONFIG2_REG				= 0xBB,
> +	IIN_REG					= 0xD0,
> +	OCV_REG					= 0xEE,
> +	VFOCV_REG				= 0xFB,
> +	VFSOC_REG				= 0xFF,
> +
> +	MAX77705_FG_END,
> +};
> +
> +enum max77705_irq_source {
> +	SYS_INT = 0,
> +	CHG_INT,
> +	FUEL_INT,
> +	MAX77705_IRQ_GROUP_NR,
> +};
> +
> +
> +#define MAX77705_REG_MAINCTRL1_BIASEN		BIT(7)
> +
> +/* Slave addr = 0x94: RGB LED */
> +enum max77705_led_reg {
> +	MAX77705_RGBLED_REG_LEDEN			= 0x30,
> +	MAX77705_RGBLED_REG_LED0BRT			= 0x31,
> +	MAX77705_RGBLED_REG_LED1BRT			= 0x32,
> +	MAX77705_RGBLED_REG_LED2BRT			= 0x33,
> +	MAX77705_RGBLED_REG_LED3BRT			= 0x34,
> +	MAX77705_RGBLED_REG_LEDRMP			= 0x36,
> +	MAX77705_RGBLED_REG_LEDBLNK			= 0x38,
> +	MAX77705_LED_REG_END,
> +};
> +
> +enum max77705_irq {
> +	/* PMIC; TOPSYS */
> +	MAX77705_SYSTEM_IRQ_BSTEN_INT,
> +	MAX77705_SYSTEM_IRQ_SYSUVLO_INT,
> +	MAX77705_SYSTEM_IRQ_SYSOVLO_INT,
> +	MAX77705_SYSTEM_IRQ_TSHDN_INT,
> +	MAX77705_SYSTEM_IRQ_TM_INT,
> +
> +	/* PMIC; Charger */
> +	MAX77705_CHG_IRQ_BYP_I,
> +	MAX77705_CHG_IRQ_BAT_I,
> +	MAX77705_CHG_IRQ_CHG_I,
> +	MAX77705_CHG_IRQ_WCIN_I,
> +	MAX77705_CHG_IRQ_CHGIN_I,
> +	MAX77705_CHG_IRQ_AICL_I,
> +
> +	/* Fuelgauge */
> +	MAX77705_FG_IRQ_ALERT,
> +
> +	MAX77705_IRQ_NR,
> +};
> +
> +struct max77705_dev {
> +	struct device *dev;
> +	struct i2c_client *i2c; /* 0xCC; Haptic, PMIC */
> +	struct i2c_client *charger; /* 0xD2; Charger */
> +	struct i2c_client *fuelgauge; /* 0x6C; Fuelgauge */
> +	struct i2c_client *muic; /* 0x4A; MUIC */
> +	struct i2c_client *debug; /* 0xC4; Debug */
> +	struct mutex i2c_lock;
> +
> +	struct regmap *regmap;
> +	struct regmap *regmap_fg;
> +	struct regmap *regmap_charger;
> +	struct regmap *regmap_leds;
> +
> +	int type;
> +
> +	int irq;
> +	int irq_base;
> +	int irq_masks_cur[MAX77705_IRQ_GROUP_NR];
> +	int irq_masks_cache[MAX77705_IRQ_GROUP_NR];
> +	bool wakeup;
> +	struct mutex irqlock;
> +
> +#ifdef CONFIG_HIBERNATION
> +	/* For hibernation */
> +	u8 reg_pmic_dump[MAX77705_PMIC_REG_END];
> +	u8 reg_muic_dump[MAX77705_USBC_REG_END];
> +	u8 reg_led_dump[MAX77705_LED_REG_END];
> +#endif
> +
> +	/* pmic VER/REV register */
> +	u8 pmic_rev;	/* pmic Rev */
> +	u8 pmic_ver;	/* pmic version */

Why do you need to store it?

> +
> +	u8 cc_booting_complete;

That's nowhere used. Just like many other fields here. Clean up your
driver before posting it upstream.

> +
> +	wait_queue_head_t queue_empty_wait_q;
> +	int doing_irq;
> +	int is_usbc_queue;
> +
> +	struct max77705_platform_data *pdata;
> +};
> +
> +enum max77705_types {
> +	TYPE_MAX77705,

Drop. What is this for?

> +};
> +
> +
> +/**
> + * Unmask sub device interrupts on device level
> + *
> + * @param max77705 - device structure
> + * @param mask - sub device interrupts to unmask
> + */
> +extern inline int max77705_irq_unmask_subdevice(struct max77705_dev *max77705, unsigned int mask);

See coding style: limit is 80. checkpatch is not coding style.

> +
> +/**
> + * Same as max77705_irq_unmask_device, but for masking.
> + */
> +extern inline int max77705_irq_mask_subdevice(struct max77705_dev *max77705, unsigned int mask);
> +
> +
> +extern int max77705_irq_init(struct max77705_dev *max77705);

Drop externs everywhere.

> +
> +#endif /* __LINUX_MFD_MAX77705_PRIV_H */
> diff --git a/include/linux/mfd/max77705.h b/include/linux/mfd/max77705.h
> new file mode 100644
> index 000000000000..e2d757c77973
> --- /dev/null
> +++ b/include/linux/mfd/max77705.h
> @@ -0,0 +1,20 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * max77705.h - Driver for the Maxim 77705
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef __MAX77705_H__
> +#define __MAX77705_H__
> +
> +#define MFD_DEV_NAME "max77705"
> +
> +struct max77705_platform_data {
> +	struct power_supply_battery_info *bat_info;

Entire platform data is redundant. Drop.

> +};
> +
> +#endif /* __MAX77705_H__ */
> +
> 

Do not keep redundant blank lines. Drop.

Best regards,
Krzysztof


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

* Re: [PATCH v3 13/23] input: add max77705 haptic driver
  2024-06-18 13:59 ` [PATCH v3 13/23] input: add max77705 haptic driver Dzmitry Sankouski
@ 2024-06-20 16:04   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 16:04 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> Add support for haptic controller on MAX77705 Multifunction
> device.
> 
> This driver supports external pwm and LRA (Linear Resonant Actuator) motor.
> User can control the haptic device via force feedback framework.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---

> +static int max77705_haptic_bias(struct max77705_haptic *haptic, bool on)
> +{
> +	int error;
> +
> +	error = regmap_update_bits(haptic->regmap_haptic,
> +							   MAX77705_PMIC_REG_MAINCTRL1,
> +							   MAX77705_MAINCTRL1_BIASEN_MASK,
> +							   on << MAX77705_MAINCTRL1_BIASEN_SHIFT);
> +
> +	if (error) {
> +		dev_err(haptic->dev, "failed to %s bias: %d\n",
> +			on ? "enable" : "disable", error);
> +		return error;
> +	}
> +
> +	return 0;
> +}
> +
> +static int max77705_haptic_configure(struct max77705_haptic *haptic,
> +				     bool enable)
> +{
> +	unsigned int value, config_reg;
> +	int error;
> +
> +	value = ((haptic->type << MAX77705_CONFIG2_MODE_SHIFT) |
> +		(enable << MAX77705_CONFIG2_MEN_SHIFT) |
> +		(haptic->mode << MAX77705_CONFIG2_HTYP_SHIFT) |
> +		MAX77705_HAPTIC_PWM_DIVISOR_128);
> +	config_reg = MAX77705_PMIC_REG_MCONFIG;
> +
> +	error = regmap_write(haptic->regmap_haptic,
> +			     config_reg, value);
> +	if (error) {
> +		dev_err(haptic->dev,
> +			"failed to update haptic config: %d\n", error);
> +		return error;
> +	}
> +
> +	return 0;
> +}
> +
> +static void max77705_haptic_enable(struct max77705_haptic *haptic)
> +{
> +	int error;
> +
> +	if (haptic->enabled)
> +		return;
> +
> +	error = pwm_enable(haptic->pwm_dev);
> +	if (error) {
> +		dev_err(haptic->dev,
> +			"failed to enable haptic pwm device: %d\n", error);
> +		return;
> +	}
> +
> +	error = max77705_haptic_configure(haptic, true);
> +	if (error)
> +		goto err_enable_config;
> +
> +	haptic->enabled = true;
> +
> +	return;
> +
> +err_enable_config:
> +	pwm_disable(haptic->pwm_dev);
> +}
> +
> +static void max77705_haptic_disable(struct max77705_haptic *haptic)
> +{
> +	int error;
> +
> +	if (!haptic->enabled)
> +		return;
> +
> +	error = max77705_haptic_configure(haptic, false);
> +	if (error)
> +		return;
> +
> +	pwm_disable(haptic->pwm_dev);
> +	haptic->enabled = false;
> +}
> +
> +static void max77705_haptic_play_work(struct work_struct *work)
> +{
> +	struct max77705_haptic *haptic =
> +			container_of(work, struct max77705_haptic, work);
> +	int error;
> +
> +	error = max77705_haptic_set_duty_cycle(haptic);
> +	if (error) {
> +		dev_err(haptic->dev, "failed to set duty cycle: %d\n", error);
> +		return;
> +	}
> +
> +	if (haptic->magnitude)
> +		max77705_haptic_enable(haptic);
> +	else
> +		max77705_haptic_disable(haptic);
> +}
> +
> +static int max77705_haptic_play_effect(struct input_dev *dev, void *data,
> +				       struct ff_effect *effect)
> +{
> +	struct max77705_haptic *haptic = input_get_drvdata(dev);
> +	struct pwm_args pargs;
> +	u64 period_mag_multi;
> +
> +	haptic->magnitude = effect->u.rumble.strong_magnitude;
> +	if (!haptic->magnitude)
> +		haptic->magnitude = effect->u.rumble.weak_magnitude;
> +
> +	/*
> +	 * The magnitude comes from force-feedback interface.
> +	 * The formula to convert magnitude to pwm_duty as follows:
> +	 * - pwm_duty = (magnitude * pwm_period) / MAX_MAGNITUDE(0xFFFF)
> +	 */
> +	pr_info("magnitude: %d(%x)", haptic->magnitude, haptic->magnitude);

Do not use pr_xxx in your drivers. That's a generic comment so please
apply it everywhere. Anyway driver should be silent.


> +	pwm_get_args(haptic->pwm_dev, &pargs);
> +	period_mag_multi = (u64)pargs.period * haptic->magnitude;
> +	haptic->pwm_duty = (unsigned int)(period_mag_multi >>
> +						MAX_MAGNITUDE_SHIFT);
> +
> +	schedule_work(&haptic->work);
> +
> +	return 0;
> +}


> +
> +static DEFINE_SIMPLE_DEV_PM_OPS(max77705_haptic_pm_ops,
> +				max77705_haptic_suspend,
> +				max77705_haptic_resume);
> +
> +static const struct of_device_id of_max77705_haptic_dt_match[] = {
> +	{ .compatible = "maxim,max77705-haptic", },
> +	{ /* sentinel */ },
> +};
> +MODULE_DEVICE_TABLE(of, of_max77705_haptic_dt_match);
> +
> +static struct platform_driver max77705_haptic_driver = {
> +	.driver		= {
> +		.name	= "max77705-haptic",
> +		.pm	= pm_sleep_ptr(&max77705_haptic_pm_ops),
> +		.of_match_table = of_max77705_haptic_dt_match,
> +	},
> +	.probe		= max77705_haptic_probe,
> +	.remove_new	= max77705_haptic_remove,
> +};
> +module_platform_driver(max77705_haptic_driver);
> +
> +MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
> +MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
> +MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>");

I doubt that this driver is needed. Everything is copy of max777693.


Best regards,
Krzysztof


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

* Re: [PATCH v3 14/23] power: supply: max77705: Add charger driver for Maxim 77705
  2024-06-18 13:59 ` [PATCH v3 14/23] power: supply: max77705: Add charger driver for Maxim 77705 Dzmitry Sankouski
@ 2024-06-20 16:06   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 16:06 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> Add driver for Maxim 77705 switch-mode charger (part of max77705
> MFD driver) providing power supply class information to userspace.
> 
> The driver is configured through DTS (battery and system related
> settings). Also, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE property
> is writable, which allows to configure charge end at less than 100%
> 

...

> + *
> + * Copyright (C) 2015 Samsung Electronics, Inc.
> + *
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.

Yeah, please do not upstream 2015 Samsung code. Instead, take a new,
clean, decent driver and use it as template.

Otherwise you ask us to do exactly the same review we already gave last
10 years. Or review on issues we fixed last 10 years.

Best regards,
Krzysztof


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

* Re: [PATCH v3 17/23] mfd: add s2dos series core driver
  2024-06-18 13:59 ` [PATCH v3 17/23] mfd: add s2dos series core driver Dzmitry Sankouski
@ 2024-06-20 16:07   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 16:07 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> S2DOS05 is a panel/touchscreen PMIC, often found in
> Samsung phones. We define 2 sub-devices for which drivers will
> be added in subsequent patches.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  MAINTAINERS                            |   1 +
>  drivers/mfd/Kconfig                    |  13 +++
>  drivers/mfd/Makefile                   |   2 +-
>  drivers/mfd/s2dos-core.c               | 141 +++++++++++++++++++++++++++++++++
>  include/linux/mfd/samsung/s2dos-core.h |  21 +++++
>  include/linux/mfd/samsung/s2dos05.h    | 115 +++++++++++++++++++++++++++
>  6 files changed, 292 insertions(+), 1 deletion(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f3c245d432d9..b53462684a30 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -19908,6 +19908,7 @@ F:	Documentation/devicetree/bindings/regulator/samsung,s2dos*.yaml
>  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/s2dos*.c
>  F:	drivers/mfd/sec*.c
>  F:	drivers/regulator/s2m*.c
>  F:	drivers/regulator/s5m*.c
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index c4eb8ff2dcad..517d8778d7a8 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -1278,6 +1278,19 @@ config MFD_RN5T618
>  	  additional drivers must be enabled in order to use the
>  	  functionality of the device.
>  
> +config MFD_S2DOS_CORE
> +	tristate "Samsung Electronics PMIC Series Support"

Nope, that's a strong NAK.

No need for one more clone of Samsung PMIC driver.


Best regards,
Krzysztof


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

* Re: [PATCH v3 18/23] regulator: add s2dos05 regulator support
  2024-06-18 13:59 ` [PATCH v3 18/23] regulator: add s2dos05 regulator support Dzmitry Sankouski
  2024-06-18 14:08   ` Mark Brown
@ 2024-06-20 16:08   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 16:08 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> S2dos05 has 1 buck and 4 LDO regulators, used for powering
> panel/touchscreen.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>


> diff --git a/drivers/regulator/s2dos05-regulator.c b/drivers/regulator/s2dos05-regulator.c
> new file mode 100644
> index 000000000000..3c58a1bd2262
> --- /dev/null
> +++ b/drivers/regulator/s2dos05-regulator.c
> @@ -0,0 +1,362 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * s2dos05.c - Regulator driver for the Samsung s2dos05
> + *
> + * Copyright (C) 2016 Samsung Electronics

Not happy. You upstream old issues. :( Please drop all junk Samsung code.

> + * Copyright (C) 2023 Dzmitry Sankouski <dsankouski@gmail.com>
> + *
> + */

...

> +
> +	return ret;
> +
> +err_data:
> +	devm_kfree(dev, (void *)s2dos05);

Why?

> +	kfree(s2dos05);

Please test this first. This is obviously wrong and having such trivial
issue makes me question what else is in this Samsung code.


Best regards,
Krzysztof


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

* Re: [PATCH v3 19/23] power: supply: s2dos05: Add fuel gauge driver for s2dos05
  2024-06-18 13:59 ` [PATCH v3 19/23] power: supply: s2dos05: Add fuel gauge driver for s2dos05 Dzmitry Sankouski
@ 2024-06-20 16:11   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 16:11 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> Add fuel gauge driver for s2dos05 PMIC. It uses adc to measure power
> on each power output s2dos05 provides, including regulator outputs
> and AVDD, ELVSS, ELVDD lines. Driver registers power supply for each
> corresponding power line.
> 
> Adc can be disabled and enabled via sysfs.
> 


> +
> +static const struct power_supply_desc s2dos05_avdd_fg_desc = {
> +	.name		= "s2dos05_avdd",
> +	.type		= POWER_SUPPLY_TYPE_UNKNOWN,
> +	.get_property	= s2dos05_fg_get_property_avdd,
> +	.properties	= s2dos05_fg_properties,
> +	.num_properties	= ARRAY_SIZE(s2dos05_fg_properties),
> +};
> +
> +static const struct power_supply_desc s2dos05_buck_fg_desc = {
> +	.name		= "s2dos05_buck",
> +	.type		= POWER_SUPPLY_TYPE_UNKNOWN,
> +	.get_property	= s2dos05_fg_get_property_buck,
> +	.properties	= s2dos05_fg_properties,
> +	.num_properties	= ARRAY_SIZE(s2dos05_fg_properties),
> +};

Buck is a regulator. Not power supply.

Entire driver is something odd. NAK.

> +static int s2dos05_fuelgauge_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct s2dos_core *iodev = dev_get_drvdata(dev->parent);
> +	struct s2dos05_fg	*drv_data;

Drop redundant spaces.

> +	struct power_supply_config pscfg = {};
> +	int ret;
> +
> +	drv_data = devm_kzalloc(dev, sizeof(struct s2dos05_fg),

Drop 2015 code. Use new drivers as template.

> +							GFP_KERNEL);
> +	if (!drv_data)
> +		ret = -ENOMEM;


> +
> +MODULE_DESCRIPTION("s2dos05 power meter");
> +MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
> +MODULE_LICENSE("GPL");
> diff --git a/include/linux/mfd/s2dos05.h b/include/linux/mfd/s2dos05.h
> new file mode 100644
> index 000000000000..8d216064bc78
> --- /dev/null
> +++ b/include/linux/mfd/s2dos05.h

Why this is MFD? Squash the header into C code.

> @@ -0,0 +1,123 @@
> +/* SPDX-License-Identifier: GPL-2.0+
> + * s2dos05.h

Drop

> + *
> + * Copyright (c) 2016 Samsung Electronics Co., Ltd
> + *              http://www.samsung.com
> + *
> + */
> +
> +#ifndef __LINUX_MFD_S2DOS05_H
> +#define __LINUX_MFD_S2DOS05_H
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +
> +#define MFD_DEV_NAME "s2dos05"

Drop

> +
> +struct s2dos05_dev {
> +	struct device *dev;
> +	struct regmap *regmap;
> +};
> +
> +/* 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 {

What does it have to do with power supply / fuel gauge?

> +	S2DOS05_LDO1,
> +	S2DOS05_LDO2,
> +	S2DOS05_LDO3,
> +	S2DOS05_LDO4,
> +	S2DOS05_BUCK1,
> +	S2DOS05_REG_MAX,
> +};



Best regards,
Krzysztof


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

* Re: [PATCH v3 07/23] dt-bindings: power: supply: add maxim,max77705
  2024-06-18 13:59 ` [PATCH v3 07/23] dt-bindings: power: supply: add maxim,max77705 Dzmitry Sankouski
  2024-06-18 16:53   ` Rob Herring (Arm)
@ 2024-06-20 16:14   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 16:14 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> add maxim,max77705 fuel gauge binding part
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  .../bindings/power/supply/maxim,max77705-fg.yaml   | 35 ++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml
> new file mode 100644
> index 000000000000..b24db0aba0d7
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml
> @@ -0,0 +1,35 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/power/supply/maxim,max77705-fg.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim MAX77705 Companion Power Management IC fuelgauge
> +
> +maintainers:
> +  - Dzmitry Sankouski <dsankouski@gmail.com>
> +
> +description: |
> +  This is a part of device tree bindings for Maxim MAX77705 multi functional device.
> +
> +  MAX77705 fuelgauge with ModelGauge m5 EZ algorithm support.
> +
> +  See also Documentation/devicetree/bindings/mfd/maxim,max77705.yaml for
> +  additional information and example.
> +
> +allOf:
> +  - $ref: power-supply.yaml#
> +
> +properties:
> +  compatible:
> +    const: maxim,max77705-fg
> +
> +  rsense:
> +    $ref: /schemas/types.yaml#/definitions/uint32

Look at other bindings how this is defined. shunt-resistor-micro-ohms

> +    description: |
> +      Sense resistor value in mOhm

Merge the node into parent node. No resources here.

Best regards,
Krzysztof


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

* Re: [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver
  2024-06-19 13:27     ` Dzmitry Sankouski
@ 2024-06-20 20:13       ` Dmitry Baryshkov
  0 siblings, 0 replies; 62+ messages in thread
From: Dmitry Baryshkov @ 2024-06-20 20:13 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Konrad Dybcio, Chanwoo Choi, phone-devel, linux-pm, linux-kernel,
	linux-arm-msm, linux-clk, dri-devel, devicetree, linux-input,
	linux-leds, linux-pwm, linux-samsung-soc

On Wed, Jun 19, 2024 at 04:27:40PM GMT, Dzmitry Sankouski wrote:
> вт, 18 июн. 2024 г. в 21:39, Dmitry Baryshkov <dmitry.baryshkov@linaro.org>:
> >
> > > +     ret = mipi_dsi_compression_mode(dsi, true);
> > > +     if (ret < 0) {
> > > +             dev_err(dev, "Failed to set compression mode: %d\n", ret);
> > > +             return ret;
> > > +     }
> >
> > Interesting, compression mode is being set before the PPS programming?
> >
> Yes, as per vendor kernel:
> https://github.com/klabit87/twrp_android_samsung_kernel_sdm845/blob/e8bb63039008e1704a2f1bde68d39ded9c16ea88/drivers/gpu/drm/msm/samsung/S6E3HA8_AMB577PX01/dsi_panel_S6E3HA8_AMB577PX01_wqhd_octa_cmd.dtsi#L5508

Ack

-- 
With best wishes
Dmitry

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

* Re: [PATCH v3 16/23] leds: max77705: Add LEDs support
  2024-06-18 13:59 ` [PATCH v3 16/23] leds: max77705: Add LEDs support Dzmitry Sankouski
@ 2024-06-20 20:14   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 62+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-20 20:14 UTC (permalink / raw)
  To: Dzmitry Sankouski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel
  Cc: linux-pm, linux-kernel, linux-arm-msm, linux-clk, dri-devel,
	devicetree, linux-input, linux-leds, linux-pwm, linux-samsung-soc

On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> This adds basic support for LEDs for the max77705 PMIC.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> ---
>  MAINTAINERS                  |   1 +
>  drivers/leds/Kconfig         |   6 ++
>  drivers/leds/Makefile        |   1 +
>  drivers/leds/leds-max77705.c | 166 +++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 174 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f66f08825db9..f3c245d432d9 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13691,6 +13691,7 @@ F:	drivers/*/max14577*.c
>  F:	drivers/*/max77686*.c
>  F:	drivers/*/max77693*.c
>  F:	drivers/*/max77705*.c
> +F:	drivers/leds/leds-max77705.c
>  F:	drivers/clk/clk-max77686.c
>  F:	drivers/extcon/extcon-max14577.c
>  F:	drivers/extcon/extcon-max77693.c
> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index 05e6af88b88c..14d483011308 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -728,6 +728,12 @@ config LEDS_MAX77650
>  	help
>  	  LEDs driver for MAX77650 family of PMICs from Maxim Integrated.
>  
> +config LEDS_MAX77705
> +	tristate "LED support for Maxim MAX77705 RGB"
> +	depends on MFD_MAX77705 && LEDS_CLASS && I2C
> +	help
> +	  LED driver for MAX77705 MFD chip from Maxim Integrated.
> +
>  config LEDS_MAX8997
>  	tristate "LED support for MAX8997 PMIC"
>  	depends on LEDS_CLASS && MFD_MAX8997
> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> index effdfc6f1e95..be064e3d678e 100644
> --- a/drivers/leds/Makefile
> +++ b/drivers/leds/Makefile
> @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_LP8860)		+= leds-lp8860.o
>  obj-$(CONFIG_LEDS_LT3593)		+= leds-lt3593.o
>  obj-$(CONFIG_LEDS_MAX5970)		+= leds-max5970.o
>  obj-$(CONFIG_LEDS_MAX77650)		+= leds-max77650.o
> +obj-$(CONFIG_LEDS_MAX77705)		+= leds-max77705.o
>  obj-$(CONFIG_LEDS_MAX8997)		+= leds-max8997.o
>  obj-$(CONFIG_LEDS_MC13783)		+= leds-mc13783.o
>  obj-$(CONFIG_LEDS_MENF21BMC)		+= leds-menf21bmc.o
> diff --git a/drivers/leds/leds-max77705.c b/drivers/leds/leds-max77705.c
> new file mode 100644
> index 000000000000..f91c0e41056c
> --- /dev/null
> +++ b/drivers/leds/leds-max77705.c
> @@ -0,0 +1,166 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Based on leds-max77650 driver:
> + *		Copyright (C) 2018 BayLibre SAS
> + *		Author: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> + *
> + * LED driver for MAXIM 77705 MFD.
> + * Copyright (C) 2024 Dzmitry Sankouski <dsankouski@gmail.org>
> + */
> +
> +#include <linux/i2c.h>
> +#include <linux/leds.h>
> +#include <linux/mfd/max77705.h>
> +#include <linux/mfd/max77705-private.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +
> +#define MAX77705_LED_NUM_LEDS		4
> +#define MAX77705_LED_EN_MASK		GENMASK(1, 0)
> +#define MAX77705_LED_MAX_BRIGHTNESS	0xff
> +
> +#define LEDBLNK_ON(time)	((time < 100) ? 0 :			\
> +				(time < 500) ? time/100-1 :		\
> +				(time < 3250) ? (time-500)/250+4 : 15)
> +
> +#define LEDBLNK_OFF(time)	((time < 1) ? 0x00 :			\
> +				(time < 500) ? 0x01 :			\
> +				(time < 5000) ? time/500 :		\
> +				(time < 8000) ? (time-5000)/1000+10 :	 \
> +				(time < 12000) ? (time-8000)/2000+13 : 15)

Make both static functions, if really needed, but these appear only in
one place, so maybe just code it directly.


> +
> +struct max77705_led {
> +	struct led_classdev cdev;
> +	struct regmap *regmap;
> +	unsigned int en_shift;
> +	unsigned int reg_brightness;
> +	unsigned int regB;

noCamelCase.

> +};
> +
> +static struct max77705_led *max77705_to_led(struct led_classdev *cdev)
> +{
> +	return container_of(cdev, struct max77705_led, cdev);
> +}
> +


> +		led = &leds[reg];
> +		led->regmap = map;
> +		led->reg_brightness = MAX77705_RGBLED_REG_LED0BRT + reg;
> +		led->en_shift = 2 * reg;
> +		led->cdev.brightness_set_blocking = max77705_led_brightness_set;
> +		led->cdev.blink_set = max77705_rgb_blink;
> +		led->cdev.max_brightness = MAX77705_LED_MAX_BRIGHTNESS;
> +
> +		init_data.fwnode = child;
> +		init_data.devicename = "max77705";
> +		/* for backwards compatibility if `label` is not present */
> +		init_data.default_label = ":";

There is no backwards compatibility - it's fresh driver.

> +
> +		rv = devm_led_classdev_register_ext(dev, &led->cdev,
> +							&init_data);
> +		if (rv)
> +			goto err_node_put;
> +
> +		rv = max77705_led_brightness_set(&led->cdev, LED_OFF);
> +		if (rv)
> +			goto err_node_put;
> +	}
> +
> +	return 0;
> +err_node_put:
> +	fwnode_handle_put(child);
> +	return rv;
> +}
> +
> +static const struct of_device_id max77705_led_of_match[] = {
> +	{ .compatible = "maxim,max77705-led" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, max77705_led_of_match);
> +
> +static struct platform_driver max77705_led_driver = {
> +	.driver = {
> +		.name = "max77705-led",
> +		.of_match_table = max77705_led_of_match,
> +	},
> +	.probe = max77705_led_probe,
> +};
> +module_platform_driver(max77705_led_driver);
> +
> +MODULE_DESCRIPTION("MAXIM 77705 LED driver");
> +MODULE_AUTHOR("Bartosz Golaszewski <bgolaszewski@baylibre.com>");
> +MODULE_AUTHOR("Dzmitry Sankouski <dsankouski@gmail.com>");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:max77705-led");

You should not need MODULE_ALIAS() in normal cases. If you need it,
usually it means your device ID table is wrong (e.g. misses either
entries or MODULE_DEVICE_TABLE()). MODULE_ALIAS() is not a substitute
for incomplete ID table.


Best regards,
Krzysztof


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

* Re: [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features
  2024-06-18 14:12   ` Konrad Dybcio
@ 2024-07-08 15:54     ` Dzmitry Sankouski
  2024-07-08 18:08       ` Konrad Dybcio
  0 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-07-08 15:54 UTC (permalink / raw)
  To: Konrad Dybcio
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Chanwoo Choi, phone-devel, linux-pm, linux-kernel, linux-arm-msm,
	linux-clk, dri-devel, devicetree, linux-input, linux-leds,
	linux-pwm, linux-samsung-soc

вт, 18 июн. 2024 г. в 17:12, Konrad Dybcio <konrad.dybcio@linaro.org>:
>
>
...
>
> >       gpio-reserved-ranges = <0 4>, <27 4>, <81 4>, <85 4>;
>
> Do you know what these are for?
>
> Konrad

<85 4> is spi for fingerprint.
<27 4> is spi for eSE(embedded Secure Element)
The rest shouldn't be reserved.

-- 

Best regards,
Dzmitry

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

* Re: [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features
  2024-07-08 15:54     ` Dzmitry Sankouski
@ 2024-07-08 18:08       ` Konrad Dybcio
  0 siblings, 0 replies; 62+ messages in thread
From: Konrad Dybcio @ 2024-07-08 18:08 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Krzysztof Kozlowski,
	Chanwoo Choi, phone-devel, linux-pm, linux-kernel, linux-arm-msm,
	linux-clk, dri-devel, devicetree, linux-input, linux-leds,
	linux-pwm, linux-samsung-soc

On 8.07.2024 5:54 PM, Dzmitry Sankouski wrote:
> вт, 18 июн. 2024 г. в 17:12, Konrad Dybcio <konrad.dybcio@linaro.org>:
>>
>>
> ...
>>
>>>       gpio-reserved-ranges = <0 4>, <27 4>, <81 4>, <85 4>;
>>
>> Do you know what these are for?
>>
>> Konrad
> 
> <85 4> is spi for fingerprint.
> <27 4> is spi for eSE(embedded Secure Element)
> The rest shouldn't be reserved.

Thanks for digging this up!

Please add a comment for it, like in x1e80100-crd.dts

Konrad

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

* Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks
  2024-06-18 19:11         ` Konrad Dybcio
  2024-06-19  6:31           ` Dmitry Baryshkov
@ 2024-07-19  9:01           ` Dzmitry Sankouski
  1 sibling, 0 replies; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-07-19  9:01 UTC (permalink / raw)
  To: Konrad Dybcio
  Cc: Dmitry Baryshkov, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König,
	Krzysztof Kozlowski, Chanwoo Choi, phone-devel, linux-pm,
	linux-kernel, linux-arm-msm, linux-clk, dri-devel, devicetree,
	linux-input, linux-leds, linux-pwm, linux-samsung-soc

Why cannot max values be defined as ((2 ^ mnd_width) - 1) and ((2 ^
hid_width) - 1)?

вт, 18 июн. 2024 г. в 22:12, Konrad Dybcio <konrad.dybcio@linaro.org>:
>
>
>
> On 6/18/24 20:55, Dmitry Baryshkov wrote:
> > On Tue, Jun 18, 2024 at 08:50:52PM GMT, Konrad Dybcio wrote:
> >>
> >>
> >> On 6/18/24 19:50, Dmitry Baryshkov wrote:
> >>> On Tue, Jun 18, 2024 at 04:59:36PM GMT, Dzmitry Sankouski wrote:
> >>>> sdm845 has "General Purpose" clocks that can be muxed to
> >>>> SoC pins.
> >>>>
> >>>> Those clocks may be used as e.g. PWM sources for external peripherals.
> >>>> Add more frequencies to the table for those clocks so it's possible
> >>>> for arbitrary peripherals to make use of them.
> >>>>
> >>>> See also: bf8bb8eaccf(clk: qcom: gcc-msm8916: Add rates to the GP clocks)
> >>>
> >>> Each time I look at the table attached to the GP CLK, I feel that it's
> >>> plain wrong. In the end the GPCLK can in theory have arbitrary value
> >>> depending on the usecase.
> >>>
> >>> Bjorn, Konrad, maybe we should add special clk_ops for GP CLK which
> >>> allow more flexibility than a default clk_rcg2_ops?
> >>
> >> If we can somehow get max m/n/d values for all possible parents, sure
> >
> > Calculate them at runtime?
>
> We'd be calculating the mnd values for a frequency that's either equal or
> reasonably close to the one requested. My worry is that we somehow need
> to get the maximum values they can take (unless they're well-known)
>
> Konrad

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

* Re: [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705
  2024-06-20 15:45   ` Krzysztof Kozlowski
@ 2024-09-13 14:51     ` Dzmitry Sankouski
  2024-09-13 16:47       ` Conor Dooley
  0 siblings, 1 reply; 62+ messages in thread
From: Dzmitry Sankouski @ 2024-09-13 14:51 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Sebastian Reichel, Bjorn Andersson, Michael Turquette,
	Stephen Boyd, Neil Armstrong, Jessica Zhang, Sam Ravnborg,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lee Jones, Dmitry Torokhov, Pavel Machek, Liam Girdwood,
	Mark Brown, Uwe Kleine-König, Konrad Dybcio, Chanwoo Choi,
	phone-devel, linux-pm, linux-kernel, linux-arm-msm, linux-clk,
	dri-devel, devicetree, linux-input, linux-leds, linux-pwm,
	linux-samsung-soc

чт, 20 июн. 2024 г. в 18:46, Krzysztof Kozlowski <krzk@kernel.org>:
>
> On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> > maxim,max77705 is MAX77705 pmic binding part
> >
> > Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> > ---
> >  .../devicetree/bindings/mfd/maxim,max77705.yaml    | 112 +++++++++++++++++++++
>
> Your patch order is totally messed. Not tested by automation. Only
> limited review follows.
>
Hmm, not sure what was wrong. I sent version 4 to myself with `b4 send
--reflect`, the order looks good.

-- 

Best regards,
Dzmitry

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

* Re: [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705
  2024-09-13 14:51     ` Dzmitry Sankouski
@ 2024-09-13 16:47       ` Conor Dooley
  0 siblings, 0 replies; 62+ messages in thread
From: Conor Dooley @ 2024-09-13 16:47 UTC (permalink / raw)
  To: Dzmitry Sankouski
  Cc: Krzysztof Kozlowski, Sebastian Reichel, Bjorn Andersson,
	Michael Turquette, Stephen Boyd, Neil Armstrong, Jessica Zhang,
	Sam Ravnborg, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Lee Jones, Dmitry Torokhov, Pavel Machek,
	Liam Girdwood, Mark Brown, Uwe Kleine-König, Konrad Dybcio,
	Chanwoo Choi, phone-devel, linux-pm, linux-kernel, linux-arm-msm,
	linux-clk, dri-devel, devicetree, linux-input, linux-leds,
	linux-pwm, linux-samsung-soc

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

On Fri, Sep 13, 2024 at 05:51:56PM +0300, Dzmitry Sankouski wrote:
> чт, 20 июн. 2024 г. в 18:46, Krzysztof Kozlowski <krzk@kernel.org>:
> >
> > On 18/06/2024 15:59, Dzmitry Sankouski wrote:
> > > maxim,max77705 is MAX77705 pmic binding part
> > >
> > > Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
> > > ---
> > >  .../devicetree/bindings/mfd/maxim,max77705.yaml    | 112 +++++++++++++++++++++
> >
> > Your patch order is totally messed. Not tested by automation. Only
> > limited review follows.
> >
> Hmm, not sure what was wrong. I sent version 4 to myself with `b4 send
> --reflect`, the order looks good.

I suspect that the order that he is referring to is not what you think,
and that the patches do appear in the order to him that they did to you,
but that order you committed changes is likely not bisectable due
dependencies coming after their users.

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

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

end of thread, other threads:[~2024-09-13 16:47 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-18 13:59 [PATCH v3 00/23] This is continued work on Samsung S9(SM-9600) starqltechn Dzmitry Sankouski
2024-06-18 13:59 ` [PATCH v3 01/23] power: supply: add undervoltage health status property Dzmitry Sankouski
2024-06-18 13:59 ` [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks Dzmitry Sankouski
2024-06-18 17:50   ` Dmitry Baryshkov
2024-06-18 18:50     ` Konrad Dybcio
2024-06-18 18:55       ` Dmitry Baryshkov
2024-06-18 19:11         ` Konrad Dybcio
2024-06-19  6:31           ` Dmitry Baryshkov
2024-07-19  9:01           ` Dzmitry Sankouski
2024-06-18 13:59 ` [PATCH v3 03/23] dt-bindings: panel: add Samsung s6e3ha8 Dzmitry Sankouski
2024-06-20 15:44   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705 Dzmitry Sankouski
2024-06-18 16:53   ` Rob Herring (Arm)
2024-06-20 15:45   ` Krzysztof Kozlowski
2024-09-13 14:51     ` Dzmitry Sankouski
2024-09-13 16:47       ` Conor Dooley
2024-06-18 13:59 ` [PATCH v3 05/23] dt-bindings: input: add maxim,max77705-haptic Dzmitry Sankouski
2024-06-20 15:47   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 06/23] dt-bindings: power: supply: add maxim,max77705 charger Dzmitry Sankouski
2024-06-20 15:47   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 07/23] dt-bindings: power: supply: add maxim,max77705 Dzmitry Sankouski
2024-06-18 16:53   ` Rob Herring (Arm)
2024-06-20 16:14   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 08/23] dt-bindings: led: add maxim,max77705-leds Dzmitry Sankouski
2024-06-18 13:59 ` [PATCH v3 09/23] dt-bindings: mfd: add samsung,s2dos05 Dzmitry Sankouski
2024-06-18 16:53   ` Rob Herring (Arm)
2024-06-20 15:49   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 10/23] dt-bindings: regulator: " Dzmitry Sankouski
2024-06-20 15:51   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver Dzmitry Sankouski
2024-06-18 18:39   ` Dmitry Baryshkov
2024-06-19 13:27     ` Dzmitry Sankouski
2024-06-20 20:13       ` Dmitry Baryshkov
2024-06-18 13:59 ` [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC Dzmitry Sankouski
2024-06-20 16:02   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 13/23] input: add max77705 haptic driver Dzmitry Sankouski
2024-06-20 16:04   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 14/23] power: supply: max77705: Add charger driver for Maxim 77705 Dzmitry Sankouski
2024-06-20 16:06   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 15/23] power: supply: max77705: Add fuel gauge " Dzmitry Sankouski
2024-06-18 13:59 ` [PATCH v3 16/23] leds: max77705: Add LEDs support Dzmitry Sankouski
2024-06-20 20:14   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 17/23] mfd: add s2dos series core driver Dzmitry Sankouski
2024-06-20 16:07   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 18/23] regulator: add s2dos05 regulator support Dzmitry Sankouski
2024-06-18 14:08   ` Mark Brown
2024-06-19 15:49     ` Dzmitry Sankouski
2024-06-19 15:52       ` Mark Brown
2024-06-20 16:08   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 19/23] power: supply: s2dos05: Add fuel gauge driver for s2dos05 Dzmitry Sankouski
2024-06-20 16:11   ` Krzysztof Kozlowski
2024-06-18 13:59 ` [PATCH v3 20/23] arm64: dts: qcom: starqltechn: remove wifi Dzmitry Sankouski
2024-06-18 14:06   ` Konrad Dybcio
2024-06-18 13:59 ` [PATCH v3 21/23] arm64: dts: qcom: starqltechn: remove framebuffer Dzmitry Sankouski
2024-06-18 14:06   ` Konrad Dybcio
2024-06-18 13:59 ` [PATCH v3 22/23] arm64: dts: qcom: starqltechn: fix usb regulator mistake Dzmitry Sankouski
2024-06-18 14:07   ` Konrad Dybcio
2024-06-18 14:16     ` Dzmitry Sankouski
2024-06-18 13:59 ` [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features Dzmitry Sankouski
2024-06-18 14:12   ` Konrad Dybcio
2024-07-08 15:54     ` Dzmitry Sankouski
2024-07-08 18:08       ` Konrad Dybcio

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).