e6dd68eb7a5482f3940cd3540db74f3f4bdab8e6
[coreboot.git] / src / southbridge / intel / i82371eb / i82371eb_early_pm.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #include <stdint.h>
22 #include <device/pci_ids.h>
23 #include "i82371eb.h"
24
25 #define PM_IO_BASE 0xe400
26
27 static void enable_pm(void)
28 {
29         device_t dev;
30         u8 reg8;
31         u16 reg16;
32
33         /* Check for SMBus/PM device PCI ID on the 82371AB/EB/MB. */
34         dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_INTEL,
35                                 PCI_DEVICE_ID_INTEL_82371AB_SMB_ACPI), 0);
36
37         if (dev == PCI_DEV_INVALID)
38                 die("SMBus/PM controller not found\n");
39
40         /* Set the PM I/O base. */
41         pci_write_config32(dev, PMBA, PM_IO_BASE | 1);
42
43         /* Enable access to the PM I/O space. */
44         reg16 = pci_read_config16(dev, PCI_COMMAND);
45         reg16 |= PCI_COMMAND_IO;
46         pci_write_config16(dev, PCI_COMMAND, reg16);
47
48         /* PM I/O Space Enable (PMIOSE). */
49         reg8 = pci_read_config8(dev, PMREGMISC);
50         reg8 |= PMIOSE;
51         pci_write_config8(dev, PMREGMISC, reg8);
52 }
53