Add support for Intel Sandybridge CPU (northbridge part)
[coreboot.git] / src / northbridge / intel / sandybridge / pcie_config.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007-2009 coresystems GmbH
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; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 #include "sandybridge.h"
21
22 static inline __attribute__ ((always_inline))
23 u8 pcie_read_config8(device_t dev, unsigned int where)
24 {
25         unsigned long addr;
26         addr = DEFAULT_PCIEXBAR | dev | where;
27         return read8(addr);
28 }
29
30 static inline __attribute__ ((always_inline))
31 u16 pcie_read_config16(device_t dev, unsigned int where)
32 {
33         unsigned long addr;
34         addr = DEFAULT_PCIEXBAR | dev | where;
35         return read16(addr);
36 }
37
38 static inline __attribute__ ((always_inline))
39 u32 pcie_read_config32(device_t dev, unsigned int where)
40 {
41         unsigned long addr;
42         addr = DEFAULT_PCIEXBAR | dev | where;
43         return read32(addr);
44 }
45
46 static inline __attribute__ ((always_inline))
47 void pcie_write_config8(device_t dev, unsigned int where, u8 value)
48 {
49         unsigned long addr;
50         addr = DEFAULT_PCIEXBAR | dev | where;
51         write8(addr, value);
52 }
53
54 static inline __attribute__ ((always_inline))
55 void pcie_write_config16(device_t dev, unsigned int where, u16 value)
56 {
57         unsigned long addr;
58         addr = DEFAULT_PCIEXBAR | dev | where;
59         write16(addr, value);
60 }
61
62 static inline __attribute__ ((always_inline))
63 void pcie_write_config32(device_t dev, unsigned int where, u32 value)
64 {
65         unsigned long addr;
66         addr = DEFAULT_PCIEXBAR | dev | where;
67         write32(addr, value);
68 }
69
70 static inline __attribute__ ((always_inline))
71 void pcie_or_config8(device_t dev, unsigned int where, u8 ormask)
72 {
73         u8 value = pcie_read_config8(dev, where);
74         pcie_write_config8(dev, where, value | ormask);
75 }
76
77 static inline __attribute__ ((always_inline))
78 void pcie_or_config16(device_t dev, unsigned int where, u16 ormask)
79 {
80         u16 value = pcie_read_config16(dev, where);
81         pcie_write_config16(dev, where, value | ormask);
82 }
83
84 static inline __attribute__ ((always_inline))
85 void pcie_or_config32(device_t dev, unsigned int where, u32 ormask)
86 {
87         u32 value = pcie_read_config32(dev, where);
88         pcie_write_config32(dev, where, value | ormask);
89 }