openrd.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * (C) Copyright 2009
  3. * Net Insight <www.netinsight.net>
  4. * Written-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
  5. *
  6. * Based on sheevaplug.c:
  7. * (C) Copyright 2009
  8. * Marvell Semiconductor <www.marvell.com>
  9. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  10. *
  11. * SPDX-License-Identifier: GPL-2.0+
  12. */
  13. #include <common.h>
  14. #include <miiphy.h>
  15. #include <asm/arch/cpu.h>
  16. #include <asm/arch/soc.h>
  17. #include <asm/arch/mpp.h>
  18. #include "openrd.h"
  19. DECLARE_GLOBAL_DATA_PTR;
  20. int board_early_init_f(void)
  21. {
  22. /*
  23. * default gpio configuration
  24. * There are maximum 64 gpios controlled through 2 sets of registers
  25. * the below configuration configures mainly initial LED status
  26. */
  27. mvebu_config_gpio(OPENRD_OE_VAL_LOW,
  28. OPENRD_OE_VAL_HIGH,
  29. OPENRD_OE_LOW, OPENRD_OE_HIGH);
  30. /* Multi-Purpose Pins Functionality configuration */
  31. static const u32 kwmpp_config[] = {
  32. MPP0_NF_IO2,
  33. MPP1_NF_IO3,
  34. MPP2_NF_IO4,
  35. MPP3_NF_IO5,
  36. MPP4_NF_IO6,
  37. MPP5_NF_IO7,
  38. MPP6_SYSRST_OUTn,
  39. MPP7_GPO,
  40. MPP8_TW_SDA,
  41. MPP9_TW_SCK,
  42. MPP10_UART0_TXD,
  43. MPP11_UART0_RXD,
  44. MPP12_SD_CLK,
  45. MPP13_SD_CMD, /* Alt UART1_TXD */
  46. MPP14_SD_D0, /* Alt UART1_RXD */
  47. MPP15_SD_D1,
  48. MPP16_SD_D2,
  49. MPP17_SD_D3,
  50. MPP18_NF_IO0,
  51. MPP19_NF_IO1,
  52. MPP20_GE1_0,
  53. MPP21_GE1_1,
  54. MPP22_GE1_2,
  55. MPP23_GE1_3,
  56. MPP24_GE1_4,
  57. MPP25_GE1_5,
  58. MPP26_GE1_6,
  59. MPP27_GE1_7,
  60. MPP28_GPIO,
  61. MPP29_TSMP9,
  62. MPP30_GE1_10,
  63. MPP31_GE1_11,
  64. MPP32_GE1_12,
  65. MPP33_GE1_13,
  66. MPP34_GPIO, /* UART1 / SD sel */
  67. MPP35_TDM_CH0_TX_QL,
  68. MPP36_TDM_SPI_CS1,
  69. MPP37_TDM_CH2_TX_QL,
  70. MPP38_TDM_CH2_RX_QL,
  71. MPP39_AUDIO_I2SBCLK,
  72. MPP40_AUDIO_I2SDO,
  73. MPP41_AUDIO_I2SLRC,
  74. MPP42_AUDIO_I2SMCLK,
  75. MPP43_AUDIO_I2SDI,
  76. MPP44_AUDIO_EXTCLK,
  77. MPP45_TDM_PCLK,
  78. MPP46_TDM_FS,
  79. MPP47_TDM_DRX,
  80. MPP48_TDM_DTX,
  81. MPP49_TDM_CH0_RX_QL,
  82. 0
  83. };
  84. kirkwood_mpp_conf(kwmpp_config, NULL);
  85. return 0;
  86. }
  87. int board_init(void)
  88. {
  89. /*
  90. * arch number of board
  91. */
  92. #if defined(CONFIG_BOARD_IS_OPENRD_BASE)
  93. gd->bd->bi_arch_number = MACH_TYPE_OPENRD_BASE;
  94. #elif defined(CONFIG_BOARD_IS_OPENRD_CLIENT)
  95. gd->bd->bi_arch_number = MACH_TYPE_OPENRD_CLIENT;
  96. #elif defined(CONFIG_BOARD_IS_OPENRD_ULTIMATE)
  97. gd->bd->bi_arch_number = MACH_TYPE_OPENRD_ULTIMATE;
  98. #endif
  99. /* adress of boot parameters */
  100. gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  101. return 0;
  102. }
  103. #ifdef CONFIG_RESET_PHY_R
  104. /* Configure and enable MV88E1116/88E1121 PHY */
  105. void mv_phy_init(char *name)
  106. {
  107. u16 reg;
  108. u16 devadr;
  109. if (miiphy_set_current_dev(name))
  110. return;
  111. /* command to read PHY dev address */
  112. if (miiphy_read(name, 0xEE, 0xEE, (u16 *)&devadr)) {
  113. printf("Err..%s could not read PHY dev address\n", __func__);
  114. return;
  115. }
  116. /*
  117. * Enable RGMII delay on Tx and Rx for CPU port
  118. * Ref: sec 4.7.2 of chip datasheet
  119. */
  120. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
  121. miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
  122. reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
  123. miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
  124. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
  125. /* reset the phy */
  126. miiphy_reset(name, devadr);
  127. printf(PHY_NO" Initialized on %s\n", name);
  128. }
  129. void reset_phy(void)
  130. {
  131. mv_phy_init("egiga0");
  132. #ifdef CONFIG_BOARD_IS_OPENRD_CLIENT
  133. /* Kirkwood ethernet driver is written with the assumption that in case
  134. * of multiple PHYs, their addresses are consecutive. But unfortunately
  135. * in case of OpenRD-Client, PHY addresses are not consecutive.*/
  136. miiphy_write("egiga1", 0xEE, 0xEE, 24);
  137. #endif
  138. #if defined(CONFIG_BOARD_IS_OPENRD_CLIENT) || \
  139. defined(CONFIG_BOARD_IS_OPENRD_ULTIMATE)
  140. /* configure and initialize both PHY's */
  141. mv_phy_init("egiga1");
  142. #endif
  143. }
  144. #endif /* CONFIG_RESET_PHY_R */