summaryrefslogtreecommitdiff
path: root/util/autoport/ec_fixme.go
blob: 850998d5ceb2484eebf80298ccfb082e44e395c2 (plain)
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
package main

import "fmt"

func FIXMEEC(ctx Context) {
	ap := Create(ctx, "acpi/platform.asl")
	defer ap.Close()

	hasKeyboard := ctx.InfoSource.HasPS2()

	sbGPE := GuessECGPE(ctx)
	var GPEUnsure bool
	if sbGPE < 0 {
		sbGPE = SouthBridge.EncodeGPE(1)
		GPEUnsure = true
		SouthBridge.NeedRouteGPIOManually()
	} else {
		GPEUnsure = false
		SouthBridge.EnableGPE(SouthBridge.DecodeGPE(sbGPE))
	}

	ap.WriteString(
		`Method(_WAK,1)
{
        /* FIXME: EC support  */
	Return(Package(){0,0})
}

Method(_PTS,1)
{
        /* FIXME: EC support  */
}
`)

	ecs := ctx.InfoSource.GetEC()
	MainboardIncludes = append(MainboardIncludes, "ec/acpi/ec.h")
	MainboardIncludes = append(MainboardIncludes, "console/console.h")

	MainboardInit +=
		`	/* FIXME: trim this down or remove if necessary */
	{
		int i;
		const u8 dmp[256] = {`
	for i := 0; i < 0x100; i++ {
		if (i & 0xf) == 0 {
			MainboardInit += fmt.Sprintf("\n\t\t\t/* %02x */ ", i)
		}
		MainboardInit += fmt.Sprintf("0x%02x,", ecs[i])
		if (i & 0xf) != 0xf {
			MainboardInit += " "
		}
	}
	MainboardInit += "\n\t\t};\n"
	MainboardInit += `
		printk(BIOS_DEBUG, "Replaying EC dump ...");
		for (i = 0; i < 256; i++)
			ec_write (i, dmp[i]);
		printk(BIOS_DEBUG, "done\n");
	}
`

	KconfigBool["EC_ACPI"] = true
	si := Create(ctx, "acpi/superio.asl")
	defer si.Close()

	if hasKeyboard {
		si.WriteString("#include <drivers/pc80/ps2_controller.asl>\n")
		MainboardInit += fmt.Sprintf("\tpc_keyboard_init();\n")
		MainboardIncludes = append(MainboardIncludes, "pc80/keyboard.h")
	}

	ec := Create(ctx, "acpi/ec.asl")
	defer ec.Close()

	ec.WriteString(`Device(EC)
{
	Name (_HID, EISAID("PNP0C09"))
	Name (_UID, 0)
`)
	if GPEUnsure {
		ec.WriteString("\t/* FIXME: Set GPE  */\n")
		ec.WriteString("\t/* Name (_GPE, ?)  */\n")
	} else {
		fmt.Fprintf(ec, "\tName (_GPE, %d)\n", sbGPE)
	}
	ec.WriteString("/* FIXME: EC support */\n")
	ec.WriteString("}\n")
}