802-can-0025-can-flexcan-add-LPSR-mode-support-for-i.MX7D.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From 211c20a459a0fd4868ed22ecfc2b2186d9df6da0 Mon Sep 17 00:00:00 2001
  2. From: Joakim Zhang <[email protected]>
  3. Date: Tue, 30 Jul 2019 14:43:25 +0800
  4. Subject: [PATCH] can: flexcan: add LPSR mode support for i.MX7D
  5. For i.MX7D LPSR mode, the controller will lost power and got the
  6. configuration state lost after system resume back.
  7. So we need to set pinctrl state again and re-start chip to do
  8. re-configuration after resume.
  9. For wakeup case, it should not set pinctrl to sleep state by
  10. pinctrl_pm_select_sleep_state.
  11. For interface is not up before suspend case, we don't need
  12. re-configure as it will be configured by user later by interface up.
  13. Signed-off-by: Joakim Zhang <[email protected]>
  14. ---
  15. drivers/net/can/flexcan.c | 21 ++++++++++++++-------
  16. 1 file changed, 14 insertions(+), 7 deletions(-)
  17. --- a/drivers/net/can/flexcan.c
  18. +++ b/drivers/net/can/flexcan.c
  19. @@ -26,6 +26,7 @@
  20. #include <linux/platform_device.h>
  21. #include <linux/pm_runtime.h>
  22. #include <linux/regulator/consumer.h>
  23. +#include <linux/pinctrl/consumer.h>
  24. #include <linux/regmap.h>
  25. #define DRV_NAME "flexcan"
  26. @@ -1959,9 +1960,7 @@ static int __maybe_unused flexcan_suspen
  27. if (err)
  28. return err;
  29. } else {
  30. - err = flexcan_chip_disable(priv);
  31. - if (err)
  32. - return err;
  33. + flexcan_chip_stop(dev);
  34. }
  35. netif_stop_queue(dev);
  36. netif_device_detach(dev);
  37. @@ -1987,7 +1986,9 @@ static int __maybe_unused flexcan_resume
  38. if (err)
  39. return err;
  40. } else {
  41. - err = flexcan_chip_enable(priv);
  42. + err = flexcan_chip_start(dev);
  43. + if (err)
  44. + return err;
  45. }
  46. }