edminiv2.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (C) 2010 Albert ARIBAUD <albert.u.boot@aribaud.net>
  3. *
  4. * (C) Copyright 2009
  5. * Marvell Semiconductor <www.marvell.com>
  6. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  24. * MA 02110-1301 USA
  25. */
  26. #include <common.h>
  27. #include <miiphy.h>
  28. #include <asm/arch/orion5x.h>
  29. #include "edminiv2.h"
  30. DECLARE_GLOBAL_DATA_PTR;
  31. /*
  32. * The ED Mini V2 is equipped with a Macronix MXLV400CB FLASH
  33. * which CFI does not properly detect, hence the LEGACY config.
  34. */
  35. #if defined(CONFIG_FLASH_CFI_LEGACY)
  36. #include <flash.h>
  37. ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
  38. {
  39. int sectsz[] = CONFIG_SYS_FLASH_SECTSZ;
  40. int sect;
  41. if (base != CONFIG_SYS_FLASH_BASE)
  42. return 0;
  43. info->size = 0;
  44. info->sector_count = CONFIG_SYS_MAX_FLASH_SECT;
  45. /* set each sector's start address and size based */
  46. for (sect = 0; sect < CONFIG_SYS_MAX_FLASH_SECT; sect++) {
  47. info->start[sect] = base+info->size;
  48. info->size += sectsz[sect];
  49. }
  50. /* This flash must be accessed in 8-bits mode, no buffer. */
  51. info->flash_id = 0x01000000;
  52. info->portwidth = FLASH_CFI_8BIT;
  53. info->chipwidth = FLASH_CFI_BY8;
  54. info->buffer_size = 0;
  55. /* timings are derived from the Macronix datasheet. */
  56. info->erase_blk_tout = 1000;
  57. info->write_tout = 10;
  58. info->buffer_write_tout = 300;
  59. /* Commands and addresses are for AMD mode 8-bit access. */
  60. info->vendor = CFI_CMDSET_AMD_LEGACY;
  61. info->cmd_reset = 0xF0;
  62. info->interface = FLASH_CFI_X8;
  63. info->legacy_unlock = 0;
  64. info->ext_addr = 0;
  65. info->addr_unlock1 = 0x00000aaa;
  66. info->addr_unlock2 = 0x00000555;
  67. /* Manufacturer Macronix, device MX29LV400CB, CFI 1.3. */
  68. info->manufacturer_id = 0x22;
  69. info->device_id = 0xBA;
  70. info->device_id2 = 0;
  71. info->cfi_version = 0x3133;
  72. info->cfi_offset = 0x0000;
  73. info->name = "MX29LV400CB";
  74. return 1;
  75. }
  76. #endif /* CONFIG_SYS_FLASH_CFI */
  77. int board_init(void)
  78. {
  79. /* arch number of board */
  80. gd->bd->bi_arch_number = MACH_TYPE_EDMINI_V2;
  81. /* boot parameter start at 256th byte of RAM base */
  82. gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
  83. return 0;
  84. }
  85. #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
  86. /* Configure and enable MV88E1116 PHY */
  87. void reset_phy(void)
  88. {
  89. u16 reg;
  90. u16 devadr;
  91. char *name = "egiga0";
  92. if (miiphy_set_current_dev(name))
  93. return;
  94. /* command to read PHY dev address */
  95. if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
  96. printf("Err..%s could not read PHY dev address\n",
  97. __func__);
  98. return;
  99. }
  100. /*
  101. * Enable RGMII delay on Tx and Rx for CPU port
  102. * Ref: sec 4.7.2 of chip datasheet
  103. */
  104. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
  105. miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
  106. reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
  107. miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
  108. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
  109. /* reset the phy */
  110. miiphy_reset(name, devadr);
  111. printf("88E1116 Initialized on %s\n", name);
  112. }
  113. #endif /* CONFIG_RESET_PHY_R */