Hi 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.
In v2 I updated the bindings to use tcan4x5x always as a fallback. The
driver now uses the first more specific binding if available. If the
given binding does not match the chip that is present, a warning is
printed and the correct driver data is loaded instead.
Based on v6.4-rc1.
Best,
Markus
Changes in v2:
- Update the binding documentation to specify tcan4552 and tcan4553 with
the tcan4x5x as fallback
- Update the driver to use auto detection as well. If compatible differs
from the ID2 register, use the ID2 register and print a warning.
- Small style changes
Previous versions:
v1 - https://lore.kernel.org/lkml/[email protected]
Markus Schneider-Pargmann (6):
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
can: tcan4x5x: Add error messages in probe
.../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 | 161 ++++++++++++++----
drivers/net/can/m_can/tcan4x5x-regmap.c | 1 -
5 files changed, 155 insertions(+), 35 deletions(-)
base-commit: ac9a78681b921877518763ba0e89202254349d1b
--
2.40.1
To be able to understand issues during probe easier, add error messages
if something fails.
Signed-off-by: Markus Schneider-Pargmann <[email protected]>
---
drivers/net/can/m_can/tcan4x5x-core.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
index 756acd122075..e30faa1cf893 100644
--- a/drivers/net/can/m_can/tcan4x5x-core.c
+++ b/drivers/net/can/m_can/tcan4x5x-core.c
@@ -397,6 +397,8 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
/* Sanity check */
if (freq < 20000000 || freq > TCAN4X5X_EXT_CLK_DEF) {
+ dev_err(&spi->dev, "Clock frequency is out of supported range %d\n",
+ freq);
ret = -ERANGE;
goto out_m_can_class_free_dev;
}
@@ -415,32 +417,44 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
/* Configure the SPI bus */
spi->bits_per_word = 8;
ret = spi_setup(spi);
- if (ret)
+ if (ret) {
+ dev_err(&spi->dev, "SPI setup failed %d\n", ret);
goto out_m_can_class_free_dev;
+ }
ret = tcan4x5x_regmap_init(priv);
- if (ret)
+ if (ret) {
+ dev_err(&spi->dev, "regmap init failed %d\n", ret);
goto out_m_can_class_free_dev;
+ }
ret = tcan4x5x_power_enable(priv->power, 1);
- if (ret)
+ if (ret) {
+ dev_err(&spi->dev, "Enabling regulator failed %d\n", ret);
goto out_m_can_class_free_dev;
+ }
ret = tcan4x5x_verify_version(priv, &version_info);
if (ret)
goto out_power;
ret = tcan4x5x_get_gpios(mcan_class, version_info);
- if (ret)
+ if (ret) {
+ dev_err(&spi->dev, "Getting gpios failed %d\n", ret);
goto out_power;
+ }
ret = tcan4x5x_init(mcan_class);
- if (ret)
+ if (ret) {
+ dev_err(&spi->dev, "tcan initialization failed %d\n", ret);
goto out_power;
+ }
ret = m_can_class_register(mcan_class);
- if (ret)
+ if (ret) {
+ dev_err(&spi->dev, "Failed registering m_can device %d\n", ret);
goto out_power;
+ }
netdev_info(mcan_class->net, "TCAN4X5X successfully initialized.\n");
return 0;
--
2.40.1
The mentioned register is not writable. It is reserved and should not be
written.
Fixes: 39dbb21b6a29 ("can: tcan4x5x: Specify separate read/write ranges")
Signed-off-by: Markus Schneider-Pargmann <[email protected]>
Reviewed-by: Michal Kubiak <[email protected]>
---
drivers/net/can/m_can/tcan4x5x-regmap.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/can/m_can/tcan4x5x-regmap.c b/drivers/net/can/m_can/tcan4x5x-regmap.c
index 2b218ce04e9f..fafa6daa67e6 100644
--- a/drivers/net/can/m_can/tcan4x5x-regmap.c
+++ b/drivers/net/can/m_can/tcan4x5x-regmap.c
@@ -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 */
--
2.40.1