aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/Makefile4
-rw-r--r--arch/powerpc/kernel/dma.c69
-rw-r--r--arch/powerpc/kernel/pci-common.c48
-rw-r--r--arch/powerpc/kernel/pci_32.c7
-rw-r--r--arch/powerpc/kernel/pci_64.c46
5 files changed, 103 insertions, 71 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 09b3cabf2f91..fdb58253fa5b 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -70,10 +70,10 @@ extra-$(CONFIG_8xx) := head_8xx.o
70extra-y += vmlinux.lds 70extra-y += vmlinux.lds
71 71
72obj-y += time.o prom.o traps.o setup-common.o \ 72obj-y += time.o prom.o traps.o setup-common.o \
73 udbg.o misc.o io.o \ 73 udbg.o misc.o io.o dma.o \
74 misc_$(CONFIG_WORD_SIZE).o 74 misc_$(CONFIG_WORD_SIZE).o
75obj-$(CONFIG_PPC32) += entry_32.o setup_32.o 75obj-$(CONFIG_PPC32) += entry_32.o setup_32.o
76obj-$(CONFIG_PPC64) += dma.o dma-iommu.o iommu.o 76obj-$(CONFIG_PPC64) += dma-iommu.o iommu.o
77obj-$(CONFIG_KGDB) += kgdb.o 77obj-$(CONFIG_KGDB) += kgdb.o
78obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o 78obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o
79obj-$(CONFIG_MODULES) += ppc_ksyms.o 79obj-$(CONFIG_MODULES) += ppc_ksyms.o
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 124f86743bde..41fdd48bf433 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -16,21 +16,30 @@
16 * This implementation supports a per-device offset that can be applied if 16 * This implementation supports a per-device offset that can be applied if
17 * the address at which memory is visible to devices is not 0. Platform code 17 * the address at which memory is visible to devices is not 0. Platform code
18 * can set archdata.dma_data to an unsigned long holding the offset. By 18 * can set archdata.dma_data to an unsigned long holding the offset. By
19 * default the offset is zero. 19 * default the offset is PCI_DRAM_OFFSET.
20 */ 20 */
21 21
22static unsigned long get_dma_direct_offset(struct device *dev) 22static unsigned long get_dma_direct_offset(struct device *dev)
23{ 23{
24 return (unsigned long)dev->archdata.dma_data; 24 if (dev)
25 return (unsigned long)dev->archdata.dma_data;
26
27 return PCI_DRAM_OFFSET;
25} 28}
26 29
27static void *dma_direct_alloc_coherent(struct device *dev, size_t size, 30void *dma_direct_alloc_coherent(struct device *dev, size_t size,
28 dma_addr_t *dma_handle, gfp_t flag) 31 dma_addr_t *dma_handle, gfp_t flag)
29{ 32{
33#ifdef CONFIG_NOT_COHERENT_CACHE
34 return __dma_alloc_coherent(size, dma_handle, flag);
35#else
30 struct page *page; 36 struct page *page;
31 void *ret; 37 void *ret;
32 int node = dev_to_node(dev); 38 int node = dev_to_node(dev);
33 39
40 /* ignore region specifiers */
41 flag &= ~(__GFP_HIGHMEM);
42
34 page = alloc_pages_node(node, flag, get_order(size)); 43 page = alloc_pages_node(node, flag, get_order(size));
35 if (page == NULL) 44 if (page == NULL)
36 return NULL; 45 return NULL;
@@ -39,27 +48,17 @@ static void *dma_direct_alloc_coherent(struct device *dev, size_t size,
39 *dma_handle = virt_to_abs(ret) + get_dma_direct_offset(dev); 48 *dma_handle = virt_to_abs(ret) + get_dma_direct_offset(dev);
40 49
41 return ret; 50 return ret;
51#endif
42} 52}
43 53
44static void dma_direct_free_coherent(struct device *dev, size_t size, 54void dma_direct_free_coherent(struct device *dev, size_t size,
45 void *vaddr, dma_addr_t dma_handle) 55 void *vaddr, dma_addr_t dma_handle)
46{ 56{
57#ifdef CONFIG_NOT_COHERENT_CACHE
58 __dma_free_coherent(size, vaddr);
59#else
47 free_pages((unsigned long)vaddr, get_order(size)); 60 free_pages((unsigned long)vaddr, get_order(size));
48} 61#endif
49
50static dma_addr_t dma_direct_map_single(struct device *dev, void *ptr,
51 size_t size,
52 enum dma_data_direction direction,
53 struct dma_attrs *attrs)
54{
55 return virt_to_abs(ptr) + get_dma_direct_offset(dev);
56}
57
58static void dma_direct_unmap_single(struct device *dev, dma_addr_t dma_addr,
59 size_t size,
60 enum dma_data_direction direction,
61 struct dma_attrs *attrs)
62{
63} 62}
64 63
65static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, 64static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
@@ -85,20 +84,44 @@ static void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sg,
85 84
86static int dma_direct_dma_supported(struct device *dev, u64 mask) 85static int dma_direct_dma_supported(struct device *dev, u64 mask)
87{ 86{
87#ifdef CONFIG_PPC64
88 /* Could be improved to check for memory though it better be 88 /* Could be improved to check for memory though it better be
89 * done via some global so platforms can set the limit in case 89 * done via some global so platforms can set the limit in case
90 * they have limited DMA windows 90 * they have limited DMA windows
91 */ 91 */
92 return mask >= DMA_32BIT_MASK; 92 return mask >= DMA_32BIT_MASK;
93#else
94 return 1;
95#endif
96}
97
98static inline dma_addr_t dma_direct_map_page(struct device *dev,
99 struct page *page,
100 unsigned long offset,
101 size_t size,
102 enum dma_data_direction dir,
103 struct dma_attrs *attrs)
104{
105 BUG_ON(dir == DMA_NONE);
106 __dma_sync_page(page, offset, size, dir);
107 return page_to_phys(page) + offset + get_dma_direct_offset(dev);
108}
109
110static inline void dma_direct_unmap_page(struct device *dev,
111 dma_addr_t dma_address,
112 size_t size,
113 enum dma_data_direction direction,
114 struct dma_attrs *attrs)
115{
93} 116}
94 117
95struct dma_mapping_ops dma_direct_ops = { 118struct dma_mapping_ops dma_direct_ops = {
96 .alloc_coherent = dma_direct_alloc_coherent, 119 .alloc_coherent = dma_direct_alloc_coherent,
97 .free_coherent = dma_direct_free_coherent, 120 .free_coherent = dma_direct_free_coherent,
98 .map_single = dma_direct_map_single,
99 .unmap_single = dma_direct_unmap_single,
100 .map_sg = dma_direct_map_sg, 121 .map_sg = dma_direct_map_sg,
101 .unmap_sg = dma_direct_unmap_sg, 122 .unmap_sg = dma_direct_unmap_sg,
102 .dma_supported = dma_direct_dma_supported, 123 .dma_supported = dma_direct_dma_supported,
124 .map_page = dma_direct_map_page,
125 .unmap_page = dma_direct_unmap_page,
103}; 126};
104EXPORT_SYMBOL(dma_direct_ops); 127EXPORT_SYMBOL(dma_direct_ops);
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index ea0c61e09b76..52ccfed416ad 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -56,6 +56,34 @@ resource_size_t isa_mem_base;
56/* Default PCI flags is 0 */ 56/* Default PCI flags is 0 */
57unsigned int ppc_pci_flags; 57unsigned int ppc_pci_flags;
58 58
59static struct dma_mapping_ops *pci_dma_ops;
60
61void set_pci_dma_ops(struct dma_mapping_ops *dma_ops)
62{
63 pci_dma_ops = dma_ops;
64}
65
66struct dma_mapping_ops *get_pci_dma_ops(void)
67{
68 return pci_dma_ops;
69}
70EXPORT_SYMBOL(get_pci_dma_ops);
71
72int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
73{
74 return dma_set_mask(&dev->dev, mask);
75}
76
77int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
78{
79 int rc;
80
81 rc = dma_set_mask(&dev->dev, mask);
82 dev->dev.coherent_dma_mask = dev->dma_mask;
83
84 return rc;
85}
86
59struct pci_controller *pcibios_alloc_controller(struct device_node *dev) 87struct pci_controller *pcibios_alloc_controller(struct device_node *dev)
60{ 88{
61 struct pci_controller *phb; 89 struct pci_controller *phb;
@@ -180,6 +208,26 @@ char __devinit *pcibios_setup(char *str)
180 return str; 208 return str;
181} 209}
182 210
211void __devinit pcibios_setup_new_device(struct pci_dev *dev)
212{
213 struct dev_archdata *sd = &dev->dev.archdata;
214
215 sd->of_node = pci_device_to_OF_node(dev);
216
217 DBG("PCI: device %s OF node: %s\n", pci_name(dev),
218 sd->of_node ? sd->of_node->full_name : "<none>");
219
220 sd->dma_ops = pci_dma_ops;
221#ifdef CONFIG_PPC32
222 sd->dma_data = (void *)PCI_DRAM_OFFSET;
223#endif
224 set_dev_node(&dev->dev, pcibus_to_node(dev->bus));
225
226 if (ppc_md.pci_dma_dev_setup)
227 ppc_md.pci_dma_dev_setup(dev);
228}
229EXPORT_SYMBOL(pcibios_setup_new_device);
230
183/* 231/*
184 * Reads the interrupt pin to determine if interrupt is use by card. 232 * Reads the interrupt pin to determine if interrupt is use by card.
185 * If the interrupt is used, then gets the interrupt line from the 233 * If the interrupt is used, then gets the interrupt line from the
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 88db4ffaf11c..174b77ee18ff 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -424,6 +424,7 @@ void __devinit pcibios_do_bus_setup(struct pci_bus *bus)
424 unsigned long io_offset; 424 unsigned long io_offset;
425 struct resource *res; 425 struct resource *res;
426 int i; 426 int i;
427 struct pci_dev *dev;
427 428
428 /* Hookup PHB resources */ 429 /* Hookup PHB resources */
429 io_offset = (unsigned long)hose->io_base_virt - isa_io_base; 430 io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
@@ -457,6 +458,12 @@ void __devinit pcibios_do_bus_setup(struct pci_bus *bus)
457 bus->resource[i+1] = res; 458 bus->resource[i+1] = res;
458 } 459 }
459 } 460 }
461
462 if (ppc_md.pci_dma_bus_setup)
463 ppc_md.pci_dma_bus_setup(bus);
464
465 list_for_each_entry(dev, &bus->devices, bus_list)
466 pcibios_setup_new_device(dev);
460} 467}
461 468
462/* the next one is stolen from the alpha port... */ 469/* the next one is stolen from the alpha port... */
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 1f75bf03446f..8247cff1cb3e 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -52,35 +52,6 @@ EXPORT_SYMBOL(pci_io_base);
52 52
53LIST_HEAD(hose_list); 53LIST_HEAD(hose_list);
54 54
55static struct dma_mapping_ops *pci_dma_ops;
56
57void set_pci_dma_ops(struct dma_mapping_ops *dma_ops)
58{
59 pci_dma_ops = dma_ops;
60}
61
62struct dma_mapping_ops *get_pci_dma_ops(void)
63{
64 return pci_dma_ops;
65}
66EXPORT_SYMBOL(get_pci_dma_ops);
67
68
69int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
70{
71 return dma_set_mask(&dev->dev, mask);
72}
73
74int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
75{
76 int rc;
77
78 rc = dma_set_mask(&dev->dev, mask);
79 dev->dev.coherent_dma_mask = dev->dma_mask;
80
81 return rc;
82}
83
84static void fixup_broken_pcnet32(struct pci_dev* dev) 55static void fixup_broken_pcnet32(struct pci_dev* dev)
85{ 56{
86 if ((dev->class>>8 == PCI_CLASS_NETWORK_ETHERNET)) { 57 if ((dev->class>>8 == PCI_CLASS_NETWORK_ETHERNET)) {
@@ -548,23 +519,6 @@ int __devinit pcibios_map_io_space(struct pci_bus *bus)
548} 519}
549EXPORT_SYMBOL_GPL(pcibios_map_io_space); 520EXPORT_SYMBOL_GPL(pcibios_map_io_space);
550 521
551void __devinit pcibios_setup_new_device(struct pci_dev *dev)
552{
553 struct dev_archdata *sd = &dev->dev.archdata;
554
555 sd->of_node = pci_device_to_OF_node(dev);
556
557 DBG("PCI: device %s OF node: %s\n", pci_name(dev),
558 sd->of_node ? sd->of_node->full_name : "<none>");
559
560 sd->dma_ops = pci_dma_ops;
561 set_dev_node(&dev->dev, pcibus_to_node(dev->bus));
562
563 if (ppc_md.pci_dma_dev_setup)
564 ppc_md.pci_dma_dev_setup(dev);
565}
566EXPORT_SYMBOL(pcibios_setup_new_device);
567
568void __devinit pcibios_do_bus_setup(struct pci_bus *bus) 522void __devinit pcibios_do_bus_setup(struct pci_bus *bus)
569{ 523{
570 struct pci_dev *dev; 524 struct pci_dev *dev;