dns325.c 3.0 KB

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