xref: /openbmc/linux/arch/s390/pci/pci_bus.h (revision ab909509)
105bc1be6SPierre Morel /* SPDX-License-Identifier: GPL-2.0 */
205bc1be6SPierre Morel /*
305bc1be6SPierre Morel  * Copyright IBM Corp. 2020
405bc1be6SPierre Morel  *
505bc1be6SPierre Morel  * Author(s):
605bc1be6SPierre Morel  *   Pierre Morel <pmorel@linux.ibm.com>
705bc1be6SPierre Morel  *
805bc1be6SPierre Morel  */
905bc1be6SPierre Morel 
1005bc1be6SPierre Morel int zpci_bus_device_register(struct zpci_dev *zdev, struct pci_ops *ops);
1105bc1be6SPierre Morel void zpci_bus_device_unregister(struct zpci_dev *zdev);
1205bc1be6SPierre Morel 
13a50297cfSNiklas Schnelle int zpci_bus_scan_bus(struct zpci_bus *zbus);
1414c87ba8SNiklas Schnelle void zpci_bus_scan_busses(void);
15a50297cfSNiklas Schnelle 
16faf29a4dSNiklas Schnelle int zpci_bus_scan_device(struct zpci_dev *zdev);
1795b3a8b4SNiklas Schnelle void zpci_bus_remove_device(struct zpci_dev *zdev, bool set_error);
1895b3a8b4SNiklas Schnelle 
1905bc1be6SPierre Morel void zpci_release_device(struct kref *kref);
zpci_zdev_put(struct zpci_dev * zdev)2005bc1be6SPierre Morel static inline void zpci_zdev_put(struct zpci_dev *zdev)
2105bc1be6SPierre Morel {
22c122383dSNiklas Schnelle 	if (zdev)
2305bc1be6SPierre Morel 		kref_put(&zdev->kref, zpci_release_device);
2405bc1be6SPierre Morel }
2505bc1be6SPierre Morel 
zpci_zdev_get(struct zpci_dev * zdev)262a671f77SNiklas Schnelle static inline void zpci_zdev_get(struct zpci_dev *zdev)
272a671f77SNiklas Schnelle {
282a671f77SNiklas Schnelle 	kref_get(&zdev->kref);
292a671f77SNiklas Schnelle }
302a671f77SNiklas Schnelle 
3105bc1be6SPierre Morel int zpci_alloc_domain(int domain);
3205bc1be6SPierre Morel void zpci_free_domain(int domain);
33*ab909509SNiklas Schnelle int zpci_setup_bus_resources(struct zpci_dev *zdev);
3405bc1be6SPierre Morel 
zdev_from_bus(struct pci_bus * bus,unsigned int devfn)357dcfe50fSNiklas Schnelle static inline struct zpci_dev *zdev_from_bus(struct pci_bus *bus,
3644510d6fSPierre Morel 					     unsigned int devfn)
3705bc1be6SPierre Morel {
3805bc1be6SPierre Morel 	struct zpci_bus *zbus = bus->sysdata;
3905bc1be6SPierre Morel 
4044510d6fSPierre Morel 	return (devfn >= ZPCI_FUNCTIONS_PER_BUS) ? NULL : zbus->function[devfn];
4105bc1be6SPierre Morel }
42b97bf44fSNiklas Schnelle 
43