xref: /dragonfly/sys/bus/smbus/ichiic/ig4_reg.h (revision 9d626b29)
1 /*
2  * Copyright (c) 2014 The DragonFly Project.  All rights reserved.
3  *
4  * This code is derived from software contributed to The DragonFly Project
5  * by Matthew Dillon <dillon@backplane.com>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name of The DragonFly Project nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific, prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  */
34 /*
35  * Intel 4th generation mobile cpus integrated I2C device.
36  *
37  * Datasheet reference:  Section 22.
38  *
39  * http://www.intel.com/content/www/us/en/processors/core/4th-gen-core-family-mobile-i-o-datasheet.html?wapkw=datasheets+4th+generation
40  *
41  * This is a from-scratch driver under the BSD license using the Intel data
42  * sheet and the linux driver for reference.  All code is freshly written
43  * without referencing the linux driver code.  However, during testing
44  * I am also using the linux driver code as a reference to help resolve any
45  * issues that come.  These will be specifically documented in the code.
46  *
47  * Please see protocol notes in section 5.21.  This controller is an I2C
48  * master only and cannot act as a slave.  The IO voltage should be set by
49  * the BIOS.  Standard (100Kb/s) and Fast (400Kb/s) and fast mode plus
50  * (1MB/s) is supported.  High speed mode (3.4 MB/s) is NOT supported.
51  */
52 
53 #ifndef _BUS_SMBUS_INTELGEN4_IG4_REG_H_
54 #define _BUS_SMBUS_INTELGEN4_IG4_REG_H_
55 
56 /*
57  * 22.2 MMIO registers can be accessed through BAR0 in PCI mode or through
58  *	BAR1 when in ACPI mode.
59  *
60  *	Register width is 32-bits
61  *
62  * 22.2 Default Values on device reset are 0 except as specified here:
63  *	TAR_ADD		0x00000055
64  *	SS_SCL_HCNT	0x00000264
65  *	SS_SCL_LCNT	0x000002C2
66  *	FS_SCL_HCNT	0x0000006E
67  *	FS_SCL_LCNT	0x000000CF
68  *	INTR_MASK	0x000008FF
69  *	I2C_STA		0x00000006
70  *	SDA_HOLD	0x00000001
71  *	SDA_SETUP	0x00000064
72  *	COMP_PARAM1	0x00FFFF6E
73  *	COMP_VER	0x3131352A
74  */
75 
76 #define IG4_REG_CTL		0x0000	/* RW	Control Register */
77 #define IG4_REG_TAR_ADD		0x0004	/* RW	Target Address */
78 #define IG4_REG_DATA_CMD	0x0010	/* RW	Data Buffer and Command */
79 #define IG4_REG_SS_SCL_HCNT	0x0014	/* RW	Std Speed clock High Count */
80 #define IG4_REG_SS_SCL_LCNT	0x0018	/* RW	Std Speed clock Low Count */
81 #define IG4_REG_FS_SCL_HCNT	0x001C	/* RW	Fast Speed clock High Count */
82 #define IG4_REG_FS_SCL_LCNT	0x0020	/* RW	Fast Speed clock Low Count */
83 #define IG4_REG_INTR_STAT	0x002C	/* RO	Interrupt Status */
84 #define IG4_REG_INTR_MASK	0x0030	/* RW	Interrupt Mask */
85 #define IG4_REG_RAW_INTR_STAT	0x0034	/* RO	Raw Interrupt Status */
86 #define IG4_REG_RX_TL		0x0038	/* RW	Receive FIFO Threshold */
87 #define IG4_REG_TX_TL		0x003C	/* RW	Transmit FIFO Threshold */
88 #define IG4_REG_CLR_INTR	0x0040	/* RO	Clear Interrupt */
89 #define IG4_REG_CLR_RX_UNDER	0x0044	/* RO	Clear RX_Under Interrupt */
90 #define IG4_REG_CLR_RX_OVER	0x0048	/* RO	Clear RX_Over Interrupt */
91 #define IG4_REG_CLR_TX_OVER	0x004C	/* RO	Clear TX_Over Interrupt */
92 #define IG4_REG_CLR_TX_ABORT	0x0054	/* RO	Clear TX_Abort Interrupt */
93 #define IG4_REG_CLR_ACTIVITY	0x005C	/* RO	Clear Activity Interrupt */
94 #define IG4_REG_CLR_STOP_DET	0x0060	/* RO	Clear STOP Detection Int */
95 #define IG4_REG_CLR_START_DET	0x0064	/* RO	Clear START Detection Int */
96 #define IG4_REG_CLR_GEN_CALL	0x0068	/* RO	Clear General Call Interrupt */
97 #define IG4_REG_I2C_EN		0x006C	/* RW	I2C Enable */
98 #define IG4_REG_I2C_STA		0x0070	/* RO	I2C Status */
99 #define IG4_REG_TXFLR		0x0074	/* RO	Transmit FIFO Level */
100 #define IG4_REG_RXFLR		0x0078	/* RO	Receive FIFO Level */
101 #define IG4_REG_SDA_HOLD	0x007C	/* RW	SDA Hold Time Length */
102 #define IG4_REG_TX_ABRT_SOURCE	0x0080	/* RO	Transmit Abort Source */
103 #define IG4_REG_SLV_DATA_NACK	0x0084	/* RW	General Slave Data NACK */
104 #define IG4_REG_DMA_CTRL	0x0088	/* RW	DMA Control */
105 #define IG4_REG_DMA_TDLR	0x008C	/* RW	DMA Transmit Data Level */
106 #define IG4_REG_DMA_RDLR	0x0090	/* RW	DMA Receive Data Level */
107 #define IG4_REG_SDA_SETUP	0x0094	/* RW	SDA Setup */
108 #define IG4_REG_ENABLE_STATUS	0x009C	/* RO	Enable Status */
109 /* Available at least on Atom SoCs and Haswell mobile. */
110 #define IG4_REG_COMP_PARAM1	0x00F4	/* RO	Component Parameter */
111 #define IG4_REG_COMP_VER	0x00F8	/* RO	Component Version */
112 /* Available at least on Atom SoCs */
113 #define IG4_REG_COMP_TYPE	0x00FC	/* RO	Probe width/endian? (linux) */
114 /* Available on Skylake-U/Y and Kaby Lake-U/Y */
115 #define IG4_REG_RESETS_SKL	0x0204	/* RW	Reset Register */
116 #define IG4_REG_ACTIVE_LTR_VALUE 0x0210	/* RW	Active LTR Value */
117 #define IG4_REG_IDLE_LTR_VALUE	0x0214	/* RW	Idle LTR Value */
118 /* Available at least on Atom SoCs */
119 #define IG4_REG_CLK_PARMS	0x0800	/* RW	Clock Parameters */
120 /* Available at least on Atom SoCs and Haswell mobile */
121 #define IG4_REG_RESETS_HSW	0x0804	/* RW	Reset Register */
122 #define IG4_REG_GENERAL		0x0808	/* RW	General Register */
123 /* These LTR config registers are at least available on Haswell mobile. */
124 #define IG4_REG_SW_LTR_VALUE	0x0810	/* RW	SW LTR Value */
125 #define IG4_REG_AUTO_LTR_VALUE	0x0814	/* RW	Auto LTR Value */
126 
127 /*
128  * CTL - Control Register 		22.2.1
129  *	 Default Value: 0x0000007F.
130  *
131  *	RESTARTEN	- RW Restart Enable
132  *	10BIT		- RW Controller operates in 10-bit mode, else 7-bit
133  *
134  * NOTE: When restart is disabled the controller is incapable of
135  *	 performing the following functions:
136  *
137  *		 Sending a START Byte
138  *		 Performing any high-speed mode op
139  *		 Performing direction changes in combined format mode
140  *		 Performing a read operation with a 10-bit address
141  *
142  *	 Attempting to perform the above operations will result in the
143  *	 TX_ABORT bit being set in RAW_INTR_STAT.
144  */
145 #define IG4_CTL_SLAVE_DISABLE	0x0040	/* snarfed from linux */
146 #define IG4_CTL_RESTARTEN	0x0020	/* Allow Restart when master */
147 #define IG4_CTL_10BIT		0x0010	/* ctlr accepts 10-bit addresses */
148 #define IG4_CTL_SPEED_FAST	0x0004	/* snarfed from linux */
149 #define IG4_CTL_SPEED_STD	0x0002	/* snarfed from linux */
150 #define IG4_CTL_MASTER		0x0001	/* snarfed from linux */
151 
152 /*
153  * TAR_ADD - Target Address Register	22.2.2
154  *	     Default Value: 0x00000055F
155  *
156  *	10BIT		- RW controller starts its transfers in 10-bit
157  *			  address mode, else 7-bit.
158  *
159  *	SPECIAL		- RW Indicates whether software performs a General Call
160  *			  or START BYTE command.
161  *
162  *		0	  Ignore GC_OR_START and use TAR address.
163  *
164  *		1	  Perform special I2C Command based on GC_OR_START.
165  *
166  *	GC_OR_START	- RW (only if SPECIAL is set)
167  *
168  *		0	  General Call Address.  After issuing a General Call,
169  *			  only writes may be performed.  Attempting to issue
170  *			  a read command results in IX_ABRT in RAW_INTR_STAT.
171  *			  The controller remains in General Call mode until
172  *			  bit 11 (SPECIAL) is cleared.
173  *
174  *		1	  START BYTE.
175  *
176  *
177  * 	IC_TAR		- RW when transmitting a general call, these bits are
178  *			  ignored.  To generate a START BYTE, the address
179  *			  needs to be written into these bits once.
180  *
181  * This register should only be updated when the IIC is disabled (I2C_ENABLE=0)
182  */
183 #define IG4_TAR_10BIT		0x1000	/* start xfer in 10-bit mode */
184 #define IG4_TAR_SPECIAL		0x0800	/* Perform special command */
185 #define IG4_TAR_GC_OR_START	0x0400	/* General Call or Start */
186 #define IG4_TAR_ADDR_MASK	0x03FF	/* Target address */
187 
188 /*
189  * TAR_DATA_CMD - Data Buffer and Command Register	22.2.3
190  *
191  *	RESTART		- RW This bit controls whether a forced RESTART is
192  *			  issued before the byte is sent or received.
193  *
194  *		0	  If not set a RESTART is only issued if the tranfer
195  *			  direction is changing from the previous command.
196  *
197  *		1	  A RESTART is issued before the byte is sent or
198  *			  received, regardless of whether or not the transfer
199  *			  direction is changing from the previous command.
200  *
201  *	STOP		- RW This bit controls whether a STOP is issued after
202  *			  the byte is sent or received.
203  *
204  *		0	  STOP is not issued after this byte, regardless
205  *			  of whether or not the Tx FIFO is empty.
206  *
207  *		1	  STOP is issued after this byte, regardless of
208  *			  whether or not the Tx FIFO is empty.  If the
209  *			  Tx FIFO is not empty the master immediately tries
210  *			  to start a new transfer by issuing a START and
211  *			  arbitrating for the bus.
212  *
213  *			  i.e. the STOP is issued along with this byte,
214  *			  within the write stream.
215  *
216  *	COMMAND		- RW Control whether a read or write is performed.
217  *
218  *		0	  WRITE
219  *
220  *		1	  READ
221  *
222  *	DATA (7:0)	- RW Contains the data to be transmitted or received
223  *			  on the I2C bus.
224  *
225  *	NOTE: Writing to this register causes a START + slave + RW to be
226  *	      issued if the direction has changed or the last data byte was
227  *	      sent with a STOP.
228  *
229  *	NOTE: We control termination?  so this register must be written
230  *	      for each byte we wish to receive.  We can then drain the
231  *	      receive FIFO.
232  */
233 
234 #define IG4_DATA_RESTART	0x0400	/* Force RESTART */
235 #define IG4_DATA_STOP		0x0200	/* Force STOP[+START] */
236 #define IG4_DATA_COMMAND_RD	0x0100	/* bus direction 0=write 1=read */
237 #define IG4_DATA_MASK		0x00FF
238 
239 /*
240  * SS_SCL_HCNT - Standard Speed Clock High Count Register	22.2.4
241  * SS_SCL_LCNT - Standard Speed Clock Low Count Register	22.2.5
242  * FS_SCL_HCNT - Fast Speed Clock High Count Register		22.2.6
243  * FS_SCL_LCNT - Fast Speed Clock Low Count Register		22.2.7
244  *
245  *	COUNT (15:0)	- Set the period count to a value between 6 and
246  *			  65525.
247  */
248 #define IG4_SCL_CLOCK_MASK	0xFFFFU	/* count bits in register */
249 
250 /*
251  * INTR_STAT	- (RO) Interrupt Status Register		22.2.8
252  * INTR_MASK	- (RW) Interrupt Mask Register			22.2.9
253  * RAW_INTR_STAT- (RO) Raw Interrupt Status Register		22.2.10
254  *
255  *	GEN_CALL	Set only when a general call (broadcast) address
256  *			is received and acknowleged, stays set until
257  *			cleared by reading CLR_GEN_CALL.
258  *
259  *	START_DET	Set when a START or RESTART condition has occurred
260  *			on the interface.
261  *
262  *	STOP_DET	Set when a STOP condition has occurred on the
263  *			interface.
264  *
265  *	ACTIVITY	Set by any activity on the interface.  Cleared
266  *			by reading CLR_ACTIVITY or CLR_INTR.
267  *
268  *	TX_ABRT		Indicates the controller as a transmitter is
269  *			unable to complete the intended action.  When set,
270  *			the controller will hold the TX FIFO in a reset
271  *			state (flushed) until CLR_TX_ABORT is read to
272  *			clear the condition.  Once cleared, the TX FIFO
273  *			will be available again.
274  *
275  *	TX_EMPTY	Indicates that the transmitter is at or below
276  *			the specified TX_TL threshold.  Automatically
277  *			cleared by HW when the buffer level goes above
278  *			the threshold.
279  *
280  *	TX_OVER		Indicates that the processer attempted to write
281  *			to the TX FIFO while the TX FIFO was full.  Cleared
282  *			by reading CLR_TX_OVER.
283  *
284  *	RX_FULL		Indicates that the receive FIFO has reached or
285  *			exceeded the specified RX_TL threshold.  Cleared
286  *			by HW when the cpu drains the FIFO to below the
287  *			threshold.
288  *
289  *	RX_OVER		Indicates that the receive FIFO was unable to
290  *			accept new data and data was lost.  Cleared by
291  *			reading CLR_RX_OVER.
292  *
293  *	RX_UNDER	Indicates that the cpu attempted to read data
294  *			from the receive buffer while the RX FIFO was
295  *			empty.  Cleared by reading CLR_RX_UNDER.
296  *
297  * NOTES ON RAW_INTR_STAT:
298  *
299  *	This register can be used to monitor the GEN_CALL, START_DET,
300  *	STOP_DET, ACTIVITY, TX_ABRT, TX_EMPTY, TX_OVER, RX_FULL, RX_OVER,
301  *	and RX_UNDER bits.  The documentation is a bit unclear but presumably
302  *	this is the unlatched version.
303  *
304  *	Code should test FIFO conditions using the I2C_STA (status) register,
305  *	not the interrupt status registers.
306  */
307 
308 #define IG4_INTR_GEN_CALL	0x0800
309 #define IG4_INTR_START_DET	0x0400
310 #define IG4_INTR_STOP_DET	0x0200
311 #define IG4_INTR_ACTIVITY	0x0100
312 #define IG4_INTR_TX_ABRT	0x0040
313 #define IG4_INTR_TX_EMPTY	0x0010
314 #define IG4_INTR_TX_OVER	0x0008
315 #define IG4_INTR_RX_FULL	0x0004
316 #define IG4_INTR_RX_OVER	0x0002
317 #define IG4_INTR_RX_UNDER	0x0001
318 
319 /*
320  * RX_TL	- (RW) Receive FIFO Threshold Register		22.2.11
321  * TX_TL	- (RW) Transmit FIFO Threshold Register		22.2.12
322  *
323  * 	Specify the receive and transmit FIFO threshold register.  The
324  *	FIFOs have 16 elements.  The valid range is 0-15.  Setting a
325  *	value greater than 15 causes the actual value to be the maximum
326  *	depth of the FIFO.
327  *
328  *	Generally speaking since everything is messaged, we can use a
329  *	mid-level setting for both parameters and (e.g.) fully drain the
330  *	receive FIFO on the STOP_DET condition to handle loose ends.
331  */
332 #define IG4_FIFO_MASK		0x00FF
333 #define IG4_FIFO_LIMIT		16
334 
335 /*
336  * CLR_INTR	- (RO) Clear Interrupt Register			22.2.13
337  * CLR_RX_UNDER	- (RO) Clear Interrupt Register (specific)	22.2.14
338  * CLR_RX_OVER	- (RO) Clear Interrupt Register (specific)	22.2.15
339  * CLR_TX_OVER	- (RO) Clear Interrupt Register (specific)	22.2.16
340  * CLR_TX_ABORT	- (RO) Clear Interrupt Register (specific)	22.2.17
341  * CLR_ACTIVITY	- (RO) Clear Interrupt Register (specific)	22.2.18
342  * CLR_STOP_DET	- (RO) Clear Interrupt Register (specific)	22.2.19
343  * CLR_START_DET- (RO) Clear Interrupt Register (specific)	22.2.20
344  * CLR_GEN_CALL	- (RO) Clear Interrupt Register (specific)	22.2.21
345  *
346  *	CLR_* specific operations clear the appropriate bit in the
347  *	RAW_INTR_STAT register.  Intel does not really document whether
348  *	these operations clear the normal interrupt status register.
349  *
350  *	CLR_INTR clears bits in the normal interrupt status register and
351  *	presumably also the raw(?) register?  Intel is again unclear.
352  *
353  * NOTE: CLR_INTR only clears software-clearable interrupts.  Hardware
354  *	 clearable interrupts are controlled entirely by the hardware.
355  *	 CLR_INTR also clears the TX_ABRT_SOURCE register.
356  *
357  * NOTE: CLR_TX_ABORT also clears the TX_ABRT_SOURCE register and releases
358  *	 the TX FIFO from its flushed/reset state, allowing more writes
359  *	 to the TX FIFO.
360  *
361  * NOTE: CLR_ACTIVITY has no effect if the I2C bus is still active.
362  *	 Intel documents that the bit is automatically cleared when
363  *	 there is no further activity on the bus.
364  */
365 #define IG4_CLR_BIT		0x0001		/* Reflects source */
366 
367 /*
368  * I2C_EN	- (RW) I2C Enable Register			22.2.22
369  *
370  *	ABORT		Software can abort an I2C transfer by setting this
371  *			bit.  Hardware will clear the bit once the STOP has
372  *			been detected.  This bit can only be set while the
373  *			I2C interface is enabled.
374  *
375  *	I2C_ENABLE	Enable the controller, else disable it.
376  *			(Use I2C_ENABLE_STATUS to poll enable status
377  *			& wait for changes)
378  */
379 #define IG4_I2C_ABORT		0x0002
380 #define IG4_I2C_ENABLE		0x0001
381 
382 /*
383  * I2C_STA	- (RO) I2C Status Register			22.2.23
384  */
385 #define IG4_STATUS_ACTIVITY	0x0020	/* Controller is active */
386 #define IG4_STATUS_RX_FULL	0x0010	/* RX FIFO completely full */
387 #define IG4_STATUS_RX_NOTEMPTY	0x0008	/* RX FIFO not empty */
388 #define IG4_STATUS_TX_EMPTY	0x0004	/* TX FIFO completely empty */
389 #define IG4_STATUS_TX_NOTFULL	0x0002	/* TX FIFO not full */
390 #define IG4_STATUS_I2C_ACTIVE	0x0001	/* I2C bus is active */
391 
392 /*
393  * TXFLR	- (RO) Transmit FIFO Level Register		22.2.24
394  * RXFLR	- (RO) Receive FIFO Level Register		22.2.25
395  *
396  *	Read the number of entries currently in the Transmit or Receive
397  *	FIFOs.  Note that for some reason the mask is 9 bits instead of
398  *	the 8 bits the fill level controls.
399  */
400 #define IG4_FIFOLVL_MASK	0x001F
401 
402 /*
403  * SDA_HOLD	- (RW) SDA Hold Time Length Register		22.2.26
404  *
405  *	Set the SDA hold time length register in I2C clocks.
406  */
407 #define IG4_SDA_HOLD_MASK	0x00FF
408 
409 /*
410  * TX_ABRT_SOURCE- (RO) Transmit Abort Source Register		22.2.27
411  *
412  *	Indicates the cause of a transmit abort.  This can indicate a
413  *	software programming error or a device expected address width
414  *	mismatch or other issues.  The NORESTART conditions and GENCALL_NOACK
415  *	can only occur if a programming error was made in the driver software.
416  *
417  *	In particular, it should be possible to detect whether any devices
418  *	are on the bus by observing the GENCALL_READ status, and it might
419  *	be possible to detect ADDR7 vs ADDR10 mismatches.
420  */
421 #define IG4_ABRTSRC_TRANSFER		0x00010000 /* Abort initiated by user */
422 #define IG4_ABRTSRC_ARBLOST		0x00001000 /* Arbitration lost */
423 #define IG4_ABRTSRC_NORESTART_10	0x00000400 /* RESTART disabled */
424 #define IG4_ABRTSRC_NORESTART_START	0x00000200 /* RESTART disabled */
425 #define IG4_ABRTSRC_ACKED_START		0x00000080 /* Improper acked START */
426 #define IG4_ABRTSRC_GENCALL_NOACK	0x00000020 /* Improper GENCALL */
427 #define IG4_ABRTSRC_GENCALL_READ	0x00000010 /* Nobody acked GENCALL */
428 #define IG4_ABRTSRC_TXNOACK_DATA	0x00000008 /* data phase no ACK */
429 #define IG4_ABRTSRC_TXNOACK_ADDR10_2	0x00000004 /* addr10/1 phase no ACK */
430 #define IG4_ABRTSRC_TXNOACK_ADDR10_1	0x00000002 /* addr10/2 phase no ACK */
431 #define IG4_ABRTSRC_TXNOACK_ADDR7	0x00000001 /* addr7 phase no ACK */
432 
433 /*
434  * SLV_DATA_NACK - (RW) Generate Slave DATA NACK Register	22.2.28
435  *
436  *	When the controller is a receiver a NACK can be generated on
437  *	receipt of data.
438  *
439  *	NACK_GENERATE		Set to 0 for normal NACK/ACK generation.
440  *				Set to 1 to generate a NACK after next data
441  *				byte received.
442  *
443  */
444 #define IG4_NACK_GENERATE	0x0001
445 
446 /*
447  * DMA_CTRL	- (RW) DMA Control Register			22.2.29
448  *
449  *	Enables DMA on the transmit and/or receive DMA channel.
450  */
451 #define IG4_TX_DMA_ENABLE	0x0002
452 #define IG4_RX_DMA_ENABLE	0x0001
453 
454 /*
455  * DMA_TDLR	- (RW) DMA Transmit Data Level Register		22.2.30
456  * DMA_RDLR	- (RW) DMA Receive Data Level Register		22.2.31
457  *
458  *	Similar to RX_TL and TX_TL but controls when a DMA burst occurs
459  *	to empty or fill the FIFOs.  Use the same IG4_FIFO_MASK and
460  *	IG4_FIFO_LIMIT defines for RX_RL and TX_TL.
461  */
462 /* empty */
463 
464 /*
465  * SDA_SETUP	- (RW) SDA Setup Time Length Register		22.2.32
466  *
467  *	Set the SDA setup time length register in I2C clocks.
468  *	The register must be programmed with a value >=2.
469  *	(Defaults to 0x64).
470  */
471 #define IG4_SDA_SETUP_MASK	0x00FF
472 
473 /*
474  * ACK_GEN_CALL	- (RW) ACK General Call Register		22.2.33
475  *
476  *	Control whether the controller responds with a ACK or NACK when
477  *	it receives an I2C General Call address.
478  *
479  *	If set to 0 a NACK is generated and a General Call interrupt is
480  *	NOT generated.  Otherwise an ACK + interrupt is generated.
481  */
482 #define IG4_ACKGC_ACK		0x0001
483 
484 /*
485  * ENABLE_STATUS - (RO) Enable Status Registger			22.2.34
486  *
487  *	DATA_LOST	- Indicates that a slave receiver operation has
488  *			  been aborted with at least one data byte received
489  *			  from a transfer due to the I2C controller being
490  *			  disabled (IG4_I2C_ENABLE -> 0)
491  *
492  *	ENABLED		- Intel documentation is lacking but I assume this
493  *			  is a reflection of the IG4_I2C_ENABLE bit in the
494  *			  I2C_EN register.
495  *
496  */
497 #define IG4_ENASTAT_DATA_LOST	0x0004
498 #define IG4_ENASTAT_ENABLED	0x0001
499 
500 /*
501  * COMP_PARAM1 - (RO) Component Parameter Register		22.2.35
502  *		      Default Value 0x00FFFF6E
503  *
504  *	VALID		- Intel documentation is unclear but I believe this
505  *			  must be read as a 1 to indicate that the rest of
506  *			  the bits in the register are valid.
507  *
508  *	HASDMA		- Indicates that the chip is DMA-capable.  Presumably
509  *			  in certain virtualization cases the chip might be
510  *			  set to not be DMA-capable.
511  *
512  *	INTR_IO		- Indicates that all interrupts are combined to
513  *			  generate one interrupt.  If not set, interrupts
514  *			  are individual (more virtualization stuff?)
515  *
516  *	HCCNT_RO	- Indicates that the clock timing registers are
517  *			  RW.  If not set, the registers are RO.
518  *			  (more virtualization stuff).
519  *
520  *	MAXSPEED	- Indicates the maximum speed supported.
521  *
522  *	DATAW		- Indicates the internal bus width in bits.
523  */
524 #define IG4_PARAM1_TXFIFO_DEPTH(v)	(((v) >> 16) & 0xFF)
525 #define IG4_PARAM1_RXFIFO_DEPTH(v)	(((v) >> 8) & 0xFF)
526 #define IG4_PARAM1_CONFIG_VALID		0x00000080
527 #define IG4_PARAM1_CONFIG_HASDMA	0x00000040
528 #define IG4_PARAM1_CONFIG_INTR_IO	0x00000020
529 #define IG4_PARAM1_CONFIG_HCCNT_RO	0x00000010
530 #define IG4_PARAM1_CONFIG_MAXSPEED_MASK	0x0000000C
531 #define IG4_PARAM1_CONFIG_DATAW_MASK	0x00000003
532 
533 #define IG4_CONFIG_MAXSPEED_RESERVED00	0x00000000
534 #define IG4_CONFIG_MAXSPEED_STANDARD	0x00000004
535 #define IG4_CONFIG_MAXSPEED_FAST	0x00000008
536 #define IG4_CONFIG_MAXSPEED_HIGH	0x0000000C
537 
538 #define IG4_CONFIG_DATAW_8		0x00000000
539 #define IG4_CONFIG_DATAW_16		0x00000001
540 #define IG4_CONFIG_DATAW_32		0x00000002
541 #define IG4_CONFIG_DATAW_RESERVED11	0x00000003
542 
543 /*
544  * COMP_VER - (RO) Component Version Register			22.2.36
545  *		   Default Value 0x3131352A
546  *
547  *	Contains the chip version number.  All 32 bits.
548  */
549 #define IG4_COMP_VER		0x3131352A
550 
551 /*
552  * COMP_TYPE - (RO) (linux) Endian and bus width probe
553  *
554  * 	Read32 from this register and test against IG4_COMP_TYPE
555  *	to determine the bus width.  e.g. 01404457 = endian-reversed,
556  *	and 00000140 or 00004457 means internal 16-bit bus (?).
557  *
558  *	This register is not in the intel documentation, I pulled it
559  *	from the linux driver i2c-designware-core.c.
560  */
561 #define IG4_COMP_TYPE		0x44570140
562 
563 /*
564  * RESETS - (RW) Resets Register				22.2.37
565  *
566  *	Used to reset the I2C host controller by SW.  There is no timing
567  *	requirement, software can assert and de-assert in back-to-back
568  *	transactions.
569  *
570  *	00	I2C host controller is NOT in reset.
571  *	01	(reserved)
572  *	10	(reserved)
573  *	11	I2C host controller is in reset.
574  */
575 #define IG4_RESETS_ASSERT_HSW	0x0003
576 #define IG4_RESETS_DEASSERT_HSW	0x0000
577 
578 /* Skylake-U/Y and Kaby Lake-U/Y have the reset bits inverted */
579 #define IG4_RESETS_DEASSERT_SKL	0x0003
580 #define IG4_RESETS_ASSERT_SKL	0x0000
581 
582 /*
583  * GENERAL - (RW) General Reigster				22.2.38
584  *
585  *	IOVOLT	0=1.8V 1=3.3V
586  *
587  *	LTR	0=Auto 1=SW
588  *
589  *	    In Auto mode the BIOS will write to the host controller's
590  *	    AUTO LTR Value register (offset 0x0814) with the active
591  *	    state LTR value, and will write to the SW LTR Value register
592  *	    (offset 0x0810) with the idle state LTR value.
593  *
594  *	    In SW mode the SW will write to the host controller SW LTR
595  *	    value (offset 0x0810).  It is the SW responsibility to update
596  *	    the LTR with the appropriate value.
597  */
598 #define IG4_GENERAL_IOVOLT3_3	0x0008
599 #define IG4_GENERAL_SWMODE	0x0004
600 
601 /*
602  * SW_LTR_VALUE - (RW) SW LTR Value Register			22.2.39
603  * AUTO_LTR_VALUE - (RW) SW LTR Value Register			22.2.40
604  *
605  *	Default value is 0x00000800 which means the best possible
606  *	service/response time.
607  *
608  *	It isn't quite clear how the snooping works.  There are two scale
609  *	bits for both sets but two of the four codes are reserved.  The
610  *	*SNOOP_VALUE() is specified as a 10-bit latency value.  If 0, it
611  *	indicates that the device cannot tolerate any delay and needs the
612  *	best possible service/response time.
613  *
614  *	I think this is for snooping (testing) the I2C bus.  The lowest
615  *	delay (0) probably runs the controller polling at a high, power hungry
616  *	rate.  But I dunno.
617  */
618 #define IG4_SWLTR_NSNOOP_REQ		0x80000000	/* (ro) */
619 #define IG4_SWLTR_NSNOOP_SCALE_MASK	0x1C000000	/* (ro) */
620 #define IG4_SWLTR_NSNOOP_SCALE_1US	0x08000000	/* (ro) */
621 #define IG4_SWLTR_NSNOOP_SCALE_32US	0x0C000000	/* (ro) */
622 #define IG4_SWLTR_NSNOOP_VALUE_DECODE(v) (((v) >> 16) & 0x3F)
623 #define IG4_SWLTR_NSNOOP_VALUE_ENCODE(v) (((v) & 0x3F) << 16)
624 
625 #define IG4_SWLTR_SNOOP_REQ		0x00008000	/* (rw) */
626 #define IG4_SWLTR_SNOOP_SCALE_MASK	0x00001C00	/* (rw) */
627 #define IG4_SWLTR_SNOOP_SCALE_1US	0x00000800	/* (rw) */
628 #define IG4_SWLTR_SNOOP_SCALE_32US	0x00000C00	/* (rw) */
629 #define IG4_SWLTR_SNOOP_VALUE_DECODE(v)	 ((v) & 0x3F)
630 #define IG4_SWLTR_SNOOP_VALUE_ENCODE(v)	 ((v) & 0x3F)
631 
632 #endif
633