Add constants for fast path resume copying
[coreboot.git] / src / northbridge / via / vx800 / pci_rawops.h
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2009 One Laptop per Child, Association, Inc.
5  * Copyright (C) 2010 coresystems GmbH
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License.
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 #ifndef NORTHBRIDGE_VIA_VX800_PCI_RAWOPS_H
22 #define NORTHBRIDGE_VIA_VX800_PCI_RAWOPS_H
23
24 #include <stdint.h>
25 #include <arch/romcc_io.h>
26
27 struct VIA_PCI_REG_INIT_TABLE {
28         u8 ChipRevisionStart;
29         u8 ChipRevisionEnd;
30         u8 Bus;
31         u8 Device;
32         u8 Function;
33         u32 Register;
34         u8 Mask;
35         u8 Value;
36 };
37
38 static void pci_modify_config8(device_t dev, unsigned where, u8 orval, u8 mask)
39 {
40         u8 data = pci_read_config8(dev, where);
41         data &= (~mask);
42         data |= orval;
43         pci_write_config8(dev, where, data);
44 }
45
46 static void via_pci_inittable(u8 chipversion,
47                        const struct VIA_PCI_REG_INIT_TABLE *initdata)
48 {
49         u8 i = 0;
50         device_t devbxdxfx;
51         for (i = 0;; i++) {
52                 if ((initdata[i].Mask == 0) && (initdata[i].Value == 0)
53                     && (initdata[i].Bus == 0)
54                     && (initdata[i].ChipRevisionEnd == 0xff)
55                     && (initdata[i].ChipRevisionStart == 0)
56                     && (initdata[i].Device == 0)
57                     && (initdata[i].Function == 0)
58                     && (initdata[i].Register == 0))
59                         break;
60                 if ((chipversion >= initdata[i].ChipRevisionStart)
61                     && (chipversion <= initdata[i].ChipRevisionEnd)) {
62                         devbxdxfx =
63                             PCI_DEV(initdata[i].Bus, initdata[i].Device,
64                                        initdata[i].Function);
65                         pci_modify_config8(devbxdxfx,
66                                               initdata[i].Register,
67                                               initdata[i].Value,
68                                               initdata[i].Mask);
69                 }
70         }
71 }
72 #endif