Skip to content

Commit 8333c1c

Browse files
committed
Merge tag 'linux-can-next-for-5.10-20200930' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next
Marc Kleine-Budde says: ==================== pull-request: can-next 2020-09-30 this is a pull request of 13 patches for net-next. The first 10 target the mcp25xxfd driver (which is renamed to mcp251xfd during this series). The first two patches are by Thomas Kopp, which adds reference to the just related errata and updates the documentation and log messages. Dan Carpenter's patch fixes a resource leak during ifdown. A patch by me adds the missing initialization of a variable. Oleksij Rempel updates the DT binding documentation as requested by Rob Herring. The next 5 patches are by Thomas Kopp and me. During review Geert Uytterhoeven suggested to use "microchip,mcp251xfd" instead of "microchip,mcp25xxfd" as the DT autodetection compatible to avoid clashes with future but incompatible devices. We decided not only to rename the compatible but the whole driver from "mcp25xxfd" to "mcp251xfd". This is done in several patches. Joakim Zhang contributes three patches for the flexcan driver. The first one adds support for the ECC feature, which is implemented on some modern IP cores, by initializing the controller's memory during ifup. The next patch adds support for the i.MX8MP (which supports ECC) and the last patch properly disables the runtime PM if device registration fails. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 11789fe + 5a9323f commit 8333c1c

File tree

12 files changed

+1749
-1673
lines changed

12 files changed

+1749
-1673
lines changed

Documentation/devicetree/bindings/net/can/microchip,mcp25xxfd.yaml renamed to Documentation/devicetree/bindings/net/can/microchip,mcp251xfd.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
22
%YAML 1.2
33
---
4-
$id: http://devicetree.org/schemas/net/can/microchip,mcp25xxfd.yaml#
4+
$id: http://devicetree.org/schemas/net/can/microchip,mcp251xfd.yaml#
55
$schema: http://devicetree.org/meta-schemas/core.yaml#
66

77
title:
@@ -18,29 +18,27 @@ properties:
1818
description: for MCP2517FD
1919
- const: microchip,mcp2518fd
2020
description: for MCP2518FD
21-
- const: microchip,mcp25xxfd
21+
- const: microchip,mcp251xfd
2222
description: to autodetect chip variant
2323

2424
reg:
2525
maxItems: 1
2626

27-
interrupts-extended:
27+
interrupts:
2828
maxItems: 1
2929

3030
clocks:
3131
maxItems: 1
3232

3333
vdd-supply:
3434
description: Regulator that powers the CAN controller.
35-
maxItems: 1
3635

3736
xceiver-supply:
3837
description: Regulator that powers the CAN transceiver.
39-
maxItems: 1
4038

4139
microchip,rx-int-gpios:
4240
description:
43-
GPIO phandle of GPIO connected to to INT1 pin of the MCP25XXFD, which
41+
GPIO phandle of GPIO connected to to INT1 pin of the MCP251XFD, which
4442
signals a pending RX interrupt.
4543
maxItems: 1
4644

@@ -52,9 +50,11 @@ properties:
5250
required:
5351
- compatible
5452
- reg
55-
- interrupts-extended
53+
- interrupts
5654
- clocks
5755

56+
additionalProperties: false
57+
5858
examples:
5959
- |
6060
#include <dt-bindings/gpio/gpio.h>
@@ -65,7 +65,7 @@ examples:
6565
#size-cells = <0>;
6666
6767
can@0 {
68-
compatible = "microchip,mcp25xxfd";
68+
compatible = "microchip,mcp251xfd";
6969
reg = <0>;
7070
clocks = <&can0_osc>;
7171
pinctrl-names = "default";

drivers/net/can/flexcan.c

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
* MX53 FlexCAN2 03.00.00.00 yes no no no no no
215215
* MX6s FlexCAN3 10.00.12.00 yes yes no no yes no
216216
* MX8QM FlexCAN3 03.00.23.00 yes yes no no yes yes
217+
* MX8MP FlexCAN3 03.00.17.01 yes yes no yes yes yes
217218
* VF610 FlexCAN3 ? no yes no yes yes? no
218219
* LS1021A FlexCAN2 03.00.04.00 no yes no no yes no
219220
* LX2160A FlexCAN3 03.00.23.00 no yes no no yes yes
@@ -239,6 +240,8 @@
239240
#define FLEXCAN_QUIRK_SETUP_STOP_MODE BIT(8)
240241
/* Support CAN-FD mode */
241242
#define FLEXCAN_QUIRK_SUPPORT_FD BIT(9)
243+
/* support memory detection and correction */
244+
#define FLEXCAN_QUIRK_SUPPORT_ECC BIT(10)
242245

243246
/* Structure of the message buffer */
244247
struct flexcan_mb {
@@ -292,7 +295,16 @@ struct flexcan_regs {
292295
u32 rximr[64]; /* 0x880 - Not affected by Soft Reset */
293296
u32 _reserved5[24]; /* 0x980 */
294297
u32 gfwr_mx6; /* 0x9e0 - MX6 */
295-
u32 _reserved6[63]; /* 0x9e4 */
298+
u32 _reserved6[39]; /* 0x9e4 */
299+
u32 _rxfir[6]; /* 0xa80 */
300+
u32 _reserved8[2]; /* 0xa98 */
301+
u32 _rxmgmask; /* 0xaa0 */
302+
u32 _rxfgmask; /* 0xaa4 */
303+
u32 _rx14mask; /* 0xaa8 */
304+
u32 _rx15mask; /* 0xaac */
305+
u32 tx_smb[4]; /* 0xab0 */
306+
u32 rx_smb0[4]; /* 0xac0 */
307+
u32 rx_smb1[4]; /* 0xad0 */
296308
u32 mecr; /* 0xae0 */
297309
u32 erriar; /* 0xae4 */
298310
u32 erridpr; /* 0xae8 */
@@ -305,9 +317,13 @@ struct flexcan_regs {
305317
u32 fdctrl; /* 0xc00 - Not affected by Soft Reset */
306318
u32 fdcbt; /* 0xc04 - Not affected by Soft Reset */
307319
u32 fdcrc; /* 0xc08 */
320+
u32 _reserved9[199]; /* 0xc0c */
321+
u32 tx_smb_fd[18]; /* 0xf28 */
322+
u32 rx_smb0_fd[18]; /* 0xf70 */
323+
u32 rx_smb1_fd[18]; /* 0xfb8 */
308324
};
309325

310-
static_assert(sizeof(struct flexcan_regs) == 0x4 + 0xc08);
326+
static_assert(sizeof(struct flexcan_regs) == 0x4 * 18 + 0xfb8);
311327

312328
struct flexcan_devtype_data {
313329
u32 quirks; /* quirks needed for different IP cores */
@@ -376,6 +392,13 @@ static const struct flexcan_devtype_data fsl_imx8qm_devtype_data = {
376392
FLEXCAN_QUIRK_SUPPORT_FD,
377393
};
378394

395+
static struct flexcan_devtype_data fsl_imx8mp_devtype_data = {
396+
.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
397+
FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP |
398+
FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_SETUP_STOP_MODE |
399+
FLEXCAN_QUIRK_SUPPORT_FD | FLEXCAN_QUIRK_SUPPORT_ECC,
400+
};
401+
379402
static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
380403
.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
381404
FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP |
@@ -1292,6 +1315,37 @@ static void flexcan_set_bittiming(struct net_device *dev)
12921315
return flexcan_set_bittiming_ctrl(dev);
12931316
}
12941317

1318+
static void flexcan_ram_init(struct net_device *dev)
1319+
{
1320+
struct flexcan_priv *priv = netdev_priv(dev);
1321+
struct flexcan_regs __iomem *regs = priv->regs;
1322+
u32 reg_ctrl2;
1323+
1324+
/* 11.8.3.13 Detection and correction of memory errors:
1325+
* CTRL2[WRMFRZ] grants write access to all memory positions
1326+
* that require initialization, ranging from 0x080 to 0xADF
1327+
* and from 0xF28 to 0xFFF when the CAN FD feature is enabled.
1328+
* The RXMGMASK, RX14MASK, RX15MASK, and RXFGMASK registers
1329+
* need to be initialized as well. MCR[RFEN] must not be set
1330+
* during memory initialization.
1331+
*/
1332+
reg_ctrl2 = priv->read(&regs->ctrl2);
1333+
reg_ctrl2 |= FLEXCAN_CTRL2_WRMFRZ;
1334+
priv->write(reg_ctrl2, &regs->ctrl2);
1335+
1336+
memset_io(&regs->mb[0][0], 0,
1337+
offsetof(struct flexcan_regs, rx_smb1[3]) -
1338+
offsetof(struct flexcan_regs, mb[0][0]) + 0x4);
1339+
1340+
if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
1341+
memset_io(&regs->tx_smb_fd[0], 0,
1342+
offsetof(struct flexcan_regs, rx_smb1_fd[17]) -
1343+
offsetof(struct flexcan_regs, tx_smb_fd[0]) + 0x4);
1344+
1345+
reg_ctrl2 &= ~FLEXCAN_CTRL2_WRMFRZ;
1346+
priv->write(reg_ctrl2, &regs->ctrl2);
1347+
}
1348+
12951349
/* flexcan_chip_start
12961350
*
12971351
* this functions is entered with clocks enabled
@@ -1316,6 +1370,9 @@ static int flexcan_chip_start(struct net_device *dev)
13161370
if (err)
13171371
goto out_chip_disable;
13181372

1373+
if (priv->devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_ECC)
1374+
flexcan_ram_init(dev);
1375+
13191376
flexcan_set_bittiming(dev);
13201377

13211378
/* MCR
@@ -1845,6 +1902,7 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
18451902

18461903
static const struct of_device_id flexcan_of_match[] = {
18471904
{ .compatible = "fsl,imx8qm-flexcan", .data = &fsl_imx8qm_devtype_data, },
1905+
{ .compatible = "fsl,imx8mp-flexcan", .data = &fsl_imx8mp_devtype_data, },
18481906
{ .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, },
18491907
{ .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, },
18501908
{ .compatible = "fsl,imx53-flexcan", .data = &fsl_imx25_devtype_data, },
@@ -1999,6 +2057,8 @@ static int flexcan_probe(struct platform_device *pdev)
19992057
return 0;
20002058

20012059
failed_register:
2060+
pm_runtime_put_noidle(&pdev->dev);
2061+
pm_runtime_disable(&pdev->dev);
20022062
free_candev(dev);
20032063
return err;
20042064
}

drivers/net/can/spi/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ config CAN_MCP251X
1313
Driver for the Microchip MCP251x and MCP25625 SPI CAN
1414
controllers.
1515

16-
source "drivers/net/can/spi/mcp25xxfd/Kconfig"
16+
source "drivers/net/can/spi/mcp251xfd/Kconfig"
1717

1818
endmenu

drivers/net/can/spi/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
obj-$(CONFIG_CAN_HI311X) += hi311x.o
88
obj-$(CONFIG_CAN_MCP251X) += mcp251x.o
9-
obj-y += mcp25xxfd/
9+
obj-y += mcp251xfd/

drivers/net/can/spi/mcp25xxfd/Kconfig renamed to drivers/net/can/spi/mcp251xfd/Kconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22

3-
config CAN_MCP25XXFD
4-
tristate "Microchip MCP25xxFD SPI CAN controllers"
3+
config CAN_MCP251XFD
4+
tristate "Microchip MCP251xFD SPI CAN controllers"
55
select REGMAP
66
help
7-
Driver for the Microchip MCP25XXFD SPI FD-CAN controller
7+
Driver for the Microchip MCP251XFD SPI FD-CAN controller
88
family.
99

10-
config CAN_MCP25XXFD_SANITY
11-
depends on CAN_MCP25XXFD
10+
config CAN_MCP251XFD_SANITY
11+
depends on CAN_MCP251XFD
1212
bool "Additional Sanity Checks"
1313
help
1414
This option enables additional sanity checks in the driver,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
3+
obj-$(CONFIG_CAN_MCP251XFD) += mcp251xfd.o
4+
5+
mcp251xfd-objs :=
6+
mcp251xfd-objs += mcp251xfd-core.o
7+
mcp251xfd-objs += mcp251xfd-crc16.o
8+
mcp251xfd-objs += mcp251xfd-regmap.o

0 commit comments

Comments
 (0)