bridge.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * bridge.h - bridge chip header file, derived from IRIX <sys/PCI/bridge.h>,
  7. * revision 1.76.
  8. *
  9. * Copyright (C) 1996, 1999 Silcon Graphics, Inc.
  10. * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org)
  11. */
  12. #ifndef _ASM_PCI_BRIDGE_H
  13. #define _ASM_PCI_BRIDGE_H
  14. #include <linux/types.h>
  15. #include <linux/pci.h>
  16. #include <asm/xtalk/xwidget.h> /* generic widget header */
  17. #include <asm/sn/types.h>
  18. /* I/O page size */
  19. #define IOPFNSHIFT 12 /* 4K per mapped page */
  20. #define IOPGSIZE (1 << IOPFNSHIFT)
  21. #define IOPG(x) ((x) >> IOPFNSHIFT)
  22. #define IOPGOFF(x) ((x) & (IOPGSIZE-1))
  23. /* Bridge RAM sizes */
  24. #define BRIDGE_ATE_RAM_SIZE 0x00000400 /* 1kB ATE RAM */
  25. #define BRIDGE_CONFIG_BASE 0x20000
  26. #define BRIDGE_CONFIG1_BASE 0x28000
  27. #define BRIDGE_CONFIG_END 0x30000
  28. #define BRIDGE_CONFIG_SLOT_SIZE 0x1000
  29. #define BRIDGE_SSRAM_512K 0x00080000 /* 512kB */
  30. #define BRIDGE_SSRAM_128K 0x00020000 /* 128kB */
  31. #define BRIDGE_SSRAM_64K 0x00010000 /* 64kB */
  32. #define BRIDGE_SSRAM_0K 0x00000000 /* 0kB */
  33. /* ========================================================================
  34. * Bridge address map
  35. */
  36. #ifndef __ASSEMBLY__
  37. /*
  38. * All accesses to bridge hardware registers must be done
  39. * using 32-bit loads and stores.
  40. */
  41. typedef u32 bridgereg_t;
  42. typedef u64 bridge_ate_t;
  43. /* pointers to bridge ATEs
  44. * are always "pointer to volatile"
  45. */
  46. typedef volatile bridge_ate_t *bridge_ate_p;
  47. /*
  48. * It is generally preferred that hardware registers on the bridge
  49. * are located from C code via this structure.
  50. *
  51. * Generated from Bridge spec dated 04oct95
  52. */
  53. typedef volatile struct bridge_s {
  54. /* Local Registers 0x000000-0x00FFFF */
  55. /* standard widget configuration 0x000000-0x000057 */
  56. widget_cfg_t b_widget; /* 0x000000 */
  57. /* helper fieldnames for accessing bridge widget */
  58. #define b_wid_id b_widget.w_id
  59. #define b_wid_stat b_widget.w_status
  60. #define b_wid_err_upper b_widget.w_err_upper_addr
  61. #define b_wid_err_lower b_widget.w_err_lower_addr
  62. #define b_wid_control b_widget.w_control
  63. #define b_wid_req_timeout b_widget.w_req_timeout
  64. #define b_wid_int_upper b_widget.w_intdest_upper_addr
  65. #define b_wid_int_lower b_widget.w_intdest_lower_addr
  66. #define b_wid_err_cmdword b_widget.w_err_cmd_word
  67. #define b_wid_llp b_widget.w_llp_cfg
  68. #define b_wid_tflush b_widget.w_tflush
  69. /* bridge-specific widget configuration 0x000058-0x00007F */
  70. bridgereg_t _pad_000058;
  71. bridgereg_t b_wid_aux_err; /* 0x00005C */
  72. bridgereg_t _pad_000060;
  73. bridgereg_t b_wid_resp_upper; /* 0x000064 */
  74. bridgereg_t _pad_000068;
  75. bridgereg_t b_wid_resp_lower; /* 0x00006C */
  76. bridgereg_t _pad_000070;
  77. bridgereg_t b_wid_tst_pin_ctrl; /* 0x000074 */
  78. bridgereg_t _pad_000078[2];
  79. /* PMU & Map 0x000080-0x00008F */
  80. bridgereg_t _pad_000080;
  81. bridgereg_t b_dir_map; /* 0x000084 */
  82. bridgereg_t _pad_000088[2];
  83. /* SSRAM 0x000090-0x00009F */
  84. bridgereg_t _pad_000090;
  85. bridgereg_t b_ram_perr; /* 0x000094 */
  86. bridgereg_t _pad_000098[2];
  87. /* Arbitration 0x0000A0-0x0000AF */
  88. bridgereg_t _pad_0000A0;
  89. bridgereg_t b_arb; /* 0x0000A4 */
  90. bridgereg_t _pad_0000A8[2];
  91. /* Number In A Can 0x0000B0-0x0000BF */
  92. bridgereg_t _pad_0000B0;
  93. bridgereg_t b_nic; /* 0x0000B4 */
  94. bridgereg_t _pad_0000B8[2];
  95. /* PCI/GIO 0x0000C0-0x0000FF */
  96. bridgereg_t _pad_0000C0;
  97. bridgereg_t b_bus_timeout; /* 0x0000C4 */
  98. #define b_pci_bus_timeout b_bus_timeout
  99. bridgereg_t _pad_0000C8;
  100. bridgereg_t b_pci_cfg; /* 0x0000CC */
  101. bridgereg_t _pad_0000D0;
  102. bridgereg_t b_pci_err_upper; /* 0x0000D4 */
  103. bridgereg_t _pad_0000D8;
  104. bridgereg_t b_pci_err_lower; /* 0x0000DC */
  105. bridgereg_t _pad_0000E0[8];
  106. #define b_gio_err_lower b_pci_err_lower
  107. #define b_gio_err_upper b_pci_err_upper
  108. /* Interrupt 0x000100-0x0001FF */
  109. bridgereg_t _pad_000100;
  110. bridgereg_t b_int_status; /* 0x000104 */
  111. bridgereg_t _pad_000108;
  112. bridgereg_t b_int_enable; /* 0x00010C */
  113. bridgereg_t _pad_000110;
  114. bridgereg_t b_int_rst_stat; /* 0x000114 */
  115. bridgereg_t _pad_000118;
  116. bridgereg_t b_int_mode; /* 0x00011C */
  117. bridgereg_t _pad_000120;
  118. bridgereg_t b_int_device; /* 0x000124 */
  119. bridgereg_t _pad_000128;
  120. bridgereg_t b_int_host_err; /* 0x00012C */
  121. struct {
  122. bridgereg_t __pad; /* 0x0001{30,,,68} */
  123. bridgereg_t addr; /* 0x0001{34,,,6C} */
  124. } b_int_addr[8]; /* 0x000130 */
  125. bridgereg_t _pad_000170[36];
  126. /* Device 0x000200-0x0003FF */
  127. struct {
  128. bridgereg_t __pad; /* 0x0002{00,,,38} */
  129. bridgereg_t reg; /* 0x0002{04,,,3C} */
  130. } b_device[8]; /* 0x000200 */
  131. struct {
  132. bridgereg_t __pad; /* 0x0002{40,,,78} */
  133. bridgereg_t reg; /* 0x0002{44,,,7C} */
  134. } b_wr_req_buf[8]; /* 0x000240 */
  135. struct {
  136. bridgereg_t __pad; /* 0x0002{80,,,88} */
  137. bridgereg_t reg; /* 0x0002{84,,,8C} */
  138. } b_rrb_map[2]; /* 0x000280 */
  139. #define b_even_resp b_rrb_map[0].reg /* 0x000284 */
  140. #define b_odd_resp b_rrb_map[1].reg /* 0x00028C */
  141. bridgereg_t _pad_000290;
  142. bridgereg_t b_resp_status; /* 0x000294 */
  143. bridgereg_t _pad_000298;
  144. bridgereg_t b_resp_clear; /* 0x00029C */
  145. bridgereg_t _pad_0002A0[24];
  146. char _pad_000300[0x10000 - 0x000300];
  147. /* Internal Address Translation Entry RAM 0x010000-0x0103FF */
  148. union {
  149. bridge_ate_t wr; /* write-only */
  150. struct {
  151. bridgereg_t _p_pad;
  152. bridgereg_t rd; /* read-only */
  153. } hi;
  154. } b_int_ate_ram[128];
  155. char _pad_010400[0x11000 - 0x010400];
  156. /* Internal Address Translation Entry RAM LOW 0x011000-0x0113FF */
  157. struct {
  158. bridgereg_t _p_pad;
  159. bridgereg_t rd; /* read-only */
  160. } b_int_ate_ram_lo[128];
  161. char _pad_011400[0x20000 - 0x011400];
  162. /* PCI Device Configuration Spaces 0x020000-0x027FFF */
  163. union { /* make all access sizes available. */
  164. u8 c[0x1000 / 1];
  165. u16 s[0x1000 / 2];
  166. u32 l[0x1000 / 4];
  167. u64 d[0x1000 / 8];
  168. union {
  169. u8 c[0x100 / 1];
  170. u16 s[0x100 / 2];
  171. u32 l[0x100 / 4];
  172. u64 d[0x100 / 8];
  173. } f[8];
  174. } b_type0_cfg_dev[8]; /* 0x020000 */
  175. /* PCI Type 1 Configuration Space 0x028000-0x028FFF */
  176. union { /* make all access sizes available. */
  177. u8 c[0x1000 / 1];
  178. u16 s[0x1000 / 2];
  179. u32 l[0x1000 / 4];
  180. u64 d[0x1000 / 8];
  181. } b_type1_cfg; /* 0x028000-0x029000 */
  182. char _pad_029000[0x007000]; /* 0x029000-0x030000 */
  183. /* PCI Interrupt Acknowledge Cycle 0x030000 */
  184. union {
  185. u8 c[8 / 1];
  186. u16 s[8 / 2];
  187. u32 l[8 / 4];
  188. u64 d[8 / 8];
  189. } b_pci_iack; /* 0x030000 */
  190. u8 _pad_030007[0x04fff8]; /* 0x030008-0x07FFFF */
  191. /* External Address Translation Entry RAM 0x080000-0x0FFFFF */
  192. bridge_ate_t b_ext_ate_ram[0x10000];
  193. /* Reserved 0x100000-0x1FFFFF */
  194. char _pad_100000[0x200000-0x100000];
  195. /* PCI/GIO Device Spaces 0x200000-0xBFFFFF */
  196. union { /* make all access sizes available. */
  197. u8 c[0x100000 / 1];
  198. u16 s[0x100000 / 2];
  199. u32 l[0x100000 / 4];
  200. u64 d[0x100000 / 8];
  201. } b_devio_raw[10]; /* 0x200000 */
  202. /* b_devio macro is a bit strange; it reflects the
  203. * fact that the Bridge ASIC provides 2M for the
  204. * first two DevIO windows and 1M for the other six.
  205. */
  206. #define b_devio(n) b_devio_raw[((n)<2)?(n*2):(n+2)]
  207. /* External Flash Proms 1,0 0xC00000-0xFFFFFF */
  208. union { /* make all access sizes available. */
  209. u8 c[0x400000 / 1]; /* read-only */
  210. u16 s[0x400000 / 2]; /* read-write */
  211. u32 l[0x400000 / 4]; /* read-only */
  212. u64 d[0x400000 / 8]; /* read-only */
  213. } b_external_flash; /* 0xC00000 */
  214. } bridge_t;
  215. /*
  216. * Field formats for Error Command Word and Auxiliary Error Command Word
  217. * of bridge.
  218. */
  219. typedef struct bridge_err_cmdword_s {
  220. union {
  221. u32 cmd_word;
  222. struct {
  223. u32 didn:4, /* Destination ID */
  224. sidn:4, /* Source ID */
  225. pactyp:4, /* Packet type */
  226. tnum:5, /* Trans Number */
  227. coh:1, /* Coh Transaction */
  228. ds:2, /* Data size */
  229. gbr:1, /* GBR enable */
  230. vbpm:1, /* VBPM message */
  231. error:1, /* Error occurred */
  232. barr:1, /* Barrier op */
  233. rsvd:8;
  234. } berr_st;
  235. } berr_un;
  236. } bridge_err_cmdword_t;
  237. #define berr_field berr_un.berr_st
  238. #endif /* !__ASSEMBLY__ */
  239. /*
  240. * The values of these macros can and should be crosschecked
  241. * regularly against the offsets of the like-named fields
  242. * within the "bridge_t" structure above.
  243. */
  244. /* Byte offset macros for Bridge internal registers */
  245. #define BRIDGE_WID_ID WIDGET_ID
  246. #define BRIDGE_WID_STAT WIDGET_STATUS
  247. #define BRIDGE_WID_ERR_UPPER WIDGET_ERR_UPPER_ADDR
  248. #define BRIDGE_WID_ERR_LOWER WIDGET_ERR_LOWER_ADDR
  249. #define BRIDGE_WID_CONTROL WIDGET_CONTROL
  250. #define BRIDGE_WID_REQ_TIMEOUT WIDGET_REQ_TIMEOUT
  251. #define BRIDGE_WID_INT_UPPER WIDGET_INTDEST_UPPER_ADDR
  252. #define BRIDGE_WID_INT_LOWER WIDGET_INTDEST_LOWER_ADDR
  253. #define BRIDGE_WID_ERR_CMDWORD WIDGET_ERR_CMD_WORD
  254. #define BRIDGE_WID_LLP WIDGET_LLP_CFG
  255. #define BRIDGE_WID_TFLUSH WIDGET_TFLUSH
  256. #define BRIDGE_WID_AUX_ERR 0x00005C /* Aux Error Command Word */
  257. #define BRIDGE_WID_RESP_UPPER 0x000064 /* Response Buf Upper Addr */
  258. #define BRIDGE_WID_RESP_LOWER 0x00006C /* Response Buf Lower Addr */
  259. #define BRIDGE_WID_TST_PIN_CTRL 0x000074 /* Test pin control */
  260. #define BRIDGE_DIR_MAP 0x000084 /* Direct Map reg */
  261. #define BRIDGE_RAM_PERR 0x000094 /* SSRAM Parity Error */
  262. #define BRIDGE_ARB 0x0000A4 /* Arbitration Priority reg */
  263. #define BRIDGE_NIC 0x0000B4 /* Number In A Can */
  264. #define BRIDGE_BUS_TIMEOUT 0x0000C4 /* Bus Timeout Register */
  265. #define BRIDGE_PCI_BUS_TIMEOUT BRIDGE_BUS_TIMEOUT
  266. #define BRIDGE_PCI_CFG 0x0000CC /* PCI Type 1 Config reg */
  267. #define BRIDGE_PCI_ERR_UPPER 0x0000D4 /* PCI error Upper Addr */
  268. #define BRIDGE_PCI_ERR_LOWER 0x0000DC /* PCI error Lower Addr */
  269. #define BRIDGE_INT_STATUS 0x000104 /* Interrupt Status */
  270. #define BRIDGE_INT_ENABLE 0x00010C /* Interrupt Enables */
  271. #define BRIDGE_INT_RST_STAT 0x000114 /* Reset Intr Status */
  272. #define BRIDGE_INT_MODE 0x00011C /* Interrupt Mode */
  273. #define BRIDGE_INT_DEVICE 0x000124 /* Interrupt Device */
  274. #define BRIDGE_INT_HOST_ERR 0x00012C /* Host Error Field */
  275. #define BRIDGE_INT_ADDR0 0x000134 /* Host Address Reg */
  276. #define BRIDGE_INT_ADDR_OFF 0x000008 /* Host Addr offset (1..7) */
  277. #define BRIDGE_INT_ADDR(x) (BRIDGE_INT_ADDR0+(x)*BRIDGE_INT_ADDR_OFF)
  278. #define BRIDGE_DEVICE0 0x000204 /* Device 0 */
  279. #define BRIDGE_DEVICE_OFF 0x000008 /* Device offset (1..7) */
  280. #define BRIDGE_DEVICE(x) (BRIDGE_DEVICE0+(x)*BRIDGE_DEVICE_OFF)
  281. #define BRIDGE_WR_REQ_BUF0 0x000244 /* Write Request Buffer 0 */
  282. #define BRIDGE_WR_REQ_BUF_OFF 0x000008 /* Buffer Offset (1..7) */
  283. #define BRIDGE_WR_REQ_BUF(x) (BRIDGE_WR_REQ_BUF0+(x)*BRIDGE_WR_REQ_BUF_OFF)
  284. #define BRIDGE_EVEN_RESP 0x000284 /* Even Device Response Buf */
  285. #define BRIDGE_ODD_RESP 0x00028C /* Odd Device Response Buf */
  286. #define BRIDGE_RESP_STATUS 0x000294 /* Read Response Status reg */
  287. #define BRIDGE_RESP_CLEAR 0x00029C /* Read Response Clear reg */
  288. /* Byte offset macros for Bridge I/O space */
  289. #define BRIDGE_ATE_RAM 0x00010000 /* Internal Addr Xlat Ram */
  290. #define BRIDGE_TYPE0_CFG_DEV0 0x00020000 /* Type 0 Cfg, Device 0 */
  291. #define BRIDGE_TYPE0_CFG_SLOT_OFF 0x00001000 /* Type 0 Cfg Slot Offset (1..7) */
  292. #define BRIDGE_TYPE0_CFG_FUNC_OFF 0x00000100 /* Type 0 Cfg Func Offset (1..7) */
  293. #define BRIDGE_TYPE0_CFG_DEV(s) (BRIDGE_TYPE0_CFG_DEV0+\
  294. (s)*BRIDGE_TYPE0_CFG_SLOT_OFF)
  295. #define BRIDGE_TYPE0_CFG_DEVF(s, f) (BRIDGE_TYPE0_CFG_DEV0+\
  296. (s)*BRIDGE_TYPE0_CFG_SLOT_OFF+\
  297. (f)*BRIDGE_TYPE0_CFG_FUNC_OFF)
  298. #define BRIDGE_TYPE1_CFG 0x00028000 /* Type 1 Cfg space */
  299. #define BRIDGE_PCI_IACK 0x00030000 /* PCI Interrupt Ack */
  300. #define BRIDGE_EXT_SSRAM 0x00080000 /* Extern SSRAM (ATE) */
  301. /* Byte offset macros for Bridge device IO spaces */
  302. #define BRIDGE_DEV_CNT 8 /* Up to 8 devices per bridge */
  303. #define BRIDGE_DEVIO0 0x00200000 /* Device IO 0 Addr */
  304. #define BRIDGE_DEVIO1 0x00400000 /* Device IO 1 Addr */
  305. #define BRIDGE_DEVIO2 0x00600000 /* Device IO 2 Addr */
  306. #define BRIDGE_DEVIO_OFF 0x00100000 /* Device IO Offset (3..7) */
  307. #define BRIDGE_DEVIO_2MB 0x00200000 /* Device IO Offset (0..1) */
  308. #define BRIDGE_DEVIO_1MB 0x00100000 /* Device IO Offset (2..7) */
  309. #define BRIDGE_DEVIO(x) ((x)<=1 ? BRIDGE_DEVIO0+(x)*BRIDGE_DEVIO_2MB : BRIDGE_DEVIO2+((x)-2)*BRIDGE_DEVIO_1MB)
  310. #define BRIDGE_EXTERNAL_FLASH 0x00C00000 /* External Flash PROMS */
  311. /* ========================================================================
  312. * Bridge register bit field definitions
  313. */
  314. /* Widget part number of bridge */
  315. #define BRIDGE_WIDGET_PART_NUM 0xc002
  316. #define XBRIDGE_WIDGET_PART_NUM 0xd002
  317. /* Manufacturer of bridge */
  318. #define BRIDGE_WIDGET_MFGR_NUM 0x036
  319. #define XBRIDGE_WIDGET_MFGR_NUM 0x024
  320. /* Revision numbers for known Bridge revisions */
  321. #define BRIDGE_REV_A 0x1
  322. #define BRIDGE_REV_B 0x2
  323. #define BRIDGE_REV_C 0x3
  324. #define BRIDGE_REV_D 0x4
  325. /* Bridge widget status register bits definition */
  326. #define BRIDGE_STAT_LLP_REC_CNT (0xFFu << 24)
  327. #define BRIDGE_STAT_LLP_TX_CNT (0xFF << 16)
  328. #define BRIDGE_STAT_FLASH_SELECT (0x1 << 6)
  329. #define BRIDGE_STAT_PCI_GIO_N (0x1 << 5)
  330. #define BRIDGE_STAT_PENDING (0x1F << 0)
  331. /* Bridge widget control register bits definition */
  332. #define BRIDGE_CTRL_FLASH_WR_EN (0x1ul << 31)
  333. #define BRIDGE_CTRL_EN_CLK50 (0x1 << 30)
  334. #define BRIDGE_CTRL_EN_CLK40 (0x1 << 29)
  335. #define BRIDGE_CTRL_EN_CLK33 (0x1 << 28)
  336. #define BRIDGE_CTRL_RST(n) ((n) << 24)
  337. #define BRIDGE_CTRL_RST_MASK (BRIDGE_CTRL_RST(0xF))
  338. #define BRIDGE_CTRL_RST_PIN(x) (BRIDGE_CTRL_RST(0x1 << (x)))
  339. #define BRIDGE_CTRL_IO_SWAP (0x1 << 23)
  340. #define BRIDGE_CTRL_MEM_SWAP (0x1 << 22)
  341. #define BRIDGE_CTRL_PAGE_SIZE (0x1 << 21)
  342. #define BRIDGE_CTRL_SS_PAR_BAD (0x1 << 20)
  343. #define BRIDGE_CTRL_SS_PAR_EN (0x1 << 19)
  344. #define BRIDGE_CTRL_SSRAM_SIZE(n) ((n) << 17)
  345. #define BRIDGE_CTRL_SSRAM_SIZE_MASK (BRIDGE_CTRL_SSRAM_SIZE(0x3))
  346. #define BRIDGE_CTRL_SSRAM_512K (BRIDGE_CTRL_SSRAM_SIZE(0x3))
  347. #define BRIDGE_CTRL_SSRAM_128K (BRIDGE_CTRL_SSRAM_SIZE(0x2))
  348. #define BRIDGE_CTRL_SSRAM_64K (BRIDGE_CTRL_SSRAM_SIZE(0x1))
  349. #define BRIDGE_CTRL_SSRAM_1K (BRIDGE_CTRL_SSRAM_SIZE(0x0))
  350. #define BRIDGE_CTRL_F_BAD_PKT (0x1 << 16)
  351. #define BRIDGE_CTRL_LLP_XBAR_CRD(n) ((n) << 12)
  352. #define BRIDGE_CTRL_LLP_XBAR_CRD_MASK (BRIDGE_CTRL_LLP_XBAR_CRD(0xf))
  353. #define BRIDGE_CTRL_CLR_RLLP_CNT (0x1 << 11)
  354. #define BRIDGE_CTRL_CLR_TLLP_CNT (0x1 << 10)
  355. #define BRIDGE_CTRL_SYS_END (0x1 << 9)
  356. #define BRIDGE_CTRL_MAX_TRANS(n) ((n) << 4)
  357. #define BRIDGE_CTRL_MAX_TRANS_MASK (BRIDGE_CTRL_MAX_TRANS(0x1f))
  358. #define BRIDGE_CTRL_WIDGET_ID(n) ((n) << 0)
  359. #define BRIDGE_CTRL_WIDGET_ID_MASK (BRIDGE_CTRL_WIDGET_ID(0xf))
  360. /* Bridge Response buffer Error Upper Register bit fields definition */
  361. #define BRIDGE_RESP_ERRUPPR_DEVNUM_SHFT (20)
  362. #define BRIDGE_RESP_ERRUPPR_DEVNUM_MASK (0x7 << BRIDGE_RESP_ERRUPPR_DEVNUM_SHFT)
  363. #define BRIDGE_RESP_ERRUPPR_BUFNUM_SHFT (16)
  364. #define BRIDGE_RESP_ERRUPPR_BUFNUM_MASK (0xF << BRIDGE_RESP_ERRUPPR_BUFNUM_SHFT)
  365. #define BRIDGE_RESP_ERRRUPPR_BUFMASK (0xFFFF)
  366. #define BRIDGE_RESP_ERRUPPR_BUFNUM(x) \
  367. (((x) & BRIDGE_RESP_ERRUPPR_BUFNUM_MASK) >> \
  368. BRIDGE_RESP_ERRUPPR_BUFNUM_SHFT)
  369. #define BRIDGE_RESP_ERRUPPR_DEVICE(x) \
  370. (((x) & BRIDGE_RESP_ERRUPPR_DEVNUM_MASK) >> \
  371. BRIDGE_RESP_ERRUPPR_DEVNUM_SHFT)
  372. /* Bridge direct mapping register bits definition */
  373. #define BRIDGE_DIRMAP_W_ID_SHFT 20
  374. #define BRIDGE_DIRMAP_W_ID (0xf << BRIDGE_DIRMAP_W_ID_SHFT)
  375. #define BRIDGE_DIRMAP_RMF_64 (0x1 << 18)
  376. #define BRIDGE_DIRMAP_ADD512 (0x1 << 17)
  377. #define BRIDGE_DIRMAP_OFF (0x1ffff << 0)
  378. #define BRIDGE_DIRMAP_OFF_ADDRSHFT (31) /* lsbit of DIRMAP_OFF is xtalk address bit 31 */
  379. /* Bridge Arbitration register bits definition */
  380. #define BRIDGE_ARB_REQ_WAIT_TICK(x) ((x) << 16)
  381. #define BRIDGE_ARB_REQ_WAIT_TICK_MASK BRIDGE_ARB_REQ_WAIT_TICK(0x3)
  382. #define BRIDGE_ARB_REQ_WAIT_EN(x) ((x) << 8)
  383. #define BRIDGE_ARB_REQ_WAIT_EN_MASK BRIDGE_ARB_REQ_WAIT_EN(0xff)
  384. #define BRIDGE_ARB_FREEZE_GNT (1 << 6)
  385. #define BRIDGE_ARB_HPRI_RING_B2 (1 << 5)
  386. #define BRIDGE_ARB_HPRI_RING_B1 (1 << 4)
  387. #define BRIDGE_ARB_HPRI_RING_B0 (1 << 3)
  388. #define BRIDGE_ARB_LPRI_RING_B2 (1 << 2)
  389. #define BRIDGE_ARB_LPRI_RING_B1 (1 << 1)
  390. #define BRIDGE_ARB_LPRI_RING_B0 (1 << 0)
  391. /* Bridge Bus time-out register bits definition */
  392. #define BRIDGE_BUS_PCI_RETRY_HLD(x) ((x) << 16)
  393. #define BRIDGE_BUS_PCI_RETRY_HLD_MASK BRIDGE_BUS_PCI_RETRY_HLD(0x1f)
  394. #define BRIDGE_BUS_GIO_TIMEOUT (1 << 12)
  395. #define BRIDGE_BUS_PCI_RETRY_CNT(x) ((x) << 0)
  396. #define BRIDGE_BUS_PCI_RETRY_MASK BRIDGE_BUS_PCI_RETRY_CNT(0x3ff)
  397. /* Bridge interrupt status register bits definition */
  398. #define BRIDGE_ISR_MULTI_ERR (0x1u << 31)
  399. #define BRIDGE_ISR_PMU_ESIZE_FAULT (0x1 << 30)
  400. #define BRIDGE_ISR_UNEXP_RESP (0x1 << 29)
  401. #define BRIDGE_ISR_BAD_XRESP_PKT (0x1 << 28)
  402. #define BRIDGE_ISR_BAD_XREQ_PKT (0x1 << 27)
  403. #define BRIDGE_ISR_RESP_XTLK_ERR (0x1 << 26)
  404. #define BRIDGE_ISR_REQ_XTLK_ERR (0x1 << 25)
  405. #define BRIDGE_ISR_INVLD_ADDR (0x1 << 24)
  406. #define BRIDGE_ISR_UNSUPPORTED_XOP (0x1 << 23)
  407. #define BRIDGE_ISR_XREQ_FIFO_OFLOW (0x1 << 22)
  408. #define BRIDGE_ISR_LLP_REC_SNERR (0x1 << 21)
  409. #define BRIDGE_ISR_LLP_REC_CBERR (0x1 << 20)
  410. #define BRIDGE_ISR_LLP_RCTY (0x1 << 19)
  411. #define BRIDGE_ISR_LLP_TX_RETRY (0x1 << 18)
  412. #define BRIDGE_ISR_LLP_TCTY (0x1 << 17)
  413. #define BRIDGE_ISR_SSRAM_PERR (0x1 << 16)
  414. #define BRIDGE_ISR_PCI_ABORT (0x1 << 15)
  415. #define BRIDGE_ISR_PCI_PARITY (0x1 << 14)
  416. #define BRIDGE_ISR_PCI_SERR (0x1 << 13)
  417. #define BRIDGE_ISR_PCI_PERR (0x1 << 12)
  418. #define BRIDGE_ISR_PCI_MST_TIMEOUT (0x1 << 11)
  419. #define BRIDGE_ISR_GIO_MST_TIMEOUT BRIDGE_ISR_PCI_MST_TIMEOUT
  420. #define BRIDGE_ISR_PCI_RETRY_CNT (0x1 << 10)
  421. #define BRIDGE_ISR_XREAD_REQ_TIMEOUT (0x1 << 9)
  422. #define BRIDGE_ISR_GIO_B_ENBL_ERR (0x1 << 8)
  423. #define BRIDGE_ISR_INT_MSK (0xff << 0)
  424. #define BRIDGE_ISR_INT(x) (0x1 << (x))
  425. #define BRIDGE_ISR_LINK_ERROR \
  426. (BRIDGE_ISR_LLP_REC_SNERR|BRIDGE_ISR_LLP_REC_CBERR| \
  427. BRIDGE_ISR_LLP_RCTY|BRIDGE_ISR_LLP_TX_RETRY| \
  428. BRIDGE_ISR_LLP_TCTY)
  429. #define BRIDGE_ISR_PCIBUS_PIOERR \
  430. (BRIDGE_ISR_PCI_MST_TIMEOUT|BRIDGE_ISR_PCI_ABORT)
  431. #define BRIDGE_ISR_PCIBUS_ERROR \
  432. (BRIDGE_ISR_PCIBUS_PIOERR|BRIDGE_ISR_PCI_PERR| \
  433. BRIDGE_ISR_PCI_SERR|BRIDGE_ISR_PCI_RETRY_CNT| \
  434. BRIDGE_ISR_PCI_PARITY)
  435. #define BRIDGE_ISR_XTALK_ERROR \
  436. (BRIDGE_ISR_XREAD_REQ_TIMEOUT|BRIDGE_ISR_XREQ_FIFO_OFLOW|\
  437. BRIDGE_ISR_UNSUPPORTED_XOP|BRIDGE_ISR_INVLD_ADDR| \
  438. BRIDGE_ISR_REQ_XTLK_ERR|BRIDGE_ISR_RESP_XTLK_ERR| \
  439. BRIDGE_ISR_BAD_XREQ_PKT|BRIDGE_ISR_BAD_XRESP_PKT| \
  440. BRIDGE_ISR_UNEXP_RESP)
  441. #define BRIDGE_ISR_ERRORS \
  442. (BRIDGE_ISR_LINK_ERROR|BRIDGE_ISR_PCIBUS_ERROR| \
  443. BRIDGE_ISR_XTALK_ERROR|BRIDGE_ISR_SSRAM_PERR| \
  444. BRIDGE_ISR_PMU_ESIZE_FAULT)
  445. /*
  446. * List of Errors which are fatal and kill the system
  447. */
  448. #define BRIDGE_ISR_ERROR_FATAL \
  449. ((BRIDGE_ISR_XTALK_ERROR & ~BRIDGE_ISR_XREAD_REQ_TIMEOUT)|\
  450. BRIDGE_ISR_PCI_SERR|BRIDGE_ISR_PCI_PARITY )
  451. #define BRIDGE_ISR_ERROR_DUMP \
  452. (BRIDGE_ISR_PCIBUS_ERROR|BRIDGE_ISR_PMU_ESIZE_FAULT| \
  453. BRIDGE_ISR_XTALK_ERROR|BRIDGE_ISR_SSRAM_PERR)
  454. /* Bridge interrupt enable register bits definition */
  455. #define BRIDGE_IMR_UNEXP_RESP BRIDGE_ISR_UNEXP_RESP
  456. #define BRIDGE_IMR_PMU_ESIZE_FAULT BRIDGE_ISR_PMU_ESIZE_FAULT
  457. #define BRIDGE_IMR_BAD_XRESP_PKT BRIDGE_ISR_BAD_XRESP_PKT
  458. #define BRIDGE_IMR_BAD_XREQ_PKT BRIDGE_ISR_BAD_XREQ_PKT
  459. #define BRIDGE_IMR_RESP_XTLK_ERR BRIDGE_ISR_RESP_XTLK_ERR
  460. #define BRIDGE_IMR_REQ_XTLK_ERR BRIDGE_ISR_REQ_XTLK_ERR
  461. #define BRIDGE_IMR_INVLD_ADDR BRIDGE_ISR_INVLD_ADDR
  462. #define BRIDGE_IMR_UNSUPPORTED_XOP BRIDGE_ISR_UNSUPPORTED_XOP
  463. #define BRIDGE_IMR_XREQ_FIFO_OFLOW BRIDGE_ISR_XREQ_FIFO_OFLOW
  464. #define BRIDGE_IMR_LLP_REC_SNERR BRIDGE_ISR_LLP_REC_SNERR
  465. #define BRIDGE_IMR_LLP_REC_CBERR BRIDGE_ISR_LLP_REC_CBERR
  466. #define BRIDGE_IMR_LLP_RCTY BRIDGE_ISR_LLP_RCTY
  467. #define BRIDGE_IMR_LLP_TX_RETRY BRIDGE_ISR_LLP_TX_RETRY
  468. #define BRIDGE_IMR_LLP_TCTY BRIDGE_ISR_LLP_TCTY
  469. #define BRIDGE_IMR_SSRAM_PERR BRIDGE_ISR_SSRAM_PERR
  470. #define BRIDGE_IMR_PCI_ABORT BRIDGE_ISR_PCI_ABORT
  471. #define BRIDGE_IMR_PCI_PARITY BRIDGE_ISR_PCI_PARITY
  472. #define BRIDGE_IMR_PCI_SERR BRIDGE_ISR_PCI_SERR
  473. #define BRIDGE_IMR_PCI_PERR BRIDGE_ISR_PCI_PERR
  474. #define BRIDGE_IMR_PCI_MST_TIMEOUT BRIDGE_ISR_PCI_MST_TIMEOUT
  475. #define BRIDGE_IMR_GIO_MST_TIMEOUT BRIDGE_ISR_GIO_MST_TIMEOUT
  476. #define BRIDGE_IMR_PCI_RETRY_CNT BRIDGE_ISR_PCI_RETRY_CNT
  477. #define BRIDGE_IMR_XREAD_REQ_TIMEOUT BRIDGE_ISR_XREAD_REQ_TIMEOUT
  478. #define BRIDGE_IMR_GIO_B_ENBL_ERR BRIDGE_ISR_GIO_B_ENBL_ERR
  479. #define BRIDGE_IMR_INT_MSK BRIDGE_ISR_INT_MSK
  480. #define BRIDGE_IMR_INT(x) BRIDGE_ISR_INT(x)
  481. /* Bridge interrupt reset register bits definition */
  482. #define BRIDGE_IRR_MULTI_CLR (0x1 << 6)
  483. #define BRIDGE_IRR_CRP_GRP_CLR (0x1 << 5)
  484. #define BRIDGE_IRR_RESP_BUF_GRP_CLR (0x1 << 4)
  485. #define BRIDGE_IRR_REQ_DSP_GRP_CLR (0x1 << 3)
  486. #define BRIDGE_IRR_LLP_GRP_CLR (0x1 << 2)
  487. #define BRIDGE_IRR_SSRAM_GRP_CLR (0x1 << 1)
  488. #define BRIDGE_IRR_PCI_GRP_CLR (0x1 << 0)
  489. #define BRIDGE_IRR_GIO_GRP_CLR (0x1 << 0)
  490. #define BRIDGE_IRR_ALL_CLR 0x7f
  491. #define BRIDGE_IRR_CRP_GRP (BRIDGE_ISR_UNEXP_RESP | \
  492. BRIDGE_ISR_XREQ_FIFO_OFLOW)
  493. #define BRIDGE_IRR_RESP_BUF_GRP (BRIDGE_ISR_BAD_XRESP_PKT | \
  494. BRIDGE_ISR_RESP_XTLK_ERR | \
  495. BRIDGE_ISR_XREAD_REQ_TIMEOUT)
  496. #define BRIDGE_IRR_REQ_DSP_GRP (BRIDGE_ISR_UNSUPPORTED_XOP | \
  497. BRIDGE_ISR_BAD_XREQ_PKT | \
  498. BRIDGE_ISR_REQ_XTLK_ERR | \
  499. BRIDGE_ISR_INVLD_ADDR)
  500. #define BRIDGE_IRR_LLP_GRP (BRIDGE_ISR_LLP_REC_SNERR | \
  501. BRIDGE_ISR_LLP_REC_CBERR | \
  502. BRIDGE_ISR_LLP_RCTY | \
  503. BRIDGE_ISR_LLP_TX_RETRY | \
  504. BRIDGE_ISR_LLP_TCTY)
  505. #define BRIDGE_IRR_SSRAM_GRP (BRIDGE_ISR_SSRAM_PERR | \
  506. BRIDGE_ISR_PMU_ESIZE_FAULT)
  507. #define BRIDGE_IRR_PCI_GRP (BRIDGE_ISR_PCI_ABORT | \
  508. BRIDGE_ISR_PCI_PARITY | \
  509. BRIDGE_ISR_PCI_SERR | \
  510. BRIDGE_ISR_PCI_PERR | \
  511. BRIDGE_ISR_PCI_MST_TIMEOUT | \
  512. BRIDGE_ISR_PCI_RETRY_CNT)
  513. #define BRIDGE_IRR_GIO_GRP (BRIDGE_ISR_GIO_B_ENBL_ERR | \
  514. BRIDGE_ISR_GIO_MST_TIMEOUT)
  515. /* Bridge INT_DEV register bits definition */
  516. #define BRIDGE_INT_DEV_SHFT(n) ((n)*3)
  517. #define BRIDGE_INT_DEV_MASK(n) (0x7 << BRIDGE_INT_DEV_SHFT(n))
  518. #define BRIDGE_INT_DEV_SET(_dev, _line) (_dev << BRIDGE_INT_DEV_SHFT(_line))
  519. /* Bridge interrupt(x) register bits definition */
  520. #define BRIDGE_INT_ADDR_HOST 0x0003FF00
  521. #define BRIDGE_INT_ADDR_FLD 0x000000FF
  522. #define BRIDGE_TMO_PCI_RETRY_HLD_MASK 0x1f0000
  523. #define BRIDGE_TMO_GIO_TIMEOUT_MASK 0x001000
  524. #define BRIDGE_TMO_PCI_RETRY_CNT_MASK 0x0003ff
  525. #define BRIDGE_TMO_PCI_RETRY_CNT_MAX 0x3ff
  526. /*
  527. * The NASID should be shifted by this amount and stored into the
  528. * interrupt(x) register.
  529. */
  530. #define BRIDGE_INT_ADDR_NASID_SHFT 8
  531. /*
  532. * The BRIDGE_INT_ADDR_DEST_IO bit should be set to send an interrupt to
  533. * memory.
  534. */
  535. #define BRIDGE_INT_ADDR_DEST_IO (1 << 17)
  536. #define BRIDGE_INT_ADDR_DEST_MEM 0
  537. #define BRIDGE_INT_ADDR_MASK (1 << 17)
  538. /* Bridge device(x) register bits definition */
  539. #define BRIDGE_DEV_ERR_LOCK_EN 0x10000000
  540. #define BRIDGE_DEV_PAGE_CHK_DIS 0x08000000
  541. #define BRIDGE_DEV_FORCE_PCI_PAR 0x04000000
  542. #define BRIDGE_DEV_VIRTUAL_EN 0x02000000
  543. #define BRIDGE_DEV_PMU_WRGA_EN 0x01000000
  544. #define BRIDGE_DEV_DIR_WRGA_EN 0x00800000
  545. #define BRIDGE_DEV_DEV_SIZE 0x00400000
  546. #define BRIDGE_DEV_RT 0x00200000
  547. #define BRIDGE_DEV_SWAP_PMU 0x00100000
  548. #define BRIDGE_DEV_SWAP_DIR 0x00080000
  549. #define BRIDGE_DEV_PREF 0x00040000
  550. #define BRIDGE_DEV_PRECISE 0x00020000
  551. #define BRIDGE_DEV_COH 0x00010000
  552. #define BRIDGE_DEV_BARRIER 0x00008000
  553. #define BRIDGE_DEV_GBR 0x00004000
  554. #define BRIDGE_DEV_DEV_SWAP 0x00002000
  555. #define BRIDGE_DEV_DEV_IO_MEM 0x00001000
  556. #define BRIDGE_DEV_OFF_MASK 0x00000fff
  557. #define BRIDGE_DEV_OFF_ADDR_SHFT 20
  558. #define BRIDGE_DEV_PMU_BITS (BRIDGE_DEV_PMU_WRGA_EN | \
  559. BRIDGE_DEV_SWAP_PMU)
  560. #define BRIDGE_DEV_D32_BITS (BRIDGE_DEV_DIR_WRGA_EN | \
  561. BRIDGE_DEV_SWAP_DIR | \
  562. BRIDGE_DEV_PREF | \
  563. BRIDGE_DEV_PRECISE | \
  564. BRIDGE_DEV_COH | \
  565. BRIDGE_DEV_BARRIER)
  566. #define BRIDGE_DEV_D64_BITS (BRIDGE_DEV_DIR_WRGA_EN | \
  567. BRIDGE_DEV_SWAP_DIR | \
  568. BRIDGE_DEV_COH | \
  569. BRIDGE_DEV_BARRIER)
  570. /* Bridge Error Upper register bit field definition */
  571. #define BRIDGE_ERRUPPR_DEVMASTER (0x1 << 20) /* Device was master */
  572. #define BRIDGE_ERRUPPR_PCIVDEV (0x1 << 19) /* Virtual Req value */
  573. #define BRIDGE_ERRUPPR_DEVNUM_SHFT (16)
  574. #define BRIDGE_ERRUPPR_DEVNUM_MASK (0x7 << BRIDGE_ERRUPPR_DEVNUM_SHFT)
  575. #define BRIDGE_ERRUPPR_DEVICE(err) (((err) >> BRIDGE_ERRUPPR_DEVNUM_SHFT) & 0x7)
  576. #define BRIDGE_ERRUPPR_ADDRMASK (0xFFFF)
  577. /* Bridge interrupt mode register bits definition */
  578. #define BRIDGE_INTMODE_CLR_PKT_EN(x) (0x1 << (x))
  579. /* this should be written to the xbow's link_control(x) register */
  580. #define BRIDGE_CREDIT 3
  581. /* RRB assignment register */
  582. #define BRIDGE_RRB_EN 0x8 /* after shifting down */
  583. #define BRIDGE_RRB_DEV 0x7 /* after shifting down */
  584. #define BRIDGE_RRB_VDEV 0x4 /* after shifting down */
  585. #define BRIDGE_RRB_PDEV 0x3 /* after shifting down */
  586. /* RRB status register */
  587. #define BRIDGE_RRB_VALID(r) (0x00010000<<(r))
  588. #define BRIDGE_RRB_INUSE(r) (0x00000001<<(r))
  589. /* RRB clear register */
  590. #define BRIDGE_RRB_CLEAR(r) (0x00000001<<(r))
  591. /* xbox system controller declarations */
  592. #define XBOX_BRIDGE_WID 8
  593. #define FLASH_PROM1_BASE 0xE00000 /* To read the xbox sysctlr status */
  594. #define XBOX_RPS_EXISTS 1 << 6 /* RPS bit in status register */
  595. #define XBOX_RPS_FAIL 1 << 4 /* RPS status bit in register */
  596. /* ========================================================================
  597. */
  598. /*
  599. * Macros for Xtalk to Bridge bus (PCI/GIO) PIO
  600. * refer to section 4.2.1 of Bridge Spec for xtalk to PCI/GIO PIO mappings
  601. */
  602. /* XTALK addresses that map into Bridge Bus addr space */
  603. #define BRIDGE_PIO32_XTALK_ALIAS_BASE 0x000040000000L
  604. #define BRIDGE_PIO32_XTALK_ALIAS_LIMIT 0x00007FFFFFFFL
  605. #define BRIDGE_PIO64_XTALK_ALIAS_BASE 0x000080000000L
  606. #define BRIDGE_PIO64_XTALK_ALIAS_LIMIT 0x0000BFFFFFFFL
  607. #define BRIDGE_PCIIO_XTALK_ALIAS_BASE 0x000100000000L
  608. #define BRIDGE_PCIIO_XTALK_ALIAS_LIMIT 0x0001FFFFFFFFL
  609. /* Ranges of PCI bus space that can be accessed via PIO from xtalk */
  610. #define BRIDGE_MIN_PIO_ADDR_MEM 0x00000000 /* 1G PCI memory space */
  611. #define BRIDGE_MAX_PIO_ADDR_MEM 0x3fffffff
  612. #define BRIDGE_MIN_PIO_ADDR_IO 0x00000000 /* 4G PCI IO space */
  613. #define BRIDGE_MAX_PIO_ADDR_IO 0xffffffff
  614. /* XTALK addresses that map into PCI addresses */
  615. #define BRIDGE_PCI_MEM32_BASE BRIDGE_PIO32_XTALK_ALIAS_BASE
  616. #define BRIDGE_PCI_MEM32_LIMIT BRIDGE_PIO32_XTALK_ALIAS_LIMIT
  617. #define BRIDGE_PCI_MEM64_BASE BRIDGE_PIO64_XTALK_ALIAS_BASE
  618. #define BRIDGE_PCI_MEM64_LIMIT BRIDGE_PIO64_XTALK_ALIAS_LIMIT
  619. #define BRIDGE_PCI_IO_BASE BRIDGE_PCIIO_XTALK_ALIAS_BASE
  620. #define BRIDGE_PCI_IO_LIMIT BRIDGE_PCIIO_XTALK_ALIAS_LIMIT
  621. /*
  622. * Macros for Bridge bus (PCI/GIO) to Xtalk DMA
  623. */
  624. /* Bridge Bus DMA addresses */
  625. #define BRIDGE_LOCAL_BASE 0
  626. #define BRIDGE_DMA_MAPPED_BASE 0x40000000
  627. #define BRIDGE_DMA_MAPPED_SIZE 0x40000000 /* 1G Bytes */
  628. #define BRIDGE_DMA_DIRECT_BASE 0x80000000
  629. #define BRIDGE_DMA_DIRECT_SIZE 0x80000000 /* 2G Bytes */
  630. #define PCI32_LOCAL_BASE BRIDGE_LOCAL_BASE
  631. /* PCI addresses of regions decoded by Bridge for DMA */
  632. #define PCI32_MAPPED_BASE BRIDGE_DMA_MAPPED_BASE
  633. #define PCI32_DIRECT_BASE BRIDGE_DMA_DIRECT_BASE
  634. #define IS_PCI32_LOCAL(x) ((ulong_t)(x) < PCI32_MAPPED_BASE)
  635. #define IS_PCI32_MAPPED(x) ((ulong_t)(x) < PCI32_DIRECT_BASE && \
  636. (ulong_t)(x) >= PCI32_MAPPED_BASE)
  637. #define IS_PCI32_DIRECT(x) ((ulong_t)(x) >= PCI32_MAPPED_BASE)
  638. #define IS_PCI64(x) ((ulong_t)(x) >= PCI64_BASE)
  639. /*
  640. * The GIO address space.
  641. */
  642. /* Xtalk to GIO PIO */
  643. #define BRIDGE_GIO_MEM32_BASE BRIDGE_PIO32_XTALK_ALIAS_BASE
  644. #define BRIDGE_GIO_MEM32_LIMIT BRIDGE_PIO32_XTALK_ALIAS_LIMIT
  645. #define GIO_LOCAL_BASE BRIDGE_LOCAL_BASE
  646. /* GIO addresses of regions decoded by Bridge for DMA */
  647. #define GIO_MAPPED_BASE BRIDGE_DMA_MAPPED_BASE
  648. #define GIO_DIRECT_BASE BRIDGE_DMA_DIRECT_BASE
  649. #define IS_GIO_LOCAL(x) ((ulong_t)(x) < GIO_MAPPED_BASE)
  650. #define IS_GIO_MAPPED(x) ((ulong_t)(x) < GIO_DIRECT_BASE && \
  651. (ulong_t)(x) >= GIO_MAPPED_BASE)
  652. #define IS_GIO_DIRECT(x) ((ulong_t)(x) >= GIO_MAPPED_BASE)
  653. /* PCI to xtalk mapping */
  654. /* given a DIR_OFF value and a pci/gio 32 bits direct address, determine
  655. * which xtalk address is accessed
  656. */
  657. #define BRIDGE_DIRECT_32_SEG_SIZE BRIDGE_DMA_DIRECT_SIZE
  658. #define BRIDGE_DIRECT_32_TO_XTALK(dir_off,adr) \
  659. ((dir_off) * BRIDGE_DIRECT_32_SEG_SIZE + \
  660. ((adr) & (BRIDGE_DIRECT_32_SEG_SIZE - 1)) + PHYS_RAMBASE)
  661. /* 64-bit address attribute masks */
  662. #define PCI64_ATTR_TARG_MASK 0xf000000000000000
  663. #define PCI64_ATTR_TARG_SHFT 60
  664. #define PCI64_ATTR_PREF 0x0800000000000000
  665. #define PCI64_ATTR_PREC 0x0400000000000000
  666. #define PCI64_ATTR_VIRTUAL 0x0200000000000000
  667. #define PCI64_ATTR_BAR 0x0100000000000000
  668. #define PCI64_ATTR_RMF_MASK 0x00ff000000000000
  669. #define PCI64_ATTR_RMF_SHFT 48
  670. #ifndef __ASSEMBLY__
  671. /* Address translation entry for mapped pci32 accesses */
  672. typedef union ate_u {
  673. u64 ent;
  674. struct ate_s {
  675. u64 rmf:16;
  676. u64 addr:36;
  677. u64 targ:4;
  678. u64 reserved:3;
  679. u64 barrier:1;
  680. u64 prefetch:1;
  681. u64 precise:1;
  682. u64 coherent:1;
  683. u64 valid:1;
  684. } field;
  685. } ate_t;
  686. #endif /* !__ASSEMBLY__ */
  687. #define ATE_V 0x01
  688. #define ATE_CO 0x02
  689. #define ATE_PREC 0x04
  690. #define ATE_PREF 0x08
  691. #define ATE_BAR 0x10
  692. #define ATE_PFNSHIFT 12
  693. #define ATE_TIDSHIFT 8
  694. #define ATE_RMFSHIFT 48
  695. #define mkate(xaddr, xid, attr) ((xaddr) & 0x0000fffffffff000ULL) | \
  696. ((xid)<<ATE_TIDSHIFT) | \
  697. (attr)
  698. #define BRIDGE_INTERNAL_ATES 128
  699. struct bridge_controller {
  700. struct pci_controller pc;
  701. struct resource mem;
  702. struct resource io;
  703. struct resource busn;
  704. bridge_t *base;
  705. nasid_t nasid;
  706. unsigned int widget_id;
  707. unsigned int irq_cpu;
  708. u64 baddr;
  709. unsigned int pci_int[8];
  710. };
  711. #define BRIDGE_CONTROLLER(bus) \
  712. ((struct bridge_controller *)((bus)->sysdata))
  713. extern void register_bridge_irq(unsigned int irq);
  714. extern int request_bridge_irq(struct bridge_controller *bc);
  715. extern struct pci_ops bridge_pci_ops;
  716. #endif /* _ASM_PCI_BRIDGE_H */