Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2002 |
Albert ARIBAUD | 60fbc8d | 2011-08-04 18:45:45 +0200 | [diff] [blame] | 4 | * Daniel Engström, Omicron Ceti AB, daniel@omicron.se |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _PCI_I386_H_ |
Gabe Black | 67bb7b0 | 2012-10-10 13:12:57 +0000 | [diff] [blame] | 8 | #define _PCI_I386_H_ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 9 | |
Simon Glass | 4e03781 | 2015-03-05 12:25:31 -0700 | [diff] [blame] | 10 | #include <pci.h> |
| 11 | |
Bin Meng | 39620f6 | 2015-02-02 22:35:25 +0800 | [diff] [blame] | 12 | /* 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 Glass | 7567787 | 2019-09-25 08:11:37 -0600 | [diff] [blame] | 20 | /** |
| 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 Glass | 7567787 | 2019-09-25 08:11:37 -0600 | [diff] [blame] | 25 | * @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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 29 | * Return: 0 if OK, -ve on error |
Simon Glass | 7567787 | 2019-09-25 08:11:37 -0600 | [diff] [blame] | 30 | */ |
Simon Glass | a546458 | 2019-08-31 21:23:18 -0600 | [diff] [blame] | 31 | int pci_x86_read_config(pci_dev_t bdf, uint offset, ulong *valuep, |
| 32 | enum pci_size_t size); |
Simon Glass | 4e03781 | 2015-03-05 12:25:31 -0700 | [diff] [blame] | 33 | |
Simon Glass | 7567787 | 2019-09-25 08:11:37 -0600 | [diff] [blame] | 34 | /** |
| 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 Glass | 7567787 | 2019-09-25 08:11:37 -0600 | [diff] [blame] | 39 | * @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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 43 | * Return: 0 if OK, -ve on error |
Simon Glass | 7567787 | 2019-09-25 08:11:37 -0600 | [diff] [blame] | 44 | */ |
Simon Glass | a546458 | 2019-08-31 21:23:18 -0600 | [diff] [blame] | 45 | int pci_x86_write_config(pci_dev_t bdf, uint offset, ulong value, |
| 46 | enum pci_size_t size); |
Simon Glass | 4e03781 | 2015-03-05 12:25:31 -0700 | [diff] [blame] | 47 | |
Bin Meng | 363849b | 2015-04-24 18:10:03 +0800 | [diff] [blame] | 48 | /** |
Simon Glass | 7567787 | 2019-09-25 08:11:37 -0600 | [diff] [blame] | 49 | * 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 Glass | 7567787 | 2019-09-25 08:11:37 -0600 | [diff] [blame] | 54 | * @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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 58 | * Return: 0 if OK, -ve on error |
Simon Glass | 7567787 | 2019-09-25 08:11:37 -0600 | [diff] [blame] | 59 | */ |
Simon Glass | a546458 | 2019-08-31 21:23:18 -0600 | [diff] [blame] | 60 | int pci_x86_clrset_config(pci_dev_t bdf, uint offset, ulong clr, ulong set, |
| 61 | enum pci_size_t size); |
Simon Glass | 7567787 | 2019-09-25 08:11:37 -0600 | [diff] [blame] | 62 | |
| 63 | /** |
Bin Meng | 363849b | 2015-04-24 18:10:03 +0800 | [diff] [blame] | 64 | * 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 Meng | 363849b | 2015-04-24 18:10:03 +0800 | [diff] [blame] | 71 | * @irq: An array of IRQ numbers that are assigned to INTA through |
| 72 | * INTD of this PCI device. |
| 73 | */ |
Bin Meng | da5d463 | 2015-07-15 16:23:40 +0800 | [diff] [blame] | 74 | void pci_assign_irqs(int bus, int device, u8 irq[4]); |
Bin Meng | 363849b | 2015-04-24 18:10:03 +0800 | [diff] [blame] | 75 | |
Bin Meng | 39620f6 | 2015-02-02 22:35:25 +0800 | [diff] [blame] | 76 | #endif /* __ASSEMBLY__ */ |
| 77 | |
| 78 | #endif /* _PCI_I386_H_ */ |