summaryrefslogtreecommitdiff
path: root/src/northbridge/via/vx800/pci_rawops.h
blob: 89d7eb2bdd1d2a4e47b183c8bf02a438ff12475f (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
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2009 One Laptop per Child, Association, Inc.
 * Copyright (C) 2010 coresystems GmbH
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

#ifndef NORTHBRIDGE_VIA_VX800_PCI_RAWOPS_H
#define NORTHBRIDGE_VIA_VX800_PCI_RAWOPS_H

#include <stdint.h>
#include <arch/romcc_io.h>

struct VIA_PCI_REG_INIT_TABLE {
	u8 ChipRevisionStart;
	u8 ChipRevisionEnd;
	u8 Bus;
	u8 Device;
	u8 Function;
	u32 Register;
	u8 Mask;
	u8 Value;
};

static void pci_modify_config8(device_t dev, unsigned where, u8 orval, u8 mask)
{
	u8 data = pci_read_config8(dev, where);
	data &= (~mask);
	data |= orval;
	pci_write_config8(dev, where, data);
}

static void via_pci_inittable(u8 chipversion,
		       const struct VIA_PCI_REG_INIT_TABLE *initdata)
{
	u8 i = 0;
	device_t devbxdxfx;
	for (i = 0;; i++) {
		if ((initdata[i].Mask == 0) && (initdata[i].Value == 0)
		    && (initdata[i].Bus == 0)
		    && (initdata[i].ChipRevisionEnd == 0xff)
		    && (initdata[i].ChipRevisionStart == 0)
		    && (initdata[i].Device == 0)
		    && (initdata[i].Function == 0)
		    && (initdata[i].Register == 0))
			break;
		if ((chipversion >= initdata[i].ChipRevisionStart)
		    && (chipversion <= initdata[i].ChipRevisionEnd)) {
			devbxdxfx =
			    PCI_DEV(initdata[i].Bus, initdata[i].Device,
				       initdata[i].Function);
			pci_modify_config8(devbxdxfx,
					      initdata[i].Register,
					      initdata[i].Value,
					      initdata[i].Mask);
		}
	}
}
#endif