fsl_liodn.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright 2009-2011 Freescale Semiconductor, Inc.
  4. */
  5. #ifndef _FSL_LIODN_H_
  6. #define _FSL_LIODN_H_
  7. #include <asm/types.h>
  8. #include <fsl_qbman.h>
  9. struct srio_liodn_id_table {
  10. u32 id[2];
  11. unsigned long reg_offset[2];
  12. u8 num_ids;
  13. u8 portid;
  14. };
  15. #define SET_SRIO_LIODN_1(port, idA) \
  16. { .id = { idA }, .num_ids = 1, .portid = port, \
  17. .reg_offset[0] = offsetof(ccsr_gur_t, rio##port##liodnr) \
  18. + CONFIG_SYS_MPC85xx_GUTS_OFFSET + CONFIG_SYS_CCSRBAR, \
  19. }
  20. #define SET_SRIO_LIODN_2(port, idA, idB) \
  21. { .id = { idA, idB }, .num_ids = 2, .portid = port, \
  22. .reg_offset[0] = offsetof(ccsr_gur_t, rio##port##liodnr) \
  23. + CONFIG_SYS_MPC85xx_GUTS_OFFSET + CONFIG_SYS_CCSRBAR, \
  24. .reg_offset[1] = offsetof(ccsr_gur_t, rio##port##maintliodnr) \
  25. + CONFIG_SYS_MPC85xx_GUTS_OFFSET + CONFIG_SYS_CCSRBAR, \
  26. }
  27. #define SET_SRIO_LIODN_BASE(port, id_a) \
  28. { .id = { id_a }, .num_ids = 1, .portid = port, \
  29. .reg_offset[0] = offsetof(struct ccsr_rio, liodn) \
  30. + (port - 1) * 0x200 \
  31. + CONFIG_SYS_FSL_SRIO_ADDR, \
  32. }
  33. struct liodn_id_table {
  34. const char * compat;
  35. u32 id[2];
  36. u8 num_ids;
  37. phys_addr_t compat_offset;
  38. unsigned long reg_offset;
  39. };
  40. struct fman_liodn_id_table {
  41. /* Freescale FMan Device Tree binding was updated for FMan.
  42. * We need to support both new and old compatibles in order not to
  43. * break backward compatibility.
  44. */
  45. const char *compat[2];
  46. u32 id[2];
  47. u8 num_ids;
  48. phys_addr_t compat_offset;
  49. unsigned long reg_offset;
  50. };
  51. extern u32 get_ppid_liodn(int ppid_tbl_idx, int ppid);
  52. extern void set_liodns(void);
  53. extern void fdt_fixup_liodn(void *blob);
  54. #define SET_LIODN_BASE_1(idA) \
  55. { .id = { idA }, .num_ids = 1, }
  56. #define SET_LIODN_BASE_2(idA, idB) \
  57. { .id = { idA, idB }, .num_ids = 2 }
  58. #define SET_FMAN_LIODN_ENTRY(name1, name2, idA, off, compatoff)\
  59. { .compat[0] = name1, \
  60. .compat[1] = name2, \
  61. .id = { idA }, .num_ids = 1, \
  62. .reg_offset = off + CONFIG_SYS_CCSRBAR, \
  63. .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \
  64. }
  65. #define SET_LIODN_ENTRY_1(name, idA, off, compatoff) \
  66. { .compat = name, \
  67. .id = { idA }, .num_ids = 1, \
  68. .reg_offset = off + CONFIG_SYS_CCSRBAR, \
  69. .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \
  70. }
  71. #define SET_LIODN_ENTRY_2(name, idA, idB, off, compatoff) \
  72. { .compat = name, \
  73. .id = { idA, idB }, .num_ids = 2, \
  74. .reg_offset = off + CONFIG_SYS_CCSRBAR, \
  75. .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \
  76. }
  77. #define SET_GUTS_LIODN(compat, liodn, name, compatoff) \
  78. SET_LIODN_ENTRY_1(compat, liodn, \
  79. offsetof(ccsr_gur_t, name) + CONFIG_SYS_MPC85xx_GUTS_OFFSET, \
  80. compatoff)
  81. #define SET_USB_LIODN(usbNum, compat, liodn) \
  82. SET_GUTS_LIODN(compat, liodn, usb##usbNum##liodnr,\
  83. CONFIG_SYS_MPC85xx_USB##usbNum##_OFFSET)
  84. #define SET_SATA_LIODN(sataNum, liodn) \
  85. SET_GUTS_LIODN("fsl,pq-sata-v2", liodn, sata##sataNum##liodnr,\
  86. CONFIG_SYS_MPC85xx_SATA##sataNum##_OFFSET)
  87. #define SET_PCI_LIODN(compat, pciNum, liodn) \
  88. SET_GUTS_LIODN(compat, liodn, pex##pciNum##liodnr,\
  89. CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET)
  90. #define SET_PCI_LIODN_BASE(compat, pciNum, liodn) \
  91. SET_LIODN_ENTRY_1(compat, liodn,\
  92. offsetof(ccsr_pcix_t, liodn_base) + CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET,\
  93. CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET)
  94. /* reg nodes for DMA start @ 0x300 */
  95. #define SET_DMA_LIODN(dmaNum, compat, liodn) \
  96. SET_GUTS_LIODN(compat, liodn, dma##dmaNum##liodnr,\
  97. CONFIG_SYS_MPC85xx_DMA##dmaNum##_OFFSET + 0x300)
  98. #define SET_SDHC_LIODN(sdhcNum, liodn) \
  99. SET_GUTS_LIODN("fsl,esdhc", liodn, sdmmc##sdhcNum##liodnr,\
  100. CONFIG_SYS_MPC85xx_ESDHC_OFFSET)
  101. #define SET_QE_LIODN(liodn) \
  102. SET_GUTS_LIODN("fsl,qe", liodn, qeliodnr,\
  103. CONFIG_SYS_MPC85xx_QE_OFFSET)
  104. #define SET_TDM_LIODN(liodn) \
  105. SET_GUTS_LIODN("fsl,tdm1.0", liodn, tdmliodnr,\
  106. CONFIG_SYS_MPC85xx_TDM_OFFSET)
  107. #define SET_QMAN_LIODN(liodn) \
  108. SET_LIODN_ENTRY_1("fsl,qman", liodn, \
  109. offsetof(struct ccsr_qman, liodnr) + \
  110. CONFIG_SYS_FSL_QMAN_OFFSET, \
  111. CONFIG_SYS_FSL_QMAN_OFFSET)
  112. #define SET_BMAN_LIODN(liodn) \
  113. SET_LIODN_ENTRY_1("fsl,bman", liodn, \
  114. offsetof(struct ccsr_bman, liodnr) + \
  115. CONFIG_SYS_FSL_BMAN_OFFSET, \
  116. CONFIG_SYS_FSL_BMAN_OFFSET)
  117. #define SET_PME_LIODN(liodn) \
  118. SET_LIODN_ENTRY_1("fsl,pme", liodn, offsetof(ccsr_pme_t, liodnr) + \
  119. CONFIG_SYS_FSL_CORENET_PME_OFFSET, \
  120. CONFIG_SYS_FSL_CORENET_PME_OFFSET)
  121. #define SET_PMAN_LIODN(num, liodn) \
  122. SET_LIODN_ENTRY_2("fsl,pman", liodn, 0, \
  123. offsetof(struct ccsr_pman, ppa1) + \
  124. CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET, \
  125. CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET)
  126. /* -1 from portID due to how immap has the registers */
  127. #define FM_PPID_RX_PORT_OFFSET(fmNum, portID) \
  128. CONFIG_SYS_FSL_FM##fmNum##_OFFSET + \
  129. offsetof(struct ccsr_fman, fm_bmi_common.fmbm_ppid[portID - 1])
  130. #ifdef CONFIG_SYS_FMAN_V3
  131. /* enetNum is 0, 1, 2... so we + 8 for 1g to get to HW Port ID */
  132. #define SET_FMAN_RX_1G_LIODN(fmNum, enetNum, liodn) \
  133. SET_FMAN_LIODN_ENTRY("fsl,fman-v3-port-rx", "fsl,fman-port-1g-rx", \
  134. liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \
  135. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET)
  136. /* enetNum is 0, 1, 2... so we + 16 for 10g to get to HW Port ID */
  137. #define SET_FMAN_RX_10G_LIODN(fmNum, enetNum, liodn) \
  138. SET_FMAN_LIODN_ENTRY("fsl,fman-v3-port-rx", "fsl,fman-port-10g-rx", \
  139. liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 16), \
  140. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_10G_OFFSET)
  141. /* enetNum is 0, 1, 2... so we + 8 for type-2 10g to get to HW Port ID */
  142. #define SET_FMAN_RX_10G_TYPE2_LIODN(fmNum, enetNum, liodn) \
  143. SET_FMAN_LIODN_ENTRY("fsl,fman-v3-port-rx", "fsl,fman-port-10g-rx", \
  144. liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \
  145. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET)
  146. #else
  147. /* enetNum is 0, 1, 2... so we + 8 for 1g to get to HW Port ID */
  148. #define SET_FMAN_RX_1G_LIODN(fmNum, enetNum, liodn) \
  149. SET_FMAN_LIODN_ENTRY("fsl,fman-v2-port-rx", "fsl,fman-port-1g-rx", \
  150. liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \
  151. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET)
  152. /* enetNum is 0, 1, 2... so we + 16 for 10g to get to HW Port ID */
  153. #define SET_FMAN_RX_10G_LIODN(fmNum, enetNum, liodn) \
  154. SET_FMAN_LIODN_ENTRY("fsl,fman-v2-port-rx", "fsl,fman-port-10g-rx", \
  155. liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 16), \
  156. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_10G_OFFSET)
  157. #endif
  158. /*
  159. * handle both old and new versioned SEC properties:
  160. * "fsl,secX.Y" became "fsl,sec-vX.Y" during development
  161. */
  162. #define SET_SEC_JR_LIODN_ENTRY(jrNum, liodnA, liodnB) \
  163. SET_LIODN_ENTRY_2("fsl,sec4.0-job-ring", liodnA, liodnB,\
  164. offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \
  165. CONFIG_SYS_FSL_SEC_OFFSET, \
  166. CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum), \
  167. SET_LIODN_ENTRY_2("fsl,sec-v4.0-job-ring", liodnA, liodnB,\
  168. offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \
  169. CONFIG_SYS_FSL_SEC_OFFSET, \
  170. CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum)
  171. /* This is a bit evil since we treat rtic param as both a string & hex value */
  172. #define SET_SEC_RTIC_LIODN_ENTRY(rtic, liodnA) \
  173. SET_LIODN_ENTRY_1("fsl,sec4.0-rtic-memory", \
  174. liodnA, \
  175. offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \
  176. CONFIG_SYS_FSL_SEC_OFFSET, \
  177. CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa)), \
  178. SET_LIODN_ENTRY_1("fsl,sec-v4.0-rtic-memory", \
  179. liodnA, \
  180. offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \
  181. CONFIG_SYS_FSL_SEC_OFFSET, \
  182. CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa))
  183. #define SET_SEC_DECO_LIODN_ENTRY(num, liodnA, liodnB) \
  184. SET_LIODN_ENTRY_2(NULL, liodnA, liodnB, \
  185. offsetof(ccsr_sec_t, decoliodnr[num].ls) + \
  186. CONFIG_SYS_FSL_SEC_OFFSET, 0)
  187. #define SET_RAID_ENGINE_JQ_LIODN_ENTRY(jqNum, rNum, liodnA) \
  188. SET_LIODN_ENTRY_1("fsl,raideng-v1.0-job-ring", \
  189. liodnA, \
  190. offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg1) + \
  191. CONFIG_SYS_FSL_RAID_ENGINE_OFFSET, \
  192. offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg0) + \
  193. CONFIG_SYS_FSL_RAID_ENGINE_OFFSET)
  194. #define SET_RMAN_LIODN(ibNum, liodn) \
  195. SET_LIODN_ENTRY_1("fsl,rman-inbound-block", liodn, \
  196. offsetof(struct ccsr_rman, mmitdr) + \
  197. CONFIG_SYS_FSL_CORENET_RMAN_OFFSET, \
  198. CONFIG_SYS_FSL_CORENET_RMAN_OFFSET + ibNum * 0x1000)
  199. extern struct liodn_id_table liodn_tbl[], liodn_bases[], sec_liodn_tbl[];
  200. extern struct liodn_id_table raide_liodn_tbl[];
  201. extern struct fman_liodn_id_table fman1_liodn_tbl[], fman2_liodn_tbl[];
  202. #ifdef CONFIG_SYS_SRIO
  203. extern struct srio_liodn_id_table srio_liodn_tbl[];
  204. extern int srio_liodn_tbl_sz;
  205. #endif
  206. extern struct liodn_id_table rman_liodn_tbl[];
  207. extern int liodn_tbl_sz, sec_liodn_tbl_sz, raide_liodn_tbl_sz;
  208. extern int fman1_liodn_tbl_sz, fman2_liodn_tbl_sz;
  209. extern int rman_liodn_tbl_sz;
  210. #endif