pci_64.c (3da27289a8ecc688fc62c0961dfe89d392370480) pci_64.c (6e99e4582861578fb00d84d085f8f283569f51dd)
1/*
2 * Port for PPC64 David Engebretsen, IBM Corp.
3 * Contains common pci routines for ppc64 platform, pSeries and iSeries brands.
4 *
5 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
6 * Rework, based on alpha PCI code.
7 *
8 * This program is free software; you can redistribute it and/or

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

16#include <linux/kernel.h>
17#include <linux/pci.h>
18#include <linux/string.h>
19#include <linux/init.h>
20#include <linux/bootmem.h>
21#include <linux/mm.h>
22#include <linux/list.h>
23#include <linux/syscalls.h>
1/*
2 * Port for PPC64 David Engebretsen, IBM Corp.
3 * Contains common pci routines for ppc64 platform, pSeries and iSeries brands.
4 *
5 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
6 * Rework, based on alpha PCI code.
7 *
8 * This program is free software; you can redistribute it and/or

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

16#include <linux/kernel.h>
17#include <linux/pci.h>
18#include <linux/string.h>
19#include <linux/init.h>
20#include <linux/bootmem.h>
21#include <linux/mm.h>
22#include <linux/list.h>
23#include <linux/syscalls.h>
24#include <linux/irq.h>
24
25#include <asm/processor.h>
26#include <asm/io.h>
27#include <asm/prom.h>
28#include <asm/pci-bridge.h>
29#include <asm/byteorder.h>
25
26#include <asm/processor.h>
27#include <asm/io.h>
28#include <asm/prom.h>
29#include <asm/pci-bridge.h>
30#include <asm/byteorder.h>
30#include <asm/irq.h>
31#include <asm/machdep.h>
32#include <asm/ppc-pci.h>
33
34#ifdef DEBUG
35#include <asm/udbg.h>
36#define DBG(fmt...) printk(fmt)
37#else
38#define DBG(fmt...)

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

180 memset(hose, 0, sizeof(struct pci_controller));
181
182 spin_lock(&hose_spinlock);
183 hose->global_number = global_phb_number++;
184 list_add_tail(&hose->list_node, &hose_list);
185 spin_unlock(&hose_spinlock);
186}
187
31#include <asm/machdep.h>
32#include <asm/ppc-pci.h>
33
34#ifdef DEBUG
35#include <asm/udbg.h>
36#define DBG(fmt...) printk(fmt)
37#else
38#define DBG(fmt...)

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

180 memset(hose, 0, sizeof(struct pci_controller));
181
182 spin_lock(&hose_spinlock);
183 hose->global_number = global_phb_number++;
184 list_add_tail(&hose->list_node, &hose_list);
185 spin_unlock(&hose_spinlock);
186}
187
188static void add_linux_pci_domain(struct device_node *dev,
189 struct pci_controller *phb)
190{
191 struct property *of_prop;
192 unsigned int size;
193
194 of_prop = (struct property *)
195 get_property(dev, "linux,pci-domain", &size);
196 if (of_prop != NULL)
197 return;
198 WARN_ON(of_prop && size < sizeof(int));
199 if (of_prop && size < sizeof(int))
200 of_prop = NULL;
201 size = sizeof(struct property) + sizeof(int);
202 if (of_prop == NULL) {
203 if (mem_init_done)
204 of_prop = kmalloc(size, GFP_KERNEL);
205 else
206 of_prop = alloc_bootmem(size);
207 }
208 memset(of_prop, 0, sizeof(struct property));
209 of_prop->name = "linux,pci-domain";
210 of_prop->length = sizeof(int);
211 of_prop->value = (unsigned char *)&of_prop[1];
212 *((int *)of_prop->value) = phb->global_number;
213 prom_add_property(dev, of_prop);
214}
215
188struct pci_controller * pcibios_alloc_controller(struct device_node *dev)
189{
190 struct pci_controller *phb;
191
192 if (mem_init_done)
193 phb = kmalloc(sizeof(struct pci_controller), GFP_KERNEL);
194 else
195 phb = alloc_bootmem(sizeof (struct pci_controller));
196 if (phb == NULL)
197 return NULL;
198 pci_setup_pci_controller(phb);
199 phb->arch_data = dev;
200 phb->is_dynamic = mem_init_done;
216struct pci_controller * pcibios_alloc_controller(struct device_node *dev)
217{
218 struct pci_controller *phb;
219
220 if (mem_init_done)
221 phb = kmalloc(sizeof(struct pci_controller), GFP_KERNEL);
222 else
223 phb = alloc_bootmem(sizeof (struct pci_controller));
224 if (phb == NULL)
225 return NULL;
226 pci_setup_pci_controller(phb);
227 phb->arch_data = dev;
228 phb->is_dynamic = mem_init_done;
201 if (dev)
229 if (dev) {
202 PHB_SET_NODE(phb, of_node_to_nid(dev));
230 PHB_SET_NODE(phb, of_node_to_nid(dev));
231 add_linux_pci_domain(dev, phb);
232 }
203 return phb;
204}
205
206void pcibios_free_controller(struct pci_controller *phb)
207{
233 return phb;
234}
235
236void pcibios_free_controller(struct pci_controller *phb)
237{
238 if (phb->arch_data) {
239 struct device_node *np = phb->arch_data;
240 int *domain = (int *)get_property(np,
241 "linux,pci-domain", NULL);
242 if (domain)
243 *domain = -1;
244 }
208 if (phb->is_dynamic)
209 kfree(phb);
210}
211
212#ifndef CONFIG_PPC_ISERIES
213void __devinit pcibios_claim_one_bus(struct pci_bus *b)
214{
215 struct pci_dev *dev;

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

1247 */
1248int pci_read_irq_line(struct pci_dev *pci_dev)
1249{
1250 struct of_irq oirq;
1251 unsigned int virq;
1252
1253 DBG("Try to map irq for %s...\n", pci_name(pci_dev));
1254
245 if (phb->is_dynamic)
246 kfree(phb);
247}
248
249#ifndef CONFIG_PPC_ISERIES
250void __devinit pcibios_claim_one_bus(struct pci_bus *b)
251{
252 struct pci_dev *dev;

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

1284 */
1285int pci_read_irq_line(struct pci_dev *pci_dev)
1286{
1287 struct of_irq oirq;
1288 unsigned int virq;
1289
1290 DBG("Try to map irq for %s...\n", pci_name(pci_dev));
1291
1292 /* Try to get a mapping from the device-tree */
1255 if (of_irq_map_pci(pci_dev, &oirq)) {
1293 if (of_irq_map_pci(pci_dev, &oirq)) {
1256 DBG(" -> failed !\n");
1257 return -1;
1258 }
1294 u8 line, pin;
1259
1295
1260 DBG(" -> got one, spec %d cells (0x%08x...) on %s\n",
1261 oirq.size, oirq.specifier[0], oirq.controller->full_name);
1296 /* If that fails, lets fallback to what is in the config
1297 * space and map that through the default controller. We
1298 * also set the type to level low since that's what PCI
1299 * interrupts are. If your platform does differently, then
1300 * either provide a proper interrupt tree or don't use this
1301 * function.
1302 */
1303 if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_PIN, &pin))
1304 return -1;
1305 if (pin == 0)
1306 return -1;
1307 if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &line) ||
1308 line == 0xff) {
1309 return -1;
1310 }
1311 DBG(" -> no map ! Using irq line %d from PCI config\n", line);
1262
1312
1263 virq = irq_create_of_mapping(oirq.controller, oirq.specifier, oirq.size);
1313 virq = irq_create_mapping(NULL, line);
1314 if (virq != NO_IRQ)
1315 set_irq_type(virq, IRQ_TYPE_LEVEL_LOW);
1316 } else {
1317 DBG(" -> got one, spec %d cells (0x%08x...) on %s\n",
1318 oirq.size, oirq.specifier[0], oirq.controller->full_name);
1319
1320 virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
1321 oirq.size);
1322 }
1264 if(virq == NO_IRQ) {
1265 DBG(" -> failed to map !\n");
1266 return -1;
1267 }
1268 pci_dev->irq = virq;
1269 pci_write_config_byte(pci_dev, PCI_INTERRUPT_LINE, virq);
1270
1271 return 0;

--- 117 unchanged lines hidden ---
1323 if(virq == NO_IRQ) {
1324 DBG(" -> failed to map !\n");
1325 return -1;
1326 }
1327 pci_dev->irq = virq;
1328 pci_write_config_byte(pci_dev, PCI_INTERRUPT_LINE, virq);
1329
1330 return 0;

--- 117 unchanged lines hidden ---