Skip to contentSkip to conversation

This is continued work on Samsung S9(SM-9600) starqltechn

PATCH Superseded Dzmitry Sankouski 9 participants 68 messages Jun 18, 2024 – Sep 13, 2024

Subsystems (19)

v3 of 17 Superseded Latest is v17 →

lore
Share & tools
lore

Dzmitry Sankouski

author maintainer
#0 lore raw

v3 cover This is continued work on Samsung S9(SM-9600) starqltechn

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.

---
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,

Signature · 1 line
Dzmitry Sankouski <[email protected]>
author maintainer
#1 lore raw

PATCH v3 1/23 power: supply: add undervoltage health status property

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

---
 include/linux/power_supply.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/power_supply.h +1 -0
index 65082ef75692..0f82a5c0ccf4 100644
@@ -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,
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH v3 2/23 gcc-sdm845: Add rates to the GP clocks

In reply to 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)

---
 drivers/clk/qcom/gcc-sdm845.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/clk/qcom/gcc-sdm845.c +14 -0
index ea4c3bf4fb9b..0efd3364e8f5 100644
@@ -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),
Signature · 1 line
2.39.2
#3 lore raw

Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks

Quoted 8 lines · 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)

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?

Quoted 36 lines
---
 drivers/clk/qcom/gcc-sdm845.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/clk/qcom/gcc-sdm845.c +14 -0
index ea4c3bf4fb9b..0efd3364e8f5 100644
@@ -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),
Signature · 2 lines
-- 
2.39.2
Signature · 2 lines
With best wishes
Dmitry
#4 lore raw

Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks

Quoted 8 lines · Dmitry Baryshkov
Quoted 7 lines · 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.

Quoted 8 lines
Quoted 1 line

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

#5 lore raw

Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks

Quoted 13 lines · Konrad Dybcio
Quoted 10 lines · Dmitry Baryshkov
Quoted 8 lines · 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)

Quoted 8 lines
Quoted 6 lines

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?

Signature · 2 lines
With best wishes
Dmitry
#6 lore raw

Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks

Quoted 18 lines · Dmitry Baryshkov
Quoted 17 lines · Konrad Dybcio
Quoted 14 lines · Dmitry Baryshkov
Quoted 8 lines · 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)

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.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

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

#7 lore raw

Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks

Quoted 24 lines · Konrad Dybcio
Quoted 21 lines · Dmitry Baryshkov
Quoted 20 lines · Konrad Dybcio
Quoted 16 lines · Dmitry Baryshkov
Quoted 8 lines · 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)

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?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

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.

Signature · 2 lines
With best wishes
Dmitry
author maintainer
#8 lore raw

Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks

This is Proof-of-concept for general purpose clock ops. It's purpose is to eliminate the need of freq_tbl for general purpose clock, by runtime m/n/hid_div(pre-divisor) calculation. The calculation done as follows:
- upon determine rate request, we calculate m/n/hid_div as follows:
- find parent(from our client's assigned-clock-parent) rate
- find requested rate - parent rate highest common factor
- find scaled rates by dividing rates on highest common factor
- assign requested scaled rate to m
- factorize scaled parent rate, put even multipliers to hid_div, odd to n (to maintain approximately same hid_div and n width)
- validate calculated values with *_width:
- if doesn't fit, shift right accordingly
- return determined rate

In this POC, pwm-clk driver requests assigned-clock-parent with the call of assigned-clock-parent function, so GP clocks don't need to configure parent. __clk_rcg2_configure is therefore divided to __clk_rcg2_configure_parent and __clk_rcg2_configure_mnd to reuse code.

SDM845 has "General Purpose" clocks that can be muxed to SoC pins to clock various external devices.
Those clocks may be used as e.g. PWM sources for external peripherals.

GPCLK can in theory have arbitrary value depending on the use case, so the concept of frequency tables, used in rcg2 clock driver, is not efficient, because it allows only defined frequencies.

Introduce clk_rcg2_gp_ops, which automatically calculate clock mnd values for arbitrary clock rate.

---

 drivers/clk/qcom/clk-rcg.h    |   1 +
 drivers/clk/qcom/clk-rcg2.c   | 162 ++++++++++++++++++++++++++++++++--
 drivers/clk/qcom/gcc-sdm845.c |  12 ++-
 drivers/pwm/pwm-clk.c         |   5 ++
 4 files changed, 167 insertions(+), 13 deletions(-)
drivers/clk/qcom/clk-rcg.h +1 -0
index d7414361e432..5bd86bce0c4d 100644
@@ -189,6 +189,7 @@ struct clk_rcg2_gfx3d {
 	container_of(to_clk_rcg2(_hw), struct clk_rcg2_gfx3d, rcg)
 
 extern const struct clk_ops clk_rcg2_ops;
+extern const struct clk_ops clk_rcg2_gp_ops;
 extern const struct clk_ops clk_rcg2_floor_ops;
 extern const struct clk_ops clk_rcg2_fm_ops;
 extern const struct clk_ops clk_rcg2_mux_closest_ops;
drivers/clk/qcom/clk-rcg2.c +156 -6

211 lines not on this page · raw message

drivers/clk/qcom/gcc-sdm845.c +5 -7
index dc3aa7014c3e..4567f405683b 100644
@@ -285,10 +285,8 @@ static struct clk_rcg2 gcc_sdm670_cpuss_rbcpr_clk_src = {
 
 static const struct freq_tbl ftbl_gcc_gp1_clk_src[] = {
 	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),
-	F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0),
-	F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
+	F(300000000, P_GPLL0_OUT_EVEN, 1, 0, 0),
+	F(600000000, P_GPLL0_OUT_MAIN, 1, 0, 0),
 	{ }
 };
 
@@ -302,7 +300,7 @@ static struct clk_rcg2 gcc_gp1_clk_src = {
 		.name = "gcc_gp1_clk_src",
 		.parent_data = gcc_parent_data_1,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_1),
-		.ops = &clk_rcg2_ops,
+		.ops = &clk_rcg2_gp_ops,
 	},
 };
 
@@ -316,7 +314,7 @@ static struct clk_rcg2 gcc_gp2_clk_src = {
 		.name = "gcc_gp2_clk_src",
 		.parent_data = gcc_parent_data_1,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_1),
-		.ops = &clk_rcg2_ops,
+		.ops = &clk_rcg2_gp_ops,
 	},
 };
 
@@ -330,7 +328,7 @@ static struct clk_rcg2 gcc_gp3_clk_src = {
 		.name = "gcc_gp3_clk_src",
 		.parent_data = gcc_parent_data_1,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_1),
-		.ops = &clk_rcg2_ops,
+		.ops = &clk_rcg2_gp_ops,
 	},
 };
 
drivers/pwm/pwm-clk.c +5 -0
index c19a482d7e28..1bfc7870e3aa 100644
@@ -25,6 +25,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/clk/clk-conf.h>
 #include <linux/pwm.h>
 
 struct pwm_clk_chip {
@@ -87,6 +88,10 @@ static int pwm_clk_probe(struct platform_device *pdev)
 	struct pwm_clk_chip *pcchip;
 	int ret;
 
+	ret = of_clk_set_defaults(pdev->dev.of_node, false);
+	if (ret < 0)
+		return -EINVAL;
+
 	chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*pcchip));
 	if (IS_ERR(chip))
 		return PTR_ERR(chip);
Signature · 1 line
2.39.2
maintainer
#9 lore raw

Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks

Quoting Dzmitry Sankouski (2024-08-12 08:16:06)

Quoted 17 lines
drivers/clk/qcom/clk-rcg2.c +1 -1
index 30b19bd39d08..44b257481556 100644
@@ -32,6 +32,7 @@
 
 #define CFG_REG                        0x4
 #define CFG_SRC_DIV_SHIFT      0
+#define CFG_SRC_DIV_LENGTH     8
 #define CFG_SRC_SEL_SHIFT      8
 #define CFG_SRC_SEL_MASK       (0x7 << CFG_SRC_SEL_SHIFT)
 #define CFG_MODE_SHIFT         12
@@ -393,16 +394,103 @@ static int clk_rcg2_fm_determine_rate(struct clk_hw *hw,
        return _freq_tbl_fm_determine_rate(hw, rcg->freq_multi_tbl, req);
 }
 
-static int __clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f,

drivers/clk/qcom/clk-rcg2.c static int clk_rcg2_fm_determine_rate(struct clk_hw *hw, · line 405

Quoted 10 lines
drivers/clk/qcom/clk-rcg2.c +9 -1
-                               u32 *_cfg)
+static inline u64 find_hcf(u64 a, u64 b)
+{
+       while (a != 0 && b != 0) {
+               if (a > b)
+                       a %= b;
+               else
+                       b %= a;
+       }
+       return a + b;

Is this gcd()?

Quoted 34 lines
drivers/clk/qcom/clk-rcg2.c +34 -0
+}
+
+static int clk_calc_mnd(u64 parent_rate, u64 rate, struct freq_tbl *f)
+{
+       u64 hcf;
+       u64 hid_div = 1, n = 1;
+       int i = 2, count = 0;
+
+       hcf = find_hcf(parent_rate, rate);
+       u64 scaled_rate = rate / hcf;
+       u64 scaled_parent_rate = parent_rate / hcf;
+
+       while (scaled_parent_rate > 1) {
+               while (scaled_parent_rate % i == 0) {
+                       scaled_parent_rate /= i;
+                       if (count % 2 == 0)
+                               hid_div *= i;
+                       else
+                               n *= i;
+               }
+               i++;
+               count++;
+       }
+
+       f->m = scaled_rate;
+       f->n = n;
+       f->pre_div = hid_div;
+
+       return 0;
+}
+
+static int clk_rcg2_determine_gp_rate(struct clk_hw *hw,
+                                  struct clk_rate_request *req)
+{

drivers/clk/qcom/clk-rcg2.c static int clk_rcg2_fm_determine_rate(struct clk_hw *hw, · line 449

Quoted 10 lines
drivers/clk/qcom/clk-rcg2.c +10 -0
+       struct clk_rcg2 *rcg = to_clk_rcg2(hw);
+       struct freq_tbl *f;
+       int src = clk_rcg2_get_parent(hw);
+       int mnd_max = BIT(rcg->mnd_width) - 1;
+       int hid_max = BIT(rcg->hid_width) - 1;
+       u64 parent_rate;
+       int ret;
+
+       parent_rate = rcg->freq_tbl[src].freq;
+       f = kcalloc(MAX_PERF_LEVEL + 1, sizeof(f), GFP_KERNEL);

When is this freed? Determine rate can be called many times. Is that supposed to be sizeof(*f)? Why so many frequency entries?

Quoted 14 lines
drivers/clk/qcom/clk-rcg2.c +14 -0
+
+       if (!f)
+               return 0;
+
+       ret = clk_calc_mnd(parent_rate, req->rate, f);
+       if (ret)
+               return 0;
+
+
+       while (f->n - f->m >= mnd_max) {
+               f->m = f->m >> 1;
+               f->n = f->n >> 1;
+       }
+       while (f->pre_div >= hid_max) {

drivers/clk/qcom/clk-rcg2.c static int clk_rcg2_fm_determine_rate(struct clk_hw *hw, · line 473

Quoted 10 lines
drivers/clk/qcom/clk-rcg2.c +10 -0
+               f->pre_div = f->pre_div >> 1;
+               f->m = f->m >> 1;
+       }
+
+       req->rate = calc_rate(parent_rate, f->m, f->n, f->n, f->pre_div);
+
+       return 0;
+}
+
+static int __clk_rcg2_configure_parent(struct clk_rcg2 *rcg, int src, u32 *_cfg)

u8 src? Good to keep types consistent.

Quoted 87 lines
drivers/clk/qcom/clk-rcg2.c +51 -4
 {
-       u32 cfg, mask, d_val, not2d_val, n_minus_m;
        struct clk_hw *hw = &rcg->clkr.hw;
-       int ret, index = qcom_find_src_index(hw, rcg->parent_map, f->src);
+       u32 mask = CFG_SRC_SEL_MASK;
+       int index = qcom_find_src_index(hw, rcg->parent_map, src);
 
        if (index < 0)
                return index;
 
+       *_cfg &= ~mask;
+       *_cfg |= rcg->parent_map[index].cfg << CFG_SRC_SEL_SHIFT;
+
+       return 0;
+}
+
+static int __clk_rcg2_configure_mnd(struct clk_rcg2 *rcg, const struct freq_tbl *f,
+                               u32 *_cfg)
+{
+       u32 cfg, mask, d_val, not2d_val, n_minus_m;
+       int ret;
+
        if (rcg->mnd_width && f->n) {
                mask = BIT(rcg->mnd_width) - 1;
                ret = regmap_update_bits(rcg->clkr.regmap,
@@ -431,9 +519,8 @@ static int __clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f,
        }
 
        mask = BIT(rcg->hid_width) - 1;
-       mask |= CFG_SRC_SEL_MASK | CFG_MODE_MASK | CFG_HW_CLK_CTRL_MASK;
+       mask |= CFG_MODE_MASK | CFG_HW_CLK_CTRL_MASK;
        cfg = f->pre_div << CFG_SRC_DIV_SHIFT;
-       cfg |= rcg->parent_map[index].cfg << CFG_SRC_SEL_SHIFT;
        if (rcg->mnd_width && f->n && (f->m != f->n))
                cfg |= CFG_MODE_DUAL_EDGE;
        if (rcg->hw_clk_ctrl)
@@ -445,6 +532,22 @@ static int __clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f,
        return 0;
 }
 
+static int __clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f,
+                               u32 *_cfg)
+{
+       int ret;
+
+       ret = __clk_rcg2_configure_parent(rcg, f->src, _cfg);
+       if (ret)
+               return ret;
+
+       ret = __clk_rcg2_configure_mnd(rcg, f, _cfg);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
 static int clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f)
 {
        u32 cfg;
@@ -465,6 +568,26 @@ static int clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f)
        return update_config(rcg);
 }
 
+static int clk_rcg2_configure_gp(struct clk_rcg2 *rcg, const struct freq_tbl *f)
+{
+       u32 cfg;
+       int ret;
+
+       ret = regmap_read(rcg->clkr.regmap, RCG_CFG_OFFSET(rcg), &cfg);
+       if (ret)
+               return ret;
+
+       ret = __clk_rcg2_configure_mnd(rcg, f, &cfg);
+       if (ret)
+               return ret;
+
+       ret = regmap_write(rcg->clkr.regmap, RCG_CFG_OFFSET(rcg), cfg);
+       if (ret)
+               return ret;
+
+       return update_config(rcg);
+}
+
 static int __clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate,
                               enum freq_policy policy)
 {

drivers/clk/qcom/clk-rcg2.c static int clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate, · line 650

Quoted 10 lines
drivers/clk/qcom/clk-rcg2.c +7 -0
@@ -518,6 +641,22 @@ static int clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate,
        return __clk_rcg2_set_rate(hw, rate, CEIL);
 }
 
+static int clk_rcg2_set_gp_rate(struct clk_hw *hw, unsigned long rate,
+                           unsigned long parent_rate)
+{
+       struct clk_rcg2 *rcg = to_clk_rcg2(hw);
+       struct freq_tbl *f;
+
+       f = kcalloc(MAX_PERF_LEVEL + 1, sizeof(*f), GFP_KERNEL);

When is this freed?

Quoted 43 lines
drivers/clk/qcom/clk-rcg2.c +20 -0
+
+       if (!f)
+               return -ENOMEM;
+
+       clk_calc_mnd(parent_rate, rate, f);
+
+       return clk_rcg2_configure_gp(rcg, f);
+}
+
 static int clk_rcg2_set_floor_rate(struct clk_hw *hw, unsigned long rate,
                                   unsigned long parent_rate)
 {
@@ -645,6 +784,17 @@ const struct clk_ops clk_rcg2_ops = {
 };
 EXPORT_SYMBOL_GPL(clk_rcg2_ops);
 
+const struct clk_ops clk_rcg2_gp_ops = {
+       .is_enabled = clk_rcg2_is_enabled,
+       .get_parent = clk_rcg2_get_parent,
+       .set_parent = clk_rcg2_set_parent,
+       .determine_rate = clk_rcg2_determine_gp_rate,
+       .set_rate = clk_rcg2_set_gp_rate,
+       .get_duty_cycle = clk_rcg2_get_duty_cycle,
+       .set_duty_cycle = clk_rcg2_set_duty_cycle,
+};
+EXPORT_SYMBOL_GPL(clk_rcg2_gp_ops);
+
 const struct clk_ops clk_rcg2_floor_ops = {
        .is_enabled = clk_rcg2_is_enabled,
        .get_parent = clk_rcg2_get_parent,
drivers/pwm/pwm-clk.c +1 -0
index c19a482d7e28..1bfc7870e3aa 100644
@@ -25,6 +25,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/clk/clk-conf.h>
 #include <linux/pwm.h>
 
 struct pwm_clk_chip {

drivers/pwm/pwm-clk.c static int pwm_clk_probe(struct platform_device *pdev) · line 94

Quoted 7 lines
drivers/pwm/pwm-clk.c +4 -0
@@ -87,6 +88,10 @@ static int pwm_clk_probe(struct platform_device *pdev)
        struct pwm_clk_chip *pcchip;
        int ret;
 
+       ret = of_clk_set_defaults(pdev->dev.of_node, false);
+       if (ret < 0)
+               return -EINVAL;
+

What is this? Debug code?

Quoted 7 lines
drivers/pwm/pwm-clk.c +0 -0
        chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*pcchip));
        if (IS_ERR(chip))
                return PTR_ERR(chip);
Signature · 1 line
2.39.2
author maintainer
#10 lore raw

Re: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks

In reply to Konrad Dybcio

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

вт, 18 июн. 2024 г. в 22:12, Konrad Dybcio <[email protected]>:

Quoted 34 lines · Dmitry Baryshkov
Quoted 18 lines · Konrad Dybcio
Quoted 17 lines · Dmitry Baryshkov
Quoted 14 lines · Dzmitry Sankouski
Quoted 8 lines

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.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

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

author maintainer
#11 lore raw

PATCH v3 3/23 dt-bindings: panel: add Samsung s6e3ha8

In reply to Dzmitry Sankouski

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

---
 .../bindings/display/panel/samsung,s6e3ha8.yaml    | 76 ++++++++++++++++++++++
 MAINTAINERS                                        |  5 ++
 2 files changed, 81 insertions(+)
Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml new file +76 -0
new file mode 100644
index 000000000000..9d7d747264dd
@@ -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 <[email protected]>
+
+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>;
+      		};
+      	};
+      };
+    };
+
+...
MAINTAINERS +5 -0
index a2f416e4a7c6..fddbd50f7685 100644
@@ -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 <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml
+
 DRM DRIVER FOR SITRONIX ST7586 PANELS
 M:	David Lechner <[email protected]>
 S:	Maintained
Signature · 1 line
2.39.2
#12 lore raw

Re: [PATCH v3 03/23] dt-bindings: panel: add Samsung s6e3ha8

Quoted 30 lines · Dzmitry Sankouski

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

---
 .../bindings/display/panel/samsung,s6e3ha8.yaml    | 76 ++++++++++++++++++++++
 MAINTAINERS                                        |  5 ++
 2 files changed, 81 insertions(+)
Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml new file +16 -0
new file mode 100644
index 000000000000..9d7d747264dd
@@ -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 <[email protected]>
+
+allOf:
+  - $ref: panel-common.yaml#

Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml line 26

Quoted 10 lines
Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml new file +10 -0
+
+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.

Quoted 22 lines
Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml new file +22 -0
+
+  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:

Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml line 58

Quoted 10 lines
Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml new file +10 -0
+  - |
+    #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

author maintainer
#13 lore raw

PATCH v3 4/23 dt-bindings: mfd: add maxim,max77705

In reply to Dzmitry Sankouski

maxim,max77705 is MAX77705 pmic binding part

---
 .../devicetree/bindings/mfd/maxim,max77705.yaml    | 112 +++++++++++++++++++++
 MAINTAINERS                                        |   1 +
 2 files changed, 113 insertions(+)
Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file +112 -0
new file mode 100644
index 000000000000..b54408e3d792
@@ -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 <[email protected]>
+
+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>;
+    		};
+    	};
+    };
MAINTAINERS +1 -0
index fddbd50f7685..f008429033c9 100644
@@ -13682,6 +13682,7 @@ B:	mailto:[email protected]
 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
Signature · 1 line
2.39.2
#14 lore raw

Re: [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705

Quoted 8 lines · Dzmitry Sankouski

maxim,max77705 is MAX77705 pmic binding part

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

#15 lore raw

Re: [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705

In reply to Dzmitry Sankouski
Quoted 5 lines · Dzmitry Sankouski

maxim,max77705 is MAX77705 pmic binding part

---
 .../devicetree/bindings/mfd/maxim,max77705.yaml    | 112 +++++++++++++++++++++

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

Quoted 23 lines
 MAINTAINERS                                        |   1 +
 2 files changed, 113 insertions(+)
Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file +14 -0
new file mode 100644
index 000000000000..b54408e3d792
@@ -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 <[email protected]>
+
+description: |
+  This is a part of device tree bindings for Maxim MAX77705 multi functional device.
+

Documentation/devicetree/bindings/mfd/maxim,max77705.yaml line 24

Quoted 10 lines
Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file +10 -0
+  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.

Documentation/devicetree/bindings/mfd/maxim,max77705.yaml line 34

Quoted 10 lines
Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file +10 -0
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-names:
+    description:
+      MAX77705 shared irq.
+    items:
+      - const: max77705_irq

Drop entire property, not really useful.

Quoted 15 lines
Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file +15 -0
+
+  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:

Documentation/devicetree/bindings/mfd/maxim,max77705.yaml line 59

Quoted 10 lines
Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file +10 -0
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/leds/common.h>
+
+    i2c14 {

i2c

Documentation/devicetree/bindings/mfd/maxim,max77705.yaml line 65

Quoted 6 lines
Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file +6 -0
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+    	pmic@66 {
+    		compatible = "maxim,max77705";
+    		reg = <0x66>;

Totally messed indentation. Fix your code.

Best regards,
Krzysztof

author maintainer
#16 lore raw

Re: [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705

чт, 20 июн. 2024 г. в 18:46, Krzysztof Kozlowski <[email protected]>:

Quoted 11 lines · Dzmitry Sankouski
Quoted 5 lines

maxim,max77705 is MAX77705 pmic binding part

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

Signature · 2 lines
Best regards,
Dzmitry
#17 lore raw

Re: [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705

Quoted 9 lines · Dzmitry Sankouski

чт, 20 июн. 2024 г. в 18:46, Krzysztof Kozlowski <[email protected]>:

Quoted 8 lines · Dzmitry Sankouski
Quoted 5 lines

maxim,max77705 is MAX77705 pmic binding part

---
 .../devicetree/bindings/mfd/maxim,max77705.yaml    | 112 +++++++++++++++++++++
Quoted 5 lines
Quoted 3 lines

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.

author maintainer
#18 lore raw

PATCH v3 5/23 dt-bindings: input: add maxim,max77705-haptic

In reply to Dzmitry Sankouski

maxim,max77705-haptic is MAX77705 pmic binding part

---
 .../devicetree/bindings/input/maxim,max77705.yaml  | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
Documentation/devicetree/bindings/input/maxim,max77705.yaml new file +31 -0
new file mode 100644
index 000000000000..8f065a2fe7bd
@@ -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 <[email protected]>
+
+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
Signature · 1 line
2.39.2
#19 lore raw

Re: [PATCH v3 05/23] dt-bindings: input: add maxim,max77705-haptic

Documentation/devicetree/bindings/input/maxim,max77705.yaml line 13

Quoted 10 lines · Dzmitry Sankouski

maxim,max77705-haptic is MAX77705 pmic binding part

Documentation/devicetree/bindings/input/maxim,max77705.yaml new file +6 -0
+
+maintainers:
+  - Dzmitry Sankouski <[email protected]>
+
+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.

Documentation/devicetree/bindings/input/maxim,max77705.yaml line 24

Quoted 11 lines
Documentation/devicetree/bindings/input/maxim,max77705.yaml new file +11 -0
+
+  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

author maintainer
#20 lore raw

PATCH v3 6/23 dt-bindings: power: supply: add maxim,max77705 charger

In reply to Dzmitry Sankouski

add maxim,max77705 charger binding part

---
 .../power/supply/maxim,max77705-charger.yaml       | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)
Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml new file +30 -0
new file mode 100644
index 000000000000..2b805da2a328
@@ -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 <[email protected]>
+
+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
+
+...
Signature · 1 line
2.39.2
#21 lore raw

Re: [PATCH v3 06/23] dt-bindings: power: supply: add maxim,max77705 charger

Quoted 1 line · Dzmitry Sankouski

add maxim,max77705 charger binding part

Make it a proper sentence.

Quoted 25 lines
---
 .../power/supply/maxim,max77705-charger.yaml       | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)
Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml new file +13 -0
new file mode 100644
index 000000000000..2b805da2a328
@@ -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 <[email protected]>
+
+description: |
+  This is a part of device tree bindings for Maxim MAX77705 multi functional device.

Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml line 23

Quoted 10 lines
Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml new file +10 -0
+
+  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

author maintainer
#22 lore raw

PATCH v3 7/23 dt-bindings: power: supply: add maxim,max77705

In reply to Dzmitry Sankouski

add maxim,max77705 fuel gauge binding part

---
 .../bindings/power/supply/maxim,max77705-fg.yaml   | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml new file +35 -0
new file mode 100644
index 000000000000..b24db0aba0d7
@@ -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 <[email protected]>
+
+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
Signature · 1 line
2.39.2
#23 lore raw

Re: [PATCH v3 07/23] dt-bindings: power: supply: add maxim,max77705

Quoted 7 lines · Dzmitry Sankouski

add maxim,max77705 fuel gauge binding part

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

#24 lore raw

Re: [PATCH v3 07/23] dt-bindings: power: supply: add maxim,max77705

In reply to Dzmitry Sankouski
Quoted 31 lines · Dzmitry Sankouski

add maxim,max77705 fuel gauge binding part

---
 .../bindings/power/supply/maxim,max77705-fg.yaml   | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml new file +18 -0
new file mode 100644
index 000000000000..b24db0aba0d7
@@ -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 <[email protected]>
+
+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.

Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml line 28

Quoted 10 lines
Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml new file +10 -0
+
+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

Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml line 30

Quoted 2 lines
Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml new file +2 -0
+    description: |
+      Sense resistor value in mOhm

Merge the node into parent node. No resources here.

Best regards,
Krzysztof

author maintainer
#25 lore raw

PATCH v3 8/23 dt-bindings: led: add maxim,max77705-leds

In reply to Dzmitry Sankouski

add maxim,max77705 leds binding part

---
 .../devicetree/bindings/leds/maxim,max77705.yaml   | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)
Documentation/devicetree/bindings/leds/maxim,max77705.yaml new file +45 -0
new file mode 100644
index 000000000000..7c512545788a
@@ -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 <[email protected]>
+
+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
Signature · 1 line
2.39.2
author maintainer
#26 lore raw

PATCH v3 9/23 dt-bindings: mfd: add samsung,s2dos05

In reply to Dzmitry Sankouski

add samsung,s2dos05 core MFD module binding

---
 .../devicetree/bindings/mfd/samsung,s2dos05.yaml   | 89 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 90 insertions(+)
Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml new file +89 -0
new file mode 100644
index 000000000000..f2ef5171cc40
@@ -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 <[email protected]>
+
+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>;
+      		};
+      	};
+      };
+    };
+
+...
MAINTAINERS +1 -0
index f008429033c9..3ab41e53c9fc 100644
@@ -19897,6 +19897,7 @@ L:	[email protected]
 S:	Maintained
 B:	mailto:[email protected]
 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
Signature · 1 line
2.39.2
#27 lore raw

Re: [PATCH v3 09/23] dt-bindings: mfd: add samsung,s2dos05

Quoted 8 lines · Dzmitry Sankouski

add samsung,s2dos05 core MFD module binding

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

#28 lore raw

Re: [PATCH v3 09/23] dt-bindings: mfd: add samsung,s2dos05

In reply to Dzmitry Sankouski
Quoted 18 lines · Dzmitry Sankouski

add samsung,s2dos05 core MFD module binding

---
 .../devicetree/bindings/mfd/samsung,s2dos05.yaml   | 89 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 90 insertions(+)
Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml new file +4 -0
new file mode 100644
index 000000000000..f2ef5171cc40
@@ -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#

Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml line 14

Quoted 10 lines
Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml new file +10 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Samsung S2DOS05 Power Management IC
+
+maintainers:
+  - Dzmitry Sankouski <[email protected]>
+
+description:
+  This is a part of device tree bindings for S2M and S5M family of Power
+  Management IC (PMIC).

No, it is not.

Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml line 22

Quoted 8 lines
Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml new file +8 -0
+
+  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.

Quoted 16 lines
Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml new file +16 -0
+
+  reg:
+    maxItems: 1
+
+  regulators:
+    $ref: /schemas/regulator/samsung,s2dos05.yaml
+    description: List of regulators and its properties
+
+required:
+  - compatible
+  - reg
+  - regulators
+
+additionalProperties: false
+
+examples:

Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml line 48

Quoted 10 lines
Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml new file +10 -0
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      pmic@60 {
+      	compatible = "samsung,s2dos05";
+      	reg = <0x60>;
+
+      	regulators {

Messed indentation. Everywhere, each of your patch.

Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml line 49

Quoted 1 line
Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml new file +1 -0
+      		s2dos05_ldo1: s2dos05-ldo1 {

Just "ldo1" and drop unused labels.

Best regards,
Krzysztof

author maintainer
#29 lore raw

PATCH v3 10/23 dt-bindings: regulator: add samsung,s2dos05

In reply to Dzmitry Sankouski

add samsung,s2dos05 regulator binding part

---
 .../bindings/regulator/samsung,s2dos05.yaml        | 36 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 37 insertions(+)
Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml new file +36 -0
new file mode 100644
index 000000000000..4b8e4389329c
@@ -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 <[email protected]>
+
+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
+
+...
MAINTAINERS +1 -0
index 3ab41e53c9fc..92a5d0a56353 100644
@@ -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
Signature · 1 line
2.39.2
#30 lore raw

Re: [PATCH v3 10/23] dt-bindings: regulator: add samsung,s2dos05

Quoted 1 line · Dzmitry Sankouski

add samsung,s2dos05 regulator binding part

Make it a proper sentence.

Quoted 17 lines
---
 .../bindings/regulator/samsung,s2dos05.yaml        | 36 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 37 insertions(+)
Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml new file +4 -0
new file mode 100644
index 000000000000..4b8e4389329c
@@ -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#

Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml line 14

Quoted 10 lines
Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml new file +10 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Samsung S2DOS05 Power Management IC Regulators
+
+maintainers:
+  - Dzmitry Sankouski <[email protected]>
+
+description:
+  This is a part of device tree bindings for S2M and S5M family of Power
+  Management IC (PMIC).

No, it's not.

Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml line 23

Quoted 9 lines
Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml new file +9 -0
+
+  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.

Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml line 26

Quoted 3 lines
Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml new file +3 -0
+
+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

author maintainer
#31 lore raw

PATCH v3 11/23 drm/panel: Add support for S6E3HA8 panel driver

In reply to 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.

---
 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(+)
MAINTAINERS +1 -0
index 92a5d0a56353..fae3b8ea9ce4 100644
@@ -7154,6 +7154,7 @@ DRM DRIVER FOR SAMSUNG S6E3HA8 PANELS
 M:	Dzmitry Sankouski <[email protected]>
 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 <[email protected]>
drivers/gpu/drm/panel/Kconfig +7 -0
index 2ae0eb0638f3..903fc8c155c0 100644
@@ -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
drivers/gpu/drm/panel/Makefile +1 -0
index f0203f6e02f4..71774cc5820a 100644
@@ -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
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +426 -0

426 lines not on this page · raw message

Signature · 1 line
2.39.2
#32 lore raw

Re: [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver

Quoted 89 lines · 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.

---
 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(+)
MAINTAINERS +1 -0
index 92a5d0a56353..fae3b8ea9ce4 100644
@@ -7154,6 +7154,7 @@ DRM DRIVER FOR SAMSUNG S6E3HA8 PANELS
 M:	Dzmitry Sankouski <[email protected]>
 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 <[email protected]>
drivers/gpu/drm/panel/Kconfig +7 -0
index 2ae0eb0638f3..903fc8c155c0 100644
@@ -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
drivers/gpu/drm/panel/Makefile +1 -0
index f0203f6e02f4..71774cc5820a 100644
@@ -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
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +28 -0
new file mode 100644
index 000000000000..49d629643171
@@ -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 <[email protected]>
+ */
+
+#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

drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c line 38

Quoted 10 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +10 -0
+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.

drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c line 45

Quoted 7 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +7 -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;

Ugh. So which return is it?

Quoted 2 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +2 -0
+}
+

[...]

drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c line 96

Quoted 5 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +5 -0
+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.

Quoted 27 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +27 -0
+	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;
+

drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c line 133

Quoted 10 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +10 -0
+	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?

Quoted 129 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +129 -0
+
+	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) {

drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c line 272

Quoted 10 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +10 -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?

Quoted 36 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +36 -0
+
+
+	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;
+

drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c line 318

Quoted 10 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +10 -0
+	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()

Quoted 4 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +4 -0
+
+	return 1;
+}
+
Signature · 2 lines
With best wishes
Dmitry
author maintainer
#33 lore raw

Re: [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver

вт, 18 июн. 2024 г. в 21:39, Dmitry Baryshkov <[email protected]>:

Quoted 9 lines

drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c line 133

Quoted 6 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +5 -0
+     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

#34 lore raw

Re: [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver

Quoted 8 lines · Dzmitry Sankouski

вт, 18 июн. 2024 г. в 21:39, Dmitry Baryshkov <[email protected]>:

Quoted 7 lines
Quoted 6 lines
drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file +5 -0
+     ret = mipi_dsi_compression_mode(dsi, true);
+     if (ret < 0) {
+             dev_err(dev, "Failed to set compression mode: %d\n", ret);
+             return ret;
+     }
Quoted 4 lines
Quoted 2 lines

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

Signature · 2 lines
With best wishes
Dmitry
author maintainer
#35 lore raw

PATCH v3 12/23 mfd: Add new driver for MAX77705 PMIC

In reply to Dzmitry Sankouski

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

---
 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(+)
MAINTAINERS +2 -0
index fae3b8ea9ce4..f66f08825db9 100644
@@ -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 <[email protected]>
drivers/mfd/Kconfig +12 -0
index 266b4f54af60..c4eb8ff2dcad 100644
@@ -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
drivers/mfd/Makefile +3 -0
index db1ba39de3b5..bf65cc36d59c 100644
@@ -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
drivers/mfd/max77705-core.c new file +278 -0

278 lines not on this page · raw message

drivers/mfd/max77705-irq.c new file +299 -0

299 lines not on this page · raw message

include/linux/mfd/max77705-private.h new file +281 -0

281 lines not on this page · raw message

include/linux/mfd/max77705.h new file +20 -0
new file mode 100644
index 000000000000..e2d757c77973
@@ -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__ */
+
Signature · 1 line
2.39.2
#36 lore raw

Re: [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC

Quoted 72 lines · Dzmitry Sankouski

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

---
 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(+)
MAINTAINERS +2 -0
index fae3b8ea9ce4..f66f08825db9 100644
@@ -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 <[email protected]>
drivers/mfd/Kconfig +12 -0
index 266b4f54af60..c4eb8ff2dcad 100644
@@ -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
drivers/mfd/Makefile +2 -0
index db1ba39de3b5..bf65cc36d59c 100644
@@ -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

drivers/mfd/Makefile obj-$(CONFIG_MFD_RK8XX_I2C) += rk8xx-i2c.o · line 231

Quoted 4 lines
drivers/mfd/Makefile +1 -0
@@ -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.

Quoted 67 lines
drivers/mfd/Makefile +0 -0
 obj-$(CONFIG_MFD_SYSCON)	+= syscon.o
 obj-$(CONFIG_MFD_LM3533)	+= lm3533-core.o lm3533-ctrlbank.o
 obj-$(CONFIG_MFD_VEXPRESS_SYSREG)	+= vexpress-sysreg.o
drivers/mfd/max77705-core.c new file +58 -0
new file mode 100644
index 000000000000..7cb71a0a9688
@@ -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 <[email protected]>
+ */
+
+#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",

drivers/mfd/max77705-core.c line 68

Quoted 10 lines
drivers/mfd/max77705-core.c new file +10 -0
+		   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.

Quoted 35 lines
drivers/mfd/max77705-core.c new file +35 -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",
+	},

drivers/mfd/max77705-core.c line 113

Quoted 10 lines
drivers/mfd/max77705-core.c new file +10 -0
+	{
+		.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.

drivers/mfd/max77705-core.c line 118

Quoted 5 lines
drivers/mfd/max77705-core.c new file +5 -0
+
+	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.

drivers/mfd/max77705-core.c line 122

Quoted 4 lines
drivers/mfd/max77705-core.c new file +4 -0
+	if (!max77705)
+		return -ENOMEM;
+
+	max77705->pdata = pdata;

Drop, not used.

drivers/mfd/max77705-core.c line 131

Quoted 9 lines
drivers/mfd/max77705-core.c new file +9 -0
+	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

Quoted 14 lines
drivers/mfd/max77705-core.c new file +14 -0
+		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) {

drivers/mfd/max77705-core.c line 155

Quoted 10 lines
drivers/mfd/max77705-core.c new file +10 -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

Quoted 13 lines
drivers/mfd/max77705-core.c new file +13 -0
+	}
+
+	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);

drivers/mfd/max77705-core.c line 178

Quoted 10 lines
drivers/mfd/max77705-core.c new file +10 -0
+	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

drivers/mfd/max77705-core.c line 179

Quoted 1 line
drivers/mfd/max77705-core.c new file +1 -0
+		max77705->irq = i2c->irq;

Why do you need it?

drivers/mfd/max77705-core.c line 185

Quoted 6 lines
drivers/mfd/max77705-core.c new file +6 -0
+	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?

drivers/mfd/max77705-core.c line 192

Quoted 7 lines
drivers/mfd/max77705-core.c new file +7 -0
+	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?

Quoted 6 lines
drivers/mfd/max77705-core.c new file +6 -0
+	ret = max77705_irq_init(max77705);
+	if (ret) {
+		dev_err(max77705->dev, "failed to init irq system: %d\n", ret);
+		return ret;
+	}
+

drivers/mfd/max77705-core.c line 208

Quoted 10 lines
drivers/mfd/max77705-core.c new file +10 -0
+	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

Quoted 11 lines
drivers/mfd/max77705-core.c new file +11 -0
+
+	device_init_wakeup(max77705->dev, true);
+
+	return ret;
+
+err_mfd:
+	mfd_remove_devices(max77705->dev);
+err:
+	kfree(max77705);
+	return ret;
+}

drivers/mfd/max77705-core.c line 229

Quoted 10 lines
drivers/mfd/max77705-core.c new file +10 -0
+
+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.

Quoted 30 lines
drivers/mfd/max77705-core.c new file +30 -0
+}
+
+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" },

drivers/mfd/max77705-core.c line 269

Quoted 10 lines
drivers/mfd/max77705-core.c new file +10 -0
+	{ },
+};
+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.

Quoted 94 lines
drivers/mfd/max77705-core.c new file +9 -0
+	},
+	.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 <[email protected]>");
+MODULE_LICENSE("GPL");
drivers/mfd/max77705-irq.c new file +79 -0
new file mode 100644
index 000000000000..0da17fc95e18
@@ -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 <[email protected]>
+ */
+
+#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);
+

drivers/mfd/max77705-irq.c line 89

Quoted 10 lines
drivers/mfd/max77705-irq.c new file +10 -0
+		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.

Quoted 8 lines
drivers/mfd/max77705-irq.c new file +2 -0
+
+MODULE_LICENSE("GPL");
include/linux/mfd/max77705-private.h new file +0 -0
new file mode 100644
index 000000000000..bd6ab9c582b8

include/linux/mfd/max77705-private.h line 7

Quoted 7 lines
include/linux/mfd/max77705-private.h new file +7 -0
@@ -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.

Quoted 36 lines
include/linux/mfd/max77705-private.h new file +36 -0
+ */
+
+#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,

include/linux/mfd/max77705-private.h line 53

Quoted 10 lines
include/linux/mfd/max77705-private.h new file +10 -0
+	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.

Quoted 186 lines
include/linux/mfd/max77705-private.h new file +186 -0
+	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;
+

include/linux/mfd/max77705-private.h line 249

Quoted 10 lines
include/linux/mfd/max77705-private.h new file +10 -0
+#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?

include/linux/mfd/max77705-private.h line 251

Quoted 2 lines
include/linux/mfd/max77705-private.h new file +2 -0
+
+	u8 cc_booting_complete;

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

include/linux/mfd/max77705-private.h line 261

Quoted 10 lines
include/linux/mfd/max77705-private.h new file +10 -0
+
+	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?

include/linux/mfd/max77705-private.h line 271

Quoted 10 lines
include/linux/mfd/max77705-private.h new file +10 -0
+};
+
+
+/**
+ * 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.

include/linux/mfd/max77705-private.h line 279

Quoted 8 lines
include/linux/mfd/max77705-private.h new file +8 -0
+
+/**
+ * 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.

Quoted 14 lines
include/linux/mfd/max77705-private.h new file +2 -0
+
+#endif /* __LINUX_MFD_MAX77705_PRIV_H */
include/linux/mfd/max77705.h new file +6 -0
new file mode 100644
index 000000000000..e2d757c77973
@@ -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

include/linux/mfd/max77705.h line 16

Quoted 10 lines
include/linux/mfd/max77705.h new file +10 -0
+ * 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.

include/linux/mfd/max77705.h line 20

Quoted 5 lines
include/linux/mfd/max77705.h new file +4 -0
+};
+
+#endif /* __MAX77705_H__ */
+

Do not keep redundant blank lines. Drop.

Best regards,
Krzysztof

#37 lore raw

Re: [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC

In reply to Dzmitry Sankouski
kernel test robot noticed the following build errors:

Hi Dzmitry,

kernel test robot noticed the following build errors:

[auto build test ERROR on 6906a84c482f098d31486df8dc98cead21cce2d0]

url:    https://github.com/intel-lab-lkp/linux/commits/Dzmitry-Sankouski/power-supply-add-undervoltage-health-status-property/20240618-222456
base:   6906a84c482f098d31486df8dc98cead21cce2d0
patch link:    https://lore.kernel.org/r/20240618-starqltechn_integration_upstream-v3-12-e3f6662017ac%40gmail.com
patch subject: [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC
config: mips-allmodconfig (https://download.01.org/0day-ci/archive/20240622/[email protected]/config)
compiler: mips-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240622/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/mfd/max77705-core.c:20:

>> include/linux/mfd/max77705-private.h:243:26: error: 'MAX77705_USBC_REG_END' undeclared here (not in a function); did you mean 'MAX77705_PMIC_REG_END'?
     243 |         u8 reg_muic_dump[MAX77705_USBC_REG_END];
         |                          ^~~~~~~~~~~~~~~~~~~~~
         |                          MAX77705_PMIC_REG_END

vim +243 include/linux/mfd/max77705-private.h

216
217 struct max77705_dev {
218 struct device *dev;
219 struct i2c_client *i2c; /* 0xCC; Haptic, PMIC */
220 struct i2c_client *charger; /* 0xD2; Charger */
221 struct i2c_client *fuelgauge; /* 0x6C; Fuelgauge */
222 struct i2c_client *muic; /* 0x4A; MUIC */
223 struct i2c_client *debug; /* 0xC4; Debug */
224 struct mutex i2c_lock;
225
226 struct regmap *regmap;
227 struct regmap *regmap_fg;
228 struct regmap *regmap_charger;
229 struct regmap *regmap_leds;
230
231 int type;
232
233 int irq;
234 int irq_base;
235 int irq_masks_cur[MAX77705_IRQ_GROUP_NR];
236 int irq_masks_cache[MAX77705_IRQ_GROUP_NR];
237 bool wakeup;
238 struct mutex irqlock;
239
240 #ifdef CONFIG_HIBERNATION
241 /* For hibernation */
242 u8 reg_pmic_dump[MAX77705_PMIC_REG_END];

 > 243		u8 reg_muic_dump[MAX77705_USBC_REG_END];

244 u8 reg_led_dump[MAX77705_LED_REG_END];
245 #endif
246
247 /* pmic VER/REV register */
248 u8 pmic_rev; /* pmic Rev */
249 u8 pmic_ver; /* pmic version */
250
251 u8 cc_booting_complete;
252
253 wait_queue_head_t queue_empty_wait_q;
254 int doing_irq;
255 int is_usbc_queue;
256
257 struct max77705_platform_data *pdata;
258 };
259

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#38 lore raw

Re: [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC

In reply to Dzmitry Sankouski
kernel test robot noticed the following build errors:

Hi Dzmitry,

kernel test robot noticed the following build errors:

[auto build test ERROR on 6906a84c482f098d31486df8dc98cead21cce2d0]

url:    https://github.com/intel-lab-lkp/linux/commits/Dzmitry-Sankouski/power-supply-add-undervoltage-health-status-property/20240618-222456
base:   6906a84c482f098d31486df8dc98cead21cce2d0
patch link:    https://lore.kernel.org/r/20240618-starqltechn_integration_upstream-v3-12-e3f6662017ac%40gmail.com
patch subject: [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC
config: riscv-allmodconfig (https://download.01.org/0day-ci/archive/20240622/[email protected]/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project ad79a14c9e5ec4a369eed4adf567c22cc029863f)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240622/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/mfd/max77705-core.c:14:
In file included from include/linux/i2c.h:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:25:
In file included from include/linux/kernel_stat.h:8:
In file included from include/linux/interrupt.h:22:
In file included from arch/riscv/include/asm/sections.h:9:
In file included from include/linux/mm.h:2214:
include/linux/vmstat.h:484:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]

     484 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     485 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:491:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     491 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     492 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:498:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     498 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:503:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     503 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     504 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:512:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     512 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     513 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/mfd/max77705-core.c:20:
>> include/linux/mfd/max77705-private.h:243:19: error: use of undeclared identifier 'MAX77705_USBC_REG_END'; did you mean 'MAX77705_PMIC_REG_END'?
     243 |         u8 reg_muic_dump[MAX77705_USBC_REG_END];
         |                          ^~~~~~~~~~~~~~~~~~~~~
         |                          MAX77705_PMIC_REG_END
   include/linux/mfd/max77705-private.h:96:2: note: 'MAX77705_PMIC_REG_END' declared here
      96 |         MAX77705_PMIC_REG_END,
         |         ^

5 warnings and 1 error generated.

vim +243 include/linux/mfd/max77705-private.h

216
217 struct max77705_dev {
218 struct device *dev;
219 struct i2c_client *i2c; /* 0xCC; Haptic, PMIC */
220 struct i2c_client *charger; /* 0xD2; Charger */
221 struct i2c_client *fuelgauge; /* 0x6C; Fuelgauge */
222 struct i2c_client *muic; /* 0x4A; MUIC */
223 struct i2c_client *debug; /* 0xC4; Debug */
224 struct mutex i2c_lock;
225
226 struct regmap *regmap;
227 struct regmap *regmap_fg;
228 struct regmap *regmap_charger;
229 struct regmap *regmap_leds;
230
231 int type;
232
233 int irq;
234 int irq_base;
235 int irq_masks_cur[MAX77705_IRQ_GROUP_NR];
236 int irq_masks_cache[MAX77705_IRQ_GROUP_NR];
237 bool wakeup;
238 struct mutex irqlock;
239
240 #ifdef CONFIG_HIBERNATION
241 /* For hibernation */
242 u8 reg_pmic_dump[MAX77705_PMIC_REG_END];

 > 243		u8 reg_muic_dump[MAX77705_USBC_REG_END];

244 u8 reg_led_dump[MAX77705_LED_REG_END];
245 #endif
246
247 /* pmic VER/REV register */
248 u8 pmic_rev; /* pmic Rev */
249 u8 pmic_ver; /* pmic version */
250
251 u8 cc_booting_complete;
252
253 wait_queue_head_t queue_empty_wait_q;
254 int doing_irq;
255 int is_usbc_queue;
256
257 struct max77705_platform_data *pdata;
258 };
259

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#39 lore raw

PATCH v3 13/23 input: add max77705 haptic driver

In reply to 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.

---
 drivers/input/misc/Kconfig           |  11 +
 drivers/input/misc/Makefile          |   1 +
 drivers/input/misc/max77705-haptic.c | 378 +++++++++++++++++++++++++++++++++++
 3 files changed, 390 insertions(+)
drivers/input/misc/Kconfig +11 -0
index 6ba984d7f0b1..26f7b25a0b42 100644
@@ -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
drivers/input/misc/Makefile +1 -0
index 04296a4abe8e..4dea2720b757 100644
@@ -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
drivers/input/misc/max77705-haptic.c new file +378 -0

378 lines not on this page · raw message

Signature · 1 line
2.39.2
#40 lore raw

Re: [PATCH v3 13/23] input: add max77705 haptic driver

Quoted 116 lines · 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.

---

drivers/input/misc/max77705-haptic.c new file +107 -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;
+

drivers/input/misc/max77705-haptic.c line 199

Quoted 10 lines
drivers/input/misc/max77705-haptic.c new file +10 -0
+	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.

Quoted 26 lines
(quoted diff) +24 -0
+	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),

Review

Quoted 10 lines
(quoted diff) +10 -0
+		.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 <[email protected]>");
+MODULE_AUTHOR("Jaewon Kim <[email protected]>");
+MODULE_AUTHOR("Krzysztof Kozlowski <[email protected]>");

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

Best regards,
Krzysztof

author maintainer
#41 lore raw

PATCH v3 14/23 power: supply: max77705: Add charger driver for Maxim 77705

In reply to 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%

---
 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(+)
drivers/power/supply/Kconfig +6 -0
index 3e31375491d5..47ca8cc00a80 100644
@@ -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
drivers/power/supply/Makefile +1 -0
index 58b567278034..dbec648c78c9 100644
@@ -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
drivers/power/supply/max77705_charger.c new file +772 -0

772 lines not on this page · raw message

include/linux/mfd/max77705_charger.h new file +225 -0

225 lines not on this page · raw message

Signature · 1 line
2.39.2
#42 lore raw

Re: [PATCH v3 14/23] power: supply: max77705: Add charger driver for Maxim 77705

Quoted 7 lines · 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%

...

Quoted 4 lines

+ *
+ * Copyright (C) 2015 Samsung Electronics, Inc.
+ *
+ *

Quoted 8 lines

+ * 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

author maintainer
#43 lore raw

PATCH v3 15/23 power: supply: max77705: Add fuel gauge driver for Maxim 77705

In reply to 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).

---
 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(+)
drivers/power/supply/Kconfig +7 -0
index 47ca8cc00a80..a3fdfcb5aa64 100644
@@ -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
drivers/power/supply/Makefile +1 -0
index dbec648c78c9..e1abad8b6b75 100644
@@ -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
drivers/power/supply/max77705_fuelgauge.c new file +624 -0

624 lines not on this page · raw message

include/linux/power/max77705_fuelgauge.h new file +107 -0

107 lines not on this page · raw message

Signature · 1 line
2.39.2
author maintainer
#44 lore raw

PATCH v3 16/23 leds: max77705: Add LEDs support

In reply to Dzmitry Sankouski

This adds basic support for LEDs for the max77705 PMIC.

---
 MAINTAINERS                  |   1 +
 drivers/leds/Kconfig         |   6 ++
 drivers/leds/Makefile        |   1 +
 drivers/leds/leds-max77705.c | 166 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 174 insertions(+)
MAINTAINERS +1 -0
index f66f08825db9..f3c245d432d9 100644
@@ -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
drivers/leds/Kconfig +6 -0
index 05e6af88b88c..14d483011308 100644
@@ -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
drivers/leds/Makefile +1 -0
index effdfc6f1e95..be064e3d678e 100644
@@ -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
drivers/leds/leds-max77705.c new file +166 -0

166 lines not on this page · raw message

Signature · 1 line
2.39.2
#45 lore raw

Re: [PATCH v3 16/23] leds: max77705: Add LEDs support

Quoted 78 lines · Dzmitry Sankouski

This adds basic support for LEDs for the max77705 PMIC.

---
 MAINTAINERS                  |   1 +
 drivers/leds/Kconfig         |   6 ++
 drivers/leds/Makefile        |   1 +
 drivers/leds/leds-max77705.c | 166 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 174 insertions(+)
MAINTAINERS +1 -0
index f66f08825db9..f3c245d432d9 100644
@@ -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
drivers/leds/Kconfig +6 -0
index 05e6af88b88c..14d483011308 100644
@@ -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
drivers/leds/Makefile +1 -0
index effdfc6f1e95..be064e3d678e 100644
@@ -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
drivers/leds/leds-max77705.c new file +21 -0
new file mode 100644
index 000000000000..f91c0e41056c
@@ -0,0 +1,166 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Based on leds-max77650 driver:
+ *		Copyright (C) 2018 BayLibre SAS
+ *		Author: Bartosz Golaszewski <[email protected]>
+ *
+ * LED driver for MAXIM 77705 MFD.
+ * Copyright (C) 2024 Dzmitry Sankouski <[email protected]>
+ */
+
+#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

drivers/leds/leds-max77705.c line 31

Quoted 10 lines
drivers/leds/leds-max77705.c new file +10 -0
+
+#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.

drivers/leds/leds-max77705.c line 38

Quoted 7 lines
drivers/leds/leds-max77705.c new file +7 -0
+
+struct max77705_led {
+	struct led_classdev cdev;
+	struct regmap *regmap;
+	unsigned int en_shift;
+	unsigned int reg_brightness;
+	unsigned int regB;

noCamelCase.

Quoted 11 lines
drivers/leds/leds-max77705.c new file +9 -0
+};
+
+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;

drivers/leds/leds-max77705.c line 129

Quoted 10 lines
drivers/leds/leds-max77705.c new file +10 -0
+		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.

Quoted 27 lines
drivers/leds/leds-max77705.c new file +27 -0
+
+		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,

drivers/leds/leds-max77705.c line 166

Quoted 10 lines
drivers/leds/leds-max77705.c new file +10 -0
+	},
+	.probe = max77705_led_probe,
+};
+module_platform_driver(max77705_led_driver);
+
+MODULE_DESCRIPTION("MAXIM 77705 LED driver");
+MODULE_AUTHOR("Bartosz Golaszewski <[email protected]>");
+MODULE_AUTHOR("Dzmitry Sankouski <[email protected]>");
+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

author maintainer
#46 lore raw

PATCH v3 17/23 mfd: add s2dos series core driver

In reply to 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.

---
 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(-)
MAINTAINERS +1 -0
index f3c245d432d9..b53462684a30 100644
@@ -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
drivers/mfd/Kconfig +13 -0
index c4eb8ff2dcad..517d8778d7a8 100644
@@ -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
drivers/mfd/Makefile +1 -1
index bf65cc36d59c..37c51aab0205 100644
@@ -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
drivers/mfd/s2dos-core.c new file +141 -0

141 lines not on this page · raw message

include/linux/mfd/samsung/s2dos-core.h new file +21 -0
new file mode 100644
index 000000000000..7e84b387063c
@@ -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 <[email protected]>
+ *
+ */
+
+#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 */
include/linux/mfd/samsung/s2dos05.h new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
2.39.2
#47 lore raw

Re: [PATCH v3 17/23] mfd: add s2dos series core driver

Quoted 31 lines · 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.

---
 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(-)
MAINTAINERS +1 -0
index f3c245d432d9..b53462684a30 100644
@@ -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
drivers/mfd/Kconfig +0 -0
index c4eb8ff2dcad..517d8778d7a8 100644

drivers/mfd/Kconfig config MFD_RN5T618 · line 1282

Quoted 5 lines
drivers/mfd/Kconfig +2 -0
@@ -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

#48 lore raw

Re: [PATCH v3 17/23] mfd: add s2dos series core driver

In reply to Dzmitry Sankouski
kernel test robot noticed the following build warnings:

Hi Dzmitry,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 6906a84c482f098d31486df8dc98cead21cce2d0]

url:    https://github.com/intel-lab-lkp/linux/commits/Dzmitry-Sankouski/power-supply-add-undervoltage-health-status-property/20240618-222456
base:   6906a84c482f098d31486df8dc98cead21cce2d0
patch link:    https://lore.kernel.org/r/20240618-starqltechn_integration_upstream-v3-17-e3f6662017ac%40gmail.com
patch subject: [PATCH v3 17/23] mfd: add s2dos series core driver
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20240622/[email protected]/config)
compiler: mips-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240622/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/mfd/s2dos-core.c: In function 's2dos05_i2c_probe':

>> drivers/mfd/s2dos-core.c:88:13: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
      88 |         int ret = 0;
         |             ^~~

vim +/ret +88 drivers/mfd/s2dos-core.c

    79	
    80	
    81	static int s2dos05_i2c_probe(struct i2c_client *i2c)
    82	{
    83		struct s2dos_core *s2dos05;
    84		struct regmap *regmap;
    85		struct device *dev = &i2c->dev;
    86	
    87		unsigned int reg_data;
  > 88		int ret = 0;
    89	
    90		s2dos05 = kzalloc(sizeof(struct s2dos_core), GFP_KERNEL);
    91		if (!s2dos05)
    92			return -ENOMEM;
    93	
    94		regmap = devm_regmap_init_i2c(i2c, &s2dos05_regmap_config);
    95		if (IS_ERR(regmap)) {
    96			dev_err(dev, "Unable to initialise I2C Regmap\n");
    97			return PTR_ERR(regmap);
    98		}
    99		s2dos05->regmap = regmap;

100
101 if (regmap_read(regmap, S2DOS05_REG_DEV_ID, &reg_data) < 0) {
102 dev_err(dev,
103 "device not found on this channel (this is not an error)\n");
104 ret = -ENODEV;
105 } else {
106 dev_info(dev, "%s device found with id: .0x%x\n",
107 __func__, reg_data);
108 }
109
110 i2c_set_clientdata(i2c, s2dos05);
111
112 debugfs_file = debugfs_create_file("s2dos05-regs",
113 0664, NULL, (void *)s2dos05,
114 &s2dos05_debugfs_fops);
115 if (!debugfs_file)
116 dev_err(dev, "Failed to create debugfs file\n");
117
118 return mfd_add_devices(dev, -1, s2dos05_devs,
119 ARRAY_SIZE(s2dos05_devs), NULL, 0, NULL);
120 }
121

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#49 lore raw

PATCH v3 18/23 regulator: add s2dos05 regulator support

In reply to Dzmitry Sankouski

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

---
 MAINTAINERS                           |   1 +
 drivers/regulator/Kconfig             |   8 +
 drivers/regulator/Makefile            |   1 +
 drivers/regulator/s2dos05-regulator.c | 362 ++++++++++++++++++++++++++++++++++
 4 files changed, 372 insertions(+)
MAINTAINERS +1 -0
index b53462684a30..bee700a5e648 100644
@@ -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
drivers/regulator/Kconfig +8 -0
index d333be2bea3b..d6d6f571a65d 100644
@@ -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
drivers/regulator/Makefile +1 -0
index ba15fa5f30ad..80f889404597 100644
@@ -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
drivers/regulator/s2dos05-regulator.c new file +362 -0

362 lines not on this page · raw message

Signature · 1 line
2.39.2
maintainer
#50 lore raw

Re: [PATCH v3 18/23] regulator: add s2dos05 regulator support

drivers/regulator/s2dos05-regulator.c line 4

Quoted 8 lines · Dzmitry Sankouski

index 000000000000..3c58a1bd2262

drivers/regulator/s2dos05-regulator.c new file +4 -0
@@ -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.

drivers/regulator/s2dos05-regulator.c line 40

Quoted 9 lines
drivers/regulator/s2dos05-regulator.c new file +9 -0
+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.

drivers/regulator/s2dos05-regulator.c line 276

Quoted 8 lines
drivers/regulator/s2dos05-regulator.c new file +8 -0
+	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.

drivers/regulator/s2dos05-regulator.c line 302

Quoted 6 lines
drivers/regulator/s2dos05-regulator.c new file +5 -0
+	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.

author maintainer
#51 lore raw

Re: [PATCH v3 18/23] regulator: add s2dos05 regulator support

вт, 18 июн. 2024 г. в 17:08, Mark Brown <[email protected]>:

Quoted 15 lines · Dzmitry Sankouski

drivers/regulator/s2dos05-regulator.c line 4

Quoted 9 lines

index 000000000000..3c58a1bd2262

drivers/regulator/s2dos05-regulator.c new file +4 -0
@@ -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?

maintainer
#52 lore raw

Re: [PATCH v3 18/23] regulator: add s2dos05 regulator support

Quoted 11 lines · Dzmitry Sankouski

вт, 18 июн. 2024 г. в 17:08, Mark Brown <[email protected]>:

Quoted 9 lines · Dzmitry Sankouski

drivers/regulator/s2dos05-regulator.c line 4

Quoted 5 lines
drivers/regulator/s2dos05-regulator.c new file +4 -0
+// 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.

Quoted 2 lines

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.

#53 lore raw

Re: [PATCH v3 18/23] regulator: add s2dos05 regulator support

In reply to Dzmitry Sankouski
kernel test robot noticed the following build warnings:

Hi Dzmitry,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 6906a84c482f098d31486df8dc98cead21cce2d0]

url:    https://github.com/intel-lab-lkp/linux/commits/Dzmitry-Sankouski/power-supply-add-undervoltage-health-status-property/20240618-222456
base:   6906a84c482f098d31486df8dc98cead21cce2d0
patch link:    https://lore.kernel.org/r/20240618-starqltechn_integration_upstream-v3-18-e3f6662017ac%40gmail.com
patch subject: [PATCH v3 18/23] regulator: add s2dos05 regulator support

:::::: branch date: 18 hours ago
:::::: commit date: 18 hours ago
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

includecheck warnings: (new ones prefixed by >>)

>> drivers/regulator/s2dos05-regulator.c: linux/module.h is included more than once.

vim +10 drivers/regulator/s2dos05-regulator.c

  > 10	#include <linux/module.h>
    11	#include <linux/bug.h>
    12	#include <linux/delay.h>
    13	#include <linux/err.h>
    14	#include <linux/slab.h>
  > 15	#include <linux/module.h>
    16	#include <linux/regmap.h>
    17	#include <linux/interrupt.h>
    18	#include <linux/platform_device.h>
    19	#include <linux/regulator/driver.h>
    20	#include <linux/regulator/machine.h>
    21	#include <linux/regulator/of_regulator.h>
    22	#include <linux/mfd/samsung/s2dos-core.h>
    23	#include <linux/mfd/samsung/s2dos05.h>
    24	#include <linux/i2c.h>
    25	#include <linux/debugfs.h>
    26	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#54 lore raw

Re: [PATCH v3 18/23] regulator: add s2dos05 regulator support

In reply to Dzmitry Sankouski
Quoted 12 lines · Dzmitry Sankouski

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

drivers/regulator/s2dos05-regulator.c new file +0 -0
new file mode 100644
index 000000000000..3c58a1bd2262

drivers/regulator/s2dos05-regulator.c line 5

Quoted 5 lines
drivers/regulator/s2dos05-regulator.c new file +5 -0
@@ -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.

Quoted 3 lines
drivers/regulator/s2dos05-regulator.c new file +3 -0
+ * Copyright (C) 2023 Dzmitry Sankouski <[email protected]>
+ *
+ */

...

drivers/regulator/s2dos05-regulator.c line 339

Quoted 5 lines
drivers/regulator/s2dos05-regulator.c new file +5 -0
+
+	return ret;
+
+err_data:
+	devm_kfree(dev, (void *)s2dos05);

Why?

drivers/regulator/s2dos05-regulator.c line 340

Quoted 1 line
drivers/regulator/s2dos05-regulator.c new file +1 -0
+	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

author maintainer
#55 lore raw

PATCH v3 19/23 power: supply: s2dos05: Add fuel gauge driver for s2dos05

In reply to 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.

---
 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(+)
MAINTAINERS +1 -0
index bee700a5e648..2c5d9a74f977 100644
@@ -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
drivers/power/supply/Kconfig +8 -0
index a3fdfcb5aa64..22090b150885 100644
@@ -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
drivers/power/supply/Makefile +1 -0
index e1abad8b6b75..fcea83c8aa79 100644
@@ -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
drivers/power/supply/s2dos05-fg.c new file +427 -0

427 lines not on this page · raw message

include/linux/mfd/s2dos05.h new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
2.39.2
#56 lore raw

Re: [PATCH v3 19/23] power: supply: s2dos05: Add fuel gauge driver for s2dos05

Quoted 15 lines · 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.

drivers/power/supply/s2dos05-fg.c new file +6 -0
+
+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,

drivers/power/supply/s2dos05-fg.c line 319

Quoted 10 lines
drivers/power/supply/s2dos05-fg.c new file +10 -0
+	.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.

drivers/power/supply/s2dos05-fg.c line 357

Quoted 5 lines
drivers/power/supply/s2dos05-fg.c new file +5 -0
+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.

drivers/power/supply/s2dos05-fg.c line 361

Quoted 4 lines
drivers/power/supply/s2dos05-fg.c new file +4 -0
+	struct power_supply_config pscfg = {};
+	int ret;
+
+	drv_data = devm_kzalloc(dev, sizeof(struct s2dos05_fg),

Drop 2015 code. Use new drivers as template.

include/linux/mfd/s2dos05.h

Quoted 14 lines
drivers/power/supply/s2dos05-fg.c new file +7 -0
+							GFP_KERNEL);
+	if (!drv_data)
+		ret = -ENOMEM;
 
 
+
+MODULE_DESCRIPTION("s2dos05 power meter");
+MODULE_AUTHOR("Dzmitry Sankouski <[email protected]>");
+MODULE_LICENSE("GPL");
include/linux/mfd/s2dos05.h new file +0 -0
new file mode 100644
index 000000000000..8d216064bc78

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

include/linux/mfd/s2dos05.h line 2

Quoted 3 lines
include/linux/mfd/s2dos05.h new file +2 -0
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ * s2dos05.h

Drop

include/linux/mfd/s2dos05.h line 14

Quoted 12 lines
include/linux/mfd/s2dos05.h new file +12 -0
+ *
+ * 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

Quoted 17 lines
include/linux/mfd/s2dos05.h new file +17 -0
+
+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,

include/linux/mfd/s2dos05.h line 41

Quoted 10 lines
include/linux/mfd/s2dos05.h new file +10 -0
+	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?

include/linux/mfd/s2dos05.h line 48

Quoted 7 lines
include/linux/mfd/s2dos05.h new file +7 -0
+	S2DOS05_LDO1,
+	S2DOS05_LDO2,
+	S2DOS05_LDO3,
+	S2DOS05_LDO4,
+	S2DOS05_BUCK1,
+	S2DOS05_REG_MAX,
+};

Best regards,
Krzysztof

author maintainer
#57 lore raw

PATCH v3 20/23 arm64: dts: qcom: starqltechn: remove wifi

In reply to 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")
---
 arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts | 8 --------
 1 file changed, 8 deletions(-)
arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +0 -8
index d37a433130b9..6fc30fd1262b 100644
@@ -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>;
 
Signature · 1 line
2.39.2
author maintainer
#59 lore raw

PATCH v3 21/23 arm64: dts: qcom: starqltechn: remove framebuffer

In reply to Dzmitry Sankouski

Remove framebuffer because a panel driver introduced.

---
 arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts | 9 ---------
 1 file changed, 9 deletions(-)
arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +0 -9
index 6fc30fd1262b..578798704577 100644
@@ -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 {
Signature · 1 line
2.39.2
#60 lore raw

Re: [PATCH v3 21/23] arm64: dts: qcom: starqltechn: remove framebuffer

Quoted 4 lines · Dzmitry Sankouski

Remove framebuffer because a panel driver introduced.

---

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

Konrad

author maintainer
#61 lore raw

PATCH v3 22/23 arm64: dts: qcom: starqltechn: fix usb regulator mistake

In reply to 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")
---
 arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +1 -2
index 578798704577..bad154b1e894 100644
@@ -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:
Signature · 1 line
2.39.2
#62 lore raw

Re: [PATCH v3 22/23] arm64: dts: qcom: starqltechn: fix usb regulator mistake

Quoted 7 lines · 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")

---

How did you confirm that?

Konrad

author maintainer
#63 lore raw

Re: [PATCH v3 22/23] arm64: dts: qcom: starqltechn: fix usb regulator mistake

вт, 18 июн. 2024 г. в 17:08, Konrad Dybcio <[email protected]>:

Quoted 13 lines · Dzmitry Sankouski
Quoted 7 lines

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

---

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

Quoted 2 lines

Konrad

author maintainer
#64 lore raw

PATCH v3 23/23 arm64: dts: qcom: starqltechn: add new features

In reply to Dzmitry Sankouski

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

---
 .../boot/dts/qcom/sdm845-samsung-starqltechn.dts   | 593 ++++++++++++++++++++-
 1 file changed, 592 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +592 -1
index bad154b1e894..28a5210e22fb 100644
@@ -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;
 };
Signature · 1 line
2.39.2
#65 lore raw

Re: [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features

Quoted 11 lines · Dzmitry Sankouski

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

Quoted 2 lines

---

Please split this up

Quoted 51 lines
  .../boot/dts/qcom/sdm845-samsung-starqltechn.dts   | 593 ++++++++++++++++++++-
  1 file changed, 592 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +25 -0
index bad154b1e894..28a5210e22fb 100644
@@ -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>;

arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts memory@a1300000 { · line 95

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +9 -0
  		};
+
+		/* 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

arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts memory@a1300000 { · line 103

Quoted 8 lines
arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +8 -0
+
+		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

[...]

arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts memory@a1300000 { · line 117

Quoted 7 lines
arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +7 -0
+		/*
+		 * 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

[...]

arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts memory@a1300000 { · line 232

Quoted 4 lines
arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +4 -0
+
+&gmu {
+	status = "okay";
+};

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

[...]

arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts &usb_1_qmpphy { · line 931

Quoted 1 line
arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +0 -0
  	gpio-reserved-ranges = <0 4>, <27 4>, <81 4>, <85 4>;

Do you know what these are for?

Konrad

author maintainer
#66 lore raw

Re: [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features

вт, 18 июн. 2024 г. в 17:12, Konrad Dybcio <[email protected]>:

Quoted 2 lines

...

Quoted 6 lines
Quoted 2 lines
      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.

Signature · 2 lines
Best regards,
Dzmitry
#67 lore raw

Re: [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features

Quoted 7 lines · Dzmitry Sankouski

вт, 18 июн. 2024 г. в 17:12, Konrad Dybcio <[email protected]>:

Quoted 2 lines

...

Quoted 3 lines
Quoted 2 lines
      gpio-reserved-ranges = <0 4>, <27 4>, <81 4>, <85 4>;
Quoted 7 lines
Quoted 3 lines

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