srio.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 2 of the License, or (at your option)
  7. * 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 <config.h>
  21. #include <asm/fsl_law.h>
  22. #include <asm/fsl_serdes.h>
  23. #if defined(CONFIG_FSL_CORENET)
  24. #define _DEVDISR_SRIO1 FSL_CORENET_DEVDISR_SRIO1
  25. #define _DEVDISR_SRIO2 FSL_CORENET_DEVDISR_SRIO2
  26. #define _DEVDISR_RMU FSL_CORENET_DEVDISR_RMU
  27. #define CONFIG_SYS_MPC8xxx_GUTS_ADDR CONFIG_SYS_MPC85xx_GUTS_ADDR
  28. #elif defined(CONFIG_MPC85xx)
  29. #define _DEVDISR_SRIO1 MPC85xx_DEVDISR_SRIO
  30. #define _DEVDISR_SRIO2 MPC85xx_DEVDISR_SRIO
  31. #define _DEVDISR_RMU MPC85xx_DEVDISR_RMSG
  32. #define CONFIG_SYS_MPC8xxx_GUTS_ADDR CONFIG_SYS_MPC85xx_GUTS_ADDR
  33. #elif defined(CONFIG_MPC86xx)
  34. #define _DEVDISR_SRIO1 MPC86xx_DEVDISR_SRIO
  35. #define _DEVDISR_SRIO2 MPC86xx_DEVDISR_SRIO
  36. #define _DEVDISR_RMU MPC86xx_DEVDISR_RMSG
  37. #define CONFIG_SYS_MPC8xxx_GUTS_ADDR \
  38. (&((immap_t *)CONFIG_SYS_IMMR)->im_gur)
  39. #else
  40. #error "No defines for DEVDISR_SRIO"
  41. #endif
  42. void srio_init(void)
  43. {
  44. ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC8xxx_GUTS_ADDR;
  45. int srio1_used = 0, srio2_used = 0;
  46. if (is_serdes_configured(SRIO1)) {
  47. set_next_law(CONFIG_SYS_SRIO1_MEM_PHYS,
  48. law_size_bits(CONFIG_SYS_SRIO1_MEM_SIZE),
  49. LAW_TRGT_IF_RIO_1);
  50. srio1_used = 1;
  51. printf("SRIO1: enabled\n");
  52. } else {
  53. printf("SRIO1: disabled\n");
  54. }
  55. #ifdef CONFIG_SRIO2
  56. if (is_serdes_configured(SRIO2)) {
  57. set_next_law(CONFIG_SYS_SRIO2_MEM_PHYS,
  58. law_size_bits(CONFIG_SYS_SRIO2_MEM_SIZE),
  59. LAW_TRGT_IF_RIO_2);
  60. srio2_used = 1;
  61. printf("SRIO2: enabled\n");
  62. } else {
  63. printf("SRIO2: disabled\n");
  64. }
  65. #endif
  66. #ifdef CONFIG_FSL_CORENET
  67. /* On FSL_CORENET devices we can disable individual ports */
  68. if (!srio1_used)
  69. setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_SRIO1);
  70. if (!srio2_used)
  71. setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_SRIO2);
  72. #endif
  73. /* neither port is used - disable everything */
  74. if (!srio1_used && !srio2_used) {
  75. setbits_be32(&gur->devdisr, _DEVDISR_SRIO1);
  76. setbits_be32(&gur->devdisr, _DEVDISR_SRIO2);
  77. setbits_be32(&gur->devdisr, _DEVDISR_RMU);
  78. }
  79. }