Skip to contentSkip to conversation

can: tcan4x5x: Introduce tcan4552/4553

PATCH Superseded Markus Schneider-Pargmann 5 participants 20 messages Mar 14, 2023 – Mar 15, 2023

Subsystems (5)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Markus Schneider-Pargmann

author maintainer
#0 lore raw

cover can: tcan4x5x: Introduce tcan4552/4553

Hi Marc and everyone,

This series introduces two new chips tcan-4552 and tcan-4553. The generic driver works in general but needs a few small changes. These are caused by the removal of wake and state pins.

I included two patches from the optimization series and will remove them from the optimization series. Hopefully it avoids conflicts and not polute the other series with tcan4552/4553 stuff.

Best,
Markus

optimization series:
https://lore.kernel.org/lkml/[email protected]

Markus Schneider-Pargmann (5):
dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants
can: tcan4x5x: Remove reserved register 0x814 from writable table
can: tcan4x5x: Check size of mram configuration
can: tcan4x5x: Rename ID registers to match datasheet
can: tcan4x5x: Add support for tcan4552/4553

 .../devicetree/bindings/net/can/tcan4x5x.txt  |  11 +-
 drivers/net/can/m_can/m_can.c                 |  16 +++
 drivers/net/can/m_can/m_can.h                 |   1 +
 drivers/net/can/m_can/tcan4x5x-core.c         | 122 ++++++++++++++----
 drivers/net/can/m_can/tcan4x5x-regmap.c       |   1 -
 5 files changed, 121 insertions(+), 30 deletions(-)
Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH 1/5 dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants

These two new chips do not have state or wake pins.

---
 .../devicetree/bindings/net/can/tcan4x5x.txt          | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +8 -3
index e3501bfa22e9..38a2b5369b44 100644
@@ -4,7 +4,10 @@ Texas Instruments TCAN4x5x CAN Controller
 This file provides device node information for the TCAN4x5x interface contains.
 
 Required properties:
-	- compatible: "ti,tcan4x5x"
+	- compatible:
+		"ti,tcan4x5x" or
+		"ti,tcan4552" or
+		"ti,tcan4553"
 	- reg: 0
 	- #address-cells: 1
 	- #size-cells: 0
@@ -21,8 +24,10 @@ Optional properties:
 	- reset-gpios: Hardwired output GPIO. If not defined then software
 		       reset.
 	- device-state-gpios: Input GPIO that indicates if the device is in
-			      a sleep state or if the device is active.
-	- device-wake-gpios: Wake up GPIO to wake up the TCAN device.
+			      a sleep state or if the device is active. Not
+			      available with tcan4552/4553.
+	- device-wake-gpios: Wake up GPIO to wake up the TCAN device. Not
+			     available with tcan4552/4553.
 
 Example:
 tcan4x5x: tcan4x5x@0 {
Signature · 1 line
2.39.2
author maintainer
#11 lore raw

PATCH 2/5 can: tcan4x5x: Remove reserved register 0x814 from writable table

In reply to Markus Schneider-Pargmann

The mentioned register is not writable. It is reserved and should not be written.

Fixes 39dbb21b6a29 ("can: tcan4x5x: Specify separate read/write ranges")
---
 drivers/net/can/m_can/tcan4x5x-regmap.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/can/m_can/tcan4x5x-regmap.c +0 -1
index 2b218ce04e9f..fafa6daa67e6 100644
@@ -95,7 +95,6 @@ static const struct regmap_range tcan4x5x_reg_table_wr_range[] = {
 	regmap_reg_range(0x000c, 0x0010),
 	/* Device configuration registers and Interrupt Flags*/
 	regmap_reg_range(0x0800, 0x080c),
-	regmap_reg_range(0x0814, 0x0814),
 	regmap_reg_range(0x0820, 0x0820),
 	regmap_reg_range(0x0830, 0x0830),
 	/* M_CAN */
Signature · 1 line
2.39.2
author maintainer
#12 lore raw

PATCH 3/5 can: tcan4x5x: Check size of mram configuration

In reply to Markus Schneider-Pargmann

To reduce debugging effort in case the mram is misconfigured, add this size check of the DT configuration. Currently if the mram configuration doesn't fit into the available MRAM it just overwrites other areas of the MRAM.

---
 drivers/net/can/m_can/m_can.c         | 16 ++++++++++++++++
 drivers/net/can/m_can/m_can.h         |  1 +
 drivers/net/can/m_can/tcan4x5x-core.c |  5 +++++
 3 files changed, 22 insertions(+)
drivers/net/can/m_can/m_can.c +16 -0
index 8e83d6963d85..8ccf20f093f8 100644
@@ -1886,6 +1886,22 @@ static int register_m_can_dev(struct net_device *dev)
 	return register_candev(dev);
 }
 
+int m_can_check_mram_cfg(struct m_can_classdev *cdev, u32 mram_max_size)
+{
+	u32 total_size;
+
+	total_size = cdev->mcfg[MRAM_TXB].off - cdev->mcfg[MRAM_SIDF].off +
+			cdev->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE;
+	if (total_size > mram_max_size) {
+		dev_err(cdev->dev, "Total size of mram config(%u) exceeds mram(%u)\n",
+			total_size, mram_max_size);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(m_can_check_mram_cfg);
+
 static void m_can_of_parse_mram(struct m_can_classdev *cdev,
 				const u32 *mram_config_vals)
 {
drivers/net/can/m_can/m_can.h +1 -0
index a839dc71dc9b..d8150d8128e7 100644
@@ -101,6 +101,7 @@ int m_can_class_register(struct m_can_classdev *cdev);
 void m_can_class_unregister(struct m_can_classdev *cdev);
 int m_can_class_get_clocks(struct m_can_classdev *cdev);
 int m_can_init_ram(struct m_can_classdev *priv);
+int m_can_check_mram_cfg(struct m_can_classdev *cdev, u32 mram_max_size);
 
 int m_can_class_suspend(struct device *dev);
 int m_can_class_resume(struct device *dev);
drivers/net/can/m_can/tcan4x5x-core.c +5 -0
index 2342aa011647..e706518176e4 100644
@@ -80,6 +80,7 @@
 	 TCAN4X5X_MCAN_IR_RF1F)
 
 #define TCAN4X5X_MRAM_START 0x8000
+#define TCAN4X5X_MRAM_SIZE 0x800
 #define TCAN4X5X_MCAN_OFFSET 0x1000
 
 #define TCAN4X5X_CLEAR_ALL_INT 0xffffffff
@@ -307,6 +308,10 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
 	if (!mcan_class)
 		return -ENOMEM;
 
+	ret = m_can_check_mram_cfg(mcan_class, TCAN4X5X_MRAM_SIZE);
+	if (ret)
+		goto out_m_can_class_free_dev;
+
 	priv = cdev_to_priv(mcan_class);
 
 	priv->power = devm_regulator_get_optional(&spi->dev, "vsup");
Signature · 1 line
2.39.2
author maintainer
#13 lore raw

PATCH 4/5 can: tcan4x5x: Rename ID registers to match datasheet

In reply to Markus Schneider-Pargmann

The datasheet calls these registers ID1 and ID2. Rename these to avoid confusion.

---
 drivers/net/can/m_can/tcan4x5x-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/can/m_can/tcan4x5x-core.c +2 -2
index e706518176e4..fb9375fa20ec 100644
@@ -6,8 +6,8 @@
 
 #define TCAN4X5X_EXT_CLK_DEF 40000000
 
-#define TCAN4X5X_DEV_ID0 0x00
-#define TCAN4X5X_DEV_ID1 0x04
+#define TCAN4X5X_DEV_ID1 0x00
+#define TCAN4X5X_DEV_ID2 0x04
 #define TCAN4X5X_REV 0x08
 #define TCAN4X5X_STATUS 0x0C
 #define TCAN4X5X_ERROR_STATUS_MASK 0x10
Signature · 1 line
2.39.2
author maintainer
#14 lore raw

PATCH 5/5 can: tcan4x5x: Add support for tcan4552/4553

In reply to Markus Schneider-Pargmann

tcan4552 and tcan4553 do not have wake or state pins, so they are currently not compatible with the generic driver. The generic driver uses tcan4x5x_disable_state() and tcan4x5x_disable_wake() if the gpios are not defined. These functions use register bits that are not available in tcan4552/4553.

This patch adds support by introducing version information to reflect if the chip has wake and state pins. Also the version is now checked.

Signed-off-by Markus Schneider-Pargmann
---
 drivers/net/can/m_can/tcan4x5x-core.c | 113 ++++++++++++++++++++------
 1 file changed, 89 insertions(+), 24 deletions(-)
drivers/net/can/m_can/tcan4x5x-core.c +89 -24
index fb9375fa20ec..e7fa509dacc9 100644
@@ -7,6 +7,7 @@
 #define TCAN4X5X_EXT_CLK_DEF 40000000
 
 #define TCAN4X5X_DEV_ID1 0x00
+#define TCAN4X5X_DEV_ID1_TCAN 0x4e414354 /* ASCII TCAN */
 #define TCAN4X5X_DEV_ID2 0x04
 #define TCAN4X5X_REV 0x08
 #define TCAN4X5X_STATUS 0x0C
@@ -103,6 +104,13 @@
 #define TCAN4X5X_WD_3_S_TIMER BIT(29)
 #define TCAN4X5X_WD_6_S_TIMER (BIT(28) | BIT(29))
 
+struct tcan4x5x_version_info {
+	u32 id2_register;
+
+	bool has_wake_pin;
+	bool has_state_pin;
+};
+
 static inline struct tcan4x5x_priv *cdev_to_priv(struct m_can_classdev *cdev)
 {
 	return container_of(cdev, struct tcan4x5x_priv, cdev);
@@ -254,18 +262,53 @@ static int tcan4x5x_disable_state(struct m_can_classdev *cdev)
 				  TCAN4X5X_DISABLE_INH_MSK, 0x01);
 }
 
-static int tcan4x5x_get_gpios(struct m_can_classdev *cdev)
+static int tcan4x5x_verify_version(
+		struct tcan4x5x_priv *priv,
+		const struct tcan4x5x_version_info *version_info)
+{
+	u32 val;
+	int ret;
+
+	ret = regmap_read(priv->regmap, TCAN4X5X_DEV_ID1, &val);
+	if (ret)
+		return ret;
+
+	if (val != TCAN4X5X_DEV_ID1_TCAN) {
+		dev_err(&priv->spi->dev, "Not a tcan device %x\n", val);
+		return -ENODEV;
+	}
+
+	if (!version_info->id2_register)
+		return 0;
+
+	ret = regmap_read(priv->regmap, TCAN4X5X_DEV_ID2, &val);
+	if (ret)
+		return ret;
+
+	if (version_info->id2_register != val) {
+		dev_err(&priv->spi->dev, "Not the specified TCAN device, id2: %x != %x\n",
+			version_info->id2_register, val);
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+static int tcan4x5x_get_gpios(struct m_can_classdev *cdev,
+			      const struct tcan4x5x_version_info *version_info)
 {
 	struct tcan4x5x_priv *tcan4x5x = cdev_to_priv(cdev);
 	int ret;
 
-	tcan4x5x->device_wake_gpio = devm_gpiod_get(cdev->dev, "device-wake",
-						    GPIOD_OUT_HIGH);
-	if (IS_ERR(tcan4x5x->device_wake_gpio)) {
-		if (PTR_ERR(tcan4x5x->device_wake_gpio) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
+	if (version_info->has_wake_pin) {
+		tcan4x5x->device_wake_gpio = devm_gpiod_get(cdev->dev, "device-wake",
+							    GPIOD_OUT_HIGH);
+		if (IS_ERR(tcan4x5x->device_wake_gpio)) {
+			if (PTR_ERR(tcan4x5x->device_wake_gpio) == -EPROBE_DEFER)
+				return -EPROBE_DEFER;
 
-		tcan4x5x_disable_wake(cdev);
+			tcan4x5x_disable_wake(cdev);
+		}
 	}
 
 	tcan4x5x->reset_gpio = devm_gpiod_get_optional(cdev->dev, "reset",
@@ -277,12 +320,14 @@ static int tcan4x5x_get_gpios(struct m_can_classdev *cdev)
 	if (ret)
 		return ret;
 
-	tcan4x5x->device_state_gpio = devm_gpiod_get_optional(cdev->dev,
-							      "device-state",
-							      GPIOD_IN);
-	if (IS_ERR(tcan4x5x->device_state_gpio)) {
-		tcan4x5x->device_state_gpio = NULL;
-		tcan4x5x_disable_state(cdev);
+	if (version_info->has_state_pin) {
+		tcan4x5x->device_state_gpio = devm_gpiod_get_optional(cdev->dev,
+								      "device-state",
+								      GPIOD_IN);
+		if (IS_ERR(tcan4x5x->device_state_gpio)) {
+			tcan4x5x->device_state_gpio = NULL;
+			tcan4x5x_disable_state(cdev);
+		}
 	}
 
 	return 0;
@@ -301,8 +346,13 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
 {
 	struct tcan4x5x_priv *priv;
 	struct m_can_classdev *mcan_class;
+	const struct tcan4x5x_version_info *version_info;
 	int freq, ret;
 
+	version_info = of_device_get_match_data(&spi->dev);
+	if (!version_info)
+		version_info = (void *)spi_get_device_id(spi)->driver_data;
+
 	mcan_class = m_can_class_allocate_dev(&spi->dev,
 					      sizeof(struct tcan4x5x_priv));
 	if (!mcan_class)
@@ -361,7 +411,11 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
 	if (ret)
 		goto out_m_can_class_free_dev;
 
-	ret = tcan4x5x_get_gpios(mcan_class);
+	ret = tcan4x5x_verify_version(priv, version_info);
+	if (ret)
+		goto out_power;
+
+	ret = tcan4x5x_get_gpios(mcan_class, version_info);
 	if (ret)
 		goto out_power;
 
@@ -394,21 +448,32 @@ static void tcan4x5x_can_remove(struct spi_device *spi)
 	m_can_class_free_dev(priv->cdev.net);
 }
 
+static const struct tcan4x5x_version_info tcan4x5x_generic = {
+	.has_state_pin = true,
+	.has_wake_pin = true,
+};
+
+static const struct tcan4x5x_version_info tcan4x5x_tcan4552 = {
+	.id2_register = 0x32353534, /* ASCII = 4552 */
+};
+
+static const struct tcan4x5x_version_info tcan4x5x_tcan4553 = {
+	.id2_register = 0x33353534, /* ASCII = 4553 */
+};
+
 static const struct of_device_id tcan4x5x_of_match[] = {
-	{
-		.compatible = "ti,tcan4x5x",
-	}, {
-		/* sentinel */
-	},
+	{ .compatible = "ti,tcan4x5x", .data = &tcan4x5x_generic },
+	{ .compatible = "ti,tcan4552", .data = &tcan4x5x_tcan4552 },
+	{ .compatible = "ti,tcan4553", .data = &tcan4x5x_tcan4553 },
+	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, tcan4x5x_of_match);
 
 static const struct spi_device_id tcan4x5x_id_table[] = {
-	{
-		.name = "tcan4x5x",
-	}, {
-		/* sentinel */
-	},
+	{ .name = "tcan4x5x", .driver_data = (unsigned long) &tcan4x5x_generic, },
+	{ .name = "tcan4552", .driver_data = (unsigned long) &tcan4x5x_tcan4552, },
+	{ .name = "tcan4553", .driver_data = (unsigned long) &tcan4x5x_tcan4553, },
+	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(spi, tcan4x5x_id_table);
 
Signature · 1 line
2.39.2
#2 lore raw

Re: [PATCH 1/5] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants

In reply to Markus Schneider-Pargmann
Quoted 3 lines · Markus Schneider-Pargmann

These two new chips do not have state or wake pins.

Not a requirement from my side,
but perhaps it would be worth converting this binding to yaml at some point.

Quoted 36 lines
---
 .../devicetree/bindings/net/can/tcan4x5x.txt          | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +8 -3
index e3501bfa22e9..38a2b5369b44 100644
@@ -4,7 +4,10 @@ Texas Instruments TCAN4x5x CAN Controller
 This file provides device node information for the TCAN4x5x interface contains.
 
 Required properties:
-	- compatible: "ti,tcan4x5x"
+	- compatible:
+		"ti,tcan4x5x" or
+		"ti,tcan4552" or
+		"ti,tcan4553"
 	- reg: 0
 	- #address-cells: 1
 	- #size-cells: 0
@@ -21,8 +24,10 @@ Optional properties:
 	- reset-gpios: Hardwired output GPIO. If not defined then software
 		       reset.
 	- device-state-gpios: Input GPIO that indicates if the device is in
-			      a sleep state or if the device is active.
-	- device-wake-gpios: Wake up GPIO to wake up the TCAN device.
+			      a sleep state or if the device is active. Not
+			      available with tcan4552/4553.
+	- device-wake-gpios: Wake up GPIO to wake up the TCAN device. Not
+			     available with tcan4552/4553.
 
 Example:
 tcan4x5x: tcan4x5x@0 {
Signature · 1 line
2.39.2
#15 lore raw

Re: [PATCH 5/5] can: tcan4x5x: Add support for tcan4552/4553

In reply to Markus Schneider-Pargmann
Quoted 10 lines · Markus Schneider-Pargmann

tcan4552 and tcan4553 do not have wake or state pins, so they are currently not compatible with the generic driver. The generic driver uses tcan4x5x_disable_state() and tcan4x5x_disable_wake() if the gpios are not defined. These functions use register bits that are not available in tcan4552/4553.

This patch adds support by introducing version information to reflect if the chip has wake and state pins. Also the version is now checked.

Signed-off-by Markus Schneider-Pargmann

Hi Markus,

you forgot your email address in the signed-off-by line.

Quoted 8 lines
---
 drivers/net/can/m_can/tcan4x5x-core.c | 113 ++++++++++++++++++++------
 1 file changed, 89 insertions(+), 24 deletions(-)
drivers/net/can/m_can/tcan4x5x-core.c +0 -0
index fb9375fa20ec..e7fa509dacc9 100644

...

drivers/net/can/m_can/tcan4x5x-core.c static int tcan4x5x_disable_state(struct m_can_classdev *cdev) · line 267

Quoted 8 lines
drivers/net/can/m_can/tcan4x5x-core.c +3 -1
@@ -254,18 +262,53 @@ static int tcan4x5x_disable_state(struct m_can_classdev *cdev)
 				  TCAN4X5X_DISABLE_INH_MSK, 0x01);
 }
 
-static int tcan4x5x_get_gpios(struct m_can_classdev *cdev)
+static int tcan4x5x_verify_version(
+		struct tcan4x5x_priv *priv,
+		const struct tcan4x5x_version_info *version_info)

nit:

static int
tcan4x5x_verify_version(struct tcan4x5x_priv *priv, const struct tcan4x5x_version_info *version_info)

or:

static int tcan4x5x_verify_version(struct tcan4x5x_priv *priv, const struct tcan4x5x_version_info *version_info)

Your could make the line shorter by renaming the 'version_info' parameter, say to 'info'.

...

Quoted 29 lines
drivers/net/can/m_can/tcan4x5x-core.c +17 -5
@@ -394,21 +448,32 @@ static void tcan4x5x_can_remove(struct spi_device *spi)
 	m_can_class_free_dev(priv->cdev.net);
 }
 
+static const struct tcan4x5x_version_info tcan4x5x_generic = {
+	.has_state_pin = true,
+	.has_wake_pin = true,
+};
+
+static const struct tcan4x5x_version_info tcan4x5x_tcan4552 = {
+	.id2_register = 0x32353534, /* ASCII = 4552 */
+};
+
+static const struct tcan4x5x_version_info tcan4x5x_tcan4553 = {
+	.id2_register = 0x33353534, /* ASCII = 4553 */
+};
+
 static const struct of_device_id tcan4x5x_of_match[] = {
-	{
-		.compatible = "ti,tcan4x5x",
-	}, {
-		/* sentinel */
-	},
+	{ .compatible = "ti,tcan4x5x", .data = &tcan4x5x_generic },
+	{ .compatible = "ti,tcan4552", .data = &tcan4x5x_tcan4552 },
+	{ .compatible = "ti,tcan4553", .data = &tcan4x5x_tcan4553 },
+	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, tcan4x5x_of_match);

drivers/net/can/m_can/tcan4x5x-core.c static void tcan4x5x_can_remove(struct spi_device *spi) · line 475

Quoted 10 lines
drivers/net/can/m_can/tcan4x5x-core.c +3 -5
 
 static const struct spi_device_id tcan4x5x_id_table[] = {
-	{
-		.name = "tcan4x5x",
-	}, {
-		/* sentinel */
-	},
+	{ .name = "tcan4x5x", .driver_data = (unsigned long) &tcan4x5x_generic, },
+	{ .name = "tcan4552", .driver_data = (unsigned long) &tcan4x5x_tcan4552, },
+	{ .name = "tcan4553", .driver_data = (unsigned long) &tcan4x5x_tcan4553, },

nit: checkpatch tells me that no space is necessary after a cast.

Quoted 7 lines
drivers/net/can/m_can/tcan4x5x-core.c +1 -0
+	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(spi, tcan4x5x_id_table);
 
Signature · 1 line
2.39.2
#17 lore raw

Re: [PATCH 5/5] can: tcan4x5x: Add support for tcan4552/4553

In reply to Markus Schneider-Pargmann
Quoted 123 lines · Markus Schneider-Pargmann

tcan4552 and tcan4553 do not have wake or state pins, so they are currently not compatible with the generic driver. The generic driver uses tcan4x5x_disable_state() and tcan4x5x_disable_wake() if the gpios are not defined. These functions use register bits that are not available in tcan4552/4553.

This patch adds support by introducing version information to reflect if the chip has wake and state pins. Also the version is now checked.

Signed-off-by Markus Schneider-Pargmann
---
 drivers/net/can/m_can/tcan4x5x-core.c | 113 ++++++++++++++++++++------
 1 file changed, 89 insertions(+), 24 deletions(-)
drivers/net/can/m_can/tcan4x5x-core.c +58 -13
index fb9375fa20ec..e7fa509dacc9 100644
@@ -7,6 +7,7 @@
 #define TCAN4X5X_EXT_CLK_DEF 40000000
 
 #define TCAN4X5X_DEV_ID1 0x00
+#define TCAN4X5X_DEV_ID1_TCAN 0x4e414354 /* ASCII TCAN */
 #define TCAN4X5X_DEV_ID2 0x04
 #define TCAN4X5X_REV 0x08
 #define TCAN4X5X_STATUS 0x0C
@@ -103,6 +104,13 @@
 #define TCAN4X5X_WD_3_S_TIMER BIT(29)
 #define TCAN4X5X_WD_6_S_TIMER (BIT(28) | BIT(29))
 
+struct tcan4x5x_version_info {
+	u32 id2_register;
+
+	bool has_wake_pin;
+	bool has_state_pin;
+};
+
 static inline struct tcan4x5x_priv *cdev_to_priv(struct m_can_classdev *cdev)
 {
 	return container_of(cdev, struct tcan4x5x_priv, cdev);
@@ -254,18 +262,53 @@ static int tcan4x5x_disable_state(struct m_can_classdev *cdev)
 				  TCAN4X5X_DISABLE_INH_MSK, 0x01);
 }
 
-static int tcan4x5x_get_gpios(struct m_can_classdev *cdev)
+static int tcan4x5x_verify_version(
+		struct tcan4x5x_priv *priv,
+		const struct tcan4x5x_version_info *version_info)
+{
+	u32 val;
+	int ret;
+
+	ret = regmap_read(priv->regmap, TCAN4X5X_DEV_ID1, &val);
+	if (ret)
+		return ret;
+
+	if (val != TCAN4X5X_DEV_ID1_TCAN) {
+		dev_err(&priv->spi->dev, "Not a tcan device %x\n", val);
+		return -ENODEV;
+	}
+
+	if (!version_info->id2_register)
+		return 0;
+
+	ret = regmap_read(priv->regmap, TCAN4X5X_DEV_ID2, &val);
+	if (ret)
+		return ret;
+
+	if (version_info->id2_register != val) {
+		dev_err(&priv->spi->dev, "Not the specified TCAN device, id2: %x != %x\n",
+			version_info->id2_register, val);
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+static int tcan4x5x_get_gpios(struct m_can_classdev *cdev,
+			      const struct tcan4x5x_version_info *version_info)
 {
 	struct tcan4x5x_priv *tcan4x5x = cdev_to_priv(cdev);
 	int ret;
 
-	tcan4x5x->device_wake_gpio = devm_gpiod_get(cdev->dev, "device-wake",
-						    GPIOD_OUT_HIGH);
-	if (IS_ERR(tcan4x5x->device_wake_gpio)) {
-		if (PTR_ERR(tcan4x5x->device_wake_gpio) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
+	if (version_info->has_wake_pin) {
+		tcan4x5x->device_wake_gpio = devm_gpiod_get(cdev->dev, "device-wake",
+							    GPIOD_OUT_HIGH);
+		if (IS_ERR(tcan4x5x->device_wake_gpio)) {
+			if (PTR_ERR(tcan4x5x->device_wake_gpio) == -EPROBE_DEFER)
+				return -EPROBE_DEFER;
 
-		tcan4x5x_disable_wake(cdev);
+			tcan4x5x_disable_wake(cdev);
+		}
 	}
 
 	tcan4x5x->reset_gpio = devm_gpiod_get_optional(cdev->dev, "reset",
@@ -277,12 +320,14 @@ static int tcan4x5x_get_gpios(struct m_can_classdev *cdev)
 	if (ret)
 		return ret;
 
-	tcan4x5x->device_state_gpio = devm_gpiod_get_optional(cdev->dev,
-							      "device-state",
-							      GPIOD_IN);
-	if (IS_ERR(tcan4x5x->device_state_gpio)) {
-		tcan4x5x->device_state_gpio = NULL;
-		tcan4x5x_disable_state(cdev);
+	if (version_info->has_state_pin) {
+		tcan4x5x->device_state_gpio = devm_gpiod_get_optional(cdev->dev,
+								      "device-state",
+								      GPIOD_IN);
+		if (IS_ERR(tcan4x5x->device_state_gpio)) {
+			tcan4x5x->device_state_gpio = NULL;
+			tcan4x5x_disable_state(cdev);
+		}
 	}
 
 	return 0;

drivers/net/can/m_can/tcan4x5x-core.c static int tcan4x5x_can_probe(struct spi_device *spi) · line 350

Quoted 5 lines
drivers/net/can/m_can/tcan4x5x-core.c +1 -0
@@ -301,8 +346,13 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
 {
 	struct tcan4x5x_priv *priv;
 	struct m_can_classdev *mcan_class;
+	const struct tcan4x5x_version_info *version_info;
 	int freq, ret;

Nitpick: RCT.

Quoted 53 lines
drivers/net/can/m_can/tcan4x5x-core.c +26 -7
+	version_info = of_device_get_match_data(&spi->dev);
+	if (!version_info)
+		version_info = (void *)spi_get_device_id(spi)->driver_data;
+
 	mcan_class = m_can_class_allocate_dev(&spi->dev,
 					      sizeof(struct tcan4x5x_priv));
 	if (!mcan_class)
@@ -361,7 +411,11 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
 	if (ret)
 		goto out_m_can_class_free_dev;
 
-	ret = tcan4x5x_get_gpios(mcan_class);
+	ret = tcan4x5x_verify_version(priv, version_info);
+	if (ret)
+		goto out_power;
+
+	ret = tcan4x5x_get_gpios(mcan_class, version_info);
 	if (ret)
 		goto out_power;
 
@@ -394,21 +448,32 @@ static void tcan4x5x_can_remove(struct spi_device *spi)
 	m_can_class_free_dev(priv->cdev.net);
 }
 
+static const struct tcan4x5x_version_info tcan4x5x_generic = {
+	.has_state_pin = true,
+	.has_wake_pin = true,
+};
+
+static const struct tcan4x5x_version_info tcan4x5x_tcan4552 = {
+	.id2_register = 0x32353534, /* ASCII = 4552 */
+};
+
+static const struct tcan4x5x_version_info tcan4x5x_tcan4553 = {
+	.id2_register = 0x33353534, /* ASCII = 4553 */
+};
+
 static const struct of_device_id tcan4x5x_of_match[] = {
-	{
-		.compatible = "ti,tcan4x5x",
-	}, {
-		/* sentinel */
-	},
+	{ .compatible = "ti,tcan4x5x", .data = &tcan4x5x_generic },
+	{ .compatible = "ti,tcan4552", .data = &tcan4x5x_tcan4552 },
+	{ .compatible = "ti,tcan4553", .data = &tcan4x5x_tcan4553 },
+	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, tcan4x5x_of_match);
 
 static const struct spi_device_id tcan4x5x_id_table[] = {
-	{

drivers/net/can/m_can/tcan4x5x-core.c static void tcan4x5x_can_remove(struct spi_device *spi) · line 478

Quoted 10 lines
drivers/net/can/m_can/tcan4x5x-core.c +4 -4
-		.name = "tcan4x5x",
-	}, {
-		/* sentinel */
-	},
+	{ .name = "tcan4x5x", .driver_data = (unsigned long) &tcan4x5x_generic, },
+	{ .name = "tcan4552", .driver_data = (unsigned long) &tcan4x5x_tcan4552, },
+	{ .name = "tcan4553", .driver_data = (unsigned long) &tcan4x5x_tcan4553, },
+	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(spi, tcan4x5x_id_table);

Thanks,
Michal

Quoted 4 lines
Signature · 2 lines
-- 
2.39.2
Reviewed-by on the v1 series
#18 lore raw
In reply to Markus Schneider-Pargmann
Quoted 23 lines · Markus Schneider-Pargmann

Hi Marc and everyone,

This series introduces two new chips tcan-4552 and tcan-4553. The generic driver works in general but needs a few small changes. These are caused by the removal of wake and state pins.

I included two patches from the optimization series and will remove them from the optimization series. Hopefully it avoids conflicts and not polute the other series with tcan4552/4553 stuff.

Best,
Markus

optimization series:
https://lore.kernel.org/lkml/[email protected]

Markus Schneider-Pargmann (5):
dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants
can: tcan4x5x: Remove reserved register 0x814 from writable table
can: tcan4x5x: Check size of mram configuration
can: tcan4x5x: Rename ID registers to match datasheet
can: tcan4x5x: Add support for tcan4552/4553

Quoted 7 lines
 .../devicetree/bindings/net/can/tcan4x5x.txt  |  11 +-
 drivers/net/can/m_can/m_can.c                 |  16 +++
 drivers/net/can/m_can/m_can.h                 |   1 +
 drivers/net/can/m_can/tcan4x5x-core.c         | 122 ++++++++++++++----
 drivers/net/can/m_can/tcan4x5x-regmap.c       |   1 -
 5 files changed, 121 insertions(+), 30 deletions(-)

The logic and coding style looks OK to me, but CAN-specific stuff should be reviewed by someone else.
Just one nitpick in the last patch.

Thanks,
Michal

For entire series:

Quoted 3 lines
Signature · 1 line
2.39.2
Acked-by on v1 1/5
#3 lore raw

Re: [PATCH 1/5] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants

In reply to Markus Schneider-Pargmann
Quoted 12 lines · Markus Schneider-Pargmann

These two new chips do not have state or wake pins.

---
 .../devicetree/bindings/net/can/tcan4x5x.txt          | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +0 -0
index e3501bfa22e9..38a2b5369b44 100644

Documentation/devicetree/bindings/net/can/tcan4x5x.txt Texas Instruments TCAN4x5x CAN Controller · line 10

Quoted 8 lines
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +4 -1
@@ -4,7 +4,10 @@ Texas Instruments TCAN4x5x CAN Controller
 This file provides device node information for the TCAN4x5x interface contains.
 
 Required properties:
-	- compatible: "ti,tcan4x5x"
+	- compatible:
+		"ti,tcan4x5x" or
+		"ti,tcan4552" or
+		"ti,tcan4553"

Awesome, they nicely fit into wildcard... Would be useful to deprecate the wildcard at some point and switch to proper compatibles in such case, because now they became confusing.

Anyway:

Best regards,
Krzysztof

author maintainer
#16 lore raw

Re: [PATCH 5/5] can: tcan4x5x: Add support for tcan4552/4553

In reply to Simon Horman

Hi Simon,

Quoted 7 lines · Simon Horman
Quoted 6 lines · Markus Schneider-Pargmann

tcan4552 and tcan4553 do not have wake or state pins, so they are currently not compatible with the generic driver. The generic driver uses tcan4x5x_disable_state() and tcan4x5x_disable_wake() if the gpios are not defined. These functions use register bits that are not available in tcan4552/4553.

Quoted 8 lines
Quoted 4 lines

This patch adds support by introducing version information to reflect if the chip has wake and state pins. Also the version is now checked.

Signed-off-by Markus Schneider-Pargmann

Hi Markus,

you forgot your email address in the signed-off-by line.

Thank you, I am wondering how I managed to do that :D.

Quoted 26 lines
Quoted 9 lines
---
 drivers/net/can/m_can/tcan4x5x-core.c | 113 ++++++++++++++++++++------
 1 file changed, 89 insertions(+), 24 deletions(-)
drivers/net/can/m_can/tcan4x5x-core.c +0 -0
index fb9375fa20ec..e7fa509dacc9 100644

...

drivers/net/can/m_can/tcan4x5x-core.c static int tcan4x5x_disable_state(struct m_can_classdev *cdev) · line 267

Quoted 8 lines
drivers/net/can/m_can/tcan4x5x-core.c +3 -1
@@ -254,18 +262,53 @@ static int tcan4x5x_disable_state(struct m_can_classdev *cdev)
 				  TCAN4X5X_DISABLE_INH_MSK, 0x01);
 }
 
-static int tcan4x5x_get_gpios(struct m_can_classdev *cdev)
+static int tcan4x5x_verify_version(
+		struct tcan4x5x_priv *priv,
+		const struct tcan4x5x_version_info *version_info)

nit:

static int
tcan4x5x_verify_version(struct tcan4x5x_priv *priv, const struct tcan4x5x_version_info *version_info)

Quoted 6 lines

or:

static int tcan4x5x_verify_version(struct tcan4x5x_priv *priv, const struct tcan4x5x_version_info *version_info)

Your could make the line shorter by renaming the 'version_info' parameter, say to 'info'.

Thanks, fixed. I would like to keep version_info as it is used like that everywhere else. I think/hope breaking the 80c here is fine.

Quoted 33 lines

...

Quoted 30 lines
drivers/net/can/m_can/tcan4x5x-core.c +17 -5
@@ -394,21 +448,32 @@ static void tcan4x5x_can_remove(struct spi_device *spi)
 	m_can_class_free_dev(priv->cdev.net);
 }
 
+static const struct tcan4x5x_version_info tcan4x5x_generic = {
+	.has_state_pin = true,
+	.has_wake_pin = true,
+};
+
+static const struct tcan4x5x_version_info tcan4x5x_tcan4552 = {
+	.id2_register = 0x32353534, /* ASCII = 4552 */
+};
+
+static const struct tcan4x5x_version_info tcan4x5x_tcan4553 = {
+	.id2_register = 0x33353534, /* ASCII = 4553 */
+};
+
 static const struct of_device_id tcan4x5x_of_match[] = {
-	{
-		.compatible = "ti,tcan4x5x",
-	}, {
-		/* sentinel */
-	},
+	{ .compatible = "ti,tcan4x5x", .data = &tcan4x5x_generic },
+	{ .compatible = "ti,tcan4552", .data = &tcan4x5x_tcan4552 },
+	{ .compatible = "ti,tcan4553", .data = &tcan4x5x_tcan4553 },
+	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, tcan4x5x_of_match);
 
Quoted 11 lines

drivers/net/can/m_can/tcan4x5x-core.c static void tcan4x5x_can_remove(struct spi_device *spi) · line 475

Quoted 9 lines
drivers/net/can/m_can/tcan4x5x-core.c +3 -5
 static const struct spi_device_id tcan4x5x_id_table[] = {
-	{
-		.name = "tcan4x5x",
-	}, {
-		/* sentinel */
-	},
+	{ .name = "tcan4x5x", .driver_data = (unsigned long) &tcan4x5x_generic, },
+	{ .name = "tcan4552", .driver_data = (unsigned long) &tcan4x5x_tcan4552, },
+	{ .name = "tcan4553", .driver_data = (unsigned long) &tcan4x5x_tcan4553, },

nit: checkpatch tells me that no space is necessary after a cast.

Fixed as well.

Thanks for reviewing.

Best,
Markus

author maintainer
#19 lore raw
In reply to Michal Kubiak

Hi Michal,

Quoted 36 lines · Michal Kubiak
Quoted 23 lines · Markus Schneider-Pargmann

Hi Marc and everyone,

This series introduces two new chips tcan-4552 and tcan-4553. The generic driver works in general but needs a few small changes. These are caused by the removal of wake and state pins.

I included two patches from the optimization series and will remove them from the optimization series. Hopefully it avoids conflicts and not polute the other series with tcan4552/4553 stuff.

Best,
Markus

optimization series:
https://lore.kernel.org/lkml/[email protected]

Markus Schneider-Pargmann (5):
dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants
can: tcan4x5x: Remove reserved register 0x814 from writable table
can: tcan4x5x: Check size of mram configuration
can: tcan4x5x: Rename ID registers to match datasheet
can: tcan4x5x: Add support for tcan4552/4553

Quoted 7 lines
 .../devicetree/bindings/net/can/tcan4x5x.txt  |  11 +-
 drivers/net/can/m_can/m_can.c                 |  16 +++
 drivers/net/can/m_can/m_can.h                 |   1 +
 drivers/net/can/m_can/tcan4x5x-core.c         | 122 ++++++++++++++----
 drivers/net/can/m_can/tcan4x5x-regmap.c       |   1 -
 5 files changed, 121 insertions(+), 30 deletions(-)

The logic and coding style looks OK to me, but CAN-specific stuff should be reviewed by someone else.
Just one nitpick in the last patch.

Quoted 5 lines

Thanks,
Michal

For entire series:

Thanks for your review, I fixed the nitpick.

Best,
Markus

author maintainer
#4 lore raw

Re: [PATCH 1/5] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants

In reply to Krzysztof Kozlowski

Hi Krzysztof,

Quoted 26 lines · Krzysztof Kozlowski
Quoted 12 lines · Markus Schneider-Pargmann

These two new chips do not have state or wake pins.

---
 .../devicetree/bindings/net/can/tcan4x5x.txt          | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +0 -0
index e3501bfa22e9..38a2b5369b44 100644

Documentation/devicetree/bindings/net/can/tcan4x5x.txt Texas Instruments TCAN4x5x CAN Controller · line 10

Quoted 8 lines
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +4 -1
@@ -4,7 +4,10 @@ Texas Instruments TCAN4x5x CAN Controller
 This file provides device node information for the TCAN4x5x interface contains.
 
 Required properties:
-	- compatible: "ti,tcan4x5x"
+	- compatible:
+		"ti,tcan4x5x" or
+		"ti,tcan4552" or
+		"ti,tcan4553"

Awesome, they nicely fit into wildcard... Would be useful to deprecate the wildcard at some point and switch to proper compatibles in such case, because now they became confusing.

Quoted 3 lines

Anyway:

Thank you. Indeed the old generic name could be replaced, unfortunately I don't have a list of devices that this generic wildcard matches.

Best,
Markus

#6 lore raw

Re: [PATCH 1/5] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants

In reply to Krzysztof Kozlowski
Quoted 15 lines · Krzysztof Kozlowski
Quoted 14 lines · Markus Schneider-Pargmann

These two new chips do not have state or wake pins.

---
 .../devicetree/bindings/net/can/tcan4x5x.txt          | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +0 -0
index e3501bfa22e9..38a2b5369b44 100644
@@ -4,7 +4,10 @@ Texas Instruments TCAN4x5x CAN Controller
 This file provides device node information for the TCAN4x5x interface contains.
 
Quoted 10 lines

Documentation/devicetree/bindings/net/can/tcan4x5x.txt Texas Instruments TCAN4x5x CAN Controller · line 10

Quoted 6 lines
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +4 -1
 Required properties:
-	- compatible: "ti,tcan4x5x"
+	- compatible:
+		"ti,tcan4x5x" or
+		"ti,tcan4552" or
+		"ti,tcan4553"

Awesome, they nicely fit into wildcard... Would be useful to deprecate the wildcard at some point and switch to proper compatibles in such case, because now they became confusing.

I plead for DT stability!

As I understand correctly, the exact version of the chip (4550, 4552, or 4553) can be detected via the ID2 register.

regards,
Marc

Signature · 3 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#5 lore raw

Re: [PATCH 1/5] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants

In reply to Markus Schneider-Pargmann
Quoted 29 lines · Markus Schneider-Pargmann

Hi Krzysztof,

Quoted 26 lines · Krzysztof Kozlowski
Quoted 12 lines · Markus Schneider-Pargmann

These two new chips do not have state or wake pins.

---
 .../devicetree/bindings/net/can/tcan4x5x.txt          | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +0 -0
index e3501bfa22e9..38a2b5369b44 100644

Documentation/devicetree/bindings/net/can/tcan4x5x.txt Texas Instruments TCAN4x5x CAN Controller · line 10

Quoted 8 lines
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +4 -1
@@ -4,7 +4,10 @@ Texas Instruments TCAN4x5x CAN Controller
 This file provides device node information for the TCAN4x5x interface contains.
 
 Required properties:
-	- compatible: "ti,tcan4x5x"
+	- compatible:
+		"ti,tcan4x5x" or
+		"ti,tcan4552" or
+		"ti,tcan4553"

Awesome, they nicely fit into wildcard... Would be useful to deprecate the wildcard at some point and switch to proper compatibles in such case, because now they became confusing.

Quoted 6 lines
Quoted 3 lines

Anyway:

Thank you. Indeed the old generic name could be replaced, unfortunately I don't have a list of devices that this generic wildcard matches.

The mcp251xfd driver supports "microchip,mcp2517fd", "microchip,mcp2518fd", "microchip,mcp251863", and "microchip,mcp251xfd". It always does auto detection and throws a warning if the found chip is not consistent with the firmware (DT, ACPI).

Marc

Signature · 3 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#7 lore raw

Re: [PATCH 1/5] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants

In reply to Marc Kleine-Budde
Quoted 27 lines · Marc Kleine-Budde
Quoted 15 lines · Krzysztof Kozlowski
Quoted 14 lines · Markus Schneider-Pargmann

These two new chips do not have state or wake pins.

---
 .../devicetree/bindings/net/can/tcan4x5x.txt          | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +0 -0
index e3501bfa22e9..38a2b5369b44 100644
@@ -4,7 +4,10 @@ Texas Instruments TCAN4x5x CAN Controller
 This file provides device node information for the TCAN4x5x interface contains.
 
Quoted 10 lines

Documentation/devicetree/bindings/net/can/tcan4x5x.txt Texas Instruments TCAN4x5x CAN Controller · line 10

Quoted 6 lines
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +4 -1
 Required properties:
-	- compatible: "ti,tcan4x5x"
+	- compatible:
+		"ti,tcan4x5x" or
+		"ti,tcan4552" or
+		"ti,tcan4553"

Awesome, they nicely fit into wildcard... Would be useful to deprecate the wildcard at some point and switch to proper compatibles in such case, because now they became confusing.

Quoted 4 lines

I plead for DT stability!

As I understand correctly, the exact version of the chip (4550, 4552, or 4553) can be detected via the ID2 register.

So maybe there is no need for this patch at all? Or the new compatibles should be made compatible with generic fallback?

Best regards,
Krzysztof

author maintainer
#8 lore raw

Re: [PATCH 1/5] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants

Quoted 28 lines · Krzysztof Kozlowski
Quoted 27 lines · Marc Kleine-Budde
Quoted 25 lines · Krzysztof Kozlowski
Quoted 12 lines · Markus Schneider-Pargmann

These two new chips do not have state or wake pins.

---
 .../devicetree/bindings/net/can/tcan4x5x.txt          | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +0 -0
index e3501bfa22e9..38a2b5369b44 100644

Documentation/devicetree/bindings/net/can/tcan4x5x.txt Texas Instruments TCAN4x5x CAN Controller · line 10

Quoted 8 lines
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +4 -1
@@ -4,7 +4,10 @@ Texas Instruments TCAN4x5x CAN Controller
 This file provides device node information for the TCAN4x5x interface contains.
 
 Required properties:
-	- compatible: "ti,tcan4x5x"
+	- compatible:
+		"ti,tcan4x5x" or
+		"ti,tcan4552" or
+		"ti,tcan4553"

Awesome, they nicely fit into wildcard... Would be useful to deprecate the wildcard at some point and switch to proper compatibles in such case, because now they became confusing.

Quoted 7 lines
Quoted 4 lines

I plead for DT stability!

As I understand correctly, the exact version of the chip (4550, 4552, or 4553) can be detected via the ID2 register.

So maybe there is no need for this patch at all? Or the new compatibles should be made compatible with generic fallback?

I can use the value being read from the ID2 register to get the version. This at least holds the correct value for tcan4550, 4552 and 4553. But the state and wake gpios can't be used in case of a 4552 or 4553.

So yes, it is possible to do it without the new compatibles but the changes for state and wake gpios need to stay.

What do you two prefer?

Best,
Markus

#9 lore raw

Re: [PATCH 1/5] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants

Quoted 37 lines · Markus Schneider-Pargmann
Quoted 28 lines · Krzysztof Kozlowski
Quoted 27 lines · Marc Kleine-Budde
Quoted 25 lines · Krzysztof Kozlowski
Quoted 12 lines · Markus Schneider-Pargmann

These two new chips do not have state or wake pins.

---
 .../devicetree/bindings/net/can/tcan4x5x.txt          | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +0 -0
index e3501bfa22e9..38a2b5369b44 100644

Documentation/devicetree/bindings/net/can/tcan4x5x.txt Texas Instruments TCAN4x5x CAN Controller · line 10

Quoted 8 lines
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +4 -1
@@ -4,7 +4,10 @@ Texas Instruments TCAN4x5x CAN Controller
 This file provides device node information for the TCAN4x5x interface contains.
 
 Required properties:
-	- compatible: "ti,tcan4x5x"
+	- compatible:
+		"ti,tcan4x5x" or
+		"ti,tcan4552" or
+		"ti,tcan4553"

Awesome, they nicely fit into wildcard... Would be useful to deprecate the wildcard at some point and switch to proper compatibles in such case, because now they became confusing.

Quoted 7 lines
Quoted 4 lines

I plead for DT stability!

As I understand correctly, the exact version of the chip (4550, 4552, or 4553) can be detected via the ID2 register.

So maybe there is no need for this patch at all? Or the new compatibles should be made compatible with generic fallback?

Quoted 8 lines

I can use the value being read from the ID2 register to get the version. This at least holds the correct value for tcan4550, 4552 and 4553. But the state and wake gpios can't be used in case of a 4552 or 4553.

So yes, it is possible to do it without the new compatibles but the changes for state and wake gpios need to stay.

What do you two prefer?

FWIIW, I think it is good to have the extra compat strings, even if the driver only uses the fallback string for now. This would allow the driver to take into account HW differences that come to light later, without needing to update the bindings.

#10 lore raw

Re: [PATCH 1/5] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants

In reply to Markus Schneider-Pargmann
Quoted 37 lines · Markus Schneider-Pargmann
Quoted 28 lines · Krzysztof Kozlowski
Quoted 27 lines · Marc Kleine-Budde
Quoted 25 lines · Krzysztof Kozlowski
Quoted 12 lines · Markus Schneider-Pargmann

These two new chips do not have state or wake pins.

---
 .../devicetree/bindings/net/can/tcan4x5x.txt          | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +0 -0
index e3501bfa22e9..38a2b5369b44 100644

Documentation/devicetree/bindings/net/can/tcan4x5x.txt Texas Instruments TCAN4x5x CAN Controller · line 10

Quoted 8 lines
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +4 -1
@@ -4,7 +4,10 @@ Texas Instruments TCAN4x5x CAN Controller
 This file provides device node information for the TCAN4x5x interface contains.
 
 Required properties:
-	- compatible: "ti,tcan4x5x"
+	- compatible:
+		"ti,tcan4x5x" or
+		"ti,tcan4552" or
+		"ti,tcan4553"

Awesome, they nicely fit into wildcard... Would be useful to deprecate the wildcard at some point and switch to proper compatibles in such case, because now they became confusing.

Quoted 7 lines
Quoted 4 lines

I plead for DT stability!

As I understand correctly, the exact version of the chip (4550, 4552, or 4553) can be detected via the ID2 register.

So maybe there is no need for this patch at all? Or the new compatibles should be made compatible with generic fallback?

Quoted 8 lines

I can use the value being read from the ID2 register to get the version. This at least holds the correct value for tcan4550, 4552 and 4553. But the state and wake gpios can't be used in case of a 4552 or 4553.

So yes, it is possible to do it without the new compatibles but the changes for state and wake gpios need to stay.

What do you two prefer?

Then specific with generic fallback compatibles, although for driver it still won't matter as you need to customize driver_data anyway.

Best regards,
Krzysztof