11 #include <linux/export.h>
12 #include <linux/kernel.h>
13 #include <linux/string.h>
14 #include <linux/sched.h>
15 #include <linux/capability.h>
16 #include <linux/errno.h>
17 #include <linux/pci.h>
24 #include <asm/uaccess.h>
25 #include <asm/pgtable.h>
53 __asm__ __volatile__(
"membar #Sync\n\t"
54 "lduba [%1] %2, %0\n\t"
63 spin_unlock_irqrestore(&pci_poke_lock, flags);
75 __asm__ __volatile__(
"membar #Sync\n\t"
76 "lduha [%1] %2, %0\n\t"
85 spin_unlock_irqrestore(&pci_poke_lock, flags);
97 __asm__ __volatile__(
"membar #Sync\n\t"
98 "lduwa [%1] %2, %0\n\t"
107 spin_unlock_irqrestore(&pci_poke_lock, flags);
118 __asm__ __volatile__(
"membar #Sync\n\t"
119 "stba %0, [%1] %2\n\t"
126 spin_unlock_irqrestore(&pci_poke_lock, flags);
137 __asm__ __volatile__(
"membar #Sync\n\t"
138 "stha %0, [%1] %2\n\t"
145 spin_unlock_irqrestore(&pci_poke_lock, flags);
156 __asm__ __volatile__(
"membar #Sync\n\t"
157 "stwa %0, [%1] %2\n\t"
164 spin_unlock_irqrestore(&pci_poke_lock, flags);
167 static int ofpci_verbose;
179 __setup(
"ofpci_debug=", ofpci_debug);
183 unsigned long flags = 0;
185 if (addr0 & 0x02000000) {
189 if (addr0 & 0x40000000)
192 }
else if (addr0 & 0x01000000)
213 printk(
" parse addresses (%d bytes) @ %p\n",
216 for (; proplen >= 20; proplen -= 20, addrs += 5, op_res++) {
226 printk(
" start: %llx, end: %llx, i: %x\n",
242 res->
name = pci_name(dev);
261 sd = &dev->
dev.archdata;
268 sd = &op->
dev.archdata;
281 printk(
" create device, devfn: %x, type: %s\n",
288 dev->
dev.of_node = of_node_get(node);
313 dev->class = class >> 8;
321 dev->class, pci_name(dev));
338 }
else if (!
strcmp(type,
"cardbus")) {
344 dev->
irq = sd->
op->archdata.irqs[0];
345 if (dev->
irq == 0xffffffff)
346 dev->
irq = PCI_IRQ_NONE;
349 pci_parse_of_addrs(sd->
op, node, dev);
352 printk(
" adding to system ...\n");
365 for (idx = 0; idx < 8; idx++) {
366 if ((map & (1 << idx)) != 0) {
391 apb_calc_first_last(map, &first, &last);
394 region.start = (first << 21);
395 region.end = (last << 21) + ((1 << 21) - 1);
399 apb_calc_first_last(map, &first, &last);
402 region.start = (first << 21);
403 region.end = (last << 21) + ((1 << 21) - 1);
411 #define GET_64BIT(prop, i) ((((u64) (prop)[(i)]) << 32) | (prop)[(i)+1])
418 const u32 *busrange, *ranges;
430 if (busrange ==
NULL || len != 8) {
437 if (ranges ==
NULL) {
439 if (model && !
strcmp(model,
"SUNW,simba"))
463 apb_fake_ranges(dev, bus, pbm);
465 }
else if (ranges ==
NULL) {
470 for (; len >= 32; len -= 32, ranges += 8) {
473 if (flags == 0 || size == 0)
494 region.
end = region.
start + size - 1;
503 pci_of_scan_bus(pbm, node, bus);
512 int reglen,
devfn, prev_devfn;
516 printk(
"PCI: scan_bus[%s] bus no %d\n",
525 if (reg ==
NULL || reglen < 20)
528 devfn = (reg[0] >> 8) & 0xff;
535 if (devfn == prev_devfn)
544 printk(
"PCI: dev header type: %x\n",
560 dp = pdev->
dev.of_node;
585 pci_bus_register_of_sysfs(child_bus);
598 pbm->io_space.start);
600 pbm->mem_space.start);
601 pbm->busn.start = pbm->pci_first_busno;
602 pbm->busn.end = pbm->pci_last_busno;
614 pci_of_scan_bus(pbm, node, bus);
616 pci_bus_register_of_sysfs(bus);
643 if (!(mask & (1<<i)))
674 unsigned long space_size, user_offset, user_size;
677 space_size = resource_size(&pbm->
io_space);
679 space_size = resource_size(&pbm->
mem_space);
686 if (user_offset >= space_size ||
687 (user_offset + user_size) > space_size)
711 static int __pci_mmap_make_offset(
struct pci_dev *pdev,
715 unsigned long user_paddr, user_size;
722 err = __pci_mmap_make_offset_bus(pdev, vma, mmap_state);
765 if ((rp->
start <= user_paddr) &&
766 (user_paddr + user_size) <= aligned_end)
782 vma->
vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
808 ret = __pci_mmap_make_offset(dev, vma, mmap_state);
812 __pci_mmap_set_flags(dev, vma, mmap_state);
813 __pci_mmap_set_pgprot(dev, vma, mmap_state);
853 #ifdef CONFIG_PCI_MSI
859 if (!pbm->setup_msi_irq)
862 return pbm->setup_msi_irq(&irq, pdev, desc);
871 if (pbm->teardown_msi_irq)
872 pbm->teardown_msi_irq(irq, pdev);
878 struct pci_dev *ali_isa_bridge;
888 pci_read_config_byte(ali_isa_bridge, 0x7e, &val);
893 pci_write_config_byte(ali_isa_bridge, 0x7e, val);
902 dma_addr_mask = 0xffffffff;
910 device_mask == 0x7fffffff) {
911 ali_sound_dma_hack(pdev,
912 (dma_addr_mask & 0x80000000) != 0);
917 if (device_mask >= (1
UL << 32
UL))
955 const struct pci_slot_names {
967 mask = prop->slot_mask;
971 printk(
"PCI: Making slots for [%s] mask[0x%02x]\n",
977 u32 this_bit = 1 <<
i;
979 if (!(mask & this_bit)) {
985 printk(
"PCI: Making slot [%s]\n", sp);
988 if (IS_ERR(pci_slot))
998 static int __init of_pci_slot_init(
void)
1007 node = pbus->
self->dev.of_node;
1012 node = pbm->
op->dev.of_node;
1015 pci_bus_slot_names(node, pbus);