blob: 233b4b50eff3f1e52d1d45b75df9308f01398fd2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Russell King4baa9922008-08-02 10:55:55 +01002 * arch/arm/include/asm/mach/pci.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Copyright (C) 2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
Anton Vorontsov52882172010-04-19 13:20:49 +010011#ifndef __ASM_MACH_PCI_H
12#define __ASM_MACH_PCI_H
13
Rob Herring3c5d1692012-07-09 21:59:03 -050014#include <linux/ioport.h>
Rob Herringc2794432012-02-29 18:10:58 -060015
Linus Torvalds1da177e2005-04-16 15:20:36 -070016struct pci_sys_data;
Russell Kingc23bfc32012-03-10 12:49:16 +000017struct pci_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070018struct pci_bus;
Lorenzo Pieralisi97ad2bd2017-06-28 15:13:55 -050019struct pci_host_bridge;
Linus Walleij14d86e72013-04-11 23:32:28 +020020struct device;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
22struct hw_pci {
Yijing Wang49dcc012014-10-27 15:48:40 +080023 struct msi_controller *msi_ctrl;
Russell Kingc23bfc32012-03-10 12:49:16 +000024 struct pci_ops *ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 int nr_controllers;
Bjorn Helgaas1fa05102016-06-21 10:54:29 -050026 unsigned int io_optional:1;
Thierry Reding352af7d2013-02-11 08:46:10 +010027 void **private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 int (*setup)(int nr, struct pci_sys_data *);
Lorenzo Pieralisi97ad2bd2017-06-28 15:13:55 -050029 int (*scan)(int nr, struct pci_host_bridge *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 void (*preinit)(void);
31 void (*postinit)(void);
32 u8 (*swizzle)(struct pci_dev *dev, u8 *pin);
Ralf Baechled5341942011-06-10 15:30:21 +010033 int (*map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
Thomas Petazzoni029baf12013-03-26 18:14:24 +010034 resource_size_t (*align_resource)(struct pci_dev *dev,
35 const struct resource *res,
36 resource_size_t start,
37 resource_size_t size,
38 resource_size_t align);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039};
40
41/*
42 * Per-controller structure
43 */
44struct pci_sys_data {
45 struct list_head node;
46 int busnr; /* primary bus number */
Greg Kroah-Hartmane31dd6e2006-06-12 17:06:02 -070047 u64 mem_offset; /* bus->cpu memory mapping offset */
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 unsigned long io_offset; /* bus->cpu IO mapping offset */
49 struct pci_bus *bus; /* PCI bus */
Bjorn Helgaas37d15902011-10-28 16:26:16 -060050 struct list_head resources; /* root bus resources (apertures) */
Rob Herring3c5d1692012-07-09 21:59:03 -050051 struct resource io_res;
52 char io_res_name[12];
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 /* Bridge swizzling */
54 u8 (*swizzle)(struct pci_dev *, u8 *);
55 /* IRQ mapping */
Ralf Baechled5341942011-06-10 15:30:21 +010056 int (*map_irq)(const struct pci_dev *, u8, u8);
Saeed Bishara35fe2fc2010-06-03 14:58:46 +030057 void *private_data; /* platform controller private data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070058};
59
60/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 * Call this with your hw_pci struct to initialise the PCI system.
62 */
Linus Walleij14d86e72013-04-11 23:32:28 +020063void pci_common_init_dev(struct device *, struct hw_pci *);
64
65/*
66 * Compatibility wrapper for older platforms that do not care about
67 * passing the parent device.
68 */
69static inline void pci_common_init(struct hw_pci *hw)
70{
71 pci_common_init_dev(NULL, hw);
72}
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74/*
Rob Herringc2794432012-02-29 18:10:58 -060075 * Setup early fixed I/O mapping.
76 */
77#if defined(CONFIG_PCI)
78extern void pci_map_io_early(unsigned long pfn);
79#else
80static inline void pci_map_io_early(unsigned long pfn) {}
81#endif
82
83/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 * PCI controllers
85 */
Russell Kingc23bfc32012-03-10 12:49:16 +000086extern struct pci_ops iop3xx_ops;
Lennert Buytenhek0cb015f2006-09-18 23:16:23 +010087extern int iop3xx_pci_setup(int nr, struct pci_sys_data *);
Lennert Buytenhek0cb015f2006-09-18 23:16:23 +010088extern void iop3xx_pci_preinit(void);
Dan Williamsc34002c2008-03-26 19:12:38 -070089extern void iop3xx_pci_preinit_cond(void);
Lennert Buytenhek0cb015f2006-09-18 23:16:23 +010090
Russell Kingc23bfc32012-03-10 12:49:16 +000091extern struct pci_ops dc21285_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092extern int dc21285_setup(int nr, struct pci_sys_data *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093extern void dc21285_preinit(void);
94extern void dc21285_postinit(void);
95
Anton Vorontsov52882172010-04-19 13:20:49 +010096#endif /* __ASM_MACH_PCI_H */