1258692Sgnn/*-
2258692Sgnn * Copyright (c) 2013 George V. Neville-Neil
3258692Sgnn * All rights reserved.
4258692Sgnn *
5258692Sgnn * Redistribution and use in source and binary forms, with or without
6258692Sgnn * modification, are permitted provided that the following conditions
7258692Sgnn * are met:
8258692Sgnn * 1. Redistributions of source code must retain the above copyright
9258692Sgnn *    notice, this list of conditions and the following disclaimer.
10258692Sgnn * 2. Redistributions in binary form must reproduce the above copyright
11258692Sgnn *    notice, this list of conditions and the following disclaimer in the
12258692Sgnn *    documentation and/or other materials provided with the distribution.
13258692Sgnn *
14258692Sgnn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15258692Sgnn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16258692Sgnn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17258692Sgnn * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18258692Sgnn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19258692Sgnn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20258692Sgnn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21258692Sgnn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22258692Sgnn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23258692Sgnn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24258692Sgnn * SUCH DAMAGE.
25258692Sgnn *
26258692Sgnn * $FreeBSD$
27258692Sgnn */
28258692Sgnn
29258692Sgnn/*
30258692Sgnn * The following set of constants are from Document SFF-8472
31258692Sgnn * "Diagnostic Monitoring Interface for Optical Transceivers" revision
32258692Sgnn * 11.3 published by the SFF Committee on June 11, 2013
33258692Sgnn *
34258692Sgnn * The SFF standard defines two ranges of addresses, each 255 bytes
35258692Sgnn * long for the storage of data and diagnostics on cables, such as
36258692Sgnn * SFP+ optics and TwinAx cables.  The ranges are defined in the
37258692Sgnn * following way:
38258692Sgnn *
39258692Sgnn * Base Address 0xa0 (Identification Data)
40258692Sgnn * 0-95    Serial ID Defined by SFP MSA
41258692Sgnn * 96-127  Vendor Specific Data
42258692Sgnn * 128-255 Reserved
43258692Sgnn *
44258692Sgnn * Base Address 0xa2 (Diagnostic Data)
45258692Sgnn * 0-55    Alarm and Warning Thresholds
46258692Sgnn * 56-95   Cal Constants
47258692Sgnn * 96-119  Real Time Diagnostic Interface
48258692Sgnn * 120-127 Vendor Specific
49258692Sgnn * 128-247 User Writable EEPROM
50258692Sgnn * 248-255 Vendor Specific
51258692Sgnn *
52258692Sgnn * Note that not all addresses are supported.  Where support is
53258692Sgnn * optional this is noted and instructions for checking for the
54258692Sgnn * support are supplied.
55258692Sgnn *
56258692Sgnn * All these values are read across an I2C (i squared C) bus.  Any
57258692Sgnn * device wishing to read these addresses must first have support for
58258692Sgnn * i2c calls.  The Chelsio T4/T5 driver (dev/cxgbe) is one such
59258692Sgnn * driver.
60258692Sgnn */
61258692Sgnn
62258692Sgnn
63258692Sgnn/* Table 3.1 Two-wire interface ID: Data Fields */
64258692Sgnn
65261860Sgnnenum {
66261860Sgnn	SFF_8472_BASE 		= 0xa0,   /* Base address for all our queries. */
67261860Sgnn	SFF_8472_ID		= 0,  /* Transceiver Type (Table 3.2) */
68261860Sgnn	SFF_8472_EXT_ID		= 1,  /* Extended transceiver type (Table 3.3) */
69261860Sgnn	SFF_8472_CONNECTOR	= 2,  /* Connector type (Table 3.4) */
70261860Sgnn	SFF_8472_TRANS_START	= 3,  /* Elec or Optical Compatibility
71258692Sgnn				    * (Table 3.5) */
72261860Sgnn	SFF_8472_TRANS_END	= 10,
73261860Sgnn	SFF_8472_ENCODING	= 11, /* Encoding Code for high speed
74261860Sgnn				     * serial encoding algorithm (see
75261860Sgnn				     * Table 3.6) */
76261860Sgnn	SFF_8472_BITRATE	= 12, /* Nominal signaling rate, units
77261860Sgnn				     * of 100MBd.  (see details for
78261860Sgnn				     * rates > 25.0Gb/s) */
79261860Sgnn	SFF_8472_RATEID		= 13, /* Type of rate select
80261860Sgnn				     * functionality (see Table
81261860Sgnn				     * 3.6a) */
82261860Sgnn	SFF_8472_LEN_SMF_KM	= 14, /* Link length supported for single
83258692Sgnn				    * mode fiber, units of km */
84261860Sgnn	SFF_8472_LEN_SMF	= 15, /* Link length supported for single
85258692Sgnn				    * mode fiber, units of 100 m */
86261860Sgnn	SFF_8472_LEN_50UM	= 16, /* Link length supported for 50 um
87258692Sgnn				    * OM2 fiber, units of 10 m */
88261860Sgnn	SFF_8472_LEN_625UM	= 17, /* Link length supported for 62.5
89258692Sgnn				    * um OM1 fiber, units of 10 m */
90261860Sgnn	SFF_8472_LEN_OM4	= 18, /* Link length supported for 50um
91258692Sgnn				    * OM4 fiber, units of 10m.
92258692Sgnn				    * Alternatively copper or direct
93258692Sgnn				    * attach cable, units of m */
94261860Sgnn	SFF_8472_LEN_OM3	= 19, /* Link length supported for 50 um OM3 fiber, units of 10 m */
95261860Sgnn	SFF_8472_VENDOR_START 	= 20, /* Vendor name [Address A0h, Bytes
96258692Sgnn				    * 20-35] */
97261860Sgnn	SFF_8472_VENDOR_END 	= 35,
98261860Sgnn	SFF_8472_TRANS		= 36, /* Transceiver Code for electronic
99258692Sgnn				    * or optical compatibility (see
100258692Sgnn				    * Table 3.5) */
101261860Sgnn	SFF_8472_VENDOR_OUI_START	= 37, /* Vendor OUI SFP vendor IEEE
102258692Sgnn				    * company ID */
103261860Sgnn	SFF_8472_VENDOR_OUI_END	= 39,
104261860Sgnn	SFF_8472_PN_START 	= 40, /* Vendor PN */
105261860Sgnn	SFF_8472_PN_END 	= 55,
106261860Sgnn	SFF_8472_REV_START 	= 56, /* Vendor Revision */
107261860Sgnn	SFF_8472_REV_END 	= 59,
108261860Sgnn	SFF_8472_WAVELEN_START	= 60, /* Wavelength Laser wavelength
109258692Sgnn				    * (Passive/Active Cable
110258692Sgnn				    * Specification Compliance) */
111261860Sgnn	SFF_8472_WAVELEN_END	= 61,
112261860Sgnn	SFF_8472_CC_BASE	= 63, /* CC_BASE Check code for Base ID
113258692Sgnn				    * Fields (addresses 0 to 62) */
114258692Sgnn
115258692Sgnn/*
116258692Sgnn * Extension Fields (optional) check the options before reading other
117258692Sgnn * addresses.
118258692Sgnn */
119261860Sgnn	SFF_8472_OPTIONS_MSB	= 64, /* Options Indicates which optional
120258692Sgnn				    * transceiver signals are
121258692Sgnn				    * implemented */
122261860Sgnn	SFF_8472_OPTIONS_LSB	= 65, /* (see Table 3.7) */
123261860Sgnn	SFF_8472_BR_MAX		= 66, /* BR max Upper bit rate margin,
124258692Sgnn				    * units of % (see details for
125258692Sgnn				    * rates > 25.0Gb/s) */
126261860Sgnn	SFF_8472_BR_MIN		= 67, /* Lower bit rate margin, units of
127258692Sgnn				    * % (see details for rates >
128258692Sgnn				    * 25.0Gb/s) */
129261860Sgnn	SFF_8472_SN_START 	= 68, /* Vendor SN [Address A0h, Bytes 68-83] */
130261860Sgnn	SFF_8472_SN_END 	= 83,
131261860Sgnn	SFF_8472_DATE_START	= 84, /* Date code Vendor���s manufacturing
132258692Sgnn				    * date code (see Table 3.8) */
133261860Sgnn	SFF_8472_DATE_END	= 91,
134261860Sgnn	SFF_8472_DIAG_TYPE	= 92, /* Diagnostic Monitoring Type
135258692Sgnn				    * Indicates which type of
136258692Sgnn				    * diagnostic monitoring is
137258692Sgnn				    * implemented (if any) in the
138258692Sgnn				    * transceiver (see Table 3.9)
139258692Sgnn				    */
140258692Sgnn
141261860Sgnn	SFF_8472_ENHANCED	= 93, /* Enhanced Options Indicates which
142258692Sgnn				    * optional enhanced features are
143258692Sgnn				    * implemented (if any) in the
144258692Sgnn				    * transceiver (see Table 3.10) */
145261860Sgnn	SFF_8472_COMPLIANCE	= 94, /* SFF-8472 Compliance Indicates
146258692Sgnn				    * which revision of SFF-8472 the
147258692Sgnn				    * transceiver complies with.  (see
148258692Sgnn				    * Table 3.12)*/
149261860Sgnn	SFF_8472_CC_EXT		= 95, /* Check code for the Extended ID
150258692Sgnn				    * Fields (addresses 64 to 94)
151258692Sgnn				    */
152258692Sgnn
153261860Sgnn	SFF_8472_VENDOR_RSRVD_START	= 96,
154261860Sgnn	SFF_8472_VENDOR_RSRVD_END	= 127,
155258692Sgnn
156261860Sgnn	SFF_8472_RESERVED_START	= 128,
157261860Sgnn	SFF_8472_RESERVED_END	= 255
158261860Sgnn};
159258692Sgnn
160261860Sgnn#define SFF_8472_DIAG_IMPL	(1 << 6) /* Required to be 1 */
161261860Sgnn#define SFF_8472_DIAG_INTERNAL	(1 << 5) /* Internal measurements. */
162261860Sgnn#define SFF_8472_DIAG_EXTERNAL	(1 << 4) /* External measurements. */
163261860Sgnn#define SFF_8472_DIAG_POWER	(1 << 3) /* Power measurement type */
164261860Sgnn#define SFF_8472_DIAG_ADDR_CHG	(1 << 2) /* Address change required.
165261860Sgnn					  * See SFF-8472 doc. */
166261860Sgnn
167258692Sgnn /*
168258692Sgnn  * Diagnostics are available at the two wire address 0xa2.  All
169258692Sgnn  * diagnostics are OPTIONAL so you should check 0xa0 registers 92 to
170258692Sgnn  * see which, if any are supported.
171258692Sgnn  */
172258692Sgnn
173261860Sgnnenum {SFF_8472_DIAG = 0xa2};  /* Base address for diagnostics. */
174258692Sgnn
175258692Sgnn /*
176258692Sgnn  *  Table 3.15 Alarm and Warning Thresholds All values are 2 bytes
177258692Sgnn  * and MUST be read in a single read operation starting at the MSB
178258692Sgnn  */
179258692Sgnn
180261860Sgnnenum {
181261860Sgnn	SFF_8472_TEMP_HIGH_ALM		= 0, /* Temp High Alarm  */
182261860Sgnn	SFF_8472_TEMP_LOW_ALM		= 2, /* Temp Low Alarm */
183261860Sgnn	SFF_8472_TEMP_HIGH_WARN		= 4, /* Temp High Warning */
184261860Sgnn	SFF_8472_TEMP_LOW_WARN		= 6, /* Temp Low Warning */
185261860Sgnn	SFF_8472_VOLTAGE_HIGH_ALM	= 8, /* Voltage High Alarm */
186261860Sgnn	SFF_8472_VOLTAGE_LOW_ALM	= 10, /* Voltage Low Alarm */
187261860Sgnn	SFF_8472_VOLTAGE_HIGH_WARN	= 12, /* Voltage High Warning */
188261860Sgnn	SFF_8472_VOLTAGE_LOW_WARN	= 14, /* Voltage Low Warning */
189261860Sgnn	SFF_8472_BIAS_HIGH_ALM		= 16, /* Bias High Alarm */
190261860Sgnn	SFF_8472_BIAS_LOW_ALM		= 18, /* Bias Low Alarm */
191261860Sgnn	SFF_8472_BIAS_HIGH_WARN		= 20, /* Bias High Warning */
192261860Sgnn	SFF_8472_BIAS_LOW_WARN		= 22, /* Bias Low Warning */
193261860Sgnn	SFF_8472_TX_POWER_HIGH_ALM	= 24, /* TX Power High Alarm */
194261860Sgnn	SFF_8472_TX_POWER_LOW_ALM	= 26, /* TX Power Low Alarm */
195261860Sgnn	SFF_8472_TX_POWER_HIGH_WARN	= 28, /* TX Power High Warning */
196261860Sgnn	SFF_8472_TX_POWER_LOW_WARN	= 30, /* TX Power Low Warning */
197261860Sgnn	SFF_8472_RX_POWER_HIGH_ALM	= 32, /* RX Power High Alarm */
198261860Sgnn	SFF_8472_RX_POWER_LOW_ALM	= 34, /* RX Power Low Alarm */
199261860Sgnn	SFF_8472_RX_POWER_HIGH_WARN	= 36, /* RX Power High Warning */
200261860Sgnn	SFF_8472_RX_POWER_LOW_WARN	= 38, /* RX Power Low Warning */
201258692Sgnn
202261860Sgnn	SFF_8472_RX_POWER4	= 56, /* Rx_PWR(4) Single precision
203258692Sgnn				    *  floating point calibration data
204258692Sgnn				    *  - Rx optical power. Bit 7 of
205258692Sgnn				    *  byte 56 is MSB. Bit 0 of byte
206258692Sgnn				    *  59 is LSB. Rx_PWR(4) should be
207258692Sgnn				    *  set to zero for ���internally
208258692Sgnn				    *  calibrated��� devices. */
209261860Sgnn	SFF_8472_RX_POWER3	= 60, /* Rx_PWR(3) Single precision
210258692Sgnn				    * floating point calibration data
211258692Sgnn				    * - Rx optical power.  Bit 7 of
212258692Sgnn				    * byte 60 is MSB. Bit 0 of byte 63
213258692Sgnn				    * is LSB. Rx_PWR(3) should be set
214258692Sgnn				    * to zero for ���internally
215258692Sgnn				    * calibrated��� devices.*/
216261860Sgnn	SFF_8472_RX_POWER2	= 64, /* Rx_PWR(2) Single precision
217258692Sgnn				    * floating point calibration data,
218258692Sgnn				    * Rx optical power.  Bit 7 of byte
219258692Sgnn				    * 64 is MSB, bit 0 of byte 67 is
220258692Sgnn				    * LSB. Rx_PWR(2) should be set to
221258692Sgnn				    * zero for ���internally calibrated���
222258692Sgnn				    * devices. */
223261860Sgnn	SFF_8472_RX_POWER1	= 68, /* Rx_PWR(1) Single precision
224258692Sgnn				    * floating point calibration data,
225258692Sgnn				    * Rx optical power. Bit 7 of byte
226258692Sgnn				    * 68 is MSB, bit 0 of byte 71 is
227258692Sgnn				    * LSB. Rx_PWR(1) should be set to
228258692Sgnn				    * 1 for ���internally calibrated���
229258692Sgnn				    * devices. */
230261860Sgnn	SFF_8472_RX_POWER0	= 72, /* Rx_PWR(0) Single precision
231258692Sgnn				    * floating point calibration data,
232258692Sgnn				    * Rx optical power. Bit 7 of byte
233258692Sgnn				    * 72 is MSB, bit 0 of byte 75 is
234258692Sgnn				    * LSB. Rx_PWR(0) should be set to
235258692Sgnn				    * zero for ���internally calibrated���
236258692Sgnn				    * devices. */
237261860Sgnn	SFF_8472_TX_I_SLOPE	= 76, /* Tx_I(Slope) Fixed decimal
238258692Sgnn				    * (unsigned) calibration data,
239258692Sgnn				    * laser bias current. Bit 7 of
240258692Sgnn				    * byte 76 is MSB, bit 0 of byte 77
241258692Sgnn				    * is LSB. Tx_I(Slope) should be
242258692Sgnn				    * set to 1 for ���internally
243258692Sgnn				    * calibrated��� devices. */
244261860Sgnn	SFF_8472_TX_I_OFFSET	= 78, /* Tx_I(Offset) Fixed decimal
245258692Sgnn				    * (signed two���s complement)
246258692Sgnn				    * calibration data, laser bias
247258692Sgnn				    * current. Bit 7 of byte 78 is
248258692Sgnn				    * MSB, bit 0 of byte 79 is
249258692Sgnn				    * LSB. Tx_I(Offset) should be set
250258692Sgnn				    * to zero for ���internally
251258692Sgnn				    * calibrated��� devices. */
252261860Sgnn	SFF_8472_TX_POWER_SLOPE	= 80, /* Tx_PWR(Slope) Fixed decimal
253258692Sgnn				    * (unsigned) calibration data,
254258692Sgnn				    * transmitter coupled output
255258692Sgnn				    * power. Bit 7 of byte 80 is MSB,
256258692Sgnn				    * bit 0 of byte 81 is LSB.
257258692Sgnn				    * Tx_PWR(Slope) should be set to 1
258258692Sgnn				    * for ���internally calibrated���
259258692Sgnn				    * devices. */
260261860Sgnn	SFF_8472_TX_POWER_OFFSET	= 82, /* Tx_PWR(Offset) Fixed decimal
261261860Sgnn					    * (signed two���s complement)
262261860Sgnn					    * calibration data, transmitter
263261860Sgnn					    * coupled output power. Bit 7 of
264261860Sgnn					    * byte 82 is MSB, bit 0 of byte 83
265261860Sgnn					    * is LSB. Tx_PWR(Offset) should be
266261860Sgnn					    * set to zero for ���internally
267261860Sgnn					    * calibrated��� devices. */
268261860Sgnn	SFF_8472_T_SLOPE	= 84, /* T (Slope) Fixed decimal
269258692Sgnn				    * (unsigned) calibration data,
270258692Sgnn				    * internal module temperature. Bit
271258692Sgnn				    * 7 of byte 84 is MSB, bit 0 of
272258692Sgnn				    * byte 85 is LSB.  T(Slope) should
273258692Sgnn				    * be set to 1 for ���internally
274258692Sgnn				    * calibrated��� devices. */
275261860Sgnn	SFF_8472_T_OFFSET	= 86, /* T (Offset) Fixed decimal (signed
276258692Sgnn				    * two���s complement) calibration
277258692Sgnn				    * data, internal module
278258692Sgnn				    * temperature. Bit 7 of byte 86 is
279258692Sgnn				    * MSB, bit 0 of byte 87 is LSB.
280258692Sgnn				    * T(Offset) should be set to zero
281258692Sgnn				    * for ���internally calibrated���
282258692Sgnn				    * devices. */
283261860Sgnn	SFF_8472_V_SLOPE	= 88, /* V (Slope) Fixed decimal
284258692Sgnn				    * (unsigned) calibration data,
285258692Sgnn				    * internal module supply
286258692Sgnn				    * voltage. Bit 7 of byte 88 is
287258692Sgnn				    * MSB, bit 0 of byte 89 is
288258692Sgnn				    * LSB. V(Slope) should be set to 1
289258692Sgnn				    * for ���internally calibrated���
290258692Sgnn				    * devices. */
291261860Sgnn	SFF_8472_V_OFFSET	= 90, /* V (Offset) Fixed decimal (signed
292258692Sgnn				    * two���s complement) calibration
293258692Sgnn				    * data, internal module supply
294258692Sgnn				    * voltage. Bit 7 of byte 90 is
295258692Sgnn				    * MSB. Bit 0 of byte 91 is
296258692Sgnn				    * LSB. V(Offset) should be set to
297258692Sgnn				    * zero for ���internally calibrated���
298258692Sgnn				    * devices. */
299261860Sgnn	SFF_8472_CHECKSUM	= 95, /* Checksum Byte 95 contains the
300258692Sgnn				    * low order 8 bits of the sum of
301258692Sgnn				    * bytes 0 ��� 94. */
302261860Sgnn	/* Internal measurements. */
303258692Sgnn
304261860Sgnn	SFF_8472_TEMP	 	= 96, /* Internally measured module temperature. */
305261860Sgnn	SFF_8472_VCC 		= 98, /* Internally measured supply
306258692Sgnn				    * voltage in transceiver.
307258692Sgnn				    */
308261860Sgnn	SFF_8472_TX_BIAS	= 100, /* Internally measured TX Bias Current. */
309261860Sgnn	SFF_8472_TX_POWER	= 102, /* Measured TX output power. */
310261860Sgnn	SFF_8472_RX_POWER	= 104, /* Measured RX input power. */
311258692Sgnn
312261860Sgnn	SFF_8472_STATUS		= 110 /* See below */
313261860Sgnn};
314258692Sgnn /* Status Bits Described */
315258692Sgnn
316258692Sgnn/*
317258692Sgnn * TX Disable State Digital state of the TX Disable Input Pin. Updated
318258692Sgnn * within 100ms of change on pin.
319258692Sgnn */
320258692Sgnn#define SFF_8472_STATUS_TX_DISABLE  (1 << 7)
321258692Sgnn
322258692Sgnn/*
323258692Sgnn * Select Read/write bit that allows software disable of
324258692Sgnn * laser. Writing ���1��� disables laser. See Table 3.11 for
325258692Sgnn * enable/disable timing requirements. This bit is ���OR���d with the hard
326258692Sgnn * TX_DISABLE pin value. Note, per SFP MSA TX_DISABLE pin is default
327258692Sgnn * enabled unless pulled low by hardware. If Soft TX Disable is not
328258692Sgnn * implemented, the transceiver ignores the value of this bit. Default
329258692Sgnn * power up value is zero/low.
330258692Sgnn */
331258692Sgnn#define SFF_8472_STATUS_SOFT_TX_DISABLE (1 << 6)
332258692Sgnn
333258692Sgnn/*
334258692Sgnn * RS(1) State Digital state of SFP input pin AS(1) per SFF-8079 or
335258692Sgnn * RS(1) per SFF-8431. Updated within 100ms of change on pin. See A2h
336258692Sgnn * Byte 118, Bit 3 for Soft RS(1) Select control information.
337258692Sgnn */
338258692Sgnn#define SFF_8472_RS_STATE (1 << 5)
339258692Sgnn
340258692Sgnn/*
341258692Sgnn * Rate_Select State [aka. ���RS(0)���] Digital state of the SFP
342258692Sgnn * Rate_Select Input Pin. Updated within 100ms of change on pin. Note:
343258692Sgnn * This pin is also known as AS(0) in SFF-8079 and RS(0) in SFF-8431.
344258692Sgnn */
345258692Sgnn#define SFF_8472_STATUS_SELECT_STATE (1 << 4)
346258692Sgnn
347258692Sgnn/*
348258692Sgnn * Read/write bit that allows software rate select control. Writing
349258692Sgnn * ���1��� selects full bandwidth operation. This bit is ���OR���d with the
350258692Sgnn * hard Rate_Select, AS(0) or RS(0) pin value. See Table 3.11 for
351258692Sgnn * timing requirements. Default at power up is logic zero/low. If Soft
352258692Sgnn * Rate Select is not implemented, the transceiver ignores the value
353258692Sgnn * of this bit. Note: Specific transceiver behaviors of this bit are
354258692Sgnn * identified in Table 3.6a and referenced documents. See Table 3.18a,
355258692Sgnn * byte 118, bit 3 for Soft RS(1) Select.
356258692Sgnn */
357258692Sgnn#define SFF_8472_STATUS_SOFT_RATE_SELECT (1 << 3)
358258692Sgnn
359258692Sgnn/*
360258692Sgnn * TX Fault State Digital state of the TX Fault Output Pin. Updated
361258692Sgnn * within 100ms of change on pin.
362258692Sgnn */
363258692Sgnn#define SFF_8472_STATUS_TX_FAULT_STATE (1 << 2)
364258692Sgnn
365258692Sgnn/*
366258692Sgnn * Digital state of the RX_LOS Output Pin. Updated within 100ms of
367258692Sgnn * change on pin.
368258692Sgnn */
369258692Sgnn#define SFF_8472_STATUS_RX_LOS (1 << 1)
370258692Sgnn
371258692Sgnn/*
372258692Sgnn * Indicates transceiver has achieved power up and data is ready. Bit
373258692Sgnn * remains high until data is ready to be read at which time the
374258692Sgnn * device sets the bit low.
375258692Sgnn */
376258692Sgnn#define SFF_8472_STATUS_DATA_READY (1 << 0)
377258692Sgnn
378286810Smelifaro/*
379286810Smelifaro * Table 3.2 Identifier values.
380286810Smelifaro * Identifier constants has taken from SFF-8024 rev 2.9 table 4.1
381286810Smelifaro * (as referenced by table 3.2 footer)
382286810Smelifaro * */
383261860Sgnnenum {
384286810Smelifaro	SFF_8024_ID_UNKNOWN	= 0x0, /* Unknown or unspecified */
385286810Smelifaro	SFF_8024_ID_GBIC	= 0x1, /* GBIC */
386286810Smelifaro	SFF_8024_ID_SFF		= 0x2, /* Module soldered to motherboard (ex: SFF)*/
387286810Smelifaro	SFF_8024_ID_SFP		= 0x3, /* SFP or SFP ���Plus��� */
388286810Smelifaro	SFF_8024_ID_XBI		= 0x4, /* 300 pin XBI */
389286810Smelifaro	SFF_8024_ID_XENPAK	= 0x5, /* Xenpak */
390286810Smelifaro	SFF_8024_ID_XFP		= 0x6, /* XFP */
391286810Smelifaro	SFF_8024_ID_XFF		= 0x7, /* XFF */
392286810Smelifaro	SFF_8024_ID_XFPE	= 0x8, /* XFP-E */
393286810Smelifaro	SFF_8024_ID_XPAK	= 0x9, /* XPAk */
394286810Smelifaro	SFF_8024_ID_X2		= 0xA, /* X2 */
395286810Smelifaro	SFF_8024_ID_DWDM_SFP	= 0xB, /* DWDM-SFP */
396286810Smelifaro	SFF_8024_ID_QSFP	= 0xC, /* QSFP */
397286810Smelifaro	SFF_8024_ID_QSFPPLUS	= 0xD, /* QSFP+ */
398286810Smelifaro	SFF_8024_ID_CXP		= 0xE, /* CXP */
399286810Smelifaro	SFF_8024_ID_HD4X	= 0xF, /* Shielded Mini Multilane HD 4X */
400286810Smelifaro	SFF_8024_ID_HD8X	= 0x10, /* Shielded Mini Multilane HD 8X */
401286810Smelifaro	SFF_8024_ID_QSFP28	= 0x11, /* QSFP28 */
402286810Smelifaro	SFF_8024_ID_CXP2	= 0x12, /* CXP2 (aka CXP28) */
403286810Smelifaro	SFF_8024_ID_CDFP	= 0x13, /* CDFP (Style 1/Style 2) */
404286810Smelifaro	SFF_8024_ID_SMM4	= 0x14, /* Shielded Mini Multilate HD 4X Fanout */
405286810Smelifaro	SFF_8024_ID_SMM8	= 0x15, /* Shielded Mini Multilate HD 8X Fanout */
406286810Smelifaro	SFF_8024_ID_CDFP3	= 0x16, /* CDFP (Style3) */
407286810Smelifaro	SFF_8024_ID_LAST	= SFF_8024_ID_CDFP3
408261860Sgnn	};
409258692Sgnn
410286810Smelifarostatic const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {"Unknown",
411258692Sgnn					     "GBIC",
412258692Sgnn					     "SFF",
413286810Smelifaro					     "SFP/SFP+/SFP28",
414258692Sgnn					     "XBI",
415258692Sgnn					     "Xenpak",
416258692Sgnn					     "XFP",
417258692Sgnn					     "XFF",
418258692Sgnn					     "XFP-E",
419286810Smelifaro					     "XPAK",
420258692Sgnn					     "X2",
421286810Smelifaro					     "DWDM-SFP/SFP+",
422286810Smelifaro					     "QSFP",
423286810Smelifaro					     "QSFP+",
424286810Smelifaro					     "CXP",
425286810Smelifaro					     "HD4X",
426286810Smelifaro					     "HD8X",
427286810Smelifaro					     "QSFP28",
428286810Smelifaro					     "CXP2",
429286810Smelifaro					     "CDFP",
430286810Smelifaro					     "SMM4",
431286810Smelifaro					     "SMM8",
432286810Smelifaro					     "CDFP3"};
433258692Sgnn
434286810Smelifaro/* Keep compability with old definitions */
435286810Smelifaro#define	SFF_8472_ID_UNKNOWN	SFF_8024_ID_UNKNOWN
436286810Smelifaro#define	SFF_8472_ID_GBIC	SFF_8024_ID_GBIC
437286810Smelifaro#define	SFF_8472_ID_SFF		SFF_8024_ID_SFF
438286810Smelifaro#define	SFF_8472_ID_SFP		SFF_8024_ID_SFP
439286810Smelifaro#define	SFF_8472_ID_XBI		SFF_8024_ID_XBI
440286810Smelifaro#define	SFF_8472_ID_XENPAK	SFF_8024_ID_XENPAK
441286810Smelifaro#define	SFF_8472_ID_XFP		SFF_8024_ID_XFP
442286810Smelifaro#define	SFF_8472_ID_XFF		SFF_8024_ID_XFF
443286810Smelifaro#define	SFF_8472_ID_XFPE	SFF_8024_ID_XFPE
444286810Smelifaro#define	SFF_8472_ID_XPAK	SFF_8024_ID_XPAK
445286810Smelifaro#define	SFF_8472_ID_X2		SFF_8024_ID_X2
446286810Smelifaro#define	SFF_8472_ID_DWDM_SFP	SFF_8024_ID_DWDM_SFP
447286810Smelifaro#define	SFF_8472_ID_QSFP	SFF_8024_ID_QSFP
448286810Smelifaro#define	SFF_8472_ID_LAST	SFF_8024_ID_LAST
449286810Smelifaro
450286810Smelifaro#define	sff_8472_id		sff_8024_id
451286810Smelifaro
452286810Smelifaro/*
453286810Smelifaro * Table 3.9 Diagnostic Monitoring Type (byte 92)
454286810Smelifaro * bits described.
455286810Smelifaro */
456286810Smelifaro
457286810Smelifaro/*
458286810Smelifaro * Digital diagnostic monitoring implemented.
459286810Smelifaro * Set to 1 for transceivers implementing DDM.
460286810Smelifaro */
461286810Smelifaro#define	SFF_8472_DDM_DONE	(1 << 6)
462286810Smelifaro
463286810Smelifaro/*
464286810Smelifaro * Measurements are internally calibrated.
465286810Smelifaro */
466286810Smelifaro#define	SFF_8472_DDM_INTERNAL	(1 << 5)
467286810Smelifaro
468286810Smelifaro/*
469286810Smelifaro * Measurements are externally calibrated.
470286810Smelifaro */
471286810Smelifaro#define	SFF_8472_DDM_EXTERNAL	(1 << 4)
472286810Smelifaro
473286810Smelifaro/*
474286810Smelifaro * Received power measurement type
475286810Smelifaro * 0 = OMA, 1 = average power
476286810Smelifaro */
477286810Smelifaro#define	SFF_8472_DDM_PMTYPE	(1 << 3)
478286810Smelifaro
479258692Sgnn/* Table 3.13 and 3.14 Temperature Conversion Values */
480258692Sgnn#define SFF_8472_TEMP_SIGN (1 << 15)
481258692Sgnn#define SFF_8472_TEMP_SHIFT  8
482258692Sgnn#define SFF_8472_TEMP_MSK  0xEF00
483258692Sgnn#define SFF_8472_TEMP_FRAC 0x00FF
484258692Sgnn
485258692Sgnn/* Internal Callibration Conversion factors */
486258692Sgnn
487258692Sgnn/*
488258692Sgnn * Represented as a 16 bit unsigned integer with the voltage defined
489258692Sgnn * as the full 16 bit value (0 ��� 65535) with LSB equal to 100 uVolt,
490258692Sgnn * yielding a total range of 0 to +6.55 Volts.
491258692Sgnn */
492258692Sgnn#define SFF_8472_VCC_FACTOR 10000.0
493258692Sgnn
494258692Sgnn/*
495258692Sgnn * Represented as a 16 bit unsigned integer with the current defined
496258692Sgnn * as the full 16 bit value (0 ��� 65535) with LSB equal to 2 uA,
497258692Sgnn * yielding a total range of 0 to 131 mA.
498258692Sgnn */
499258692Sgnn
500258692Sgnn#define SFF_8472_BIAS_FACTOR 2000.0
501258692Sgnn
502258692Sgnn/*
503258692Sgnn * Represented as a 16 bit unsigned integer with the power defined as
504258692Sgnn * the full 16 bit value (0 ��� 65535) with LSB equal to 0.1 uW,
505258692Sgnn * yielding a total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm).
506258692Sgnn */
507258692Sgnn
508258692Sgnn#define SFF_8472_POWER_FACTOR 10000.0
509