pci.c (ef407beefbd9928792ccc93857e408e0057bc17b) pci.c (b6c58b1d987a5795086c5c2babd8c7367d2fdb8c)
1/*
2 * New-style PCI core.
3 *
4 * Copyright (c) 2004 - 2009 Paul Mundt
5 * Copyright (c) 2002 M. R. Brown
6 *
7 * Modelled after arch/mips/pci/pci.c:
8 * Copyright (C) 2003, 04 Ralf Baechle (ralf@linux-mips.org)

--- 46 unchanged lines hidden (view full) ---

55 pci_enable_bridges(bus);
56 }
57}
58
59static DEFINE_MUTEX(pci_scan_mutex);
60
61int __devinit register_pci_controller(struct pci_channel *hose)
62{
1/*
2 * New-style PCI core.
3 *
4 * Copyright (c) 2004 - 2009 Paul Mundt
5 * Copyright (c) 2002 M. R. Brown
6 *
7 * Modelled after arch/mips/pci/pci.c:
8 * Copyright (C) 2003, 04 Ralf Baechle (ralf@linux-mips.org)

--- 46 unchanged lines hidden (view full) ---

55 pci_enable_bridges(bus);
56 }
57}
58
59static DEFINE_MUTEX(pci_scan_mutex);
60
61int __devinit register_pci_controller(struct pci_channel *hose)
62{
63 if (request_resource(&iomem_resource, hose->mem_resource) < 0)
64 goto out;
65 if (request_resource(&ioport_resource, hose->io_resource) < 0) {
66 release_resource(hose->mem_resource);
67 goto out;
63 int i;
64
65 for (i = 0; i < hose->nr_resources; i++) {
66 struct resource *res = hose->resources + i;
67
68 if (res->flags & IORESOURCE_IO) {
69 if (request_resource(&ioport_resource, res) < 0)
70 goto out;
71 } else {
72 if (request_resource(&iomem_resource, res) < 0)
73 goto out;
74 }
68 }
69
70 *hose_tail = hose;
71 hose_tail = &hose->next;
72
73 /*
74 * Do not panic here but later - this might hapen before console init.
75 */

--- 15 unchanged lines hidden (view full) ---

91 mutex_lock(&pci_scan_mutex);
92 pcibios_scanbus(hose);
93 mutex_unlock(&pci_scan_mutex);
94 }
95
96 return 0;
97
98out:
75 }
76
77 *hose_tail = hose;
78 hose_tail = &hose->next;
79
80 /*
81 * Do not panic here but later - this might hapen before console init.
82 */

--- 15 unchanged lines hidden (view full) ---

98 mutex_lock(&pci_scan_mutex);
99 pcibios_scanbus(hose);
100 mutex_unlock(&pci_scan_mutex);
101 }
102
103 return 0;
104
105out:
106 for (--i; i >= 0; i--)
107 release_resource(&hose->resources[i]);
108
99 printk(KERN_WARNING "Skipping PCI bus scan due to resource conflict\n");
100 return -1;
101}
102
103static int __init pcibios_init(void)
104{
105 struct pci_channel *hose;
106

--- 37 unchanged lines hidden (view full) ---

144/*
145 * Called after each bus is probed, but before its children
146 * are examined.
147 */
148void __devinit pcibios_fixup_bus(struct pci_bus *bus)
149{
150 struct pci_dev *dev = bus->self;
151 struct list_head *ln;
109 printk(KERN_WARNING "Skipping PCI bus scan due to resource conflict\n");
110 return -1;
111}
112
113static int __init pcibios_init(void)
114{
115 struct pci_channel *hose;
116

--- 37 unchanged lines hidden (view full) ---

154/*
155 * Called after each bus is probed, but before its children
156 * are examined.
157 */
158void __devinit pcibios_fixup_bus(struct pci_bus *bus)
159{
160 struct pci_dev *dev = bus->self;
161 struct list_head *ln;
152 struct pci_channel *chan = bus->sysdata;
162 struct pci_channel *hose = bus->sysdata;
153
154 if (!dev) {
163
164 if (!dev) {
155 bus->resource[0] = chan->io_resource;
156 bus->resource[1] = chan->mem_resource;
165 int i;
166
167 for (i = 0; i < hose->nr_resources; i++)
168 bus->resource[i] = hose->resources + i;
157 }
158
159 for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
160 dev = pci_dev_b(ln);
161
162 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
163 pcibios_fixup_device_resources(dev, bus);
164 }

--- 4 unchanged lines hidden (view full) ---

169 * and other strange ISA hardware, so we always want the
170 * addresses to be allocated in the 0x000-0x0ff region
171 * modulo 0x400.
172 */
173void pcibios_align_resource(void *data, struct resource *res,
174 resource_size_t size, resource_size_t align)
175{
176 struct pci_dev *dev = data;
169 }
170
171 for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
172 dev = pci_dev_b(ln);
173
174 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
175 pcibios_fixup_device_resources(dev, bus);
176 }

--- 4 unchanged lines hidden (view full) ---

181 * and other strange ISA hardware, so we always want the
182 * addresses to be allocated in the 0x000-0x0ff region
183 * modulo 0x400.
184 */
185void pcibios_align_resource(void *data, struct resource *res,
186 resource_size_t size, resource_size_t align)
187{
188 struct pci_dev *dev = data;
177 struct pci_channel *chan = dev->sysdata;
189 struct pci_channel *hose = dev->sysdata;
178 resource_size_t start = res->start;
179
180 if (res->flags & IORESOURCE_IO) {
190 resource_size_t start = res->start;
191
192 if (res->flags & IORESOURCE_IO) {
181 if (start < PCIBIOS_MIN_IO + chan->io_resource->start)
182 start = PCIBIOS_MIN_IO + chan->io_resource->start;
193 if (start < PCIBIOS_MIN_IO + hose->resources[0].start)
194 start = PCIBIOS_MIN_IO + hose->resources[0].start;
183
184 /*
185 * Put everything into 0x00-0xff region modulo 0x400.
186 */
187 if (start & 0x300)
188 start = (start + 0x3ff) & ~0x3ff;
195
196 /*
197 * Put everything into 0x00-0xff region modulo 0x400.
198 */
199 if (start & 0x300)
200 start = (start + 0x3ff) & ~0x3ff;
189 } else if (res->flags & IORESOURCE_MEM) {
190 if (start < PCIBIOS_MIN_MEM + chan->mem_resource->start)
191 start = PCIBIOS_MIN_MEM + chan->mem_resource->start;
192 }
193
194 res->start = start;
195}
196
197void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
198 struct resource *res)
199{

--- 220 unchanged lines hidden ---
201 }
202
203 res->start = start;
204}
205
206void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
207 struct resource *res)
208{

--- 220 unchanged lines hidden ---