blob: 8144d61e5693e7ca96d4272e0b21909d0a99a705 [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;
Linus Walleij14d86e72013-04-11 23:32:28 +020019struct device;
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21struct hw_pci {
Anton Vorontsov52882172010-04-19 13:20:49 +010022#ifdef CONFIG_PCI_DOMAINS
23 int domain;
24#endif
Yijing Wang49dcc012014-10-27 15:48:40 +080025#ifdef CONFIG_PCI_MSI
26 struct msi_controller *msi_ctrl;
27#endif
Russell Kingc23bfc32012-03-10 12:49:16 +000028 struct pci_ops *ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 int nr_controllers;
Thierry Reding352af7d2013-02-11 08:46:10 +010030 void **private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 int (*setup)(int nr, struct pci_sys_data *);
32 struct pci_bus *(*scan)(int nr, struct pci_sys_data *);
33 void (*preinit)(void);
34 void (*postinit)(void);
35 u8 (*swizzle)(struct pci_dev *dev, u8 *pin);
Ralf Baechled5341942011-06-10 15:30:21 +010036 int (*map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
Thomas Petazzoni029baf12013-03-26 18:14:24 +010037 resource_size_t (*align_resource)(struct pci_dev *dev,
38 const struct resource *res,
39 resource_size_t start,
40 resource_size_t size,
41 resource_size_t align);
Thomas Petazzoni9d981ea2013-08-09 22:27:12 +020042 void (*add_bus)(struct pci_bus *bus);
43 void (*remove_bus)(struct pci_bus *bus);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044};
45
46/*
47 * Per-controller structure
48 */
49struct pci_sys_data {
Anton Vorontsov52882172010-04-19 13:20:49 +010050#ifdef CONFIG_PCI_DOMAINS
51 int domain;
52#endif
Yijing Wang49dcc012014-10-27 15:48:40 +080053#ifdef CONFIG_PCI_MSI
54 struct msi_controller *msi_ctrl;
55#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 struct list_head node;
57 int busnr; /* primary bus number */
Greg Kroah-Hartmane31dd6e2006-06-12 17:06:02 -070058 u64 mem_offset; /* bus->cpu memory mapping offset */
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 unsigned long io_offset; /* bus->cpu IO mapping offset */
60 struct pci_bus *bus; /* PCI bus */
Bjorn Helgaas37d15902011-10-28 16:26:16 -060061 struct list_head resources; /* root bus resources (apertures) */
Rob Herring3c5d1692012-07-09 21:59:03 -050062 struct resource io_res;
63 char io_res_name[12];
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 /* Bridge swizzling */
65 u8 (*swizzle)(struct pci_dev *, u8 *);
66 /* IRQ mapping */
Ralf Baechled5341942011-06-10 15:30:21 +010067 int (*map_irq)(const struct pci_dev *, u8, u8);
Thomas Petazzoni029baf12013-03-26 18:14:24 +010068 /* Resource alignement requirements */
69 resource_size_t (*align_resource)(struct pci_dev *dev,
70 const struct resource *res,
71 resource_size_t start,
72 resource_size_t size,
73 resource_size_t align);
Thomas Petazzoni9d981ea2013-08-09 22:27:12 +020074 void (*add_bus)(struct pci_bus *bus);
75 void (*remove_bus)(struct pci_bus *bus);
Saeed Bishara35fe2fc2010-06-03 14:58:46 +030076 void *private_data; /* platform controller private data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070077};
78
79/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 * Call this with your hw_pci struct to initialise the PCI system.
81 */
Linus Walleij14d86e72013-04-11 23:32:28 +020082void pci_common_init_dev(struct device *, struct hw_pci *);
83
84/*
85 * Compatibility wrapper for older platforms that do not care about
86 * passing the parent device.
87 */
88static inline void pci_common_init(struct hw_pci *hw)
89{
90 pci_common_init_dev(NULL, hw);
91}
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93/*
Rob Herringc2794432012-02-29 18:10:58 -060094 * Setup early fixed I/O mapping.
95 */
96#if defined(CONFIG_PCI)
97extern void pci_map_io_early(unsigned long pfn);
98#else
99static inline void pci_map_io_early(unsigned long pfn) {}
100#endif
101
102/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 * PCI controllers
104 */
Russell Kingc23bfc32012-03-10 12:49:16 +0000105extern struct pci_ops iop3xx_ops;
Lennert Buytenhek0cb015f2006-09-18 23:16:23 +0100106extern int iop3xx_pci_setup(int nr, struct pci_sys_data *);
Lennert Buytenhek0cb015f2006-09-18 23:16:23 +0100107extern void iop3xx_pci_preinit(void);
Dan Williamsc34002c2008-03-26 19:12:38 -0700108extern void iop3xx_pci_preinit_cond(void);
Lennert Buytenhek0cb015f2006-09-18 23:16:23 +0100109
Russell Kingc23bfc32012-03-10 12:49:16 +0000110extern struct pci_ops dc21285_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111extern int dc21285_setup(int nr, struct pci_sys_data *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112extern void dc21285_preinit(void);
113extern void dc21285_postinit(void);
114
Anton Vorontsov52882172010-04-19 13:20:49 +0100115#endif /* __ASM_MACH_PCI_H */