pogo_e02.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 2012
  3. * David Purdy <david.c.purdy@gmail.com>
  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, see <http://www.gnu.org/licenses/>.
  25. */
  26. #include <common.h>
  27. #include <miiphy.h>
  28. #include <asm/arch/cpu.h>
  29. #include <asm/arch/kirkwood.h>
  30. #include <asm/arch/mpp.h>
  31. #include "pogo_e02.h"
  32. DECLARE_GLOBAL_DATA_PTR;
  33. int board_early_init_f(void)
  34. {
  35. /*
  36. * default gpio configuration
  37. * There are maximum 64 gpios controlled through 2 sets of registers
  38. * the below configuration configures mainly initial LED status
  39. */
  40. kw_config_gpio(POGO_E02_OE_VAL_LOW,
  41. POGO_E02_OE_VAL_HIGH,
  42. POGO_E02_OE_LOW, POGO_E02_OE_HIGH);
  43. /* Multi-Purpose Pins Functionality configuration */
  44. static const u32 kwmpp_config[] = {
  45. MPP0_NF_IO2,
  46. MPP1_NF_IO3,
  47. MPP2_NF_IO4,
  48. MPP3_NF_IO5,
  49. MPP4_NF_IO6,
  50. MPP5_NF_IO7,
  51. MPP6_SYSRST_OUTn,
  52. MPP7_GPO,
  53. MPP8_UART0_RTS,
  54. MPP9_UART0_CTS,
  55. MPP10_UART0_TXD,
  56. MPP11_UART0_RXD,
  57. MPP12_SD_CLK,
  58. MPP13_SD_CMD,
  59. MPP14_SD_D0,
  60. MPP15_SD_D1,
  61. MPP16_SD_D2,
  62. MPP17_SD_D3,
  63. MPP18_NF_IO0,
  64. MPP19_NF_IO1,
  65. MPP29_TSMP9, /* USB Power Enable */
  66. MPP48_GPIO, /* LED green */
  67. MPP49_GPIO, /* LED orange */
  68. 0
  69. };
  70. kirkwood_mpp_conf(kwmpp_config, NULL);
  71. return 0;
  72. }
  73. int board_init(void)
  74. {
  75. /* Boot parameters address */
  76. gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
  77. return 0;
  78. }
  79. #ifdef CONFIG_RESET_PHY_R
  80. /* Configure and initialize 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. debug("88E1116 Initialized on %s\n", name);
  105. }
  106. #endif /* CONFIG_RESET_PHY_R */