pci drivers should be const.
[coreboot.git] / src / northbridge / amd / amdfam10 / amdfam10_pci.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 Advanced Micro Devices, Inc.
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
21 #ifndef AMDFAM10_PCI_C
22 #define AMDFAM10_PCI_C
23 /* bit [10,8] are dev func, bit[1,0] are dev index */
24
25
26 static u32 pci_read_config32_index(device_t dev, u32 index_reg, u32 index)
27 {
28         u32 dword;
29
30         pci_write_config32(dev, index_reg, index);
31         dword = pci_read_config32(dev, index_reg+0x4);
32         return dword;
33 }
34
35 static void pci_write_config32_index(device_t dev, u32 index_reg, u32 index, u32 data)
36 {
37
38         pci_write_config32(dev, index_reg, index);
39
40         pci_write_config32(dev, index_reg + 0x4, data);
41
42 }
43
44 static u32 pci_read_config32_index_wait(device_t dev, u32 index_reg, u32 index)
45 {
46
47         u32 dword;
48
49         index &= ~(1<<30);
50         pci_write_config32(dev, index_reg, index);
51         do {
52                 dword = pci_read_config32(dev, index_reg);
53         } while (!(dword & (1<<31)));
54         dword = pci_read_config32(dev, index_reg+0x4);
55         return dword;
56 }
57
58 static void pci_write_config32_index_wait(device_t dev, u32 index_reg, u32 index, u32 data)
59 {
60
61         u32 dword;
62
63         pci_write_config32(dev, index_reg + 0x4, data);
64         index |= (1<<30);
65         pci_write_config32(dev, index_reg, index);
66         do {
67                 dword = pci_read_config32(dev, index_reg);
68         } while (!(dword & (1<<31)));
69
70 }
71 #endif
72
73