1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
|
/**************************************************************************;
;* *;
;* *;
;* Intel Corporation - ACPI Reference Code for the Baytrail *;
;* Family of Customer Reference Boards. *;
;* *;
;* *;
;* Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved *;
;
; This program and the accompanying materials are licensed and made available under
; the terms and conditions of the BSD License that accompanies this distribution.
; The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
;* *;
;* *;
;**************************************************************************/
// Define various SMBus PCI Configuration Space Registers.
OperationRegion(SMBP,PCI_Config,0x40,0xC0)
Field(SMBP,DWordAcc,NoLock,Preserve)
{
, 2,
I2CE, 1
}
// SMBus Send Byte - This function will write a single byte of
// data to a specific Slave Device per SMBus Send Byte Protocol.
// Arg0 = Address
// Arg1 = Data
// Return: Success = 1
// Failure = 0
Method(SSXB,2,Serialized)
{
OperationRegion(SMPB,PCI_Config,0x20,4)
Field(SMPB,DWordAcc,NoLock,Preserve)
{
, 5,
SBAR, 11
}
// Define various SMBus IO Mapped Registers.
OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
Field(SMBI,ByteAcc,NoLock,Preserve)
{
HSTS, 8, // 0 - Host Status Register
Offset(0x02),
HCON, 8, // 2 - Host Control
HCOM, 8, // 3 - Host Command
TXSA, 8, // 4 - Transmit Slave Address
DAT0, 8, // 5 - Host Data 0
DAT1, 8, // 6 - Host Data 1
HBDR, 8, // 7 - Host Block Data
PECR, 8, // 8 - Packer Error Check
RXSA, 8, // 9 - Receive Slave Address
SDAT, 16, // A - Slave Data
}
// Step 1: Confirm the ICHx SMBus is ready to perform
// communication.
If(STRT())
{
Return(0)
}
// Step 2: Initiate a Send Byte.
Store(0,I2CE) // Ensure SMbus Mode.
Store(0xBF,HSTS) // Clear all but INUSE_STS.
Store(Arg0,TXSA) // Write Address in TXSA.
Store(Arg1,HCOM) // Data in HCOM.
// Set the SMBus Host control register to 0x48.
// Bit 7: = 0 = reserved
// Bit 6: = 1 = start
// Bit 5: = 0 = disregard, I2C related bit
// Bits 4:2: = 001 = Byte Protocol
// Bit 1: = 0 = Normal Function
// Bit 0: = 0 = Disable interrupt generation
Store(0x48,HCON)
// Step 3: Exit the Method correctly.
If(COMP)
{
Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others..
Return(1) // Return Success.
}
Return(0)
}
// SMBus Receive Byte - This function will write a single byte
// of data to a specific Slave Device per SMBus Receive Byte
// Protocol.
// Arg0 = Address
// Return: Success = Byte-Size Value
// Failure = Word-Size Value = FFFFh.
Method(SRXB,1,Serialized)
{
OperationRegion(SMPB,PCI_Config,0x20,4)
Field(SMPB,DWordAcc,NoLock,Preserve)
{
, 5,
SBAR, 11
}
// Define various SMBus IO Mapped Registers.
OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
Field(SMBI,ByteAcc,NoLock,Preserve)
{
HSTS, 8, // 0 - Host Status Register
Offset(0x02),
HCON, 8, // 2 - Host Control
HCOM, 8, // 3 - Host Command
TXSA, 8, // 4 - Transmit Slave Address
DAT0, 8, // 5 - Host Data 0
DAT1, 8, // 6 - Host Data 1
HBDR, 8, // 7 - Host Block Data
PECR, 8, // 8 - Packer Error Check
RXSA, 8, // 9 - Receive Slave Address
SDAT, 16, // A - Slave Data
}
// Step 1: Confirm the ICHx SMBus is ready to perform
// communication.
If(STRT())
{
Return(0xFFFF)
}
// Step 2: Initiate a Receive Byte.
Store(0,I2CE) // Ensure SMbus Mode.
Store(0xBF,HSTS) // Clear all but INUSE_STS.
Store(Or(Arg0,1),TXSA) // Read Address in TXSA.
// Set the SMBus Host control register to 0x48.
// Bit 7: = 0 = reserved
// Bit 6: = 1 = start
// Bit 5: = 0 = disregard, I2C related bit
// Bits 4:2: = 001 = Byte Protocol
// Bit 1: = 0 = Normal Function
// Bit 0: = 0 = Disable interrupt generation
Store(0x44,HCON)
// Step 3: Exit the Method correctly.
If(COMP)
{
Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others..
Return(DAT0) // Return Success.
}
Return(0xFFFF) // Return Failure.
}
// SMBus Write Byte - This function will write a single byte
// of data to a specific Slave Device per SMBus Write Byte
// Protocol.
// Arg0 = Address
// Arg1 = Command
// Arg2 = Data
// Return: Success = 1
// Failure = 0
Method(SWRB,3,Serialized)
{
OperationRegion(SMPB,PCI_Config,0x20,4)
Field(SMPB,DWordAcc,NoLock,Preserve)
{
, 5,
SBAR, 11
}
// Define various SMBus IO Mapped Registers.
OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
Field(SMBI,ByteAcc,NoLock,Preserve)
{
HSTS, 8, // 0 - Host Status Register
Offset(0x02),
HCON, 8, // 2 - Host Control
HCOM, 8, // 3 - Host Command
TXSA, 8, // 4 - Transmit Slave Address
DAT0, 8, // 5 - Host Data 0
DAT1, 8, // 6 - Host Data 1
HBDR, 8, // 7 - Host Block Data
PECR, 8, // 8 - Packer Error Check
RXSA, 8, // 9 - Receive Slave Address
SDAT, 16, // A - Slave Data
}
// Step 1: Confirm the ICHx SMBus is ready to perform communication.
If(STRT())
{
Return(0)
}
// Step 2: Initiate a Write Byte.
Store(0,I2CE) // Ensure SMbus Mode.
Store(0xBF,HSTS) // Clear all but INUSE_STS.
Store(Arg0,TXSA) // Write Address in TXSA.
Store(Arg1,HCOM) // Command in HCOM.
Store(Arg2,DAT0) // Data in DAT0.
// Set the SMBus Host control register to 0x48.
// Bit 7: = 0 = reserved
// Bit 6: = 1 = start
// Bit 5: = 0 = disregard, I2C related bit
// Bits 4:2: = 010 = Byte Data Protocol
// Bit 1: = 0 = Normal Function
// Bit 0: = 0 = Disable interrupt generation
Store(0x48,HCON)
// Step 3: Exit the Method correctly.
If(COMP)
{
Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others..
Return(1) // Return Success.
}
Return(0) // Return Failure.
}
// SMBus Read Byte - This function will read a single byte of data
// from a specific slave device per SMBus Read Byte Protocol.
// Arg0 = Address
// Arg1 = Command
// Return: Success = Byte-Size Value
// Failure = Word-Size Value
Method(SRDB,2,Serialized)
{
OperationRegion(SMPB,PCI_Config,0x20,4)
Field(SMPB,DWordAcc,NoLock,Preserve)
{
, 5,
SBAR, 11
}
// Define various SMBus IO Mapped Registers.
OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
Field(SMBI,ByteAcc,NoLock,Preserve)
{
HSTS, 8, // 0 - Host Status Register
Offset(0x02),
HCON, 8, // 2 - Host Control
HCOM, 8, // 3 - Host Command
TXSA, 8, // 4 - Transmit Slave Address
DAT0, 8, // 5 - Host Data 0
DAT1, 8, // 6 - Host Data 1
HBDR, 8, // 7 - Host Block Data
PECR, 8, // 8 - Packer Error Check
RXSA, 8, // 9 - Receive Slave Address
SDAT, 16, // A - Slave Data
}
// Step 1: Confirm the ICHx SMBus is ready to perform communication.
If(STRT())
{
Return(0xFFFF)
}
// Step 2: Initiate a Read Byte.
Store(0,I2CE) // Ensure SMbus Mode.
Store(0xBF,HSTS) // Clear all but INUSE_STS.
Store(Or(Arg0,1),TXSA) // Read Address in TXSA.
Store(Arg1,HCOM) // Command in HCOM.
// Set the SMBus Host control register to 0x48.
// Bit 7: = 0 = reserved
// Bit 6: = 1 = start
// Bit 5: = 0 = disregard, I2C related bit
// Bits 4:2: = 010 = Byte Data Protocol
// Bit 1: = 0 = Normal Function
// Bit 0: = 0 = Disable interrupt generation
Store(0x48,HCON)
// Step 3: Exit the Method correctly.
If(COMP)
{
Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others..
Return(DAT0) // Return Success.
}
Return(0xFFFF) // Return Failure.
}
// SMBus Write Word - This function will write a single word
// of data to a specific Slave Device per SMBus Write Word
// Protocol.
// Arg0 = Address
// Arg1 = Command
// Arg2 = Data (16 bits in size)
// Return: Success = 1
// Failure = 0
Method(SWRW,3,Serialized)
{
OperationRegion(SMPB,PCI_Config,0x20,4)
Field(SMPB,DWordAcc,NoLock,Preserve)
{
, 5,
SBAR, 11
}
// Define various SMBus IO Mapped Registers.
OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
Field(SMBI,ByteAcc,NoLock,Preserve)
{
HSTS, 8, // 0 - Host Status Register
Offset(0x02),
HCON, 8, // 2 - Host Control
HCOM, 8, // 3 - Host Command
TXSA, 8, // 4 - Transmit Slave Address
DAT0, 8, // 5 - Host Data 0
DAT1, 8, // 6 - Host Data 1
HBDR, 8, // 7 - Host Block Data
PECR, 8, // 8 - Packer Error Check
RXSA, 8, // 9 - Receive Slave Address
SDAT, 16, // A - Slave Data
}
// Step 1: Confirm the ICHx SMBus is ready to perform communication.
If(STRT())
{
Return(0)
}
// Step 2: Initiate a Write Word.
Store(0,I2CE) // Ensure SMbus Mode.
Store(0xBF,HSTS) // Clear all but INUSE_STS.
Store(Arg0,TXSA) // Write Address in TXSA.
Store(Arg1,HCOM) // Command in HCOM.
And(Arg2,0xFF,DAT1) // Low byte Data in DAT1.
And(ShiftRight(Arg2,8),0xFF,DAT0) // High byte Data in DAT0.
// Set the SMBus Host control register to 0x4C.
// Bit 7: = 0 = reserved
// Bit 6: = 1 = start
// Bit 5: = 0 = disregard, I2C related bit
// Bits 4:2: = 011 = Word Data Protocol
// Bit 1: = 0 = Normal Function
// Bit 0: = 0 = Disable interrupt generation
Store(0x4C,HCON)
// Step 3: Exit the Method correctly.
If(COMP())
{
Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others.
Return(1) // Return Success.
}
Return(0) // Return Failure.
}
// SMBus Read Word - This function will read a single byte of data
// from a specific slave device per SMBus Read Word Protocol.
// Arg0 = Address
// Arg1 = Command
// Return: Success = Word-Size Value
// Failure = Dword-Size Value
Method(SRDW,2,Serialized)
{
OperationRegion(SMPB,PCI_Config,0x20,4)
Field(SMPB,DWordAcc,NoLock,Preserve)
{
, 5,
SBAR, 11
}
// Define various SMBus IO Mapped Registers.
OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
Field(SMBI,ByteAcc,NoLock,Preserve)
{
HSTS, 8, // 0 - Host Status Register
Offset(0x02),
HCON, 8, // 2 - Host Control
HCOM, 8, // 3 - Host Command
TXSA, 8, // 4 - Transmit Slave Address
DAT0, 8, // 5 - Host Data 0
DAT1, 8, // 6 - Host Data 1
HBDR, 8, // 7 - Host Block Data
PECR, 8, // 8 - Packer Error Check
RXSA, 8, // 9 - Receive Slave Address
SDAT, 16, // A - Slave Data
}
// Step 1: Confirm the ICHx SMBus is ready to perform communication.
If(STRT())
{
Return(0xFFFF)
}
// Step 2: Initiate a Read Word.
Store(0,I2CE) // Ensure SMbus Mode.
Store(0xBF,HSTS) // Clear all but INUSE_STS.
Store(Or(Arg0,1),TXSA) // Read Address in TXSA.
Store(Arg1,HCOM) // Command in HCOM.
// Set the SMBus Host control register to 0x4C.
// Bit 7: = 0 = reserved
// Bit 6: = 1 = start
// Bit 5: = 0 = disregard, I2C related bit
// Bits 4:2: = 011 = Word Data Protocol
// Bit 1: = 0 = Normal Function
// Bit 0: = 0 = Disable interrupt generation
Store(0x4C,HCON)
// Step 3: Exit the Method correctly.
If(COMP())
{
Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others.
Return(Or(ShiftLeft(DAT0,8),DAT1)) // Return Success.
}
Return(0xFFFFFFFF) // Return Failure.
}
// SMBus Block Write - This function will write an entire block of data
// to a specific slave device per SMBus Block Write Protocol.
// Arg0 = Address
// Arg1 = Command
// Arg2 = Buffer of Data to Write
// Arg3 = 1 = I2C Block Write, 0 = SMBus Block Write
// Return: Success = 1
// Failure = 0
Method(SBLW,4,Serialized)
{
OperationRegion(SMPB,PCI_Config,0x20,4)
Field(SMPB,DWordAcc,NoLock,Preserve)
{
, 5,
SBAR, 11
}
// Define various SMBus IO Mapped Registers.
OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
Field(SMBI,ByteAcc,NoLock,Preserve)
{
HSTS, 8, // 0 - Host Status Register
Offset(0x02),
HCON, 8, // 2 - Host Control
HCOM, 8, // 3 - Host Command
TXSA, 8, // 4 - Transmit Slave Address
DAT0, 8, // 5 - Host Data 0
DAT1, 8, // 6 - Host Data 1
HBDR, 8, // 7 - Host Block Data
PECR, 8, // 8 - Packer Error Check
RXSA, 8, // 9 - Receive Slave Address
SDAT, 16, // A - Slave Data
}
// Step 1: Confirm the ICHx SMBus is ready to perform communication.
If(STRT())
{
Return(0)
}
// Step 2: Initiate a Block Write.
Store(Arg3,I2CE) // Select the proper protocol.
Store(0xBF,HSTS) // Clear all but INUSE_STS.
Store(Arg0,TXSA) // Write Address in TXSA.
Store(Arg1,HCOM) // Command in HCOM.
Store(Sizeof(Arg2),DAT0) // Count in DAT0.
Store(0,Local1) // Init Pointer to Buffer.
Store(DerefOf(Index(Arg2,0)),HBDR) // First Byte in HBD Register.
// Set the SMBus Host control register to 0x48.
// Bit 7: = 0 = reserved
// Bit 6: = 1 = start
// Bit 5: = 0 = disregard, I2C related bit
// Bits 4:2: = 101 = Block Protocol
// Bit 1: = 0 = Normal Function
// Bit 0: = 0 = Disable interrupt generation
Store(0x54,HCON)
// Step 3: Send the entire Block of Data.
While(LGreater(Sizeof(Arg2),Local1))
{
// Wait up to 200ms for Host Status to get set.
Store(4000,Local0) // 4000 * 50us = 200ms.
While(LAnd(LNot(And(HSTS,0x80)),Local0))
{
Decrement(Local0) // Decrement Count.
Stall(50) // Delay = 50us.
}
If(LNot(Local0)) // Timeout?
{
KILL() // Yes. Kill Communication.
Return(0) // Return failure.
}
Store(0x80,HSTS) // Clear Host Status.
Increment(Local1) // Point to Next Byte.
// Place next byte in HBDR if last byte has not been sent.
If(LGreater(Sizeof(Arg2),Local1))
{
Store(DerefOf(Index(Arg2,Local1)),HBDR)
}
}
// Step 4: Exit the Method correctly.
If(COMP())
{
Or(HSTS,0xFF,HSTS) // Clear all status bits.
Return(1) // Return Success.
}
Return(0) // Return Failure.
}
// SMBus Block Read - This function will read a block of data from
// a specific slave device per SMBus Block Read Protocol.
// Arg0 = Address
// Arg1 = Command
// Arg2 = 1 = I2C Block Write, 0 = SMBus Block Write
// Return: Success = Data Buffer (First Byte = length)
// Failure = 0
Method(SBLR,3,Serialized)
{
OperationRegion(SMPB,PCI_Config,0x20,4)
Field(SMPB,DWordAcc,NoLock,Preserve)
{
, 5,
SBAR, 11
}
// Define various SMBus IO Mapped Registers.
OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
Field(SMBI,ByteAcc,NoLock,Preserve)
{
HSTS, 8, // 0 - Host Status Register
Offset(0x02),
HCON, 8, // 2 - Host Control
HCOM, 8, // 3 - Host Command
TXSA, 8, // 4 - Transmit Slave Address
DAT0, 8, // 5 - Host Data 0
DAT1, 8, // 6 - Host Data 1
HBDR, 8, // 7 - Host Block Data
PECR, 8, // 8 - Packer Error Check
RXSA, 8, // 9 - Receive Slave Address
SDAT, 16, // A - Slave Data
}
Name(TBUF, Buffer(256) {})
// Step 1: Confirm the ICHx SMBus is ready to perform communication.
If(STRT())
{
Return(0)
}
// Step 2: Initiate a Block Read.
Store(Arg2,I2CE) // Select the proper protocol.
Store(0xBF,HSTS) // Clear all but INUSE_STS.
Store(Or(Arg0,1),TXSA) // Read Address in TXSA.
Store(Arg1,HCOM) // Command in HCOM.
// Set the SMBus Host control register to 0x48.
// Bit 7: = 0 = reserved
// Bit 6: = 1 = start
// Bit 5: = 0 = disregard, I2C related bit
// Bits 4:2: = 101 = Block Protocol
// Bit 1: = 0 = Normal Function
// Bit 0: = 0 = Disable interrupt generation
Store(0x54,HCON)
// Step 3: Wait up to 200ms to get the Data Count.
Store(4000,Local0) // 4000 * 50us = 200ms.
While(LAnd(LNot(And(HSTS,0x80)),Local0))
{
Decrement(Local0) // Decrement Count.
Stall(50) // Delay = 50us.
}
If(LNot(Local0)) // Timeout?
{
KILL() // Yes. Kill Communication.
Return(0) // Return failure.
}
Store(DAT0,Index(TBUF,0)) // Get the Data Count.
Store(0x80,HSTS) // Clear Host Status.
Store(1,Local1) // Local1 = Buffer Pointer.
// Step 4: Get the Block Data and store it.
While(LLess(Local1,DerefOf(Index(TBUF,0))))
{
// Wait up to 200ms for Host Status to get set.
Store(4000,Local0) // 4000 * 50us = 200ms.
While(LAnd(LNot(And(HSTS,0x80)),Local0))
{
Decrement(Local0) // Decrement Count.
Stall(50) // Delay = 50us.
}
If(LNot(Local0)) // Timeout?
{
KILL() // Yes. Kill Communication.
Return(0) // Return failure.
}
Store(HBDR,Index(TBUF,Local1)) // Place into Buffer.
Store(0x80,HSTS) // Clear Host Status.
Increment(Local1)
}
// Step 5: Exit the Method correctly.
If(COMP())
{
Or(HSTS,0xFF,HSTS) // Clear INUSE_STS and others.
Return(TBUF) // Return Success.
}
Return(0) // Return Failure.
}
// SMBus Start Check
// Return: Success = 0
// Failure = 1
Method(STRT,0,Serialized)
{
OperationRegion(SMPB,PCI_Config,0x20,4)
Field(SMPB,DWordAcc,NoLock,Preserve)
{
, 5,
SBAR, 11
}
// Define various SMBus IO Mapped Registers.
OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
Field(SMBI,ByteAcc,NoLock,Preserve)
{
HSTS, 8, // 0 - Host Status Register
Offset(0x02),
HCON, 8, // 2 - Host Control
HCOM, 8, // 3 - Host Command
TXSA, 8, // 4 - Transmit Slave Address
DAT0, 8, // 5 - Host Data 0
DAT1, 8, // 6 - Host Data 1
HBDR, 8, // 7 - Host Block Data
PECR, 8, // 8 - Packer Error Check
RXSA, 8, // 9 - Receive Slave Address
SDAT, 16, // A - Slave Data
}
// Wait up to 200ms to confirm the SMBus Semaphore has been
// released (In Use Status = 0). Note that the Sleep time may take
// longer as the This function will yield the Processor such that it
// may perform different tasks during the delay.
Store(200,Local0) // 200 * 1ms = 200ms.
While(Local0)
{
If(And(HSTS,0x40)) // In Use Set?
{
Decrement(Local0) // Yes. Decrement Count.
Sleep(1) // Delay = 1ms.
If(LEqual(Local0,0)) // Count = 0?
{
Return(1) // Return failure.
}
}
Else
{
Store(0,Local0) // In Use Clear. Continue.
}
}
// In Use Status = 0 during last read, which will make subsequent
// reads return In Use Status = 1 until software clears it. All
// software using ICHx SMBus should check this bit before initiating
// any SMBus communication.
// Wait up to 200ms to confirm the Host Interface is
// not processing a command.
Store(4000,Local0) // 4000 * 50us = 200ms.
While(Local0)
{
If(And(HSTS,0x01)) // Host Busy Set?
{
Decrement(Local0) // Decrement Count.
Stall(50) // Delay = 50us.
If(LEqual(Local0,0)) // Count = 0?
{
KILL() // Yes. Kill Communication.
}
}
Else
{
Return(0)
}
}
Return(1) // Timeout. Return failure.
}
// SMBus Completion Check
// Return: Success = 1
// Failure = 0
Method(COMP,0,Serialized)
{
OperationRegion(SMPB,PCI_Config,0x20,4)
Field(SMPB,DWordAcc,NoLock,Preserve)
{
, 5,
SBAR, 11
}
// Define various SMBus IO Mapped Registers.
OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
Field(SMBI,ByteAcc,NoLock,Preserve)
{
HSTS, 8, // 0 - Host Status Register
Offset(0x02),
HCON, 8, // 2 - Host Control
HCOM, 8, // 3 - Host Command
TXSA, 8, // 4 - Transmit Slave Address
DAT0, 8, // 5 - Host Data 0
DAT1, 8, // 6 - Host Data 1
HBDR, 8, // 7 - Host Block Data
PECR, 8, // 8 - Packer Error Check
RXSA, 8, // 9 - Receive Slave Address
SDAT, 16, // A - Slave Data
}
// Wait for up to 200ms for the Completion Command
// Status to get set.
Store(4000,Local0) // 4000 * 50us = 200ms.
While(Local0)
{
If(And(HSTS,0x02)) // Completion Status Set?
{
Return(1) // Yes. We are done.
}
Else
{
Decrement(Local0) // Decrement Count.
Stall(50) // Delay 50us.
If(LEqual(Local0,0)) // Count = 0?
{
KILL() // Yes. Kill Communication.
}
}
}
Return(0) // Timeout. Return Failure.
}
// SMBus Kill Command
Method(KILL,0,Serialized)
{
OperationRegion(SMPB,PCI_Config,0x20,4)
Field(SMPB,DWordAcc,NoLock,Preserve)
{
, 5,
SBAR, 11
}
// Define various SMBus IO Mapped Registers.
OperationRegion(SMBI,SystemIO,ShiftLeft(SBAR,5),0x10)
Field(SMBI,ByteAcc,NoLock,Preserve)
{
HSTS, 8, // 0 - Host Status Register
Offset(0x02),
HCON, 8, // 2 - Host Control
HCOM, 8, // 3 - Host Command
TXSA, 8, // 4 - Transmit Slave Address
DAT0, 8, // 5 - Host Data 0
DAT1, 8, // 6 - Host Data 1
HBDR, 8, // 7 - Host Block Data
PECR, 8, // 8 - Packer Error Check
RXSA, 8, // 9 - Receive Slave Address
SDAT, 16, // A - Slave Data
}
Or(HCON,0x02,HCON) // Yes. Send Kill command.
Or(HSTS,0xFF,HSTS) // Clear all status.
}
|