fsl_liodn.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. * Copyright 2009-2011 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _FSL_LIODN_H_
  7. #define _FSL_LIODN_H_
  8. #include <asm/types.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, offsetof(ccsr_qman_t, liodnr) + \
  109. CONFIG_SYS_FSL_QMAN_OFFSET, \
  110. CONFIG_SYS_FSL_QMAN_OFFSET)
  111. #define SET_BMAN_LIODN(liodn) \
  112. SET_LIODN_ENTRY_1("fsl,bman", liodn, offsetof(ccsr_bman_t, liodnr) + \
  113. CONFIG_SYS_FSL_BMAN_OFFSET, \
  114. CONFIG_SYS_FSL_BMAN_OFFSET)
  115. #define SET_PME_LIODN(liodn) \
  116. SET_LIODN_ENTRY_1("fsl,pme", liodn, offsetof(ccsr_pme_t, liodnr) + \
  117. CONFIG_SYS_FSL_CORENET_PME_OFFSET, \
  118. CONFIG_SYS_FSL_CORENET_PME_OFFSET)
  119. #define SET_PMAN_LIODN(num, liodn) \
  120. SET_LIODN_ENTRY_2("fsl,pman", liodn, 0, \
  121. offsetof(struct ccsr_pman, ppa1) + \
  122. CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET, \
  123. CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET)
  124. /* -1 from portID due to how immap has the registers */
  125. #define FM_PPID_RX_PORT_OFFSET(fmNum, portID) \
  126. CONFIG_SYS_FSL_FM##fmNum##_OFFSET + \
  127. offsetof(struct ccsr_fman, fm_bmi_common.fmbm_ppid[portID - 1])
  128. #ifdef CONFIG_SYS_FMAN_V3
  129. /* enetNum is 0, 1, 2... so we + 8 for 1g to get to HW Port ID */
  130. #define SET_FMAN_RX_1G_LIODN(fmNum, enetNum, liodn) \
  131. SET_FMAN_LIODN_ENTRY("fsl,fman-v3-port-rx", "fsl,fman-port-1g-rx", \
  132. liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \
  133. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET)
  134. /* enetNum is 0, 1, 2... so we + 16 for 10g to get to HW Port ID */
  135. #define SET_FMAN_RX_10G_LIODN(fmNum, enetNum, liodn) \
  136. SET_FMAN_LIODN_ENTRY("fsl,fman-v3-port-rx", "fsl,fman-port-10g-rx", \
  137. liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 16), \
  138. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_10G_OFFSET)
  139. /* enetNum is 0, 1, 2... so we + 8 for type-2 10g to get to HW Port ID */
  140. #define SET_FMAN_RX_10G_TYPE2_LIODN(fmNum, enetNum, liodn) \
  141. SET_FMAN_LIODN_ENTRY("fsl,fman-v3-port-rx", "fsl,fman-port-10g-rx", \
  142. liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \
  143. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET)
  144. #else
  145. /* enetNum is 0, 1, 2... so we + 8 for 1g to get to HW Port ID */
  146. #define SET_FMAN_RX_1G_LIODN(fmNum, enetNum, liodn) \
  147. SET_FMAN_LIODN_ENTRY("fsl,fman-v2-port-rx", "fsl,fman-port-1g-rx", \
  148. liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \
  149. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET)
  150. /* enetNum is 0, 1, 2... so we + 16 for 10g to get to HW Port ID */
  151. #define SET_FMAN_RX_10G_LIODN(fmNum, enetNum, liodn) \
  152. SET_FMAN_LIODN_ENTRY("fsl,fman-v2-port-rx", "fsl,fman-port-10g-rx", \
  153. liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 16), \
  154. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_10G_OFFSET)
  155. #endif
  156. /*
  157. * handle both old and new versioned SEC properties:
  158. * "fsl,secX.Y" became "fsl,sec-vX.Y" during development
  159. */
  160. #define SET_SEC_JR_LIODN_ENTRY(jrNum, liodnA, liodnB) \
  161. SET_LIODN_ENTRY_2("fsl,sec4.0-job-ring", liodnA, liodnB,\
  162. offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \
  163. CONFIG_SYS_FSL_SEC_OFFSET, \
  164. CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum), \
  165. SET_LIODN_ENTRY_2("fsl,sec-v4.0-job-ring", liodnA, liodnB,\
  166. offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \
  167. CONFIG_SYS_FSL_SEC_OFFSET, \
  168. CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum)
  169. /* This is a bit evil since we treat rtic param as both a string & hex value */
  170. #define SET_SEC_RTIC_LIODN_ENTRY(rtic, liodnA) \
  171. SET_LIODN_ENTRY_1("fsl,sec4.0-rtic-memory", \
  172. liodnA, \
  173. offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \
  174. CONFIG_SYS_FSL_SEC_OFFSET, \
  175. CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa)), \
  176. SET_LIODN_ENTRY_1("fsl,sec-v4.0-rtic-memory", \
  177. liodnA, \
  178. offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \
  179. CONFIG_SYS_FSL_SEC_OFFSET, \
  180. CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa))
  181. #define SET_SEC_DECO_LIODN_ENTRY(num, liodnA, liodnB) \
  182. SET_LIODN_ENTRY_2(NULL, liodnA, liodnB, \
  183. offsetof(ccsr_sec_t, decoliodnr[num].ls) + \
  184. CONFIG_SYS_FSL_SEC_OFFSET, 0)
  185. #define SET_RAID_ENGINE_JQ_LIODN_ENTRY(jqNum, rNum, liodnA) \
  186. SET_LIODN_ENTRY_1("fsl,raideng-v1.0-job-ring", \
  187. liodnA, \
  188. offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg1) + \
  189. CONFIG_SYS_FSL_RAID_ENGINE_OFFSET, \
  190. offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg0) + \
  191. CONFIG_SYS_FSL_RAID_ENGINE_OFFSET)
  192. #define SET_RMAN_LIODN(ibNum, liodn) \
  193. SET_LIODN_ENTRY_1("fsl,rman-inbound-block", liodn, \
  194. offsetof(struct ccsr_rman, mmitdr) + \
  195. CONFIG_SYS_FSL_CORENET_RMAN_OFFSET, \
  196. CONFIG_SYS_FSL_CORENET_RMAN_OFFSET + ibNum * 0x1000)
  197. extern struct liodn_id_table liodn_tbl[], liodn_bases[], sec_liodn_tbl[];
  198. extern struct liodn_id_table raide_liodn_tbl[];
  199. extern struct fman_liodn_id_table fman1_liodn_tbl[], fman2_liodn_tbl[];
  200. #ifdef CONFIG_SYS_SRIO
  201. extern struct srio_liodn_id_table srio_liodn_tbl[];
  202. extern int srio_liodn_tbl_sz;
  203. #endif
  204. extern struct liodn_id_table rman_liodn_tbl[];
  205. extern int liodn_tbl_sz, sec_liodn_tbl_sz, raide_liodn_tbl_sz;
  206. extern int fman1_liodn_tbl_sz, fman2_liodn_tbl_sz;
  207. extern int rman_liodn_tbl_sz;
  208. #endif