dns325.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2011
  4. * Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
  5. *
  6. * Based on Kirkwood support:
  7. * (C) Copyright 2009
  8. * Marvell Semiconductor <www.marvell.com>
  9. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  10. */
  11. #include <common.h>
  12. #include <miiphy.h>
  13. #include <netdev.h>
  14. #include <asm/arch/cpu.h>
  15. #include <asm/arch/soc.h>
  16. #include <asm/arch/mpp.h>
  17. #include <asm/arch/gpio.h>
  18. #include "dns325.h"
  19. DECLARE_GLOBAL_DATA_PTR;
  20. int board_early_init_f(void)
  21. {
  22. /* Gpio configuration */
  23. mvebu_config_gpio(DNS325_OE_VAL_LOW, DNS325_OE_VAL_HIGH,
  24. DNS325_OE_LOW, DNS325_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_GPO,
  35. MPP8_TW_SDA,
  36. MPP9_TW_SCK,
  37. MPP10_UART0_TXD,
  38. MPP11_UART0_RXD,
  39. MPP12_SD_CLK,
  40. MPP13_SD_CMD,
  41. MPP14_SD_D0,
  42. MPP15_SD_D1,
  43. MPP16_SD_D2,
  44. MPP17_SD_D3,
  45. MPP18_NF_IO0,
  46. MPP19_NF_IO1,
  47. MPP20_SATA1_ACTn, /* sata1(left) status led */
  48. MPP21_SATA0_ACTn, /* sata0(right) status led */
  49. MPP22_GPIO,
  50. MPP23_GPIO,
  51. MPP24_GPIO, /* power off out */
  52. MPP25_GPIO,
  53. MPP26_GPIO, /* power led */
  54. MPP27_GPIO, /* sata0(right) error led */
  55. MPP28_GPIO, /* sata1(left) error led */
  56. MPP29_GPIO, /* usb error led */
  57. MPP30_GPIO,
  58. MPP31_GPIO,
  59. MPP32_GPIO,
  60. MPP33_GPIO,
  61. MPP34_GPIO, /* power key */
  62. MPP35_GPIO,
  63. MPP36_GPIO,
  64. MPP37_GPIO,
  65. MPP38_GPIO,
  66. MPP39_GPIO, /* enable sata 0 */
  67. MPP40_GPIO, /* enable sata 1 */
  68. MPP41_GPIO, /* hdd0 present */
  69. MPP42_GPIO, /* hdd1 present */
  70. MPP43_GPIO, /* usb status led */
  71. MPP44_GPIO, /* fan status */
  72. MPP45_GPIO, /* fan high speed */
  73. MPP46_GPIO, /* fan low speed */
  74. MPP47_GPIO, /* usb umount */
  75. MPP48_GPIO, /* factory reset */
  76. MPP49_GPIO, /* thermal sensor */
  77. 0
  78. };
  79. kirkwood_mpp_conf(kwmpp_config, NULL);
  80. kw_gpio_set_blink(DNS325_GPIO_LED_POWER , 1);
  81. kw_gpio_set_value(DNS325_GPIO_SATA0_EN , 1);
  82. return 0;
  83. }
  84. int board_init(void)
  85. {
  86. /* Boot parameters address */
  87. gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  88. return 0;
  89. }
  90. #ifdef CONFIG_RESET_PHY_R
  91. /* Configure and initialize PHY */
  92. void reset_phy(void)
  93. {
  94. u16 reg;
  95. u16 devadr;
  96. char *name = "egiga0";
  97. if (miiphy_set_current_dev(name))
  98. return;
  99. /* command to read PHY dev address */
  100. if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
  101. printf("Err..(%s) could not read PHY dev address\n", __func__);
  102. return;
  103. }
  104. /*
  105. * Enable RGMII delay on Tx and Rx for CPU port
  106. * Ref: sec 4.7.2 of chip datasheet
  107. */
  108. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
  109. miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
  110. reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
  111. miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
  112. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
  113. /* reset the phy */
  114. miiphy_reset(name, devadr);
  115. debug("88E1116 Initialized on %s\n", name);
  116. }
  117. #endif /* CONFIG_RESET_PHY_R */