p1023.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17. * MA 02111-1307 USA
  18. */
  19. #include <common.h>
  20. #include <phy.h>
  21. #include <fm_eth.h>
  22. #include <asm/io.h>
  23. #include <asm/immap_85xx.h>
  24. #include <asm/fsl_serdes.h>
  25. u32 port_to_devdisr[] = {
  26. [FM1_DTSEC1] = MPC85xx_DEVDISR_TSEC1,
  27. [FM1_DTSEC2] = MPC85xx_DEVDISR_TSEC2,
  28. };
  29. static int is_device_disabled(enum fm_port port)
  30. {
  31. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  32. u32 devdisr = in_be32(&gur->devdisr);
  33. return port_to_devdisr[port] & devdisr;
  34. }
  35. void fman_disable_port(enum fm_port port)
  36. {
  37. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  38. /* don't allow disabling of DTSEC1 as its needed for MDIO */
  39. if (port == FM1_DTSEC1)
  40. return;
  41. setbits_be32(&gur->devdisr, port_to_devdisr[port]);
  42. }
  43. phy_interface_t fman_port_enet_if(enum fm_port port)
  44. {
  45. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  46. u32 pordevsr = in_be32(&gur->pordevsr);
  47. if (is_device_disabled(port))
  48. return PHY_INTERFACE_MODE_NONE;
  49. /* DTSEC1 can be SGMII, RGMII or RMII */
  50. if (port == FM1_DTSEC1) {
  51. if (is_serdes_configured(SGMII_FM1_DTSEC1))
  52. return PHY_INTERFACE_MODE_SGMII;
  53. if (pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS) {
  54. if (pordevsr & MPC85xx_PORDEVSR_TSEC1_PRTC)
  55. return PHY_INTERFACE_MODE_RGMII;
  56. else
  57. return PHY_INTERFACE_MODE_RMII;
  58. }
  59. }
  60. /* DTSEC2 only supports SGMII or RGMII */
  61. if (port == FM1_DTSEC2) {
  62. if (is_serdes_configured(SGMII_FM1_DTSEC2))
  63. return PHY_INTERFACE_MODE_SGMII;
  64. if (pordevsr & MPC85xx_PORDEVSR_SGMII2_DIS)
  65. return PHY_INTERFACE_MODE_RGMII;
  66. }
  67. return PHY_INTERFACE_MODE_NONE;
  68. }