dns325.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (C) 2011
  3. * Stefan Herbrechtsmeier <stefan@code.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. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  26. * MA 02110-1301 USA
  27. */
  28. #include <common.h>
  29. #include <miiphy.h>
  30. #include <netdev.h>
  31. #include <asm/arch/cpu.h>
  32. #include <asm/arch/kirkwood.h>
  33. #include <asm/arch/mpp.h>
  34. #include <asm/arch/gpio.h>
  35. #include "dns325.h"
  36. DECLARE_GLOBAL_DATA_PTR;
  37. int board_early_init_f(void)
  38. {
  39. /* Gpio configuration */
  40. kw_config_gpio(DNS325_OE_VAL_LOW, DNS325_OE_VAL_HIGH,
  41. DNS325_OE_LOW, DNS325_OE_HIGH);
  42. /* Multi-Purpose Pins Functionality configuration */
  43. u32 kwmpp_config[] = {
  44. MPP0_NF_IO2,
  45. MPP1_NF_IO3,
  46. MPP2_NF_IO4,
  47. MPP3_NF_IO5,
  48. MPP4_NF_IO6,
  49. MPP5_NF_IO7,
  50. MPP6_SYSRST_OUTn,
  51. MPP7_GPO,
  52. MPP8_TW_SDA,
  53. MPP9_TW_SCK,
  54. MPP10_UART0_TXD,
  55. MPP11_UART0_RXD,
  56. MPP12_SD_CLK,
  57. MPP13_SD_CMD,
  58. MPP14_SD_D0,
  59. MPP15_SD_D1,
  60. MPP16_SD_D2,
  61. MPP17_SD_D3,
  62. MPP18_NF_IO0,
  63. MPP19_NF_IO1,
  64. MPP20_SATA1_ACTn, /* sata1(left) status led */
  65. MPP21_SATA0_ACTn, /* sata0(right) status led */
  66. MPP22_GPIO,
  67. MPP23_GPIO,
  68. MPP24_GPIO, /* power off out */
  69. MPP25_GPIO,
  70. MPP26_GPIO, /* power led */
  71. MPP27_GPIO, /* sata0(right) error led */
  72. MPP28_GPIO, /* sata1(left) error led */
  73. MPP29_GPIO, /* usb error led */
  74. MPP30_GPIO,
  75. MPP31_GPIO,
  76. MPP32_GPIO,
  77. MPP33_GPIO,
  78. MPP34_GPIO, /* power key */
  79. MPP35_GPIO,
  80. MPP36_GPIO,
  81. MPP37_GPIO,
  82. MPP38_GPIO,
  83. MPP39_GPIO, /* enable sata 0 */
  84. MPP40_GPIO, /* enable sata 1 */
  85. MPP41_GPIO, /* hdd0 present */
  86. MPP42_GPIO, /* hdd1 present */
  87. MPP43_GPIO, /* usb status led */
  88. MPP44_GPIO, /* fan status */
  89. MPP45_GPIO, /* fan high speed */
  90. MPP46_GPIO, /* fan low speed */
  91. MPP47_GPIO, /* usb umount */
  92. MPP48_GPIO, /* factory reset */
  93. MPP49_GPIO, /* thermal sensor */
  94. 0
  95. };
  96. kirkwood_mpp_conf(kwmpp_config);
  97. kw_gpio_set_blink(DNS325_GPIO_LED_POWER , 1);
  98. kw_gpio_set_value(DNS325_GPIO_SATA0_EN , 1);
  99. return 0;
  100. }
  101. int board_init(void)
  102. {
  103. /* Boot parameters address */
  104. gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
  105. return 0;
  106. }
  107. #ifdef CONFIG_RESET_PHY_R
  108. /* Configure and initialize PHY */
  109. void reset_phy(void)
  110. {
  111. u16 reg;
  112. u16 devadr;
  113. char *name = "egiga0";
  114. if (miiphy_set_current_dev(name))
  115. return;
  116. /* command to read PHY dev address */
  117. if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
  118. printf("Err..(%s) could not read PHY dev address\n", __func__);
  119. return;
  120. }
  121. /*
  122. * Enable RGMII delay on Tx and Rx for CPU port
  123. * Ref: sec 4.7.2 of chip datasheet
  124. */
  125. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
  126. miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
  127. reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
  128. miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
  129. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
  130. /* reset the phy */
  131. miiphy_reset(name, devadr);
  132. debug("88E1116 Initialized on %s\n", name);
  133. }
  134. #endif /* CONFIG_RESET_PHY_R */