aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/Kconfig8
-rw-r--r--arch/powerpc/boot/Makefile2
-rw-r--r--arch/powerpc/kernel/ptrace.c52
-rw-r--r--arch/powerpc/kernel/sysfs.c2
-rw-r--r--arch/powerpc/kernel/vio.c13
-rw-r--r--arch/powerpc/kernel/vmlinux.lds.S10
-rw-r--r--arch/powerpc/oprofile/op_model_power4.c6
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c2
-rw-r--r--arch/powerpc/platforms/pasemi/Makefile2
-rw-r--r--arch/powerpc/platforms/pasemi/dma_lib.c488
-rw-r--r--arch/powerpc/platforms/pasemi/pasemi.h1
-rw-r--r--arch/powerpc/platforms/powermac/pic.c2
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-cpu.c8
-rw-r--r--arch/powerpc/platforms/pseries/power.c32
-rw-r--r--arch/powerpc/platforms/pseries/rtasd.c8
-rw-r--r--arch/powerpc/sysdev/ipic.c2
-rw-r--r--arch/powerpc/sysdev/mpic.c2
-rw-r--r--arch/powerpc/sysdev/mv64x60_dev.c6
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe_ic.c2
19 files changed, 542 insertions, 106 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5e1083829d82..2bf2f3f53029 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -42,6 +42,9 @@ config GENERIC_HARDIRQS
42 bool 42 bool
43 default y 43 default y
44 44
45config ARCH_SETS_UP_PER_CPU_AREA
46 def_bool PPC64
47
45config IRQ_PER_CPU 48config IRQ_PER_CPU
46 bool 49 bool
47 default y 50 default y
@@ -53,6 +56,11 @@ config RWSEM_XCHGADD_ALGORITHM
53 bool 56 bool
54 default y 57 default y
55 58
59config GENERIC_LOCKBREAK
60 bool
61 default y
62 depends on SMP && PREEMPT
63
56config ARCH_HAS_ILOG2_U32 64config ARCH_HAS_ILOG2_U32
57 bool 65 bool
58 default y 66 default y
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 7f6b07c30d69..122a27078998 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -72,7 +72,7 @@ obj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib))))
72obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat)))) 72obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat))))
73 73
74quiet_cmd_copy_zlib = COPY $@ 74quiet_cmd_copy_zlib = COPY $@
75 cmd_copy_zlib = sed "s@__attribute_used__@@;s@<linux/\([^>]*\).*@\"\1\"@" $< > $@ 75 cmd_copy_zlib = sed "s@__used@@;s@<linux/\([^>]*\).*@\"\1\"@" $< > $@
76 76
77quiet_cmd_copy_zlibheader = COPY $@ 77quiet_cmd_copy_zlibheader = COPY $@
78 cmd_copy_zlibheader = sed "s@<linux/\([^>]*\).*@\"\1\"@" $< > $@ 78 cmd_copy_zlibheader = sed "s@<linux/\([^>]*\).*@\"\1\"@" $< > $@
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 3e17d154d0d4..8b056d2295cc 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -256,7 +256,7 @@ static int set_evrregs(struct task_struct *task, unsigned long *data)
256#endif /* CONFIG_SPE */ 256#endif /* CONFIG_SPE */
257 257
258 258
259static void set_single_step(struct task_struct *task) 259void user_enable_single_step(struct task_struct *task)
260{ 260{
261 struct pt_regs *regs = task->thread.regs; 261 struct pt_regs *regs = task->thread.regs;
262 262
@@ -271,7 +271,7 @@ static void set_single_step(struct task_struct *task)
271 set_tsk_thread_flag(task, TIF_SINGLESTEP); 271 set_tsk_thread_flag(task, TIF_SINGLESTEP);
272} 272}
273 273
274static void clear_single_step(struct task_struct *task) 274void user_disable_single_step(struct task_struct *task)
275{ 275{
276 struct pt_regs *regs = task->thread.regs; 276 struct pt_regs *regs = task->thread.regs;
277 277
@@ -313,7 +313,7 @@ static int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
313void ptrace_disable(struct task_struct *child) 313void ptrace_disable(struct task_struct *child)
314{ 314{
315 /* make sure the single step bit is not set. */ 315 /* make sure the single step bit is not set. */
316 clear_single_step(child); 316 user_disable_single_step(child);
317} 317}
318 318
319/* 319/*
@@ -445,52 +445,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
445 break; 445 break;
446 } 446 }
447 447
448 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
449 case PTRACE_CONT: { /* restart after signal. */
450 ret = -EIO;
451 if (!valid_signal(data))
452 break;
453 if (request == PTRACE_SYSCALL)
454 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
455 else
456 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
457 child->exit_code = data;
458 /* make sure the single step bit is not set. */
459 clear_single_step(child);
460 wake_up_process(child);
461 ret = 0;
462 break;
463 }
464
465/*
466 * make the child exit. Best I can do is send it a sigkill.
467 * perhaps it should be put in the status that it wants to
468 * exit.
469 */
470 case PTRACE_KILL: {
471 ret = 0;
472 if (child->exit_state == EXIT_ZOMBIE) /* already dead */
473 break;
474 child->exit_code = SIGKILL;
475 /* make sure the single step bit is not set. */
476 clear_single_step(child);
477 wake_up_process(child);
478 break;
479 }
480
481 case PTRACE_SINGLESTEP: { /* set the trap flag. */
482 ret = -EIO;
483 if (!valid_signal(data))
484 break;
485 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
486 set_single_step(child);
487 child->exit_code = data;
488 /* give it a chance to run. */
489 wake_up_process(child);
490 ret = 0;
491 break;
492 }
493
494 case PTRACE_GET_DEBUGREG: { 448 case PTRACE_GET_DEBUGREG: {
495 ret = -EINVAL; 449 ret = -EINVAL;
496 /* We only support one DABR and no IABRS at the moment */ 450 /* We only support one DABR and no IABRS at the moment */
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 25d9a96484dd..c8127f832df0 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -158,7 +158,7 @@ static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
158 unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \ 158 unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \
159 return sprintf(buf, "%lx\n", val); \ 159 return sprintf(buf, "%lx\n", val); \
160} \ 160} \
161static ssize_t __attribute_used__ \ 161static ssize_t __used \
162 store_##NAME(struct sys_device *dev, const char *buf, size_t count) \ 162 store_##NAME(struct sys_device *dev, const char *buf, size_t count) \
163{ \ 163{ \
164 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ 164 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 19a5656001c0..f0bad7070fb5 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -37,8 +37,6 @@
37#include <asm/iseries/hv_call_xm.h> 37#include <asm/iseries/hv_call_xm.h>
38#include <asm/iseries/iommu.h> 38#include <asm/iseries/iommu.h>
39 39
40extern struct kset devices_subsys; /* needed for vio_find_name() */
41
42static struct bus_type vio_bus_type; 40static struct bus_type vio_bus_type;
43 41
44static struct vio_dev vio_bus_device = { /* fake "parent" device */ 42static struct vio_dev vio_bus_device = { /* fake "parent" device */
@@ -361,19 +359,16 @@ EXPORT_SYMBOL(vio_get_attribute);
361#ifdef CONFIG_PPC_PSERIES 359#ifdef CONFIG_PPC_PSERIES
362/* vio_find_name() - internal because only vio.c knows how we formatted the 360/* vio_find_name() - internal because only vio.c knows how we formatted the
363 * kobject name 361 * kobject name
364 * XXX once vio_bus_type.devices is actually used as a kset in
365 * drivers/base/bus.c, this function should be removed in favor of
366 * "device_find(kobj_name, &vio_bus_type)"
367 */ 362 */
368static struct vio_dev *vio_find_name(const char *kobj_name) 363static struct vio_dev *vio_find_name(const char *name)
369{ 364{
370 struct kobject *found; 365 struct device *found;
371 366
372 found = kset_find_obj(&devices_subsys, kobj_name); 367 found = bus_find_device_by_name(&vio_bus_type, NULL, name);
373 if (!found) 368 if (!found)
374 return NULL; 369 return NULL;
375 370
376 return to_vio_dev(container_of(found, struct device, kobj)); 371 return to_vio_dev(found);
377} 372}
378 373
379/** 374/**
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index f66fa5d966b0..0afb9e31d2a0 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -23,7 +23,7 @@ SECTIONS
23 /* Sections to be discarded. */ 23 /* Sections to be discarded. */
24 /DISCARD/ : { 24 /DISCARD/ : {
25 *(.exitcall.exit) 25 *(.exitcall.exit)
26 *(.exit.data) 26 EXIT_DATA
27 } 27 }
28 28
29 . = KERNELBASE; 29 . = KERNELBASE;
@@ -76,17 +76,19 @@ SECTIONS
76 76
77 .init.text : { 77 .init.text : {
78 _sinittext = .; 78 _sinittext = .;
79 *(.init.text) 79 INIT_TEXT
80 _einittext = .; 80 _einittext = .;
81 } 81 }
82 82
83 /* .exit.text is discarded at runtime, not link time, 83 /* .exit.text is discarded at runtime, not link time,
84 * to deal with references from __bug_table 84 * to deal with references from __bug_table
85 */ 85 */
86 .exit.text : { *(.exit.text) } 86 .exit.text : {
87 EXIT_TEXT
88 }
87 89
88 .init.data : { 90 .init.data : {
89 *(.init.data); 91 INIT_DATA
90 __vtop_table_begin = .; 92 __vtop_table_begin = .;
91 *(.vtop_fixup); 93 *(.vtop_fixup);
92 __vtop_table_end = .; 94 __vtop_table_end = .;
diff --git a/arch/powerpc/oprofile/op_model_power4.c b/arch/powerpc/oprofile/op_model_power4.c
index cddc250a6a5c..446a8bbb847b 100644
--- a/arch/powerpc/oprofile/op_model_power4.c
+++ b/arch/powerpc/oprofile/op_model_power4.c
@@ -172,15 +172,15 @@ static void power4_stop(void)
172} 172}
173 173
174/* Fake functions used by canonicalize_pc */ 174/* Fake functions used by canonicalize_pc */
175static void __attribute_used__ hypervisor_bucket(void) 175static void __used hypervisor_bucket(void)
176{ 176{
177} 177}
178 178
179static void __attribute_used__ rtas_bucket(void) 179static void __used rtas_bucket(void)
180{ 180{
181} 181}
182 182
183static void __attribute_used__ kernel_unknown_bucket(void) 183static void __used kernel_unknown_bucket(void)
184{ 184{
185} 185}
186 186
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index fb266ae32095..e45cfa84911f 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -511,7 +511,7 @@ static int spu_shutdown(struct sys_device *sysdev)
511} 511}
512 512
513static struct sysdev_class spu_sysdev_class = { 513static struct sysdev_class spu_sysdev_class = {
514 set_kset_name("spu"), 514 .name = "spu",
515 .shutdown = spu_shutdown, 515 .shutdown = spu_shutdown,
516}; 516};
517 517
diff --git a/arch/powerpc/platforms/pasemi/Makefile b/arch/powerpc/platforms/pasemi/Makefile
index 2cd2a4f26a48..8f52d7515793 100644
--- a/arch/powerpc/platforms/pasemi/Makefile
+++ b/arch/powerpc/platforms/pasemi/Makefile
@@ -1,3 +1,3 @@
1obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o 1obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o dma_lib.o
2obj-$(CONFIG_PPC_PASEMI_MDIO) += gpio_mdio.o 2obj-$(CONFIG_PPC_PASEMI_MDIO) += gpio_mdio.o
3obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += cpufreq.o 3obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += cpufreq.o
diff --git a/arch/powerpc/platforms/pasemi/dma_lib.c b/arch/powerpc/platforms/pasemi/dma_lib.c
new file mode 100644
index 000000000000..c529d8dff395
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/dma_lib.c
@@ -0,0 +1,488 @@
1/*
2 * Copyright (C) 2006-2007 PA Semi, Inc
3 *
4 * Common functions for DMA access on PA Semi PWRficient
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/init.h>
21#include <linux/module.h>
22#include <linux/pci.h>
23#include <linux/of.h>
24
25#include <asm/pasemi_dma.h>
26
27#define MAX_TXCH 64
28#define MAX_RXCH 64
29
30static struct pasdma_status *dma_status;
31
32static void __iomem *iob_regs;
33static void __iomem *mac_regs[6];
34static void __iomem *dma_regs;
35
36static int base_hw_irq;
37
38static int num_txch, num_rxch;
39
40static struct pci_dev *dma_pdev;
41
42/* Bitmaps to handle allocation of channels */
43
44static DECLARE_BITMAP(txch_free, MAX_TXCH);
45static DECLARE_BITMAP(rxch_free, MAX_RXCH);
46
47/* pasemi_read_iob_reg - read IOB register
48 * @reg: Register to read (offset into PCI CFG space)
49 */
50unsigned int pasemi_read_iob_reg(unsigned int reg)
51{
52 return in_le32(iob_regs+reg);
53}
54EXPORT_SYMBOL(pasemi_read_iob_reg);
55
56/* pasemi_write_iob_reg - write IOB register
57 * @reg: Register to write to (offset into PCI CFG space)
58 * @val: Value to write
59 */
60void pasemi_write_iob_reg(unsigned int reg, unsigned int val)
61{
62 out_le32(iob_regs+reg, val);
63}
64EXPORT_SYMBOL(pasemi_write_iob_reg);
65
66/* pasemi_read_mac_reg - read MAC register
67 * @intf: MAC interface
68 * @reg: Register to read (offset into PCI CFG space)
69 */
70unsigned int pasemi_read_mac_reg(int intf, unsigned int reg)
71{
72 return in_le32(mac_regs[intf]+reg);
73}
74EXPORT_SYMBOL(pasemi_read_mac_reg);
75
76/* pasemi_write_mac_reg - write MAC register
77 * @intf: MAC interface
78 * @reg: Register to write to (offset into PCI CFG space)
79 * @val: Value to write
80 */
81void pasemi_write_mac_reg(int intf, unsigned int reg, unsigned int val)
82{
83 out_le32(mac_regs[intf]+reg, val);
84}
85EXPORT_SYMBOL(pasemi_write_mac_reg);
86
87/* pasemi_read_dma_reg - read DMA register
88 * @reg: Register to read (offset into PCI CFG space)
89 */
90unsigned int pasemi_read_dma_reg(unsigned int reg)
91{
92 return in_le32(dma_regs+reg);
93}
94EXPORT_SYMBOL(pasemi_read_dma_reg);
95
96/* pasemi_write_dma_reg - write DMA register
97 * @reg: Register to write to (offset into PCI CFG space)
98 * @val: Value to write
99 */
100void pasemi_write_dma_reg(unsigned int reg, unsigned int val)
101{
102 out_le32(dma_regs+reg, val);
103}
104EXPORT_SYMBOL(pasemi_write_dma_reg);
105
106static int pasemi_alloc_tx_chan(enum pasemi_dmachan_type type)
107{
108 int bit;
109 int start, limit;
110
111 switch (type & (TXCHAN_EVT0|TXCHAN_EVT1)) {
112 case TXCHAN_EVT0:
113 start = 0;
114 limit = 10;
115 break;
116 case TXCHAN_EVT1:
117 start = 10;
118 limit = MAX_TXCH;
119 break;
120 default:
121 start = 0;
122 limit = MAX_TXCH;
123 break;
124 }
125retry:
126 bit = find_next_bit(txch_free, MAX_TXCH, start);
127 if (bit >= limit)
128 return -ENOSPC;
129 if (!test_and_clear_bit(bit, txch_free))
130 goto retry;
131
132 return bit;
133}
134
135static void pasemi_free_tx_chan(int chan)
136{
137 BUG_ON(test_bit(chan, txch_free));
138 set_bit(chan, txch_free);
139}
140
141static int pasemi_alloc_rx_chan(void)
142{
143 int bit;
144retry:
145 bit = find_first_bit(rxch_free, MAX_RXCH);
146 if (bit >= MAX_TXCH)
147 return -ENOSPC;
148 if (!test_and_clear_bit(bit, rxch_free))
149 goto retry;
150
151 return bit;
152}
153
154static void pasemi_free_rx_chan(int chan)
155{
156 BUG_ON(test_bit(chan, rxch_free));
157 set_bit(chan, rxch_free);
158}
159
160/* pasemi_dma_alloc_chan - Allocate a DMA channel
161 * @type: Type of channel to allocate
162 * @total_size: Total size of structure to allocate (to allow for more
163 * room behind the structure to be used by the client)
164 * @offset: Offset in bytes from start of the total structure to the beginning
165 * of struct pasemi_dmachan. Needed when struct pasemi_dmachan is
166 * not the first member of the client structure.
167 *
168 * pasemi_dma_alloc_chan allocates a DMA channel for use by a client. The
169 * type argument specifies whether it's a RX or TX channel, and in the case
170 * of TX channels which group it needs to belong to (if any).
171 *
172 * Returns a pointer to the total structure allocated on success, NULL
173 * on failure.
174 */
175void *pasemi_dma_alloc_chan(enum pasemi_dmachan_type type,
176 int total_size, int offset)
177{
178 void *buf;
179 struct pasemi_dmachan *chan;
180 int chno;
181
182 BUG_ON(total_size < sizeof(struct pasemi_dmachan));
183
184 buf = kzalloc(total_size, GFP_KERNEL);
185
186 if (!buf)
187 return NULL;
188 chan = buf + offset;
189
190 chan->priv = buf;
191
192 switch (type & (TXCHAN|RXCHAN)) {
193 case RXCHAN:
194 chno = pasemi_alloc_rx_chan();
195 chan->chno = chno;
196 chan->irq = irq_create_mapping(NULL,
197 base_hw_irq + num_txch + chno);
198 chan->status = &dma_status->rx_sta[chno];
199 break;
200 case TXCHAN:
201 chno = pasemi_alloc_tx_chan(type);
202 chan->chno = chno;
203 chan->irq = irq_create_mapping(NULL, base_hw_irq + chno);
204 chan->status = &dma_status->tx_sta[chno];
205 break;
206 }
207
208 chan->chan_type = type;
209
210 return chan;
211}
212EXPORT_SYMBOL(pasemi_dma_alloc_chan);
213
214/* pasemi_dma_free_chan - Free a previously allocated channel
215 * @chan: Channel to free
216 *
217 * Frees a previously allocated channel. It will also deallocate any
218 * descriptor ring associated with the channel, if allocated.
219 */
220void pasemi_dma_free_chan(struct pasemi_dmachan *chan)
221{
222 if (chan->ring_virt)
223 pasemi_dma_free_ring(chan);
224
225 switch (chan->chan_type & (RXCHAN|TXCHAN)) {
226 case RXCHAN:
227 pasemi_free_rx_chan(chan->chno);
228 break;
229 case TXCHAN:
230 pasemi_free_tx_chan(chan->chno);
231 break;
232 }
233
234 kfree(chan->priv);
235}
236EXPORT_SYMBOL(pasemi_dma_free_chan);
237
238/* pasemi_dma_alloc_ring - Allocate descriptor ring for a channel
239 * @chan: Channel for which to allocate
240 * @ring_size: Ring size in 64-bit (8-byte) words
241 *
242 * Allocate a descriptor ring for a channel. Returns 0 on success, errno
243 * on failure. The passed in struct pasemi_dmachan is updated with the
244 * virtual and DMA addresses of the ring.
245 */
246int pasemi_dma_alloc_ring(struct pasemi_dmachan *chan, int ring_size)
247{
248 BUG_ON(chan->ring_virt);
249
250 chan->ring_size = ring_size;
251
252 chan->ring_virt = dma_alloc_coherent(&dma_pdev->dev,
253 ring_size * sizeof(u64),
254 &chan->ring_dma, GFP_KERNEL);
255
256 if (!chan->ring_virt)
257 return -ENOMEM;
258
259 memset(chan->ring_virt, 0, ring_size * sizeof(u64));
260
261 return 0;
262}
263EXPORT_SYMBOL(pasemi_dma_alloc_ring);
264
265/* pasemi_dma_free_ring - Free an allocated descriptor ring for a channel
266 * @chan: Channel for which to free the descriptor ring
267 *
268 * Frees a previously allocated descriptor ring for a channel.
269 */
270void pasemi_dma_free_ring(struct pasemi_dmachan *chan)
271{
272 BUG_ON(!chan->ring_virt);
273
274 dma_free_coherent(&dma_pdev->dev, chan->ring_size * sizeof(u64),
275 chan->ring_virt, chan->ring_dma);
276 chan->ring_virt = NULL;
277 chan->ring_size = 0;
278 chan->ring_dma = 0;
279}
280EXPORT_SYMBOL(pasemi_dma_free_ring);
281
282/* pasemi_dma_start_chan - Start a DMA channel
283 * @chan: Channel to start
284 * @cmdsta: Additional CCMDSTA/TCMDSTA bits to write
285 *
286 * Enables (starts) a DMA channel with optional additional arguments.
287 */
288void pasemi_dma_start_chan(const struct pasemi_dmachan *chan, const u32 cmdsta)
289{
290 if (chan->chan_type == RXCHAN)
291 pasemi_write_dma_reg(PAS_DMA_RXCHAN_CCMDSTA(chan->chno),
292 cmdsta | PAS_DMA_RXCHAN_CCMDSTA_EN);
293 else
294 pasemi_write_dma_reg(PAS_DMA_TXCHAN_TCMDSTA(chan->chno),
295 cmdsta | PAS_DMA_TXCHAN_TCMDSTA_EN);
296}
297EXPORT_SYMBOL(pasemi_dma_start_chan);
298
299/* pasemi_dma_stop_chan - Stop a DMA channel
300 * @chan: Channel to stop
301 *
302 * Stops (disables) a DMA channel. This is done by setting the ST bit in the
303 * CMDSTA register and waiting on the ACT (active) bit to clear, then
304 * finally disabling the whole channel.
305 *
306 * This function will only try for a short while for the channel to stop, if
307 * it doesn't it will return failure.
308 *
309 * Returns 1 on success, 0 on failure.
310 */
311#define MAX_RETRIES 5000
312int pasemi_dma_stop_chan(const struct pasemi_dmachan *chan)
313{
314 int reg, retries;
315 u32 sta;
316
317 if (chan->chan_type == RXCHAN) {
318 reg = PAS_DMA_RXCHAN_CCMDSTA(chan->chno);
319 pasemi_write_dma_reg(reg, PAS_DMA_RXCHAN_CCMDSTA_ST);
320 for (retries = 0; retries < MAX_RETRIES; retries++) {
321 sta = pasemi_read_dma_reg(reg);
322 if (!(sta & PAS_DMA_RXCHAN_CCMDSTA_ACT)) {
323 pasemi_write_dma_reg(reg, 0);
324 return 1;
325 }
326 cond_resched();
327 }
328 } else {
329 reg = PAS_DMA_TXCHAN_TCMDSTA(chan->chno);
330 pasemi_write_dma_reg(reg, PAS_DMA_TXCHAN_TCMDSTA_ST);
331 for (retries = 0; retries < MAX_RETRIES; retries++) {
332 sta = pasemi_read_dma_reg(reg);
333 if (!(sta & PAS_DMA_TXCHAN_TCMDSTA_ACT)) {
334 pasemi_write_dma_reg(reg, 0);
335 return 1;
336 }
337 cond_resched();
338 }
339 }
340
341 return 0;
342}
343EXPORT_SYMBOL(pasemi_dma_stop_chan);
344
345/* pasemi_dma_alloc_buf - Allocate a buffer to use for DMA
346 * @chan: Channel to allocate for
347 * @size: Size of buffer in bytes
348 * @handle: DMA handle
349 *
350 * Allocate a buffer to be used by the DMA engine for read/write,
351 * similar to dma_alloc_coherent().
352 *
353 * Returns the virtual address of the buffer, or NULL in case of failure.
354 */
355void *pasemi_dma_alloc_buf(struct pasemi_dmachan *chan, int size,
356 dma_addr_t *handle)
357{
358 return dma_alloc_coherent(&dma_pdev->dev, size, handle, GFP_KERNEL);
359}
360EXPORT_SYMBOL(pasemi_dma_alloc_buf);
361
362/* pasemi_dma_free_buf - Free a buffer used for DMA
363 * @chan: Channel the buffer was allocated for
364 * @size: Size of buffer in bytes
365 * @handle: DMA handle
366 *
367 * Frees a previously allocated buffer.
368 */
369void pasemi_dma_free_buf(struct pasemi_dmachan *chan, int size,
370 dma_addr_t *handle)
371{
372 dma_free_coherent(&dma_pdev->dev, size, handle, GFP_KERNEL);
373}
374EXPORT_SYMBOL(pasemi_dma_free_buf);
375
376static void *map_onedev(struct pci_dev *p, int index)
377{
378 struct device_node *dn;
379 void __iomem *ret;
380
381 dn = pci_device_to_OF_node(p);
382 if (!dn)
383 goto fallback;
384
385 ret = of_iomap(dn, index);
386 if (!ret)
387 goto fallback;
388
389 return ret;
390fallback:
391 /* This is hardcoded and ugly, but we have some firmware versions
392 * that don't provide the register space in the device tree. Luckily
393 * they are at well-known locations so we can just do the math here.
394 */
395 return ioremap(0xe0000000 + (p->devfn << 12), 0x2000);
396}
397
398/* pasemi_dma_init - Initialize the PA Semi DMA library
399 *
400 * This function initializes the DMA library. It must be called before
401 * any other function in the library.
402 *
403 * Returns 0 on success, errno on failure.
404 */
405int pasemi_dma_init(void)
406{
407 static spinlock_t init_lock = SPIN_LOCK_UNLOCKED;
408 struct pci_dev *iob_pdev;
409 struct pci_dev *pdev;
410 struct resource res;
411 struct device_node *dn;
412 int i, intf, err = 0;
413 u32 tmp;
414
415 if (!machine_is(pasemi))
416 return -ENODEV;
417
418 spin_lock(&init_lock);
419
420 /* Make sure we haven't already initialized */
421 if (dma_pdev)
422 goto out;
423
424 iob_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa001, NULL);
425 if (!iob_pdev) {
426 BUG();
427 printk(KERN_WARNING "Can't find I/O Bridge\n");
428 err = -ENODEV;
429 goto out;
430 }
431 iob_regs = map_onedev(iob_pdev, 0);
432
433 dma_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa007, NULL);
434 if (!dma_pdev) {
435 BUG();
436 printk(KERN_WARNING "Can't find DMA controller\n");
437 err = -ENODEV;
438 goto out;
439 }
440 dma_regs = map_onedev(dma_pdev, 0);
441 base_hw_irq = virq_to_hw(dma_pdev->irq);
442
443 pci_read_config_dword(dma_pdev, PAS_DMA_CAP_TXCH, &tmp);
444 num_txch = (tmp & PAS_DMA_CAP_TXCH_TCHN_M) >> PAS_DMA_CAP_TXCH_TCHN_S;
445
446 pci_read_config_dword(dma_pdev, PAS_DMA_CAP_RXCH, &tmp);
447 num_rxch = (tmp & PAS_DMA_CAP_RXCH_RCHN_M) >> PAS_DMA_CAP_RXCH_RCHN_S;
448
449 intf = 0;
450 for (pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa006, NULL);
451 pdev;
452 pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa006, pdev))
453 mac_regs[intf++] = map_onedev(pdev, 0);
454
455 pci_dev_put(pdev);
456
457 for (pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa005, NULL);
458 pdev;
459 pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa005, pdev))
460 mac_regs[intf++] = map_onedev(pdev, 0);
461
462 pci_dev_put(pdev);
463
464 dn = pci_device_to_OF_node(iob_pdev);
465 if (dn)
466 err = of_address_to_resource(dn, 1, &res);
467 if (!dn || err) {
468 /* Fallback for old firmware */
469 res.start = 0xfd800000;
470 res.end = res.start + 0x1000;
471 }
472 dma_status = __ioremap(res.start, res.end-res.start, 0);
473 pci_dev_put(iob_pdev);
474
475 for (i = 0; i < MAX_TXCH; i++)
476 __set_bit(i, txch_free);
477
478 for (i = 0; i < MAX_RXCH; i++)
479 __set_bit(i, rxch_free);
480
481 printk(KERN_INFO "PA Semi PWRficient DMA library initialized "
482 "(%d tx, %d rx channels)\n", num_txch, num_rxch);
483
484out:
485 spin_unlock(&init_lock);
486 return err;
487}
488EXPORT_SYMBOL(pasemi_dma_init);
diff --git a/arch/powerpc/platforms/pasemi/pasemi.h b/arch/powerpc/platforms/pasemi/pasemi.h
index c96127b029b6..b1e524f7489d 100644
--- a/arch/powerpc/platforms/pasemi/pasemi.h
+++ b/arch/powerpc/platforms/pasemi/pasemi.h
@@ -9,6 +9,7 @@ extern void __devinit pas_pci_dma_dev_setup(struct pci_dev *dev);
9extern void __iomem *pasemi_pci_getcfgaddr(struct pci_dev *dev, int offset); 9extern void __iomem *pasemi_pci_getcfgaddr(struct pci_dev *dev, int offset);
10 10
11extern void __init alloc_iobmap_l2(void); 11extern void __init alloc_iobmap_l2(void);
12extern void __init pasemi_map_registers(void);
12 13
13/* Power savings modes, implemented in asm */ 14/* Power savings modes, implemented in asm */
14extern void idle_spin(void); 15extern void idle_spin(void);
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index cd7216437416..40736400ef80 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -663,7 +663,7 @@ static int pmacpic_resume(struct sys_device *sysdev)
663#endif /* CONFIG_PM && CONFIG_PPC32 */ 663#endif /* CONFIG_PM && CONFIG_PPC32 */
664 664
665static struct sysdev_class pmacpic_sysclass = { 665static struct sysdev_class pmacpic_sysclass = {
666 set_kset_name("pmac_pic"), 666 .name = "pmac_pic",
667}; 667};
668 668
669static struct sys_device device_pmacpic = { 669static struct sys_device device_pmacpic = {
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 412e6b42986f..c4ad54e0f288 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -153,7 +153,7 @@ static int pseries_add_processor(struct device_node *np)
153 for (i = 0; i < nthreads; i++) 153 for (i = 0; i < nthreads; i++)
154 cpu_set(i, tmp); 154 cpu_set(i, tmp);
155 155
156 lock_cpu_hotplug(); 156 cpu_maps_update_begin();
157 157
158 BUG_ON(!cpus_subset(cpu_present_map, cpu_possible_map)); 158 BUG_ON(!cpus_subset(cpu_present_map, cpu_possible_map));
159 159
@@ -190,7 +190,7 @@ static int pseries_add_processor(struct device_node *np)
190 } 190 }
191 err = 0; 191 err = 0;
192out_unlock: 192out_unlock:
193 unlock_cpu_hotplug(); 193 cpu_maps_update_done();
194 return err; 194 return err;
195} 195}
196 196
@@ -211,7 +211,7 @@ static void pseries_remove_processor(struct device_node *np)
211 211
212 nthreads = len / sizeof(u32); 212 nthreads = len / sizeof(u32);
213 213
214 lock_cpu_hotplug(); 214 cpu_maps_update_begin();
215 for (i = 0; i < nthreads; i++) { 215 for (i = 0; i < nthreads; i++) {
216 for_each_present_cpu(cpu) { 216 for_each_present_cpu(cpu) {
217 if (get_hard_smp_processor_id(cpu) != intserv[i]) 217 if (get_hard_smp_processor_id(cpu) != intserv[i])
@@ -225,7 +225,7 @@ static void pseries_remove_processor(struct device_node *np)
225 printk(KERN_WARNING "Could not find cpu to remove " 225 printk(KERN_WARNING "Could not find cpu to remove "
226 "with physical id 0x%x\n", intserv[i]); 226 "with physical id 0x%x\n", intserv[i]);
227 } 227 }
228 unlock_cpu_hotplug(); 228 cpu_maps_update_done();
229} 229}
230 230
231static int pseries_smp_notifier(struct notifier_block *nb, 231static int pseries_smp_notifier(struct notifier_block *nb,
diff --git a/arch/powerpc/platforms/pseries/power.c b/arch/powerpc/platforms/pseries/power.c
index 73e69023d90a..e95fc1594c84 100644
--- a/arch/powerpc/platforms/pseries/power.c
+++ b/arch/powerpc/platforms/pseries/power.c
@@ -28,13 +28,15 @@
28 28
29unsigned long rtas_poweron_auto; /* default and normal state is 0 */ 29unsigned long rtas_poweron_auto; /* default and normal state is 0 */
30 30
31static ssize_t auto_poweron_show(struct kset *kset, char *buf) 31static ssize_t auto_poweron_show(struct kobject *kobj,
32 struct kobj_attribute *attr, char *buf)
32{ 33{
33 return sprintf(buf, "%lu\n", rtas_poweron_auto); 34 return sprintf(buf, "%lu\n", rtas_poweron_auto);
34} 35}
35 36
36static ssize_t 37static ssize_t auto_poweron_store(struct kobject *kobj,
37auto_poweron_store(struct kset *kset, const char *buf, size_t n) 38 struct kobj_attribute *attr,
39 const char *buf, size_t n)
38{ 40{
39 int ret; 41 int ret;
40 unsigned long ups_restart; 42 unsigned long ups_restart;
@@ -47,17 +49,11 @@ auto_poweron_store(struct kset *kset, const char *buf, size_t n)
47 return -EINVAL; 49 return -EINVAL;
48} 50}
49 51
50static struct subsys_attribute auto_poweron_attr = { 52static struct kobj_attribute auto_poweron_attr =
51 .attr = { 53 __ATTR(auto_poweron, 0644, auto_poweron_show, auto_poweron_store);
52 .name = __stringify(auto_poweron),
53 .mode = 0644,
54 },
55 .show = auto_poweron_show,
56 .store = auto_poweron_store,
57};
58 54
59#ifndef CONFIG_PM 55#ifndef CONFIG_PM
60decl_subsys(power,NULL,NULL); 56struct kobject *power_kobj;
61 57
62static struct attribute *g[] = { 58static struct attribute *g[] = {
63 &auto_poweron_attr.attr, 59 &auto_poweron_attr.attr,
@@ -70,18 +66,16 @@ static struct attribute_group attr_group = {
70 66
71static int __init pm_init(void) 67static int __init pm_init(void)
72{ 68{
73 int error = subsystem_register(&power_subsys); 69 power_kobj = kobject_create_and_add("power", NULL);
74 if (!error) 70 if (!power_kobj)
75 error = sysfs_create_group(&power_subsys.kobj, &attr_group); 71 return -ENOMEM;
76 return error; 72 return sysfs_create_group(power_kobj, &attr_group);
77} 73}
78core_initcall(pm_init); 74core_initcall(pm_init);
79#else 75#else
80extern struct kset power_subsys;
81
82static int __init apo_pm_init(void) 76static int __init apo_pm_init(void)
83{ 77{
84 return (subsys_create_file(&power_subsys, &auto_poweron_attr)); 78 return (sysfs_create_file(power_kobj, &auto_poweron_attr));
85} 79}
86__initcall(apo_pm_init); 80__initcall(apo_pm_init);
87#endif 81#endif
diff --git a/arch/powerpc/platforms/pseries/rtasd.c b/arch/powerpc/platforms/pseries/rtasd.c
index 73401c820110..e3078ce41518 100644
--- a/arch/powerpc/platforms/pseries/rtasd.c
+++ b/arch/powerpc/platforms/pseries/rtasd.c
@@ -382,7 +382,7 @@ static void do_event_scan_all_cpus(long delay)
382{ 382{
383 int cpu; 383 int cpu;
384 384
385 lock_cpu_hotplug(); 385 get_online_cpus();
386 cpu = first_cpu(cpu_online_map); 386 cpu = first_cpu(cpu_online_map);
387 for (;;) { 387 for (;;) {
388 set_cpus_allowed(current, cpumask_of_cpu(cpu)); 388 set_cpus_allowed(current, cpumask_of_cpu(cpu));
@@ -390,15 +390,15 @@ static void do_event_scan_all_cpus(long delay)
390 set_cpus_allowed(current, CPU_MASK_ALL); 390 set_cpus_allowed(current, CPU_MASK_ALL);
391 391
392 /* Drop hotplug lock, and sleep for the specified delay */ 392 /* Drop hotplug lock, and sleep for the specified delay */
393 unlock_cpu_hotplug(); 393 put_online_cpus();
394 msleep_interruptible(delay); 394 msleep_interruptible(delay);
395 lock_cpu_hotplug(); 395 get_online_cpus();
396 396
397 cpu = next_cpu(cpu, cpu_online_map); 397 cpu = next_cpu(cpu, cpu_online_map);
398 if (cpu == NR_CPUS) 398 if (cpu == NR_CPUS)
399 break; 399 break;
400 } 400 }
401 unlock_cpu_hotplug(); 401 put_online_cpus();
402} 402}
403 403
404static int rtasd(void *unused) 404static int rtasd(void *unused)
diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index d7f6a70e78df..ae0dbf4c1d66 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -894,7 +894,7 @@ unsigned int ipic_get_irq(void)
894} 894}
895 895
896static struct sysdev_class ipic_sysclass = { 896static struct sysdev_class ipic_sysclass = {
897 set_kset_name("ipic"), 897 .name = "ipic",
898}; 898};
899 899
900static struct sys_device device_ipic = { 900static struct sys_device device_ipic = {
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 0da7069c7c62..6ffdda244bb1 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1628,7 +1628,7 @@ static struct sysdev_class mpic_sysclass = {
1628 .resume = mpic_resume, 1628 .resume = mpic_resume,
1629 .suspend = mpic_suspend, 1629 .suspend = mpic_suspend,
1630#endif 1630#endif
1631 set_kset_name("mpic"), 1631 .name = "mpic",
1632}; 1632};
1633 1633
1634static int mpic_init_sys(void) 1634static int mpic_init_sys(void)
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c
index 304056cafb1e..efda0028909d 100644
--- a/arch/powerpc/sysdev/mv64x60_dev.c
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -361,12 +361,6 @@ static int __init mv64x60_i2c_device_setup(struct device_node *np, int id)
361 else 361 else
362 pdata.timeout = 1000; /* 1 second */ 362 pdata.timeout = 1000; /* 1 second */
363 363
364 prop = of_get_property(np, "retries", NULL);
365 if (prop)
366 pdata.retries = *prop;
367 else
368 pdata.retries = 1;
369
370 pdev = platform_device_alloc(MV64XXX_I2C_CTLR_NAME, id); 364 pdev = platform_device_alloc(MV64XXX_I2C_CTLR_NAME, id);
371 if (!pdev) 365 if (!pdev)
372 return -ENOMEM; 366 return -ENOMEM;
diff --git a/arch/powerpc/sysdev/qe_lib/qe_ic.c b/arch/powerpc/sysdev/qe_lib/qe_ic.c
index e1c0fd6dbc1a..f59444d3be75 100644
--- a/arch/powerpc/sysdev/qe_lib/qe_ic.c
+++ b/arch/powerpc/sysdev/qe_lib/qe_ic.c
@@ -483,7 +483,7 @@ int qe_ic_set_high_priority(unsigned int virq, unsigned int priority, int high)
483} 483}
484 484
485static struct sysdev_class qe_ic_sysclass = { 485static struct sysdev_class qe_ic_sysclass = {
486 set_kset_name("qe_ic"), 486 .name = "qe_ic",
487}; 487};
488 488
489static struct sys_device device_qe_ic = { 489static struct sys_device device_qe_ic = {