x600.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * (C) Copyright 2009
  3. * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
  4. *
  5. * Copyright (C) 2012 Stefan Roese <sr@denx.de>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <micrel.h>
  11. #include <nand.h>
  12. #include <netdev.h>
  13. #include <phy.h>
  14. #include <rtc.h>
  15. #include <asm/io.h>
  16. #include <asm/arch/hardware.h>
  17. #include <asm/arch/spr_defs.h>
  18. #include <asm/arch/spr_misc.h>
  19. #include <linux/mtd/fsmc_nand.h>
  20. #include "fpga.h"
  21. static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
  22. int board_init(void)
  23. {
  24. /*
  25. * X600 is equipped with an M41T82 RTC. This RTC has the
  26. * HT bit (Halt Update), which needs to be cleared upon
  27. * power-up. Otherwise the RTC is halted.
  28. */
  29. rtc_reset();
  30. return spear_board_init(MACH_TYPE_SPEAR600);
  31. }
  32. int board_late_init(void)
  33. {
  34. /*
  35. * Monitor and env protection on by default
  36. */
  37. flash_protect(FLAG_PROTECT_SET,
  38. CONFIG_SYS_FLASH_BASE, CONFIG_SYS_FLASH_BASE +
  39. CONFIG_SYS_SPL_LEN + CONFIG_SYS_MONITOR_LEN +
  40. 2 * CONFIG_ENV_SECT_SIZE - 1,
  41. &flash_info[0]);
  42. /* Init FPGA subsystem */
  43. x600_init_fpga();
  44. return 0;
  45. }
  46. /*
  47. * board_nand_init - Board specific NAND initialization
  48. * @nand: mtd private chip structure
  49. *
  50. * Called by nand_init_chip to initialize the board specific functions
  51. */
  52. void board_nand_init(void)
  53. {
  54. struct misc_regs *const misc_regs_p =
  55. (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
  56. struct nand_chip *nand = &nand_chip[0];
  57. if (!(readl(&misc_regs_p->auto_cfg_reg) & MISC_NANDDIS))
  58. fsmc_nand_init(nand);
  59. }
  60. int board_phy_config(struct phy_device *phydev)
  61. {
  62. unsigned short id1, id2;
  63. /* check whether KSZ9031 or AR8035 has to be configured */
  64. id1 = phy_read(phydev, MDIO_DEVAD_NONE, 2);
  65. id2 = phy_read(phydev, MDIO_DEVAD_NONE, 3);
  66. if ((id1 == 0x22) && ((id2 & 0xFFF0) == 0x1620)) {
  67. /* PHY configuration for Micrel KSZ9031 */
  68. printf("PHY KSZ9031 detected - ");
  69. phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, 0x1c00);
  70. /* control data pad skew - devaddr = 0x02, register = 0x04 */
  71. ksz9031_phy_extended_write(phydev, 0x02,
  72. MII_KSZ9031_EXT_RGMII_CTRL_SIG_SKEW,
  73. MII_KSZ9031_MOD_DATA_NO_POST_INC,
  74. 0x0000);
  75. /* rx data pad skew - devaddr = 0x02, register = 0x05 */
  76. ksz9031_phy_extended_write(phydev, 0x02,
  77. MII_KSZ9031_EXT_RGMII_RX_DATA_SKEW,
  78. MII_KSZ9031_MOD_DATA_NO_POST_INC,
  79. 0x0000);
  80. /* tx data pad skew - devaddr = 0x02, register = 0x05 */
  81. ksz9031_phy_extended_write(phydev, 0x02,
  82. MII_KSZ9031_EXT_RGMII_TX_DATA_SKEW,
  83. MII_KSZ9031_MOD_DATA_NO_POST_INC,
  84. 0x0000);
  85. /* gtx and rx clock pad skew - devaddr = 0x02, reg = 0x08 */
  86. ksz9031_phy_extended_write(phydev, 0x02,
  87. MII_KSZ9031_EXT_RGMII_CLOCK_SKEW,
  88. MII_KSZ9031_MOD_DATA_NO_POST_INC,
  89. 0x03FF);
  90. } else {
  91. /* PHY configuration for Vitesse VSC8641 */
  92. printf("PHY VSC8641 detected - ");
  93. /* Extended PHY control 1, select GMII */
  94. phy_write(phydev, MDIO_DEVAD_NONE, 23, 0x0020);
  95. /* Software reset necessary after GMII mode selction */
  96. phy_reset(phydev);
  97. /* Enable extended page register access */
  98. phy_write(phydev, MDIO_DEVAD_NONE, 31, 0x0001);
  99. /* 17e: Enhanced LED behavior, needs to be written twice */
  100. phy_write(phydev, MDIO_DEVAD_NONE, 17, 0x09ff);
  101. phy_write(phydev, MDIO_DEVAD_NONE, 17, 0x09ff);
  102. /* 16e: Enhanced LED method select */
  103. phy_write(phydev, MDIO_DEVAD_NONE, 16, 0xe0ea);
  104. /* Disable extended page register access */
  105. phy_write(phydev, MDIO_DEVAD_NONE, 31, 0x0000);
  106. /* Enable clock output pin */
  107. phy_write(phydev, MDIO_DEVAD_NONE, 18, 0x0049);
  108. }
  109. if (phydev->drv->config)
  110. phydev->drv->config(phydev);
  111. return 0;
  112. }
  113. int board_eth_init(bd_t *bis)
  114. {
  115. int ret = 0;
  116. if (designware_initialize(CONFIG_SPEAR_ETHBASE,
  117. PHY_INTERFACE_MODE_GMII) >= 0)
  118. ret++;
  119. return ret;
  120. }