aboutsummaryrefslogtreecommitdiff
path: root/src/southbridge/amd/amd8111/amd8111_acpi.c
blob: 3a5a594f57694c3666d0774da642db51922177dd (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
#include <console/console.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_ids.h>
#include <device/pci_ops.h>
#include <pc80/mc146818rtc.h>
#include "amd8111.h"

#define PREVIOUS_POWER_STATE 0x43
#define MAINBOARD_POWER_OFF 0
#define MAINBOARD_POWER_ON 1

#ifndef MAINBOARD_POWER_ON_AFTER_POWER_FAIL
#define MAINBOARD_POWER_ON_AFTER_POWER_FAIL MAINBOARD_POWER_ON
#endif


static void acpi_init(struct device *dev)
{
	uint8_t byte;
	uint16_t word;
	int on;

#if 0
	printk_debug("ACPI: disabling NMI watchdog.. ");
	pci_read_config_byte(dev, 0x49, &byte);
	pci_write_config_byte(dev, 0x49, byte | (1<<2));


	pci_read_config_byte(dev, 0x41, &byte);
	pci_write_config_byte(dev, 0x41, byte | (1<<6)|(1<<2));

	/* added from sourceforge */
	pci_read_config_byte(dev, 0x48, &byte);
	pci_write_config_byte(dev, 0x48, byte | (1<<3));

	printk_debug("done.\n");


	printk_debug("ACPI: Routing IRQ 12 to PS2 port.. ");
	pci_read_config_word(dev, 0x46, &word);
	pci_write_config_word(dev, 0x46, word | (1<<9));
	printk_debug("done.\n");

	
	printk_debug("ACPI: setting PM class code.. ");
	pci_write_config_dword(dev, 0x60, 0x06800000);
	printk_debug("done.\n");
#endif
	on = MAINBOARD_POWER_ON_AFTER_POWER_FAIL;
	get_option(&on, "power_on_after_fail");
	byte = pci_read_config8(dev, PREVIOUS_POWER_STATE);
	byte &= ~0x40;
	if (!on) {
		byte |= 0x40;
	}
	pci_write_config8(dev, PREVIOUS_POWER_STATE, byte);
	printk_info("set power %s after power fail\n", on?"on":"off");

}

static struct device_operations acpi_ops  = {
	.read_resources   = pci_dev_read_resources,
	.set_resources    = pci_dev_set_resources,
	.enable_resources = pci_dev_enable_resources,
	.init             = acpi_init,
	.scan_bus         = 0,
	.enable           = amd8111_enable,
};

static struct pci_driver acpi_driver __pci_driver = {
	.ops    = &acpi_ops,
	.vendor = PCI_VENDOR_ID_AMD,
	.device = PCI_DEVICE_ID_AMD_8111_ACPI,
};