socfpga.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (C) 2012 Altera Corporation <www.altera.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/arch/reset_manager.h>
  8. #include <asm/io.h>
  9. #include <usb.h>
  10. #include <usb/dwc2_udc.h>
  11. #include <usb_mass_storage.h>
  12. #include <micrel.h>
  13. #include <netdev.h>
  14. #include <phy.h>
  15. DECLARE_GLOBAL_DATA_PTR;
  16. void s_init(void) {}
  17. /*
  18. * Miscellaneous platform dependent initialisations
  19. */
  20. int board_init(void)
  21. {
  22. /* Address of boot parameters for ATAG (if ATAG is used) */
  23. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  24. return 0;
  25. }
  26. /*
  27. * PHY configuration
  28. */
  29. #ifdef CONFIG_PHY_MICREL_KSZ9021
  30. int board_phy_config(struct phy_device *phydev)
  31. {
  32. int ret;
  33. /*
  34. * These skew settings for the KSZ9021 ethernet phy is required for ethernet
  35. * to work reliably on most flavors of cyclone5 boards.
  36. */
  37. ret = ksz9021_phy_extended_write(phydev,
  38. MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW,
  39. 0x0);
  40. if (ret)
  41. return ret;
  42. ret = ksz9021_phy_extended_write(phydev,
  43. MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW,
  44. 0x0);
  45. if (ret)
  46. return ret;
  47. ret = ksz9021_phy_extended_write(phydev,
  48. MII_KSZ9021_EXT_RGMII_CLOCK_SKEW,
  49. 0xf0f0);
  50. if (ret)
  51. return ret;
  52. if (phydev->drv->config)
  53. return phydev->drv->config(phydev);
  54. return 0;
  55. }
  56. #endif
  57. #ifdef CONFIG_USB_GADGET
  58. struct dwc2_plat_otg_data socfpga_otg_data = {
  59. .regs_otg = CONFIG_USB_DWC2_REG_ADDR,
  60. .usb_gusbcfg = 0x1417,
  61. };
  62. int board_usb_init(int index, enum usb_init_type init)
  63. {
  64. return dwc2_udc_probe(&socfpga_otg_data);
  65. }
  66. int g_dnl_board_usb_cable_connected(void)
  67. {
  68. return 1;
  69. }
  70. #endif