qib_7220.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #ifndef _QIB_7220_H
  2. #define _QIB_7220_H
  3. /*
  4. * Copyright (c) 2007, 2009, 2010 QLogic Corporation. All rights reserved.
  5. *
  6. * This software is available to you under a choice of one of two
  7. * licenses. You may choose to be licensed under the terms of the GNU
  8. * General Public License (GPL) Version 2, available from the file
  9. * COPYING in the main directory of this source tree, or the
  10. * OpenIB.org BSD license below:
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above
  17. * copyright notice, this list of conditions and the following
  18. * disclaimer.
  19. *
  20. * - Redistributions in binary form must reproduce the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer in the documentation and/or other materials
  23. * provided with the distribution.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  29. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  30. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  31. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32. * SOFTWARE.
  33. */
  34. /* grab register-defs auto-generated by HW */
  35. #include "qib_7220_regs.h"
  36. /* The number of eager receive TIDs for context zero. */
  37. #define IBA7220_KRCVEGRCNT 2048U
  38. #define IB_7220_LT_STATE_CFGRCVFCFG 0x09
  39. #define IB_7220_LT_STATE_CFGWAITRMT 0x0a
  40. #define IB_7220_LT_STATE_TXREVLANES 0x0d
  41. #define IB_7220_LT_STATE_CFGENH 0x10
  42. struct qib_chip_specific {
  43. u64 __iomem *cregbase;
  44. u64 *cntrs;
  45. u64 *portcntrs;
  46. spinlock_t sdepb_lock; /* serdes EPB bus */
  47. spinlock_t rcvmod_lock; /* protect rcvctrl shadow changes */
  48. spinlock_t gpio_lock; /* RMW of shadows/regs for ExtCtrl and GPIO */
  49. u64 hwerrmask;
  50. u64 errormask;
  51. u64 gpio_out; /* shadow of kr_gpio_out, for rmw ops */
  52. u64 gpio_mask; /* shadow the gpio mask register */
  53. u64 extctrl; /* shadow the gpio output enable, etc... */
  54. u32 ncntrs;
  55. u32 nportcntrs;
  56. u32 cntrnamelen;
  57. u32 portcntrnamelen;
  58. u32 numctxts;
  59. u32 rcvegrcnt;
  60. u32 autoneg_tries;
  61. u32 serdes_first_init_done;
  62. u32 sdmabufcnt;
  63. u32 lastbuf_for_pio;
  64. u32 updthresh; /* current AvailUpdThld */
  65. u32 updthresh_dflt; /* default AvailUpdThld */
  66. int irq;
  67. u8 presets_needed;
  68. u8 relock_timer_active;
  69. char emsgbuf[128];
  70. char sdmamsgbuf[192];
  71. char bitsmsgbuf[64];
  72. struct timer_list relock_timer;
  73. unsigned int relock_interval; /* in jiffies */
  74. };
  75. struct qib_chippport_specific {
  76. struct qib_pportdata pportdata;
  77. wait_queue_head_t autoneg_wait;
  78. struct delayed_work autoneg_work;
  79. struct timer_list chase_timer;
  80. /*
  81. * these 5 fields are used to establish deltas for IB symbol
  82. * errors and linkrecovery errors. They can be reported on
  83. * some chips during link negotiation prior to INIT, and with
  84. * DDR when faking DDR negotiations with non-IBTA switches.
  85. * The chip counters are adjusted at driver unload if there is
  86. * a non-zero delta.
  87. */
  88. u64 ibdeltainprog;
  89. u64 ibsymdelta;
  90. u64 ibsymsnap;
  91. u64 iblnkerrdelta;
  92. u64 iblnkerrsnap;
  93. u64 ibcctrl; /* kr_ibcctrl shadow */
  94. u64 ibcddrctrl; /* kr_ibcddrctrl shadow */
  95. unsigned long chase_end;
  96. u32 last_delay_mult;
  97. };
  98. /*
  99. * This header file provides the declarations and common definitions
  100. * for (mostly) manipulation of the SerDes blocks within the IBA7220.
  101. * the functions declared should only be called from within other
  102. * 7220-related files such as qib_iba7220.c or qib_sd7220.c.
  103. */
  104. int qib_sd7220_presets(struct qib_devdata *dd);
  105. int qib_sd7220_init(struct qib_devdata *dd);
  106. void qib_sd7220_clr_ibpar(struct qib_devdata *);
  107. /*
  108. * Below used for sdnum parameter, selecting one of the two sections
  109. * used for PCIe, or the single SerDes used for IB, which is the
  110. * only one currently used
  111. */
  112. #define IB_7220_SERDES 2
  113. static inline u32 qib_read_kreg32(const struct qib_devdata *dd,
  114. const u16 regno)
  115. {
  116. if (!dd->kregbase || !(dd->flags & QIB_PRESENT))
  117. return -1;
  118. return readl((u32 __iomem *)&dd->kregbase[regno]);
  119. }
  120. static inline u64 qib_read_kreg64(const struct qib_devdata *dd,
  121. const u16 regno)
  122. {
  123. if (!dd->kregbase || !(dd->flags & QIB_PRESENT))
  124. return -1;
  125. return readq(&dd->kregbase[regno]);
  126. }
  127. static inline void qib_write_kreg(const struct qib_devdata *dd,
  128. const u16 regno, u64 value)
  129. {
  130. if (dd->kregbase)
  131. writeq(value, &dd->kregbase[regno]);
  132. }
  133. void set_7220_relock_poll(struct qib_devdata *, int);
  134. void shutdown_7220_relock_poll(struct qib_devdata *);
  135. void toggle_7220_rclkrls(struct qib_devdata *);
  136. #endif /* _QIB_7220_H */