1
0

014-fix-gmac-init.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. From fc8991c61c393ce6a9d3dfc97cb56dbbd9e8cbba Mon Sep 17 00:00:00 2001
  2. From: Hans de Goede <hdegoede@redhat.com>
  3. Date: Thu, 17 Mar 2016 13:53:03 +0100
  4. Subject: [PATCH] sunxi: Fix gmac not working due to cpu_eth_init no longer
  5. being called
  6. cpu_eth_init is no longer called for dm enabled eth drivers, this
  7. was causing the sunxi gmac eth controller to no longer work in u-boot.
  8. This commit fixes this by calling the clock, reset and pinmux setup
  9. function from s_init() and enabling the phy power pin (if any) from
  10. board_init().
  11. The enabling of phy power cannot be done from s_init because it uses dm
  12. and dm is not ready yet at this point.
  13. Note that the mdelay is dropped as the phy gets enabled much earlier
  14. now, so it is no longer needed.
  15. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  16. Acked-by: Ian Campbell <ijc@hellion.org.uk>
  17. Tested-by: Karsten Merker <merker@debian.org>
  18. Tested-by: Michael Haas <haas@computerlinguist.org>
  19. ---
  20. arch/arm/cpu/armv7/sunxi/board.c | 28 +---------------------------
  21. arch/arm/include/asm/arch-sunxi/sys_proto.h | 6 +++++-
  22. board/sunxi/board.c | 5 +++++
  23. board/sunxi/gmac.c | 14 +-------------
  24. 4 files changed, 12 insertions(+), 41 deletions(-)
  25. --- a/arch/arm/cpu/armv7/sunxi/board.c
  26. +++ b/arch/arm/cpu/armv7/sunxi/board.c
  27. @@ -136,6 +136,7 @@ void s_init(void)
  28. timer_init();
  29. gpio_init();
  30. i2c_init_board();
  31. + eth_init_board();
  32. }
  33. #ifdef CONFIG_SPL_BUILD
  34. @@ -243,30 +244,3 @@ void enable_caches(void)
  35. dcache_enable();
  36. }
  37. #endif
  38. -
  39. -#ifdef CONFIG_CMD_NET
  40. -/*
  41. - * Initializes on-chip ethernet controllers.
  42. - * to override, implement board_eth_init()
  43. - */
  44. -int cpu_eth_init(bd_t *bis)
  45. -{
  46. - __maybe_unused int rc;
  47. -
  48. -#ifdef CONFIG_MACPWR
  49. - gpio_request(CONFIG_MACPWR, "macpwr");
  50. - gpio_direction_output(CONFIG_MACPWR, 1);
  51. - mdelay(200);
  52. -#endif
  53. -
  54. -#ifdef CONFIG_SUNXI_GMAC
  55. - rc = sunxi_gmac_initialize(bis);
  56. - if (rc < 0) {
  57. - printf("sunxi: failed to initialize gmac\n");
  58. - return rc;
  59. - }
  60. -#endif
  61. -
  62. - return 0;
  63. -}
  64. -#endif
  65. --- a/arch/arm/include/asm/arch-sunxi/sys_proto.h
  66. +++ b/arch/arm/include/asm/arch-sunxi/sys_proto.h
  67. @@ -24,6 +24,10 @@ void sdelay(unsigned long);
  68. void return_to_fel(uint32_t lr, uint32_t sp);
  69. /* Board / SoC level designware gmac init */
  70. -int sunxi_gmac_initialize(bd_t *bis);
  71. +#if !defined CONFIG_SPL_BUILD && defined CONFIG_SUNXI_GMAC
  72. +void eth_init_board(void);
  73. +#else
  74. +static inline void eth_init_board(void) {}
  75. +#endif
  76. #endif
  77. --- a/board/sunxi/board.c
  78. +++ b/board/sunxi/board.c
  79. @@ -90,6 +90,11 @@ int board_init(void)
  80. if (ret)
  81. return ret;
  82. +#ifdef CONFIG_MACPWR
  83. + gpio_request(CONFIG_MACPWR, "macpwr");
  84. + gpio_direction_output(CONFIG_MACPWR, 1);
  85. +#endif
  86. +
  87. /* Uses dm gpio code so do this here and not in i2c_init_board() */
  88. return soft_i2c_board_init();
  89. }
  90. --- a/board/sunxi/gmac.c
  91. +++ b/board/sunxi/gmac.c
  92. @@ -6,7 +6,7 @@
  93. #include <asm/arch/clock.h>
  94. #include <asm/arch/gpio.h>
  95. -int sunxi_gmac_initialize(bd_t *bis)
  96. +void eth_init_board(void)
  97. {
  98. int pin;
  99. struct sunxi_ccm_reg *const ccm =
  100. @@ -79,16 +79,4 @@ int sunxi_gmac_initialize(bd_t *bis)
  101. for (pin = SUNXI_GPA(26); pin <= SUNXI_GPA(27); pin++)
  102. sunxi_gpio_set_cfgpin(pin, SUN6I_GPA_GMAC);
  103. #endif
  104. -
  105. -#ifdef CONFIG_DM_ETH
  106. - return 0;
  107. -#else
  108. -# ifdef CONFIG_RGMII
  109. - return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII);
  110. -# elif defined CONFIG_GMII
  111. - return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_GMII);
  112. -# else
  113. - return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII);
  114. -# endif
  115. -#endif
  116. }