1
2
3
4
5
6
7#define QSFP_DEV 0xA0
8#define QSFP_PWR_LAG_MSEC 2000
9#define QSFP_MODPRS_LAG_MSEC 20
10
11#define QSFP_MAX_NUM_PAGES 5
12
13
14
15
16
17#define QSFP_HFI0_I2CCLK BIT(0)
18#define QSFP_HFI0_I2CDAT BIT(1)
19#define QSFP_HFI0_RESET_N BIT(2)
20#define QSFP_HFI0_INT_N BIT(3)
21#define QSFP_HFI0_MODPRST_N BIT(4)
22
23
24#define QSFP_PAGESIZE 256
25
26#define QSFP_RW_BOUNDARY 128
27
28
29#define __QSFP_OFFSET_SIZE 1
30#define QSFP_OFFSET_SIZE (__QSFP_OFFSET_SIZE << 8)
31
32
33
34
35#define QSFP_MONITOR_VAL_START 22
36#define QSFP_MONITOR_VAL_END 81
37#define QSFP_MONITOR_RANGE (QSFP_MONITOR_VAL_END - QSFP_MONITOR_VAL_START + 1)
38#define QSFP_TX_CTRL_BYTE_OFFS 86
39#define QSFP_PWR_CTRL_BYTE_OFFS 93
40#define QSFP_CDR_CTRL_BYTE_OFFS 98
41
42#define QSFP_PAGE_SELECT_BYTE_OFFS 127
43
44#define QSFP_MOD_ID_OFFS 128
45
46
47
48
49
50#define QSFP_MOD_PWR_OFFS 129
51
52
53
54
55#define QSFP_NOM_BIT_RATE_100_OFFS 140
56
57
58
59#define QSFP_MOD_LEN_OFFS 146
60
61
62
63
64#define QSFP_MOD_TECH_OFFS 147
65extern const char *const hfi1_qsfp_devtech[16];
66
67#define QSFP_IS_ACTIVE(tech) ((0xA2FF >> ((tech) >> 4)) & 1)
68
69#define QSFP_IS_ACTIVE_FAR(tech) ((0x32FF >> ((tech) >> 4)) & 1)
70
71#define QSFP_HAS_ATTEN(tech) ((0x4D00 >> ((tech) >> 4)) & 1)
72
73#define QSFP_IS_CU(tech) ((0xED00 >> ((tech) >> 4)) & 1)
74#define QSFP_TECH_1490 9
75
76#define QSFP_OUI(oui) (((unsigned)oui[0] << 16) | ((unsigned)oui[1] << 8) | \
77 oui[2])
78#define QSFP_OUI_AMPHENOL 0x415048
79#define QSFP_OUI_FINISAR 0x009065
80#define QSFP_OUI_GORE 0x002177
81
82
83#define QSFP_VEND_OFFS 148
84#define QSFP_VEND_LEN 16
85
86#define QSFP_IBXCV_OFFS 164
87
88#define QSFP_VOUI_OFFS 165
89#define QSFP_VOUI_LEN 3
90
91#define QSFP_PN_OFFS 168
92#define QSFP_PN_LEN 16
93
94#define QSFP_REV_OFFS 184
95#define QSFP_REV_LEN 2
96
97
98
99
100
101#define QSFP_ATTEN_OFFS 186
102#define QSFP_ATTEN_LEN 2
103
104
105
106
107
108#define QSFP_CU_ATTEN_7G_OFFS 188
109#define QSFP_CU_ATTEN_12G_OFFS 189
110
111
112#define QSFP_CC_OFFS 191
113#define QSFP_EQ_INFO_OFFS 193
114#define QSFP_CDR_INFO_OFFS 194
115
116#define QSFP_SN_OFFS 196
117#define QSFP_SN_LEN 16
118
119#define QSFP_DATE_OFFS 212
120#define QSFP_DATE_LEN 6
121
122#define QSFP_LOT_OFFS 218
123#define QSFP_LOT_LEN 2
124
125
126#define QSFP_NOM_BIT_RATE_250_OFFS 222
127
128#define QSFP_CC_EXT_OFFS 223
129
130
131
132
133#define QSFP_DATA_NOT_READY 0x01
134
135#define QSFP_HIGH_TEMP_ALARM 0x80
136#define QSFP_LOW_TEMP_ALARM 0x40
137#define QSFP_HIGH_TEMP_WARNING 0x20
138#define QSFP_LOW_TEMP_WARNING 0x10
139
140#define QSFP_HIGH_VCC_ALARM 0x80
141#define QSFP_LOW_VCC_ALARM 0x40
142#define QSFP_HIGH_VCC_WARNING 0x20
143#define QSFP_LOW_VCC_WARNING 0x10
144
145#define QSFP_HIGH_POWER_ALARM 0x88
146#define QSFP_LOW_POWER_ALARM 0x44
147#define QSFP_HIGH_POWER_WARNING 0x22
148#define QSFP_LOW_POWER_WARNING 0x11
149
150#define QSFP_HIGH_BIAS_ALARM 0x88
151#define QSFP_LOW_BIAS_ALARM 0x44
152#define QSFP_HIGH_BIAS_WARNING 0x22
153#define QSFP_LOW_BIAS_WARNING 0x11
154
155#define QSFP_ATTEN_SDR(attenarray) (attenarray[0])
156#define QSFP_ATTEN_DDR(attenarray) (attenarray[1])
157
158
159
160
161
162
163
164
165
166
167
168
169struct qsfp_data {
170
171 struct hfi1_pportdata *ppd;
172 struct work_struct qsfp_work;
173 u8 cache[QSFP_MAX_NUM_PAGES * 128];
174
175 spinlock_t qsfp_lock;
176 u8 check_interrupt_flags;
177 u8 reset_needed;
178 u8 limiting_active;
179 u8 cache_valid;
180 u8 cache_refresh_required;
181};
182
183int refresh_qsfp_cache(struct hfi1_pportdata *ppd,
184 struct qsfp_data *cp);
185int get_qsfp_power_class(u8 power_byte);
186int qsfp_mod_present(struct hfi1_pportdata *ppd);
187int get_cable_info(struct hfi1_devdata *dd, u32 port_num, u32 addr,
188 u32 len, u8 *data);
189
190int i2c_write(struct hfi1_pportdata *ppd, u32 target, int i2c_addr,
191 int offset, void *bp, int len);
192int i2c_read(struct hfi1_pportdata *ppd, u32 target, int i2c_addr,
193 int offset, void *bp, int len);
194int qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
195 int len);
196int qsfp_read(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
197 int len);
198int one_qsfp_write(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
199 int len);
200int one_qsfp_read(struct hfi1_pportdata *ppd, u32 target, int addr, void *bp,
201 int len);
202struct hfi1_asic_data;
203int set_up_i2c(struct hfi1_devdata *dd, struct hfi1_asic_data *ad);
204void clean_up_i2c(struct hfi1_devdata *dd, struct hfi1_asic_data *ad);
205