blob: 1c30b32d46aa728bc50116e0fad23a3b8ff735fe [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenk591dda52002-11-18 00:14:45 +00002/*
3 * (C) Copyright 2002
Albert ARIBAUD60fbc8d2011-08-04 18:45:45 +02004 * Daniel Engström, Omicron Ceti AB, daniel@omicron.se
wdenk591dda52002-11-18 00:14:45 +00005 */
6
7#ifndef _PCI_I386_H_
Gabe Black67bb7b02012-10-10 13:12:57 +00008#define _PCI_I386_H_
wdenk591dda52002-11-18 00:14:45 +00009
Simon Glass4e037812015-03-05 12:25:31 -070010#include <pci.h>
11
Bin Meng39620f62015-02-02 22:35:25 +080012/* bus mapping constants (used for PCI core initialization) */
13#define PCI_REG_ADDR 0xcf8
14#define PCI_REG_DATA 0xcfc
15
16#define PCI_CFG_EN 0x80000000
17
18#ifndef __ASSEMBLY__
19
Simon Glass75677872019-09-25 08:11:37 -060020/**
21 * pci_x86_read_config() - Read a configuration value from a device
22 *
23 * This function can be called before PCI is set up in driver model.
24 *
Simon Glass75677872019-09-25 08:11:37 -060025 * @bdf: PCI device address: bus, device and function -see PCI_BDF()
26 * @offset: Register offset to read
27 * @valuep: Place to put the returned value
28 * @size: Access size
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010029 * Return: 0 if OK, -ve on error
Simon Glass75677872019-09-25 08:11:37 -060030 */
Simon Glassa5464582019-08-31 21:23:18 -060031int pci_x86_read_config(pci_dev_t bdf, uint offset, ulong *valuep,
32 enum pci_size_t size);
Simon Glass4e037812015-03-05 12:25:31 -070033
Simon Glass75677872019-09-25 08:11:37 -060034/**
35 * pci_bus_write_config() - Write a configuration value to a device
36 *
37 * This function can be called before PCI is set up in driver model.
38 *
Simon Glass75677872019-09-25 08:11:37 -060039 * @bdf: PCI device address: bus, device and function -see PCI_BDF()
40 * @offset: Register offset to write
41 * @value: Value to write
42 * @size: Access size
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010043 * Return: 0 if OK, -ve on error
Simon Glass75677872019-09-25 08:11:37 -060044 */
Simon Glassa5464582019-08-31 21:23:18 -060045int pci_x86_write_config(pci_dev_t bdf, uint offset, ulong value,
46 enum pci_size_t size);
Simon Glass4e037812015-03-05 12:25:31 -070047
Bin Meng363849b2015-04-24 18:10:03 +080048/**
Simon Glass75677872019-09-25 08:11:37 -060049 * pci_bus_clrset_config32() - Update a configuration value for a device
50 *
51 * The register at @offset is updated to (oldvalue & ~clr) | set. This function
52 * can be called before PCI is set up in driver model.
53 *
Simon Glass75677872019-09-25 08:11:37 -060054 * @bdf: PCI device address: bus, device and function -see PCI_BDF()
55 * @offset: Register offset to update
56 * @clr: Bits to clear
57 * @set: Bits to set
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010058 * Return: 0 if OK, -ve on error
Simon Glass75677872019-09-25 08:11:37 -060059 */
Simon Glassa5464582019-08-31 21:23:18 -060060int pci_x86_clrset_config(pci_dev_t bdf, uint offset, ulong clr, ulong set,
61 enum pci_size_t size);
Simon Glass75677872019-09-25 08:11:37 -060062
63/**
Bin Meng363849b2015-04-24 18:10:03 +080064 * Assign IRQ number to a PCI device
65 *
66 * This function assigns IRQ for a PCI device. If the device does not exist
67 * or does not require interrupts then this function has no effect.
68 *
69 * @bus: PCI bus number
70 * @device: PCI device number
Bin Meng363849b2015-04-24 18:10:03 +080071 * @irq: An array of IRQ numbers that are assigned to INTA through
72 * INTD of this PCI device.
73 */
Bin Mengda5d4632015-07-15 16:23:40 +080074void pci_assign_irqs(int bus, int device, u8 irq[4]);
Bin Meng363849b2015-04-24 18:10:03 +080075
Bin Meng39620f62015-02-02 22:35:25 +080076#endif /* __ASSEMBLY__ */
77
78#endif /* _PCI_I386_H_ */