blob: 1674e85cc23542a1967af92fd16d54c44e8d5053 [file] [log] [blame]
Alexandru Gagniuc88a30232013-06-04 23:37:56 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Alexandru Gagniuc <mr.nuke.me@gmail.com>
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.
Alexandru Gagniuc88a30232013-06-04 23:37:56 -050015 */
16
17#include "vx900.h"
18
19void dump_pci_device(device_t dev)
20{
21 int i;
22 for (i = 0; i <= 0xff; i++) {
23 unsigned char val;
24 if ((i & 0x0f) == 0)
25 printk(BIOS_DEBUG, "%.2x:", i);
26
27 if ((i & 0x0f) == 0x08)
28 printk(BIOS_DEBUG, " |");
29
30 val = pci_read_config8(dev, i);
31 printk(BIOS_DEBUG, " %.2x", val);
32
33 if ((i & 0x0f) == 0x0f)
34 printk(BIOS_DEBUG, "\n");
35 }
36}
37
38void pci_mod_config8(device_t dev, unsigned int where,
39 uint8_t clr_mask, uint8_t set_mask)
40{
41 uint8_t reg8 = pci_read_config8(dev, where);
42 reg8 &= ~clr_mask;
43 reg8 |= set_mask;
44 pci_write_config8(dev, where, reg8);
45}
46
47void pci_mod_config16(device_t dev, unsigned int where,
48 uint16_t clr_mask, uint16_t set_mask)
49{
50 uint16_t reg16 = pci_read_config16(dev, where);
51 reg16 &= ~clr_mask;
52 reg16 |= set_mask;
53 pci_write_config16(dev, where, reg16);
54}
55
56void pci_mod_config32(device_t dev, unsigned int where,
57 uint32_t clr_mask, uint32_t set_mask)
58{
59 uint32_t reg32 = pci_read_config32(dev, where);
60 reg32 &= ~clr_mask;
61 reg32 |= set_mask;
62 pci_write_config32(dev, where, reg32);
63}