nas220.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 2014 Evgeni Dobrev <evgeni@studio-punkt.com>
  3. *
  4. * Based on sheevaplug.c originally written by
  5. * Prafulla Wadaskar <prafulla@marvell.com>
  6. * (C) Copyright 2009
  7. * Marvell Semiconductor <www.marvell.com>
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include <common.h>
  12. #include <miiphy.h>
  13. #include <asm/arch/soc.h>
  14. #include <asm/arch/mpp.h>
  15. #include <asm/arch/cpu.h>
  16. #include <asm/io.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. int board_early_init_f(void)
  19. {
  20. /*
  21. * default gpio configuration
  22. */
  23. mvebu_config_gpio(NAS220_GE_OE_VAL_LOW, NAS220_GE_OE_VAL_HIGH,
  24. NAS220_GE_OE_LOW, NAS220_GE_OE_HIGH);
  25. /* Multi-Purpose Pins Functionality configuration */
  26. static const u32 kwmpp_config[] = {
  27. MPP0_NF_IO2,
  28. MPP1_NF_IO3,
  29. MPP2_NF_IO4,
  30. MPP3_NF_IO5,
  31. MPP4_NF_IO6,
  32. MPP5_NF_IO7,
  33. MPP6_SYSRST_OUTn,
  34. MPP7_SPI_SCn,
  35. MPP8_TW_SDA,
  36. MPP9_TW_SCK,
  37. MPP10_UART0_TXD,
  38. MPP11_UART0_RXD,
  39. MPP12_GPO,
  40. MPP13_GPIO,
  41. MPP14_GPIO,
  42. MPP15_SATA0_ACTn,
  43. MPP16_SATA1_ACTn,
  44. MPP17_SATA0_PRESENTn,
  45. MPP18_NF_IO0,
  46. MPP19_NF_IO1,
  47. MPP20_GPIO,
  48. MPP21_GPIO,
  49. MPP22_GPIO,
  50. MPP23_GPIO,
  51. MPP24_GPIO,
  52. MPP25_GPIO,
  53. MPP26_GPIO,
  54. MPP27_GPIO,
  55. MPP28_GPIO,
  56. MPP29_GPIO,
  57. MPP30_GPIO,
  58. MPP31_GPIO,
  59. MPP32_GPIO,
  60. MPP33_GPIO,
  61. MPP34_GPIO,
  62. MPP35_GPIO,
  63. 0
  64. };
  65. kirkwood_mpp_conf(kwmpp_config, NULL);
  66. return 0;
  67. }
  68. int board_init(void)
  69. {
  70. /*
  71. * arch number of board
  72. */
  73. gd->bd->bi_arch_number = MACH_TYPE_NAS220;
  74. /* adress of boot parameters */
  75. gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  76. return 0;
  77. }
  78. #ifdef CONFIG_RESET_PHY_R
  79. /* Configure and enable MV88E1116 PHY */
  80. void reset_phy(void)
  81. {
  82. u16 reg;
  83. u16 devadr;
  84. char *name = "egiga0";
  85. if (miiphy_set_current_dev(name))
  86. return;
  87. /* command to read PHY dev address */
  88. if (miiphy_read(name, 0xEE, 0xEE, (u16 *)&devadr)) {
  89. printf("Err..%s could not read PHY dev address\n", __func__);
  90. return;
  91. }
  92. /*
  93. * Enable RGMII delay on Tx and Rx for CPU port
  94. * Ref: sec 4.7.2 of chip datasheet
  95. */
  96. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
  97. miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
  98. reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
  99. miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
  100. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
  101. /* reset the phy */
  102. miiphy_reset(name, devadr);
  103. printf("88E1116 Initialized on %s\n", name);
  104. }
  105. #endif /* CONFIG_RESET_PHY_R */