fsl_liodn.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * Copyright 2009-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. #ifndef _FSL_LIODN_H_
  23. #define _FSL_LIODN_H_
  24. #include <asm/types.h>
  25. struct srio_liodn_id_table {
  26. u32 id[2];
  27. unsigned long reg_offset[2];
  28. u8 num_ids;
  29. u8 portid;
  30. };
  31. #define SET_SRIO_LIODN_1(port, idA) \
  32. { .id = { idA }, .num_ids = 1, .portid = port, \
  33. .reg_offset[0] = offsetof(ccsr_gur_t, rio##port##liodnr) \
  34. + CONFIG_SYS_MPC85xx_GUTS_OFFSET + CONFIG_SYS_CCSRBAR, \
  35. }
  36. #define SET_SRIO_LIODN_2(port, idA, idB) \
  37. { .id = { idA, idB }, .num_ids = 2, .portid = port, \
  38. .reg_offset[0] = offsetof(ccsr_gur_t, rio##port##liodnr) \
  39. + CONFIG_SYS_MPC85xx_GUTS_OFFSET + CONFIG_SYS_CCSRBAR, \
  40. .reg_offset[1] = offsetof(ccsr_gur_t, rio##port##maintliodnr) \
  41. + CONFIG_SYS_MPC85xx_GUTS_OFFSET + CONFIG_SYS_CCSRBAR, \
  42. }
  43. struct liodn_id_table {
  44. const char * compat;
  45. u32 id[2];
  46. u8 num_ids;
  47. phys_addr_t compat_offset;
  48. unsigned long reg_offset;
  49. };
  50. extern u32 get_ppid_liodn(int ppid_tbl_idx, int ppid);
  51. extern void set_liodns(void);
  52. extern void fdt_fixup_liodn(void *blob);
  53. #define SET_LIODN_BASE_1(idA) \
  54. { .id = { idA }, .num_ids = 1, }
  55. #define SET_LIODN_BASE_2(idA, idB) \
  56. { .id = { idA, idB }, .num_ids = 2 }
  57. #define SET_LIODN_ENTRY_1(name, idA, off, compatoff) \
  58. { .compat = name, \
  59. .id = { idA }, .num_ids = 1, \
  60. .reg_offset = off + CONFIG_SYS_CCSRBAR, \
  61. .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \
  62. }
  63. #define SET_LIODN_ENTRY_2(name, idA, idB, off, compatoff) \
  64. { .compat = name, \
  65. .id = { idA, idB }, .num_ids = 2, \
  66. .reg_offset = off + CONFIG_SYS_CCSRBAR, \
  67. .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \
  68. }
  69. #define SET_GUTS_LIODN(compat, liodn, name, compatoff) \
  70. SET_LIODN_ENTRY_1(compat, liodn, \
  71. offsetof(ccsr_gur_t, name) + CONFIG_SYS_MPC85xx_GUTS_OFFSET, \
  72. compatoff)
  73. #define SET_USB_LIODN(usbNum, compat, liodn) \
  74. SET_GUTS_LIODN(compat, liodn, usb##usbNum##liodnr,\
  75. CONFIG_SYS_MPC85xx_USB##usbNum##_OFFSET)
  76. #define SET_SATA_LIODN(sataNum, liodn) \
  77. SET_GUTS_LIODN("fsl,pq-sata-v2", liodn, sata##sataNum##liodnr,\
  78. CONFIG_SYS_MPC85xx_SATA##sataNum##_OFFSET)
  79. #define SET_PCI_LIODN(compat, pciNum, liodn) \
  80. SET_GUTS_LIODN(compat, liodn, pex##pciNum##liodnr,\
  81. CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET)
  82. /* reg nodes for DMA start @ 0x300 */
  83. #define SET_DMA_LIODN(dmaNum, liodn) \
  84. SET_GUTS_LIODN("fsl,eloplus-dma", liodn, dma##dmaNum##liodnr,\
  85. CONFIG_SYS_MPC85xx_DMA##dmaNum##_OFFSET + 0x300)
  86. #define SET_SDHC_LIODN(sdhcNum, liodn) \
  87. SET_GUTS_LIODN("fsl,esdhc", liodn, sdmmc##sdhcNum##liodnr,\
  88. CONFIG_SYS_MPC85xx_ESDHC_OFFSET)
  89. #define SET_QMAN_LIODN(liodn) \
  90. SET_LIODN_ENTRY_1("fsl,qman", liodn, offsetof(ccsr_qman_t, liodnr) + \
  91. CONFIG_SYS_FSL_QMAN_OFFSET, \
  92. CONFIG_SYS_FSL_QMAN_OFFSET)
  93. #define SET_BMAN_LIODN(liodn) \
  94. SET_LIODN_ENTRY_1("fsl,bman", liodn, offsetof(ccsr_bman_t, liodnr) + \
  95. CONFIG_SYS_FSL_BMAN_OFFSET, \
  96. CONFIG_SYS_FSL_BMAN_OFFSET)
  97. #define SET_PME_LIODN(liodn) \
  98. SET_LIODN_ENTRY_1("fsl,pme", liodn, offsetof(ccsr_pme_t, liodnr) + \
  99. CONFIG_SYS_FSL_CORENET_PME_OFFSET, \
  100. CONFIG_SYS_FSL_CORENET_PME_OFFSET)
  101. /* -1 from portID due to how immap has the registers */
  102. #define FM_PPID_RX_PORT_OFFSET(fmNum, portID) \
  103. CONFIG_SYS_FSL_FM##fmNum##_OFFSET + \
  104. offsetof(struct ccsr_fman, fm_bmi_common.fmbm_ppid[portID - 1])
  105. /* enetNum is 0, 1, 2... so we + 8 for 1g to get to HW Port ID */
  106. #define SET_FMAN_RX_1G_LIODN(fmNum, enetNum, liodn) \
  107. SET_LIODN_ENTRY_1("fsl,fman-port-1g-rx", liodn, \
  108. FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \
  109. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET) \
  110. /* enetNum is 0, 1, 2... so we + 16 for 10g to get to HW Port ID */
  111. #define SET_FMAN_RX_10G_LIODN(fmNum, enetNum, liodn) \
  112. SET_LIODN_ENTRY_1("fsl,fman-port-10g-rx", liodn, \
  113. FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 16), \
  114. CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_10G_OFFSET) \
  115. /*
  116. * handle both old and new versioned SEC properties:
  117. * "fsl,secX.Y" became "fsl,sec-vX.Y" during development
  118. */
  119. #define SET_SEC_JR_LIODN_ENTRY(jrNum, liodnA, liodnB) \
  120. SET_LIODN_ENTRY_2("fsl,sec4.0-job-ring", liodnA, liodnB,\
  121. offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \
  122. CONFIG_SYS_FSL_SEC_OFFSET, \
  123. CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum), \
  124. SET_LIODN_ENTRY_2("fsl,sec-v4.0-job-ring", liodnA, liodnB,\
  125. offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \
  126. CONFIG_SYS_FSL_SEC_OFFSET, \
  127. CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum)
  128. /* This is a bit evil since we treat rtic param as both a string & hex value */
  129. #define SET_SEC_RTIC_LIODN_ENTRY(rtic, liodnA) \
  130. SET_LIODN_ENTRY_1("fsl,sec4.0-rtic-memory", \
  131. liodnA, \
  132. offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \
  133. CONFIG_SYS_FSL_SEC_OFFSET, \
  134. CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa)), \
  135. SET_LIODN_ENTRY_1("fsl,sec-v4.0-rtic-memory", \
  136. liodnA, \
  137. offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \
  138. CONFIG_SYS_FSL_SEC_OFFSET, \
  139. CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa))
  140. #define SET_SEC_DECO_LIODN_ENTRY(num, liodnA, liodnB) \
  141. SET_LIODN_ENTRY_2(NULL, liodnA, liodnB, \
  142. offsetof(ccsr_sec_t, decoliodnr[num].ls) + \
  143. CONFIG_SYS_FSL_SEC_OFFSET, 0)
  144. #define SET_RAID_ENGINE_JQ_LIODN_ENTRY(jqNum, rNum, liodnA) \
  145. SET_LIODN_ENTRY_1("fsl,raideng-v1.0-job-ring", \
  146. liodnA, \
  147. offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg1) + \
  148. CONFIG_SYS_FSL_RAID_ENGINE_OFFSET, \
  149. offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg0) + \
  150. CONFIG_SYS_FSL_RAID_ENGINE_OFFSET)
  151. #define SET_RMAN_LIODN(ibNum, liodn) \
  152. SET_LIODN_ENTRY_1("fsl,rman-inbound-block", liodn, \
  153. offsetof(struct ccsr_rman, mmitdr) + \
  154. CONFIG_SYS_FSL_CORENET_RMAN_OFFSET, \
  155. CONFIG_SYS_FSL_CORENET_RMAN_OFFSET + ibNum * 0x1000)
  156. extern struct liodn_id_table liodn_tbl[], liodn_bases[], sec_liodn_tbl[];
  157. extern struct liodn_id_table raide_liodn_tbl[];
  158. extern struct liodn_id_table fman1_liodn_tbl[], fman2_liodn_tbl[];
  159. extern struct srio_liodn_id_table srio_liodn_tbl[];
  160. extern struct liodn_id_table rman_liodn_tbl[];
  161. extern int liodn_tbl_sz, sec_liodn_tbl_sz, raide_liodn_tbl_sz;
  162. extern int fman1_liodn_tbl_sz, fman2_liodn_tbl_sz;
  163. extern int srio_liodn_tbl_sz;
  164. extern int rman_liodn_tbl_sz;
  165. #endif