eth.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2013 Keymile AG
  4. * Valentin Longchamp <valentin.longchamp@keymile.com>
  5. */
  6. #include <common.h>
  7. #include <netdev.h>
  8. #include <fm_eth.h>
  9. #include <fsl_mdio.h>
  10. #include <phy.h>
  11. int board_eth_init(bd_t *bis)
  12. {
  13. int ret = 0;
  14. #ifdef CONFIG_FMAN_ENET
  15. struct fsl_pq_mdio_info dtsec_mdio_info;
  16. printf("Initializing Fman\n");
  17. dtsec_mdio_info.regs =
  18. (struct tsec_mii_mng *)CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR;
  19. dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
  20. /* Register the real 1G MDIO bus */
  21. fsl_pq_mdio_init(bis, &dtsec_mdio_info);
  22. /* DTESC1/2 don't have a PHY, they are temporarily disabled
  23. * so that u-boot doesn't try to unsuccessfuly enable them */
  24. fm_disable_port(FM1_DTSEC1);
  25. fm_disable_port(FM1_DTSEC2);
  26. /*
  27. * Program RGMII DTSEC5 (FM1 MAC5) on the EC2 physical itf
  28. * This is the debug interface, the only one used in u-boot
  29. */
  30. fm_info_set_phy_address(FM1_DTSEC5, CONFIG_SYS_FM1_DTSEC5_PHY_ADDR);
  31. fm_info_set_mdio(FM1_DTSEC5,
  32. miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
  33. ret = cpu_eth_init(bis);
  34. /* reenable DTSEC1/2 for later (kernel) */
  35. fm_enable_port(FM1_DTSEC1);
  36. fm_enable_port(FM1_DTSEC2);
  37. #endif
  38. return ret;
  39. }
  40. #if defined(CONFIG_PHYLIB) && defined(CONFIG_PHY_MARVELL)
  41. #define mv88E1118_PAGE_REG 22
  42. int board_phy_config(struct phy_device *phydev)
  43. {
  44. if (phydev->addr == CONFIG_SYS_FM1_DTSEC5_PHY_ADDR) {
  45. /* driver config is good */
  46. if (phydev->drv->config)
  47. phydev->drv->config(phydev);
  48. /* but we still need to fix the LEDs */
  49. phy_write(phydev, MDIO_DEVAD_NONE, mv88E1118_PAGE_REG, 0x0003);
  50. phy_write(phydev, MDIO_DEVAD_NONE, 0x10, 0x0840);
  51. phy_write(phydev, MDIO_DEVAD_NONE, mv88E1118_PAGE_REG, 0x0000);
  52. }
  53. return 0;
  54. }
  55. #endif