1d5dcfe133a28b12d093a403a10228af5d167e4d
[powerpc.git] / include / asm-sparc64 / pbm.h
1 /* pbm.h: UltraSparc PCI controller software state.
2  *
3  * Copyright (C) 1997, 1998, 1999, 2007 David S. Miller (davem@davemloft.net)
4  */
5
6 #ifndef __SPARC64_PBM_H
7 #define __SPARC64_PBM_H
8
9 #include <linux/types.h>
10 #include <linux/pci.h>
11 #include <linux/ioport.h>
12 #include <linux/spinlock.h>
13 #include <linux/msi.h>
14
15 #include <asm/io.h>
16 #include <asm/page.h>
17 #include <asm/oplib.h>
18 #include <asm/prom.h>
19 #include <asm/of_device.h>
20 #include <asm/iommu.h>
21
22 /* The abstraction used here is that there are PCI controllers,
23  * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules
24  * underneath.  Each PCI bus module uses an IOMMU (shared by both
25  * PBMs of a controller, or per-PBM), and if a streaming buffer
26  * is present, each PCI bus module has it's own. (ie. the IOMMU
27  * might be shared between PBMs, the STC is never shared)
28  * Furthermore, each PCI bus module controls it's own autonomous
29  * PCI bus.
30  */
31
32 extern void pci_iommu_table_init(struct iommu *iommu, int tsbsize, u32 dma_offset, u32 dma_addr_mask);
33
34 #define PCI_STC_FLUSHFLAG_INIT(STC) \
35         (*((STC)->strbuf_flushflag) = 0UL)
36 #define PCI_STC_FLUSHFLAG_SET(STC) \
37         (*((STC)->strbuf_flushflag) != 0UL)
38
39 struct pci_controller_info;
40
41 struct pci_pbm_info {
42         struct pci_pbm_info             *next;
43
44         /* PCI controller we sit under. */
45         struct pci_controller_info      *parent;
46
47         /* Physical address base of controller registers. */
48         unsigned long                   controller_regs;
49
50         /* Physical address base of PBM registers. */
51         unsigned long                   pbm_regs;
52
53         /* Physical address of DMA sync register, if any.  */
54         unsigned long                   sync_reg;
55
56         /* Opaque 32-bit system bus Port ID. */
57         u32                             portid;
58
59         /* Opaque 32-bit handle used for hypervisor calls.  */
60         u32                             devhandle;
61
62         /* Chipset version information. */
63         int                             chip_type;
64 #define PBM_CHIP_TYPE_SABRE             1
65 #define PBM_CHIP_TYPE_PSYCHO            2
66 #define PBM_CHIP_TYPE_SCHIZO            3
67 #define PBM_CHIP_TYPE_SCHIZO_PLUS       4
68 #define PBM_CHIP_TYPE_TOMATILLO         5
69         int                             chip_version;
70         int                             chip_revision;
71
72         /* Name used for top-level resources. */
73         char                            *name;
74
75         /* OBP specific information. */
76         struct device_node              *prom_node;
77         u64                             ino_bitmap;
78
79         /* PBM I/O and Memory space resources. */
80         struct resource                 io_space;
81         struct resource                 mem_space;
82
83         /* Base of PCI Config space, can be per-PBM or shared. */
84         unsigned long                   config_space;
85
86         /* State of 66MHz capabilities on this PBM. */
87         int                             is_66mhz_capable;
88         int                             all_devs_66mhz;
89
90 #ifdef CONFIG_PCI_MSI
91         /* MSI info.  */
92         u32                             msiq_num;
93         u32                             msiq_ent_count;
94         u32                             msiq_first;
95         u32                             msiq_first_devino;
96         u32                             msi_num;
97         u32                             msi_first;
98         u32                             msi_data_mask;
99         u32                             msix_data_width;
100         u64                             msi32_start;
101         u64                             msi64_start;
102         u32                             msi32_len;
103         u32                             msi64_len;
104         void                            *msi_queues;
105         unsigned long                   *msi_bitmap;
106         int (*setup_msi_irq)(unsigned int *virt_irq_p, struct pci_dev *pdev,
107                              struct msi_desc *entry);
108         void (*teardown_msi_irq)(unsigned int virt_irq, struct pci_dev *pdev);
109 #endif /* !(CONFIG_PCI_MSI) */
110
111         /* This PBM's streaming buffer. */
112         struct strbuf                   stc;
113
114         /* IOMMU state, potentially shared by both PBM segments. */
115         struct iommu                    *iommu;
116
117         /* Now things for the actual PCI bus probes. */
118         unsigned int                    pci_first_busno;
119         unsigned int                    pci_last_busno;
120         struct pci_bus                  *pci_bus;
121         void (*scan_bus)(struct pci_pbm_info *);
122         struct pci_ops                  *pci_ops;
123 };
124
125 struct pci_controller_info {
126         /* Each controller gets a unique index, used mostly for
127          * error logging purposes.
128          */
129         int                             index;
130
131         /* The PCI bus modules controlled by us. */
132         struct pci_pbm_info             pbm_A;
133         struct pci_pbm_info             pbm_B;
134 };
135
136 #endif /* !(__SPARC64_PBM_H) */