1 /**************************************************************************;
4 ;* Intel Corporation - ACPI Reference Code for the Baytrail *;
5 ;* Family of Customer Reference Boards. *;
8 ;* Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved *;
10 ; SPDX-License-Identifier: BSD-2-Clause-Patent
14 ;**************************************************************************/
17 // Define various SMBus PCI Configuration Space Registers.
19 OperationRegion(SMBP,PCI_Config,0x40,0xC0)
20 Field(SMBP,DWordAcc,NoLock,Preserve)
26 // SMBus Send Byte - This function will write a single byte of
27 // data to a specific Slave Device per SMBus Send Byte Protocol.
30 // Return: Success = 1
33 Method(SSXB,2,Serialized)
35 OperationRegion(SMPB,PCI_Config,0x20,4)
36 Field(SMPB,DWordAcc,NoLock,Preserve)
42 // Define various SMBus IO Mapped Registers.
44 OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
45 Field(SMBI,ByteAcc,NoLock,Preserve)
47 HSTS, 8, // 0 - Host Status Register
49 HCON, 8, // 2 - Host Control
50 HCOM, 8, // 3 - Host Command
51 TXSA, 8, // 4 - Transmit Slave Address
52 DAT0, 8, // 5 - Host Data 0
53 DAT1, 8, // 6 - Host Data 1
54 HBDR, 8, // 7 - Host Block Data
55 PECR, 8, // 8 - Packer Error Check
56 RXSA, 8, // 9 - Receive Slave Address
57 SDAT, 16, // A - Slave Data
60 // Step 1: Confirm the ICHx SMBus is ready to perform
68 // Step 2: Initiate a Send Byte.
70 Store(0,I2CE) // Ensure SMbus Mode.
71 Store(0xBF,HSTS) // Clear all but INUSE_STS.
72 Store(Arg0,TXSA) // Write Address in TXSA.
73 Store(Arg1,HCOM) // Data in HCOM.
75 // Set the SMBus Host control register to 0x48.
76 // Bit 7: = 0 = reserved
78 // Bit 5: = 0 = disregard, I2C related bit
79 // Bits 4:2: = 001 = Byte Protocol
80 // Bit 1: = 0 = Normal Function
81 // Bit 0: = 0 = Disable interrupt generation
85 // Step 3: Exit the Method correctly.
89 Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others..
90 Return(1) // Return Success.
96 // SMBus Receive Byte - This function will write a single byte
97 // of data to a specific Slave Device per SMBus Receive Byte
100 // Return: Success = Byte-Size Value
101 // Failure = Word-Size Value = FFFFh.
103 Method(SRXB,1,Serialized)
105 OperationRegion(SMPB,PCI_Config,0x20,4)
106 Field(SMPB,DWordAcc,NoLock,Preserve)
112 // Define various SMBus IO Mapped Registers.
114 OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
115 Field(SMBI,ByteAcc,NoLock,Preserve)
117 HSTS, 8, // 0 - Host Status Register
119 HCON, 8, // 2 - Host Control
120 HCOM, 8, // 3 - Host Command
121 TXSA, 8, // 4 - Transmit Slave Address
122 DAT0, 8, // 5 - Host Data 0
123 DAT1, 8, // 6 - Host Data 1
124 HBDR, 8, // 7 - Host Block Data
125 PECR, 8, // 8 - Packer Error Check
126 RXSA, 8, // 9 - Receive Slave Address
127 SDAT, 16, // A - Slave Data
129 // Step 1: Confirm the ICHx SMBus is ready to perform
137 // Step 2: Initiate a Receive Byte.
139 Store(0,I2CE) // Ensure SMbus Mode.
140 Store(0xBF,HSTS) // Clear all but INUSE_STS.
141 Store(Or(Arg0,1),TXSA) // Read Address in TXSA.
143 // Set the SMBus Host control register to 0x48.
144 // Bit 7: = 0 = reserved
145 // Bit 6: = 1 = start
146 // Bit 5: = 0 = disregard, I2C related bit
147 // Bits 4:2: = 001 = Byte Protocol
148 // Bit 1: = 0 = Normal Function
149 // Bit 0: = 0 = Disable interrupt generation
153 // Step 3: Exit the Method correctly.
157 Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others..
158 Return(DAT0) // Return Success.
161 Return(0xFFFF) // Return Failure.
164 // SMBus Write Byte - This function will write a single byte
165 // of data to a specific Slave Device per SMBus Write Byte
170 // Return: Success = 1
173 Method(SWRB,3,Serialized)
175 OperationRegion(SMPB,PCI_Config,0x20,4)
176 Field(SMPB,DWordAcc,NoLock,Preserve)
182 // Define various SMBus IO Mapped Registers.
184 OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
185 Field(SMBI,ByteAcc,NoLock,Preserve)
187 HSTS, 8, // 0 - Host Status Register
189 HCON, 8, // 2 - Host Control
190 HCOM, 8, // 3 - Host Command
191 TXSA, 8, // 4 - Transmit Slave Address
192 DAT0, 8, // 5 - Host Data 0
193 DAT1, 8, // 6 - Host Data 1
194 HBDR, 8, // 7 - Host Block Data
195 PECR, 8, // 8 - Packer Error Check
196 RXSA, 8, // 9 - Receive Slave Address
197 SDAT, 16, // A - Slave Data
199 // Step 1: Confirm the ICHx SMBus is ready to perform communication.
206 // Step 2: Initiate a Write Byte.
208 Store(0,I2CE) // Ensure SMbus Mode.
209 Store(0xBF,HSTS) // Clear all but INUSE_STS.
210 Store(Arg0,TXSA) // Write Address in TXSA.
211 Store(Arg1,HCOM) // Command in HCOM.
212 Store(Arg2,DAT0) // Data in DAT0.
214 // Set the SMBus Host control register to 0x48.
215 // Bit 7: = 0 = reserved
216 // Bit 6: = 1 = start
217 // Bit 5: = 0 = disregard, I2C related bit
218 // Bits 4:2: = 010 = Byte Data Protocol
219 // Bit 1: = 0 = Normal Function
220 // Bit 0: = 0 = Disable interrupt generation
224 // Step 3: Exit the Method correctly.
228 Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others..
229 Return(1) // Return Success.
232 Return(0) // Return Failure.
235 // SMBus Read Byte - This function will read a single byte of data
236 // from a specific slave device per SMBus Read Byte Protocol.
239 // Return: Success = Byte-Size Value
240 // Failure = Word-Size Value
242 Method(SRDB,2,Serialized)
244 OperationRegion(SMPB,PCI_Config,0x20,4)
245 Field(SMPB,DWordAcc,NoLock,Preserve)
251 // Define various SMBus IO Mapped Registers.
253 OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
254 Field(SMBI,ByteAcc,NoLock,Preserve)
256 HSTS, 8, // 0 - Host Status Register
258 HCON, 8, // 2 - Host Control
259 HCOM, 8, // 3 - Host Command
260 TXSA, 8, // 4 - Transmit Slave Address
261 DAT0, 8, // 5 - Host Data 0
262 DAT1, 8, // 6 - Host Data 1
263 HBDR, 8, // 7 - Host Block Data
264 PECR, 8, // 8 - Packer Error Check
265 RXSA, 8, // 9 - Receive Slave Address
266 SDAT, 16, // A - Slave Data
268 // Step 1: Confirm the ICHx SMBus is ready to perform communication.
275 // Step 2: Initiate a Read Byte.
277 Store(0,I2CE) // Ensure SMbus Mode.
278 Store(0xBF,HSTS) // Clear all but INUSE_STS.
279 Store(Or(Arg0,1),TXSA) // Read Address in TXSA.
280 Store(Arg1,HCOM) // Command in HCOM.
282 // Set the SMBus Host control register to 0x48.
283 // Bit 7: = 0 = reserved
284 // Bit 6: = 1 = start
285 // Bit 5: = 0 = disregard, I2C related bit
286 // Bits 4:2: = 010 = Byte Data Protocol
287 // Bit 1: = 0 = Normal Function
288 // Bit 0: = 0 = Disable interrupt generation
292 // Step 3: Exit the Method correctly.
296 Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others..
297 Return(DAT0) // Return Success.
300 Return(0xFFFF) // Return Failure.
303 // SMBus Write Word - This function will write a single word
304 // of data to a specific Slave Device per SMBus Write Word
308 // Arg2 = Data (16 bits in size)
309 // Return: Success = 1
312 Method(SWRW,3,Serialized)
314 OperationRegion(SMPB,PCI_Config,0x20,4)
315 Field(SMPB,DWordAcc,NoLock,Preserve)
321 // Define various SMBus IO Mapped Registers.
323 OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
324 Field(SMBI,ByteAcc,NoLock,Preserve)
326 HSTS, 8, // 0 - Host Status Register
328 HCON, 8, // 2 - Host Control
329 HCOM, 8, // 3 - Host Command
330 TXSA, 8, // 4 - Transmit Slave Address
331 DAT0, 8, // 5 - Host Data 0
332 DAT1, 8, // 6 - Host Data 1
333 HBDR, 8, // 7 - Host Block Data
334 PECR, 8, // 8 - Packer Error Check
335 RXSA, 8, // 9 - Receive Slave Address
336 SDAT, 16, // A - Slave Data
338 // Step 1: Confirm the ICHx SMBus is ready to perform communication.
345 // Step 2: Initiate a Write Word.
347 Store(0,I2CE) // Ensure SMbus Mode.
348 Store(0xBF,HSTS) // Clear all but INUSE_STS.
349 Store(Arg0,TXSA) // Write Address in TXSA.
350 Store(Arg1,HCOM) // Command in HCOM.
351 And(Arg2,0xFF,DAT1) // Low byte Data in DAT1.
352 And(ShiftRight(Arg2,8),0xFF,DAT0) // High byte Data in DAT0.
354 // Set the SMBus Host control register to 0x4C.
355 // Bit 7: = 0 = reserved
356 // Bit 6: = 1 = start
357 // Bit 5: = 0 = disregard, I2C related bit
358 // Bits 4:2: = 011 = Word Data Protocol
359 // Bit 1: = 0 = Normal Function
360 // Bit 0: = 0 = Disable interrupt generation
364 // Step 3: Exit the Method correctly.
368 Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others.
369 Return(1) // Return Success.
372 Return(0) // Return Failure.
375 // SMBus Read Word - This function will read a single byte of data
376 // from a specific slave device per SMBus Read Word Protocol.
379 // Return: Success = Word-Size Value
380 // Failure = Dword-Size Value
382 Method(SRDW,2,Serialized)
384 OperationRegion(SMPB,PCI_Config,0x20,4)
385 Field(SMPB,DWordAcc,NoLock,Preserve)
391 // Define various SMBus IO Mapped Registers.
393 OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
394 Field(SMBI,ByteAcc,NoLock,Preserve)
396 HSTS, 8, // 0 - Host Status Register
398 HCON, 8, // 2 - Host Control
399 HCOM, 8, // 3 - Host Command
400 TXSA, 8, // 4 - Transmit Slave Address
401 DAT0, 8, // 5 - Host Data 0
402 DAT1, 8, // 6 - Host Data 1
403 HBDR, 8, // 7 - Host Block Data
404 PECR, 8, // 8 - Packer Error Check
405 RXSA, 8, // 9 - Receive Slave Address
406 SDAT, 16, // A - Slave Data
408 // Step 1: Confirm the ICHx SMBus is ready to perform communication.
415 // Step 2: Initiate a Read Word.
417 Store(0,I2CE) // Ensure SMbus Mode.
418 Store(0xBF,HSTS) // Clear all but INUSE_STS.
419 Store(Or(Arg0,1),TXSA) // Read Address in TXSA.
420 Store(Arg1,HCOM) // Command in HCOM.
422 // Set the SMBus Host control register to 0x4C.
423 // Bit 7: = 0 = reserved
424 // Bit 6: = 1 = start
425 // Bit 5: = 0 = disregard, I2C related bit
426 // Bits 4:2: = 011 = Word Data Protocol
427 // Bit 1: = 0 = Normal Function
428 // Bit 0: = 0 = Disable interrupt generation
432 // Step 3: Exit the Method correctly.
436 Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others.
437 Return(Or(ShiftLeft(DAT0,8),DAT1)) // Return Success.
440 Return(0xFFFFFFFF) // Return Failure.
443 // SMBus Block Write - This function will write an entire block of data
444 // to a specific slave device per SMBus Block Write Protocol.
447 // Arg2 = Buffer of Data to Write
448 // Arg3 = 1 = I2C Block Write, 0 = SMBus Block Write
449 // Return: Success = 1
452 Method(SBLW,4,Serialized)
454 OperationRegion(SMPB,PCI_Config,0x20,4)
455 Field(SMPB,DWordAcc,NoLock,Preserve)
461 // Define various SMBus IO Mapped Registers.
463 OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
464 Field(SMBI,ByteAcc,NoLock,Preserve)
466 HSTS, 8, // 0 - Host Status Register
468 HCON, 8, // 2 - Host Control
469 HCOM, 8, // 3 - Host Command
470 TXSA, 8, // 4 - Transmit Slave Address
471 DAT0, 8, // 5 - Host Data 0
472 DAT1, 8, // 6 - Host Data 1
473 HBDR, 8, // 7 - Host Block Data
474 PECR, 8, // 8 - Packer Error Check
475 RXSA, 8, // 9 - Receive Slave Address
476 SDAT, 16, // A - Slave Data
478 // Step 1: Confirm the ICHx SMBus is ready to perform communication.
485 // Step 2: Initiate a Block Write.
487 Store(Arg3,I2CE) // Select the proper protocol.
488 Store(0xBF,HSTS) // Clear all but INUSE_STS.
489 Store(Arg0,TXSA) // Write Address in TXSA.
490 Store(Arg1,HCOM) // Command in HCOM.
491 Store(Sizeof(Arg2),DAT0) // Count in DAT0.
492 Store(0,Local1) // Init Pointer to Buffer.
493 Store(DerefOf(Index(Arg2,0)),HBDR) // First Byte in HBD Register.
495 // Set the SMBus Host control register to 0x48.
496 // Bit 7: = 0 = reserved
497 // Bit 6: = 1 = start
498 // Bit 5: = 0 = disregard, I2C related bit
499 // Bits 4:2: = 101 = Block Protocol
500 // Bit 1: = 0 = Normal Function
501 // Bit 0: = 0 = Disable interrupt generation
505 // Step 3: Send the entire Block of Data.
507 While(LGreater(Sizeof(Arg2),Local1))
509 // Wait up to 200ms for Host Status to get set.
511 Store(4000,Local0) // 4000 * 50us = 200ms.
513 While(LAnd(LNot(And(HSTS,0x80)),Local0))
515 Decrement(Local0) // Decrement Count.
516 Stall(50) // Delay = 50us.
519 If(LNot(Local0)) // Timeout?
521 KILL() // Yes. Kill Communication.
522 Return(0) // Return failure.
525 Store(0x80,HSTS) // Clear Host Status.
526 Increment(Local1) // Point to Next Byte.
528 // Place next byte in HBDR if last byte has not been sent.
530 If(LGreater(Sizeof(Arg2),Local1))
532 Store(DerefOf(Index(Arg2,Local1)),HBDR)
536 // Step 4: Exit the Method correctly.
540 Or(HSTS,0xFF,HSTS) // Clear all status bits.
541 Return(1) // Return Success.
544 Return(0) // Return Failure.
547 // SMBus Block Read - This function will read a block of data from
548 // a specific slave device per SMBus Block Read Protocol.
551 // Arg2 = 1 = I2C Block Write, 0 = SMBus Block Write
552 // Return: Success = Data Buffer (First Byte = length)
555 Method(SBLR,3,Serialized)
557 OperationRegion(SMPB,PCI_Config,0x20,4)
558 Field(SMPB,DWordAcc,NoLock,Preserve)
564 // Define various SMBus IO Mapped Registers.
566 OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
567 Field(SMBI,ByteAcc,NoLock,Preserve)
569 HSTS, 8, // 0 - Host Status Register
571 HCON, 8, // 2 - Host Control
572 HCOM, 8, // 3 - Host Command
573 TXSA, 8, // 4 - Transmit Slave Address
574 DAT0, 8, // 5 - Host Data 0
575 DAT1, 8, // 6 - Host Data 1
576 HBDR, 8, // 7 - Host Block Data
577 PECR, 8, // 8 - Packer Error Check
578 RXSA, 8, // 9 - Receive Slave Address
579 SDAT, 16, // A - Slave Data
581 Name(TBUF, Buffer(256) {})
583 // Step 1: Confirm the ICHx SMBus is ready to perform communication.
590 // Step 2: Initiate a Block Read.
592 Store(Arg2,I2CE) // Select the proper protocol.
593 Store(0xBF,HSTS) // Clear all but INUSE_STS.
594 Store(Or(Arg0,1),TXSA) // Read Address in TXSA.
595 Store(Arg1,HCOM) // Command in HCOM.
597 // Set the SMBus Host control register to 0x48.
598 // Bit 7: = 0 = reserved
599 // Bit 6: = 1 = start
600 // Bit 5: = 0 = disregard, I2C related bit
601 // Bits 4:2: = 101 = Block Protocol
602 // Bit 1: = 0 = Normal Function
603 // Bit 0: = 0 = Disable interrupt generation
607 // Step 3: Wait up to 200ms to get the Data Count.
609 Store(4000,Local0) // 4000 * 50us = 200ms.
611 While(LAnd(LNot(And(HSTS,0x80)),Local0))
613 Decrement(Local0) // Decrement Count.
614 Stall(50) // Delay = 50us.
617 If(LNot(Local0)) // Timeout?
619 KILL() // Yes. Kill Communication.
620 Return(0) // Return failure.
623 Store(DAT0,Index(TBUF,0)) // Get the Data Count.
624 Store(0x80,HSTS) // Clear Host Status.
625 Store(1,Local1) // Local1 = Buffer Pointer.
627 // Step 4: Get the Block Data and store it.
629 While(LLess(Local1,DerefOf(Index(TBUF,0))))
631 // Wait up to 200ms for Host Status to get set.
633 Store(4000,Local0) // 4000 * 50us = 200ms.
635 While(LAnd(LNot(And(HSTS,0x80)),Local0))
637 Decrement(Local0) // Decrement Count.
638 Stall(50) // Delay = 50us.
641 If(LNot(Local0)) // Timeout?
643 KILL() // Yes. Kill Communication.
644 Return(0) // Return failure.
647 Store(HBDR,Index(TBUF,Local1)) // Place into Buffer.
648 Store(0x80,HSTS) // Clear Host Status.
652 // Step 5: Exit the Method correctly.
656 Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others.
657 Return(TBUF) // Return Success.
660 Return(0) // Return Failure.
665 // Return: Success = 0
668 Method(STRT,0,Serialized)
670 OperationRegion(SMPB,PCI_Config,0x20,4)
671 Field(SMPB,DWordAcc,NoLock,Preserve)
677 // Define various SMBus IO Mapped Registers.
679 OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
680 Field(SMBI,ByteAcc,NoLock,Preserve)
682 HSTS, 8, // 0 - Host Status Register
684 HCON, 8, // 2 - Host Control
685 HCOM, 8, // 3 - Host Command
686 TXSA, 8, // 4 - Transmit Slave Address
687 DAT0, 8, // 5 - Host Data 0
688 DAT1, 8, // 6 - Host Data 1
689 HBDR, 8, // 7 - Host Block Data
690 PECR, 8, // 8 - Packer Error Check
691 RXSA, 8, // 9 - Receive Slave Address
692 SDAT, 16, // A - Slave Data
694 // Wait up to 200ms to confirm the SMBus Semaphore has been
695 // released (In Use Status = 0). Note that the Sleep time may take
696 // longer as the This function will yield the Processor such that it
697 // may perform different tasks during the delay.
699 Store(200,Local0) // 200 * 1ms = 200ms.
703 If(And(HSTS,0x40)) // In Use Set?
705 Decrement(Local0) // Yes. Decrement Count.
706 Sleep(1) // Delay = 1ms.
707 If(LEqual(Local0,0)) // Count = 0?
709 Return(1) // Return failure.
714 Store(0,Local0) // In Use Clear. Continue.
718 // In Use Status = 0 during last read, which will make subsequent
719 // reads return In Use Status = 1 until software clears it. All
720 // software using ICHx SMBus should check this bit before initiating
721 // any SMBus communication.
723 // Wait up to 200ms to confirm the Host Interface is
724 // not processing a command.
726 Store(4000,Local0) // 4000 * 50us = 200ms.
730 If(And(HSTS,0x01)) // Host Busy Set?
732 Decrement(Local0) // Decrement Count.
733 Stall(50) // Delay = 50us.
734 If(LEqual(Local0,0)) // Count = 0?
736 KILL() // Yes. Kill Communication.
745 Return(1) // Timeout. Return failure.
748 // SMBus Completion Check
749 // Return: Success = 1
752 Method(COMP,0,Serialized)
754 OperationRegion(SMPB,PCI_Config,0x20,4)
755 Field(SMPB,DWordAcc,NoLock,Preserve)
761 // Define various SMBus IO Mapped Registers.
763 OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
764 Field(SMBI,ByteAcc,NoLock,Preserve)
766 HSTS, 8, // 0 - Host Status Register
768 HCON, 8, // 2 - Host Control
769 HCOM, 8, // 3 - Host Command
770 TXSA, 8, // 4 - Transmit Slave Address
771 DAT0, 8, // 5 - Host Data 0
772 DAT1, 8, // 6 - Host Data 1
773 HBDR, 8, // 7 - Host Block Data
774 PECR, 8, // 8 - Packer Error Check
775 RXSA, 8, // 9 - Receive Slave Address
776 SDAT, 16, // A - Slave Data
778 // Wait for up to 200ms for the Completion Command
779 // Status to get set.
781 Store(4000,Local0) // 4000 * 50us = 200ms.
785 If(And(HSTS,0x02)) // Completion Status Set?
787 Return(1) // Yes. We are done.
791 Decrement(Local0) // Decrement Count.
792 Stall(50) // Delay 50us.
793 If(LEqual(Local0,0)) // Count = 0?
795 KILL() // Yes. Kill Communication.
800 Return(0) // Timeout. Return Failure.
803 // SMBus Kill Command
805 Method(KILL,0,Serialized)
807 OperationRegion(SMPB,PCI_Config,0x20,4)
808 Field(SMPB,DWordAcc,NoLock,Preserve)
814 // Define various SMBus IO Mapped Registers.
816 OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
817 Field(SMBI,ByteAcc,NoLock,Preserve)
819 HSTS, 8, // 0 - Host Status Register
821 HCON, 8, // 2 - Host Control
822 HCOM, 8, // 3 - Host Command
823 TXSA, 8, // 4 - Transmit Slave Address
824 DAT0, 8, // 5 - Host Data 0
825 DAT1, 8, // 6 - Host Data 1
826 HBDR, 8, // 7 - Host Block Data
827 PECR, 8, // 8 - Packer Error Check
828 RXSA, 8, // 9 - Receive Slave Address
829 SDAT, 16, // A - Slave Data
831 Or(HCON,0x02,HCON) // Yes. Send Kill command.
832 Or(HSTS,0xFF,HSTS) // Clear all status.