001-pinctrl-mediatek-set-R1-R0-in-case-pullen-pullsel-su.patch 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. From patchwork Wed Apr 12 20:36:43 2023
  2. Content-Type: text/plain; charset="utf-8"
  3. MIME-Version: 1.0
  4. Content-Transfer-Encoding: 7bit
  5. X-Patchwork-Submitter: Daniel Golle <[email protected]>
  6. X-Patchwork-Id: 1768270
  7. Return-Path: <[email protected]>
  8. X-Original-To: [email protected]
  9. Delivered-To: [email protected]
  10. Date: Wed, 12 Apr 2023 21:36:43 +0100
  11. From: Daniel Golle <[email protected]>
  12. To: [email protected], Sam Shih <[email protected]>,
  13. GSS_MTK_Uboot_upstream <[email protected]>,
  14. Chunfeng Yun <[email protected]>,
  15. Weijie Gao <[email protected]>, Ryder Lee <[email protected]>,
  16. Frank Wunderlich <[email protected]>
  17. Cc: Steven Liu =?utf-8?b?KOWKieS6uuixqik=?= <[email protected]>,
  18. John Crispin <[email protected]>
  19. Subject: [PATCH] pinctrl: mediatek: set R1/R0 in case pullen/pullsel succeeded
  20. Message-ID: <[email protected]>
  21. MIME-Version: 1.0
  22. Content-Disposition: inline
  23. X-BeenThere: [email protected]
  24. X-Mailman-Version: 2.1.39
  25. Precedence: list
  26. List-Id: U-Boot discussion <u-boot.lists.denx.de>
  27. Sender: "U-Boot" <[email protected]>
  28. Commit dafe0fbfb0f3 ("pinctrl: mediatek: rewrite mtk_pinconf_set and
  29. related functions") changed the logic deciding to set R0 and R1
  30. registers for V1 devices.
  31. Before:
  32. /* Also set PUPD/R0/R1 if the pin has them */
  33. err = mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_PUPD, !pullup);
  34. if (err != -EINVAL) {
  35. mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_R0, r0);
  36. mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_R1, r1);
  37. }
  38. After:
  39. /* try pupd_r1_r0 if pullen_pullsel return error */
  40. err = mtk_pinconf_bias_set_pullen_pullsel(dev, pin, disable, pullup,
  41. val);
  42. if (err)
  43. return mtk_pinconf_bias_set_pupd_r1_r0(dev, pin, disable,
  44. pullup, val);
  45. Tracing mtk_pinconf_bias_set_pullen_pullsel shows that the function
  46. always either returns 0 in case of success or -EINVAL in case any error
  47. has occurred. Hence the logic responsible of the decision to program R0
  48. and R1 has been inverted.
  49. This leads to problems on BananaPi R2 (MT7623N) when booting from
  50. SDMMC, it turns out accessing eMMC no longer works since
  51. U-Boot 2022.07:
  52. MT7623> mmc dev 0
  53. Card did not respond to voltage select! : -110
  54. The problem wasn't detected for a long time as both eMMC and SDMMC work
  55. fine if they are used to boot from, and hence R0 and R1 were already
  56. setup by the bootrom and/or preloader.
  57. Fix the logic to restore the originally intended and correct behavior
  58. and also change the descriptive comment accordingly.
  59. Fixes: dafe0fbfb0f3 ("pinctrl: mediatek: rewrite mtk_pinconf_set and related functions")
  60. Signed-off-by: Daniel Golle <[email protected]>
  61. ---
  62. drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 4 ++--
  63. 1 file changed, 2 insertions(+), 2 deletions(-)
  64. --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
  65. +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
  66. @@ -349,10 +349,10 @@ int mtk_pinconf_bias_set_v1(struct udevi
  67. {
  68. int err;
  69. - /* try pupd_r1_r0 if pullen_pullsel return error */
  70. + /* set pupd_r1_r0 if pullen_pullsel succeeded */
  71. err = mtk_pinconf_bias_set_pullen_pullsel(dev, pin, disable, pullup,
  72. val);
  73. - if (err)
  74. + if (!err)
  75. return mtk_pinconf_bias_set_pupd_r1_r0(dev, pin, disable,
  76. pullup, val);