: can-next 2020-09-30 - mcp25xxfd/mcp251xfd and flexcan
Marc Kleine-Budde
maintainerHello,
this series consists of mcp25xxfd/mcp251xfd and flexcan patches.
First some problems found during review were fixed. During this Geert pointed out that the autodetect compatible "mcp25xxfd" might be to generic. This was changed to "mcp251xfd" and the driver was renamed accordingly.
I'll send out a pull request today.
regards,
Marc
Marc Kleine-Budde
maintainerPATCH 1/12 can: mcp25xxfd: mcp25xxfd_handle_eccif(): add ECC related errata and update log messages
From: Thomas Kopp <[email protected]>
This patch adds a reference to the recent released MCP2517FD and MCP2518FD errata sheets and paste the explanation.
The single error correction does not always work, so always indicate that a single error occurred. If the location of the ECC error is outside of the TX-RAM always use netdev_notice() to log the problem. For ECC errors in the TX-RAM, there is a recovery procedure.
--- .../net/can/spi/mcp25xxfd/mcp25xxfd-core.c | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c +14 -7
@@ -1973,8 +1973,20 @@ mcp25xxfd_handle_eccif(struct mcp25xxfd_priv *priv, bool set_normal_mode)else return err; +/* Errata Reference: +* mcp2517fd: DS80000789B, mcp2518fd: DS80000792C 2. +* +* ECC single error correction does not work in all cases: +* +* Fix/Work Around: +* Enable single error correction and double error detection +* interrupts by setting SECIE and DEDIE. Handle SECIF as a +* detection interrupt and do not rely on the error +* correction. Instead, handle both interrupts as a +* notification that the RAM word at ERRADDR was corrupted. +*/ if (ecc_stat &MCP25XXFD_REG_ECCSTAT_SECIF ) - msg ="Single ECC Error corrected at address" ; + msg ="Single ECC Error detected at address" ;else if (ecc_stat &MCP25XXFD_REG_ECCSTAT_DEDIF ) msg ="Double ECC Error detected at address" ;else
@@ -1983,12 +1995,7 @@ mcp25xxfd_handle_eccif(struct mcp25xxfd_priv *priv, bool set_normal_mode)if (!in_tx_ram) { ecc->ecc_stat =0 ; -if (ecc_stat &MCP25XXFD_REG_ECCSTAT_SECIF ) -netdev_info (priv->ndev,"%s 0x%04x.\n" , - msg, addr); -else -netdev_notice (priv->ndev,"%s 0x%04x.\n" , - msg, addr); +netdev_notice (priv->ndev,"%s 0x%04x.\n" , msg, addr); }else {/* Re-occurring error? */ if (ecc->ecc_stat == ecc_stat) {
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 2/12 can: mcp25xxfd: mcp25xxfd_probe(): add SPI clk limit related errata information
In reply to Marc Kleine-BuddeFrom: Thomas Kopp <[email protected]>
This patch adds a reference to the recent released MCP2517FD and MCP2518FD errata sheets and paste the explanation.
The driver already implements the proposed fix.
--- .../net/can/spi/mcp25xxfd/mcp25xxfd-core.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c +14 -5
@@ -2819,11 +2819,21 @@ static int mcp25xxfd_probe(struct spi_device *spi) priv->devtype_data = *(struct mcp25xxfd_devtype_data *)spi_get_device_id (spi)->driver_data; -/* According to the datasheet the SPI clock must be less or -* equal SYSCLOCK / 2. +/* Errata Reference: +* mcp2517fd: DS80000789B, mcp2518fd: DS80000792C 4. +* +* The SPI can write corrupted data to the RAM at fast SPI +* speeds: +* +* Simultaneous activity on the CAN bus while writing data to +* RAM via the SPI interface, with high SCK frequency, can +* lead to corrupted data being written to RAM. +* +* Fix/Work Around: +* Ensure that FSCK is less than or equal to 0.85 * +* (FSYSCLK/2). * -* It turns out, that the Controller is not stable at this -* rate. Known good and bad combinations are: +* Known good and bad combinations are: * * MCP ext-clk SoC SPI SPI-clk max-clk parent-clk Status config *
@@ -2836,7 +2846,6 @@ static int mcp25xxfd_probe(struct spi_device *spi)* 2517 40 MHz atmel,sama5d27 atmel,at91rm9200-spi 16400000 Hz 82.00% 82000000 Hz good default * 2518 40 MHz atmel,sama5d27 atmel,at91rm9200-spi 16400000 Hz 82.00% 82000000 Hz good default * -* Limit SPI clock to 85% of SYSCLOCK / 2 for now. */ priv->spi_max_speed_hz_orig = spi->max_speed_hz; spi->max_speed_hz =min (spi->max_speed_hz, freq /2 /1000 *850 );
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 3/12 can: mcp25xxfd: mcp25xxfd_ring_free(): fix memory leak during cleanup
In reply to Marc Kleine-BuddeFrom: Dan Carpenter <[email protected]>
This loop doesn't free the first element of the array. The "i > 0" has to be changed to "i >= 0".
--- drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c +1 -1
@@ -377,7 +377,7 @@ static void mcp25xxfd_ring_free(struct mcp25xxfd_priv *priv) {int i; -for (i =ARRAY_SIZE (priv->rx) -1 ; i >0 ; i--) { +for (i =ARRAY_SIZE (priv->rx) -1 ; i >=0 ; i--) {kfree (priv->rx[i]); priv->rx[i] =NULL ; }
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 4/12 can: mcp25xxfd: mcp25xxfd_irq(): add missing initialization of variable set_normal mode
In reply to Marc Kleine-BuddeThis patch fixes the following warning:
drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c:2155 mcp25xxfd_irq()
error: uninitialized symbol 'set_normal_mode'.
by adding the missing initialization.
--- drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c +1 -1
@@ -2080,7 +2080,7 @@ static irqreturn_t mcp25xxfd_irq(int irq, void *dev_id) do { u32 intf_pending, intf_pending_clearable; - bool set_normal_mode; + bool set_normal_mode = false; err = regmap_bulk_read(priv->map_reg, MCP25XXFD_REG_INT, &priv->regs_status,
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 5/12 dt-binding: can: mcp25xxfd: documentation fixes
In reply to Marc Kleine-BuddeFrom: Oleksij Rempel <[email protected]>
Apply following fixes:
- Use 'interrupts'. (interrupts-extended will automagically be supported by the tools)
- *-supply is always a single item. So, drop maxItems=1
- add "additionalProperties: false" flag to detect unneeded properties.
--- .../devicetree/bindings/net/can/microchip,mcp25xxfd.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/net/can/microchip,mcp25xxfd.yaml +4 -4
@@ -24,7 +24,7 @@ properties: reg: maxItems: 1 - interrupts-extended: + interrupts: maxItems: 1 clocks:
@@ -32,11 +32,9 @@ properties: vdd-supply: description: Regulator that powers the CAN controller. - maxItems: 1 xceiver-supply: description: Regulator that powers the CAN transceiver. - maxItems: 1 microchip,rx-int-gpios: description:
@@ -52,9 +50,11 @@ properties: required: - compatible - reg - - interrupts-extended + - interrupts - clocks +additionalProperties: false + examples: - | #include <dt-bindings/gpio/gpio.h>
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 6/12 dt-binding: can: mcp251xfd: rename autodetect compatible to "microchip,mcp251xfd"
In reply to Marc Kleine-BuddeIn [1] Geert noted that the autodetect compatible for the mcp25xxfd driver, which is "microchip,mcp25xxfd" might be too generic and overlap with upcoming, but incompatible chips.
As the driver is in net-next but not mainline yet, the risk of breaking DT compatibility is quite low, so this patch changes the compatible to "microchip,mcp251xfd" and renames the binding documentation accordingly.
[1] http://lore.kernel.org/r/CAMuHMdVkwGjr6dJuMyhQNqFoJqbh6Ec5V2b5LenCshwpM2SDsQ@mail.gmail.com
---
...{microchip,mcp25xxfd.yaml => microchip,mcp251xfd.yaml} | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
rename Documentation/devicetree/bindings/net/can/{microchip,mcp25xxfd.yaml => microchip,mcp251xfd.yaml} (91%)Documentation/devicetree/bindings/net/can/microchip,mcp251xfd.yaml renamed from Documentation/devicetree/bindings/net/can/microchip,mcp25xxfd.yaml +4 -4
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/net/can/microchip,mcp25xxfd.yaml# +$id: http://devicetree.org/schemas/net/can/microchip,mcp251xfd.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title:
@@ -18,7 +18,7 @@ properties: description: for MCP2517FD - const: microchip,mcp2518fd description: for MCP2518FD - - const: microchip,mcp25xxfd + - const: microchip,mcp251xfd description: to autodetect chip variant reg:
@@ -38,7 +38,7 @@ properties: microchip,rx-int-gpios: description: - GPIO phandle of GPIO connected to to INT1 pin of the MCP25XXFD, which + GPIO phandle of GPIO connected to to INT1 pin of the MCP251XFD, which signals a pending RX interrupt. maxItems: 1
@@ -65,7 +65,7 @@ examples: #size-cells = <0>; can@0 { - compatible = "microchip,mcp25xxfd"; + compatible = "microchip,mcp251xfd"; reg = <0>; clocks = <&can0_osc>; pinctrl-names = "default";
Signature · 1 line
2.28.0
Re: [PATCH 06/12] dt-binding: can: mcp251xfd: rename autodetect compatible to "microchip,mcp251xfd"
CC dt
Quoted 64 lines · Marc Kleine-Budde
In [1] Geert noted that the autodetect compatible for the mcp25xxfd driver, which is "microchip,mcp25xxfd" might be too generic and overlap with upcoming, but incompatible chips.
As the driver is in net-next but not mainline yet, the risk of breaking DT compatibility is quite low, so this patch changes the compatible to "microchip,mcp251xfd" and renames the binding documentation accordingly.
[1] http://lore.kernel.org/r/CAMuHMdVkwGjr6dJuMyhQNqFoJqbh6Ec5V2b5LenCshwpM2SDsQ@mail.gmail.com
Fixes 1b5a78e69c1f ("dt-binding: can: mcp25xxfd: document device tree bindings")Reported-by Geert Uytterhoeven <[email protected]>Signed-off-by Marc Kleine-Budde <[email protected]>--- ...{microchip,mcp25xxfd.yaml => microchip,mcp251xfd.yaml} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename Documentation/devicetree/bindings/net/can/{microchip,mcp25xxfd.yaml => microchip,mcp251xfd.yaml} (91%)Documentation/devicetree/bindings/net/can/microchip,mcp251xfd.yaml renamed from Documentation/devicetree/bindings/net/can/microchip,mcp25xxfd.yaml +4
-5@@ -1,7 +1,7 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/net/can/microchip,mcp25xxfd.yaml# +$id: http://devicetree.org/schemas/net/can/microchip,mcp251xfd.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title:@@ -18,7 +18,7 @@ properties: description: for MCP2517FD - const: microchip,mcp2518fd description: for MCP2518FD - - const: microchip,mcp25xxfd + - const: microchip,mcp251xfd description: to autodetect chip variant reg:@@ -38,7 +38,7 @@ properties: microchip,rx-int-gpios: description: - GPIO phandle of GPIO connected to to INT1 pin of the MCP25XXFD, which + GPIO phandle of GPIO connected to to INT1 pin of the MCP251XFD, which signals a pending RX interrupt. maxItems: 1@@ -65,7 +65,7 @@ examples: #size-cells = <0>; can@0 { - compatible = "microchip,mcp25xxfd"; + compatible = "microchip,mcp251xfd"; reg = <0>; clocks = <&can0_osc>; pinctrl-names = "default"; --2.28.0
Marc Kleine-Budde
maintainerPATCH 7/12 can: mcp251xfd: rename driver files and subdir to mcp251xfd
In reply to Marc Kleine-BuddeIn [1] Geert noted that the autodetect compatible for the mcp25xxfd driver, which is "microchip,mcp25xxfd" might be too generic and overlap with upcoming, but incompatible chips.
In the previous patch the autodetect DT compatbile has been renamed to "microchip,mcp251xfd", this patch changes the name of the driver subdir and the individual files accordinly.
[1] http://lore.kernel.org/r/CAMuHMdVkwGjr6dJuMyhQNqFoJqbh6Ec5V2b5LenCshwpM2SDsQ@mail.gmail.com
---
drivers/net/can/spi/Kconfig | 2 +-
drivers/net/can/spi/Makefile | 2 +-
drivers/net/can/spi/{mcp25xxfd => mcp251xfd}/Kconfig | 0
drivers/net/can/spi/mcp251xfd/Makefile | 8 ++++++++
.../mcp25xxfd-core.c => mcp251xfd/mcp251xfd-core.c} | 2 +-
.../mcp25xxfd-crc16.c => mcp251xfd/mcp251xfd-crc16.c} | 2 +-
.../mcp25xxfd-regmap.c => mcp251xfd/mcp251xfd-regmap.c} | 2 +-
.../spi/{mcp25xxfd/mcp25xxfd.h => mcp251xfd/mcp251xfd.h} | 0
drivers/net/can/spi/mcp25xxfd/Makefile | 8 --------
9 files changed, 13 insertions(+), 13 deletions(-)
rename drivers/net/can/spi/{mcp25xxfd => mcp251xfd}/Kconfig (100%)
create mode 100644 drivers/net/can/spi/mcp251xfd/Makefile
rename drivers/net/can/spi/{mcp25xxfd/mcp25xxfd-core.c => mcp251xfd/mcp251xfd-core.c} (99%)
rename drivers/net/can/spi/{mcp25xxfd/mcp25xxfd-crc16.c => mcp251xfd/mcp251xfd-crc16.c} (99%)
rename drivers/net/can/spi/{mcp25xxfd/mcp25xxfd-regmap.c => mcp251xfd/mcp251xfd-regmap.c} (99%)
rename drivers/net/can/spi/{mcp25xxfd/mcp25xxfd.h => mcp251xfd/mcp251xfd.h} (100%)
delete mode 100644 drivers/net/can/spi/mcp25xxfd/Makefiledrivers/net/can/spi/Kconfig +1 -1
@@ -13,6 +13,6 @@ config CAN_MCP251X Driver for the Microchip MCP251x and MCP25625 SPI CAN controllers. -source "drivers/net/can/spi/mcp25xxfd/Kconfig" +source "drivers/net/can/spi/mcp251xfd/Kconfig" endmenu
drivers/net/can/spi/Makefile +1 -1
@@ -6,4 +6,4 @@ obj-$(CONFIG_CAN_HI311X) += hi311x.o obj-$(CONFIG_CAN_MCP251X) += mcp251x.o -obj-y += mcp25xxfd/ +obj-y += mcp251xfd/
drivers/net/can/spi/mcp251xfd/Kconfig renamed from drivers/net/can/spi/mcp25xxfd/Kconfig +0 -0
drivers/net/can/spi/mcp251xfd/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_CAN_MCP25XXFD) += mcp25xxfd.o + +mcp25xxfd-objs := +mcp25xxfd-objs += mcp251xfd-core.o +mcp25xxfd-objs += mcp251xfd-crc16.o +mcp25xxfd-objs += mcp251xfd-regmap.o
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c renamed from drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c +1 -1
@@ -23,7 +23,7 @@#include <asm/unaligned.h> -#include "mcp25xxfd.h" +#include "mcp251xfd.h" #define DEVICE_NAME "mcp25xxfd"
drivers/net/can/spi/mcp251xfd/mcp251xfd-crc16.c renamed from drivers/net/can/spi/mcp25xxfd/mcp25xxfd-crc16.c +1 -1
@@ -12,7 +12,7 @@// Copyright (c) 2019 Martin Sperl <[email protected]> // -#include "mcp25xxfd.h" +#include "mcp251xfd.h" /* The standard crc16 in linux/crc16.h is unfortunately not computing * the correct results (left shift vs. right shift). So here an
drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c renamed from drivers/net/can/spi/mcp25xxfd/mcp25xxfd-regmap.c +1 -1
@@ -6,7 +6,7 @@// Marc Kleine-Budde <[email protected]> // -#include "mcp25xxfd.h" +#include "mcp251xfd.h" #include <asm/unaligned.h>
drivers/net/can/spi/mcp251xfd/mcp251xfd.h renamed from drivers/net/can/spi/mcp25xxfd/mcp25xxfd.h +0 -0
drivers/net/can/spi/mcp25xxfd/Makefile deleted +0 -8
@@ -1,8 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -obj-$(CONFIG_CAN_MCP25XXFD) += mcp25xxfd.o - -mcp25xxfd-objs := -mcp25xxfd-objs += mcp25xxfd-core.o -mcp25xxfd-objs += mcp25xxfd-crc16.o -mcp25xxfd-objs += mcp25xxfd-regmap.o
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 8/12 can: mcp251xfd: rename all user facing strings to mcp251xfd
In reply to Marc Kleine-BuddeIn [1] Geert noted that the autodetect compatible for the mcp25xxfd driver, which is "microchip,mcp25xxfd" might be too generic and overlap with upcoming, but incompatible chips.
In the previous patch the autodetect DT compatbile has been renamed to "microchip,mcp251xfd", this patch changes all user facing strings from "mcp25xxfd" to "mcp251xfd" and "MCP25XXFD" to "MCP251XFD", including:
- kconfig symbols
- name of kernel module
- DT and SPI compatible
[1] http://lore.kernel.org/r/CAMuHMdVkwGjr6dJuMyhQNqFoJqbh6Ec5V2b5LenCshwpM2SDsQ@mail.gmail.com
--- drivers/net/can/spi/mcp251xfd/Kconfig | 10 ++++----- drivers/net/can/spi/mcp251xfd/Makefile | 10 ++++----- .../net/can/spi/mcp251xfd/mcp251xfd-core.c | 22 +++++++++---------- drivers/net/can/spi/mcp251xfd/mcp251xfd.h | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-)
drivers/net/can/spi/mcp251xfd/Kconfig +5 -5
@@ -1,14 +1,14 @@ # SPDX-License-Identifier: GPL-2.0-only -config CAN_MCP25XXFD - tristate "Microchip MCP25xxFD SPI CAN controllers" +config CAN_MCP251XFD + tristate "Microchip MCP251xFD SPI CAN controllers" select REGMAP help - Driver for the Microchip MCP25XXFD SPI FD-CAN controller + Driver for the Microchip MCP251XFD SPI FD-CAN controller family. -config CAN_MCP25XXFD_SANITY - depends on CAN_MCP25XXFD +config CAN_MCP251XFD_SANITY + depends on CAN_MCP251XFD bool "Additional Sanity Checks" help This option enables additional sanity checks in the driver,
drivers/net/can/spi/mcp251xfd/Makefile +5 -5
@@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_CAN_MCP25XXFD) += mcp25xxfd.o +obj-$(CONFIG_CAN_MCP251XFD) += mcp251xfd.o -mcp25xxfd-objs := -mcp25xxfd-objs += mcp251xfd-core.o -mcp25xxfd-objs += mcp251xfd-crc16.o -mcp25xxfd-objs += mcp251xfd-regmap.o +mcp251xfd-objs := +mcp251xfd-objs += mcp251xfd-core.o +mcp251xfd-objs += mcp251xfd-crc16.o +mcp251xfd-objs += mcp251xfd-regmap.o
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +11 -11
@@ -25,7 +25,7 @@#include "mcp251xfd.h" -#define DEVICE_NAME "mcp25xxfd" +#define DEVICE_NAME "mcp251xfd"static const struct mcp25xxfd_devtype_data mcp25xxfd_devtype_data_mcp2517fd = { .quirks = MCP25XXFD_QUIRK_MAB_NO_WARN | MCP25XXFD_QUIRK_CRC_REG |
@@ -41,10 +41,10 @@ static const struct mcp25xxfd_devtype_data mcp25xxfd_devtype_data_mcp2518fd = { };/* Autodetect model, start with CRC enabled. */ -static const struct mcp25xxfd_devtype_data mcp25xxfd_devtype_data_mcp25xxfd = { +static const struct mcp25xxfd_devtype_data mcp25xxfd_devtype_data_mcp251xfd = { .quirks =MCP25XXFD_QUIRK_CRC_REG |MCP25XXFD_QUIRK_CRC_RX |MCP25XXFD_QUIRK_CRC_TX |MCP25XXFD_QUIRK_ECC , - .model =MCP25XXFD_MODEL_MCP25XXFD , + .model =MCP25XXFD_MODEL_MCP251XFD , };static const struct can_bittiming_const mcp25xxfd_bittiming_const = {
@@ -78,8 +78,8 @@ static const char *__mcp25xxfd_get_model_str(enum mcp25xxfd_model model)return "MCP2517FD" ;break ;case MCP25XXFD_MODEL_MCP2518FD :return "MCP2518FD" ;break ; -case MCP25XXFD_MODEL_MCP25XXFD : -return "MCP25xxFD" ;break ; +case MCP25XXFD_MODEL_MCP251XFD : +return "MCP251xFD" ;break ; }return "<unknown>" ;
@@ -2494,7 +2494,7 @@ static int mcp25xxfd_register_chip_detect(struct mcp25xxfd_priv *priv)else devtype_data = &mcp25xxfd_devtype_data_mcp2517fd; -if (!mcp25xxfd_is_25XX (priv) && +if (!mcp25xxfd_is_251X (priv) && priv->devtype_data.model != devtype_data->model) { netdev_info(ndev, "Detected %s, but firmware specifies a %s. Fixing up.",
@@ -2703,8 +2703,8 @@ static const struct of_device_id mcp25xxfd_of_match[] = { .compatible = "microchip,mcp2518fd", .data = &mcp25xxfd_devtype_data_mcp2518fd, }, { - .compatible = "microchip,mcp25xxfd", - .data = &mcp25xxfd_devtype_data_mcp25xxfd, + .compatible = "microchip,mcp251xfd", + .data = &mcp25xxfd_devtype_data_mcp251xfd, }, {/* sentinel */ },
@@ -2719,8 +2719,8 @@ static const struct spi_device_id mcp25xxfd_id_table[] = { .name = "mcp2518fd", .driver_data = (kernel_ulong_t)&mcp25xxfd_devtype_data_mcp2518fd, }, { - .name = "mcp25xxfd", - .driver_data = (kernel_ulong_t)&mcp25xxfd_devtype_data_mcp25xxfd, + .name = "mcp251xfd", + .driver_data = (kernel_ulong_t)&mcp25xxfd_devtype_data_mcp251xfd, }, {/* sentinel */ },
@@ -2923,5 +2923,5 @@ static struct spi_driver mcp25xxfd_driver = {module_spi_driver (mcp25xxfd_driver);MODULE_AUTHOR ("Marc Kleine-Budde <[email protected]>" ); -MODULE_DESCRIPTION ("Microchip MCP25xxFD Family CAN controller driver" ); +MODULE_DESCRIPTION ("Microchip MCP251xFD Family CAN controller driver" );MODULE_LICENSE ("GPL v2" );
drivers/net/can/spi/mcp251xfd/mcp251xfd.h +2 -2
@@ -553,7 +553,7 @@ struct mcp25xxfd_regs_status {enum mcp25xxfd_model {MCP25XXFD_MODEL_MCP2517FD =0x2517 ,MCP25XXFD_MODEL_MCP2518FD =0x2518 , -MCP25XXFD_MODEL_MCP25XXFD =0xffff ,/* autodetect model */ +MCP25XXFD_MODEL_MCP251XFD =0xffff ,/* autodetect model */ };struct mcp25xxfd_devtype_data {
@@ -607,7 +607,7 @@ mcp25xxfd_is_##_model(const struct mcp25xxfd_priv *priv) \MCP25XXFD_IS (2517 );MCP25XXFD_IS (2518 ); -MCP25XXFD_IS(25XX); +MCP25XXFD_IS(251X);static inline u8 mcp25xxfd_first_byte_set (u32 mask) {
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 10/12 can: flexcan: initialize all flexcan memory for ECC function
In reply to Marc Kleine-BuddeFrom: Joakim Zhang <[email protected]>
One issue was reported at a baremetal environment, which is used for FPGA verification. "The first transfer will fail for extended ID format(for both 2.0B and FD format), following frames can be transmitted and received successfully for extended format, and standard format don't have this issue. This issue occurred randomly with high possiblity, when it occurs, the transmitter will detect a BIT1 error, the receiver a CRC error. According to the spec, a non-correctable error may cause this transfer failure."
With FLEXCAN_QUIRK_DISABLE_MECR quirk, it supports correctable errors, disable non-correctable errors interrupt and freeze mode. Platform has ECC hardware support, but select this quirk, this issue may not come to light. Initialize all FlexCAN memory before accessing them, at least it can avoid non-correctable errors detected due to memory uninitialized. The internal region can't be initialized when the hardware doesn't support ECC.
According to IMX8MPRM, Rev.C, 04/2020. There is a NOTE at the section 11.8.3.13 Detection and correction of memory errors:
"All FlexCAN memory must be initialized before starting its operation in order to have the parity bits in memory properly updated. CTRL2[WRMFRZ] grants write access to all memory positions that require initialization, ranging from 0x080 to 0xADF and from 0xF28 to 0xFFF when the CAN FD feature is enabled. The RXMGMASK, RX14MASK, RX15MASK, and RXFGMASK registers need to be initialized as well. MCR[RFEN] must not be set during memory initialization."
Memory range from 0x080 to 0xADF, there are reserved memory (unimplemented by hardware, e.g. only configure 64 MBs), these memory can be initialized or not. In this patch, initialize all flexcan memory which includes reserved memory.
In this patch, create FLEXCAN_QUIRK_SUPPORT_ECC for platforms which has ECC feature. If you have a ECC platform in your hand, please select this qurik to initialize all flexcan memory firstly, then you can select FLEXCAN_QUIRK_DISABLE_MECR to only enable correctable errors.
--- drivers/net/can/flexcan.c | 53 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-)
drivers/net/can/flexcan.c +51 -2
@@ -239,6 +239,8 @@#define FLEXCAN_QUIRK_SETUP_STOP_MODE BIT(8)/* Support CAN-FD mode */ #define FLEXCAN_QUIRK_SUPPORT_FD BIT(9) +/* support memory detection and correction */ +#define FLEXCAN_QUIRK_SUPPORT_ECC BIT(10)/* Structure of the message buffer */ struct flexcan_mb {
@@ -292,7 +294,16 @@ struct flexcan_regs {u32 rximr[64 ];/* 0x880 - Not affected by Soft Reset */ u32 _reserved5[24 ];/* 0x980 */ u32 gfwr_mx6;/* 0x9e0 - MX6 */ -u32 _reserved6[63 ];/* 0x9e4 */ +u32 _reserved6[39 ];/* 0x9e4 */ +u32 _rxfir[6 ];/* 0xa80 */ +u32 _reserved8[2 ];/* 0xa98 */ +u32 _rxmgmask;/* 0xaa0 */ +u32 _rxfgmask;/* 0xaa4 */ +u32 _rx14mask;/* 0xaa8 */ +u32 _rx15mask;/* 0xaac */ +u32 tx_smb[4 ];/* 0xab0 */ +u32 rx_smb0[4 ];/* 0xac0 */ +u32 rx_smb1[4 ];/* 0xad0 */ u32 mecr;/* 0xae0 */ u32 erriar;/* 0xae4 */ u32 erridpr;/* 0xae8 */
@@ -305,9 +316,13 @@ struct flexcan_regs {u32 fdctrl;/* 0xc00 - Not affected by Soft Reset */ u32 fdcbt;/* 0xc04 - Not affected by Soft Reset */ u32 fdcrc;/* 0xc08 */ +u32 _reserved9[199 ];/* 0xc0c */ +u32 tx_smb_fd[18 ];/* 0xf28 */ +u32 rx_smb0_fd[18 ];/* 0xf70 */ +u32 rx_smb1_fd[18 ];/* 0xfb8 */ }; -static_assert (sizeof (struct flexcan_regs ) ==0x4 +0xc08 ); +static_assert (sizeof (struct flexcan_regs ) ==0x4 *18 +0xfb8 );struct flexcan_devtype_data {u32 quirks;/* quirks needed for different IP cores */
@@ -1292,6 +1307,37 @@ static void flexcan_set_bittiming(struct net_device *dev)return flexcan_set_bittiming_ctrl (dev); } +static void flexcan_ram_init (struct net_device *dev) +{ +struct flexcan_priv *priv =netdev_priv (dev); +struct flexcan_regs __iomem *regs = priv->regs; +u32 reg_ctrl2; + +/* 11.8.3.13 Detection and correction of memory errors: +* CTRL2[WRMFRZ] grants write access to all memory positions +* that require initialization, ranging from 0x080 to 0xADF +* and from 0xF28 to 0xFFF when the CAN FD feature is enabled. +* The RXMGMASK, RX14MASK, RX15MASK, and RXFGMASK registers +* need to be initialized as well. MCR[RFEN] must not be set +* during memory initialization. +*/ + reg_ctrl2 = priv->read (®s->ctrl2); + reg_ctrl2 |=FLEXCAN_CTRL2_WRMFRZ ; + priv->write (reg_ctrl2, ®s->ctrl2); + +memset_io (®s->mb[0 ][0 ],0 , + offsetof(struct flexcan_regs, rx_smb1[3]) - + offsetof(struct flexcan_regs, mb[0][0]) + 0x4); + +if (priv->can.ctrlmode &CAN_CTRLMODE_FD ) +memset_io (®s->tx_smb_fd[0 ],0 , + offsetof(struct flexcan_regs, rx_smb1_fd[17]) - + offsetof(struct flexcan_regs, tx_smb_fd[0]) + 0x4); + + reg_ctrl2 &= ~FLEXCAN_CTRL2_WRMFRZ ; + priv->write (reg_ctrl2, ®s->ctrl2); +} +/* flexcan_chip_start * * this functions is entered with clocks enabled
@@ -1316,6 +1362,9 @@ static int flexcan_chip_start(struct net_device *dev)if (err) goto out_chip_disable; +if (priv->devtype_data->quirks &FLEXCAN_QUIRK_SUPPORT_ECC ) +flexcan_ram_init (dev); +flexcan_set_bittiming (dev);/* MCR
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 11/12 can: flexcan: add flexcan driver for i.MX8MP
In reply to Marc Kleine-BuddeFrom: Joakim Zhang <[email protected]>
Add flexcan driver for i.MX8MP, which supports CAN FD and ECC.
--- drivers/net/can/flexcan.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/can/flexcan.c +9 -0
@@ -214,6 +214,7 @@* MX53 FlexCAN2 03.00.00.00 yes no no no no no * MX6s FlexCAN3 10.00.12.00 yes yes no no yes no * MX8QM FlexCAN3 03.00.23.00 yes yes no no yes yes +* MX8MP FlexCAN3 03.00.17.01 yes yes no yes yes yes * VF610 FlexCAN3 ? no yes no yes yes? no * LS1021A FlexCAN2 03.00.04.00 no yes no no yes no * LX2160A FlexCAN3 03.00.23.00 no yes no no yes yes
@@ -391,6 +392,13 @@ static const struct flexcan_devtype_data fsl_imx8qm_devtype_data = { FLEXCAN_QUIRK_SUPPORT_FD, }; +static struct flexcan_devtype_data fsl_imx8mp_devtype_data = { + .quirks =FLEXCAN_QUIRK_DISABLE_RXFG |FLEXCAN_QUIRK_ENABLE_EACEN_RRS | +FLEXCAN_QUIRK_DISABLE_MECR |FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | +FLEXCAN_QUIRK_BROKEN_PERR_STATE |FLEXCAN_QUIRK_SETUP_STOP_MODE | +FLEXCAN_QUIRK_SUPPORT_FD |FLEXCAN_QUIRK_SUPPORT_ECC , +}; +static const struct flexcan_devtype_data fsl_vf610_devtype_data = { .quirks =FLEXCAN_QUIRK_DISABLE_RXFG |FLEXCAN_QUIRK_ENABLE_EACEN_RRS | FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP |
@@ -1894,6 +1902,7 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)static const struct of_device_id flexcan_of_match[] = { { .compatible ="fsl,imx8qm-flexcan" , .data = &fsl_imx8qm_devtype_data, }, + { .compatible ="fsl,imx8mp-flexcan" , .data = &fsl_imx8mp_devtype_data, }, { .compatible ="fsl,imx6q-flexcan" , .data = &fsl_imx6q_devtype_data, }, { .compatible ="fsl,imx28-flexcan" , .data = &fsl_imx28_devtype_data, }, { .compatible ="fsl,imx53-flexcan" , .data = &fsl_imx25_devtype_data, },
Signature · 1 line
2.28.0
Marc Kleine-Budde
maintainerPATCH 12/12 can: flexcan: disable runtime PM if register flexcandev failed
In reply to Marc Kleine-BuddeFrom: Joakim Zhang <[email protected]>
Disable runtime PM if register flexcandev failed, and balance reference of usage_count.
--- drivers/net/can/flexcan.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/can/flexcan.c +2 -0
@@ -2057,6 +2057,8 @@ static int flexcan_probe(struct platform_device *pdev)return 0 ; failed_register: +pm_runtime_put_noidle (&pdev->dev); +pm_runtime_disable (&pdev->dev);free_candev (dev);return err; }
Signature · 1 line
2.28.0