Skip to contentSkip to conversation

mfd: add adp5585 gpio and pwm support

PATCH In review Frank Li 7 participants 15 messages Jul 16, 2024 – Aug 5, 2024

Subsystems (6)
lore
Share & tools
lore

Frank Li

author maintainer
#0 lore raw

cover mfd: add adp5585 gpio and pwm support

adp5585 is totally difference adp5588, which in
drivers/input/keyboard/adp5588-keys.c.

So create new driver for it.

---
Clark Wang (1):

      pwm: adp5585: add adp5585 PWM support

Frank Li (3):

      dt-bindings: mfd: Add i2c device adi5585
      arm64: dts: imx93-11x11-evk: add adi,adp5585 gpio and pwm
      arm64: dts: imx95-19x19-evk: add i2c2 and adi,adp5585

Haibo Chen (2):
mfd: adp5585: add ADI adp5585 core support
gpio: adp5585-gpio: add adp5585-gpio support

 .../devicetree/bindings/mfd/adi,adp5585.yaml       |  83 ++++++++
 arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts  |  16 ++
 arch/arm64/boot/dts/freescale/imx95-19x19-evk.dts  |  30 +++
 drivers/gpio/Kconfig                               |   7 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-adp5585.c                        | 184 ++++++++++++++++++
 drivers/mfd/Kconfig                                |   9 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/adp5585.c                              | 134 +++++++++++++
 drivers/pwm/Kconfig                                |   8 +
 drivers/pwm/Makefile                               |   1 +
 drivers/pwm/pwm-adp5585.c                          | 215 +++++++++++++++++++++
 include/linux/mfd/adp5585.h                        | 100 ++++++++++
 13 files changed, 789 insertions(+)

---
base-commit: 91e3b24eb7d297d9d99030800ed96944b8652eaf
change-id: 20240715-adi-11ff2d3d35ec

Best regards,
---
Frank Li <[email protected]>

author maintainer
#1 lore raw

PATCH 1/6 dt-bindings: mfd: Add i2c device adi5585

Add adi5585, which provide gpio, pwm and keypad controller.

---
 .../devicetree/bindings/mfd/adi,adp5585.yaml       | 83 ++++++++++++++++++++++
 1 file changed, 83 insertions(+)
Documentation/devicetree/bindings/mfd/adi,adp5585.yaml new file +83 -0
new file mode 100644
index 0000000000000..03c4760242ddd
@@ -0,0 +1,83 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/adi,adp5585.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ADI adp5585 GPIO, PWM, keypad controller
+
+maintainers:
+  - Frank Li <[email protected]>
+
+description:
+  adp5585 is a multifunctional device that can provide GPIO, PWM and keypad.
+
+properties:
+  compatible:
+    const: adi,adp5585
+
+  reg:
+    items:
+      description: I2C device address.
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: adp5585-gpio
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+    required:
+      - compatible
+      - gpio-controller
+      - "#gpio-cells"
+
+    additionalProperties: false
+
+  pwm:
+    $ref: /schemas/pwm/pwm.yaml
+    properties:
+      compatible:
+        const: adp5585-pwm
+
+      "#pwm-cells":
+        const: 3
+
+    required:
+      - compatible
+      - "#pwm-cells"
+
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        mfd@34 {
+            compatible = "adi,adp5585";
+            reg = <0x34>;
+
+            gpio {
+                compatible = "adp5585-gpio";
+                gpio-controller;
+                #gpio-cells = <2>;
+            };
+
+            pwm {
+                compatible = "adp5585-pwm";
+                #pwm-cells = <3>;
+            };
+        };
+    };
Signature · 1 line
2.34.1
maintainer
#2 lore raw

Re: [PATCH 1/6] dt-bindings: mfd: Add i2c device adi5585

Quoted 76 lines · Frank Li

Add adi5585, which provide gpio, pwm and keypad controller.

---
 .../devicetree/bindings/mfd/adi,adp5585.yaml       | 83 ++++++++++++++++++++++
 1 file changed, 83 insertions(+)
Documentation/devicetree/bindings/mfd/adi,adp5585.yaml new file +63 -0
new file mode 100644
index 0000000000000..03c4760242ddd
@@ -0,0 +1,83 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/adi,adp5585.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ADI adp5585 GPIO, PWM, keypad controller
+
+maintainers:
+  - Frank Li <[email protected]>
+
+description:
+  adp5585 is a multifunctional device that can provide GPIO, PWM and keypad.
+
+properties:
+  compatible:
+    const: adi,adp5585
+
+  reg:
+    items:
+      description: I2C device address.
+
+  gpio:
+    type: object
+    properties:
+      compatible:
+        const: adp5585-gpio
+
+      gpio-controller: true
+
+      "#gpio-cells":
+        const: 2
+
+    required:
+      - compatible
+      - gpio-controller
+      - "#gpio-cells"
+
+    additionalProperties: false
+
+  pwm:
+    $ref: /schemas/pwm/pwm.yaml
+    properties:
+      compatible:
+        const: adp5585-pwm
+
+      "#pwm-cells":
+        const: 3
+
+    required:
+      - compatible
+      - "#pwm-cells"
+
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |

Documentation/devicetree/bindings/mfd/adi,adp5585.yaml line 73

Quoted 10 lines
Documentation/devicetree/bindings/mfd/adi,adp5585.yaml new file +10 -0
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        mfd@34 {
+            compatible = "adi,adp5585";
+            reg = <0x34>;
+
+            gpio {
+                compatible = "adp5585-gpio";

Missing vendor prefix. However, ...

Documentation/devicetree/bindings/mfd/adi,adp5585.yaml line 81

Quoted 8 lines
Documentation/devicetree/bindings/mfd/adi,adp5585.yaml new file +8 -0
+                gpio-controller;
+                #gpio-cells = <2>;
+            };
+
+            pwm {
+                compatible = "adp5585-pwm";
+                #pwm-cells = <3>;
+            };

There's no need for these child nodes. This can be just:

mfd@34 {
    compatible = "adi,adp5585";
    reg = <0x34>;
    gpio-controller;
    #gpio-cells = <2>;
    #pwm-cells = <3>;
};

Rob

author maintainer
#3 lore raw

PATCH 2/6 mfd: adp5585: add ADI adp5585 core support

In reply to Frank Li

From: Haibo Chen <[email protected]>

ADP5585 support multi function, include expander GPIO, pwm, keypad controller.

---
 drivers/mfd/Kconfig         |   9 +++
 drivers/mfd/Makefile        |   1 +
 drivers/mfd/adp5585.c       | 134 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/adp5585.h | 100 +++++++++++++++++++++++++++++++++
 4 files changed, 244 insertions(+)
drivers/mfd/Kconfig +9 -0
index bc8be2e593b6b..62a967ee8ae1c 100644
@@ -20,6 +20,15 @@ config MFD_CS5535
 	  This is the core driver for CS5535/CS5536 MFD functions.  This is
 	  necessary for using the board's GPIO and MFGPT functionality.
 
+config MFD_ADP5585
+	tristate "ADI ADP5585 core functions"
+	select MFD_CORE
+	depends on I2C && OF
+
+	help
+	  This is ADI adp5585 core support, implement the support for
+	  communication through i2c bus.
+
 config MFD_ALTERA_A10SR
 	bool "Altera Arria10 DevKit System Resource chip"
 	depends on ARCH_INTEL_SOCFPGA && SPI_MASTER=y && OF
drivers/mfd/Makefile +1 -0
index 02b651cd75352..2a9f91e81af83 100644
@@ -193,6 +193,7 @@ obj-$(CONFIG_MFD_DB8500_PRCMU)	+= db8500-prcmu.o
 obj-$(CONFIG_AB8500_CORE)	+= ab8500-core.o ab8500-sysctrl.o
 obj-$(CONFIG_MFD_TIMBERDALE)    += timberdale.o
 obj-$(CONFIG_PMIC_ADP5520)	+= adp5520.o
+obj-$(CONFIG_MFD_ADP5585)	+= adp5585.o
 obj-$(CONFIG_MFD_KEMPLD)	+= kempld-core.o
 obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO)	+= intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)		+= lpc_sch.o
drivers/mfd/adp5585.c new file +134 -0

134 lines not on this page · raw message

include/linux/mfd/adp5585.h new file +100 -0

100 lines not on this page · raw message

Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH 2/6] mfd: adp5585: add ADI adp5585 core support

Hi Frank,

thanks for your patch!

include/linux/mfd/adp5585.h line 98

Quoted 7 lines · Frank Li
include/linux/mfd/adp5585.h new file +7 -0
+struct adp5585_dev {
+       struct device *dev;
+       struct i2c_client *i2c_client;
+
+       int (*read_reg)(struct adp5585_dev *adp5585, u8 reg, u8 *val);
+       int (*write_reg)(struct adp5585_dev *adp5585, u8 reg, u8 val);
+};

The read_reg() and write_reg() accessors looks like a reimplementation of regmap.

Can you check if you can just let the subdrivers access a regmap for the parent MFD device and use that to read/write registers?

There are many examples of this in recent MFD drivers.

Yours,
Linus Walleij

author maintainer
#5 lore raw

PATCH 3/6 gpio: adp5585-gpio: add adp5585-gpio support

In reply to Frank Li

From: Haibo Chen <[email protected]>

Add gpio function support for MFD adp5585.

---
 drivers/gpio/Kconfig        |   7 ++
 drivers/gpio/Makefile       |   1 +
 drivers/gpio/gpio-adp5585.c | 184 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 192 insertions(+)
drivers/gpio/Kconfig +7 -0
index 58f43bcced7c1..20daa3d70abc7 100644
@@ -1233,6 +1233,13 @@ config GPIO_ADP5520
 	  This option enables support for on-chip GPIO found
 	  on Analog Devices ADP5520 PMICs.
 
+config GPIO_ADP5585
+	tristate "GPIO Support for ADP5585"
+	depends on MFD_ADP5585
+	help
+	  This option enables support for on-chip GPIO found on Analog
+	  devices ADP5585.
+
 config GPIO_ALTERA_A10SR
 	tristate "Altera Arria10 System Resource GPIO"
 	depends on MFD_ALTERA_A10SR
drivers/gpio/Makefile +1 -0
index 64dd6d9d730d5..1429e8c0229b9 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_GPIO_74X164)		+= gpio-74x164.o
 obj-$(CONFIG_GPIO_74XX_MMIO)		+= gpio-74xx-mmio.o
 obj-$(CONFIG_GPIO_ADNP)			+= gpio-adnp.o
 obj-$(CONFIG_GPIO_ADP5520)		+= gpio-adp5520.o
+obj-$(CONFIG_GPIO_ADP5585)		+= gpio-adp5585.o
 obj-$(CONFIG_GPIO_AGGREGATOR)		+= gpio-aggregator.o
 obj-$(CONFIG_GPIO_ALTERA_A10SR)		+= gpio-altera-a10sr.o
 obj-$(CONFIG_GPIO_ALTERA)  		+= gpio-altera.o
drivers/gpio/gpio-adp5585.c new file +184 -0

184 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#6 lore raw

PATCH 4/6 pwm: adp5585: add adp5585 PWM support

In reply to Frank Li

From: Clark Wang <[email protected]>

Add PWM function support for MFD adp5585.

---
 drivers/pwm/Kconfig       |   8 ++
 drivers/pwm/Makefile      |   1 +
 drivers/pwm/pwm-adp5585.c | 215 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 224 insertions(+)
drivers/pwm/Kconfig +8 -0
index 3e53838990f5b..baaadf877b9c6 100644
@@ -38,6 +38,14 @@ config PWM_DEBUG
 	  It is expected to introduce some runtime overhead and diagnostic
 	  output to the kernel log, so only enable while working on a driver.
 
+config PWM_ADP5585
+	tristate "ADP5585 PWM support"
+	depends on MFD_ADP5585
+	help
+	  This option enables support for on-chip PWM found
+	  on Analog Devices ADP5585.
+
+
 config PWM_AB8500
 	tristate "AB8500 PWM support"
 	depends on AB8500_CORE && ARCH_U8500
drivers/pwm/Makefile +1 -0
index 0be4f3e6dd432..161131a261e94 100644
@@ -2,6 +2,7 @@
 obj-$(CONFIG_PWM)		+= core.o
 obj-$(CONFIG_PWM_AB8500)	+= pwm-ab8500.o
 obj-$(CONFIG_PWM_APPLE)		+= pwm-apple.o
+obj-$(CONFIG_PWM_ADP5585)	+= pwm-adp5585.o
 obj-$(CONFIG_PWM_ATMEL)		+= pwm-atmel.o
 obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM)	+= pwm-atmel-hlcdc.o
 obj-$(CONFIG_PWM_ATMEL_TCB)	+= pwm-atmel-tcb.o
drivers/pwm/pwm-adp5585.c new file +215 -0

215 lines not on this page · raw message

Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH 4/6] pwm: adp5585: add adp5585 PWM support

Hello Clark,

Quoted 23 lines · Frank Li

From: Clark Wang <[email protected]>

Add PWM function support for MFD adp5585.

---
 drivers/pwm/Kconfig       |   8 ++
 drivers/pwm/Makefile      |   1 +
 drivers/pwm/pwm-adp5585.c | 215 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 224 insertions(+)
drivers/pwm/Kconfig +1 -0
index 3e53838990f5b..baaadf877b9c6 100644
@@ -38,6 +38,14 @@ config PWM_DEBUG
 	  It is expected to introduce some runtime overhead and diagnostic
 	  output to the kernel log, so only enable while working on a driver.
 
+config PWM_ADP5585

drivers/pwm/Kconfig config PWM_DEBUG · line 51

Quoted 10 lines
drivers/pwm/Kconfig +7 -0
+	tristate "ADP5585 PWM support"
+	depends on MFD_ADP5585
+	help
+	  This option enables support for on-chip PWM found
+	  on Analog Devices ADP5585.
+
+
 config PWM_AB8500
 	tristate "AB8500 PWM support"
 	depends on AB8500_CORE && ARCH_U8500

alphabetic ordering (by config symbol) please.

drivers/pwm/Makefile line 8

Quoted 12 lines
drivers/pwm/Makefile +1 -0
index 0be4f3e6dd432..161131a261e94 100644
@@ -2,6 +2,7 @@
 obj-$(CONFIG_PWM)		+= core.o
 obj-$(CONFIG_PWM_AB8500)	+= pwm-ab8500.o
 obj-$(CONFIG_PWM_APPLE)		+= pwm-apple.o
+obj-$(CONFIG_PWM_ADP5585)	+= pwm-adp5585.o
 obj-$(CONFIG_PWM_ATMEL)		+= pwm-atmel.o
 obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM)	+= pwm-atmel-hlcdc.o
 obj-$(CONFIG_PWM_ATMEL_TCB)	+= pwm-atmel-tcb.o

alphabetic ordering please.

Quoted 15 lines
drivers/pwm/pwm-adp5585.c new file +9 -0
new file mode 100644
index 0000000000000..f578d24df5c74
@@ -0,0 +1,215 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * PWM driver for Analog Devices ADP5585 MFD
+ *
+ * Copyright 2024 NXP
+ */
+
+#include <linux/clk.h>
+#include <linux/init.h>

drivers/pwm/pwm-adp5585.c line 19

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+#include <linux/io.h>
+#include <linux/mfd/adp5585.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pwm.h>
+#include <linux/slab.h>
+#include <linux/time.h>
+
+#define ADP5585_PWM_CHAN_NUM		1

This is only used once. I'd prefer to pass the 1 verbatim to pwmchip_alloc.

drivers/pwm/pwm-adp5585.c line 21

Quoted 2 lines
drivers/pwm/pwm-adp5585.c new file +2 -0
+#define ADP5585_PWM_FASTEST_PERIOD_NS	2000
+#define ADP5585_PWM_SLOWEST_PERIOD_NS	131070000

Funny number. I wonder where this comes from.

Quoted 5 lines
drivers/pwm/pwm-adp5585.c new file +5 -0
+struct adp5585_pwm_chip {
+	struct device *parent;
+	struct mutex lock;
+	u8 pin_config_val;
+};

drivers/pwm/pwm-adp5585.c line 37

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+
+static inline struct adp5585_pwm_chip *
+to_adp5585_pwm_chip(struct pwm_chip *chip)
+{
+	return pwmchip_get_drvdata(chip);
+}
+
+static int adp5585_pwm_reg_read(struct adp5585_pwm_chip *adp5585_pwm, u8 reg, u8 *val)
+{
+	struct adp5585_dev *adp5585  = dev_get_drvdata(adp5585_pwm->parent);

s/ / /;
ditto below in adp5585_pwm_reg_write().

Quoted 43 lines
drivers/pwm/pwm-adp5585.c new file +43 -0
+
+	return adp5585->read_reg(adp5585, reg, val);
+}
+
+static int adp5585_pwm_reg_write(struct adp5585_pwm_chip *adp5585_pwm, u8 reg, u8 val)
+{
+	struct adp5585_dev *adp5585  = dev_get_drvdata(adp5585_pwm->parent);
+
+	return adp5585->write_reg(adp5585, reg, val);
+}
+
+static int pwm_adp5585_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
+				 struct pwm_state *state)
+{
+	struct adp5585_pwm_chip *adp5585_pwm = to_adp5585_pwm_chip(chip);
+	u32 on, off;
+	u8 temp;
+
+	/* get period */
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_OFFT_LOW, &temp);
+	off = temp;
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_OFFT_HIGH, &temp);
+	off |= temp << 8;
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_ONT_LOW, &temp);
+	on = temp;
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_ONT_HIGH, &temp);
+	on |= temp << 8;
+	state->period = (on + off) * NSEC_PER_USEC;
+
+	state->duty_cycle = on;
+	state->polarity = PWM_POLARITY_NORMAL;
+
+	/* get channel status */
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_CFG, &temp);
+	state->enabled = temp & ADP5585_PWM_CFG_EN;
+
+	return 0;
+}
+
+static int pwm_adp5585_apply(struct pwm_chip *chip,
+			     struct pwm_device *pwm,
+			     const struct pwm_state *state)
+{

drivers/pwm/pwm-adp5585.c line 90

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+	struct adp5585_pwm_chip *adp5585_pwm = to_adp5585_pwm_chip(chip);
+	u32 on, off;
+	u8 enabled;
+	int ret;
+
+	if (state->period > ADP5585_PWM_SLOWEST_PERIOD_NS ||
+	    state->period < ADP5585_PWM_FASTEST_PERIOD_NS)
+		return -EINVAL;
+
+	guard(mutex)(&adp5585_pwm->lock);

What does this protect? You're allowed (and expected) to assume that the consumer serializes calls to .apply() for a single pwm_device. Given that you have npwm=1 I think this lock can be dropped.

drivers/pwm/pwm-adp5585.c line 94

Quoted 3 lines
drivers/pwm/pwm-adp5585.c new file +3 -0
+	/* set on/off cycle*/
+	on = DIV_ROUND_CLOSEST_ULL(state->duty_cycle, NSEC_PER_USEC);
+	off = DIV_ROUND_CLOSEST_ULL((state->period - state->duty_cycle), NSEC_PER_USEC);

Please enable PWM_DEBUG your tests and make sure it doesn't produce warnings. (Hint: round_closest is wrong)

Quoted 7 lines
drivers/pwm/pwm-adp5585.c new file +7 -0
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_OFFT_LOW, off & ADP5585_REG_MASK);
+	if (ret)
+		return ret;
+
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_OFFT_HIGH,
+				    (off >> 8) & ADP5585_REG_MASK);
+	if (ret)

drivers/pwm/pwm-adp5585.c line 112

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+		return ret;
+
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_ONT_LOW, on & ADP5585_REG_MASK);
+	if (ret)
+		return ret;
+
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_ONT_HIGH,
+				    (on >> 8) & ADP5585_REG_MASK);
+	if (ret)
+		return ret;

How does the hardware behave in between these register writes? Can it happen that an intermediate state is visible on the output pin? (E.g. because off is already written but on is still the old value. Or even off is only partly written after the first byte write.)

Please document this behaviour in a paragraph at the top of the driver in the same way as many other PWM drivers do it. The details should be extractable by

	sed -rn '/Limitations:/,/\*\/?$/p' drivers/pwm/*.c

drivers/pwm/pwm-adp5585.c line 111

Quoted 2 lines
drivers/pwm/pwm-adp5585.c new file +2 -0
+
+	/* enable PWM and set to continuous PWM mode*/

Missing space before comment ending delimiter

Quoted 11 lines
drivers/pwm/pwm-adp5585.c new file +11 -0
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_CFG, &enabled);
+	if (state->enabled)
+		ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_CFG, ADP5585_PWM_CFG_EN);
+	else
+		ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_CFG, 0);
+
+	return ret;
+}
+
+static int pwm_adp5585_request(struct pwm_chip *chip, struct pwm_device *pwm)
+{

drivers/pwm/pwm-adp5585.c line 135

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+	struct adp5585_pwm_chip *adp5585_pwm = to_adp5585_pwm_chip(chip);
+	u8 reg_cfg;
+	int ret;
+
+	guard(mutex)(&adp5585_pwm->lock);
+
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PIN_CONFIG_C, &adp5585_pwm->pin_config_val);
+	reg_cfg = adp5585_pwm->pin_config_val & ~ADP5585_PIN_CONFIG_R3_MASK;
+	reg_cfg |= ADP5585_PIN_CONFIG_R3_PWM;
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PIN_CONFIG_C, reg_cfg);

ret is only written to here, ditto for &adp5585_pwm->pin_config_val.

drivers/pwm/pwm-adp5585.c line 139

Quoted 4 lines
drivers/pwm/pwm-adp5585.c new file +4 -0
+
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_GENERAL_CFG, &adp5585_pwm->pin_config_val);
+	reg_cfg |= ADP5585_GENERAL_CFG_OSC_EN;
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_GENERAL_CFG, reg_cfg);

Please add a comment about what is happening here. I assume this sets up pinmuxing and enabled the oscillator. I wonder if it is sensible to do the latter only in .apply() iff state->enabled = true.

Quoted 5 lines
drivers/pwm/pwm-adp5585.c new file +5 -0
+
+	return ret;
+}
+
+static void pwm_adp5585_free(struct pwm_chip *chip, struct pwm_device *pwm)

drivers/pwm/pwm-adp5585.c line 154

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+{
+	struct adp5585_pwm_chip *adp5585_pwm = to_adp5585_pwm_chip(chip);
+	u8 reg_cfg;
+
+	guard(mutex)(&adp5585_pwm->lock);
+
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PIN_CONFIG_C, &reg_cfg);
+	reg_cfg &= ~ADP5585_PIN_CONFIG_R3_MASK;
+	reg_cfg |= adp5585_pwm->pin_config_val & ADP5585_PIN_CONFIG_R3_MASK;
+	adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PIN_CONFIG_C, reg_cfg);

It would be consequent to clear ADP5585_GENERAL_CFG_OSC_EN in this function given that it's set in .request().

Quoted 9 lines
drivers/pwm/pwm-adp5585.c new file +9 -0
+}
+
+static const struct pwm_ops adp5585_pwm_ops = {
+	.request = pwm_adp5585_request,
+	.free = pwm_adp5585_free,
+	.get_state = pwm_adp5585_get_state,
+	.apply = pwm_adp5585_apply,
+};
+

drivers/pwm/pwm-adp5585.c line 173

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+static int adp5585_pwm_probe(struct platform_device *pdev)
+{
+	struct adp5585_pwm_chip *adp5585_pwm;
+	struct pwm_chip *chip;
+	unsigned int npwm = ADP5585_PWM_CHAN_NUM;
+	int ret;
+
+	chip = devm_pwmchip_alloc(&pdev->dev, npwm, sizeof(*adp5585_pwm));
+	if (IS_ERR(chip))
+		return PTR_ERR(chip);

Error message using dev_err_probe() please.

drivers/pwm/pwm-adp5585.c line 185

Quoted 12 lines
drivers/pwm/pwm-adp5585.c new file +12 -0
+
+	adp5585_pwm = to_adp5585_pwm_chip(chip);
+	adp5585_pwm->parent = pdev->dev.parent;
+
+	platform_set_drvdata(pdev, adp5585_pwm);
+
+	chip->ops = &adp5585_pwm_ops;
+	mutex_init(&adp5585_pwm->lock);
+
+	ret = devm_pwmchip_add(&pdev->dev, chip);
+	if (ret)
+		dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret);

Please use dev_err_probe().

drivers/pwm/pwm-adp5585.c line 194

Quoted 9 lines
drivers/pwm/pwm-adp5585.c new file +9 -0
+
+	return ret;
+}
+
+static void adp5585_pwm_remove(struct platform_device *pdev)
+{
+	struct pwm_chip *chip = platform_get_drvdata(pdev);
+
+	pwmchip_remove(chip);

Did you test this? I'd expect this to explode.

drivers/pwm/pwm-adp5585.c line 198

Quoted 4 lines
drivers/pwm/pwm-adp5585.c new file +4 -0
+}
+
+static const struct of_device_id adp5585_pwm_of_match[] = {
+	{.compatible = "adp5585-pwm", },

Missing space after the opening brace.

Quoted 5 lines
drivers/pwm/pwm-adp5585.c new file +5 -0
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, adp5585_pwm_of_match);
+
+static struct platform_driver adp5585_pwm_driver = {

drivers/pwm/pwm-adp5585.c line 213

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+	.driver	= {
+		.name	= "adp5585-pwm",
+		.of_match_table = adp5585_pwm_of_match,
+	},
+	.probe		= adp5585_pwm_probe,
+	.remove		= adp5585_pwm_remove,
+};
+module_platform_driver(adp5585_pwm_driver);
+
+MODULE_AUTHOR("Xiaoning Wang <[email protected]>");

The email address matches one of the S-o-b lines, the name however is different. Is this by mistake?

Quoted 2 lines
drivers/pwm/pwm-adp5585.c new file +2 -0
+MODULE_DESCRIPTION("ADP5585 PWM Driver");
+MODULE_LICENSE("GPL");
author maintainer
#8 lore raw

Re: [PATCH 4/6] pwm: adp5585: add adp5585 PWM support

Quoted 25 lines · Uwe Kleine-König

Hello Clark,

Quoted 22 lines · Frank Li

From: Clark Wang <[email protected]>

Add PWM function support for MFD adp5585.

---
 drivers/pwm/Kconfig       |   8 ++
 drivers/pwm/Makefile      |   1 +
 drivers/pwm/pwm-adp5585.c | 215 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 224 insertions(+)
drivers/pwm/Kconfig +0 -0
index 3e53838990f5b..baaadf877b9c6 100644
@@ -38,6 +38,14 @@ config PWM_DEBUG
 	  It is expected to introduce some runtime overhead and diagnostic
 	  output to the kernel log, so only enable while working on a driver.
 
Quoted 13 lines

drivers/pwm/Kconfig config PWM_DEBUG · line 51

Quoted 11 lines
drivers/pwm/Kconfig +8 -0
+config PWM_ADP5585
+	tristate "ADP5585 PWM support"
+	depends on MFD_ADP5585
+	help
+	  This option enables support for on-chip PWM found
+	  on Analog Devices ADP5585.
+
+
 config PWM_AB8500
 	tristate "AB8500 PWM support"
 	depends on AB8500_CORE && ARCH_U8500

alphabetic ordering (by config symbol) please.

Thank you for you review. I just found someone already submit similar patch

https://lore.kernel.org/linux-gpio/[email protected]/

Let's wait for laurent. If he is busy, I can rework base on the above one.

Frank

Quoted 297 lines

drivers/pwm/Makefile line 8

Quoted 13 lines
drivers/pwm/Makefile +1 -0
index 0be4f3e6dd432..161131a261e94 100644
@@ -2,6 +2,7 @@
 obj-$(CONFIG_PWM)		+= core.o
 obj-$(CONFIG_PWM_AB8500)	+= pwm-ab8500.o
 obj-$(CONFIG_PWM_APPLE)		+= pwm-apple.o
+obj-$(CONFIG_PWM_ADP5585)	+= pwm-adp5585.o
 obj-$(CONFIG_PWM_ATMEL)		+= pwm-atmel.o
 obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM)	+= pwm-atmel-hlcdc.o
 obj-$(CONFIG_PWM_ATMEL_TCB)	+= pwm-atmel-tcb.o

alphabetic ordering please.

Quoted 15 lines
drivers/pwm/pwm-adp5585.c new file +9 -0
new file mode 100644
index 0000000000000..f578d24df5c74
@@ -0,0 +1,215 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * PWM driver for Analog Devices ADP5585 MFD
+ *
+ * Copyright 2024 NXP
+ */
+
+#include <linux/clk.h>
+#include <linux/init.h>

drivers/pwm/pwm-adp5585.c line 19

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+#include <linux/io.h>
+#include <linux/mfd/adp5585.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pwm.h>
+#include <linux/slab.h>
+#include <linux/time.h>
+
+#define ADP5585_PWM_CHAN_NUM		1

This is only used once. I'd prefer to pass the 1 verbatim to pwmchip_alloc.

drivers/pwm/pwm-adp5585.c line 21

Quoted 2 lines
drivers/pwm/pwm-adp5585.c new file +2 -0
+#define ADP5585_PWM_FASTEST_PERIOD_NS	2000
+#define ADP5585_PWM_SLOWEST_PERIOD_NS	131070000

Funny number. I wonder where this comes from.

Quoted 5 lines
drivers/pwm/pwm-adp5585.c new file +5 -0
+struct adp5585_pwm_chip {
+	struct device *parent;
+	struct mutex lock;
+	u8 pin_config_val;
+};

drivers/pwm/pwm-adp5585.c line 37

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+
+static inline struct adp5585_pwm_chip *
+to_adp5585_pwm_chip(struct pwm_chip *chip)
+{
+	return pwmchip_get_drvdata(chip);
+}
+
+static int adp5585_pwm_reg_read(struct adp5585_pwm_chip *adp5585_pwm, u8 reg, u8 *val)
+{
+	struct adp5585_dev *adp5585  = dev_get_drvdata(adp5585_pwm->parent);

s/ / /;
ditto below in adp5585_pwm_reg_write().

Quoted 43 lines
drivers/pwm/pwm-adp5585.c new file +43 -0
+
+	return adp5585->read_reg(adp5585, reg, val);
+}
+
+static int adp5585_pwm_reg_write(struct adp5585_pwm_chip *adp5585_pwm, u8 reg, u8 val)
+{
+	struct adp5585_dev *adp5585  = dev_get_drvdata(adp5585_pwm->parent);
+
+	return adp5585->write_reg(adp5585, reg, val);
+}
+
+static int pwm_adp5585_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
+				 struct pwm_state *state)
+{
+	struct adp5585_pwm_chip *adp5585_pwm = to_adp5585_pwm_chip(chip);
+	u32 on, off;
+	u8 temp;
+
+	/* get period */
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_OFFT_LOW, &temp);
+	off = temp;
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_OFFT_HIGH, &temp);
+	off |= temp << 8;
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_ONT_LOW, &temp);
+	on = temp;
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_ONT_HIGH, &temp);
+	on |= temp << 8;
+	state->period = (on + off) * NSEC_PER_USEC;
+
+	state->duty_cycle = on;
+	state->polarity = PWM_POLARITY_NORMAL;
+
+	/* get channel status */
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_CFG, &temp);
+	state->enabled = temp & ADP5585_PWM_CFG_EN;
+
+	return 0;
+}
+
+static int pwm_adp5585_apply(struct pwm_chip *chip,
+			     struct pwm_device *pwm,
+			     const struct pwm_state *state)
+{

drivers/pwm/pwm-adp5585.c line 90

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+	struct adp5585_pwm_chip *adp5585_pwm = to_adp5585_pwm_chip(chip);
+	u32 on, off;
+	u8 enabled;
+	int ret;
+
+	if (state->period > ADP5585_PWM_SLOWEST_PERIOD_NS ||
+	    state->period < ADP5585_PWM_FASTEST_PERIOD_NS)
+		return -EINVAL;
+
+	guard(mutex)(&adp5585_pwm->lock);

What does this protect? You're allowed (and expected) to assume that the consumer serializes calls to .apply() for a single pwm_device. Given that you have npwm=1 I think this lock can be dropped.

drivers/pwm/pwm-adp5585.c line 94

Quoted 3 lines
drivers/pwm/pwm-adp5585.c new file +3 -0
+	/* set on/off cycle*/
+	on = DIV_ROUND_CLOSEST_ULL(state->duty_cycle, NSEC_PER_USEC);
+	off = DIV_ROUND_CLOSEST_ULL((state->period - state->duty_cycle), NSEC_PER_USEC);

Please enable PWM_DEBUG your tests and make sure it doesn't produce warnings. (Hint: round_closest is wrong)

Quoted 7 lines
drivers/pwm/pwm-adp5585.c new file +7 -0
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_OFFT_LOW, off & ADP5585_REG_MASK);
+	if (ret)
+		return ret;
+
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_OFFT_HIGH,
+				    (off >> 8) & ADP5585_REG_MASK);
+	if (ret)

drivers/pwm/pwm-adp5585.c line 112

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+		return ret;
+
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_ONT_LOW, on & ADP5585_REG_MASK);
+	if (ret)
+		return ret;
+
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_ONT_HIGH,
+				    (on >> 8) & ADP5585_REG_MASK);
+	if (ret)
+		return ret;

How does the hardware behave in between these register writes? Can it happen that an intermediate state is visible on the output pin? (E.g. because off is already written but on is still the old value. Or even off is only partly written after the first byte write.)

Please document this behaviour in a paragraph at the top of the driver in the same way as many other PWM drivers do it. The details should be extractable by

	sed -rn '/Limitations:/,/\*\/?$/p' drivers/pwm/*.c

drivers/pwm/pwm-adp5585.c line 111

Quoted 2 lines
drivers/pwm/pwm-adp5585.c new file +2 -0
+
+	/* enable PWM and set to continuous PWM mode*/

Missing space before comment ending delimiter

Quoted 11 lines
drivers/pwm/pwm-adp5585.c new file +11 -0
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PWM_CFG, &enabled);
+	if (state->enabled)
+		ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_CFG, ADP5585_PWM_CFG_EN);
+	else
+		ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PWM_CFG, 0);
+
+	return ret;
+}
+
+static int pwm_adp5585_request(struct pwm_chip *chip, struct pwm_device *pwm)
+{

drivers/pwm/pwm-adp5585.c line 135

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+	struct adp5585_pwm_chip *adp5585_pwm = to_adp5585_pwm_chip(chip);
+	u8 reg_cfg;
+	int ret;
+
+	guard(mutex)(&adp5585_pwm->lock);
+
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PIN_CONFIG_C, &adp5585_pwm->pin_config_val);
+	reg_cfg = adp5585_pwm->pin_config_val & ~ADP5585_PIN_CONFIG_R3_MASK;
+	reg_cfg |= ADP5585_PIN_CONFIG_R3_PWM;
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PIN_CONFIG_C, reg_cfg);

ret is only written to here, ditto for &adp5585_pwm->pin_config_val.

drivers/pwm/pwm-adp5585.c line 139

Quoted 4 lines
drivers/pwm/pwm-adp5585.c new file +4 -0
+
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_GENERAL_CFG, &adp5585_pwm->pin_config_val);
+	reg_cfg |= ADP5585_GENERAL_CFG_OSC_EN;
+	ret = adp5585_pwm_reg_write(adp5585_pwm, ADP5585_GENERAL_CFG, reg_cfg);

Please add a comment about what is happening here. I assume this sets up pinmuxing and enabled the oscillator. I wonder if it is sensible to do the latter only in .apply() iff state->enabled = true.

Quoted 5 lines
drivers/pwm/pwm-adp5585.c new file +5 -0
+
+	return ret;
+}
+
+static void pwm_adp5585_free(struct pwm_chip *chip, struct pwm_device *pwm)

drivers/pwm/pwm-adp5585.c line 154

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+{
+	struct adp5585_pwm_chip *adp5585_pwm = to_adp5585_pwm_chip(chip);
+	u8 reg_cfg;
+
+	guard(mutex)(&adp5585_pwm->lock);
+
+	adp5585_pwm_reg_read(adp5585_pwm, ADP5585_PIN_CONFIG_C, &reg_cfg);
+	reg_cfg &= ~ADP5585_PIN_CONFIG_R3_MASK;
+	reg_cfg |= adp5585_pwm->pin_config_val & ADP5585_PIN_CONFIG_R3_MASK;
+	adp5585_pwm_reg_write(adp5585_pwm, ADP5585_PIN_CONFIG_C, reg_cfg);

It would be consequent to clear ADP5585_GENERAL_CFG_OSC_EN in this function given that it's set in .request().

Quoted 9 lines
drivers/pwm/pwm-adp5585.c new file +9 -0
+}
+
+static const struct pwm_ops adp5585_pwm_ops = {
+	.request = pwm_adp5585_request,
+	.free = pwm_adp5585_free,
+	.get_state = pwm_adp5585_get_state,
+	.apply = pwm_adp5585_apply,
+};
+

drivers/pwm/pwm-adp5585.c line 173

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+static int adp5585_pwm_probe(struct platform_device *pdev)
+{
+	struct adp5585_pwm_chip *adp5585_pwm;
+	struct pwm_chip *chip;
+	unsigned int npwm = ADP5585_PWM_CHAN_NUM;
+	int ret;
+
+	chip = devm_pwmchip_alloc(&pdev->dev, npwm, sizeof(*adp5585_pwm));
+	if (IS_ERR(chip))
+		return PTR_ERR(chip);

Error message using dev_err_probe() please.

drivers/pwm/pwm-adp5585.c line 185

Quoted 12 lines
drivers/pwm/pwm-adp5585.c new file +12 -0
+
+	adp5585_pwm = to_adp5585_pwm_chip(chip);
+	adp5585_pwm->parent = pdev->dev.parent;
+
+	platform_set_drvdata(pdev, adp5585_pwm);
+
+	chip->ops = &adp5585_pwm_ops;
+	mutex_init(&adp5585_pwm->lock);
+
+	ret = devm_pwmchip_add(&pdev->dev, chip);
+	if (ret)
+		dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret);

Please use dev_err_probe().

drivers/pwm/pwm-adp5585.c line 194

Quoted 9 lines
drivers/pwm/pwm-adp5585.c new file +9 -0
+
+	return ret;
+}
+
+static void adp5585_pwm_remove(struct platform_device *pdev)
+{
+	struct pwm_chip *chip = platform_get_drvdata(pdev);
+
+	pwmchip_remove(chip);

Did you test this? I'd expect this to explode.

drivers/pwm/pwm-adp5585.c line 198

Quoted 4 lines
drivers/pwm/pwm-adp5585.c new file +4 -0
+}
+
+static const struct of_device_id adp5585_pwm_of_match[] = {
+	{.compatible = "adp5585-pwm", },

Missing space after the opening brace.

Quoted 5 lines
drivers/pwm/pwm-adp5585.c new file +5 -0
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, adp5585_pwm_of_match);
+
+static struct platform_driver adp5585_pwm_driver = {

drivers/pwm/pwm-adp5585.c line 213

Quoted 10 lines
drivers/pwm/pwm-adp5585.c new file +10 -0
+	.driver	= {
+		.name	= "adp5585-pwm",
+		.of_match_table = adp5585_pwm_of_match,
+	},
+	.probe		= adp5585_pwm_probe,
+	.remove		= adp5585_pwm_remove,
+};
+module_platform_driver(adp5585_pwm_driver);
+
+MODULE_AUTHOR("Xiaoning Wang <[email protected]>");

The email address matches one of the S-o-b lines, the name however is different. Is this by mistake?

Quoted 2 lines
drivers/pwm/pwm-adp5585.c new file +2 -0
+MODULE_DESCRIPTION("ADP5585 PWM Driver");
+MODULE_LICENSE("GPL");
maintainer
#10 lore raw

Re: [PATCH 4/6] pwm: adp5585: add adp5585 PWM support

Quoted 9 lines · Fabio Estevam
Quoted 5 lines · Frank Li

Thank you for you review. I just found someone already submit similar patch

https://lore.kernel.org/linux-gpio/[email protected]/

Let's wait for laurent. If he is busy, I can rework base on the above one.

Adding Laurent.

Thanks Fabio.

I had a quick look at this series, and I think mine is better as it supports more features and more chip variants.

Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#11 lore raw

PATCH 5/6 arm64: dts: imx93-11x11-evk: add adi,adp5585 gpio and pwm

In reply to Frank Li

Add adi,adp5585 gpio and pwm for imx93-11x11-evk board.

---
 arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts +16 -0
index a15987f49e8d6..6bfb90f4da63a 100644
@@ -241,6 +241,22 @@ ldo5: LDO5 {
 			};
 		};
 	};
+
+	adp5585: mfd@34 {
+		compatible = "adi,adp5585";
+		reg = <0x34>;
+
+		adp5585gpio: gpio {
+			compatible = "adp5585-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		adp5585pwm: pwm {
+			compatible = "adp5585-pwm";
+			#pwm-cells = <3>;
+		};
+	};
 };
 
 &lpi2c3 {
Signature · 1 line
2.34.1
author maintainer
#12 lore raw

PATCH 6/6 arm64: dts: imx95-19x19-evk: add i2c2 and adi,adp5585

In reply to Frank Li

Add adi,adp5585 gpio and pwm for imx95-19x19-evk board.

---
 arch/arm64/boot/dts/freescale/imx95-19x19-evk.dts | 30 +++++++++++++++++++++++
 1 file changed, 30 insertions(+)
arch/arm64/boot/dts/freescale/imx95-19x19-evk.dts +30 -0
index d14a54ab4fd47..8c52fec79535f 100644
@@ -81,6 +81,29 @@ reg_usdhc2_vmmc: regulator-usdhc2 {
 	};
 };
 
+&lpi2c2 {
+	clock-frequency = <400000>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_lpi2c2>;
+	status = "okay";
+
+	adp5585: mfd@34 {
+		compatible = "adi,adp5585";
+		reg = <0x34>;
+
+		adp5585gpio: gpio-adp5585 {
+			compatible = "adp5585-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		adp5585pwm: pwm-adp5585 {
+			compatible = "adp5585-pwm";
+			#pwm-cells = <3>;
+		};
+	};
+};
+
 &lpi2c7 {
 	clock-frequency = <1000000>;
 	pinctrl-names = "default";
@@ -159,6 +182,13 @@ &wdog3 {
 };
 
 &scmi_iomuxc {
+	pinctrl_lpi2c2: lpi2c2grp {
+		fsl,pins = <
+			IMX95_PAD_I2C2_SCL__AONMIX_TOP_LPI2C2_SCL	0x40000b9e
+			IMX95_PAD_I2C2_SDA__AONMIX_TOP_LPI2C2_SDA	0x40000b9e
+		>;
+	};
+
 	pinctrl_i2c7_pcal6524: i2c7pcal6524grp {
 		fsl,pins = <
 			IMX95_PAD_GPIO_IO36__GPIO5_IO_BIT16			0x31e
Signature · 1 line
2.34.1
#13 lore raw
In reply to Frank Li
Quoted 33 lines · Frank Li

adp5585 is totally difference adp5588, which in
drivers/input/keyboard/adp5588-keys.c.

So create new driver for it.

---
Clark Wang (1):

      pwm: adp5585: add adp5585 PWM support

Frank Li (3):

      dt-bindings: mfd: Add i2c device adi5585
      arm64: dts: imx93-11x11-evk: add adi,adp5585 gpio and pwm
      arm64: dts: imx95-19x19-evk: add i2c2 and adi,adp5585

Haibo Chen (2):
mfd: adp5585: add ADI adp5585 core support
gpio: adp5585-gpio: add adp5585-gpio support

 .../devicetree/bindings/mfd/adi,adp5585.yaml       |  83 ++++++++
 arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts  |  16 ++
 arch/arm64/boot/dts/freescale/imx95-19x19-evk.dts  |  30 +++
 drivers/gpio/Kconfig                               |   7 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-adp5585.c                        | 184 ++++++++++++++++++
 drivers/mfd/Kconfig                                |   9 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/adp5585.c                              | 134 +++++++++++++
 drivers/pwm/Kconfig                                |   8 +
 drivers/pwm/Makefile                               |   1 +
 drivers/pwm/pwm-adp5585.c                          | 215 +++++++++++++++++++++
 include/linux/mfd/adp5585.h                        | 100 ++++++++++
 13 files changed, 789 insertions(+)
Quoted 10 lines

---
base-commit: 91e3b24eb7d297d9d99030800ed96944b8652eaf
change-id: 20240715-adi-11ff2d3d35ec

Best regards,
---
Frank Li <[email protected]>

My bot found new DTB warnings on the .dts files added or changed in this series.

Some warnings may be from an existing SoC .dtsi. Or perhaps the warnings are fixed by another series. Ultimately, it is up to the platform maintainer whether these warnings are acceptable or not. No need to reply unless the platform maintainer has comments.

If you already ran DT checks and didn't see these error(s), then make sure dt-schema is up to date:

  pip3 install dtschema --upgrade

New warnings running 'make CHECK_DTBS=y freescale/imx93-11x11-evk.dtb freescale/imx95-19x19-evk.dtb' for [email protected]:

arch/arm64/boot/dts/freescale/imx93-11x11-evk.dtb: mfd@34: 'gpio', 'pwm' do not match any of the regexes: 'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/trivial-devices.yaml#
arch/arm64/boot/dts/freescale/imx95-19x19-evk.dtb: mfd@34: 'gpio-adp5585', 'pwm-adp5585' do not match any of the regexes: 'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/trivial-devices.yaml#

#14 lore raw
In reply to Frank Li
Quoted 6 lines · Frank Li

adp5585 is totally difference adp5588, which in
drivers/input/keyboard/adp5588-keys.c.

So create new driver for it.

There is ongoing work (v4 if I recall) for adp5585, so please rebase on that. Existing patches do not look abandoned.

Best regards,
Krzysztof