Skip to contentSkip to conversation

dt-bindings: input: cirrus,cs40l26: Support for CS40L26

PATCH In review Fred Treven 4 participants 13 messages May 26, 2023

Subsystems (5)
lore
Share & tools
lore

Fred Treven

author maintainer
#0 lore raw

PATCH v2 1/5 dt-bindings: input: cirrus,cs40l26: Support for CS40L26

Introduce required basic devicetree parameters for the initial commit of CS40L26.

---
 .../devicetree/bindings/input/cirrus,cs40l26.yaml  | 102 +++++++++++++++++++++
 MAINTAINERS                                        |  10 ++
 2 files changed, 112 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +102 -0
new file mode 100644
index 000000000000..9cbc964ebded
@@ -0,0 +1,102 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/cirrus,cs40l26.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cirrus Logic CS40L26 Boosted Haptic Amplifier
+
+maintainers:
+  - Fred Treven <[email protected]>
+
+description:
+  CS40L26 is a Boosted Haptic Driver with Integrated DSP and Waveform Memory
+  with Advanced Closed Loop Algorithms and LRA protection
+
+properties:
+  compatible:
+    enum:
+      - cirrus,cs40l26a
+      - cirrus,cs40l26b
+      - cirrus,cs40l27a
+      - cirrus,cs40l27b
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    maxItems: 1
+
+  VA-supply:
+    description: Regulator for VA analog voltage
+
+  VP-supply:
+    description: Regulator for VP peak voltage
+
+  cirrus,bst-ipk-microamp:
+    description:
+      Maximum amount of current that can be drawn by the device's boost converter.
+    multipleOf: 50000
+    minimum: 1600000
+    maximum: 4800000
+    default: 4500000
+
+  cirrus,bst-ctl-microvolt:
+    description: Maximum target voltage to which DSP may increase the VBST supply.
+    multipleOf: 50000
+    minimum: 2550000
+    maximum: 11000000
+    default: 11000000
+
+  cirrus,bst-exploratory-mode-disable:
+    description:
+      Disable boost exploratory mode.
+
+      In exploratory mode the analog maximum peak current limit of 4.5 A
+      (tolerance of + 160 mA) will be applied. This is required for the
+      device to successfully detect a boost inductor short.
+
+      Boost exploratory mode allows the device to overshoot the set boost peak
+      current limit (i.e. if current peak limit is set to 2.5 A to protect the
+      battery inductor, the current limit will be opened up to 4.5 A for
+      several milliseconds at boost startup).
+      This has potential to damage the boost inductor.
+
+      Disabling this mode will prevent this from happening; it will also
+      prevent the device from detecting boost inductor short errors.
+    type: boolean
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - reset-gpios
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/input/input.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      cs40l26@58 {
+        compatible = "cirrus,cs40l26a";
+        reg = <0x58>;
+        interrupt-parent = <&gpio>;
+        interrupts = <57 IRQ_TYPE_LEVEL_LOW>;
+        reset-gpios = <&gpio 54 GPIO_ACTIVE_LOW>;
+        VA-supply = <&dummy_vreg>;
+        VP-supply = <&dummy_vreg>;
+        cirrus,bst-ctl-microvolt = <2600000>;
+        cirrus,bst-ipk-microamp = <1650000>;
+        cirrus,bst-exploratory-mode-disable;
+      };
+    };
MAINTAINERS +10 -0
index 2b073facf399..d72ed4957b0b 100644
@@ -4926,6 +4926,16 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/net/ethernet/cirrus/ep93xx_eth.c
 
+CIRRUS LOGIC HAPTICS DRIVER
+M:	Fred Treven <[email protected]>
+M:	Ben Bright <[email protected]>
+M:	James Ogletree <[email protected]>
+L:	[email protected]
+S:	Supported
+W:	https://github.com/CirrusLogic/linux-drivers/wiki
+T:	git https://github.com/CirrusLogic/linux-drivers.git
+F:	Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml
+
 CIRRUS LOGIC LOCHNAGAR DRIVER
 M:	Charles Keepax <[email protected]>
 M:	Richard Fitzgerald <[email protected]>
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH 3/5 firmware: cs_dsp: Add ability to loa multiple coefficient files

Add cs_dsp_power_up_multiple() which accepts an array of cs_dsp_coeff_desc firmware-filename pairs to load.

This enables the user to load more than one tuning file along with the associated firmware.

Change cs_dsp_power_up() to make use of the new function with a single coefficient file.

---
 drivers/firmware/cirrus/cs_dsp.c       | 61 ++++++++++++++++++++++++++--------
 include/linux/firmware/cirrus/cs_dsp.h | 20 +++++++++--
 2 files changed, 66 insertions(+), 15 deletions(-)
drivers/firmware/cirrus/cs_dsp.c +48 -13
index f558b390fbfe..3242095c1b13 100644
@@ -2515,28 +2515,30 @@ static void cs_dsp_halo_stop_watchdog(struct cs_dsp *dsp)
 }
 
 /**
- * cs_dsp_power_up() - Downloads firmware to the DSP
- * @dsp: pointer to DSP structure
+ * cs_dsp_power_up_multiple() - Downloads firmware and multiple coefficient files to the DSP
+ * @dsp: pointer to the DSP structure
  * @wmfw_firmware: the firmware to be sent
  * @wmfw_filename: file name of firmware to be sent
- * @coeff_firmware: the coefficient data to be sent
- * @coeff_filename: file name of coefficient to data be sent
+ * @coeffs: coefficient data and filename pairs to be sent
+ * @num_coeffs: number of coefficient files to be sent
  * @fw_name: the user-friendly firmware name
  *
  * This function is used on ADSP2 and Halo DSP cores, it powers-up the DSP core
  * and downloads the firmware but does not start the firmware running. The
  * cs_dsp booted flag will be set once completed and if the core has a low-power
  * memory retention mode it will be put into this state after the firmware is
- * downloaded.
+ * downloaded. Differs from cs_dsp_power_up() in that it allows for multiple
+ * coefficient files to be downloaded.
  *
  * Return: Zero for success, a negative number on error.
+ *
+ *
  */
-int cs_dsp_power_up(struct cs_dsp *dsp,
-		    const struct firmware *wmfw_firmware, char *wmfw_filename,
-		    const struct firmware *coeff_firmware, char *coeff_filename,
-		    const char *fw_name)
+int cs_dsp_power_up_multiple(struct cs_dsp *dsp, const struct firmware *wmfw_firmware,
+		char *wmfw_filename, struct cs_dsp_coeff_desc *coeffs, int num_coeffs,
+		const char *fw_name)
 {
-	int ret;
+	int i, ret;
 
 	mutex_lock(&dsp->pwr_lock);
 
@@ -2562,9 +2564,12 @@ int cs_dsp_power_up(struct cs_dsp *dsp,
 	if (ret != 0)
 		goto err_ena;
 
-	ret = cs_dsp_load_coeff(dsp, coeff_firmware, coeff_filename);
-	if (ret != 0)
-		goto err_ena;
+	for (i = 0; i < num_coeffs; i++) {
+		ret = cs_dsp_load_coeff(dsp, coeffs[i].coeff_firmware,
+					coeffs[i].coeff_filename);
+		if (ret != 0 && !coeffs[i].optional)
+			goto err_ena;
+	}
 
 	/* Initialize caches for enabled and unset controls */
 	ret = cs_dsp_coeff_init_control_caches(dsp);
@@ -2590,6 +2595,36 @@ int cs_dsp_power_up(struct cs_dsp *dsp,
 
 	return ret;
 }
+EXPORT_SYMBOL_NS_GPL(cs_dsp_power_up_multiple, FW_CS_DSP);
+
+/**
+ * cs_dsp_power_up() - Downloads firmware to the DSP
+ * @dsp: pointer to DSP structure
+ * @wmfw_firmware: the firmware to be sent
+ * @wmfw_filename: file name of firmware to be sent
+ * @coeff_firmware: the coefficient data to be sent
+ * @coeff_filename: file name of coefficient data to be sent
+ * @fw_name: the user-friendly firmware name
+ *
+ * This function is used on ADSP2 and Halo DSP cores, it powers-up the DSP core
+ * and downloads the firmware but does not start the firmware running. The
+ * cs_dsp booted flag will be set once completed and if the core has a low-power
+ * memory retention mode it will be put into this state after the firmware is
+ * downloaded.
+ *
+ * Return: Zero for success, a negative number on error.
+ */
+int cs_dsp_power_up(struct cs_dsp *dsp, const struct firmware *wmfw_firmware, char *wmfw_filename,
+		const struct firmware *coeff_firmware, char *coeff_filename, const char *fw_name)
+{
+	struct cs_dsp_coeff_desc coeff_desc;
+
+	coeff_desc.coeff_firmware = coeff_firmware;
+	coeff_desc.coeff_filename = coeff_filename;
+	coeff_desc.optional = false;
+
+	return cs_dsp_power_up_multiple(dsp, wmfw_firmware, wmfw_filename, &coeff_desc, 1, fw_name);
+}
 EXPORT_SYMBOL_NS_GPL(cs_dsp_power_up, FW_CS_DSP);
 
 /**
include/linux/firmware/cirrus/cs_dsp.h +18 -2
index cad828e21c72..1fda4104140c 100644
@@ -43,6 +43,18 @@
 #define CS_DSP_ACKED_CTL_MAX_VALUE           0xFFFFFF
 
 /**
+ * struct cs_dsp_coeff_desc - Describes a coeff. file + filename pair
+ * @coeff_firmware:	Firmware struct to populate with coeff. data
+ * @coeff_filename:	File from which coeff. data is loaded
+ * @optional:		Designates whether or not to error out if file fails to load
+ */
+struct cs_dsp_coeff_desc {
+	const struct firmware *coeff_firmware;
+	char *coeff_filename;
+	bool optional;
+};
+
+/**
  * struct cs_dsp_region - Describes a logical memory region in DSP address space
  * @type:	Memory region type
  * @base:	Address of region
@@ -217,10 +229,14 @@ int cs_dsp_adsp1_power_up(struct cs_dsp *dsp,
 			  const struct firmware *coeff_firmware, char *coeff_filename,
 			  const char *fw_name);
 void cs_dsp_adsp1_power_down(struct cs_dsp *dsp);
-int cs_dsp_power_up(struct cs_dsp *dsp,
+int cs_dsp_power_up_multiple(struct cs_dsp *dsp,
 		    const struct firmware *wmfw_firmware, char *wmfw_filename,
-		    const struct firmware *coeff_firmware, char *coeff_filename,
+		    struct cs_dsp_coeff_desc *coeffs, int num_coeffs,
 		    const char *fw_name);
+int cs_dsp_power_up(struct cs_dsp *dsp,
+		const struct firmware *wmfw_firmware, char *wmfw_filename,
+		const struct firmware *coeff_firmware, char *coeff_filename,
+		const char *fw_name);
 void cs_dsp_power_down(struct cs_dsp *dsp);
 int cs_dsp_run(struct cs_dsp *dsp);
 void cs_dsp_stop(struct cs_dsp *dsp);
Signature · 1 line
2.7.4
author maintainer
#2 lore raw

PATCH 4/5 Input: cs40l26 - Load multiple coefficient files

In reply to Fred Treven

Enable the driver to load all necessary coefficient tuning
files: cs40l26.bin (wavetable)
cs40l26-svc.bin (Sensorless Velocity Control) cs40l26-dvl.bin (Dynamic Voltage Limiter)

---
 drivers/input/misc/cs40l26.c  | 31 +++++++++++++++++++++++--------
 include/linux/input/cs40l26.h |  3 ++-
 2 files changed, 25 insertions(+), 9 deletions(-)
drivers/input/misc/cs40l26.c +23 -8
index 1959438dfe31..12c29cbd4ff0 100644
@@ -2006,6 +2006,12 @@ static const struct cs_dsp_client_ops cs40l26_cs_dsp_client_ops = {
 	.post_run		= cs40l26_cs_dsp_post_run,
 };
 
+static struct cs_dsp_coeff_desc cs40l26_coeffs[] = {
+	{ .coeff_firmware = NULL,	.coeff_filename = "cs40l26.bin",	.optional = false },
+	{ .coeff_firmware = NULL,	.coeff_filename =  "cs40l26-svc.bin",	.optional = true },
+	{ .coeff_firmware = NULL,	.coeff_filename = "cs40l26-dvl.bin",	.optional = true },
+};
+
 static int cs40l26_cs_dsp_init(struct cs40l26_private *cs40l26)
 {
 	int error;
@@ -2035,14 +2041,16 @@ static int cs40l26_cs_dsp_init(struct cs40l26_private *cs40l26)
 static void cs40l26_dsp_start(struct cs40l26_private *cs40l26)
 {
 	struct device *dev = cs40l26->dev;
+	int i;
 
 	if (cs40l26_dsp_pre_config(cs40l26))
 		goto err_rls_fw;
 
 	mutex_lock(&cs40l26->lock);
 
-	if (cs_dsp_power_up(&cs40l26->dsp, cs40l26->wmfw, "cs40l26.wmfw",
-				cs40l26->bin, "cs40l26.bin", "cs40l26"))
+	if (cs_dsp_power_up_multiple(&cs40l26->dsp, cs40l26->wmfw, "cs40l26.wmfw",
+					cs40l26_coeffs, CS40L26_NUM_COEFF_FILES,
+					"cs40l26"))
 		goto err_mutex;
 
 	if (cs40l26->dsp.fw_id != CS40L26_FW_ID) {
@@ -2062,7 +2070,9 @@ static void cs40l26_dsp_start(struct cs40l26_private *cs40l26)
 	mutex_unlock(&cs40l26->lock);
 
 err_rls_fw:
-	release_firmware(cs40l26->bin);
+	for (i = 0; i < CS40L26_NUM_COEFF_FILES; i++)
+		release_firmware(cs40l26_coeffs[i].coeff_firmware);
+
 	release_firmware(cs40l26->wmfw);
 
 	cs40l26_pm_runtime_setup(cs40l26);
@@ -2074,17 +2084,20 @@ static void cs40l26_coeff_upload(const struct firmware *bin, void *context)
 
 	if (!bin) {
 		dev_err(cs40l26->dev, "Failed to request coefficient file\n");
+		cs40l26->ncoeffs++;
 		return;
 	}
 
-	cs40l26->bin = bin;
+	cs40l26_coeffs[cs40l26->ncoeffs++].coeff_firmware = bin;
 
-	cs40l26_dsp_start(cs40l26);
+	if (cs40l26->ncoeffs == CS40L26_NUM_COEFF_FILES)
+		cs40l26_dsp_start(cs40l26);
 }
 
 static void cs40l26_fw_upload(const struct firmware *wmfw, void *context)
 {
 	struct cs40l26_private *cs40l26 = (struct cs40l26_private *)context;
+	int i;
 
 	if (!wmfw) {
 		dev_err(cs40l26->dev, "Failed to request firmware file\n");
@@ -2098,9 +2111,11 @@ static void cs40l26_fw_upload(const struct firmware *wmfw, void *context)
 
 	cs40l26->wmfw = wmfw;
 
-	request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT,
-				"cs40l26.bin", cs40l26->dev, GFP_KERNEL,
-				cs40l26, cs40l26_coeff_upload);
+	for (i = 0; i < CS40L26_NUM_COEFF_FILES; i++)
+		request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT,
+					"cs40l26.bin", cs40l26->dev,
+					GFP_KERNEL, cs40l26,
+					cs40l26_coeff_upload);
 }
 
 static inline int cs40l26_worker_init(struct cs40l26_private *cs40l26)
include/linux/input/cs40l26.h +2 -1
index bc0acec9cf23..2f74ef61b952 100644
@@ -231,6 +231,7 @@
 /* Firmware Handling */
 #define CS40L26_FW_ID				0x1800D4
 #define CS40L26_FW_ID_VERSION_MIN		0x070237
+#define CS40L26_NUM_COEFF_FILES			3
 
 /* Algorithms */
 #define CS40L26_BUZZGEN_ALGO_ID			0x0004F202
@@ -473,8 +474,8 @@ struct cs40l26_private {
 	unsigned int vbst_uv;
 	bool exploratory_mode_enabled;
 	const struct firmware *wmfw;
-	const struct firmware *bin;
 	bool dsp_initialized;
+	int ncoeffs;
 };
 
 int cs40l26_probe(struct cs40l26_private *cs40l26);
Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH 4/5] Input: cs40l26 - Load multiple coefficient files

Hi Fred,

Quoted 7 lines · Fred Treven

Enable the driver to load all necessary coefficient tuning
files: cs40l26.bin (wavetable)
cs40l26-svc.bin (Sensorless Velocity Control) cs40l26-dvl.bin (Dynamic Voltage Limiter)

---

Thanks for sending; glad to see this series continue to move along. Just a few notes about best practice for reviews:

1. For the purpose of mainline submission, patches 2 and 4 must be squashed, and then come after their dependency (patch 3 in this case). Otherwise, we end up reviewing code that subsequently disappears or changes in a subsequent patch.

2. All patches in the same thread must have the same version number (e.g. v2). If a patch was not present in a previous iteration, the change log can simply say so. Speaking of which...

3. Please include a change log below the '---' so that it is clear what has changed since the last review.

4. This is a matter of personal taste, but for a new driver that touches a few different areas such as this, it's nice to have a cover letter to explain the general layout and motivation. This is also a good place to put a change log.

Quoted 114 lines
 drivers/input/misc/cs40l26.c  | 31 +++++++++++++++++++++++--------
 include/linux/input/cs40l26.h |  3 ++-
 2 files changed, 25 insertions(+), 9 deletions(-)
drivers/input/misc/cs40l26.c +23 -8
index 1959438dfe31..12c29cbd4ff0 100644
@@ -2006,6 +2006,12 @@ static const struct cs_dsp_client_ops cs40l26_cs_dsp_client_ops = {
 	.post_run		= cs40l26_cs_dsp_post_run,
 };
 
+static struct cs_dsp_coeff_desc cs40l26_coeffs[] = {
+	{ .coeff_firmware = NULL,	.coeff_filename = "cs40l26.bin",	.optional = false },
+	{ .coeff_firmware = NULL,	.coeff_filename =  "cs40l26-svc.bin",	.optional = true },
+	{ .coeff_firmware = NULL,	.coeff_filename = "cs40l26-dvl.bin",	.optional = true },
+};
+
 static int cs40l26_cs_dsp_init(struct cs40l26_private *cs40l26)
 {
 	int error;
@@ -2035,14 +2041,16 @@ static int cs40l26_cs_dsp_init(struct cs40l26_private *cs40l26)
 static void cs40l26_dsp_start(struct cs40l26_private *cs40l26)
 {
 	struct device *dev = cs40l26->dev;
+	int i;
 
 	if (cs40l26_dsp_pre_config(cs40l26))
 		goto err_rls_fw;
 
 	mutex_lock(&cs40l26->lock);
 
-	if (cs_dsp_power_up(&cs40l26->dsp, cs40l26->wmfw, "cs40l26.wmfw",
-				cs40l26->bin, "cs40l26.bin", "cs40l26"))
+	if (cs_dsp_power_up_multiple(&cs40l26->dsp, cs40l26->wmfw, "cs40l26.wmfw",
+					cs40l26_coeffs, CS40L26_NUM_COEFF_FILES,
+					"cs40l26"))
 		goto err_mutex;
 
 	if (cs40l26->dsp.fw_id != CS40L26_FW_ID) {
@@ -2062,7 +2070,9 @@ static void cs40l26_dsp_start(struct cs40l26_private *cs40l26)
 	mutex_unlock(&cs40l26->lock);
 
 err_rls_fw:
-	release_firmware(cs40l26->bin);
+	for (i = 0; i < CS40L26_NUM_COEFF_FILES; i++)
+		release_firmware(cs40l26_coeffs[i].coeff_firmware);
+
 	release_firmware(cs40l26->wmfw);
 
 	cs40l26_pm_runtime_setup(cs40l26);
@@ -2074,17 +2084,20 @@ static void cs40l26_coeff_upload(const struct firmware *bin, void *context)
 
 	if (!bin) {
 		dev_err(cs40l26->dev, "Failed to request coefficient file\n");
+		cs40l26->ncoeffs++;
 		return;
 	}
 
-	cs40l26->bin = bin;
+	cs40l26_coeffs[cs40l26->ncoeffs++].coeff_firmware = bin;
 
-	cs40l26_dsp_start(cs40l26);
+	if (cs40l26->ncoeffs == CS40L26_NUM_COEFF_FILES)
+		cs40l26_dsp_start(cs40l26);
 }
 
 static void cs40l26_fw_upload(const struct firmware *wmfw, void *context)
 {
 	struct cs40l26_private *cs40l26 = (struct cs40l26_private *)context;
+	int i;
 
 	if (!wmfw) {
 		dev_err(cs40l26->dev, "Failed to request firmware file\n");
@@ -2098,9 +2111,11 @@ static void cs40l26_fw_upload(const struct firmware *wmfw, void *context)
 
 	cs40l26->wmfw = wmfw;
 
-	request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT,
-				"cs40l26.bin", cs40l26->dev, GFP_KERNEL,
-				cs40l26, cs40l26_coeff_upload);
+	for (i = 0; i < CS40L26_NUM_COEFF_FILES; i++)
+		request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT,
+					"cs40l26.bin", cs40l26->dev,
+					GFP_KERNEL, cs40l26,
+					cs40l26_coeff_upload);
 }
 
 static inline int cs40l26_worker_init(struct cs40l26_private *cs40l26)
include/linux/input/cs40l26.h +2 -1
index bc0acec9cf23..2f74ef61b952 100644
@@ -231,6 +231,7 @@
 /* Firmware Handling */
 #define CS40L26_FW_ID				0x1800D4
 #define CS40L26_FW_ID_VERSION_MIN		0x070237
+#define CS40L26_NUM_COEFF_FILES			3
 
 /* Algorithms */
 #define CS40L26_BUZZGEN_ALGO_ID			0x0004F202
@@ -473,8 +474,8 @@ struct cs40l26_private {
 	unsigned int vbst_uv;
 	bool exploratory_mode_enabled;
 	const struct firmware *wmfw;
-	const struct firmware *bin;
 	bool dsp_initialized;
+	int ncoeffs;
 };
 
 int cs40l26_probe(struct cs40l26_private *cs40l26);
Signature · 1 line
2.7.4

Kind regards,
Jeff LaBundy

author maintainer
#4 lore raw

RFC PATCH 5/5 mfd: cs40l26: Add CODEC driver component

In reply to Fred Treven

Use MFD interface to load the CODEC driver along
with the Input FF driver.

---
 drivers/input/misc/cs40l26.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/input/misc/cs40l26.c +11 -0
index 12c29cbd4ff0..35d15a6c2230 100644
@@ -13,6 +13,7 @@
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mfd/core.h>
 #include <linux/pm_runtime.h>
 #include <linux/string.h>
 #include <linux/firmware/cirrus/wmfw.h>
@@ -2136,6 +2137,10 @@ static inline int cs40l26_worker_init(struct cs40l26_private *cs40l26)
 	return 0;
 }
 
+static const struct mfd_cell cs40l26_devs[] = {
+	{ .name = "cs40l26-codec" },
+};
+
 static struct regulator_bulk_data cs40l26_supplies[] = {
 	{ .supply = "VP" },
 	{ .supply = "VA" },
@@ -2275,6 +2280,12 @@ int cs40l26_probe(struct cs40l26_private *cs40l26)
 	if (error)
 		goto err;
 
+	error = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, cs40l26_devs, 1, NULL, 0, NULL);
+	if (error) {
+		dev_err(dev, "Failed to MFD add device %s: %d\n", cs40l26_devs[0].name, error);
+		goto err;
+	}
+
 	return 0;
 err:
 	cs40l26_remove(cs40l26);
Signature · 1 line
2.7.4
#5 lore raw

Re: [PATCH RFC 5/5] mfd: cs40l26: Add CODEC driver component

Quoted 13 lines · Fred Treven

Use MFD interface to load the CODEC driver along
with the Input FF driver.

---
 drivers/input/misc/cs40l26.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/input/misc/cs40l26.c +0 -0
index 12c29cbd4ff0..35d15a6c2230 100644

drivers/input/misc/cs40l26.c line 16

Quoted 4 lines
drivers/input/misc/cs40l26.c +1 -0
@@ -13,6 +13,7 @@
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mfd/core.h>

NACK. Please do not use the MFD API outside of drivers/mfd.

drivers/input/misc/cs40l26.c static inline int cs40l26_worker_init(struct cs40l26_private *cs40l26) · line 2141

Quoted 9 lines
drivers/input/misc/cs40l26.c +2 -0
 #include <linux/pm_runtime.h>
 #include <linux/string.h>
 #include <linux/firmware/cirrus/wmfw.h>
@@ -2136,6 +2137,10 @@ static inline int cs40l26_worker_init(struct cs40l26_private *cs40l26)
 	return 0;
 }
 
+static const struct mfd_cell cs40l26_devs[] = {
+	{ .name = "cs40l26-codec" },

This is one device. Thus, not an MFD anyway.

Quoted 21 lines
drivers/input/misc/cs40l26.c +8 -0
+};
+
 static struct regulator_bulk_data cs40l26_supplies[] = {
 	{ .supply = "VP" },
 	{ .supply = "VA" },
@@ -2275,6 +2280,12 @@ int cs40l26_probe(struct cs40l26_private *cs40l26)
 	if (error)
 		goto err;
 
+	error = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, cs40l26_devs, 1, NULL, 0, NULL);
+	if (error) {
+		dev_err(dev, "Failed to MFD add device %s: %d\n", cs40l26_devs[0].name, error);
+		goto err;
+	}
+
 	return 0;
 err:
 	cs40l26_remove(cs40l26);
Signature · 1 line
2.7.4
Signature · 1 line
Lee Jones [李琼斯]
#6 lore raw

Re: [PATCH RFC 5/5] mfd: cs40l26: Add CODEC driver component

In reply to Fred Treven

Hi Fred,

Quoted 5 lines · Fred Treven

Use MFD interface to load the CODEC driver along
with the Input FF driver.

---

Did you mean to include a thin codec driver as part of this series to support the audio-to-haptics use-case? I don't see one.

As Lee correctly points out, this isn't an MFD despite the title of the commit message, and is sort of an abuse of the API.

What you seem to actually want is a true MFD driver responsible for initializing common resources such as regmap, an IRQ chip, etc. That driver then adds input and codec drivers as children.

At the moment, you're more or less treating the input driver as the MFD with one child, but that is not the correct pattern.

Quoted 42 lines
 drivers/input/misc/cs40l26.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/input/misc/cs40l26.c +11 -0
index 12c29cbd4ff0..35d15a6c2230 100644
@@ -13,6 +13,7 @@
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mfd/core.h>
 #include <linux/pm_runtime.h>
 #include <linux/string.h>
 #include <linux/firmware/cirrus/wmfw.h>
@@ -2136,6 +2137,10 @@ static inline int cs40l26_worker_init(struct cs40l26_private *cs40l26)
 	return 0;
 }
 
+static const struct mfd_cell cs40l26_devs[] = {
+	{ .name = "cs40l26-codec" },
+};
+
 static struct regulator_bulk_data cs40l26_supplies[] = {
 	{ .supply = "VP" },
 	{ .supply = "VA" },
@@ -2275,6 +2280,12 @@ int cs40l26_probe(struct cs40l26_private *cs40l26)
 	if (error)
 		goto err;
 
+	error = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, cs40l26_devs, 1, NULL, 0, NULL);
+	if (error) {
+		dev_err(dev, "Failed to MFD add device %s: %d\n", cs40l26_devs[0].name, error);
+		goto err;
+	}
+
 	return 0;
 err:
 	cs40l26_remove(cs40l26);
Signature · 1 line
2.7.4

Kind regards,
Jeff LaBundy

author maintainer
#7 lore raw

Re: [PATCH RFC 5/5] mfd: cs40l26: Add CODEC driver component

Hi Jeff,

Quoted 5 lines · Jeff LaBundy

Hi Fred,

On Thu, May 25, 2023 at 07:04:31PM -0500, Fred Treven wrote:

Quoted 8 lines
Quoted 5 lines

Use MFD interface to load the CODEC driver along
with the Input FF driver.

---

Did you mean to include a thin codec driver as part of this series to support the audio-to-haptics use-case? I don't see one.

That is the end-goal, but I wanted to submit a request for comment with just this patch to see if it was at all acceptable to add another device this way. I see now that it is not.

Quoted 3 lines

As Lee correctly points out, this isn't an MFD despite the title of the commit message, and is sort of an abuse of the API.

Understood. Do you think it’s best to migrate the appropriate code to the MFD subsystem before submitting this initial patchset (which will include the codec driver) or would it be acceptable to make that change after this has gone in? My hope was to avoid having code being reviewed more than once if a significant portion is moved to MFD.

Quoted 6 lines

What you seem to actually want is a true MFD driver responsible for initializing common resources such as regmap, an IRQ chip, etc. That driver then adds input and codec drivers as children.

At the moment, you're more or less treating the input driver as the MFD with one child, but that is not the correct pattern.

Yeah that makes sense. Please advise on what the best way to continue would be: a. Drop this patch and migrate to MFD after the Input driver has been accepted or b. Move necessary code to MFD and add both Input and codec drivers from there along with the codec driver.

Thank you,
Fred

#8 lore raw

Re: [PATCH RFC 5/5] mfd: cs40l26: Add CODEC driver component

Hi Fred,

Quoted 25 lines · Fred Treven

Hi Jeff,

Quoted 5 lines · Jeff LaBundy

Hi Fred,

On Thu, May 25, 2023 at 07:04:31PM -0500, Fred Treven wrote:

Quoted 8 lines
Quoted 5 lines

Use MFD interface to load the CODEC driver along
with the Input FF driver.

---

Did you mean to include a thin codec driver as part of this series to support the audio-to-haptics use-case? I don't see one.

That is the end-goal, but I wanted to submit a request for comment with just this patch to see if it was at all acceptable to add another device this way. I see now that it is not.

Quoted 3 lines

As Lee correctly points out, this isn't an MFD despite the title of the commit message, and is sort of an abuse of the API.

Understood. Do you think it’s best to migrate the appropriate code to the MFD subsystem before submitting this initial patchset (which will include the codec driver) or would it be acceptable to make that change after this has gone in? My hope was to avoid having code being reviewed more than once if a significant portion is moved to MFD.

Quoted 8 lines
Quoted 6 lines

What you seem to actually want is a true MFD driver responsible for initializing common resources such as regmap, an IRQ chip, etc. That driver then adds input and codec drivers as children.

At the moment, you're more or less treating the input driver as the MFD with one child, but that is not the correct pattern.

Yeah that makes sense. Please advise on what the best way to continue would be: a. Drop this patch and migrate to MFD after the Input driver has been accepted or b. Move necessary code to MFD and add both Input and codec drivers from there along with the codec driver.

If your goal is to support audio-to-haptics in mainline and to do so using an ASoC driver, then I recommend option B. You should start with a scalable and maintainable solution that reflects your long-term goals.

Option A is sunk cost. I also expect that you will identify additional changes required to the input driver, particularly with respect to interrupt handling, beyond moving initialization-related code to the MFD. It's a major re-write in my opinion.

It would be interesting to see if an existing Cirrus ASoC driver can be gently reworked to act as the child codec, vs. having to write an entirely new one for L26. I'm sure the devil is in the details though.

Quoted 5 lines

Thank you,
Fred

Kind regards,
Jeff LaBundy

author maintainer
#9 lore raw

PATCH v2 2/5 Input: cs40l26 - Support for CS40L26 Haptic Device

In reply to Fred Treven

Introduce support for Cirrus Logic device CS40L26:
a boosted haptics driver with integrated DSP and waveform memory with advanced closed loop algorithms and LRA protection.

---
 MAINTAINERS                      |    2 +
 drivers/input/misc/Kconfig       |   30 +
 drivers/input/misc/Makefile      |    3 +
 drivers/input/misc/cs40l26-i2c.c |   76 ++
 drivers/input/misc/cs40l26-spi.c |   77 ++
 drivers/input/misc/cs40l26.c     | 2385 ++++++++++++++++++++++++++++++++++++++
 include/linux/input/cs40l26.h    |  486 ++++++++
 7 files changed, 3059 insertions(+)
 create mode 100644 drivers/input/misc/cs40l26-i2c.c
 create mode 100644 drivers/input/misc/cs40l26-spi.c
 create mode 100644 drivers/input/misc/cs40l26.c
 create mode 100644 include/linux/input/cs40l26.h
MAINTAINERS +2 -0
index d72ed4957b0b..d4e51e6634c9 100644
@@ -4935,6 +4935,8 @@ S:	Supported
 W:	https://github.com/CirrusLogic/linux-drivers/wiki
 T:	git https://github.com/CirrusLogic/linux-drivers.git
 F:	Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml
+F:	drivers/input/misc/cs40l*
+F:	include/linux/input/cs40l*
 
 CIRRUS LOGIC LOCHNAGAR DRIVER
 M:	Charles Keepax <[email protected]>
drivers/input/misc/Kconfig +30 -0
index 81a54a59e13c..88e585897ad7 100644
@@ -140,6 +140,36 @@ config INPUT_BMA150
 	  To compile this driver as a module, choose M here: the
 	  module will be called bma150.
 
+config INPUT_CS40L26
+	tristate "Cirrus Logic CS40L26 Haptic Amplifier support"
+	select CS_DSP
+	help
+	  Say Y here to enable support for CS40L26 boosted haptic
+	  amplifier.
+
+	  To compile the driver as a module choose M here: the module
+	  will be called cs40l26_core.
+
+config INPUT_CS40L26_I2C
+	tristate "Support I2C bus connection"
+	depends on INPUT_CS40L26 && I2C
+	select REGMAP_I2C
+	help
+	  Say Y if you have CS40L26 connected to an I2C bus.
+
+	  To compile the driver as a module choose M here: the
+	  module will be called cs40l26_i2c.
+
+config INPUT_CS40L26_SPI
+	tristate "Support SPI bus connection"
+	depends on INPUT_CS40L26 && SPI
+	select REGMAP_SPI
+	help
+	  Say Y if you have CS40L26 connected to a SPI bus.
+
+	  To compile the driver as a module choose M here: the
+	  module will be called cs40l26_spi.
+
 config INPUT_E3X0_BUTTON
 	tristate "NI Ettus Research USRP E3xx Button support."
 	default n
drivers/input/misc/Makefile +3 -0
index 04296a4abe8e..97d2245fdd6a 100644
@@ -28,6 +28,9 @@ obj-$(CONFIG_INPUT_CMA3000)		+= cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)		+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)		+= cobalt_btns.o
 obj-$(CONFIG_INPUT_CPCAP_PWRBUTTON)	+= cpcap-pwrbutton.o
+obj-$(CONFIG_INPUT_CS40L26)		+= cs40l26.o
+obj-$(CONFIG_INPUT_CS40L26_I2C)		+= cs40l26-i2c.o
+obj-$(CONFIG_INPUT_CS40L26_SPI)		+= cs40l26-spi.o
 obj-$(CONFIG_INPUT_DA7280_HAPTICS)	+= da7280.o
 obj-$(CONFIG_INPUT_DA9052_ONKEY)	+= da9052_onkey.o
 obj-$(CONFIG_INPUT_DA9055_ONKEY)	+= da9055_onkey.o
drivers/input/misc/cs40l26-i2c.c new file +76 -0

76 lines not on this page · raw message

drivers/input/misc/cs40l26-spi.c new file +77 -0

77 lines not on this page · raw message

drivers/input/misc/cs40l26.c new file +2385 -0

2,385 lines not on this page · raw message

include/linux/input/cs40l26.h new file +486 -0

409 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.7.4

Part of the diff is not shown here. View the raw message.

#10 lore raw
In reply to Fred Treven

Yo Fred,

Tooling does not like your series very much, prob the missing v2's on
some patches:
Grabbing thread from lore.kernel.org/all/1685059471-9598-1-git-send-email-fred.treven%40cirrus.com/t.mbox.gz Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 6 messages in the thread
Will use the latest revision: v2
You can pick other revisions using the -vN flag
Checking attestation on all messages, may take a moment...
---
✓ [PATCH v2 1/5] dt-bindings: input: cirrus,cs40l26: Support for CS40L26
✓ Signed: DKIM/cirrus.com
+ Signed-off-by: Conor Dooley <[email protected]>
✓ [PATCH v2 2/5] Input: cs40l26 - Support for CS40L26 Haptic Device
✓ Signed: DKIM/cirrus.com
+ Signed-off-by: Conor Dooley <[email protected]>
ERROR: missing [3/5]!
ERROR: missing [4/5]!
ERROR: missing [5/5]!

Quoted 28 lines · Fred Treven

Introduce required basic devicetree parameters for the initial commit of CS40L26.

---
 .../devicetree/bindings/input/cirrus,cs40l26.yaml  | 102 +++++++++++++++++++++
 MAINTAINERS                                        |  10 ++
 2 files changed, 112 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +12 -0
new file mode 100644
index 000000000000..9cbc964ebded
@@ -0,0 +1,102 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/cirrus,cs40l26.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cirrus Logic CS40L26 Boosted Haptic Amplifier
+
+maintainers:
+  - Fred Treven <[email protected]>
+
+description:

Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml line 22

Quoted 10 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +10 -0
+  CS40L26 is a Boosted Haptic Driver with Integrated DSP and Waveform Memory
+  with Advanced Closed Loop Algorithms and LRA protection
+
+properties:
+  compatible:
+    enum:
+      - cirrus,cs40l26a
+      - cirrus,cs40l26b
+      - cirrus,cs40l27a
+      - cirrus,cs40l27b

I had a _brief_ look at the driver - you don't seem to have any match data, so are all of these devices actually compatible with eachother?

IOW, should this be:
properties:
compatible:
oneOf:
- items:
- enum:
- cirrus,cs40l26b
- cirrus,cs40l27a
- cirrus,cs40l27b
- const: cirrus,cs40l26a

- const: cirrus,cs40l26a

And then drop all but the cs40l26a in the driver? Apologies if I missed some difference in there.

Quoted 7 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +7 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+

Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml line 39

Quoted 10 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +10 -0
+  reset-gpios:
+    maxItems: 1
+
+  VA-supply:
+    description: Regulator for VA analog voltage
+
+  VP-supply:
+    description: Regulator for VP peak voltage
+
+  cirrus,bst-ipk-microamp:

Are these namings ripped from a datasheet? "bst-ipk" doesn't immediately mean anything to me, but I am not familiar with these devices.

Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml line 47

Quoted 8 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +8 -0
+    description:
+      Maximum amount of current that can be drawn by the device's boost converter.
+    multipleOf: 50000
+    minimum: 1600000
+    maximum: 4800000
+    default: 4500000
+
+  cirrus,bst-ctl-microvolt:

Ditto here. If there aren't rips, then maybe it'd be a good idea to use full words.

Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml line 54

Quoted 7 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +7 -0
+    description: Maximum target voltage to which DSP may increase the VBST supply.
+    multipleOf: 50000
+    minimum: 2550000
+    maximum: 11000000
+    default: 11000000
+
+  cirrus,bst-exploratory-mode-disable:

This one is a lot better ;)

Quoted 26 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +26 -0
+    description:
+      Disable boost exploratory mode.
+
+      In exploratory mode the analog maximum peak current limit of 4.5 A
+      (tolerance of + 160 mA) will be applied. This is required for the
+      device to successfully detect a boost inductor short.
+
+      Boost exploratory mode allows the device to overshoot the set boost peak
+      current limit (i.e. if current peak limit is set to 2.5 A to protect the
+      battery inductor, the current limit will be opened up to 4.5 A for
+      several milliseconds at boost startup).
+      This has potential to damage the boost inductor.
+
+      Disabling this mode will prevent this from happening; it will also
+      prevent the device from detecting boost inductor short errors.
+    type: boolean
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - reset-gpios
+
+additionalProperties: false
+
+examples:

Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml line 90

Quoted 10 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +10 -0
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/input/input.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      cs40l26@58 {

Generally using generic node names what we want, so something matching the class of device. Section 2.2.2 "Generic Names Recommendation" of the dt spec contains a bunch of ones to pick from, but I don't really know where "haptic amplifier" fits in!

Cheers,
Conor.

Quoted 36 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +12 -0
+        compatible = "cirrus,cs40l26a";
+        reg = <0x58>;
+        interrupt-parent = <&gpio>;
+        interrupts = <57 IRQ_TYPE_LEVEL_LOW>;
+        reset-gpios = <&gpio 54 GPIO_ACTIVE_LOW>;
+        VA-supply = <&dummy_vreg>;
+        VP-supply = <&dummy_vreg>;
+        cirrus,bst-ctl-microvolt = <2600000>;
+        cirrus,bst-ipk-microamp = <1650000>;
+        cirrus,bst-exploratory-mode-disable;
+      };
+    };
MAINTAINERS +10 -0
index 2b073facf399..d72ed4957b0b 100644
@@ -4926,6 +4926,16 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/net/ethernet/cirrus/ep93xx_eth.c
 
+CIRRUS LOGIC HAPTICS DRIVER
+M:	Fred Treven <[email protected]>
+M:	Ben Bright <[email protected]>
+M:	James Ogletree <[email protected]>
+L:	[email protected]
+S:	Supported
+W:	https://github.com/CirrusLogic/linux-drivers/wiki
+T:	git https://github.com/CirrusLogic/linux-drivers.git
+F:	Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml
+
 CIRRUS LOGIC LOCHNAGAR DRIVER
 M:	Charles Keepax <[email protected]>
 M:	Richard Fitzgerald <[email protected]>
Signature · 1 line
2.7.4
author maintainer
#11 lore raw

Hi Conor,

Quoted 15 lines · Conor Dooley

Yo Fred,

Tooling does not like your series very much, prob the missing v2's on
some patches:
Grabbing thread from lore.kernel.org/all/1685059471-9598-1-git-send-email-fred.treven%40cirrus.com/t.mbox.gz Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 6 messages in the thread
Will use the latest revision: v2
You can pick other revisions using the -vN flag
Checking attestation on all messages, may take a moment...
---
✓ [PATCH v2 1/5] dt-bindings: input: cirrus,cs40l26: Support for CS40L26

Quoted 8 lines

✓ Signed: DKIM/cirrus.com
+ Signed-off-by: Conor Dooley <[email protected]>
✓ [PATCH v2 2/5] Input: cs40l26 - Support for CS40L26 Haptic Device
✓ Signed: DKIM/cirrus.com
+ Signed-off-by: Conor Dooley <[email protected]>
ERROR: missing [3/5]!
ERROR: missing [4/5]!
ERROR: missing [5/5]!

Understood. I was uncertain if this was just needed for patches that had been edited or for all new patches. I will resubmit with some other code changes to address other comments I’ve received and will mark the patches with the same version number.

Quoted 55 lines · Fred Treven
Quoted 28 lines

Introduce required basic devicetree parameters for the initial commit of CS40L26.

---
.../devicetree/bindings/input/cirrus,cs40l26.yaml | 102 +++++++++++++++++++++
MAINTAINERS | 10 ++

2 files changed, 112 insertions(+)

create mode 100644 Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml

Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +12 -0
new file mode 100644
index 000000000000..9cbc964ebded
@@ -0,0 +1,102 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/cirrus,cs40l26.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cirrus Logic CS40L26 Boosted Haptic Amplifier
+
+maintainers:
+  - Fred Treven <[email protected]>
+
+description:

Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml line 22

Quoted 10 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +10 -0
+  CS40L26 is a Boosted Haptic Driver with Integrated DSP and Waveform Memory
+  with Advanced Closed Loop Algorithms and LRA protection
+
+properties:
+  compatible:
+    enum:
+      - cirrus,cs40l26a
+      - cirrus,cs40l26b
+      - cirrus,cs40l27a
+      - cirrus,cs40l27b

I had a _brief_ look at the driver - you don't seem to have any match data, so are all of these devices actually compatible with eachother?

IOW, should this be:
properties:
compatible:
oneOf:
- items:
- enum:
- cirrus,cs40l26b
- cirrus,cs40l27a
- cirrus,cs40l27b
- const: cirrus,cs40l26a

Quoted 4 lines

- const: cirrus,cs40l26a

And then drop all but the cs40l26a in the driver? Apologies if I missed some difference in there.

They are all compatible, yes. There is match data in cs40l26-i2c.c and cs40l26-spi.c if you are referring to the of_device_id struct. Please let me know if I’m misunderstanding your meaning here.

Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +12 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    maxItems: 1
+
+  VA-supply:
+    description: Regulator for VA analog voltage
Quoted 8 lines

Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml line 39

Quoted 5 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +5 -0
+
+  VP-supply:
+    description: Regulator for VP peak voltage
+
+  cirrus,bst-ipk-microamp:

Are these namings ripped from a datasheet? "bst-ipk" doesn't immediately mean anything to me, but I am not familiar with these devices.

Yes, they are taken from the data sheet with “bst-ipk” referring to boost inductor peak current consumption. I do think it makes sense to have clearer naming here so I can go ahead and make these changes.

Quoted 10 lines

Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml line 47

Quoted 9 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +8 -0
+    description:
+      Maximum amount of current that can be drawn by the device's boost converter.
+    multipleOf: 50000
+    minimum: 1600000
+    maximum: 4800000
+    default: 4500000
+
+  cirrus,bst-ctl-microvolt:
Quoted 2 lines

Ditto here. If there aren't rips, then maybe it'd be a good idea to use full words.

Same as above. Is ripped from DS, but doesn’t need to be called this if it’s not appropriate

Quoted 43 lines
Quoted 27 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +26 -0
+    description:
+      Disable boost exploratory mode.
+
+      In exploratory mode the analog maximum peak current limit of 4.5 A
+      (tolerance of + 160 mA) will be applied. This is required for the
+      device to successfully detect a boost inductor short.
+
+      Boost exploratory mode allows the device to overshoot the set boost peak
+      current limit (i.e. if current peak limit is set to 2.5 A to protect the
+      battery inductor, the current limit will be opened up to 4.5 A for
+      several milliseconds at boost startup).
+      This has potential to damage the boost inductor.
+
+      Disabling this mode will prevent this from happening; it will also
+      prevent the device from detecting boost inductor short errors.
+    type: boolean
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - reset-gpios
+
+additionalProperties: false
+
+examples:

Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml line 90

Quoted 10 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +10 -0
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/input/input.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      cs40l26@58 {

Generally using generic node names what we want, so something matching the class of device. Section 2.2.2 "Generic Names Recommendation" of the dt spec contains a bunch of ones to pick from, but I don't really know where "haptic amplifier" fits in!

Quoted 2 lines

Cheers,
Conor.

Understood. I’ll try to find a better way to name the node.

Best regards,
Fred

#12 lore raw
Quoted 21 lines · Fred Treven
Quoted 12 lines · Conor Dooley

Tooling does not like your series very much, prob the missing v2's on
some patches:
Grabbing thread from lore.kernel.org/all/1685059471-9598-1-git-send-email-fred.treven%40cirrus.com/t.mbox.gz Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 6 messages in the thread
Will use the latest revision: v2
You can pick other revisions using the -vN flag
Checking attestation on all messages, may take a moment...
---
✓ [PATCH v2 1/5] dt-bindings: input: cirrus,cs40l26: Support for CS40L26

Quoted 8 lines

✓ Signed: DKIM/cirrus.com
+ Signed-off-by: Conor Dooley <[email protected]>
✓ [PATCH v2 2/5] Input: cs40l26 - Support for CS40L26 Haptic Device
✓ Signed: DKIM/cirrus.com
+ Signed-off-by: Conor Dooley <[email protected]>
ERROR: missing [3/5]!
ERROR: missing [4/5]!
ERROR: missing [5/5]!

Quoted 4 lines

Understood. I was uncertain if this was just needed for patches that had been edited or for all new patches. I will resubmit with some other code changes to address other comments I’ve received and will mark the patches with the same version number.

I just whack an N into git format-patch's --reroll-count/-v option, and use the same across the whole series. Makes people's and tool's lives easier :)

Quoted 22 lines
Quoted 22 lines

Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml line 22

Quoted 7 lines
Documentation/devicetree/bindings/input/cirrus,cs40l26.yaml new file +7 -0
+properties:
+  compatible:
+    enum:
+      - cirrus,cs40l26a
+      - cirrus,cs40l26b
+      - cirrus,cs40l27a
+      - cirrus,cs40l27b

I had a _brief_ look at the driver - you don't seem to have any match data, so are all of these devices actually compatible with eachother?

IOW, should this be:
properties:
compatible:
oneOf:
- items:
- enum:
- cirrus,cs40l26b
- cirrus,cs40l27a
- cirrus,cs40l27b
- const: cirrus,cs40l26a

Quoted 8 lines
Quoted 4 lines

- const: cirrus,cs40l26a

And then drop all but the cs40l26a in the driver? Apologies if I missed some difference in there.

They are all compatible, yes. There is match data in cs40l26-i2c.c and cs40l26-spi.c if you are referring to the of_device_id struct. Please let me know if I’m misunderstanding your meaning here.

What I saw looking in the driver was:
+static const struct of_device_id cs40l26_of_match[CS40L26_NUM_DEVS + 1] = {
+ { .compatible = "cirrus,cs40l26a" },
+ { .compatible = "cirrus,cs40l26b" },
+ { .compatible = "cirrus,cs40l27a" },
+ { .compatible = "cirrus,cs40l27b" },
+ {}
+};
+MODULE_DEVICE_TABLE(of, cs40l26_of_match);

So you have a bunch of compatibles, but didn't immediately appear to be doing anything different depending on which one of them you get. What I meant was populating the data field of of_device_id with something different depending on the compatible.
If the programming model is the same, you can document that they are all compatible with "cirrus,cs40l26a", rather than having to add new entries to the match table. Also has the advantage that if you bring out a cirrus,cs40l27c that is compatible with the existing devices, then no changes are needed to software to support it ;)

Or perhaps you are doing something different based on the compatible that I just did not notice.

Cheers,
Conor.

(The [CS40L26_NUM_DEVS + 1] is also usually just [] btw)