blob: 83d340702680da5209a53a78166088cdac414a27 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Russell King4baa9922008-08-02 10:55:55 +01003 * arch/arm/include/asm/mach/pci.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 * Copyright (C) 2000 Russell King
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7
Anton Vorontsov52882172010-04-19 13:20:49 +01008#ifndef __ASM_MACH_PCI_H
9#define __ASM_MACH_PCI_H
10
Rob Herring3c5d1692012-07-09 21:59:03 -050011#include <linux/ioport.h>
Rob Herringc2794432012-02-29 18:10:58 -060012
Linus Torvalds1da177e2005-04-16 15:20:36 -070013struct pci_sys_data;
Russell Kingc23bfc32012-03-10 12:49:16 +000014struct pci_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070015struct pci_bus;
Lorenzo Pieralisi97ad2bd2017-06-28 15:13:55 -050016struct pci_host_bridge;
Linus Walleij14d86e72013-04-11 23:32:28 +020017struct device;
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
19struct hw_pci {
Yijing Wang49dcc012014-10-27 15:48:40 +080020 struct msi_controller *msi_ctrl;
Russell Kingc23bfc32012-03-10 12:49:16 +000021 struct pci_ops *ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 int nr_controllers;
Bjorn Helgaas1fa05102016-06-21 10:54:29 -050023 unsigned int io_optional:1;
Thierry Reding352af7d2013-02-11 08:46:10 +010024 void **private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 int (*setup)(int nr, struct pci_sys_data *);
Lorenzo Pieralisi97ad2bd2017-06-28 15:13:55 -050026 int (*scan)(int nr, struct pci_host_bridge *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 void (*preinit)(void);
28 void (*postinit)(void);
29 u8 (*swizzle)(struct pci_dev *dev, u8 *pin);
Ralf Baechled5341942011-06-10 15:30:21 +010030 int (*map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
Thomas Petazzoni029baf12013-03-26 18:14:24 +010031 resource_size_t (*align_resource)(struct pci_dev *dev,
32 const struct resource *res,
33 resource_size_t start,
34 resource_size_t size,
35 resource_size_t align);
Linus Torvalds1da177e2005-04-16 15:20:36 -070036};
37
38/*
39 * Per-controller structure
40 */
41struct pci_sys_data {
42 struct list_head node;
43 int busnr; /* primary bus number */
Greg Kroah-Hartmane31dd6e2006-06-12 17:06:02 -070044 u64 mem_offset; /* bus->cpu memory mapping offset */
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 unsigned long io_offset; /* bus->cpu IO mapping offset */
46 struct pci_bus *bus; /* PCI bus */
Bjorn Helgaas37d15902011-10-28 16:26:16 -060047 struct list_head resources; /* root bus resources (apertures) */
Rob Herring3c5d1692012-07-09 21:59:03 -050048 struct resource io_res;
49 char io_res_name[12];
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 /* Bridge swizzling */
51 u8 (*swizzle)(struct pci_dev *, u8 *);
52 /* IRQ mapping */
Ralf Baechled5341942011-06-10 15:30:21 +010053 int (*map_irq)(const struct pci_dev *, u8, u8);
Saeed Bishara35fe2fc2010-06-03 14:58:46 +030054 void *private_data; /* platform controller private data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070055};
56
57/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 * Call this with your hw_pci struct to initialise the PCI system.
59 */
Linus Walleij14d86e72013-04-11 23:32:28 +020060void pci_common_init_dev(struct device *, struct hw_pci *);
61
62/*
63 * Compatibility wrapper for older platforms that do not care about
64 * passing the parent device.
65 */
66static inline void pci_common_init(struct hw_pci *hw)
67{
68 pci_common_init_dev(NULL, hw);
69}
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71/*
Rob Herringc2794432012-02-29 18:10:58 -060072 * Setup early fixed I/O mapping.
73 */
74#if defined(CONFIG_PCI)
75extern void pci_map_io_early(unsigned long pfn);
76#else
77static inline void pci_map_io_early(unsigned long pfn) {}
78#endif
79
80/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 * PCI controllers
82 */
Russell Kingc23bfc32012-03-10 12:49:16 +000083extern struct pci_ops iop3xx_ops;
Lennert Buytenhek0cb015f2006-09-18 23:16:23 +010084extern int iop3xx_pci_setup(int nr, struct pci_sys_data *);
Lennert Buytenhek0cb015f2006-09-18 23:16:23 +010085extern void iop3xx_pci_preinit(void);
Dan Williamsc34002c2008-03-26 19:12:38 -070086extern void iop3xx_pci_preinit_cond(void);
Lennert Buytenhek0cb015f2006-09-18 23:16:23 +010087
Russell Kingc23bfc32012-03-10 12:49:16 +000088extern struct pci_ops dc21285_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089extern int dc21285_setup(int nr, struct pci_sys_data *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090extern void dc21285_preinit(void);
91extern void dc21285_postinit(void);
92
Anton Vorontsov52882172010-04-19 13:20:49 +010093#endif /* __ASM_MACH_PCI_H */