blob: 08e2b54c371c50938de3ffb91a8e0618ea60529c [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
Elyes HAOUASafc63842018-12-05 11:02:11 +010019#ifdef __SIMPLE_DEVICE__
20void dump_pci_device(pci_devfn_t dev)
21#else
22void dump_pci_device(struct device *dev)
23#endif
Alexandru Gagniuc88a30232013-06-04 23:37:56 -050024{
25 int i;
26 for (i = 0; i <= 0xff; i++) {
27 unsigned char val;
28 if ((i & 0x0f) == 0)
29 printk(BIOS_DEBUG, "%.2x:", i);
30
31 if ((i & 0x0f) == 0x08)
32 printk(BIOS_DEBUG, " |");
33
34 val = pci_read_config8(dev, i);
35 printk(BIOS_DEBUG, " %.2x", val);
36
37 if ((i & 0x0f) == 0x0f)
38 printk(BIOS_DEBUG, "\n");
39 }
40}
41
Elyes HAOUASafc63842018-12-05 11:02:11 +010042#ifdef __SIMPLE_DEVICE__
43void pci_mod_config8(pci_devfn_t dev, unsigned int where, uint8_t clr_mask,
44 uint8_t set_mask)
45#else
46void pci_mod_config8(struct device *dev, unsigned int where, uint8_t clr_mask,
47 uint8_t set_mask)
48#endif
Alexandru Gagniuc88a30232013-06-04 23:37:56 -050049{
50 uint8_t reg8 = pci_read_config8(dev, where);
51 reg8 &= ~clr_mask;
52 reg8 |= set_mask;
53 pci_write_config8(dev, where, reg8);
54}
55
Elyes HAOUASafc63842018-12-05 11:02:11 +010056#ifdef __SIMPLE_DEVICE__
57void pci_mod_config16(pci_devfn_t dev, unsigned int where,
Alexandru Gagniuc88a30232013-06-04 23:37:56 -050058 uint16_t clr_mask, uint16_t set_mask)
Elyes HAOUASafc63842018-12-05 11:02:11 +010059#else
60void pci_mod_config16(struct device *dev, unsigned int where,
61 uint16_t clr_mask, uint16_t set_mask)
62#endif
Alexandru Gagniuc88a30232013-06-04 23:37:56 -050063{
64 uint16_t reg16 = pci_read_config16(dev, where);
65 reg16 &= ~clr_mask;
66 reg16 |= set_mask;
67 pci_write_config16(dev, where, reg16);
68}
69
Elyes HAOUASafc63842018-12-05 11:02:11 +010070#ifdef __SIMPLE_DEVICE__
71void pci_mod_config32(pci_devfn_t dev, unsigned int where,
Alexandru Gagniuc88a30232013-06-04 23:37:56 -050072 uint32_t clr_mask, uint32_t set_mask)
Elyes HAOUASafc63842018-12-05 11:02:11 +010073#else
74void pci_mod_config32(struct device *dev, unsigned int where,
75 uint32_t clr_mask, uint32_t set_mask)
76#endif
Alexandru Gagniuc88a30232013-06-04 23:37:56 -050077{
78 uint32_t reg32 = pci_read_config32(dev, where);
79 reg32 &= ~clr_mask;
80 reg32 |= set_mask;
81 pci_write_config32(dev, where, reg32);
82}