nas220.c 2.4 KB

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