18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_MICROBLAZE_PCI_BRIDGE_H 38c2ecf20Sopenharmony_ci#define _ASM_MICROBLAZE_PCI_BRIDGE_H 48c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#include <linux/pci.h> 88c2ecf20Sopenharmony_ci#include <linux/list.h> 98c2ecf20Sopenharmony_ci#include <linux/ioport.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistruct device_node; 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI 148c2ecf20Sopenharmony_ciextern struct list_head hose_list; 158c2ecf20Sopenharmony_ciextern int pcibios_vaddr_is_ioport(void __iomem *address); 168c2ecf20Sopenharmony_ci#else 178c2ecf20Sopenharmony_cistatic inline int pcibios_vaddr_is_ioport(void __iomem *address) 188c2ecf20Sopenharmony_ci{ 198c2ecf20Sopenharmony_ci return 0; 208c2ecf20Sopenharmony_ci} 218c2ecf20Sopenharmony_ci#endif 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* 248c2ecf20Sopenharmony_ci * Structure of a PCI controller (host bridge) 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_cistruct pci_controller { 278c2ecf20Sopenharmony_ci struct pci_bus *bus; 288c2ecf20Sopenharmony_ci char is_dynamic; 298c2ecf20Sopenharmony_ci struct device_node *dn; 308c2ecf20Sopenharmony_ci struct list_head list_node; 318c2ecf20Sopenharmony_ci struct device *parent; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci int first_busno; 348c2ecf20Sopenharmony_ci int last_busno; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci int self_busno; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci void __iomem *io_base_virt; 398c2ecf20Sopenharmony_ci resource_size_t io_base_phys; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci resource_size_t pci_io_size; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci /* Some machines (PReP) have a non 1:1 mapping of 448c2ecf20Sopenharmony_ci * the PCI memory space in the CPU bus space 458c2ecf20Sopenharmony_ci */ 468c2ecf20Sopenharmony_ci resource_size_t pci_mem_offset; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci /* Some machines have a special region to forward the ISA 498c2ecf20Sopenharmony_ci * "memory" cycles such as VGA memory regions. Left to 0 508c2ecf20Sopenharmony_ci * if unsupported 518c2ecf20Sopenharmony_ci */ 528c2ecf20Sopenharmony_ci resource_size_t isa_mem_phys; 538c2ecf20Sopenharmony_ci resource_size_t isa_mem_size; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci struct pci_ops *ops; 568c2ecf20Sopenharmony_ci unsigned int __iomem *cfg_addr; 578c2ecf20Sopenharmony_ci void __iomem *cfg_data; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci /* 608c2ecf20Sopenharmony_ci * Used for variants of PCI indirect handling and possible quirks: 618c2ecf20Sopenharmony_ci * SET_CFG_TYPE - used on 4xx or any PHB that does explicit type0/1 628c2ecf20Sopenharmony_ci * EXT_REG - provides access to PCI-e extended registers 638c2ecf20Sopenharmony_ci * SURPRESS_PRIMARY_BUS - we suppress the setting of PCI_PRIMARY_BUS 648c2ecf20Sopenharmony_ci * on Freescale PCI-e controllers since they used the PCI_PRIMARY_BUS 658c2ecf20Sopenharmony_ci * to determine which bus number to match on when generating type0 668c2ecf20Sopenharmony_ci * config cycles 678c2ecf20Sopenharmony_ci * NO_PCIE_LINK - the Freescale PCI-e controllers have issues with 688c2ecf20Sopenharmony_ci * hanging if we don't have link and try to do config cycles to 698c2ecf20Sopenharmony_ci * anything but the PHB. Only allow talking to the PHB if this is 708c2ecf20Sopenharmony_ci * set. 718c2ecf20Sopenharmony_ci * BIG_ENDIAN - cfg_addr is a big endian register 728c2ecf20Sopenharmony_ci * BROKEN_MRM - the 440EPx/GRx chips have an errata that causes hangs 738c2ecf20Sopenharmony_ci * on the PLB4. Effectively disable MRM commands by setting this. 748c2ecf20Sopenharmony_ci */ 758c2ecf20Sopenharmony_ci#define INDIRECT_TYPE_SET_CFG_TYPE 0x00000001 768c2ecf20Sopenharmony_ci#define INDIRECT_TYPE_EXT_REG 0x00000002 778c2ecf20Sopenharmony_ci#define INDIRECT_TYPE_SURPRESS_PRIMARY_BUS 0x00000004 788c2ecf20Sopenharmony_ci#define INDIRECT_TYPE_NO_PCIE_LINK 0x00000008 798c2ecf20Sopenharmony_ci#define INDIRECT_TYPE_BIG_ENDIAN 0x00000010 808c2ecf20Sopenharmony_ci#define INDIRECT_TYPE_BROKEN_MRM 0x00000020 818c2ecf20Sopenharmony_ci u32 indirect_type; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci /* Currently, we limit ourselves to 1 IO range and 3 mem 848c2ecf20Sopenharmony_ci * ranges since the common pci_bus structure can't handle more 858c2ecf20Sopenharmony_ci */ 868c2ecf20Sopenharmony_ci struct resource io_resource; 878c2ecf20Sopenharmony_ci struct resource mem_resources[3]; 888c2ecf20Sopenharmony_ci int global_number; /* PCI domain number */ 898c2ecf20Sopenharmony_ci}; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI 928c2ecf20Sopenharmony_cistatic inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus) 938c2ecf20Sopenharmony_ci{ 948c2ecf20Sopenharmony_ci return bus->sysdata; 958c2ecf20Sopenharmony_ci} 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistatic inline int isa_vaddr_is_ioport(void __iomem *address) 988c2ecf20Sopenharmony_ci{ 998c2ecf20Sopenharmony_ci /* No specific ISA handling on ppc32 at this stage, it 1008c2ecf20Sopenharmony_ci * all goes through PCI 1018c2ecf20Sopenharmony_ci */ 1028c2ecf20Sopenharmony_ci return 0; 1038c2ecf20Sopenharmony_ci} 1048c2ecf20Sopenharmony_ci#endif /* CONFIG_PCI */ 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/* These are used for config access before all the PCI probing 1078c2ecf20Sopenharmony_ci has been done. */ 1088c2ecf20Sopenharmony_ciextern int early_read_config_byte(struct pci_controller *hose, int bus, 1098c2ecf20Sopenharmony_ci int dev_fn, int where, u8 *val); 1108c2ecf20Sopenharmony_ciextern int early_read_config_word(struct pci_controller *hose, int bus, 1118c2ecf20Sopenharmony_ci int dev_fn, int where, u16 *val); 1128c2ecf20Sopenharmony_ciextern int early_read_config_dword(struct pci_controller *hose, int bus, 1138c2ecf20Sopenharmony_ci int dev_fn, int where, u32 *val); 1148c2ecf20Sopenharmony_ciextern int early_write_config_byte(struct pci_controller *hose, int bus, 1158c2ecf20Sopenharmony_ci int dev_fn, int where, u8 val); 1168c2ecf20Sopenharmony_ciextern int early_write_config_word(struct pci_controller *hose, int bus, 1178c2ecf20Sopenharmony_ci int dev_fn, int where, u16 val); 1188c2ecf20Sopenharmony_ciextern int early_write_config_dword(struct pci_controller *hose, int bus, 1198c2ecf20Sopenharmony_ci int dev_fn, int where, u32 val); 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ciextern int early_find_capability(struct pci_controller *hose, int bus, 1228c2ecf20Sopenharmony_ci int dev_fn, int cap); 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ciextern void setup_indirect_pci(struct pci_controller *hose, 1258c2ecf20Sopenharmony_ci resource_size_t cfg_addr, 1268c2ecf20Sopenharmony_ci resource_size_t cfg_data, u32 flags); 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci/* Get the PCI host controller for an OF device */ 1298c2ecf20Sopenharmony_ciextern struct pci_controller *pci_find_hose_for_OF_device( 1308c2ecf20Sopenharmony_ci struct device_node *node); 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci/* Fill up host controller resources from the OF node */ 1338c2ecf20Sopenharmony_ciextern void pci_process_bridge_OF_ranges(struct pci_controller *hose, 1348c2ecf20Sopenharmony_ci struct device_node *dev, int primary); 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci/* Allocate & free a PCI host bridge structure */ 1378c2ecf20Sopenharmony_ciextern struct pci_controller *pcibios_alloc_controller(struct device_node *dev); 1388c2ecf20Sopenharmony_ciextern void pcibios_free_controller(struct pci_controller *phb); 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 1418c2ecf20Sopenharmony_ci#endif /* _ASM_MICROBLAZE_PCI_BRIDGE_H */ 142