diff options
author | Ishizaki Kou <kou.ishizaki@toshiba.co.jp> | 2008-04-24 05:31:40 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-04-24 07:08:14 -0400 |
commit | ad2c6987978d17b58204926e9be776955935f8b1 (patch) | |
tree | 1d2991d1f77f99428efa192051022bd3830b26bb /arch/powerpc/platforms/celleb | |
parent | c11dde85b62f9811eb2db656d9b0b4ad23d94871 (diff) |
[POWERPC] celleb: Move miscellaneous files for Beat
This moves miscellaneous files for Beat into platforms/cell/.
All files in this patch are used by celleb-beat only.
Signed-off-by: Kou Ishizaki <kou.ishizaki@toshiba.co.jp>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms/celleb')
-rw-r--r-- | arch/powerpc/platforms/celleb/Makefile | 5 | ||||
-rw-r--r-- | arch/powerpc/platforms/celleb/beat.c | 264 | ||||
-rw-r--r-- | arch/powerpc/platforms/celleb/beat.h | 39 | ||||
-rw-r--r-- | arch/powerpc/platforms/celleb/interrupt.c | 283 | ||||
-rw-r--r-- | arch/powerpc/platforms/celleb/interrupt.h | 33 | ||||
-rw-r--r-- | arch/powerpc/platforms/celleb/smp.c | 124 | ||||
-rw-r--r-- | arch/powerpc/platforms/celleb/udbg_beat.c | 98 |
7 files changed, 0 insertions, 846 deletions
diff --git a/arch/powerpc/platforms/celleb/Makefile b/arch/powerpc/platforms/celleb/Makefile deleted file mode 100644 index fd9531fe5337..000000000000 --- a/arch/powerpc/platforms/celleb/Makefile +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | obj-y += interrupt.o \ | ||
2 | beat.o | ||
3 | |||
4 | obj-$(CONFIG_SMP) += smp.o | ||
5 | obj-$(CONFIG_PPC_UDBG_BEAT) += udbg_beat.o | ||
diff --git a/arch/powerpc/platforms/celleb/beat.c b/arch/powerpc/platforms/celleb/beat.c deleted file mode 100644 index eb99d0b66470..000000000000 --- a/arch/powerpc/platforms/celleb/beat.c +++ /dev/null | |||
@@ -1,264 +0,0 @@ | |||
1 | /* | ||
2 | * Simple routines for Celleb/Beat | ||
3 | * | ||
4 | * (C) Copyright 2006-2007 TOSHIBA CORPORATION | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/err.h> | ||
24 | #include <linux/rtc.h> | ||
25 | #include <linux/interrupt.h> | ||
26 | #include <linux/irqreturn.h> | ||
27 | #include <linux/reboot.h> | ||
28 | |||
29 | #include <asm/hvconsole.h> | ||
30 | #include <asm/time.h> | ||
31 | #include <asm/machdep.h> | ||
32 | #include <asm/firmware.h> | ||
33 | |||
34 | #include "../cell/beat_wrapper.h" | ||
35 | #include "beat.h" | ||
36 | #include "interrupt.h" | ||
37 | |||
38 | static int beat_pm_poweroff_flag; | ||
39 | |||
40 | void beat_restart(char *cmd) | ||
41 | { | ||
42 | beat_shutdown_logical_partition(!beat_pm_poweroff_flag); | ||
43 | } | ||
44 | |||
45 | void beat_power_off(void) | ||
46 | { | ||
47 | beat_shutdown_logical_partition(0); | ||
48 | } | ||
49 | |||
50 | u64 beat_halt_code = 0x1000000000000000UL; | ||
51 | EXPORT_SYMBOL(beat_halt_code); | ||
52 | |||
53 | void beat_halt(void) | ||
54 | { | ||
55 | beat_shutdown_logical_partition(beat_halt_code); | ||
56 | } | ||
57 | |||
58 | int beat_set_rtc_time(struct rtc_time *rtc_time) | ||
59 | { | ||
60 | u64 tim; | ||
61 | tim = mktime(rtc_time->tm_year+1900, | ||
62 | rtc_time->tm_mon+1, rtc_time->tm_mday, | ||
63 | rtc_time->tm_hour, rtc_time->tm_min, rtc_time->tm_sec); | ||
64 | if (beat_rtc_write(tim)) | ||
65 | return -1; | ||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | void beat_get_rtc_time(struct rtc_time *rtc_time) | ||
70 | { | ||
71 | u64 tim; | ||
72 | |||
73 | if (beat_rtc_read(&tim)) | ||
74 | tim = 0; | ||
75 | to_tm(tim, rtc_time); | ||
76 | rtc_time->tm_year -= 1900; | ||
77 | rtc_time->tm_mon -= 1; | ||
78 | } | ||
79 | |||
80 | #define BEAT_NVRAM_SIZE 4096 | ||
81 | |||
82 | ssize_t beat_nvram_read(char *buf, size_t count, loff_t *index) | ||
83 | { | ||
84 | unsigned int i; | ||
85 | unsigned long len; | ||
86 | char *p = buf; | ||
87 | |||
88 | if (*index >= BEAT_NVRAM_SIZE) | ||
89 | return -ENODEV; | ||
90 | i = *index; | ||
91 | if (i + count > BEAT_NVRAM_SIZE) | ||
92 | count = BEAT_NVRAM_SIZE - i; | ||
93 | |||
94 | for (; count != 0; count -= len) { | ||
95 | len = count; | ||
96 | if (len > BEAT_NVRW_CNT) | ||
97 | len = BEAT_NVRW_CNT; | ||
98 | if (beat_eeprom_read(i, len, p)) | ||
99 | return -EIO; | ||
100 | |||
101 | p += len; | ||
102 | i += len; | ||
103 | } | ||
104 | *index = i; | ||
105 | return p - buf; | ||
106 | } | ||
107 | |||
108 | ssize_t beat_nvram_write(char *buf, size_t count, loff_t *index) | ||
109 | { | ||
110 | unsigned int i; | ||
111 | unsigned long len; | ||
112 | char *p = buf; | ||
113 | |||
114 | if (*index >= BEAT_NVRAM_SIZE) | ||
115 | return -ENODEV; | ||
116 | i = *index; | ||
117 | if (i + count > BEAT_NVRAM_SIZE) | ||
118 | count = BEAT_NVRAM_SIZE - i; | ||
119 | |||
120 | for (; count != 0; count -= len) { | ||
121 | len = count; | ||
122 | if (len > BEAT_NVRW_CNT) | ||
123 | len = BEAT_NVRW_CNT; | ||
124 | if (beat_eeprom_write(i, len, p)) | ||
125 | return -EIO; | ||
126 | |||
127 | p += len; | ||
128 | i += len; | ||
129 | } | ||
130 | *index = i; | ||
131 | return p - buf; | ||
132 | } | ||
133 | |||
134 | ssize_t beat_nvram_get_size(void) | ||
135 | { | ||
136 | return BEAT_NVRAM_SIZE; | ||
137 | } | ||
138 | |||
139 | int beat_set_xdabr(unsigned long dabr) | ||
140 | { | ||
141 | if (beat_set_dabr(dabr, DABRX_KERNEL | DABRX_USER)) | ||
142 | return -1; | ||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | int64_t beat_get_term_char(u64 vterm, u64 *len, u64 *t1, u64 *t2) | ||
147 | { | ||
148 | u64 db[2]; | ||
149 | s64 ret; | ||
150 | |||
151 | ret = beat_get_characters_from_console(vterm, len, (u8 *)db); | ||
152 | if (ret == 0) { | ||
153 | *t1 = db[0]; | ||
154 | *t2 = db[1]; | ||
155 | } | ||
156 | return ret; | ||
157 | } | ||
158 | EXPORT_SYMBOL(beat_get_term_char); | ||
159 | |||
160 | int64_t beat_put_term_char(u64 vterm, u64 len, u64 t1, u64 t2) | ||
161 | { | ||
162 | u64 db[2]; | ||
163 | |||
164 | db[0] = t1; | ||
165 | db[1] = t2; | ||
166 | return beat_put_characters_to_console(vterm, len, (u8 *)db); | ||
167 | } | ||
168 | EXPORT_SYMBOL(beat_put_term_char); | ||
169 | |||
170 | void beat_power_save(void) | ||
171 | { | ||
172 | beat_pause(0); | ||
173 | } | ||
174 | |||
175 | #ifdef CONFIG_KEXEC | ||
176 | void beat_kexec_cpu_down(int crash, int secondary) | ||
177 | { | ||
178 | beatic_deinit_IRQ(); | ||
179 | } | ||
180 | #endif | ||
181 | |||
182 | static irqreturn_t beat_power_event(int virq, void *arg) | ||
183 | { | ||
184 | printk(KERN_DEBUG "Beat: power button pressed\n"); | ||
185 | beat_pm_poweroff_flag = 1; | ||
186 | ctrl_alt_del(); | ||
187 | return IRQ_HANDLED; | ||
188 | } | ||
189 | |||
190 | static irqreturn_t beat_reset_event(int virq, void *arg) | ||
191 | { | ||
192 | printk(KERN_DEBUG "Beat: reset button pressed\n"); | ||
193 | beat_pm_poweroff_flag = 0; | ||
194 | ctrl_alt_del(); | ||
195 | return IRQ_HANDLED; | ||
196 | } | ||
197 | |||
198 | static struct beat_event_list { | ||
199 | const char *typecode; | ||
200 | irq_handler_t handler; | ||
201 | unsigned int virq; | ||
202 | } beat_event_list[] = { | ||
203 | { "power", beat_power_event, 0 }, | ||
204 | { "reset", beat_reset_event, 0 }, | ||
205 | }; | ||
206 | |||
207 | static int __init beat_register_event(void) | ||
208 | { | ||
209 | u64 path[4], data[2]; | ||
210 | int rc, i; | ||
211 | unsigned int virq; | ||
212 | |||
213 | for (i = 0; i < ARRAY_SIZE(beat_event_list); i++) { | ||
214 | struct beat_event_list *ev = &beat_event_list[i]; | ||
215 | |||
216 | if (beat_construct_event_receive_port(data) != 0) { | ||
217 | printk(KERN_ERR "Beat: " | ||
218 | "cannot construct event receive port for %s\n", | ||
219 | ev->typecode); | ||
220 | return -EINVAL; | ||
221 | } | ||
222 | |||
223 | virq = irq_create_mapping(NULL, data[0]); | ||
224 | if (virq == NO_IRQ) { | ||
225 | printk(KERN_ERR "Beat: failed to get virtual IRQ" | ||
226 | " for event receive port for %s\n", | ||
227 | ev->typecode); | ||
228 | beat_destruct_event_receive_port(data[0]); | ||
229 | return -EIO; | ||
230 | } | ||
231 | ev->virq = virq; | ||
232 | |||
233 | rc = request_irq(virq, ev->handler, IRQF_DISABLED, | ||
234 | ev->typecode, NULL); | ||
235 | if (rc != 0) { | ||
236 | printk(KERN_ERR "Beat: failed to request virtual IRQ" | ||
237 | " for event receive port for %s\n", | ||
238 | ev->typecode); | ||
239 | beat_destruct_event_receive_port(data[0]); | ||
240 | return rc; | ||
241 | } | ||
242 | |||
243 | path[0] = 0x1000000065780000ul; /* 1,ex */ | ||
244 | path[1] = 0x627574746f6e0000ul; /* button */ | ||
245 | path[2] = 0; | ||
246 | strncpy((char *)&path[2], ev->typecode, 8); | ||
247 | path[3] = 0; | ||
248 | data[1] = 0; | ||
249 | |||
250 | beat_create_repository_node(path, data); | ||
251 | } | ||
252 | return 0; | ||
253 | } | ||
254 | |||
255 | static int __init beat_event_init(void) | ||
256 | { | ||
257 | if (!firmware_has_feature(FW_FEATURE_BEAT)) | ||
258 | return -EINVAL; | ||
259 | |||
260 | beat_pm_poweroff_flag = 0; | ||
261 | return beat_register_event(); | ||
262 | } | ||
263 | |||
264 | device_initcall(beat_event_init); | ||
diff --git a/arch/powerpc/platforms/celleb/beat.h b/arch/powerpc/platforms/celleb/beat.h deleted file mode 100644 index 32c8efcedc80..000000000000 --- a/arch/powerpc/platforms/celleb/beat.h +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | /* | ||
2 | * Guest OS Interfaces. | ||
3 | * | ||
4 | * (C) Copyright 2006 TOSHIBA CORPORATION | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef _CELLEB_BEAT_H | ||
22 | #define _CELLEB_BEAT_H | ||
23 | |||
24 | int64_t beat_get_term_char(uint64_t, uint64_t *, uint64_t *, uint64_t *); | ||
25 | int64_t beat_put_term_char(uint64_t, uint64_t, uint64_t, uint64_t); | ||
26 | int64_t beat_repository_encode(int, const char *, uint64_t[4]); | ||
27 | void beat_restart(char *); | ||
28 | void beat_power_off(void); | ||
29 | void beat_halt(void); | ||
30 | int beat_set_rtc_time(struct rtc_time *); | ||
31 | void beat_get_rtc_time(struct rtc_time *); | ||
32 | ssize_t beat_nvram_get_size(void); | ||
33 | ssize_t beat_nvram_read(char *, size_t, loff_t *); | ||
34 | ssize_t beat_nvram_write(char *, size_t, loff_t *); | ||
35 | int beat_set_xdabr(unsigned long); | ||
36 | void beat_power_save(void); | ||
37 | void beat_kexec_cpu_down(int, int); | ||
38 | |||
39 | #endif /* _CELLEB_BEAT_H */ | ||
diff --git a/arch/powerpc/platforms/celleb/interrupt.c b/arch/powerpc/platforms/celleb/interrupt.c deleted file mode 100644 index bb7bdad95e4c..000000000000 --- a/arch/powerpc/platforms/celleb/interrupt.c +++ /dev/null | |||
@@ -1,283 +0,0 @@ | |||
1 | /* | ||
2 | * Celleb/Beat Interrupt controller | ||
3 | * | ||
4 | * (C) Copyright 2006-2007 TOSHIBA CORPORATION | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/init.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/irq.h> | ||
24 | #include <linux/percpu.h> | ||
25 | #include <linux/types.h> | ||
26 | |||
27 | #include <asm/machdep.h> | ||
28 | |||
29 | #include "interrupt.h" | ||
30 | #include "../cell/beat_wrapper.h" | ||
31 | |||
32 | #define MAX_IRQS NR_IRQS | ||
33 | static DEFINE_SPINLOCK(beatic_irq_mask_lock); | ||
34 | static uint64_t beatic_irq_mask_enable[(MAX_IRQS+255)/64]; | ||
35 | static uint64_t beatic_irq_mask_ack[(MAX_IRQS+255)/64]; | ||
36 | |||
37 | static struct irq_host *beatic_host; | ||
38 | |||
39 | /* | ||
40 | * In this implementation, "virq" == "IRQ plug number", | ||
41 | * "(irq_hw_number_t)hwirq" == "IRQ outlet number". | ||
42 | */ | ||
43 | |||
44 | /* assumption: locked */ | ||
45 | static inline void beatic_update_irq_mask(unsigned int irq_plug) | ||
46 | { | ||
47 | int off; | ||
48 | unsigned long masks[4]; | ||
49 | |||
50 | off = (irq_plug / 256) * 4; | ||
51 | masks[0] = beatic_irq_mask_enable[off + 0] | ||
52 | & beatic_irq_mask_ack[off + 0]; | ||
53 | masks[1] = beatic_irq_mask_enable[off + 1] | ||
54 | & beatic_irq_mask_ack[off + 1]; | ||
55 | masks[2] = beatic_irq_mask_enable[off + 2] | ||
56 | & beatic_irq_mask_ack[off + 2]; | ||
57 | masks[3] = beatic_irq_mask_enable[off + 3] | ||
58 | & beatic_irq_mask_ack[off + 3]; | ||
59 | if (beat_set_interrupt_mask(irq_plug&~255UL, | ||
60 | masks[0], masks[1], masks[2], masks[3]) != 0) | ||
61 | panic("Failed to set mask IRQ!"); | ||
62 | } | ||
63 | |||
64 | static void beatic_mask_irq(unsigned int irq_plug) | ||
65 | { | ||
66 | unsigned long flags; | ||
67 | |||
68 | spin_lock_irqsave(&beatic_irq_mask_lock, flags); | ||
69 | beatic_irq_mask_enable[irq_plug/64] &= ~(1UL << (63 - (irq_plug%64))); | ||
70 | beatic_update_irq_mask(irq_plug); | ||
71 | spin_unlock_irqrestore(&beatic_irq_mask_lock, flags); | ||
72 | } | ||
73 | |||
74 | static void beatic_unmask_irq(unsigned int irq_plug) | ||
75 | { | ||
76 | unsigned long flags; | ||
77 | |||
78 | spin_lock_irqsave(&beatic_irq_mask_lock, flags); | ||
79 | beatic_irq_mask_enable[irq_plug/64] |= 1UL << (63 - (irq_plug%64)); | ||
80 | beatic_update_irq_mask(irq_plug); | ||
81 | spin_unlock_irqrestore(&beatic_irq_mask_lock, flags); | ||
82 | } | ||
83 | |||
84 | static void beatic_ack_irq(unsigned int irq_plug) | ||
85 | { | ||
86 | unsigned long flags; | ||
87 | |||
88 | spin_lock_irqsave(&beatic_irq_mask_lock, flags); | ||
89 | beatic_irq_mask_ack[irq_plug/64] &= ~(1UL << (63 - (irq_plug%64))); | ||
90 | beatic_update_irq_mask(irq_plug); | ||
91 | spin_unlock_irqrestore(&beatic_irq_mask_lock, flags); | ||
92 | } | ||
93 | |||
94 | static void beatic_end_irq(unsigned int irq_plug) | ||
95 | { | ||
96 | s64 err; | ||
97 | unsigned long flags; | ||
98 | |||
99 | err = beat_downcount_of_interrupt(irq_plug); | ||
100 | if (err != 0) { | ||
101 | if ((err & 0xFFFFFFFF) != 0xFFFFFFF5) /* -11: wrong state */ | ||
102 | panic("Failed to downcount IRQ! Error = %16lx", err); | ||
103 | |||
104 | printk(KERN_ERR "IRQ over-downcounted, plug %d\n", irq_plug); | ||
105 | } | ||
106 | spin_lock_irqsave(&beatic_irq_mask_lock, flags); | ||
107 | beatic_irq_mask_ack[irq_plug/64] |= 1UL << (63 - (irq_plug%64)); | ||
108 | beatic_update_irq_mask(irq_plug); | ||
109 | spin_unlock_irqrestore(&beatic_irq_mask_lock, flags); | ||
110 | } | ||
111 | |||
112 | static struct irq_chip beatic_pic = { | ||
113 | .typename = " CELL-BEAT ", | ||
114 | .unmask = beatic_unmask_irq, | ||
115 | .mask = beatic_mask_irq, | ||
116 | .eoi = beatic_end_irq, | ||
117 | }; | ||
118 | |||
119 | /* | ||
120 | * Dispose binding hardware IRQ number (hw) and Virtuql IRQ number (virq), | ||
121 | * update flags. | ||
122 | * | ||
123 | * Note that the number (virq) is already assigned at upper layer. | ||
124 | */ | ||
125 | static void beatic_pic_host_unmap(struct irq_host *h, unsigned int virq) | ||
126 | { | ||
127 | beat_destruct_irq_plug(virq); | ||
128 | } | ||
129 | |||
130 | /* | ||
131 | * Create or update binding hardware IRQ number (hw) and Virtuql | ||
132 | * IRQ number (virq). This is called only once for a given mapping. | ||
133 | * | ||
134 | * Note that the number (virq) is already assigned at upper layer. | ||
135 | */ | ||
136 | static int beatic_pic_host_map(struct irq_host *h, unsigned int virq, | ||
137 | irq_hw_number_t hw) | ||
138 | { | ||
139 | struct irq_desc *desc = get_irq_desc(virq); | ||
140 | int64_t err; | ||
141 | |||
142 | err = beat_construct_and_connect_irq_plug(virq, hw); | ||
143 | if (err < 0) | ||
144 | return -EIO; | ||
145 | |||
146 | desc->status |= IRQ_LEVEL; | ||
147 | set_irq_chip_and_handler(virq, &beatic_pic, handle_fasteoi_irq); | ||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | /* | ||
152 | * Update binding hardware IRQ number (hw) and Virtuql | ||
153 | * IRQ number (virq). This is called only once for a given mapping. | ||
154 | */ | ||
155 | static void beatic_pic_host_remap(struct irq_host *h, unsigned int virq, | ||
156 | irq_hw_number_t hw) | ||
157 | { | ||
158 | beat_construct_and_connect_irq_plug(virq, hw); | ||
159 | } | ||
160 | |||
161 | /* | ||
162 | * Translate device-tree interrupt spec to irq_hw_number_t style (ulong), | ||
163 | * to pass away to irq_create_mapping(). | ||
164 | * | ||
165 | * Called from irq_create_of_mapping() only. | ||
166 | * Note: We have only 1 entry to translate. | ||
167 | */ | ||
168 | static int beatic_pic_host_xlate(struct irq_host *h, struct device_node *ct, | ||
169 | u32 *intspec, unsigned int intsize, | ||
170 | irq_hw_number_t *out_hwirq, | ||
171 | unsigned int *out_flags) | ||
172 | { | ||
173 | u64 *intspec2 = (u64 *)intspec; | ||
174 | |||
175 | *out_hwirq = *intspec2; | ||
176 | *out_flags |= IRQ_TYPE_LEVEL_LOW; | ||
177 | return 0; | ||
178 | } | ||
179 | |||
180 | static int beatic_pic_host_match(struct irq_host *h, struct device_node *np) | ||
181 | { | ||
182 | /* Match all */ | ||
183 | return 1; | ||
184 | } | ||
185 | |||
186 | static struct irq_host_ops beatic_pic_host_ops = { | ||
187 | .map = beatic_pic_host_map, | ||
188 | .remap = beatic_pic_host_remap, | ||
189 | .unmap = beatic_pic_host_unmap, | ||
190 | .xlate = beatic_pic_host_xlate, | ||
191 | .match = beatic_pic_host_match, | ||
192 | }; | ||
193 | |||
194 | /* | ||
195 | * Get an IRQ number | ||
196 | * Note: returns VIRQ | ||
197 | */ | ||
198 | static inline unsigned int beatic_get_irq_plug(void) | ||
199 | { | ||
200 | int i; | ||
201 | uint64_t pending[4], ub; | ||
202 | |||
203 | for (i = 0; i < MAX_IRQS; i += 256) { | ||
204 | beat_detect_pending_interrupts(i, pending); | ||
205 | __asm__ ("cntlzd %0,%1":"=r"(ub): | ||
206 | "r"(pending[0] & beatic_irq_mask_enable[i/64+0] | ||
207 | & beatic_irq_mask_ack[i/64+0])); | ||
208 | if (ub != 64) | ||
209 | return i + ub + 0; | ||
210 | __asm__ ("cntlzd %0,%1":"=r"(ub): | ||
211 | "r"(pending[1] & beatic_irq_mask_enable[i/64+1] | ||
212 | & beatic_irq_mask_ack[i/64+1])); | ||
213 | if (ub != 64) | ||
214 | return i + ub + 64; | ||
215 | __asm__ ("cntlzd %0,%1":"=r"(ub): | ||
216 | "r"(pending[2] & beatic_irq_mask_enable[i/64+2] | ||
217 | & beatic_irq_mask_ack[i/64+2])); | ||
218 | if (ub != 64) | ||
219 | return i + ub + 128; | ||
220 | __asm__ ("cntlzd %0,%1":"=r"(ub): | ||
221 | "r"(pending[3] & beatic_irq_mask_enable[i/64+3] | ||
222 | & beatic_irq_mask_ack[i/64+3])); | ||
223 | if (ub != 64) | ||
224 | return i + ub + 192; | ||
225 | } | ||
226 | |||
227 | return NO_IRQ; | ||
228 | } | ||
229 | unsigned int beatic_get_irq(void) | ||
230 | { | ||
231 | unsigned int ret; | ||
232 | |||
233 | ret = beatic_get_irq_plug(); | ||
234 | if (ret != NO_IRQ) | ||
235 | beatic_ack_irq(ret); | ||
236 | return ret; | ||
237 | } | ||
238 | |||
239 | /* | ||
240 | */ | ||
241 | void __init beatic_init_IRQ(void) | ||
242 | { | ||
243 | int i; | ||
244 | |||
245 | memset(beatic_irq_mask_enable, 0, sizeof(beatic_irq_mask_enable)); | ||
246 | memset(beatic_irq_mask_ack, 255, sizeof(beatic_irq_mask_ack)); | ||
247 | for (i = 0; i < MAX_IRQS; i += 256) | ||
248 | beat_set_interrupt_mask(i, 0L, 0L, 0L, 0L); | ||
249 | |||
250 | /* Set out get_irq function */ | ||
251 | ppc_md.get_irq = beatic_get_irq; | ||
252 | |||
253 | /* Allocate an irq host */ | ||
254 | beatic_host = irq_alloc_host(NULL, IRQ_HOST_MAP_NOMAP, 0, | ||
255 | &beatic_pic_host_ops, | ||
256 | 0); | ||
257 | BUG_ON(beatic_host == NULL); | ||
258 | irq_set_default_host(beatic_host); | ||
259 | } | ||
260 | |||
261 | #ifdef CONFIG_SMP | ||
262 | |||
263 | /* Nullified to compile with SMP mode */ | ||
264 | void beatic_setup_cpu(int cpu) | ||
265 | { | ||
266 | } | ||
267 | |||
268 | void beatic_cause_IPI(int cpu, int mesg) | ||
269 | { | ||
270 | } | ||
271 | |||
272 | void beatic_request_IPIs(void) | ||
273 | { | ||
274 | } | ||
275 | #endif /* CONFIG_SMP */ | ||
276 | |||
277 | void beatic_deinit_IRQ(void) | ||
278 | { | ||
279 | int i; | ||
280 | |||
281 | for (i = 1; i < NR_IRQS; i++) | ||
282 | beat_destruct_irq_plug(i); | ||
283 | } | ||
diff --git a/arch/powerpc/platforms/celleb/interrupt.h b/arch/powerpc/platforms/celleb/interrupt.h deleted file mode 100644 index b470fd0051f1..000000000000 --- a/arch/powerpc/platforms/celleb/interrupt.h +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | /* | ||
2 | * Celleb/Beat Interrupt controller | ||
3 | * | ||
4 | * (C) Copyright 2006 TOSHIBA CORPORATION | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef ASM_BEAT_PIC_H | ||
22 | #define ASM_BEAT_PIC_H | ||
23 | #ifdef __KERNEL__ | ||
24 | |||
25 | extern void beatic_init_IRQ(void); | ||
26 | extern unsigned int beatic_get_irq(void); | ||
27 | extern void beatic_cause_IPI(int cpu, int mesg); | ||
28 | extern void beatic_request_IPIs(void); | ||
29 | extern void beatic_setup_cpu(int); | ||
30 | extern void beatic_deinit_IRQ(void); | ||
31 | |||
32 | #endif | ||
33 | #endif /* ASM_BEAT_PIC_H */ | ||
diff --git a/arch/powerpc/platforms/celleb/smp.c b/arch/powerpc/platforms/celleb/smp.c deleted file mode 100644 index a7631250aeb4..000000000000 --- a/arch/powerpc/platforms/celleb/smp.c +++ /dev/null | |||
@@ -1,124 +0,0 @@ | |||
1 | /* | ||
2 | * SMP support for Celleb platform. (Incomplete) | ||
3 | * | ||
4 | * (C) Copyright 2006 TOSHIBA CORPORATION | ||
5 | * | ||
6 | * This code is based on arch/powerpc/platforms/cell/smp.c: | ||
7 | * Dave Engebretsen, Peter Bergner, and | ||
8 | * Mike Corrigan {engebret|bergner|mikec}@us.ibm.com | ||
9 | * Plus various changes from other IBM teams... | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License along | ||
22 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
24 | */ | ||
25 | |||
26 | #undef DEBUG | ||
27 | |||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/smp.h> | ||
30 | #include <linux/interrupt.h> | ||
31 | #include <linux/init.h> | ||
32 | #include <linux/threads.h> | ||
33 | #include <linux/cpu.h> | ||
34 | |||
35 | #include <asm/irq.h> | ||
36 | #include <asm/smp.h> | ||
37 | #include <asm/machdep.h> | ||
38 | #include <asm/udbg.h> | ||
39 | |||
40 | #include "interrupt.h" | ||
41 | |||
42 | #ifdef DEBUG | ||
43 | #define DBG(fmt...) udbg_printf(fmt) | ||
44 | #else | ||
45 | #define DBG(fmt...) | ||
46 | #endif | ||
47 | |||
48 | /* | ||
49 | * The primary thread of each non-boot processor is recorded here before | ||
50 | * smp init. | ||
51 | */ | ||
52 | /* static cpumask_t of_spin_map; */ | ||
53 | |||
54 | /** | ||
55 | * smp_startup_cpu() - start the given cpu | ||
56 | * | ||
57 | * At boot time, there is nothing to do for primary threads which were | ||
58 | * started from Open Firmware. For anything else, call RTAS with the | ||
59 | * appropriate start location. | ||
60 | * | ||
61 | * Returns: | ||
62 | * 0 - failure | ||
63 | * 1 - success | ||
64 | */ | ||
65 | static inline int __devinit smp_startup_cpu(unsigned int lcpu) | ||
66 | { | ||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | static void smp_beatic_message_pass(int target, int msg) | ||
71 | { | ||
72 | unsigned int i; | ||
73 | |||
74 | if (target < NR_CPUS) { | ||
75 | beatic_cause_IPI(target, msg); | ||
76 | } else { | ||
77 | for_each_online_cpu(i) { | ||
78 | if (target == MSG_ALL_BUT_SELF | ||
79 | && i == smp_processor_id()) | ||
80 | continue; | ||
81 | beatic_cause_IPI(i, msg); | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | |||
86 | static int __init smp_beatic_probe(void) | ||
87 | { | ||
88 | return cpus_weight(cpu_possible_map); | ||
89 | } | ||
90 | |||
91 | static void __devinit smp_beatic_setup_cpu(int cpu) | ||
92 | { | ||
93 | beatic_setup_cpu(cpu); | ||
94 | } | ||
95 | |||
96 | static void __devinit smp_celleb_kick_cpu(int nr) | ||
97 | { | ||
98 | BUG_ON(nr < 0 || nr >= NR_CPUS); | ||
99 | |||
100 | if (!smp_startup_cpu(nr)) | ||
101 | return; | ||
102 | } | ||
103 | |||
104 | static int smp_celleb_cpu_bootable(unsigned int nr) | ||
105 | { | ||
106 | return 1; | ||
107 | } | ||
108 | static struct smp_ops_t bpa_beatic_smp_ops = { | ||
109 | .message_pass = smp_beatic_message_pass, | ||
110 | .probe = smp_beatic_probe, | ||
111 | .kick_cpu = smp_celleb_kick_cpu, | ||
112 | .setup_cpu = smp_beatic_setup_cpu, | ||
113 | .cpu_bootable = smp_celleb_cpu_bootable, | ||
114 | }; | ||
115 | |||
116 | /* This is called very early */ | ||
117 | void __init smp_init_celleb(void) | ||
118 | { | ||
119 | DBG(" -> smp_init_celleb()\n"); | ||
120 | |||
121 | smp_ops = &bpa_beatic_smp_ops; | ||
122 | |||
123 | DBG(" <- smp_init_celleb()\n"); | ||
124 | } | ||
diff --git a/arch/powerpc/platforms/celleb/udbg_beat.c b/arch/powerpc/platforms/celleb/udbg_beat.c deleted file mode 100644 index 6b418f6b6175..000000000000 --- a/arch/powerpc/platforms/celleb/udbg_beat.c +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | /* | ||
2 | * udbg function for Beat | ||
3 | * | ||
4 | * (C) Copyright 2006 TOSHIBA CORPORATION | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/console.h> | ||
23 | |||
24 | #include <asm/machdep.h> | ||
25 | #include <asm/prom.h> | ||
26 | #include <asm/udbg.h> | ||
27 | |||
28 | #include "beat.h" | ||
29 | |||
30 | #define celleb_vtermno 0 | ||
31 | |||
32 | static void udbg_putc_beat(char c) | ||
33 | { | ||
34 | unsigned long rc; | ||
35 | |||
36 | if (c == '\n') | ||
37 | udbg_putc_beat('\r'); | ||
38 | |||
39 | rc = beat_put_term_char(celleb_vtermno, 1, (uint64_t)c << 56, 0); | ||
40 | } | ||
41 | |||
42 | /* Buffered chars getc */ | ||
43 | static long inbuflen; | ||
44 | static long inbuf[2]; /* must be 2 longs */ | ||
45 | |||
46 | static int udbg_getc_poll_beat(void) | ||
47 | { | ||
48 | /* The interface is tricky because it may return up to 16 chars. | ||
49 | * We save them statically for future calls to udbg_getc(). | ||
50 | */ | ||
51 | char ch, *buf = (char *)inbuf; | ||
52 | int i; | ||
53 | long rc; | ||
54 | if (inbuflen == 0) { | ||
55 | /* get some more chars. */ | ||
56 | inbuflen = 0; | ||
57 | rc = beat_get_term_char(celleb_vtermno, &inbuflen, | ||
58 | inbuf+0, inbuf+1); | ||
59 | if (rc != 0) | ||
60 | inbuflen = 0; /* otherwise inbuflen is garbage */ | ||
61 | } | ||
62 | if (inbuflen <= 0 || inbuflen > 16) { | ||
63 | /* Catch error case as well as other oddities (corruption) */ | ||
64 | inbuflen = 0; | ||
65 | return -1; | ||
66 | } | ||
67 | ch = buf[0]; | ||
68 | for (i = 1; i < inbuflen; i++) /* shuffle them down. */ | ||
69 | buf[i-1] = buf[i]; | ||
70 | inbuflen--; | ||
71 | return ch; | ||
72 | } | ||
73 | |||
74 | static int udbg_getc_beat(void) | ||
75 | { | ||
76 | int ch; | ||
77 | for (;;) { | ||
78 | ch = udbg_getc_poll_beat(); | ||
79 | if (ch == -1) { | ||
80 | /* This shouldn't be needed...but... */ | ||
81 | volatile unsigned long delay; | ||
82 | for (delay = 0; delay < 2000000; delay++) | ||
83 | ; | ||
84 | } else { | ||
85 | return ch; | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | |||
90 | /* call this from early_init() for a working debug console on | ||
91 | * vterm capable LPAR machines | ||
92 | */ | ||
93 | void __init udbg_init_debug_beat(void) | ||
94 | { | ||
95 | udbg_putc = udbg_putc_beat; | ||
96 | udbg_getc = udbg_getc_beat; | ||
97 | udbg_getc_poll = udbg_getc_poll_beat; | ||
98 | } | ||