eth.c 1.7 KB

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