-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd50f770.diff
1019 lines (1007 loc) · 29.5 KB
/
d50f770.diff
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
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From d50f77078ecf3d6bf79bec5c4a7dade3bce7708b Mon Sep 17 00:00:00 2001
From: Iru Cai <[email protected]>
Date: Sat, 12 Jan 2019 17:43:14 +0800
Subject: [PATCH] autoport: Add support for Haswell-LynxPoint platform
Change-Id: I4f6e8c97b5122101de2f36bba8ba9f8ddd5b813a
Signed-off-by: Iru Cai <[email protected]>
---
diff --git a/util/autoport/azalia.go b/util/autoport/azalia.go
index c98b03c..6dd78b1 100644
--- a/util/autoport/azalia.go
+++ b/util/autoport/azalia.go
@@ -61,4 +61,7 @@
RegisterPCI(0x8086, 0x1c20, azalia{})
/* C216/ivybridge */
RegisterPCI(0x8086, 0x1e20, azalia{})
+ /* Lynx Point */
+ RegisterPCI(0x8086, 0x8c20, azalia{})
+ RegisterPCI(0x8086, 0x9c20, azalia{})
}
diff --git a/util/autoport/bd82x6x.go b/util/autoport/bd82x6x.go
index ad8918a..ccee013 100644
--- a/util/autoport/bd82x6x.go
+++ b/util/autoport/bd82x6x.go
@@ -10,7 +10,7 @@
node *DevTreeNode
}
-func (b bd82x6x) writeGPIOSet(ctx Context, sb *os.File,
+func writeGPIOSet(ctx Context, sb *os.File,
val uint32, set uint, partno int, constraint uint32) {
max := uint(32)
@@ -36,7 +36,7 @@
}
}
-func (b bd82x6x) GPIO(ctx Context, inteltool InteltoolData) {
+func GPIO(ctx Context, inteltool InteltoolData) {
var constraint uint32
gpio := Create(ctx, "gpio.c")
defer gpio.Close()
@@ -85,7 +85,7 @@
constraint &^= inteltool.GPIO[uint16(addresses[set-1][1])]
constraint &= inteltool.GPIO[uint16(addresses[set-1][5])]
}
- b.writeGPIOSet(ctx, gpio, inteltool.GPIO[uint16(addr)], uint(set), partno, constraint)
+ writeGPIOSet(ctx, gpio, inteltool.GPIO[uint16(addr)], uint(set), partno, constraint)
gpio.WriteString("};\n\n")
}
}
@@ -115,7 +115,7 @@
`)
}
-func (b bd82x6x) IsPCIeHotplug(ctx Context, port int) bool {
+func IsPCIeHotplug(ctx Context, port int) bool {
portDev, ok := PCIMap[PCIAddr{Bus: 0, Dev: 0x1c, Func: port}]
if !ok {
return false
@@ -168,7 +168,7 @@
SouthBridge = &b
inteltool := ctx.InfoSource.GetInteltool()
- b.GPIO(ctx, inteltool)
+ GPIO(ctx, inteltool)
KconfigBool["SOUTHBRIDGE_INTEL_"+b.variant] = true
KconfigBool["SERIRQ_CONTINUOUS_MODE"] = true
@@ -202,14 +202,14 @@
pcieHotplugMap := "{ "
for port := 0; port < 7; port++ {
- if b.IsPCIeHotplug(ctx, port) {
+ if IsPCIeHotplug(ctx, port) {
pcieHotplugMap += "1, "
} else {
pcieHotplugMap += "0, "
}
}
- if b.IsPCIeHotplug(ctx, 7) {
+ if IsPCIeHotplug(ctx, 7) {
pcieHotplugMap += "1 }"
} else {
pcieHotplugMap += "0 }"
diff --git a/util/autoport/haswell.go b/util/autoport/haswell.go
new file mode 100644
index 0000000..68f47c6f
--- /dev/null
+++ b/util/autoport/haswell.go
@@ -0,0 +1,148 @@
+package main
+
+import "fmt"
+
+type haswellmc struct {
+ variant string
+}
+
+func divceil(a uint32, b uint32) uint32 {
+ return (a + b - 1) / b
+}
+
+func getPanelCfg(inteltool InteltoolData, isULT bool) string {
+ var refclk uint32
+ var pwm_hz uint32
+
+ if isULT {
+ refclk = 24000000
+ } else {
+ refclk = 135000000
+ }
+ if (inteltool.IGD[0xc8254] >> 16) != 0 {
+ pwm_hz = refclk / 128 / (inteltool.IGD[0xc8254] >> 16)
+ } else {
+ pwm_hz = 0
+ }
+
+ gpu_panel_power_up_delay := (inteltool.IGD[0xc7208] >> 16) & 0x1fff
+ gpu_panel_power_backlight_on_delay := inteltool.IGD[0xc7208] & 0x1fff
+ gpu_panel_power_down_delay := (inteltool.IGD[0xc720c] >> 16) & 0x1fff
+ gpu_panel_power_backlight_off_delay := inteltool.IGD[0xc720c] & 0x1fff
+ gpu_panel_power_cycle_delay := inteltool.IGD[0xc7210] & 0x1f
+
+ return fmt.Sprintf(`{
+ .up_delay_ms = %3d,
+ .down_delay_ms = %3d,
+ .cycle_delay_ms = %3d,
+ .backlight_on_delay_ms = %3d,
+ .backlight_off_delay_ms = %3d,
+ .backlight_pwm_hz = %3d,
+ }`,
+ divceil(gpu_panel_power_up_delay, 10),
+ divceil(gpu_panel_power_down_delay, 10),
+ (gpu_panel_power_cycle_delay-1)*100,
+ divceil(gpu_panel_power_backlight_on_delay, 10),
+ divceil(gpu_panel_power_backlight_off_delay, 10),
+ pwm_hz)
+}
+
+func (i haswellmc) Scan(ctx Context, addr PCIDevData) {
+ inteltool := ctx.InfoSource.GetInteltool()
+
+ isULT := (i.variant == "ULT")
+ DevTree = DevTreeNode{
+ Chip: "northbridge/intel/haswell",
+ MissingParent: "northbridge",
+ Comment: "FIXME: check ec_present, usb_xhci_on_resume, gfx",
+ Registers: map[string]string{
+ "gpu_dp_b_hotplug": FormatInt32((inteltool.IGD[0xc4030] >> 2) & 7),
+ "gpu_dp_c_hotplug": FormatInt32((inteltool.IGD[0xc4030] >> 10) & 7),
+ "gpu_dp_d_hotplug": FormatInt32((inteltool.IGD[0xc4030] >> 18) & 7),
+ "panel_cfg": getPanelCfg(inteltool, isULT),
+ "gpu_ddi_e_connected": FormatBool(((inteltool.IGD[0x64000] >> 4) & 1) == 0),
+ "ec_present": "false",
+ "usb_xhci_on_resume": "false",
+ /* FIXME:XX hardcoded. */
+ "gfx": "GMA_STATIC_DISPLAYS(0)",
+ },
+ Children: []DevTreeNode{
+ {
+ Chip: "cpu_cluster",
+ Dev: 0,
+ Children: []DevTreeNode{
+ {
+ Chip: "cpu/intel/haswell",
+ Children: []DevTreeNode{
+ {
+ Chip: "lapic",
+ Dev: 0,
+ },
+ {
+ Chip: "lapic",
+ Dev: 0xacac,
+ Disabled: true,
+ },
+ },
+ },
+ },
+ },
+
+ {
+ Chip: "domain",
+ Dev: 0,
+ PCIController: true,
+ ChildPCIBus: 0,
+ PCISlots: []PCISlot{
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x0, Func: 0}, writeEmpty: true, additionalComment: i.variant},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1, Func: 0}, writeEmpty: !isULT, additionalComment: "PCIe Bridge for discrete graphics"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x2, Func: 0}, writeEmpty: true, additionalComment: "Internal graphics"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x3, Func: 0}, writeEmpty: true, additionalComment: "Mini-HD audio"},
+ },
+ },
+ },
+ }
+
+ if isULT {
+ DevTree.Registers["dq_pins_interleaved"] = FormatBool(((inteltool.MCHBAR[0x2008] >> 10) & 1) == 0)
+ }
+
+ PutPCIDev(addr, "Host bridge")
+
+ KconfigBool["NORTHBRIDGE_INTEL_HASWELL"] = true
+ KconfigBool["HAVE_ACPI_TABLES"] = true
+ KconfigBool["HAVE_ACPI_RESUME"] = true
+
+ DSDTIncludes = append(DSDTIncludes, DSDTInclude{
+ File: "cpu/intel/common/acpi/cpu.asl",
+ })
+
+ DSDTPCI0Includes = append(DSDTPCI0Includes, DSDTInclude{
+ File: "northbridge/intel/haswell/acpi/hostbridge.asl",
+ }, DSDTInclude{
+ File: "drivers/intel/gma/acpi/default_brightness_levels.asl",
+ Comment: "FIXME: remove this if the board doesn't have backlight",
+ })
+}
+
+func init() {
+ RegisterPCI(0x8086, 0x0c00, haswellmc{variant: "Desktop"})
+ RegisterPCI(0x8086, 0x0c04, haswellmc{variant: "Mobile"})
+ RegisterPCI(0x8086, 0x0a04, haswellmc{variant: "ULT"})
+ RegisterPCI(0x8086, 0x0c08, haswellmc{variant: "Server"})
+ RegisterPCI(0x8086, 0x0d00, haswellmc{variant: "Crystal Well Desktop"})
+ RegisterPCI(0x8086, 0x0d04, haswellmc{variant: "Crystal Well Mobile"})
+ RegisterPCI(0x8086, 0x0d08, haswellmc{variant: "Crystal Well Server"})
+ for _, id := range []uint16{
+ 0x0402, 0x0412, 0x0422, /* Desktop */
+ 0x0406, 0x0416, 0x0426, /* Mobile */
+ 0x040a, 0x041a, 0x042a, /* Server */
+ 0x0a06, 0x0a16, 0x0a26, /* ULT */
+ 0x0d16, 0x0d22, 0x0d26, 0x0d36, /* Mobile 4+3, GT3e */
+ } {
+ RegisterPCI(0x8086, id, GenericVGA{GenericPCI{Comment: "VGA controller"}})
+ }
+ /* CPU HD Audio */
+ RegisterPCI(0x8086, 0x0a0c, GenericPCI{})
+ RegisterPCI(0x8086, 0x0c0c, GenericPCI{})
+}
diff --git a/util/autoport/log_reader.go b/util/autoport/log_reader.go
index b144804..b0518d2 100644
--- a/util/autoport/log_reader.go
+++ b/util/autoport/log_reader.go
@@ -180,7 +180,10 @@
paragraph := ""
ret.GPIO = map[uint16]uint32{}
ret.RCBA = map[uint16]uint32{}
+ ret.IOBP = map[uint32]uint32{}
ret.IGD = map[uint32]uint32{}
+ ret.MCHBAR = map[uint16]uint32{}
+ ret.PMBASE = map[uint16]uint32{}
for scanner.Scan() {
line := scanner.Text()
switch {
@@ -188,10 +191,18 @@
addr, value := 0, 0
fmt.Sscanf(line, "0x%x: 0x%x", &addr, &value)
ret.RCBA[uint16(addr)] = uint32(value)
+ case len(line) > 11 && line[0] == '0' && line[1] == 'x' && line[10] == ':' && paragraph == "IOBP":
+ addr, value := 0, 0
+ fmt.Sscanf(line, "0x%x: 0x%x", &addr, &value)
+ ret.IOBP[uint32(addr)] = uint32(value)
case len(line) > 9 && line[0] == '0' && line[1] == 'x' && line[8] == ':' && paragraph == "IGD":
addr, value := 0, 0
fmt.Sscanf(line, "0x%x: 0x%x", &addr, &value)
ret.IGD[uint32(addr)] = uint32(value)
+ case len(line) > 7 && line[0] == '0' && line[1] == 'x' && line[6] == ':' && paragraph == "MCHBAR":
+ addr, value := 0, 0
+ fmt.Sscanf(line, "0x%x: 0x%x", &addr, &value)
+ ret.MCHBAR[uint16(addr)] = uint32(value)
case strings.Contains(line, "DEFAULT"):
continue
case strings.Contains(line, "DIFF"):
@@ -200,6 +211,10 @@
addr, value := 0, 0
fmt.Sscanf(line, "gpiobase+0x%x: 0x%x", &addr, &value)
ret.GPIO[uint16(addr)] = uint32(value)
+ case strings.HasPrefix(line, "pmbase"):
+ addr, value := 0, 0
+ fmt.Sscanf(line, "pmbase+0x%x: 0x%x", &addr, &value)
+ ret.PMBASE[uint16(addr)] = uint32(value)
case strings.HasPrefix(line, "============="):
paragraph = strings.Trim(line, "= ")
}
diff --git a/util/autoport/lynxpoint.go b/util/autoport/lynxpoint.go
new file mode 100644
index 0000000..e822d2a
--- /dev/null
+++ b/util/autoport/lynxpoint.go
@@ -0,0 +1,707 @@
+package main
+
+import (
+ "fmt"
+ "os"
+ "strings"
+)
+
+type LPVariant int
+
+const (
+ LYNX_POINT_MOBILE LPVariant = iota
+ LYNX_POINT_DESKTOP
+ LYNX_POINT_SERVER
+ LYNX_POINT_ULT
+)
+
+type lynxpoint struct {
+ variant LPVariant
+ node *DevTreeNode
+}
+
+func lp_gpio_to_pirq(g uint) int {
+ switch g {
+ case 8:
+ return 0 /* PIRQI */
+ case 9:
+ return 1 /* PIRQJ */
+ case 10:
+ return 2 /* PIRQK */
+ case 13:
+ return 3 /* PIRQL */
+ case 14:
+ return 4 /* PIRQM */
+ case 45:
+ return 5 /* PIRQN */
+ case 46:
+ return 6 /* PIRQO */
+ case 47:
+ return 7 /* PIRQP */
+ case 48:
+ return 8 /* PIRQQ */
+ case 49:
+ return 9 /* PIRQR */
+ case 50:
+ return 10 /* PIRQS */
+ case 51:
+ return 11 /* PIRQT */
+ case 52:
+ return 12 /* PIRQU */
+ case 53:
+ return 13 /* PIRQV */
+ case 54:
+ return 14 /* PIRQW */
+ case 55:
+ return 15 /* PIRQX */
+ default:
+ return -1
+ }
+}
+
+func conf0str(conf0 uint32) string {
+ if (conf0 & 1) == 0 {
+ return "GPIO_MODE_NATIVE"
+ } else {
+ s := []string{"GPIO_MODE_GPIO"}
+ var gpio_output bool
+ if ((conf0 >> 2) & 1) == 1 {
+ s = append(s, "GPIO_DIR_INPUT")
+ gpio_output = false
+ } else {
+ s = append(s, "GPIO_DIR_OUTPUT")
+ gpio_output = true
+ }
+ if ((conf0 >> 3) & 1) == 1 {
+ s = append(s, "GPIO_INVERT")
+ }
+ if ((conf0 >> 4) & 1) == 1 {
+ s = append(s, "GPIO_IRQ_LEVEL")
+ }
+ if gpio_output {
+ if ((conf0 >> 31) & 1) == 1 {
+ s = append(s, "GPO_LEVEL_HIGH")
+ } else {
+ s = append(s, "GPO_LEVEL_LOW")
+ }
+ }
+ return strings.Join(s, " | ")
+ }
+}
+
+func lpgpio_preset(conf0 uint32, owner uint32, route uint32, irqen uint32, pirq uint32) string {
+ if conf0 == 0xd { /* 0b1101: MODE_GPIO | INPUT | INVERT */
+ if owner == 0 { /* OWNER_ACPI */
+ if irqen == 0 && pirq == 0 {
+ if route == 0 { /* SCI */
+ return "GPIO_ACPI_SCI"
+ } else {
+ return "GPIO_ACPI_SMI"
+ }
+ }
+ return ""
+ } else { /* OWNER_GPIO */
+ if route == 0 && irqen == 0 && pirq != 0 {
+ return "GPIO_INPUT_INVERT"
+ }
+ return ""
+ }
+ }
+
+ if conf0 == 0x5 && owner == 1 { /* 0b101: MODE_GPIO | INPUT, OWNER_GPIO */
+ if route == 0 && irqen == 0 {
+ if pirq == 1 {
+ return "GPIO_PIRQ"
+ } else {
+ return "GPIO_INPUT"
+ }
+ }
+ return ""
+ }
+
+ if owner == 1 && irqen == 1 {
+ if route == 0 && pirq == 0 {
+ if conf0 == 0x5 { /* 0b00101 */
+ return "GPIO_IRQ_EDGE"
+ }
+ if conf0 == 0x15 { /* 0b10101 */
+ return "GPIO_IRQ_LEVEL"
+ }
+ }
+ return ""
+ }
+ return ""
+}
+
+func gpio_str(conf0 uint32, conf1 uint32, owner uint32, route uint32, irqen uint32, reset uint32, blink uint32, pirq uint32) string {
+ s := []string{}
+ s = append(s, fmt.Sprintf(".conf0 = %s", conf0str(conf0)))
+ if conf1 != 0 {
+ s = append(s, fmt.Sprintf(".conf1 = 0x%x", conf1))
+ }
+ if owner != 0 {
+ s = append(s, ".owner = GPIO_OWNER_GPIO")
+ }
+ if route != 0 {
+ s = append(s, ".route = GPIO_ROUTE_SMI")
+ }
+ if irqen != 0 {
+ s = append(s, ".irqen = GPIO_IRQ_ENABLE")
+ }
+ if reset != 0 {
+ s = append(s, ".reset = GPIO_RESET_RSMRST")
+ }
+ if blink != 0 {
+ s = append(s, ".blink = GPO_BLINK")
+ }
+ if pirq != 0 {
+ s = append(s, ".pirq = GPIO_PIRQ_APIC_ROUTE")
+ }
+ return strings.Join(s, ", ")
+}
+
+func PrintLPGPIO(gpio *os.File, inteltool InteltoolData) {
+ for g := uint(0); g <= 94; g++ {
+ if g < 10 {
+ fmt.Fprintf(gpio, "\t[%d] = ", g)
+ } else {
+ fmt.Fprintf(gpio, "\t[%d] = ", g)
+ }
+ conf0 := inteltool.GPIO[uint16(0x100+g*8)]
+ conf1 := inteltool.GPIO[uint16(0x104+g*8)]
+ set := g / 32
+ bit := g % 32
+ /* owner only effective in GPIO mode */
+ owner := (inteltool.GPIO[uint16(0x0+set*4)] >> bit) & 1
+ route := (inteltool.GPIO[uint16(0x30+set*4)] >> bit) & 1
+ irqen := (inteltool.GPIO[uint16(0x90+set*4)] >> bit) & 1
+ reset := (inteltool.GPIO[uint16(0x60+set*4)] >> bit) & 1
+ var blink, pirq uint32
+ /* blink only effective in GPIO output mode */
+ if set == 0 {
+ blink = (inteltool.GPIO[uint16(0x18)] >> bit) & 1
+ } else {
+ blink = 0
+ }
+ irqset := lp_gpio_to_pirq(g)
+ if irqset >= 0 {
+ pirq = (inteltool.GPIO[uint16(0x10)] >> uint(irqset)) & 1
+ } else {
+ pirq = 0
+ }
+
+ if (conf0 & 1) == 0 {
+ fmt.Fprintf(gpio, "LP_GPIO_NATIVE,\n")
+ } else if (conf0 & 4) == 0 {
+ /* configured as output */
+ if ((conf0 >> 31) & 1) == 0 {
+ fmt.Fprintf(gpio, "LP_GPIO_OUT_LOW,\n")
+ } else {
+ fmt.Fprintf(gpio, "LP_GPIO_OUT_HIGH,\n")
+ }
+ } else if (conf1 & 4) != 0 {
+ /* configured as input and sensing disabled */
+ fmt.Fprintf(gpio, "LP_GPIO_UNUSED,\n")
+ } else {
+ is_preset := false
+ if conf1 == 0 && reset == 0 && blink == 0 {
+ preset := lpgpio_preset(conf0, owner, route, irqen, pirq)
+ if preset != "" {
+ fmt.Fprintf(gpio, "LP_%s,\n", preset)
+ is_preset = true
+ }
+ }
+ if !is_preset {
+ fmt.Fprintf(gpio, "{ %s },\n", gpio_str(conf0, conf1, owner, route, irqen, reset, blink, pirq))
+ }
+ }
+ }
+}
+
+func LPGPIO(ctx Context, inteltool InteltoolData) {
+ gpio := Create(ctx, "gpio.c")
+ defer gpio.Close()
+
+ AddROMStageFile("gpio.c", "")
+
+ Add_gpl(gpio)
+ gpio.WriteString(`#include <southbridge/intel/lynxpoint/lp_gpio.h>
+
+const struct pch_lp_gpio_map mainboard_lp_gpio_map[] = {
+`)
+ PrintLPGPIO(gpio, inteltool)
+ gpio.WriteString("\tLP_GPIO_END\n};\n")
+}
+
+func lpPchGetFlashSize(ctx Context) {
+ inteltool := ctx.InfoSource.GetInteltool()
+ /* In LP PCH, Boot BIOS Straps field in GCS has only one bit. */
+ switch (inteltool.RCBA[0x3410] >> 10) & 1 {
+ case 0:
+ ROMProtocol = "SPI"
+ highflkb := uint32(0)
+ for reg := uint16(0); reg < 5; reg++ {
+ fl := (inteltool.RCBA[0x3854+4*reg] >> 16) & 0x1fff
+ flkb := (fl + 1) << 2
+ if flkb > highflkb {
+ highflkb = flkb
+ }
+ }
+ ROMSizeKB = int(highflkb)
+ FlashROMSupport = "y"
+ }
+}
+
+func (b lynxpoint) GetGPIOHeader() string {
+ return "southbridge/intel/lynxpoint/pch.h"
+}
+
+func (b lynxpoint) EnableGPE(in int) {
+ if b.variant != LYNX_POINT_ULT {
+ b.node.Registers[fmt.Sprintf("gpi%d_routing", in)] = "2"
+ }
+}
+
+func (b lynxpoint) EncodeGPE(in int) int {
+ return in + 0x10
+}
+
+func (b lynxpoint) DecodeGPE(in int) int {
+ return in - 0x10
+}
+
+func (b lynxpoint) NeedRouteGPIOManually() {
+ b.node.Comment += ", FIXME: set gpiX_routing for EC support"
+}
+
+func GetLptDesktopEHCISetting(loc_param uint32, txamp uint32) (string, int) {
+ var port_pos string
+ var port_length int
+
+ if loc_param == 4 {
+ port_pos = "USB_PORT_BACK_PANEL"
+ if txamp <= 2 {
+ port_length = 0x40
+ } else if txamp >= 4 {
+ port_length = 0x140
+ } else {
+ port_length = 0x110
+ }
+ } else {
+ port_pos = "USB_PORT_FLEX"
+ port_length = 0x40
+ }
+ return port_pos, port_length
+}
+
+func GetLptMobileEHCISetting(loc_param uint32, txamp uint32) (string, int) {
+ var port_pos string
+ var port_length int
+
+ if loc_param == 4 {
+ port_pos = "USB_PORT_DOCK"
+ if txamp <= 1 {
+ port_length = 0x40
+ } else {
+ port_length = 0x80
+ }
+ } else if loc_param == 6 {
+ /* not internal, not dock, port_length >= 0x70 */
+ port_pos = "USB_PORT_BACK_PANEL"
+ if txamp <= 2 {
+ port_length = 0x80
+ } else {
+ port_length = 0x110
+ }
+ } else {
+ port_pos = "USB_PORT_BACK_PANEL"
+ port_length = 0x40
+ }
+ return port_pos, port_length
+}
+
+func GetLptLPEHCISetting(loc_param uint32, txamp uint32) (string, int) {
+ var port_pos string
+ var port_length int
+
+ if loc_param == 6 {
+ /* back panel or mini pcie, length >= 0x70 */
+ port_pos = "USB_PORT_MINI_PCIE"
+ if txamp <= 2 {
+ port_length = 0x80
+ } else {
+ port_length = 0x110
+ }
+ } else if loc_param == 4 {
+ port_pos = "USB_PORT_DOCK"
+ if txamp <= 1 {
+ port_length = 0x40
+ } else {
+ port_length = 0x80
+ }
+ } else {
+ port_pos = "USB_PORT_BACK_PANEL"
+ port_length = 0x40
+ }
+ return port_pos, port_length
+}
+
+func (b lynxpoint) Scan(ctx Context, addr PCIDevData) {
+
+ SouthBridge = &b
+
+ inteltool := ctx.InfoSource.GetInteltool()
+
+ isULT := (b.variant == LYNX_POINT_ULT)
+
+ if isULT {
+ LPGPIO(ctx, inteltool)
+ } else {
+ GPIO(ctx, inteltool)
+ }
+
+ KconfigBool["SOUTHBRIDGE_INTEL_LYNXPOINT"] = true
+ if isULT {
+ KconfigBool["INTEL_LYNXPOINT_LP"] = true
+ }
+ KconfigBool["SERIRQ_CONTINUOUS_MODE"] = true
+ if isULT {
+ KconfigInt["USBDEBUG_HCD_INDEX"] = 1
+ } else {
+ KconfigInt["USBDEBUG_HCD_INDEX"] = 2
+ KconfigComment["USBDEBUG_HCD_INDEX"] = "FIXME: check this"
+ }
+
+ if isULT {
+ lpPchGetFlashSize(ctx)
+ } else {
+ ich9GetFlashSize(ctx)
+ }
+
+ FADT := ctx.InfoSource.GetACPI()["FACP"]
+
+ sp0dtle_data := (inteltool.IOBP[0xea002750] >> 24) & 0xf
+ sp0dtle_edge := (inteltool.IOBP[0xea002754] >> 16) & 0xf
+ sp1dtle_data := (inteltool.IOBP[0xea002550] >> 24) & 0xf
+ sp1dtle_edge := (inteltool.IOBP[0xea002554] >> 16) & 0xf
+
+ if sp0dtle_data != sp0dtle_edge {
+ fmt.Printf("Different SATA Gen3 port0 DTLE data and edge values are used.\n")
+ }
+
+ if sp1dtle_data != sp1dtle_edge {
+ fmt.Printf("Different SATA Gen3 port1 DTLE data and edge values are used.\n")
+ }
+
+ cur := DevTreeNode{
+ Chip: "southbridge/intel/lynxpoint",
+ Comment: "Intel Series 8 Lynx Point PCH",
+
+ /* alt_gp_smi_en is not generated because coreboot doesn't use SMI like OEM firmware */
+ Registers: map[string]string{
+ "gen1_dec": FormatHexLE32(PCIMap[PCIAddr{Bus: 0, Dev: 0x1f, Func: 0}].ConfigDump[0x84:0x88]),
+ "gen2_dec": FormatHexLE32(PCIMap[PCIAddr{Bus: 0, Dev: 0x1f, Func: 0}].ConfigDump[0x88:0x8c]),
+ "gen3_dec": FormatHexLE32(PCIMap[PCIAddr{Bus: 0, Dev: 0x1f, Func: 0}].ConfigDump[0x8c:0x90]),
+ "gen4_dec": FormatHexLE32(PCIMap[PCIAddr{Bus: 0, Dev: 0x1f, Func: 0}].ConfigDump[0x90:0x94]),
+ "sata_port_map": fmt.Sprintf("0x%x", PCIMap[PCIAddr{Bus: 0, Dev: 0x1f, Func: 2}].ConfigDump[0x92]&0x3f),
+ "docking_supported": (FormatBool((FADT[113] & (1 << 1)) != 0)),
+ "sata_port0_gen3_dtle": fmt.Sprintf("0x%x", sp0dtle_data),
+ "sata_port1_gen3_dtle": fmt.Sprintf("0x%x", sp1dtle_data),
+ },
+ PCISlots: []PCISlot{
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x13, Func: 0}, writeEmpty: isULT, additionalComment: "Smart Sound Audio DSP"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x14, Func: 0}, writeEmpty: true, additionalComment: "xHCI Controller"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x15, Func: 0}, writeEmpty: isULT, additionalComment: "Serial I/O DMA"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x15, Func: 1}, writeEmpty: isULT, additionalComment: "I2C0"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x15, Func: 2}, writeEmpty: isULT, additionalComment: "I2C1"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x15, Func: 3}, writeEmpty: isULT, additionalComment: "GSPI0"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x15, Func: 4}, writeEmpty: isULT, additionalComment: "GSPI1"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x15, Func: 5}, writeEmpty: isULT, additionalComment: "UART0"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x15, Func: 6}, writeEmpty: isULT, additionalComment: "UART1"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x16, Func: 0}, writeEmpty: true, additionalComment: "Management Engine Interface 1"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x16, Func: 1}, writeEmpty: true, additionalComment: "Management Engine Interface 2"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x16, Func: 2}, writeEmpty: true, additionalComment: "Management Engine IDE-R"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x16, Func: 3}, writeEmpty: true, additionalComment: "Management Engine KT"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x17, Func: 0}, writeEmpty: isULT, additionalComment: "SDIO"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x19, Func: 0}, writeEmpty: true, additionalComment: "Intel Gigabit Ethernet"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1a, Func: 0}, writeEmpty: !isULT, additionalComment: "USB2 EHCI #2"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1b, Func: 0}, writeEmpty: true, additionalComment: "High Definition Audio"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 0}, writeEmpty: true, additionalComment: "PCIe Port #1"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 1}, writeEmpty: true, additionalComment: "PCIe Port #2"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 2}, writeEmpty: true, additionalComment: "PCIe Port #3"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 3}, writeEmpty: true, additionalComment: "PCIe Port #4"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 4}, writeEmpty: true, additionalComment: "PCIe Port #5"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 5}, writeEmpty: true, additionalComment: "PCIe Port #6"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 6}, writeEmpty: !isULT, additionalComment: "PCIe Port #7"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 7}, writeEmpty: !isULT, additionalComment: "PCIe Port #8"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1d, Func: 0}, writeEmpty: true, additionalComment: "USB2 EHCI #1"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1f, Func: 0}, writeEmpty: true, additionalComment: "LPC bridge"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1f, Func: 2}, writeEmpty: true, additionalComment: "SATA Controller (AHCI)"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1f, Func: 3}, writeEmpty: true, additionalComment: "SMBus"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1f, Func: 5}, writeEmpty: !isULT, additionalComment: "SATA Controller (Legacy)"},
+ PCISlot{PCIAddr: PCIAddr{Dev: 0x1f, Func: 6}, writeEmpty: true, additionalComment: "Thermal"},
+ },
+ }
+
+ if isULT {
+ cur.Registers["gpe0_en_1"] = fmt.Sprintf("0x%x", inteltool.PMBASE[0x90])
+ cur.Registers["gpe0_en_2"] = fmt.Sprintf("0x%x", inteltool.PMBASE[0x94])
+ cur.Registers["gpe0_en_3"] = fmt.Sprintf("0x%x", inteltool.PMBASE[0x98])
+ cur.Registers["gpe0_en_4"] = fmt.Sprintf("0x%x", inteltool.PMBASE[0x9c])
+ } else {
+ cur.Registers["gpe0_en_1"] = fmt.Sprintf("0x%x", inteltool.PMBASE[0x28])
+ cur.Registers["gpe0_en_2"] = fmt.Sprintf("0x%x", inteltool.PMBASE[0x2c])
+ }
+
+ b.node = &cur
+
+ PutPCIChip(addr, cur)
+ PutPCIDevParent(addr, "", "lpc")
+
+ DSDTIncludes = append(DSDTIncludes, DSDTInclude{
+ File: "southbridge/intel/common/acpi/platform.asl",
+ })
+ DSDTIncludes = append(DSDTIncludes, DSDTInclude{
+ File: "southbridge/intel/lynxpoint/acpi/globalnvs.asl",
+ Comment: "global NVS and variables",
+ })
+ DSDTIncludes = append(DSDTIncludes, DSDTInclude{
+ File: "southbridge/intel/common/acpi/sleepstates.asl",
+ })
+ DSDTPCI0Includes = append(DSDTPCI0Includes, DSDTInclude{
+ File: "southbridge/intel/lynxpoint/acpi/pch.asl",
+ })
+
+ AddBootBlockFile("bootblock.c", "")
+ bb := Create(ctx, "bootblock.c")
+ defer bb.Close()
+ Add_gpl(bb)
+ bb.WriteString(`#include <southbridge/intel/lynxpoint/pch.h>
+
+/* FIXME: remove this if not needed */
+void mainboard_config_superio(void)
+{
+}
+`)
+
+ sb := Create(ctx, "romstage.c")
+ defer sb.Close()
+ Add_gpl(sb)
+ sb.WriteString(`#include <stdint.h>
+#include <northbridge/intel/haswell/haswell.h>
+#include <northbridge/intel/haswell/raminit.h>
+#include <southbridge/intel/lynxpoint/pch.h>
+
+void mainboard_config_rcba(void)
+{
+}
+
+/* FIXME: called after romstage_common, remove it if not used */
+void mb_late_romstage_setup(void)
+{
+}
+
+void mb_get_spd_map(struct spd_info *spdi)
+{
+ /* FIXME: check this */
+ spdi->addresses[0] = 0x50;
+ spdi->addresses[1] = 0x51;
+ spdi->addresses[2] = 0x52;
+ spdi->addresses[3] = 0x53;
+}
+
+const struct usb2_port_config mainboard_usb2_ports[MAX_USB2_PORTS] = {
+ /* FIXME: Length and Location are computed from IOBP values, may be inaccurate */
+ /* Length, Enable, OCn#, Location */
+`)
+
+ pdo1 := PCIMap[PCIAddr{Bus: 0, Dev: 0x1d, Func: 0}].ConfigDump[0x64]
+ ocmap1 := PCIMap[PCIAddr{Bus: 0, Dev: 0x1d, Func: 0}].ConfigDump[0x74:0x78]
+
+ var pdo2 uint8
+ var ocmap2 []uint8
+ var nPorts uint
+ if isULT {
+ nPorts = 8
+ } else {
+ pdo2 = PCIMap[PCIAddr{Bus: 0, Dev: 0x1a, Func: 0}].ConfigDump[0x64]
+ ocmap2 = PCIMap[PCIAddr{Bus: 0, Dev: 0x1a, Func: 0}].ConfigDump[0x74:0x78]
+ nPorts = 14
+ }
+
+ xusb2pr := GetLE16(PCIMap[PCIAddr{Bus: 0, Dev: 0x14, Func: 0}].ConfigDump[0xd0:0xd4])
+
+ for port := uint(0); port < nPorts; port++ {
+ var port_oc int = -1
+ var port_pos string
+ var port_disable uint8
+
+ if port < 8 {
+ port_disable = ((pdo1 >> port) & (uint8(xusb2pr>>port) ^ 1)) & 1
+ for oc := 0; oc < 4; oc++ {
+ if (ocmap1[oc] & (1 << port)) != 0 {
+ port_oc = oc
+ break
+ }
+ }
+ } else {
+ port_disable = ((pdo2 >> (port - 8)) & (uint8(xusb2pr>>port) ^ 1)) & 1
+ for oc := 0; oc < 4; oc++ {
+ if (ocmap2[oc] & (1 << (port - 8))) != 0 {
+ port_oc = oc + 4
+ break
+ }
+ }
+ }
+
+ /* get USB2 port length and location from IOBP */
+ port_iobp := inteltool.IOBP[0xe5004100+uint32(port)*0x100]
+ loc_param := (port_iobp >> 8) & 7
+ txamp := (port_iobp >> 11) & 7
+ var port_length int
+
+ if isULT {
+ port_pos, port_length = GetLptLPEHCISetting(loc_param, txamp)
+ } else if b.variant == LYNX_POINT_MOBILE {
+ port_pos, port_length = GetLptMobileEHCISetting(loc_param, txamp)
+ } else { /* desktop or server */
+ port_pos, port_length = GetLptDesktopEHCISetting(loc_param, txamp)
+ }
+
+ if port_disable == 1 {
+ port_pos = "USB_PORT_SKIP"
+ }
+
+ if port_oc == -1 {
+ fmt.Fprintf(sb, "\t{ 0x%04x, %d, USB_OC_PIN_SKIP, %s },\n",
+ port_length, (port_disable ^ 1), port_pos)
+ } else {
+ fmt.Fprintf(sb, "\t{ 0x%04x, %d, %d, %s },\n",
+ port_length, (port_disable ^ 1), port_oc, port_pos)
+ }
+ }
+
+ sb.WriteString(`};
+
+const struct usb3_port_config mainboard_usb3_ports[MAX_USB3_PORTS] = {
+`)
+
+ xpdo := PCIMap[PCIAddr{Bus: 0, Dev: 0x14, Func: 0}].ConfigDump[0xe8]
+ u3ocm := PCIMap[PCIAddr{Bus: 0, Dev: 0x14, Func: 0}].ConfigDump[0xc8:0xd0]
+
+ if !isULT {
+ nPorts = 6
+ } else {
+ nPorts = 4
+ }
+
+ for port := uint(0); port < nPorts; port++ {
+ var port_oc int = -1
+ port_disable := (xpdo >> port) & 1
+ for oc := 0; oc < 8; oc++ {
+ if (u3ocm[oc] & (1 << port)) != 0 {
+ port_oc = oc
+ break
+ }
+ }
+ if port_oc == -1 {
+ fmt.Fprintf(sb, "\t{ %d, USB_OC_PIN_SKIP },\n",
+ (port_disable ^ 1))
+ } else {
+ fmt.Fprintf(sb, "\t{ %d, %d },\n",
+ (port_disable ^ 1), port_oc)
+ }
+ }
+
+ sb.WriteString(`};
+`)
+
+}
+
+func init() {
+ for _, id := range []uint16{
+ 0x8c41, 0x8c49, 0x8c4b, 0x8c4f,
+ } {
+ RegisterPCI(0x8086, uint16(id), lynxpoint{variant: LYNX_POINT_MOBILE})
+ }
+
+ for _, id := range []uint16{
+ 0x8c42, 0x8c44, 0x8c46, 0x8c4a,
+ 0x8c4c, 0x8c4e, 0x8c50, 0x8c5c,
+ } {
+ RegisterPCI(0x8086, uint16(id), lynxpoint{variant: LYNX_POINT_DESKTOP})
+ }
+
+ for _, id := range []uint16{
+ 0x8c52, 0x8c54, 0x8c56,
+ } {
+ RegisterPCI(0x8086, uint16(id), lynxpoint{variant: LYNX_POINT_SERVER})
+ }
+
+ for _, id := range []uint16{
+ 0x9c41, 0x9c43, 0x9c45,
+ } {
+ RegisterPCI(0x8086, uint16(id), lynxpoint{variant: LYNX_POINT_ULT})
+ }
+
+ /* PCIe bridge */
+ for _, id := range []uint16{
+ 0x8c10, 0x8c12, 0x8c14, 0x8c16, 0x8c18, 0x8c1a, 0x8c1c, 0x8c1e,
+ 0x9c10, 0x9c12, 0x9c14, 0x9c16, 0x9c18, 0x9c1a,
+ } {
+ RegisterPCI(0x8086, id, GenericPCI{})
+ }
+
+ /* SMBus controller */
+ RegisterPCI(0x8086, 0x8c22, GenericPCI{MissingParent: "smbus"})
+ RegisterPCI(0x8086, 0x9c22, GenericPCI{MissingParent: "smbus"})
+
+ /* SATA */
+ for _, id := range []uint16{
+ 0x8c00, 0x8c02, 0x8c04, 0x8c06, 0x8c08, 0x8c0e,
+ 0x8c01, 0x8c03, 0x8c05, 0x8c07, 0x8c09, 0x8c0f,
+ 0x9c03, 0x9c05, 0x9c07, 0x9c0f,
+ } {
+ RegisterPCI(0x8086, id, GenericPCI{})
+ }
+
+ /* EHCI */
+ for _, id := range []uint16{
+ 0x9c26, 0x8c26, 0x8c2d,
+ } {
+ RegisterPCI(0x8086, id, GenericPCI{})
+ }
+
+ /* XHCI */
+ RegisterPCI(0x8086, 0x8c31, GenericPCI{})
+ RegisterPCI(0x8086, 0x9c31, GenericPCI{})
+
+ /* ME and children */
+ for _, id := range []uint16{
+ 0x8c3a, 0x8c3b, 0x8c3c, 0x8c3d,
+ 0x9c3a, 0x9c3b, 0x9c3c, 0x9c3d,
+ } {
+ RegisterPCI(0x8086, id, GenericPCI{})
+ }
+
+ /* Ethernet */
+ RegisterPCI(0x8086, 0x8c33, GenericPCI{})
+
+ /* Thermal */
+ RegisterPCI(0x8086, 0x8c24, GenericPCI{})
+ RegisterPCI(0x8086, 0x9c24, GenericPCI{})
+
+ /* LAN Controller on LP PCH (if EEPROM has 0x0000/0xffff in DID) */
+ RegisterPCI(0x8086, 0x155a, GenericPCI{})
+
+ /* SDIO */
+ RegisterPCI(0x8086, 0x9c35, GenericPCI{})
+
+ /* Smart Sound Technology Controller */
+ RegisterPCI(0x8086, 0x9c36, GenericPCI{})
+
+ /* Serial I/O */
+ for id := uint16(0x9c60); id <= 0x9c66; id++ {
+ RegisterPCI(0x8086, id, GenericPCI{})
+ }
+}
diff --git a/util/autoport/main.go b/util/autoport/main.go