1
0
Fork 0
Commit Graph

12 Commits (79d8d171be56279b6a3697206ed5f8a5d21a510a)

Author SHA1 Message Date
Marc Kleine-Budde 69851481b3 can: tcan4x5x: tcan4x5x_can_remove(): fix order of deregistration
[ Upstream commit c81d0b6ca6 ]

Change the order in tcan4x5x_can_remove() to be the exact inverse of
tcan4x5x_can_probe(). First m_can_class_unregister(), then power down the
device.

Fixes: 5443c226ba ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
Cc: Dan Murphy <dmurphy@ti.com>
Link: http://lore.kernel.org/r/20201019154233.1262589-10-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-11-24 13:29:07 +01:00
Marc Kleine-Budde d527bb8bd5 can: tcan4x5x: tcan4x5x_can_probe(): add missing error checking for devm_regmap_init()
[ Upstream commit 1ff203badb ]

This patch adds the missing error checking when initializing the regmap
interface fails.

Fixes: 5443c226ba ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
Cc: Dan Murphy <dmurphy@ti.com>
Link: http://lore.kernel.org/r/20201019154233.1262589-7-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-11-24 13:29:06 +01:00
Sean Nyekjaer db10c64764 can: tcan4x5x: tcan4x5x_parse_config(): reset device before register access
[ Upstream commit c3083124e6 ]

It's a good idea to reset a ip-block/spi device before using it, this
patch will reset the device.

And a generic reset function if needed elsewhere.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-02-01 09:34:44 +00:00
Sean Nyekjaer 1ad3ee211d can: tcan4x5x: tcan4x5x_can_probe(): get the device out of standby before register access
commit 3069ce620d upstream.

The m_can tries to detect if Non ISO Operation is available while in
standby mode, this function results in the following error:

| tcan4x5x spi2.0 (unnamed net_device) (uninitialized): Failed to init module
| tcan4x5x spi2.0: m_can device registered (irq=84, version=32)
| tcan4x5x spi2.0 can2: TCAN4X5X successfully initialized.

When the tcan device comes out of reset it goes in standby mode. The
m_can driver tries to access the control register but fails due to the
device being in standby mode.

So this patch will put the tcan device in normal mode before the m_can
driver does the initialization.

Fixes: 5443c226ba ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
Cc: stable@vger.kernel.org
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Acked-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-14 20:08:27 +01:00
Sean Nyekjaer d7f6a5729a can: m_can: tcan4x5x: add required delay after reset
commit 60552253e2 upstream.

According to section "8.3.8 RST Pin" in the datasheet we are required to
wait >700us after the device is reset.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Acked-by: Dan Murphy <dmurphy@ti.com>
Cc: linux-stable <stable@vger.kernel.org> # >= v5.4
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-12-31 16:45:56 +01:00
Dan Murphy 81f29dd304 can: tcan4x5x: Remove checking the wake pin
Remove checking the wake pin for every read/write call.
The device is not explicitly put to sleep in the code
and the POR interrupt is cleared during the init of
the device.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-09-03 10:23:57 +02:00
Dan Murphy be1d28424a can: tcan4x5x: Remove data-ready gpio interrupt
Remove the data-ready gpio interrupt handling and use the spi->irq
that is created based on the interrupt DT property.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-09-03 10:23:57 +02:00
Marc Kleine-Budde 6093f744fe can: tcan4x5x: fix data length in regmap write path
In regmap_spi_gather_write() the "addr" is prepared. The chip expects
the number of 32 bit words to write in the lower 8 bits of addr. However
the number of byte to write in shifted left by 3 (== divided by 8).

The function tcan4x5x_regmap_write() is called with a data buffer, which
holds the register information in the first 32 bits, followed by the
actual data. tcan4x5x_regmap_write() calls regmap_spi_gather_write()
with the val pointer pointing to the actual data (i.e. the original
pointer is incremented by 4 bytes), but without decrementing the count.

If the regmap framework only calls tcan4x5x_regmap_write() to read
single 32 bit registers these two bugs cancel each other.

This patch fixes the code.

Fixes: 5443c226ba ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-08-20 13:41:26 +02:00
Marc Kleine-Budde 7fbda13065 can: tcan4x5x: tcan4x5x_can_probe(): add missing error handling if mcan_class is NULL
This patch adds the missing error handling in tcan4x5x_can_probe() if
mcan_class is NULL.

Fixes: 5443c226ba ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-08-20 13:41:26 +02:00
Marc Kleine-Budde ad07819f22 can: tcan4x5x: remove not needed casts to struct tcan4x5x_priv *
The struct m_can_classdev::device_data is a void pointer, so there's no
need to cast it to struct tcan4x5x_priv *, when assigning the struct
tcan4x5x_priv pointer.

This patch removes the not needed casts from the tcan4x5x driver.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-08-20 13:41:25 +02:00
Marc Kleine-Budde 65668b3269 can: tcan4x5x: remove unused struct tcan4x5x_priv::tcan4x5x_lock
The mutex struct tcan4x5x_priv::tcan4x5x_lock is unused in the driver,
so this patch removes the variable from the driver.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-08-20 13:41:25 +02:00
Dan Murphy 5443c226ba can: tcan4x5x: Add tcan4x5x driver to the kernel
Add the TCAN4x5x SPI CAN driver.

This device uses the Bosch MCAN IP core along with a SPI interface map.
Register to the MCAN common core code to manage the MCAN IP.

This device has a special method to indicate a write/read operation on
the data payload.

Acked-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-07-24 10:31:54 +02:00