p3060_serdes.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <asm/io.h>
  24. #include <asm/fsl_serdes.h>
  25. #include <asm/processor.h>
  26. #include <asm/io.h>
  27. #include "fsl_corenet_serdes.h"
  28. static u8 serdes_cfg_tbl[][SRDS_MAX_LANES] = {
  29. [0x03] = {PCIE1, PCIE1, PCIE1, PCIE1, PCIE2, PCIE2, PCIE2, PCIE2,
  30. SGMII_FM2_DTSEC4, SGMII_FM1_DTSEC4, SGMII_FM2_DTSEC1,
  31. SGMII_FM1_DTSEC1, SGMII_FM2_DTSEC2, SGMII_FM1_DTSEC2,
  32. NONE, NONE, AURORA, AURORA},
  33. [0x06] = {PCIE1, PCIE1, PCIE1, PCIE1, NONE, NONE, SGMII_FM2_DTSEC3,
  34. SGMII_FM1_DTSEC3, SGMII_FM2_DTSEC4, SGMII_FM1_DTSEC4,
  35. SGMII_FM2_DTSEC1, SGMII_FM1_DTSEC1, SGMII_FM2_DTSEC2,
  36. SGMII_FM1_DTSEC2, NONE, NONE, AURORA, AURORA},
  37. [0x16] = {SRIO2, SRIO2, SRIO2, SRIO2, SRIO1, SRIO1, SRIO1, SRIO1,
  38. AURORA, AURORA, SGMII_FM2_DTSEC1, SGMII_FM1_DTSEC1,
  39. SGMII_FM2_DTSEC2, SGMII_FM1_DTSEC2, SGMII_FM2_DTSEC3,
  40. SGMII_FM1_DTSEC3, SGMII_FM2_DTSEC4, SGMII_FM1_DTSEC4},
  41. [0x19] = {SRIO2, SRIO2, SRIO2, SRIO2, SRIO1, SRIO1, SRIO1, SRIO1,
  42. AURORA, AURORA, PCIE2, PCIE2, PCIE2, PCIE2, SGMII_FM2_DTSEC3,
  43. SGMII_FM1_DTSEC3, SGMII_FM2_DTSEC4, SGMII_FM1_DTSEC4},
  44. [0x1c] = {NONE, NONE, SRIO1, SRIO2, NONE, NONE, NONE, NONE,
  45. AURORA, AURORA, SGMII_FM2_DTSEC1, SGMII_FM1_DTSEC1,
  46. SGMII_FM2_DTSEC2, SGMII_FM1_DTSEC2, SGMII_FM2_DTSEC3,
  47. SGMII_FM1_DTSEC3, SGMII_FM2_DTSEC4, SGMII_FM1_DTSEC4},
  48. };
  49. enum srds_prtcl serdes_get_prtcl(int cfg, int lane)
  50. {
  51. if (!serdes_lane_enabled(lane))
  52. return NONE;
  53. return serdes_cfg_tbl[cfg][lane];
  54. }
  55. int is_serdes_prtcl_valid(u32 prtcl)
  56. {
  57. int i;
  58. if (prtcl > ARRAY_SIZE(serdes_cfg_tbl))
  59. return 0;
  60. for (i = 0; i < SRDS_MAX_LANES; i++) {
  61. if (serdes_cfg_tbl[prtcl][i] != NONE)
  62. return 1;
  63. }
  64. return 0;
  65. }
  66. void soc_serdes_init(void)
  67. {
  68. /*
  69. * On the P3060 the devdisr2 register does not correctly reflect
  70. * the state of the MACs based on the RCW fields. So disable the MACs
  71. * based on the srds_prtcl and ec1, ec2, ec3 fields
  72. */
  73. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  74. u32 devdisr2 = in_be32(&gur->devdisr2);
  75. u32 rcwsr11 = in_be32(&gur->rcwsr[11]);
  76. /* NOTE: Leave FM1-1,FM1-2 alone for MDIO access */
  77. if (!is_serdes_configured(SGMII_FM1_DTSEC3))
  78. devdisr2 |= FSL_CORENET_DEVDISR2_DTSEC1_3;
  79. if (!is_serdes_configured(SGMII_FM1_DTSEC4))
  80. devdisr2 |= FSL_CORENET_DEVDISR2_DTSEC1_4;
  81. if (!is_serdes_configured(SGMII_FM2_DTSEC1))
  82. devdisr2 |= FSL_CORENET_DEVDISR2_DTSEC2_1;
  83. if (!is_serdes_configured(SGMII_FM2_DTSEC2))
  84. devdisr2 |= FSL_CORENET_DEVDISR2_DTSEC2_2;
  85. if (!is_serdes_configured(SGMII_FM2_DTSEC3))
  86. devdisr2 |= FSL_CORENET_DEVDISR2_DTSEC2_3;
  87. if (!is_serdes_configured(SGMII_FM2_DTSEC4))
  88. devdisr2 |= FSL_CORENET_DEVDISR2_DTSEC2_4;
  89. if ((rcwsr11 & FSL_CORENET_RCWSR11_EC2) ==
  90. FSL_CORENET_RCWSR11_EC2_FM1_DTSEC2) {
  91. devdisr2 &= ~FSL_CORENET_DEVDISR2_DTSEC1_2;
  92. }
  93. if ((rcwsr11 & FSL_CORENET_RCWSR11_EC2) ==
  94. FSL_CORENET_RCWSR11_EC2_FM2_DTSEC1) {
  95. devdisr2 &= ~FSL_CORENET_DEVDISR2_DTSEC2_1;
  96. }
  97. out_be32(&gur->devdisr2, devdisr2);
  98. }