This source file includes following definitions.
- nanoengine_pci_map_bus
- pci_nanoengine_map_irq
- pci_nanoengine_setup_resources
- pci_nanoengine_setup
- nanoengine_pci_init
1
2
3
4
5
6
7
8
9 #include <linux/kernel.h>
10 #include <linux/irq.h>
11 #include <linux/pci.h>
12
13 #include <asm/mach/pci.h>
14 #include <asm/mach-types.h>
15
16 #include <mach/nanoengine.h>
17 #include <mach/hardware.h>
18
19 static void __iomem *nanoengine_pci_map_bus(struct pci_bus *bus,
20 unsigned int devfn, int where)
21 {
22 if (bus->number != 0 || (devfn >> 3) != 0)
23 return NULL;
24
25 return (void __iomem *)NANO_PCI_CONFIG_SPACE_VIRT +
26 ((bus->number << 16) | (devfn << 8) | (where & ~3));
27 }
28
29 static struct pci_ops pci_nano_ops = {
30 .map_bus = nanoengine_pci_map_bus,
31 .read = pci_generic_config_read32,
32 .write = pci_generic_config_write32,
33 };
34
35 static int __init pci_nanoengine_map_irq(const struct pci_dev *dev, u8 slot,
36 u8 pin)
37 {
38 return NANOENGINE_IRQ_GPIO_PCI;
39 }
40
41 static struct resource pci_io_ports =
42 DEFINE_RES_IO_NAMED(0x400, 0x400, "PCI IO");
43
44 static struct resource pci_non_prefetchable_memory = {
45 .name = "PCI non-prefetchable",
46 .start = NANO_PCI_MEM_RW_PHYS,
47
48
49 .end = NANO_PCI_MEM_RW_PHYS + NANO_PCI_MEM_RW_SIZE - 1,
50
51 .flags = IORESOURCE_MEM,
52 };
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 static struct resource pci_prefetchable_memory = {
123 .name = "PCI prefetchable",
124 .start = 0x78000000,
125 .end = 0x78000000 + NANO_PCI_MEM_RW_SIZE - 1,
126 .flags = IORESOURCE_MEM | IORESOURCE_PREFETCH,
127 };
128
129 static int __init pci_nanoengine_setup_resources(struct pci_sys_data *sys)
130 {
131 if (request_resource(&ioport_resource, &pci_io_ports)) {
132 printk(KERN_ERR "PCI: unable to allocate io port region\n");
133 return -EBUSY;
134 }
135 if (request_resource(&iomem_resource, &pci_non_prefetchable_memory)) {
136 release_resource(&pci_io_ports);
137 printk(KERN_ERR "PCI: unable to allocate non prefetchable\n");
138 return -EBUSY;
139 }
140 if (request_resource(&iomem_resource, &pci_prefetchable_memory)) {
141 release_resource(&pci_io_ports);
142 release_resource(&pci_non_prefetchable_memory);
143 printk(KERN_ERR "PCI: unable to allocate prefetchable\n");
144 return -EBUSY;
145 }
146 pci_add_resource_offset(&sys->resources, &pci_io_ports, sys->io_offset);
147 pci_add_resource_offset(&sys->resources,
148 &pci_non_prefetchable_memory, sys->mem_offset);
149 pci_add_resource_offset(&sys->resources,
150 &pci_prefetchable_memory, sys->mem_offset);
151
152 return 1;
153 }
154
155 int __init pci_nanoengine_setup(int nr, struct pci_sys_data *sys)
156 {
157 int ret = 0;
158
159 pcibios_min_io = 0;
160 pcibios_min_mem = 0;
161
162 if (nr == 0) {
163 sys->mem_offset = NANO_PCI_MEM_RW_PHYS;
164 sys->io_offset = 0x400;
165 ret = pci_nanoengine_setup_resources(sys);
166
167
168
169 GPDR = (GPDR & ~GPIO_MBREQ) | GPIO_MBGNT;
170 GAFR |= GPIO_MBGNT | GPIO_MBREQ;
171 TUCR |= TUCR_MBGPIO;
172 }
173
174 return ret;
175 }
176
177 static struct hw_pci nanoengine_pci __initdata = {
178 .map_irq = pci_nanoengine_map_irq,
179 .nr_controllers = 1,
180 .ops = &pci_nano_ops,
181 .setup = pci_nanoengine_setup,
182 };
183
184 static int __init nanoengine_pci_init(void)
185 {
186 if (machine_is_nanoengine())
187 pci_common_init(&nanoengine_pci);
188 return 0;
189 }
190
191 subsys_initcall(nanoengine_pci_init);