liodn.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * Copyright 2008-2010 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 <libfdt.h>
  24. #include <fdt_support.h>
  25. #include <asm/immap_85xx.h>
  26. #include <asm/io.h>
  27. #include <asm/processor.h>
  28. #include <asm/fsl_portals.h>
  29. #include <asm/fsl_liodn.h>
  30. int get_dpaa_liodn(enum fsl_dpaa_dev dpaa_dev, u32 *liodns, int liodn_offset)
  31. {
  32. liodns[0] = liodn_bases[dpaa_dev].id[0] + liodn_offset;
  33. if (liodn_bases[dpaa_dev].num_ids == 2)
  34. liodns[1] = liodn_bases[dpaa_dev].id[1] + liodn_offset;
  35. return liodn_bases[dpaa_dev].num_ids;
  36. }
  37. static void set_liodn(struct liodn_id_table *tbl, int size)
  38. {
  39. int i;
  40. for (i = 0; i < size; i++) {
  41. u32 liodn;
  42. if (tbl[i].num_ids == 2) {
  43. liodn = (tbl[i].id[0] << 16) | tbl[i].id[1];
  44. } else {
  45. liodn = tbl[i].id[0];
  46. }
  47. out_be32((volatile u32 *)(tbl[i].reg_offset), liodn);
  48. }
  49. }
  50. static void setup_sec_liodn_base(void)
  51. {
  52. ccsr_sec_t *sec = (void *)CONFIG_SYS_FSL_SEC_ADDR;
  53. u32 base;
  54. if (!IS_E_PROCESSOR(get_svr()))
  55. return;
  56. /* QILCR[QSLOM] */
  57. out_be32(&sec->qilcr_ms, 0x3ff<<16);
  58. base = (liodn_bases[FSL_HW_PORTAL_SEC].id[0] << 16) |
  59. liodn_bases[FSL_HW_PORTAL_SEC].id[1];
  60. out_be32(&sec->qilcr_ls, base);
  61. }
  62. #ifdef CONFIG_SYS_DPAA_FMAN
  63. static void setup_fman_liodn_base(enum fsl_dpaa_dev dev,
  64. struct liodn_id_table *tbl, int size)
  65. {
  66. int i;
  67. ccsr_fman_t *fm;
  68. u32 base;
  69. switch(dev) {
  70. case FSL_HW_PORTAL_FMAN1:
  71. fm = (void *)CONFIG_SYS_FSL_FM1_ADDR;
  72. break;
  73. #if (CONFIG_SYS_NUM_FMAN == 2)
  74. case FSL_HW_PORTAL_FMAN2:
  75. fm = (void *)CONFIG_SYS_FSL_FM2_ADDR;
  76. break;
  77. #endif
  78. default:
  79. printf("Error: Invalid device type to %s\n", __FUNCTION__);
  80. return ;
  81. }
  82. base = (liodn_bases[dev].id[0] << 16) | liodn_bases[dev].id[0];
  83. /* setup all bases the same */
  84. for (i = 0; i < 32; i++) {
  85. out_be32(&fm->fm_dma.fmdmplr[i], base);
  86. }
  87. /* update tbl to ... */
  88. for (i = 0; i < size; i++)
  89. tbl[i].id[0] += liodn_bases[dev].id[0];
  90. }
  91. #endif
  92. static void setup_pme_liodn_base(void)
  93. {
  94. #ifdef CONFIG_SYS_DPAA_PME
  95. ccsr_pme_t *pme = (void *)CONFIG_SYS_FSL_CORENET_PME_ADDR;
  96. u32 base = (liodn_bases[FSL_HW_PORTAL_PME].id[0] << 16) |
  97. liodn_bases[FSL_HW_PORTAL_PME].id[1];
  98. out_be32(&pme->liodnbr, base);
  99. #endif
  100. }
  101. void set_liodns(void)
  102. {
  103. /* setup general liodn offsets */
  104. set_liodn(liodn_tbl, liodn_tbl_sz);
  105. /* setup SEC block liodn bases & offsets if we have one */
  106. if (IS_E_PROCESSOR(get_svr())) {
  107. set_liodn(sec_liodn_tbl, sec_liodn_tbl_sz);
  108. setup_sec_liodn_base();
  109. }
  110. /* setup FMAN block(s) liodn bases & offsets if we have one */
  111. #ifdef CONFIG_SYS_DPAA_FMAN
  112. set_liodn(fman1_liodn_tbl, fman1_liodn_tbl_sz);
  113. setup_fman_liodn_base(FSL_HW_PORTAL_FMAN1, fman1_liodn_tbl,
  114. fman1_liodn_tbl_sz);
  115. #if (CONFIG_SYS_NUM_FMAN == 2)
  116. set_liodn(fman2_liodn_tbl, fman2_liodn_tbl_sz);
  117. setup_fman_liodn_base(FSL_HW_PORTAL_FMAN2, fman2_liodn_tbl,
  118. fman2_liodn_tbl_sz);
  119. #endif
  120. #endif
  121. /* setup PME liodn base */
  122. setup_pme_liodn_base();
  123. }
  124. static void fdt_fixup_liodn_tbl(void *blob, struct liodn_id_table *tbl, int sz)
  125. {
  126. int i;
  127. for (i = 0; i < sz; i++) {
  128. int off;
  129. if (tbl[i].compat == NULL)
  130. continue;
  131. off = fdt_node_offset_by_compat_reg(blob,
  132. tbl[i].compat, tbl[i].compat_offset);
  133. if (off >= 0) {
  134. off = fdt_setprop(blob, off, "fsl,liodn",
  135. &tbl[i].id[0],
  136. sizeof(u32) * tbl[i].num_ids);
  137. if (off > 0)
  138. printf("WARNING unable to set fsl,liodn for "
  139. "%s: %s\n",
  140. tbl[i].compat, fdt_strerror(off));
  141. } else {
  142. debug("WARNING: could not set fsl,liodn for %s: %s.\n",
  143. tbl[i].compat, fdt_strerror(off));
  144. }
  145. }
  146. }
  147. void fdt_fixup_liodn(void *blob)
  148. {
  149. fdt_fixup_liodn_tbl(blob, liodn_tbl, liodn_tbl_sz);
  150. #ifdef CONFIG_SYS_DPAA_FMAN
  151. fdt_fixup_liodn_tbl(blob, fman1_liodn_tbl, fman1_liodn_tbl_sz);
  152. #if (CONFIG_SYS_NUM_FMAN == 2)
  153. fdt_fixup_liodn_tbl(blob, fman2_liodn_tbl, fman2_liodn_tbl_sz);
  154. #endif
  155. #endif
  156. fdt_fixup_liodn_tbl(blob, sec_liodn_tbl, sec_liodn_tbl_sz);
  157. }