Skip to contentSkip to conversation

Add support for Silicon Mitus SM5703 MFD

PATCH Superseded Markuss Broks 6 participants 24 messages Apr 23, 2022 – Jul 20, 2022

Subsystems (4)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add support for Silicon Mitus SM5703 MFD

This series adds support for Silicon Mitus SM5703 MFD and the appropriate device-tree bindings. This only adds support for the regulator module, leaving room for other modules implemented in future (code for other modules is really not ready for submission right now). Silicon Mitus SM5703 is used on various mobile phones, mostly Samsung Galaxy (J5 (2015, 2016), On7, J7 (2015, 2016) ...).

Cc Matti Vaittinen <[email protected]>

v2:
- mfd bindings: add "SM5703" to the title
- mfd bindings: indent the example
- regulators/Makefile: sort alphabetically
v3:
- mfd bindings: fix an error in example: there should be no newline between #size-cells and #address-cells and the node
v4:
mfd bindings:
- drop the -mfd in the compatible
- change reference path to the regulator yaml to an absolute one
- use -gpios for the reset GPIO
- make reset-gpios a required property
- correct the example node name
- correct the example compatible
regulator bindings:
- add unevaluatedProperties: false to all four types of regulators v5:
mfd driver:
- depend on OF for the SM5703 MFD (Kconfig)
- correct the compatible in the MFD driver
- remove the compatible of -regulators in the struct mfd_cell* mfd bindings:
- adjust the example for regulators {} node
- include GPIO header in the example
- indent the example properly
- adjust the example for the voltage regulators being fixed regulator bindings:
- remove the compatible
- refer to regulators.yaml
regulator driver:
- add a separate ops for fixed voltage regulators (to avoid kernel WARN)
- set the config.dev to dev->parent to probe from parent OF node
- (Kconfig) SM5703_MFD -> MFD_SM5703 fix typo

- Add a patch to avoid driver name conflicts in SM5502 extcon driver

Markuss Broks (4):
dt-bindings: regulator: Add bindings for Silicon Mitus SM5703
regulators
dt-bindings: mfd: Add bindings for Silicon Mitus SM5703 MFD
mfd: sm5703: Add support for SM5703 MFD
regulator: sm5703-regulator: Add regulators support for SM5703 MFD

 .../bindings/mfd/siliconmitus,sm5703.yaml     |  91 ++++++++++
 .../siliconmitus,sm5703-regulator.yaml        |  48 ++++++
 MAINTAINERS                                   |   8 +
 drivers/mfd/Kconfig                           |  12 ++
 drivers/mfd/Makefile                          |   1 +
 drivers/mfd/sm5703.c                          |  81 +++++++++
 drivers/regulator/Kconfig                     |   7 +
 drivers/regulator/Makefile                    |   1 +
 drivers/regulator/sm5703-regulator.c          | 162 ++++++++++++++++++
 include/linux/mfd/sm5703.h                    | 105 ++++++++++++
 10 files changed, 516 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
 create mode 100644 Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
 create mode 100644 drivers/mfd/sm5703.c
 create mode 100644 drivers/regulator/sm5703-regulator.c
 create mode 100644 include/linux/mfd/sm5703.h
Signature · 1 line
2.35.1
#1 lore raw

PATCH v5 1/5 extcon: sm5502: Clarify SM5703's i2c device ID

While SM5502 and SM5504 are purely micro USB switching circuits, SM5703 is a multi-function device which has multiple modules in it. Change the i2c_device_id of it to avoid conflict with MFD driver.

---
 drivers/extcon/extcon-sm5502.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/extcon/extcon-sm5502.c +1 -1
index 17a40c3782ee..f706f5288257 100644
@@ -831,7 +831,7 @@ static SIMPLE_DEV_PM_OPS(sm5502_muic_pm_ops,
 static const struct i2c_device_id sm5502_i2c_id[] = {
 	{ "sm5502", (kernel_ulong_t)&sm5502_data },
 	{ "sm5504", (kernel_ulong_t)&sm5504_data },
-	{ "sm5703", (kernel_ulong_t)&sm5502_data },
+	{ "sm5703-muic", (kernel_ulong_t)&sm5502_data },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, sm5502_i2c_id);
Signature · 1 line
2.35.1
#3 lore raw

PATCH v5 2/5 dt-bindings: regulator: Add bindings for Silicon Mitus SM5703 regulators

In reply to Markuss Broks

This patch adds device-tree bindings for regulators on Silicon Mitus SM5703 MFD.

---
 .../siliconmitus,sm5703-regulator.yaml        | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml new file +49 -0
new file mode 100644
index 000000000000..75ff16b58000
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/siliconmitus,sm5703-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Silicon Mitus SM5703 multi function device regulators
+
+maintainers:
+  - Markuss Broks <[email protected]>
+
+description: |
+  SM5703 regulators node should be a sub node of the SM5703 MFD node. See SM5703 MFD
+  bindings at Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+  Regulator nodes should be named as USBLDO_<number>, BUCK, VBUS, LDO_<number>.
+  The definition for each of these nodes is defined using the standard
+  binding for regulators at Documentation/devicetree/bindings/regulator/regulator.txt.
+
+properties:
+  buck:
+    type: object
+    $ref: regulators.yaml#
+    unevaluatedProperties: false
+    description:
+      Properties for the BUCK regulator.
+
+  vbus:
+    type: object
+    $ref: regulators.yaml#
+    unevaluatedProperties: false
+    description:
+      Properties for the VBUS regulator.
+
+patternProperties:
+  "^ldo[1-3]$":
+    type: object
+    $ref: regulators.yaml#
+    unevaluatedProperties: false
+    description:
+      Properties for single LDO regulator.
+
+  "^usbldo[1-2]$":
+    type: object
+    $ref: regulators.yaml#
+    unevaluatedProperties: false
+    description:
+      Properties for a single USBLDO regulator.
+
+additionalProperties: false
Signature · 1 line
2.35.1
#8 lore raw

PATCH v5 3/5 dt-bindings: mfd: Add bindings for Silicon Mitus SM5703 MFD

In reply to Markuss Broks

This patch adds device-tree bindings for the Silicon Mitus SM5703 MFD.

---
 .../bindings/mfd/siliconmitus,sm5703.yaml     | 84 +++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml new file +84 -0
new file mode 100644
index 000000000000..32197be57cce
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/siliconmitus,sm5703.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Silicon Mitus SM5703 multi-function device bindings
+
+maintainers:
+  - Markuss Broks <[email protected]>
+
+description: |
+  Silicon Mitus SM5703 is a multi-function device, that consists of several
+  modules, designed for a mobile phone use. It consists of
+  LDO, Buck, USBLDO and VBUS regulators, a flash LED driver, a MUIC unit,
+  a fuel gauge and a battery charger circuit. The MUIC and Fuel-Gauge units
+  are separate from the main MFD, having their own i2c lines, while the
+  LED driver, regulators and charger are sharing the main i2c bus of the MFD.
+
+properties:
+  compatible:
+    const: siliconmitus,sm5703
+
+  reg:
+    description:
+      I2C slave address.
+    maxItems: 1
+
+  regulators:
+    $ref: /schemas/regulator/siliconmitus,sm5703-regulator.yaml
+    description:
+      List of child nodes that specify the regulators.
+
+  reset-gpios:
+    description:
+      GPIO which is connected to the MRSTB pin.
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - regulators
+  - reset-gpios
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        pmic@49 {
+          compatible = "siliconmitus,sm5703";
+          reg = <0x49>;
+
+          reset-gpios = <&msmgpio 24 GPIO_ACTIVE_HIGH>;
+          pinctrl-0 = <&mrstb_default>;
+
+          regulators {
+            sm5703_ldo1: ldo1 {
+              regulator-min-microvolt = <2800000>;
+              regulator-max-microvolt = <2800000>;
+            };
+
+            sm5703_ldo2: ldo2 {
+              regulator-min-microvolt = <1500000>;
+              regulator-max-microvolt = <3300000>;
+            };
+
+            sm5703_ldo3: ldo3 {
+              regulator-min-microvolt = <3300000>;
+              regulator-max-microvolt = <3300000>;
+            };
+
+            sm5703_usbldo1: usbldo1 { };
+
+            sm5703_usbldo2: usbldo2 { };
+
+            sm5703_vbus: vbus { };
+          };
+        };
+      };
+...
Signature · 1 line
2.35.1
#10 lore raw

PATCH v5 4/5 mfd: sm5703: Add support for SM5703 MFD

In reply to Markuss Broks

Silicon Mitus SM5703 is a multi-function device, meant to be used in mobile devices. It has several modules: LDO, BUCK regulators, charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger circuit, LED driver and regulators are on the main i2c line the device is controlled with.

---
 MAINTAINERS                |   8 +++
 drivers/mfd/Kconfig        |  13 +++++
 drivers/mfd/Makefile       |   1 +
 drivers/mfd/sm5703.c       |  78 +++++++++++++++++++++++++++
 include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++
 5 files changed, 205 insertions(+)
 create mode 100644 drivers/mfd/sm5703.c
 create mode 100644 include/linux/mfd/sm5703.h
MAINTAINERS +8 -0
index 6157e706ed02..6125ed1a3be4 100644
@@ -18172,6 +18172,14 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
 F:	include/linux/srcu*.h
 F:	kernel/rcu/srcu*.c
 
+SM5703 MFD DRIVER
+M:	Markuss Broks <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+F:	Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
+F:	drivers/mfd/sm5703.c
+F:	drivers/regulator/sm5703-regulator.c
+
 SMACK SECURITY MODULE
 M:	Casey Schaufler <[email protected]>
 L:	[email protected]
drivers/mfd/Kconfig +13 -0
index 3b59456f5545..c13a99ceae99 100644
@@ -1237,6 +1237,19 @@ config MFD_SM501
 	  interface. The device may be connected by PCI or local bus with
 	  varying functions enabled.
 
+config MFD_SM5703
+	tristate "Silicon Mitus SM5703 MFD"
+	depends on I2C
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  This is the core driver for the Silicon Mitus SM5703 multi-function
+	  device. This device is meant to be used in phones and it has numerous
+	  modules, including LED controller, regulators, fuel gauge, MUIC and
+	  charger circuit. It also support muxing a serial interface over USB
+	  data lines.
+
 config MFD_SM501_GPIO
 	bool "Export GPIO via GPIO layer"
 	depends on MFD_SM501 && GPIOLIB
drivers/mfd/Makefile +1 -0
index 858cacf659d6..ca8b86736a36 100644
@@ -275,3 +275,4 @@ rsmu-i2c-objs			:= rsmu_core.o rsmu_i2c.o
 rsmu-spi-objs			:= rsmu_core.o rsmu_spi.o
 obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu-i2c.o
 obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu-spi.o
+obj-$(CONFIG_MFD_SM5703)	+= sm5703.o
drivers/mfd/sm5703.c new file +78 -0

78 lines not on this page · raw message

include/linux/mfd/sm5703.h new file +105 -0

105 lines not on this page · raw message

Signature · 1 line
2.35.1
#22 lore raw

PATCH v5 5/5 regulator: sm5703-regulator: Add regulators support for SM5703 MFD

In reply to Markuss Broks

Regulators block of SM5703 controls several voltage regulators which are used to power various components. There are 3 LDO outputs ranging from 1.5 to 3.3V, a buck regulator ranging from 1V to 3V, two fixed voltage LDO regulators for powering the USB devices and one high-power fixed voltage LDO line (actually two lines) meant to power high-power USB devices.

---
 drivers/regulator/Kconfig            |   7 ++
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/sm5703-regulator.c | 167 +++++++++++++++++++++++++++
 3 files changed, 175 insertions(+)
 create mode 100644 drivers/regulator/sm5703-regulator.c
drivers/regulator/Kconfig +7 -0
index a7effc57bbdb..cbe0f96ca342 100644
@@ -1167,6 +1167,13 @@ config REGULATOR_SLG51000
 	  The SLG51000 is seven compact and customizable low dropout
 	  regulators.
 
+config REGULATOR_SM5703
+	tristate "Silicon Mitus SM5703 regulators"
+	depends on MFD_SM5703
+	help
+	  This driver provides support for voltage regulators of SM5703
+	  multi-function device.
+
 config REGULATOR_STM32_BOOSTER
 	tristate "STMicroelectronics STM32 BOOSTER"
 	depends on ARCH_STM32 || COMPILE_TEST
drivers/regulator/Makefile +1 -0
index 69b5a196acd2..8d3ee8b6d41d 100644
@@ -139,6 +139,7 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
 obj-$(CONFIG_REGULATOR_SC2731) += sc2731-regulator.o
 obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o
 obj-$(CONFIG_REGULATOR_SLG51000) += slg51000-regulator.o
+obj-$(CONFIG_REGULATOR_SM5703) += sm5703-regulator.o
 obj-$(CONFIG_REGULATOR_STM32_BOOSTER) += stm32-booster.o
 obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
 obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
drivers/regulator/sm5703-regulator.c new file +167 -0

167 lines not on this page · raw message

Signature · 1 line
2.35.1
maintainer Reviewed-by on v5 3/5
#9 lore raw

Re: [PATCH v5 3/5] dt-bindings: mfd: Add bindings for Silicon Mitus SM5703 MFD

In reply to Markuss Broks
Quoted 8 lines · Markuss Broks

This patch adds device-tree bindings for the Silicon Mitus SM5703 MFD.

---
 .../bindings/mfd/siliconmitus,sm5703.yaml     | 84 +++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
maintainer Reviewed-by on v5 2/5
#4 lore raw

Re: [PATCH v5 2/5] dt-bindings: regulator: Add bindings for Silicon Mitus SM5703 regulators

In reply to Markuss Broks
Quoted 9 lines · Markuss Broks

This patch adds device-tree bindings for regulators on Silicon Mitus SM5703 MFD.

---
 .../siliconmitus,sm5703-regulator.yaml        | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
#2 lore raw

Re: [PATCH v5 1/5] extcon: sm5502: Clarify SM5703's i2c device ID

In reply to Markuss Broks
Quoted 15 lines · Markuss Broks

While SM5502 and SM5504 are purely micro USB switching circuits, SM5703 is a multi-function device which has multiple modules in it. Change the i2c_device_id of it to avoid conflict with MFD driver.

---
  drivers/extcon/extcon-sm5502.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/extcon/extcon-sm5502.c +0 -0
index 17a40c3782ee..f706f5288257 100644

drivers/extcon/extcon-sm5502.c static SIMPLE_DEV_PM_OPS(sm5502_muic_pm_ops, · line 837

Quoted 8 lines
drivers/extcon/extcon-sm5502.c +1 -1
@@ -831,7 +831,7 @@ static SIMPLE_DEV_PM_OPS(sm5502_muic_pm_ops,
  static const struct i2c_device_id sm5502_i2c_id[] = {
  	{ "sm5502", (kernel_ulong_t)&sm5502_data },
  	{ "sm5504", (kernel_ulong_t)&sm5504_data },
-	{ "sm5703", (kernel_ulong_t)&sm5502_data },
+	{ "sm5703-muic", (kernel_ulong_t)&sm5502_data },
  	{ }
  };
  MODULE_DEVICE_TABLE(i2c, sm5502_i2c_id);

Applied it because this patch depends on already merged patch on extcon-next branch.

Signature · 3 lines
Best Regards,
Samsung Electronics
Chanwoo Choi
maintainer
#23 lore raw

Re: (subset) [PATCH v5 0/5] Add support for Silicon Mitus SM5703 MFD

In reply to Markuss Broks
Quoted 8 lines · Markuss Broks

This series adds support for Silicon Mitus SM5703 MFD and the appropriate device-tree bindings. This only adds support for the regulator module, leaving room for other modules implemented in future (code for other modules is really not ready for submission right now). Silicon Mitus SM5703 is used on various mobile phones, mostly Samsung Galaxy (J5 (2015, 2016), On7, J7 (2015, 2016) ...).

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[2/5] dt-bindings: regulator: Add bindings for Silicon Mitus SM5703 regulators

      commit: d496d68d6ba6debcc135794edb5fdc5a5b4531f1
[5/5] regulator: sm5703-regulator: Add regulators support for SM5703 MFD
      commit: e8858ba89ca377064da130d09648c99683f8bd90

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

#5 lore raw

Re: [PATCH v5 2/5] dt-bindings: regulator: Add bindings for Silicon Mitus SM5703 regulators

In reply to Markuss Broks
Quoted 28 lines · Markuss Broks

This patch adds device-tree bindings for regulators on Silicon Mitus SM5703 MFD.

---
 .../siliconmitus,sm5703-regulator.yaml        | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml new file +12 -0
new file mode 100644
index 000000000000..75ff16b58000
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/siliconmitus,sm5703-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Silicon Mitus SM5703 multi function device regulators
+
+maintainers:
+  - Markuss Broks <[email protected]>
+
+description: |

Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml line 22

Quoted 10 lines
Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml new file +10 -0
+  SM5703 regulators node should be a sub node of the SM5703 MFD node. See SM5703 MFD
+  bindings at Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+  Regulator nodes should be named as USBLDO_<number>, BUCK, VBUS, LDO_<number>.
+  The definition for each of these nodes is defined using the standard
+  binding for regulators at Documentation/devicetree/bindings/regulator/regulator.txt.
+
+properties:
+  buck:
+    type: object
+    $ref: regulators.yaml#

The correct file is regulator.yaml.

That's indicated by this warning:

schemas/regulator/regulators.yaml: ignoring, error parsing file

It will fail worse than that once the example in the MFD file is added.

Lee, Mark, I've said it before, but MFD plus child schemas need to be applied together. Maybe no one cares if dt_binding_check is broken on the MFD tree. The primary issue for me is transient failures during the merge window.

Rob

#6 lore raw

Re: [PATCH v5 2/5] dt-bindings: regulator: Add bindings for Silicon Mitus SM5703 regulators

Hi Rob,

Quoted 31 lines · Rob Herring
Quoted 30 lines · Markuss Broks

This patch adds device-tree bindings for regulators on Silicon Mitus SM5703 MFD.

---
  .../siliconmitus,sm5703-regulator.yaml        | 49 +++++++++++++++++++
  1 file changed, 49 insertions(+)

create mode 100644 Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml

Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml new file +15 -0
new file mode 100644
index 000000000000..75ff16b58000
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/siliconmitus,sm5703-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Silicon Mitus SM5703 multi function device regulators
+
+maintainers:
+  - Markuss Broks <[email protected]>
+
+description: |
+  SM5703 regulators node should be a sub node of the SM5703 MFD node. See SM5703 MFD
+  bindings at Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+  Regulator nodes should be named as USBLDO_<number>, BUCK, VBUS, LDO_<number>.
Quoted 8 lines

Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml line 22

Quoted 7 lines
Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml new file +7 -0
+  The definition for each of these nodes is defined using the standard
+  binding for regulators at Documentation/devicetree/bindings/regulator/regulator.txt.
+
+properties:
+  buck:
+    type: object
+    $ref: regulators.yaml#

The correct file is regulator.yaml.

I was applying all the suggestions, and I thought I had somehow made a typo referring to a wrong file.

Do I re-send the whole series with just the s/regulators/regulator/g? A part of series has already been merged, do I not re-send the already merged patches then?

Quoted 5 lines

That's indicated by this warning:

schemas/regulator/regulators.yaml: ignoring, error parsing file

Quoted 8 lines

It will fail worse than that once the example in the MFD file is added.

Lee, Mark, I've said it before, but MFD plus child schemas need to be applied together. Maybe no one cares if dt_binding_check is broken on the MFD tree. The primary issue for me is transient failures during the merge window.

Rob

- Markuss

#7 lore raw

Re: [PATCH v5 2/5] dt-bindings: regulator: Add bindings for Silicon Mitus SM5703 regulators

Quoted 43 lines · Markuss Broks

Hi Rob,

Quoted 31 lines · Rob Herring
Quoted 30 lines · Markuss Broks

This patch adds device-tree bindings for regulators on Silicon Mitus SM5703 MFD.

---
  .../siliconmitus,sm5703-regulator.yaml        | 49 +++++++++++++++++++
  1 file changed, 49 insertions(+)

create mode 100644 Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml

Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml new file +15 -0
new file mode 100644
index 000000000000..75ff16b58000
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/siliconmitus,sm5703-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Silicon Mitus SM5703 multi function device regulators
+
+maintainers:
+  - Markuss Broks <[email protected]>
+
+description: |
+  SM5703 regulators node should be a sub node of the SM5703 MFD node. See SM5703 MFD
+  bindings at Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+  Regulator nodes should be named as USBLDO_<number>, BUCK, VBUS, LDO_<number>.
Quoted 8 lines

Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml line 22

Quoted 7 lines
Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml new file +7 -0
+  The definition for each of these nodes is defined using the standard
+  binding for regulators at Documentation/devicetree/bindings/regulator/regulator.txt.
+
+properties:
+  buck:
+    type: object
+    $ref: regulators.yaml#

The correct file is regulator.yaml.

Quoted 6 lines

I was applying all the suggestions, and I thought I had somehow made a typo referring to a wrong file.

Do I re-send the whole series with just the s/regulators/regulator/g? A part of series has already been merged, do I not re-send the already merged patches then?

Just send an incremental patch fixing the file name. If there are then errors in the example, then you need to resend the MFD binding with the errors fixed. Unless Lee applies v5 before you do that, then you need an incremental fix for example.

Rob

#11 lore raw

Re: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD

In reply to Markuss Broks
Quoted 1 line · Markuss Broks

Silicon Mitus SM5703 is a multi-function device, meant to be

Please avoid using the term MFD.

How is the device described in the data-sheet?

What do you mean by "meant to be"?

Quoted 1 line

used in mobile devices. It has several modules: LDO, BUCK regulators,

Modules or functions?

Quoted 3 lines

charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger

"I2C"

Quoted 39 lines

circuit, LED driver and regulators are on the main i2c line the device is controlled with.

---
 MAINTAINERS                |   8 +++
 drivers/mfd/Kconfig        |  13 +++++
 drivers/mfd/Makefile       |   1 +
 drivers/mfd/sm5703.c       |  78 +++++++++++++++++++++++++++
 include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++
 5 files changed, 205 insertions(+)
 create mode 100644 drivers/mfd/sm5703.c
 create mode 100644 include/linux/mfd/sm5703.h
MAINTAINERS +8 -0
index 6157e706ed02..6125ed1a3be4 100644
@@ -18172,6 +18172,14 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
 F:	include/linux/srcu*.h
 F:	kernel/rcu/srcu*.c
 
+SM5703 MFD DRIVER
+M:	Markuss Broks <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+F:	Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
+F:	drivers/mfd/sm5703.c
+F:	drivers/regulator/sm5703-regulator.c
+
 SMACK SECURITY MODULE
 M:	Casey Schaufler <[email protected]>
 L:	[email protected]
drivers/mfd/Kconfig +0 -0
index 3b59456f5545..c13a99ceae99 100644
@@ -1237,6 +1237,19 @@ config MFD_SM501
 	  interface. The device may be connected by PCI or local bus with

drivers/mfd/Kconfig config MFD_SM501 · line 1247

Quoted 10 lines
drivers/mfd/Kconfig +8 -0
 	  varying functions enabled.
 
+config MFD_SM5703
+	tristate "Silicon Mitus SM5703 MFD"
+	depends on I2C
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  This is the core driver for the Silicon Mitus SM5703 multi-function

Please drop the MFD term, as above.

drivers/mfd/Kconfig config MFD_SM501 · line 1248

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  device. This device is meant to be used in phones and it has numerous

"meant to be"?

drivers/mfd/Kconfig config MFD_SM501 · line 1249

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  modules, including LED controller, regulators, fuel gauge, MUIC and

Either "an LED controller" or "LED controllers"

Same with "charger circuit" below.

drivers/mfd/Kconfig config MFD_SM501 · line 1250

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  charger circuit. It also support muxing a serial interface over USB

"supports"

What kind of serial?

Quoted 25 lines
drivers/mfd/Kconfig +2 -0
+	  data lines.
+
 config MFD_SM501_GPIO
 	bool "Export GPIO via GPIO layer"
 	depends on MFD_SM501 && GPIOLIB
drivers/mfd/Makefile +1 -0
index 858cacf659d6..ca8b86736a36 100644
@@ -275,3 +275,4 @@ rsmu-i2c-objs			:= rsmu_core.o rsmu_i2c.o
 rsmu-spi-objs			:= rsmu_core.o rsmu_spi.o
 obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu-i2c.o
 obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu-spi.o
+obj-$(CONFIG_MFD_SM5703)	+= sm5703.o
drivers/mfd/sm5703.c new file +5 -0
new file mode 100644
index 000000000000..7f9838149051
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>

drivers/mfd/sm5703.c line 15

Quoted 10 lines
drivers/mfd/sm5703.c new file +10 -0
+#include <linux/i2c.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/sm5703.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+static const struct mfd_cell sm5703_devs[] = {
+	{ .name = "sm5703-regulator", },
+};

Where are the rest of the child drivers?

drivers/mfd/sm5703.c line 19

Quoted 3 lines
drivers/mfd/sm5703.c new file +3 -0
+static const struct regmap_config sm5703_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 8,

Tabbing looks odd. Just use a space.

Quoted 24 lines
drivers/mfd/sm5703.c new file +24 -0
+};
+
+static int sm5703_i2c_probe(struct i2c_client *i2c,
+			    const struct i2c_device_id *id)
+{
+	struct sm5703_dev *sm5703;
+	struct device *dev = &i2c->dev;
+	unsigned int dev_id;
+	int ret;
+
+	sm5703 = devm_kzalloc(dev, sizeof(*sm5703), GFP_KERNEL);
+	if (!sm5703)
+		return -ENOMEM;
+
+	i2c_set_clientdata(i2c, sm5703);
+	sm5703->dev = dev;
+
+	sm5703->regmap = devm_regmap_init_i2c(i2c, &sm5703_regmap_config);
+	if (IS_ERR(sm5703->regmap))
+		return dev_err_probe(dev, PTR_ERR(sm5703->regmap),
+				     "Failed to allocate the register map\n");
+
+	sm5703->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(sm5703->reset_gpio))

drivers/mfd/sm5703.c line 53

Quoted 10 lines
drivers/mfd/sm5703.c new file +10 -0
+		return dev_err_probe(dev, PTR_ERR(sm5703->reset_gpio), "Cannot get reset GPIO\n");
+
+	gpiod_set_value_cansleep(sm5703->reset_gpio, 1);
+	msleep(20);
+
+	ret = regmap_read(sm5703->regmap, SM5703_DEVICE_ID, &dev_id);
+	if (ret)
+		return dev_err_probe(dev, -ENODEV, "Device not found\n");
+
+	ret = devm_mfd_add_devices(sm5703->dev, -1, sm5703_devs,

Not -1. Please use the defines provided.

Quoted 13 lines
drivers/mfd/sm5703.c new file +13 -0
+				   ARRAY_SIZE(sm5703_devs), NULL, 0, NULL);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to add child devices\n");
+
+	return 0;
+}
+
+static const struct of_device_id sm5703_of_match[] = {
+	{ .compatible = "siliconmitus,sm5703", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, sm5703_of_match);
+

drivers/mfd/sm5703.c line 76

Quoted 10 lines
drivers/mfd/sm5703.c new file +10 -0
+static struct i2c_driver sm5703_driver = {
+	.driver = {
+		.name = "sm5703",
+		.of_match_table = sm5703_of_match,
+	},
+	.probe = sm5703_i2c_probe,
+};
+module_i2c_driver(sm5703_driver);
+
+MODULE_DESCRIPTION("Silicon Mitus SM5703 multi-function device driver");

There is no such thing as an MFD.

Quoted 10 lines
drivers/mfd/sm5703.c new file +2 -0
+MODULE_AUTHOR("Markuss Broks <[email protected]>");
+MODULE_LICENSE("GPL");
include/linux/mfd/sm5703.h new file +2 -0
new file mode 100644
index 000000000000..c62affa0d3f1
@@ -0,0 +1,105 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+

include/linux/mfd/sm5703.h line 12

Quoted 10 lines
include/linux/mfd/sm5703.h new file +10 -0
+#ifndef _SM5703_H
+#define _SM5703_H
+
+struct sm5703_dev {
+	struct device *dev;
+	struct regmap *regmap;
+	struct gpio_desc *reset_gpio;
+};
+
+// Regulator-related defines

No C++ style comments.

include/linux/mfd/sm5703.h line 14

Quoted 1 line
include/linux/mfd/sm5703.h new file +1 -0
+#define SM5703_REG_LDO1				0x1A

I'd drop the REG parts from these.

What are these registers called in the data-sheet?

include/linux/mfd/sm5703.h line 17

Quoted 3 lines
include/linux/mfd/sm5703.h new file +3 -0
+#define SM5703_REG_LDO2				0x1B
+#define SM5703_REG_LDO3				0x1C
+#define SM5703_LDO_EN				BIT(3)

Some people like to space out the bits to differentiate them from the register addresses.

include/linux/mfd/sm5703.h line 18

Quoted 1 line
include/linux/mfd/sm5703.h new file +1 -0
+#define SM5703_LDO_VOLT_MASK			0x7

Please keep the bit length consistent, so 0x07 here if these are Byte length registers.

include/linux/mfd/sm5703.h line 23

Quoted 5 lines
include/linux/mfd/sm5703.h new file +5 -0
+#define SM5703_BUCK_VOLT_MASK			0x1F
+#define SM5703_REG_USBLDO12			0x1C
+#define SM5703_REG_EN_USBLDO1			BIT(6)
+#define SM5703_REG_EN_USBLDO2			BIT(7)
+#define SM5703_REG_BUCK				0x1D

Please place these in order.

Quoted 82 lines
include/linux/mfd/sm5703.h new file +82 -0
+#define SM5703_REG_EN_BUCK			BIT(6)
+#define SM5703_USBLDO_MICROVOLT			4800000
+#define SM5703_VBUS_MICROVOLT			5000000
+
+// Fuel-Gauge-related defines
+
+#define SM5703_FG_REG_DEVICE_ID			0x00
+#define SM5703_FG_REG_CNTL			0x01
+#define SM5703_FG_REG_INTFG			0x02
+#define SM5703_FG_REG_INTFG_MASK		0x03
+#define SM5703_FG_REG_STATUS			0x04
+#define SM5703_FG_REG_SOC			0x05
+#define SM5703_FG_REG_OCV			0x06
+#define SM5703_FG_REG_VOLTAGE			0x07
+#define SM5703_FG_REG_CURRENT			0x08
+#define SM5703_FG_REG_TEMPERATURE		0x09
+#define SM5703_FG_REG_CURRENT_EST		0x85
+#define SM5703_FG_REG_FG_OP_STATUS		0x10
+
+// Flash LED driver-related defines
+
+#define SM5703_FLEDCNTL1			0x14
+#define SM5703_FLEDCNTL2			0x15
+#define SM5703_FLEDCNTL3			0x16
+#define SM5703_FLEDCNTL4			0x17
+#define SM5703_FLEDCNTL5			0x18
+#define SM5703_FLEDCNTL6			0x19
+
+#define SM5703_FLEDEN_MASK			0x03
+#define SM5703_FLEDEN_DISABLE			0x00
+#define SM5703_FLEDEN_MOVIE_MODE		0x01
+#define SM5703_FLEDEN_FLASH_MODE		0x02
+#define SM5703_FLEDEN_EXTERNAL			0x03
+
+#define SM5703_IFLED_MASK			0x1F
+#define SM5703_IMLED_MASK			0x1F
+
+// Charger-related, IRQ and device ID defines
+
+#define SM5703_REG_CNTL				0x0C
+#define SM5703_VBUSCNTL				0x0D
+#define SM5703_CHGCNTL1				0x0E
+#define SM5703_CHGCNTL2				0x0F
+#define SM5703_CHGCNTL3				0x10
+#define SM5703_CHGCNTL4				0x11
+#define SM5703_CHGCNTL5				0x12
+#define SM5703_CHGCNTL6				0x13
+#define SM5703_OTGCURRENTCNTL			0x60
+#define SM5703_Q3LIMITCNTL			0x66
+#define SM5703_DEVICE_ID			0x1E
+#define SM5703_OPERATION_MODE			0x07
+#define SM5703_OPERATION_MODE_MASK		0x07
+
+#define SM5703_OPERATION_MODE_SUSPEND		0x00
+#define SM5703_OPERATION_MODE_CHARGING_OFF	0x04
+#define SM5703_OPERATION_MODE_CHARGING_ON	0x05
+#define SM5703_OPERATION_MODE_FLASH_BOOST_MODE	0x06
+#define SM5703_OPERATION_MODE_USB_OTG_MODE	0x07
+
+#define SM5703_BSTOUT				0x0F
+#define SM5703_BSTOUT_MASK			0x0F
+#define SM5703_BSTOUT_SHIFT			0
+
+#define SM5703_BSTOUT_4P5			0x05
+#define SM5703_BSTOUT_5P0			0x0A
+#define SM5703_BSTOUT_5P1			0x0B
+
+#define SM5703_IRQ_STATUS1			0x08
+#define SM5703_IRQ_STATUS2			0x09
+#define SM5703_IRQ_STATUS3			0x0A
+#define SM5703_IRQ_STATUS4			0x0B
+#define SM5703_IRQ_STATUS5			0x6B
+
+#define SM5703_STATUS1_OTGFAIL			0x80
+#define SM5703_STATUS3_DONE			0x08
+#define SM5703_STATUS3_TOPOFF			0x04
+#define SM5703_STATUS3_CHGON			0x01
+#define SM5703_STATUS5_VBUSOVP			0x80
+#define SM5703_STATUS5_VBUSUVLO			0x40
+#define SM5703_STATUS5_VBUSOK			0x20
+
+#endif
Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#12 lore raw

Re: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD

Hi Lee,

Quoted 6 lines · Lee Jones
Quoted 1 line · Markuss Broks

Silicon Mitus SM5703 is a multi-function device, meant to be

Please avoid using the term MFD.

How is the device described in the data-sheet?

I don't have a data-sheet for this device. The only reference I have is downstream Linux driver. Maybe a better way to call it would be PMIC?

Quoted 2 lines

What do you mean by "meant to be"?

"designed to be", it appears that this part is almost exclusively used by Samsung in its mobile phones.

Quoted 3 lines
Quoted 2 lines

used in mobile devices. It has several modules: LDO, BUCK regulators,

Modules or functions?

Some of "modules" are quite separate, so I decided to call it that way. How should it be called?

Quoted 63 lines
Quoted 4 lines

charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger

"I2C"

Quoted 39 lines

circuit, LED driver and regulators are on the main i2c line the device is controlled with.

---
  MAINTAINERS                |   8 +++
  drivers/mfd/Kconfig        |  13 +++++
  drivers/mfd/Makefile       |   1 +
  drivers/mfd/sm5703.c       |  78 +++++++++++++++++++++++++++
  include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++
  5 files changed, 205 insertions(+)

create mode 100644 drivers/mfd/sm5703.c
create mode 100644 include/linux/mfd/sm5703.h

MAINTAINERS +8 -0
index 6157e706ed02..6125ed1a3be4 100644
@@ -18172,6 +18172,14 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
  F:	include/linux/srcu*.h
  F:	kernel/rcu/srcu*.c
 
+SM5703 MFD DRIVER
+M:	Markuss Broks <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+F:	Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
+F:	drivers/mfd/sm5703.c
+F:	drivers/regulator/sm5703-regulator.c
+
  SMACK SECURITY MODULE
  M:	Casey Schaufler <[email protected]>
  L:	[email protected]
drivers/mfd/Kconfig +0 -0
index 3b59456f5545..c13a99ceae99 100644
@@ -1237,6 +1237,19 @@ config MFD_SM501
  	  interface. The device may be connected by PCI or local bus with

drivers/mfd/Kconfig config MFD_SM501 · line 1247

Quoted 10 lines
drivers/mfd/Kconfig +8 -0
  	  varying functions enabled.
 
+config MFD_SM5703
+	tristate "Silicon Mitus SM5703 MFD"
+	depends on I2C
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  This is the core driver for the Silicon Mitus SM5703 multi-function

Please drop the MFD term, as above.

drivers/mfd/Kconfig config MFD_SM501 · line 1248

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  device. This device is meant to be used in phones and it has numerous

"meant to be"?

drivers/mfd/Kconfig config MFD_SM501 · line 1249

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  modules, including LED controller, regulators, fuel gauge, MUIC and

Either "an LED controller" or "LED controllers"

Quoted 6 lines

Same with "charger circuit" below.

drivers/mfd/Kconfig config MFD_SM501 · line 1250

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  charger circuit. It also support muxing a serial interface over USB

"supports"

What kind of serial?

UART as a standard Samsung debug port interface (619K Ohm resistor between data lines is Samsung's debug cable).

Quoted 126 lines
Quoted 26 lines
drivers/mfd/Kconfig +2 -0
+	  data lines.
+
  config MFD_SM501_GPIO
  	bool "Export GPIO via GPIO layer"
  	depends on MFD_SM501 && GPIOLIB
drivers/mfd/Makefile +1 -0
index 858cacf659d6..ca8b86736a36 100644
@@ -275,3 +275,4 @@ rsmu-i2c-objs			:= rsmu_core.o rsmu_i2c.o
  rsmu-spi-objs			:= rsmu_core.o rsmu_spi.o
  obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu-i2c.o
  obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu-spi.o
+obj-$(CONFIG_MFD_SM5703)	+= sm5703.o
drivers/mfd/sm5703.c new file +5 -0
new file mode 100644
index 000000000000..7f9838149051
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>

drivers/mfd/sm5703.c line 15

Quoted 10 lines
drivers/mfd/sm5703.c new file +10 -0
+#include <linux/i2c.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/sm5703.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+static const struct mfd_cell sm5703_devs[] = {
+	{ .name = "sm5703-regulator", },
+};

Where are the rest of the child drivers?

drivers/mfd/sm5703.c line 19

Quoted 3 lines
drivers/mfd/sm5703.c new file +3 -0
+static const struct regmap_config sm5703_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 8,

Tabbing looks odd. Just use a space.

Quoted 24 lines
drivers/mfd/sm5703.c new file +24 -0
+};
+
+static int sm5703_i2c_probe(struct i2c_client *i2c,
+			    const struct i2c_device_id *id)
+{
+	struct sm5703_dev *sm5703;
+	struct device *dev = &i2c->dev;
+	unsigned int dev_id;
+	int ret;
+
+	sm5703 = devm_kzalloc(dev, sizeof(*sm5703), GFP_KERNEL);
+	if (!sm5703)
+		return -ENOMEM;
+
+	i2c_set_clientdata(i2c, sm5703);
+	sm5703->dev = dev;
+
+	sm5703->regmap = devm_regmap_init_i2c(i2c, &sm5703_regmap_config);
+	if (IS_ERR(sm5703->regmap))
+		return dev_err_probe(dev, PTR_ERR(sm5703->regmap),
+				     "Failed to allocate the register map\n");
+
+	sm5703->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(sm5703->reset_gpio))

drivers/mfd/sm5703.c line 53

Quoted 10 lines
drivers/mfd/sm5703.c new file +10 -0
+		return dev_err_probe(dev, PTR_ERR(sm5703->reset_gpio), "Cannot get reset GPIO\n");
+
+	gpiod_set_value_cansleep(sm5703->reset_gpio, 1);
+	msleep(20);
+
+	ret = regmap_read(sm5703->regmap, SM5703_DEVICE_ID, &dev_id);
+	if (ret)
+		return dev_err_probe(dev, -ENODEV, "Device not found\n");
+
+	ret = devm_mfd_add_devices(sm5703->dev, -1, sm5703_devs,

Not -1. Please use the defines provided.

Quoted 13 lines
drivers/mfd/sm5703.c new file +13 -0
+				   ARRAY_SIZE(sm5703_devs), NULL, 0, NULL);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to add child devices\n");
+
+	return 0;
+}
+
+static const struct of_device_id sm5703_of_match[] = {
+	{ .compatible = "siliconmitus,sm5703", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, sm5703_of_match);
+

drivers/mfd/sm5703.c line 76

Quoted 10 lines
drivers/mfd/sm5703.c new file +10 -0
+static struct i2c_driver sm5703_driver = {
+	.driver = {
+		.name = "sm5703",
+		.of_match_table = sm5703_of_match,
+	},
+	.probe = sm5703_i2c_probe,
+};
+module_i2c_driver(sm5703_driver);
+
+MODULE_DESCRIPTION("Silicon Mitus SM5703 multi-function device driver");

There is no such thing as an MFD.

Quoted 10 lines
drivers/mfd/sm5703.c new file +2 -0
+MODULE_AUTHOR("Markuss Broks <[email protected]>");
+MODULE_LICENSE("GPL");
include/linux/mfd/sm5703.h new file +2 -0
new file mode 100644
index 000000000000..c62affa0d3f1
@@ -0,0 +1,105 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+

include/linux/mfd/sm5703.h line 12

Quoted 10 lines
include/linux/mfd/sm5703.h new file +10 -0
+#ifndef _SM5703_H
+#define _SM5703_H
+
+struct sm5703_dev {
+	struct device *dev;
+	struct regmap *regmap;
+	struct gpio_desc *reset_gpio;
+};
+
+// Regulator-related defines

No C++ style comments.

Quoted 4 lines

include/linux/mfd/sm5703.h line 14

Quoted 1 line
include/linux/mfd/sm5703.h new file +1 -0
+#define SM5703_REG_LDO1				0x1A

I'd drop the REG parts from these.

What are these registers called in the data-sheet?

No data-sheet, sadly.

Quoted 92 lines

include/linux/mfd/sm5703.h line 17

Quoted 4 lines
include/linux/mfd/sm5703.h new file +3 -0
+#define SM5703_REG_LDO2				0x1B
+#define SM5703_REG_LDO3				0x1C
+#define SM5703_LDO_EN				BIT(3)

Some people like to space out the bits to differentiate them from the register addresses.

include/linux/mfd/sm5703.h line 18

Quoted 1 line
include/linux/mfd/sm5703.h new file +1 -0
+#define SM5703_LDO_VOLT_MASK			0x7

Please keep the bit length consistent, so 0x07 here if these are Byte length registers.

include/linux/mfd/sm5703.h line 23

Quoted 5 lines
include/linux/mfd/sm5703.h new file +5 -0
+#define SM5703_BUCK_VOLT_MASK			0x1F
+#define SM5703_REG_USBLDO12			0x1C
+#define SM5703_REG_EN_USBLDO1			BIT(6)
+#define SM5703_REG_EN_USBLDO2			BIT(7)
+#define SM5703_REG_BUCK				0x1D

Please place these in order.

Quoted 74 lines
include/linux/mfd/sm5703.h new file +74 -0
+#define SM5703_REG_EN_BUCK			BIT(6)
+#define SM5703_USBLDO_MICROVOLT			4800000
+#define SM5703_VBUS_MICROVOLT			5000000
+
+// Fuel-Gauge-related defines
+
+#define SM5703_FG_REG_DEVICE_ID			0x00
+#define SM5703_FG_REG_CNTL			0x01
+#define SM5703_FG_REG_INTFG			0x02
+#define SM5703_FG_REG_INTFG_MASK		0x03
+#define SM5703_FG_REG_STATUS			0x04
+#define SM5703_FG_REG_SOC			0x05
+#define SM5703_FG_REG_OCV			0x06
+#define SM5703_FG_REG_VOLTAGE			0x07
+#define SM5703_FG_REG_CURRENT			0x08
+#define SM5703_FG_REG_TEMPERATURE		0x09
+#define SM5703_FG_REG_CURRENT_EST		0x85
+#define SM5703_FG_REG_FG_OP_STATUS		0x10
+
+// Flash LED driver-related defines
+
+#define SM5703_FLEDCNTL1			0x14
+#define SM5703_FLEDCNTL2			0x15
+#define SM5703_FLEDCNTL3			0x16
+#define SM5703_FLEDCNTL4			0x17
+#define SM5703_FLEDCNTL5			0x18
+#define SM5703_FLEDCNTL6			0x19
+
+#define SM5703_FLEDEN_MASK			0x03
+#define SM5703_FLEDEN_DISABLE			0x00
+#define SM5703_FLEDEN_MOVIE_MODE		0x01
+#define SM5703_FLEDEN_FLASH_MODE		0x02
+#define SM5703_FLEDEN_EXTERNAL			0x03
+
+#define SM5703_IFLED_MASK			0x1F
+#define SM5703_IMLED_MASK			0x1F
+
+// Charger-related, IRQ and device ID defines
+
+#define SM5703_REG_CNTL				0x0C
+#define SM5703_VBUSCNTL				0x0D
+#define SM5703_CHGCNTL1				0x0E
+#define SM5703_CHGCNTL2				0x0F
+#define SM5703_CHGCNTL3				0x10
+#define SM5703_CHGCNTL4				0x11
+#define SM5703_CHGCNTL5				0x12
+#define SM5703_CHGCNTL6				0x13
+#define SM5703_OTGCURRENTCNTL			0x60
+#define SM5703_Q3LIMITCNTL			0x66
+#define SM5703_DEVICE_ID			0x1E
+#define SM5703_OPERATION_MODE			0x07
+#define SM5703_OPERATION_MODE_MASK		0x07
+
+#define SM5703_OPERATION_MODE_SUSPEND		0x00
+#define SM5703_OPERATION_MODE_CHARGING_OFF	0x04
+#define SM5703_OPERATION_MODE_CHARGING_ON	0x05
+#define SM5703_OPERATION_MODE_FLASH_BOOST_MODE	0x06
+#define SM5703_OPERATION_MODE_USB_OTG_MODE	0x07
+
+#define SM5703_BSTOUT				0x0F
+#define SM5703_BSTOUT_MASK			0x0F
+#define SM5703_BSTOUT_SHIFT			0
+
+#define SM5703_BSTOUT_4P5			0x05
+#define SM5703_BSTOUT_5P0			0x0A
+#define SM5703_BSTOUT_5P1			0x0B
+
+#define SM5703_IRQ_STATUS1			0x08
+#define SM5703_IRQ_STATUS2			0x09
+#define SM5703_IRQ_STATUS3			0x0A
+#define SM5703_IRQ_STATUS4			0x0B
+#define SM5703_IRQ_STATUS5			0x6B
+
+#define SM5703_STATUS1_OTGFAIL			0x80
Quoted 8 lines

include/linux/mfd/sm5703.h line 105

Quoted 8 lines
include/linux/mfd/sm5703.h new file +8 -0
+#define SM5703_STATUS3_DONE			0x08
+#define SM5703_STATUS3_TOPOFF			0x04
+#define SM5703_STATUS3_CHGON			0x01
+#define SM5703_STATUS5_VBUSOVP			0x80
+#define SM5703_STATUS5_VBUSUVLO			0x40
+#define SM5703_STATUS5_VBUSOK			0x20
+
+#endif

- Markuss

#13 lore raw

Re: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD

Quoted 11 lines · Markuss Broks

Hi Lee,

Quoted 6 lines · Lee Jones
Quoted 1 line · Markuss Broks

Silicon Mitus SM5703 is a multi-function device, meant to be

Please avoid using the term MFD.

How is the device described in the data-sheet?

I don't have a data-sheet for this device. The only reference I have is downstream Linux driver. Maybe a better way to call it would be PMIC?

Yes, if that's what this is, PMIC sounds better.

Quoted 3 lines
Quoted 1 line

What do you mean by "meant to be"?

"designed to be", it appears that this part is almost exclusively used by Samsung in its mobile phones.

"designed to be" sounds better.

Quoted 5 lines
Quoted 2 lines
Quoted 1 line

used in mobile devices. It has several modules: LDO, BUCK regulators,

Modules or functions?

Some of "modules" are quite separate, so I decided to call it that way. How should it be called?

Functions.

Quoted 60 lines
Quoted 60 lines
Quoted 3 lines

charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger

"I2C"

Quoted 37 lines

circuit, LED driver and regulators are on the main i2c line the device is controlled with.

---
  MAINTAINERS                |   8 +++
  drivers/mfd/Kconfig        |  13 +++++
  drivers/mfd/Makefile       |   1 +
  drivers/mfd/sm5703.c       |  78 +++++++++++++++++++++++++++
  include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++
  5 files changed, 205 insertions(+)

create mode 100644 drivers/mfd/sm5703.c
create mode 100644 include/linux/mfd/sm5703.h

MAINTAINERS +8 -0
index 6157e706ed02..6125ed1a3be4 100644
@@ -18172,6 +18172,14 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
  F:	include/linux/srcu*.h
  F:	kernel/rcu/srcu*.c
+SM5703 MFD DRIVER
+M:	Markuss Broks <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+F:	Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
+F:	drivers/mfd/sm5703.c
+F:	drivers/regulator/sm5703-regulator.c
+
  SMACK SECURITY MODULE
  M:	Casey Schaufler <[email protected]>
  L:	[email protected]
drivers/mfd/Kconfig +0 -0
index 3b59456f5545..c13a99ceae99 100644

drivers/mfd/Kconfig config MFD_SM501 · line 1246

Quoted 10 lines
drivers/mfd/Kconfig +8 -0
@@ -1237,6 +1237,19 @@ config MFD_SM501
  	  interface. The device may be connected by PCI or local bus with
  	  varying functions enabled.
+config MFD_SM5703
+	tristate "Silicon Mitus SM5703 MFD"
+	depends on I2C
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  This is the core driver for the Silicon Mitus SM5703 multi-function

Please drop the MFD term, as above.

drivers/mfd/Kconfig config MFD_SM501 · line 1248

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  device. This device is meant to be used in phones and it has numerous

"meant to be"?

drivers/mfd/Kconfig config MFD_SM501 · line 1249

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  modules, including LED controller, regulators, fuel gauge, MUIC and

Either "an LED controller" or "LED controllers"

Quoted 8 lines
Quoted 6 lines

Same with "charger circuit" below.

drivers/mfd/Kconfig config MFD_SM501 · line 1250

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  charger circuit. It also support muxing a serial interface over USB

"supports"

What kind of serial?

UART as a standard Samsung debug port interface (619K Ohm resistor between data lines is Samsung's debug cable).

Probably best to state that then.

Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#14 lore raw

Re: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD

In reply to Lee Jones

Hi Lee,

Sorry to bother you again, but I've got additional questions while I was preparing the next version of the series:

Quoted 109 lines · Lee Jones
Quoted 1 line · Markuss Broks

Silicon Mitus SM5703 is a multi-function device, meant to be

Please avoid using the term MFD.

How is the device described in the data-sheet?

What do you mean by "meant to be"?

Quoted 1 line

used in mobile devices. It has several modules: LDO, BUCK regulators,

Modules or functions?

Quoted 3 lines

charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger

"I2C"

Quoted 39 lines

circuit, LED driver and regulators are on the main i2c line the device is controlled with.

---
  MAINTAINERS                |   8 +++
  drivers/mfd/Kconfig        |  13 +++++
  drivers/mfd/Makefile       |   1 +
  drivers/mfd/sm5703.c       |  78 +++++++++++++++++++++++++++
  include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++
  5 files changed, 205 insertions(+)

create mode 100644 drivers/mfd/sm5703.c
create mode 100644 include/linux/mfd/sm5703.h

MAINTAINERS +8 -0
index 6157e706ed02..6125ed1a3be4 100644
@@ -18172,6 +18172,14 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
  F:	include/linux/srcu*.h
  F:	kernel/rcu/srcu*.c
 
+SM5703 MFD DRIVER
+M:	Markuss Broks <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+F:	Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
+F:	drivers/mfd/sm5703.c
+F:	drivers/regulator/sm5703-regulator.c
+
  SMACK SECURITY MODULE
  M:	Casey Schaufler <[email protected]>
  L:	[email protected]
drivers/mfd/Kconfig +0 -0
index 3b59456f5545..c13a99ceae99 100644
@@ -1237,6 +1237,19 @@ config MFD_SM501
  	  interface. The device may be connected by PCI or local bus with

drivers/mfd/Kconfig config MFD_SM501 · line 1247

Quoted 10 lines
drivers/mfd/Kconfig +8 -0
  	  varying functions enabled.
 
+config MFD_SM5703
+	tristate "Silicon Mitus SM5703 MFD"
+	depends on I2C
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  This is the core driver for the Silicon Mitus SM5703 multi-function

Please drop the MFD term, as above.

drivers/mfd/Kconfig config MFD_SM501 · line 1248

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  device. This device is meant to be used in phones and it has numerous

"meant to be"?

drivers/mfd/Kconfig config MFD_SM501 · line 1249

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  modules, including LED controller, regulators, fuel gauge, MUIC and

Either "an LED controller" or "LED controllers"

Same with "charger circuit" below.

drivers/mfd/Kconfig config MFD_SM501 · line 1250

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  charger circuit. It also support muxing a serial interface over USB

"supports"

What kind of serial?

Quoted 28 lines
drivers/mfd/Kconfig +2 -0
+	  data lines.
+
  config MFD_SM501_GPIO
  	bool "Export GPIO via GPIO layer"
  	depends on MFD_SM501 && GPIOLIB
drivers/mfd/Makefile +1 -0
index 858cacf659d6..ca8b86736a36 100644
@@ -275,3 +275,4 @@ rsmu-i2c-objs			:= rsmu_core.o rsmu_i2c.o
  rsmu-spi-objs			:= rsmu_core.o rsmu_spi.o
  obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu-i2c.o
  obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu-spi.o
+obj-$(CONFIG_MFD_SM5703)	+= sm5703.o
drivers/mfd/sm5703.c new file +8 -0
new file mode 100644
index 000000000000..7f9838149051
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/i2c.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/sm5703.h>
Quoted 8 lines

drivers/mfd/sm5703.c line 15

Quoted 7 lines
drivers/mfd/sm5703.c new file +7 -0
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+static const struct mfd_cell sm5703_devs[] = {
+	{ .name = "sm5703-regulator", },
+};

Where are the rest of the child drivers?

Should those devices still be present even though there's no driver for them (yet) ? I have a WIP version of driver for almost every function, but I currently lack time to get them done.

Quoted 89 lines

drivers/mfd/sm5703.c line 19

Quoted 4 lines
drivers/mfd/sm5703.c new file +3 -0
+static const struct regmap_config sm5703_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 8,

Tabbing looks odd. Just use a space.

Quoted 24 lines
drivers/mfd/sm5703.c new file +24 -0
+};
+
+static int sm5703_i2c_probe(struct i2c_client *i2c,
+			    const struct i2c_device_id *id)
+{
+	struct sm5703_dev *sm5703;
+	struct device *dev = &i2c->dev;
+	unsigned int dev_id;
+	int ret;
+
+	sm5703 = devm_kzalloc(dev, sizeof(*sm5703), GFP_KERNEL);
+	if (!sm5703)
+		return -ENOMEM;
+
+	i2c_set_clientdata(i2c, sm5703);
+	sm5703->dev = dev;
+
+	sm5703->regmap = devm_regmap_init_i2c(i2c, &sm5703_regmap_config);
+	if (IS_ERR(sm5703->regmap))
+		return dev_err_probe(dev, PTR_ERR(sm5703->regmap),
+				     "Failed to allocate the register map\n");
+
+	sm5703->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(sm5703->reset_gpio))

drivers/mfd/sm5703.c line 53

Quoted 10 lines
drivers/mfd/sm5703.c new file +10 -0
+		return dev_err_probe(dev, PTR_ERR(sm5703->reset_gpio), "Cannot get reset GPIO\n");
+
+	gpiod_set_value_cansleep(sm5703->reset_gpio, 1);
+	msleep(20);
+
+	ret = regmap_read(sm5703->regmap, SM5703_DEVICE_ID, &dev_id);
+	if (ret)
+		return dev_err_probe(dev, -ENODEV, "Device not found\n");
+
+	ret = devm_mfd_add_devices(sm5703->dev, -1, sm5703_devs,

Not -1. Please use the defines provided.

Quoted 13 lines
drivers/mfd/sm5703.c new file +13 -0
+				   ARRAY_SIZE(sm5703_devs), NULL, 0, NULL);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to add child devices\n");
+
+	return 0;
+}
+
+static const struct of_device_id sm5703_of_match[] = {
+	{ .compatible = "siliconmitus,sm5703", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, sm5703_of_match);
+

drivers/mfd/sm5703.c line 76

Quoted 10 lines
drivers/mfd/sm5703.c new file +10 -0
+static struct i2c_driver sm5703_driver = {
+	.driver = {
+		.name = "sm5703",
+		.of_match_table = sm5703_of_match,
+	},
+	.probe = sm5703_i2c_probe,
+};
+module_i2c_driver(sm5703_driver);
+
+MODULE_DESCRIPTION("Silicon Mitus SM5703 multi-function device driver");

There is no such thing as an MFD.

Quoted 10 lines
drivers/mfd/sm5703.c new file +2 -0
+MODULE_AUTHOR("Markuss Broks <[email protected]>");
+MODULE_LICENSE("GPL");
include/linux/mfd/sm5703.h new file +2 -0
new file mode 100644
index 000000000000..c62affa0d3f1
@@ -0,0 +1,105 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+

include/linux/mfd/sm5703.h line 12

Quoted 10 lines
include/linux/mfd/sm5703.h new file +10 -0
+#ifndef _SM5703_H
+#define _SM5703_H
+
+struct sm5703_dev {
+	struct device *dev;
+	struct regmap *regmap;
+	struct gpio_desc *reset_gpio;
+};
+
+// Regulator-related defines

No C++ style comments.

Quoted 2 lines

include/linux/mfd/sm5703.h line 14

Quoted 1 line
include/linux/mfd/sm5703.h new file +1 -0
+#define SM5703_REG_LDO1				0x1A

I'd drop the REG parts from these.

I have no issues with that, however the already upstreamed sm5703-regulator driver uses those defines. If I change the define name, how should I make changes in that driver, would it be reasonable to send an additional patch together with the new MFD series?

Quoted 94 lines

What are these registers called in the data-sheet?

include/linux/mfd/sm5703.h line 17

Quoted 3 lines
include/linux/mfd/sm5703.h new file +3 -0
+#define SM5703_REG_LDO2				0x1B
+#define SM5703_REG_LDO3				0x1C
+#define SM5703_LDO_EN				BIT(3)

Some people like to space out the bits to differentiate them from the register addresses.

include/linux/mfd/sm5703.h line 18

Quoted 1 line
include/linux/mfd/sm5703.h new file +1 -0
+#define SM5703_LDO_VOLT_MASK			0x7

Please keep the bit length consistent, so 0x07 here if these are Byte length registers.

include/linux/mfd/sm5703.h line 23

Quoted 5 lines
include/linux/mfd/sm5703.h new file +5 -0
+#define SM5703_BUCK_VOLT_MASK			0x1F
+#define SM5703_REG_USBLDO12			0x1C
+#define SM5703_REG_EN_USBLDO1			BIT(6)
+#define SM5703_REG_EN_USBLDO2			BIT(7)
+#define SM5703_REG_BUCK				0x1D

Please place these in order.

Quoted 74 lines
include/linux/mfd/sm5703.h new file +74 -0
+#define SM5703_REG_EN_BUCK			BIT(6)
+#define SM5703_USBLDO_MICROVOLT			4800000
+#define SM5703_VBUS_MICROVOLT			5000000
+
+// Fuel-Gauge-related defines
+
+#define SM5703_FG_REG_DEVICE_ID			0x00
+#define SM5703_FG_REG_CNTL			0x01
+#define SM5703_FG_REG_INTFG			0x02
+#define SM5703_FG_REG_INTFG_MASK		0x03
+#define SM5703_FG_REG_STATUS			0x04
+#define SM5703_FG_REG_SOC			0x05
+#define SM5703_FG_REG_OCV			0x06
+#define SM5703_FG_REG_VOLTAGE			0x07
+#define SM5703_FG_REG_CURRENT			0x08
+#define SM5703_FG_REG_TEMPERATURE		0x09
+#define SM5703_FG_REG_CURRENT_EST		0x85
+#define SM5703_FG_REG_FG_OP_STATUS		0x10
+
+// Flash LED driver-related defines
+
+#define SM5703_FLEDCNTL1			0x14
+#define SM5703_FLEDCNTL2			0x15
+#define SM5703_FLEDCNTL3			0x16
+#define SM5703_FLEDCNTL4			0x17
+#define SM5703_FLEDCNTL5			0x18
+#define SM5703_FLEDCNTL6			0x19
+
+#define SM5703_FLEDEN_MASK			0x03
+#define SM5703_FLEDEN_DISABLE			0x00
+#define SM5703_FLEDEN_MOVIE_MODE		0x01
+#define SM5703_FLEDEN_FLASH_MODE		0x02
+#define SM5703_FLEDEN_EXTERNAL			0x03
+
+#define SM5703_IFLED_MASK			0x1F
+#define SM5703_IMLED_MASK			0x1F
+
+// Charger-related, IRQ and device ID defines
+
+#define SM5703_REG_CNTL				0x0C
+#define SM5703_VBUSCNTL				0x0D
+#define SM5703_CHGCNTL1				0x0E
+#define SM5703_CHGCNTL2				0x0F
+#define SM5703_CHGCNTL3				0x10
+#define SM5703_CHGCNTL4				0x11
+#define SM5703_CHGCNTL5				0x12
+#define SM5703_CHGCNTL6				0x13
+#define SM5703_OTGCURRENTCNTL			0x60
+#define SM5703_Q3LIMITCNTL			0x66
+#define SM5703_DEVICE_ID			0x1E
+#define SM5703_OPERATION_MODE			0x07
+#define SM5703_OPERATION_MODE_MASK		0x07
+
+#define SM5703_OPERATION_MODE_SUSPEND		0x00
+#define SM5703_OPERATION_MODE_CHARGING_OFF	0x04
+#define SM5703_OPERATION_MODE_CHARGING_ON	0x05
+#define SM5703_OPERATION_MODE_FLASH_BOOST_MODE	0x06
+#define SM5703_OPERATION_MODE_USB_OTG_MODE	0x07
+
+#define SM5703_BSTOUT				0x0F
+#define SM5703_BSTOUT_MASK			0x0F
+#define SM5703_BSTOUT_SHIFT			0
+
+#define SM5703_BSTOUT_4P5			0x05
+#define SM5703_BSTOUT_5P0			0x0A
+#define SM5703_BSTOUT_5P1			0x0B
+
+#define SM5703_IRQ_STATUS1			0x08
+#define SM5703_IRQ_STATUS2			0x09
+#define SM5703_IRQ_STATUS3			0x0A
+#define SM5703_IRQ_STATUS4			0x0B
+#define SM5703_IRQ_STATUS5			0x6B
+
+#define SM5703_STATUS1_OTGFAIL			0x80
Quoted 8 lines

include/linux/mfd/sm5703.h line 105

Quoted 8 lines
include/linux/mfd/sm5703.h new file +8 -0
+#define SM5703_STATUS3_DONE			0x08
+#define SM5703_STATUS3_TOPOFF			0x04
+#define SM5703_STATUS3_CHGON			0x01
+#define SM5703_STATUS5_VBUSOVP			0x80
+#define SM5703_STATUS5_VBUSUVLO			0x40
+#define SM5703_STATUS5_VBUSOK			0x20
+
+#endif

- Markuss

#15 lore raw

Re: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD

Quoted 121 lines · Markuss Broks

Hi Lee,

Sorry to bother you again, but I've got additional questions while I was preparing the next version of the series:

Quoted 107 lines · Lee Jones
Quoted 1 line · Markuss Broks

Silicon Mitus SM5703 is a multi-function device, meant to be

Please avoid using the term MFD.

How is the device described in the data-sheet?

What do you mean by "meant to be"?

Quoted 1 line

used in mobile devices. It has several modules: LDO, BUCK regulators,

Modules or functions?

Quoted 3 lines

charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger

"I2C"

Quoted 37 lines

circuit, LED driver and regulators are on the main i2c line the device is controlled with.

---
  MAINTAINERS                |   8 +++
  drivers/mfd/Kconfig        |  13 +++++
  drivers/mfd/Makefile       |   1 +
  drivers/mfd/sm5703.c       |  78 +++++++++++++++++++++++++++
  include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++
  5 files changed, 205 insertions(+)

create mode 100644 drivers/mfd/sm5703.c
create mode 100644 include/linux/mfd/sm5703.h

MAINTAINERS +8 -0
index 6157e706ed02..6125ed1a3be4 100644
@@ -18172,6 +18172,14 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
  F:	include/linux/srcu*.h
  F:	kernel/rcu/srcu*.c
+SM5703 MFD DRIVER
+M:	Markuss Broks <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+F:	Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
+F:	drivers/mfd/sm5703.c
+F:	drivers/regulator/sm5703-regulator.c
+
  SMACK SECURITY MODULE
  M:	Casey Schaufler <[email protected]>
  L:	[email protected]
drivers/mfd/Kconfig +0 -0
index 3b59456f5545..c13a99ceae99 100644

drivers/mfd/Kconfig config MFD_SM501 · line 1246

Quoted 10 lines
drivers/mfd/Kconfig +8 -0
@@ -1237,6 +1237,19 @@ config MFD_SM501
  	  interface. The device may be connected by PCI or local bus with
  	  varying functions enabled.
+config MFD_SM5703
+	tristate "Silicon Mitus SM5703 MFD"
+	depends on I2C
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  This is the core driver for the Silicon Mitus SM5703 multi-function

Please drop the MFD term, as above.

drivers/mfd/Kconfig config MFD_SM501 · line 1248

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  device. This device is meant to be used in phones and it has numerous

"meant to be"?

drivers/mfd/Kconfig config MFD_SM501 · line 1249

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  modules, including LED controller, regulators, fuel gauge, MUIC and

Either "an LED controller" or "LED controllers"

Same with "charger circuit" below.

drivers/mfd/Kconfig config MFD_SM501 · line 1250

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  charger circuit. It also support muxing a serial interface over USB

"supports"

What kind of serial?

Quoted 28 lines
drivers/mfd/Kconfig +2 -0
+	  data lines.
+
  config MFD_SM501_GPIO
  	bool "Export GPIO via GPIO layer"
  	depends on MFD_SM501 && GPIOLIB
drivers/mfd/Makefile +1 -0
index 858cacf659d6..ca8b86736a36 100644
@@ -275,3 +275,4 @@ rsmu-i2c-objs			:= rsmu_core.o rsmu_i2c.o
  rsmu-spi-objs			:= rsmu_core.o rsmu_spi.o
  obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu-i2c.o
  obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu-spi.o
+obj-$(CONFIG_MFD_SM5703)	+= sm5703.o
drivers/mfd/sm5703.c new file +8 -0
new file mode 100644
index 000000000000..7f9838149051
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/i2c.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/sm5703.h>
Quoted 8 lines

drivers/mfd/sm5703.c line 15

Quoted 7 lines
drivers/mfd/sm5703.c new file +7 -0
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+static const struct mfd_cell sm5703_devs[] = {
+	{ .name = "sm5703-regulator", },
+};

Where are the rest of the child drivers?

Quoted 3 lines

Should those devices still be present even though there's no driver for them (yet) ? I have a WIP version of driver for almost every function, but I currently lack time to get them done.

Without them the driver-set is useless, no?

We try to refrain from applying dead code.

A lot of it has a tendency to stay that way.

[...]

Quoted 16 lines
Quoted 16 lines
Quoted 4 lines
drivers/mfd/sm5703.c new file +3 -0
+++ b/include/linux/mfd/sm5703.h
@@ -0,0 +1,105 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+

drivers/mfd/sm5703.c line 12

Quoted 10 lines
drivers/mfd/sm5703.c new file +10 -0
+#ifndef _SM5703_H
+#define _SM5703_H
+
+struct sm5703_dev {
+	struct device *dev;
+	struct regmap *regmap;
+	struct gpio_desc *reset_gpio;
+};
+
+// Regulator-related defines

No C++ style comments.

Quoted 6 lines
Quoted 2 lines

drivers/mfd/sm5703.c line 13

Quoted 1 line
drivers/mfd/sm5703.c new file +1 -0
+#define SM5703_REG_LDO1				0x1A

I'd drop the REG parts from these.

I have no issues with that, however the already upstreamed sm5703-regulator driver uses those defines. If I change the define name, how should I make changes in that driver, would it be reasonable to send an additional patch together with the new MFD series?

It would. You could also keep them in for now.

They're not a major blocker.

Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#16 lore raw

Re: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD

Hi Lee,

Quoted 123 lines · Lee Jones
Quoted 121 lines · Markuss Broks

Hi Lee,

Sorry to bother you again, but I've got additional questions while I was preparing the next version of the series:

Quoted 115 lines · Lee Jones
Quoted 1 line · Markuss Broks

Silicon Mitus SM5703 is a multi-function device, meant to be

Please avoid using the term MFD.

How is the device described in the data-sheet?

What do you mean by "meant to be"?

Quoted 1 line

used in mobile devices. It has several modules: LDO, BUCK regulators,

Modules or functions?

Quoted 3 lines

charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger

"I2C"

Quoted 37 lines

circuit, LED driver and regulators are on the main i2c line the device is controlled with.

---
   MAINTAINERS                |   8 +++
   drivers/mfd/Kconfig        |  13 +++++
   drivers/mfd/Makefile       |   1 +
   drivers/mfd/sm5703.c       |  78 +++++++++++++++++++++++++++
   include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++
   5 files changed, 205 insertions(+)

create mode 100644 drivers/mfd/sm5703.c
create mode 100644 include/linux/mfd/sm5703.h

MAINTAINERS +8 -0
index 6157e706ed02..6125ed1a3be4 100644
@@ -18172,6 +18172,14 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
   F:	include/linux/srcu*.h
   F:	kernel/rcu/srcu*.c
+SM5703 MFD DRIVER
+M:	Markuss Broks <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+F:	Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
+F:	drivers/mfd/sm5703.c
+F:	drivers/regulator/sm5703-regulator.c
+
   SMACK SECURITY MODULE
   M:	Casey Schaufler <[email protected]>
   L:	[email protected]
drivers/mfd/Kconfig +0 -0
index 3b59456f5545..c13a99ceae99 100644

drivers/mfd/Kconfig config MFD_SM501 · line 1246

Quoted 10 lines
drivers/mfd/Kconfig +8 -0
@@ -1237,6 +1237,19 @@ config MFD_SM501
   	  interface. The device may be connected by PCI or local bus with
   	  varying functions enabled.
+config MFD_SM5703
+	tristate "Silicon Mitus SM5703 MFD"
+	depends on I2C
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  This is the core driver for the Silicon Mitus SM5703 multi-function

Please drop the MFD term, as above.

drivers/mfd/Kconfig config MFD_SM501 · line 1248

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  device. This device is meant to be used in phones and it has numerous

"meant to be"?

drivers/mfd/Kconfig config MFD_SM501 · line 1249

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  modules, including LED controller, regulators, fuel gauge, MUIC and

Either "an LED controller" or "LED controllers"

Same with "charger circuit" below.

drivers/mfd/Kconfig config MFD_SM501 · line 1250

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  charger circuit. It also support muxing a serial interface over USB

"supports"

What kind of serial?

Quoted 25 lines
drivers/mfd/Kconfig +2 -0
+	  data lines.
+
   config MFD_SM501_GPIO
   	bool "Export GPIO via GPIO layer"
   	depends on MFD_SM501 && GPIOLIB
drivers/mfd/Makefile +1 -0
index 858cacf659d6..ca8b86736a36 100644
@@ -275,3 +275,4 @@ rsmu-i2c-objs			:= rsmu_core.o rsmu_i2c.o
   rsmu-spi-objs			:= rsmu_core.o rsmu_spi.o
   obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu-i2c.o
   obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu-spi.o
+obj-$(CONFIG_MFD_SM5703)	+= sm5703.o
drivers/mfd/sm5703.c new file +5 -0
new file mode 100644
index 000000000000..7f9838149051
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>

drivers/mfd/sm5703.c line 15

Quoted 10 lines
drivers/mfd/sm5703.c new file +10 -0
+#include <linux/i2c.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/sm5703.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+static const struct mfd_cell sm5703_devs[] = {
+	{ .name = "sm5703-regulator", },
+};

Where are the rest of the child drivers?

Quoted 8 lines
Quoted 3 lines

Should those devices still be present even though there's no driver for them (yet) ? I have a WIP version of driver for almost every function, but I currently lack time to get them done.

Without them the driver-set is useless, no?

We try to refrain from applying dead code.

A lot of it has a tendency to stay that way.

Well, in my opinion, having just the regulator driver is already useful enough: my board (Samsung Galaxy J5 (2015) ) uses one of LDO outputs for powering the touchscreen. Touchscreen is kind of vital functionality for a phone so I decided to upstream parts that are necessary for it first and finish up other stuff later. It's not the only board that uses SM5703's regulators for supplying all different kinds of hardware, either.

Quoted 20 lines

[...]

Quoted 17 lines
Quoted 17 lines
Quoted 4 lines

+++ b/include/linux/mfd/sm5703.h

drivers/mfd/sm5703.c new file +2 -0
@@ -0,0 +1,105 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+

drivers/mfd/sm5703.c line 12

Quoted 10 lines
drivers/mfd/sm5703.c new file +10 -0
+#ifndef _SM5703_H
+#define _SM5703_H
+
+struct sm5703_dev {
+	struct device *dev;
+	struct regmap *regmap;
+	struct gpio_desc *reset_gpio;
+};
+
+// Regulator-related defines

No C++ style comments.

Quoted 1 line
drivers/mfd/sm5703.c new file +1 -0
+#define SM5703_REG_LDO1				0x1A
Quoted 9 lines
Quoted 5 lines
Quoted 1 line

I'd drop the REG parts from these.

I have no issues with that, however the already upstreamed sm5703-regulator driver uses those defines. If I change the define name, how should I make changes in that driver, would it be reasonable to send an additional patch together with the new MFD series?

It would. You could also keep them in for now.

They're not a major blocker.

- Markuss

#17 lore raw

Re: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD

Quoted 133 lines · Markuss Broks

Hi Lee,

Quoted 130 lines · Lee Jones
Quoted 121 lines · Markuss Broks

Hi Lee,

Sorry to bother you again, but I've got additional questions while I was preparing the next version of the series:

Quoted 107 lines · Lee Jones
Quoted 1 line · Markuss Broks

Silicon Mitus SM5703 is a multi-function device, meant to be

Please avoid using the term MFD.

How is the device described in the data-sheet?

What do you mean by "meant to be"?

Quoted 1 line

used in mobile devices. It has several modules: LDO, BUCK regulators,

Modules or functions?

Quoted 3 lines

charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger

"I2C"

Quoted 37 lines

circuit, LED driver and regulators are on the main i2c line the device is controlled with.

---
   MAINTAINERS                |   8 +++
   drivers/mfd/Kconfig        |  13 +++++
   drivers/mfd/Makefile       |   1 +
   drivers/mfd/sm5703.c       |  78 +++++++++++++++++++++++++++
   include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++
   5 files changed, 205 insertions(+)

create mode 100644 drivers/mfd/sm5703.c
create mode 100644 include/linux/mfd/sm5703.h

MAINTAINERS +8 -0
index 6157e706ed02..6125ed1a3be4 100644
@@ -18172,6 +18172,14 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
   F:	include/linux/srcu*.h
   F:	kernel/rcu/srcu*.c
+SM5703 MFD DRIVER
+M:	Markuss Broks <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+F:	Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
+F:	drivers/mfd/sm5703.c
+F:	drivers/regulator/sm5703-regulator.c
+
   SMACK SECURITY MODULE
   M:	Casey Schaufler <[email protected]>
   L:	[email protected]
drivers/mfd/Kconfig +0 -0
index 3b59456f5545..c13a99ceae99 100644

drivers/mfd/Kconfig config MFD_SM501 · line 1246

Quoted 10 lines
drivers/mfd/Kconfig +8 -0
@@ -1237,6 +1237,19 @@ config MFD_SM501
   	  interface. The device may be connected by PCI or local bus with
   	  varying functions enabled.
+config MFD_SM5703
+	tristate "Silicon Mitus SM5703 MFD"
+	depends on I2C
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  This is the core driver for the Silicon Mitus SM5703 multi-function

Please drop the MFD term, as above.

drivers/mfd/Kconfig config MFD_SM501 · line 1248

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  device. This device is meant to be used in phones and it has numerous

"meant to be"?

drivers/mfd/Kconfig config MFD_SM501 · line 1249

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  modules, including LED controller, regulators, fuel gauge, MUIC and

Either "an LED controller" or "LED controllers"

Same with "charger circuit" below.

drivers/mfd/Kconfig config MFD_SM501 · line 1250

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  charger circuit. It also support muxing a serial interface over USB

"supports"

What kind of serial?

Quoted 28 lines
drivers/mfd/Kconfig +2 -0
+	  data lines.
+
   config MFD_SM501_GPIO
   	bool "Export GPIO via GPIO layer"
   	depends on MFD_SM501 && GPIOLIB
drivers/mfd/Makefile +1 -0
index 858cacf659d6..ca8b86736a36 100644
@@ -275,3 +275,4 @@ rsmu-i2c-objs			:= rsmu_core.o rsmu_i2c.o
   rsmu-spi-objs			:= rsmu_core.o rsmu_spi.o
   obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu-i2c.o
   obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu-spi.o
+obj-$(CONFIG_MFD_SM5703)	+= sm5703.o
drivers/mfd/sm5703.c new file +8 -0
new file mode 100644
index 000000000000..7f9838149051
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/i2c.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/sm5703.h>
Quoted 8 lines

drivers/mfd/sm5703.c line 15

Quoted 7 lines
drivers/mfd/sm5703.c new file +7 -0
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+static const struct mfd_cell sm5703_devs[] = {
+	{ .name = "sm5703-regulator", },
+};

Where are the rest of the child drivers?

Quoted 3 lines

Should those devices still be present even though there's no driver for them (yet) ? I have a WIP version of driver for almost every function, but I currently lack time to get them done.

Without them the driver-set is useless, no?

We try to refrain from applying dead code.

Quoted 7 lines
Quoted 1 line

A lot of it has a tendency to stay that way.

Well, in my opinion, having just the regulator driver is already useful
enough: my board (Samsung Galaxy J5 (2015) ) uses one of LDO outputs for powering the touchscreen. Touchscreen is kind of vital functionality for a phone so I decided to upstream parts that are necessary for it first and finish up other stuff later. It's not the only board that uses SM5703's regulators for supplying all different kinds of hardware, either.

Upstreaming functionality which is useful on its own is fine, but that doesn't tick all of the boxes to justify an MFD. This is a lot of code which is hard to justify if it only registers a Regulator driver.

Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#18 lore raw

Re: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD

Hi Lee,

Quoted 142 lines · Lee Jones
Quoted 133 lines · Markuss Broks

Hi Lee,

Quoted 130 lines · Lee Jones
Quoted 121 lines · Markuss Broks

Hi Lee,

Sorry to bother you again, but I've got additional questions while I was preparing the next version of the series:

Quoted 107 lines · Lee Jones
Quoted 1 line · Markuss Broks

Silicon Mitus SM5703 is a multi-function device, meant to be

Please avoid using the term MFD.

How is the device described in the data-sheet?

What do you mean by "meant to be"?

Quoted 1 line

used in mobile devices. It has several modules: LDO, BUCK regulators,

Modules or functions?

Quoted 3 lines

charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger

"I2C"

Quoted 37 lines

circuit, LED driver and regulators are on the main i2c line the device is controlled with.

---
    MAINTAINERS                |   8 +++
    drivers/mfd/Kconfig        |  13 +++++
    drivers/mfd/Makefile       |   1 +
    drivers/mfd/sm5703.c       |  78 +++++++++++++++++++++++++++
    include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++
    5 files changed, 205 insertions(+)
    create mode 100644 drivers/mfd/sm5703.c
    create mode 100644 include/linux/mfd/sm5703.h
MAINTAINERS +8 -0
index 6157e706ed02..6125ed1a3be4 100644
@@ -18172,6 +18172,14 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
    F:	include/linux/srcu*.h
    F:	kernel/rcu/srcu*.c
+SM5703 MFD DRIVER
+M:	Markuss Broks <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+F:	Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
+F:	drivers/mfd/sm5703.c
+F:	drivers/regulator/sm5703-regulator.c
+
    SMACK SECURITY MODULE
    M:	Casey Schaufler <[email protected]>
    L:	[email protected]
drivers/mfd/Kconfig +0 -0
index 3b59456f5545..c13a99ceae99 100644

drivers/mfd/Kconfig config MFD_SM501 · line 1246

Quoted 10 lines
drivers/mfd/Kconfig +8 -0
@@ -1237,6 +1237,19 @@ config MFD_SM501
    	  interface. The device may be connected by PCI or local bus with
    	  varying functions enabled.
+config MFD_SM5703
+	tristate "Silicon Mitus SM5703 MFD"
+	depends on I2C
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  This is the core driver for the Silicon Mitus SM5703 multi-function

Please drop the MFD term, as above.

drivers/mfd/Kconfig config MFD_SM501 · line 1248

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  device. This device is meant to be used in phones and it has numerous

"meant to be"?

drivers/mfd/Kconfig config MFD_SM501 · line 1249

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  modules, including LED controller, regulators, fuel gauge, MUIC and

Either "an LED controller" or "LED controllers"

Same with "charger circuit" below.

drivers/mfd/Kconfig config MFD_SM501 · line 1250

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  charger circuit. It also support muxing a serial interface over USB

"supports"

What kind of serial?

Quoted 28 lines
drivers/mfd/Kconfig +2 -0
+	  data lines.
+
    config MFD_SM501_GPIO
    	bool "Export GPIO via GPIO layer"
    	depends on MFD_SM501 && GPIOLIB
drivers/mfd/Makefile +1 -0
index 858cacf659d6..ca8b86736a36 100644
@@ -275,3 +275,4 @@ rsmu-i2c-objs			:= rsmu_core.o rsmu_i2c.o
    rsmu-spi-objs			:= rsmu_core.o rsmu_spi.o
    obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu-i2c.o
    obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu-spi.o
+obj-$(CONFIG_MFD_SM5703)	+= sm5703.o
drivers/mfd/sm5703.c new file +8 -0
new file mode 100644
index 000000000000..7f9838149051
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/i2c.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/sm5703.h>
Quoted 8 lines

drivers/mfd/sm5703.c line 15

Quoted 7 lines
drivers/mfd/sm5703.c new file +7 -0
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+static const struct mfd_cell sm5703_devs[] = {
+	{ .name = "sm5703-regulator", },
+};

Where are the rest of the child drivers?

Quoted 3 lines

Should those devices still be present even though there's no driver for them (yet) ? I have a WIP version of driver for almost every function, but I currently lack time to get them done.

Without them the driver-set is useless, no?

We try to refrain from applying dead code.

Quoted 7 lines
Quoted 1 line

A lot of it has a tendency to stay that way.

Well, in my opinion, having just the regulator driver is already useful
enough: my board (Samsung Galaxy J5 (2015) ) uses one of LDO outputs for powering the touchscreen. Touchscreen is kind of vital functionality for a phone so I decided to upstream parts that are necessary for it first and finish up other stuff later. It's not the only board that uses SM5703's regulators for supplying all different kinds of hardware, either.

Quoted 3 lines

Upstreaming functionality which is useful on its own is fine, but that doesn't tick all of the boxes to justify an MFD. This is a lot of code which is hard to justify if it only registers a Regulator driver.

Do you think I should hold on this series until I have other things done? Alternatively, I could make the regulator driver standalone, dedicated, but then when I'd add other functionality I'd have to redo it and add the MFD driver back, that I believe would be quite annoying from maintainers' and sanity perspective. The other functions left on the main control I2C are also not really "vital" to device's functionality (Flash LED and charger), so the regulator function makes the most sense to be available first, which was my motivation behind upstreaming that first.

Quoted 1 line

- Markuss

#19 lore raw

Re: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD

Quoted 150 lines · Markuss Broks

Hi Lee,

Quoted 143 lines · Lee Jones
Quoted 133 lines · Markuss Broks

Hi Lee,

Quoted 130 lines · Lee Jones
Quoted 121 lines · Markuss Broks

Hi Lee,

Sorry to bother you again, but I've got additional questions while I was preparing the next version of the series:

Quoted 107 lines · Lee Jones
Quoted 1 line · Markuss Broks

Silicon Mitus SM5703 is a multi-function device, meant to be

Please avoid using the term MFD.

How is the device described in the data-sheet?

What do you mean by "meant to be"?

Quoted 1 line

used in mobile devices. It has several modules: LDO, BUCK regulators,

Modules or functions?

Quoted 3 lines

charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger

"I2C"

Quoted 37 lines

circuit, LED driver and regulators are on the main i2c line the device is controlled with.

---
    MAINTAINERS                |   8 +++
    drivers/mfd/Kconfig        |  13 +++++
    drivers/mfd/Makefile       |   1 +
    drivers/mfd/sm5703.c       |  78 +++++++++++++++++++++++++++
    include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++
    5 files changed, 205 insertions(+)
    create mode 100644 drivers/mfd/sm5703.c
    create mode 100644 include/linux/mfd/sm5703.h
MAINTAINERS +8 -0
index 6157e706ed02..6125ed1a3be4 100644
@@ -18172,6 +18172,14 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
    F:	include/linux/srcu*.h
    F:	kernel/rcu/srcu*.c
+SM5703 MFD DRIVER
+M:	Markuss Broks <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+F:	Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
+F:	drivers/mfd/sm5703.c
+F:	drivers/regulator/sm5703-regulator.c
+
    SMACK SECURITY MODULE
    M:	Casey Schaufler <[email protected]>
    L:	[email protected]
drivers/mfd/Kconfig +0 -0
index 3b59456f5545..c13a99ceae99 100644

drivers/mfd/Kconfig config MFD_SM501 · line 1246

Quoted 10 lines
drivers/mfd/Kconfig +8 -0
@@ -1237,6 +1237,19 @@ config MFD_SM501
    	  interface. The device may be connected by PCI or local bus with
    	  varying functions enabled.
+config MFD_SM5703
+	tristate "Silicon Mitus SM5703 MFD"
+	depends on I2C
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  This is the core driver for the Silicon Mitus SM5703 multi-function

Please drop the MFD term, as above.

drivers/mfd/Kconfig config MFD_SM501 · line 1247

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  device. This device is meant to be used in phones and it has numerous

"meant to be"?

drivers/mfd/Kconfig config MFD_SM501 · line 1248

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  modules, including LED controller, regulators, fuel gauge, MUIC and

Either "an LED controller" or "LED controllers"

Same with "charger circuit" below.

drivers/mfd/Kconfig config MFD_SM501 · line 1249

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  charger circuit. It also support muxing a serial interface over USB

"supports"

What kind of serial?

Quoted 28 lines
drivers/mfd/Kconfig +2 -0
+	  data lines.
+
    config MFD_SM501_GPIO
    	bool "Export GPIO via GPIO layer"
    	depends on MFD_SM501 && GPIOLIB
drivers/mfd/Makefile +1 -0
index 858cacf659d6..ca8b86736a36 100644
@@ -275,3 +275,4 @@ rsmu-i2c-objs			:= rsmu_core.o rsmu_i2c.o
    rsmu-spi-objs			:= rsmu_core.o rsmu_spi.o
    obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu-i2c.o
    obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu-spi.o
+obj-$(CONFIG_MFD_SM5703)	+= sm5703.o
drivers/mfd/sm5703.c new file +8 -0
new file mode 100644
index 000000000000..7f9838149051
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/i2c.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/sm5703.h>
Quoted 8 lines

drivers/mfd/sm5703.c line 15

Quoted 7 lines
drivers/mfd/sm5703.c new file +7 -0
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+static const struct mfd_cell sm5703_devs[] = {
+	{ .name = "sm5703-regulator", },
+};

Where are the rest of the child drivers?

Quoted 3 lines

Should those devices still be present even though there's no driver for them (yet) ? I have a WIP version of driver for almost every function, but I currently lack time to get them done.

Without them the driver-set is useless, no?

We try to refrain from applying dead code.

Quoted 7 lines
Quoted 1 line

A lot of it has a tendency to stay that way.

Well, in my opinion, having just the regulator driver is already useful
enough: my board (Samsung Galaxy J5 (2015) ) uses one of LDO outputs for powering the touchscreen. Touchscreen is kind of vital functionality for a phone so I decided to upstream parts that are necessary for it first and finish up other stuff later. It's not the only board that uses SM5703's regulators for supplying all different kinds of hardware, either.

Quoted 3 lines

Upstreaming functionality which is useful on its own is fine, but that doesn't tick all of the boxes to justify an MFD. This is a lot of code which is hard to justify if it only registers a Regulator driver.

Quoted 8 lines

Do you think I should hold on this series until I have other things done? Alternatively, I could make the regulator driver standalone, dedicated, but then when I'd add other functionality I'd have to redo it and add the MFD driver back, that I believe would be quite annoying from maintainers' and sanity perspective. The other functions left on the main control I2C are also not really "vital" to device's functionality (Flash LED and charger), so the regulator function makes the most sense to be available first, which was my motivation behind upstreaming that first.

What's the reason for this being an MFD in the first place?

Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#20 lore raw

Re: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD

Hi Lee,

Quoted 158 lines · Lee Jones
Quoted 148 lines · Markuss Broks

Hi Lee,

Quoted 142 lines · Lee Jones
Quoted 133 lines · Markuss Broks

Hi Lee,

Quoted 130 lines · Lee Jones
Quoted 121 lines · Markuss Broks

Hi Lee,

Sorry to bother you again, but I've got additional questions while I was preparing the next version of the series:

Quoted 107 lines · Lee Jones
Quoted 1 line · Markuss Broks

Silicon Mitus SM5703 is a multi-function device, meant to be

Please avoid using the term MFD.

How is the device described in the data-sheet?

What do you mean by "meant to be"?

Quoted 1 line

used in mobile devices. It has several modules: LDO, BUCK regulators,

Modules or functions?

Quoted 3 lines

charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger

"I2C"

Quoted 37 lines

circuit, LED driver and regulators are on the main i2c line the device is controlled with.

---
     MAINTAINERS                |   8 +++
     drivers/mfd/Kconfig        |  13 +++++
     drivers/mfd/Makefile       |   1 +
     drivers/mfd/sm5703.c       |  78 +++++++++++++++++++++++++++
     include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++
     5 files changed, 205 insertions(+)
     create mode 100644 drivers/mfd/sm5703.c
     create mode 100644 include/linux/mfd/sm5703.h
MAINTAINERS +8 -0
index 6157e706ed02..6125ed1a3be4 100644
@@ -18172,6 +18172,14 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
     F:	include/linux/srcu*.h
     F:	kernel/rcu/srcu*.c
+SM5703 MFD DRIVER
+M:	Markuss Broks <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml
+F:	Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulator.yaml
+F:	drivers/mfd/sm5703.c
+F:	drivers/regulator/sm5703-regulator.c
+
     SMACK SECURITY MODULE
     M:	Casey Schaufler <[email protected]>
     L:	[email protected]
drivers/mfd/Kconfig +0 -0
index 3b59456f5545..c13a99ceae99 100644

drivers/mfd/Kconfig config MFD_SM501 · line 1246

Quoted 10 lines
drivers/mfd/Kconfig +8 -0
@@ -1237,6 +1237,19 @@ config MFD_SM501
     	  interface. The device may be connected by PCI or local bus with
     	  varying functions enabled.
+config MFD_SM5703
+	tristate "Silicon Mitus SM5703 MFD"
+	depends on I2C
+	depends on OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  This is the core driver for the Silicon Mitus SM5703 multi-function

Please drop the MFD term, as above.

drivers/mfd/Kconfig config MFD_SM501 · line 1247

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  device. This device is meant to be used in phones and it has numerous

"meant to be"?

drivers/mfd/Kconfig config MFD_SM501 · line 1248

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  modules, including LED controller, regulators, fuel gauge, MUIC and

Either "an LED controller" or "LED controllers"

Same with "charger circuit" below.

drivers/mfd/Kconfig config MFD_SM501 · line 1249

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+	  charger circuit. It also support muxing a serial interface over USB

"supports"

What kind of serial?

Quoted 28 lines
drivers/mfd/Kconfig +2 -0
+	  data lines.
+
     config MFD_SM501_GPIO
     	bool "Export GPIO via GPIO layer"
     	depends on MFD_SM501 && GPIOLIB
drivers/mfd/Makefile +1 -0
index 858cacf659d6..ca8b86736a36 100644
@@ -275,3 +275,4 @@ rsmu-i2c-objs			:= rsmu_core.o rsmu_i2c.o
     rsmu-spi-objs			:= rsmu_core.o rsmu_spi.o
     obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu-i2c.o
     obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu-spi.o
+obj-$(CONFIG_MFD_SM5703)	+= sm5703.o
drivers/mfd/sm5703.c new file +8 -0
new file mode 100644
index 000000000000..7f9838149051
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/i2c.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/sm5703.h>
Quoted 8 lines

drivers/mfd/sm5703.c line 15

Quoted 7 lines
drivers/mfd/sm5703.c new file +7 -0
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+static const struct mfd_cell sm5703_devs[] = {
+	{ .name = "sm5703-regulator", },
+};

Where are the rest of the child drivers?

Quoted 3 lines

Should those devices still be present even though there's no driver for them (yet) ? I have a WIP version of driver for almost every function, but I currently lack time to get them done.

Without them the driver-set is useless, no?

We try to refrain from applying dead code.

Quoted 7 lines
Quoted 1 line

A lot of it has a tendency to stay that way.

Well, in my opinion, having just the regulator driver is already useful
enough: my board (Samsung Galaxy J5 (2015) ) uses one of LDO outputs for powering the touchscreen. Touchscreen is kind of vital functionality for a phone so I decided to upstream parts that are necessary for it first and finish up other stuff later. It's not the only board that uses SM5703's regulators for supplying all different kinds of hardware, either.

Quoted 3 lines

Upstreaming functionality which is useful on its own is fine, but that doesn't tick all of the boxes to justify an MFD. This is a lot of code which is hard to justify if it only registers a Regulator driver.

Quoted 8 lines

Do you think I should hold on this series until I have other things done? Alternatively, I could make the regulator driver standalone, dedicated, but then when I'd add other functionality I'd have to redo it and add the MFD driver back, that I believe would be quite annoying from maintainers' and sanity perspective. The other functions left on the main control I2C are also not really "vital" to device's functionality (Flash LED and charger), so the regulator function makes the most sense to be available first, which was my motivation behind upstreaming that first.

Quoted 1 line

What's the reason for this being an MFD in the first place?

Well, the "main" I2C interface is shared between three functions: regulators, Flash LED and charger. I call this one the "main" one because the device is controlled with it: you can select internal clock rate, enable or disable the PMIC and do other things that more of apply to the whole PMIC, not just the separate functions (as is the case with fuel gauge and MUIC I2C) . That's the reason for this being an MFD: those three functions share one I2C interface. While they might not be implemented at the moment, this places a foundation for adding future support.
- Markuss

#21 lore raw

Re: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD

Quoted 23 lines · Markuss Broks
Quoted 22 lines · Lee Jones
Quoted 21 lines · Markuss Broks
Quoted 21 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+static const struct mfd_cell sm5703_devs[] = {
+	{ .name = "sm5703-regulator", },
+};

Where are the rest of the child drivers?

Should those devices still be present even though there's no driver for them (yet) ? I have a WIP version of driver for almost every function, but I currently lack time to get them done.

Without them the driver-set is useless, no?

We try to refrain from applying dead code.

Quoted 7 lines
Quoted 1 line

A lot of it has a tendency to stay that way.

Well, in my opinion, having just the regulator driver is already useful
enough: my board (Samsung Galaxy J5 (2015) ) uses one of LDO outputs for powering the touchscreen. Touchscreen is kind of vital functionality for a phone so I decided to upstream parts that are necessary for it first and finish up other stuff later. It's not the only board that uses SM5703's regulators for supplying all different kinds of hardware, either.

Upstreaming functionality which is useful on its own is fine, but that doesn't tick all of the boxes to justify an MFD. This is a lot of code which is hard to justify if it only registers a Regulator driver.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Do you think I should hold on this series until I have other things done? Alternatively, I could make the regulator driver standalone, dedicated, but then when I'd add other functionality I'd have to redo it and add the MFD driver back, that I believe would be quite annoying from maintainers' and sanity perspective. The other functions left on the main control I2C are also not really "vital" to device's functionality (Flash LED and charger), so the regulator function makes the most sense to be available first, which was my motivation behind upstreaming that first.

Can you configure your mailer to stop removing the space between messages please?

Quoted 10 lines
Quoted 1 line

What's the reason for this being an MFD in the first place?

Well, the "main" I2C interface is shared between three functions:
regulators, Flash LED and charger. I call this one the "main" one because the device is controlled with it: you can select internal clock rate, enable or disable the PMIC and do other things that more of apply to the whole PMIC, not just the separate functions (as is the case with fuel gauge and MUIC I2C) . That's the reason for this being an MFD: those three functions share one I2C interface. While they might not be implemented at the moment, this places a foundation for adding future support.

Okay, so the functions cannot be controlled separately? That's fine.

For acceptance into MFD, you need to enable more than one function.

Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog