wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
Albert ARIBAUD | fa82f87 | 2011-08-04 18:45:45 +0200 | [diff] [blame] | 3 | * Daniel Engström, Omicron Ceti AB, daniel@omicron.se |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef _PCI_I386_H_ |
Gabe Black | 452f50f | 2012-10-10 13:12:57 +0000 | [diff] [blame] | 9 | #define _PCI_I386_H_ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 10 | |
Simon Glass | a219dae | 2015-03-05 12:25:31 -0700 | [diff] [blame] | 11 | #include <pci.h> |
| 12 | |
Bin Meng | 3c8ae53 | 2015-02-02 22:35:25 +0800 | [diff] [blame] | 13 | /* bus mapping constants (used for PCI core initialization) */ |
| 14 | #define PCI_REG_ADDR 0xcf8 |
| 15 | #define PCI_REG_DATA 0xcfc |
| 16 | |
| 17 | #define PCI_CFG_EN 0x80000000 |
| 18 | |
| 19 | #ifndef __ASSEMBLY__ |
| 20 | |
Graeme Russ | 83088af | 2011-11-08 02:33:15 +0000 | [diff] [blame] | 21 | #define DEFINE_PCI_DEVICE_TABLE(_table) \ |
| 22 | const struct pci_device_id _table[] |
| 23 | |
Simon Glass | d188b18 | 2014-11-12 22:42:11 -0700 | [diff] [blame] | 24 | struct pci_controller; |
| 25 | |
Graeme Russ | 1cfcf03 | 2011-11-08 02:33:22 +0000 | [diff] [blame] | 26 | void pci_setup_type1(struct pci_controller *hose); |
Simon Glass | d188b18 | 2014-11-12 22:42:11 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * board_pci_setup_hose() - Set up the PCI hose |
| 30 | * |
| 31 | * This is called by the common x86 PCI code to set up the PCI controller |
| 32 | * hose. It may be called when no memory/BSS is available so should just |
| 33 | * store things in 'hose' and not in BSS variables. |
| 34 | */ |
| 35 | void board_pci_setup_hose(struct pci_controller *hose); |
Simon Glass | 7430f10 | 2014-11-12 22:42:12 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * pci_early_init_hose() - Set up PCI host before relocation |
| 39 | * |
| 40 | * This allocates memory for, sets up and returns the PCI hose. It can be |
Bin Meng | 8f9052f | 2014-12-30 22:53:21 +0800 | [diff] [blame] | 41 | * called before relocation. The hose will be stored in gd->hose for |
Simon Glass | 7430f10 | 2014-11-12 22:42:12 -0700 | [diff] [blame] | 42 | * later use, but will become invalid one DRAM is available. |
| 43 | */ |
| 44 | int pci_early_init_hose(struct pci_controller **hosep); |
Simon Glass | 6fb3b72 | 2014-11-12 22:42:14 -0700 | [diff] [blame] | 45 | |
Simon Glass | e94ea6f | 2014-11-14 18:18:28 -0700 | [diff] [blame] | 46 | int board_pci_pre_scan(struct pci_controller *hose); |
| 47 | int board_pci_post_scan(struct pci_controller *hose); |
| 48 | |
Simon Glass | 6fb3b72 | 2014-11-12 22:42:14 -0700 | [diff] [blame] | 49 | /* |
| 50 | * Simple PCI access routines - these work from either the early PCI hose |
| 51 | * or the 'real' one, created after U-Boot has memory available |
| 52 | */ |
Simon Glass | 31f57c2 | 2015-03-05 12:25:15 -0700 | [diff] [blame] | 53 | unsigned int x86_pci_read_config8(pci_dev_t dev, unsigned where); |
| 54 | unsigned int x86_pci_read_config16(pci_dev_t dev, unsigned where); |
| 55 | unsigned int x86_pci_read_config32(pci_dev_t dev, unsigned where); |
Simon Glass | 6fb3b72 | 2014-11-12 22:42:14 -0700 | [diff] [blame] | 56 | |
Simon Glass | 31f57c2 | 2015-03-05 12:25:15 -0700 | [diff] [blame] | 57 | void x86_pci_write_config8(pci_dev_t dev, unsigned where, unsigned value); |
| 58 | void x86_pci_write_config16(pci_dev_t dev, unsigned where, unsigned value); |
| 59 | void x86_pci_write_config32(pci_dev_t dev, unsigned where, unsigned value); |
Simon Glass | 6fb3b72 | 2014-11-12 22:42:14 -0700 | [diff] [blame] | 60 | |
Simon Glass | a219dae | 2015-03-05 12:25:31 -0700 | [diff] [blame] | 61 | int pci_x86_read_config(struct udevice *bus, pci_dev_t bdf, uint offset, |
| 62 | ulong *valuep, enum pci_size_t size); |
| 63 | |
| 64 | int pci_x86_write_config(struct udevice *bus, pci_dev_t bdf, uint offset, |
| 65 | ulong value, enum pci_size_t size); |
| 66 | |
Bin Meng | e3e7fa2 | 2015-04-24 18:10:03 +0800 | [diff] [blame] | 67 | /** |
| 68 | * Assign IRQ number to a PCI device |
| 69 | * |
| 70 | * This function assigns IRQ for a PCI device. If the device does not exist |
| 71 | * or does not require interrupts then this function has no effect. |
| 72 | * |
| 73 | * @bus: PCI bus number |
| 74 | * @device: PCI device number |
Bin Meng | e3e7fa2 | 2015-04-24 18:10:03 +0800 | [diff] [blame] | 75 | * @irq: An array of IRQ numbers that are assigned to INTA through |
| 76 | * INTD of this PCI device. |
| 77 | */ |
Bin Meng | 31a2dc6 | 2015-07-15 16:23:40 +0800 | [diff] [blame] | 78 | void pci_assign_irqs(int bus, int device, u8 irq[4]); |
Bin Meng | e3e7fa2 | 2015-04-24 18:10:03 +0800 | [diff] [blame] | 79 | |
Bin Meng | 3c8ae53 | 2015-02-02 22:35:25 +0800 | [diff] [blame] | 80 | #endif /* __ASSEMBLY__ */ |
| 81 | |
| 82 | #endif /* _PCI_I386_H_ */ |