802-can-0021-can-flexcan-add-ISO-CAN-FD-feature-support.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. From 094a648bc2217a9624f35224059c3eac86196143 Mon Sep 17 00:00:00 2001
  2. From: Joakim Zhang <[email protected]>
  3. Date: Fri, 12 Jul 2019 08:02:51 +0000
  4. Subject: [PATCH] can: flexcan: add ISO CAN FD feature support
  5. ISO CAN FD is introduced to increase the failture detection capability
  6. than non-ISO CAN FD. The non-ISO CAN FD is still supported by FlexCAN so
  7. that it can be used mainly during an intermediate phase, for evaluation
  8. and development purposes.
  9. Therefore, it is strongly recommended to configure FlexCAN to the ISO
  10. CAN FD protocol by setting the ISOCANFDEN field in the CTRL2 register.
  11. NOTE: If you only set "fd on", driver will use ISO FD mode by default.
  12. You should set "fd-non-iso on" after setting "fd on" if you want to use
  13. NON ISO FD mode.
  14. Signed-off-by: Joakim Zhang <[email protected]>
  15. Signed-off-by: Marc Kleine-Budde <[email protected]>
  16. ---
  17. drivers/net/can/flexcan.c | 8 +++++++-
  18. 1 file changed, 7 insertions(+), 1 deletion(-)
  19. --- a/drivers/net/can/flexcan.c
  20. +++ b/drivers/net/can/flexcan.c
  21. @@ -92,6 +92,7 @@
  22. #define FLEXCAN_CTRL2_MRP BIT(18)
  23. #define FLEXCAN_CTRL2_RRS BIT(17)
  24. #define FLEXCAN_CTRL2_EACEN BIT(16)
  25. +#define FLEXCAN_CTRL2_ISOCANFDEN BIT(12)
  26. /* FLEXCAN memory error control register (MECR) bits */
  27. #define FLEXCAN_MECR_ECRWRDIS BIT(31)
  28. @@ -1324,6 +1325,7 @@ static int flexcan_chip_start(struct net
  29. reg_fdctrl = priv->read(&regs->fdctrl) & ~FLEXCAN_FDCTRL_FDRATE;
  30. reg_fdctrl &= ~(FLEXCAN_FDCTRL_MBDSR1(0x3) | FLEXCAN_FDCTRL_MBDSR0(0x3));
  31. reg_mcr = priv->read(&regs->mcr) & ~FLEXCAN_MCR_FDEN;
  32. + reg_ctrl2 = priv->read(&regs->ctrl2) & ~FLEXCAN_CTRL2_ISOCANFDEN;
  33. /* support BRS when set CAN FD mode
  34. * 64 bytes payload per MB and 7 MBs per RAM block by default
  35. @@ -1333,10 +1335,14 @@ static int flexcan_chip_start(struct net
  36. reg_fdctrl |= FLEXCAN_FDCTRL_FDRATE;
  37. reg_fdctrl |= FLEXCAN_FDCTRL_MBDSR1(0x3) | FLEXCAN_FDCTRL_MBDSR0(0x3);
  38. reg_mcr |= FLEXCAN_MCR_FDEN;
  39. +
  40. + if (!(priv->can.ctrlmode & CAN_CTRLMODE_FD_NON_ISO))
  41. + reg_ctrl2 |= FLEXCAN_CTRL2_ISOCANFDEN;
  42. }
  43. priv->write(reg_fdctrl, &regs->fdctrl);
  44. priv->write(reg_mcr, &regs->mcr);
  45. + priv->write(reg_ctrl2, &regs->ctrl2);
  46. }
  47. if ((priv->devtype_data->quirks & FLEXCAN_QUIRK_ENABLE_EACEN_RRS)) {
  48. @@ -1856,7 +1862,7 @@ static int flexcan_probe(struct platform
  49. if (priv->devtype_data->quirks & FLEXCAN_QUIRK_TIMESTAMP_SUPPORT_FD) {
  50. if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) {
  51. - priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD;
  52. + priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO;
  53. priv->can.bittiming_const = &flexcan_fd_bittiming_const;
  54. priv->can.data_bittiming_const = &flexcan_fd_data_bittiming_const;
  55. } else {