18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * c 2001 PPC 64 Team, IBM Corp
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_PPC_PCI_H
68c2ecf20Sopenharmony_ci#define _ASM_POWERPC_PPC_PCI_H
78c2ecf20Sopenharmony_ci#ifdef __KERNEL__
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/pci.h>
128c2ecf20Sopenharmony_ci#include <asm/pci-bridge.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciextern unsigned long isa_io_base;
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ciextern void pci_setup_phb_io(struct pci_controller *hose, int primary);
178c2ecf20Sopenharmony_ciextern void pci_setup_phb_io_dynamic(struct pci_controller *hose, int primary);
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciextern struct list_head hose_list;
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciextern struct pci_dev *isa_bridge_pcidev;	/* may be NULL if no ISA bus */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */
258c2ecf20Sopenharmony_ci#define BUID_HI(buid) upper_32_bits(buid)
268c2ecf20Sopenharmony_ci#define BUID_LO(buid) lower_32_bits(buid)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* PCI device_node operations */
298c2ecf20Sopenharmony_cistruct device_node;
308c2ecf20Sopenharmony_cistruct pci_dn;
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_civoid *pci_traverse_device_nodes(struct device_node *start,
338c2ecf20Sopenharmony_ci				void *(*fn)(struct device_node *, void *),
348c2ecf20Sopenharmony_ci				void *data);
358c2ecf20Sopenharmony_civoid *traverse_pci_dn(struct pci_dn *root,
368c2ecf20Sopenharmony_ci		      void *(*fn)(struct pci_dn *, void *),
378c2ecf20Sopenharmony_ci		      void *data);
388c2ecf20Sopenharmony_ciextern void pci_devs_phb_init_dynamic(struct pci_controller *phb);
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* From rtas_pci.h */
418c2ecf20Sopenharmony_ciextern void init_pci_config_tokens (void);
428c2ecf20Sopenharmony_ciextern unsigned long get_phb_buid (struct device_node *);
438c2ecf20Sopenharmony_ciextern int rtas_setup_phb(struct pci_controller *phb);
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#ifdef CONFIG_EEH
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_civoid eeh_addr_cache_insert_dev(struct pci_dev *dev);
488c2ecf20Sopenharmony_civoid eeh_addr_cache_rmv_dev(struct pci_dev *dev);
498c2ecf20Sopenharmony_cistruct eeh_dev *eeh_addr_cache_get_dev(unsigned long addr);
508c2ecf20Sopenharmony_civoid eeh_slot_error_detail(struct eeh_pe *pe, int severity);
518c2ecf20Sopenharmony_ciint eeh_pci_enable(struct eeh_pe *pe, int function);
528c2ecf20Sopenharmony_ciint eeh_pe_reset_full(struct eeh_pe *pe, bool include_passed);
538c2ecf20Sopenharmony_civoid eeh_save_bars(struct eeh_dev *edev);
548c2ecf20Sopenharmony_ciint rtas_write_config(struct pci_dn *, int where, int size, u32 val);
558c2ecf20Sopenharmony_ciint rtas_read_config(struct pci_dn *, int where, int size, u32 *val);
568c2ecf20Sopenharmony_civoid eeh_pe_state_mark(struct eeh_pe *pe, int state);
578c2ecf20Sopenharmony_civoid eeh_pe_mark_isolated(struct eeh_pe *pe);
588c2ecf20Sopenharmony_civoid eeh_pe_state_clear(struct eeh_pe *pe, int state, bool include_passed);
598c2ecf20Sopenharmony_civoid eeh_pe_state_mark_with_cfg(struct eeh_pe *pe, int state);
608c2ecf20Sopenharmony_civoid eeh_pe_dev_mode_mark(struct eeh_pe *pe, int mode);
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_civoid eeh_sysfs_add_device(struct pci_dev *pdev);
638c2ecf20Sopenharmony_civoid eeh_sysfs_remove_device(struct pci_dev *pdev);
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_cistatic inline const char *eeh_driver_name(struct pci_dev *pdev)
668c2ecf20Sopenharmony_ci{
678c2ecf20Sopenharmony_ci	return (pdev && pdev->driver) ? pdev->driver->name : "<null>";
688c2ecf20Sopenharmony_ci}
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci#endif /* CONFIG_EEH */
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#define PCI_BUSNO(bdfn) ((bdfn >> 8) & 0xff)
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#else /* CONFIG_PCI */
758c2ecf20Sopenharmony_cistatic inline void init_pci_config_tokens(void) { }
768c2ecf20Sopenharmony_ci#endif /* !CONFIG_PCI */
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */
798c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_PPC_PCI_H */
80