p3060.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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] = FSL_CORENET_DEVDISR2_DTSEC1_1,
  27. [FM1_DTSEC2] = FSL_CORENET_DEVDISR2_DTSEC1_2,
  28. [FM1_DTSEC3] = FSL_CORENET_DEVDISR2_DTSEC1_3,
  29. [FM1_DTSEC4] = FSL_CORENET_DEVDISR2_DTSEC1_4,
  30. [FM2_DTSEC1] = FSL_CORENET_DEVDISR2_DTSEC2_1,
  31. [FM2_DTSEC2] = FSL_CORENET_DEVDISR2_DTSEC2_2,
  32. [FM2_DTSEC3] = FSL_CORENET_DEVDISR2_DTSEC2_3,
  33. [FM2_DTSEC4] = FSL_CORENET_DEVDISR2_DTSEC2_4,
  34. };
  35. static int is_device_disabled(enum fm_port port)
  36. {
  37. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  38. u32 devdisr2 = in_be32(&gur->devdisr2);
  39. return port_to_devdisr[port] & devdisr2;
  40. }
  41. void fman_disable_port(enum fm_port port)
  42. {
  43. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  44. /* don't allow disabling of DTSEC1 as its needed for MDIO */
  45. if (port == FM1_DTSEC1)
  46. return;
  47. setbits_be32(&gur->devdisr2, port_to_devdisr[port]);
  48. }
  49. phy_interface_t fman_port_enet_if(enum fm_port port)
  50. {
  51. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  52. u32 rcwsr11 = in_be32(&gur->rcwsr[11]);
  53. if (is_device_disabled(port))
  54. return PHY_INTERFACE_MODE_NONE;
  55. /* handle RGMII/MII first */
  56. if ((port == FM1_DTSEC1) && ((rcwsr11 & FSL_CORENET_RCWSR11_EC1) ==
  57. FSL_CORENET_RCWSR11_EC1_FM1_DTSEC1))
  58. return PHY_INTERFACE_MODE_RGMII;
  59. if ((port == FM1_DTSEC2) && ((rcwsr11 & FSL_CORENET_RCWSR11_EC2) ==
  60. FSL_CORENET_RCWSR11_EC2_FM1_DTSEC2))
  61. return PHY_INTERFACE_MODE_RGMII;
  62. if ((port == FM2_DTSEC1) && ((rcwsr11 & FSL_CORENET_RCWSR11_EC2) ==
  63. FSL_CORENET_RCWSR11_EC2_FM2_DTSEC1))
  64. return PHY_INTERFACE_MODE_RGMII;
  65. switch (port) {
  66. case FM1_DTSEC1:
  67. case FM1_DTSEC2:
  68. case FM1_DTSEC3:
  69. case FM1_DTSEC4:
  70. if (is_serdes_configured(SGMII_FM1_DTSEC1 + port - FM1_DTSEC1))
  71. return PHY_INTERFACE_MODE_SGMII;
  72. break;
  73. case FM2_DTSEC1:
  74. case FM2_DTSEC2:
  75. case FM2_DTSEC3:
  76. case FM2_DTSEC4:
  77. if (is_serdes_configured(SGMII_FM2_DTSEC1 + port - FM2_DTSEC1))
  78. return PHY_INTERFACE_MODE_SGMII;
  79. break;
  80. default:
  81. return PHY_INTERFACE_MODE_NONE;
  82. }
  83. return PHY_INTERFACE_MODE_NONE;
  84. }