11 #include <asm/timer.h>
12 #include <asm/traps.h>
16 #include <asm/cacheflush.h>
17 #include <asm/setup.h>
18 #include <asm/oplib.h>
36 static unsigned int sun4d_encode_irq(
int board,
int lvl,
int slot)
38 return (board + 1) << 5 | (lvl << 2) | slot;
51 #define SUN4D_TIMER_IRQ 10
56 static unsigned char board_to_cpu[32];
58 static int pil_to_sbus[] = {
96 static void sun4d_sbus_handler_irq(
int sbusl)
98 unsigned int bus_mask;
99 unsigned int sbino,
slot;
102 bus_mask = bw_get_intr_mask(sbusl) & 0x3ffff;
103 bw_clear_intr_mask(sbusl, bus_mask);
107 for (sbino = 0; bus_mask; sbino++, bus_mask >>= 1) {
117 mask = acquire_sbi(
SBI2DEVID(sbino), 0xf << sbil);
118 mask &= (0xf << sbil);
122 for (idx = 0; mask != 0; idx++, slot <<= 1) {
130 pil = sun4d_encode_irq(sbino, sbusl, idx);
149 int sbusl = pil_to_sbus[pil];
154 cc_set_iclr(1 << pil);
161 if (pil == SUN4D_IPI_IRQ)
165 old_regs = set_irq_regs(regs);
181 sun4d_sbus_handler_irq(sbusl);
184 set_irq_regs(old_regs);
199 cc_set_imsk_other(cpuid, cc_get_imsk_other(cpuid) | (1 << real_irq));
200 spin_unlock_irqrestore(&sun4d_imsk_lock, flags);
202 cc_set_imsk(cc_get_imsk() | (1 << real_irq));
206 static void sun4d_unmask_irq(
struct irq_data *data)
211 int cpuid = handler_data->
cpuid;
218 cc_set_imsk_other(cpuid, cc_get_imsk_other(cpuid) & ~(1 << real_irq));
219 spin_unlock_irqrestore(&sun4d_imsk_lock, flags);
221 cc_set_imsk(cc_get_imsk() & ~(1 << real_irq));
225 static unsigned int sun4d_startup_irq(
struct irq_data *data)
228 sun4d_unmask_irq(data);
232 static void sun4d_shutdown_irq(
struct irq_data *data)
234 sun4d_mask_irq(data);
240 .irq_startup = sun4d_startup_irq,
241 .irq_shutdown = sun4d_shutdown_irq,
242 .irq_unmask = sun4d_unmask_irq,
243 .irq_mask = sun4d_mask_irq,
248 void __init sun4d_distribute_irqs(
void)
256 for_each_node_by_name(dp,
"sbi") {
259 board_to_cpu[board] =
cpuid;
260 set_sbi_tid(devid, cpuid << 3);
266 static void sun4d_clear_clock_irq(
void)
271 static void sun4d_load_profile_irq(
int cpu,
unsigned int limit)
273 unsigned int value = limit ? timer_value(limit) : 0;
274 bw_set_prof_limit(cpu, value);
277 static void __init sun4d_load_profile_irqs(
void)
282 sun4d_load_profile_irq(
mid >> 3, 0);
297 real_irq, pil, board);
301 handler_data = irq_get_handler_data(irq);
307 prom_printf(
"IRQ: kzalloc(sun4d_handler_data) failed.\n");
310 handler_data->
cpuid = board_to_cpu[board];
323 unsigned int real_irq)
327 char *bus_connection;
337 bus_connection =
"io-unit";
342 bus_connection =
"cpu-unit";
366 board_parent = bus->
parent;
374 sbusl = pil_to_sbus[real_irq];
376 pil = sun4d_encode_irq(board, sbusl, slot);
391 static void __init sun4d_fixup_trap_table(
void)
398 lvl14_save[2] += smp4d_ticker - real_irq_entry;
405 patchme_maybe_smp_msg[0] = 0x01000000;
406 trap_table->
inst_one = lvl14_save[0];
407 trap_table->
inst_two = lvl14_save[1];
410 local_ops->cache_all();
415 static void __init sun4d_init_timers(
void)
426 prom_printf(
"sun4d_init_timers: Unable to find cpu-unit\n");
436 prom_printf(
"sun4d_init_timers: No reg property\n");
442 prom_printf(
"sun4d_init_timers: No board# property on cpu-unit\n");
449 res.end = reg[2] - 1;
450 res.flags = reg[0] & 0xff;
454 prom_printf(
"sun4d_init_timers: Can't map timer regs\n");
473 prom_printf(
"sun4d_init_timers: request_irq() failed with %d\n",
477 sun4d_load_profile_irqs();
478 sun4d_fixup_trap_table();
487 for_each_node_by_name(dp,
"sbi") {
492 set_sbi_tid(devid, target_cpu << 3);
493 board_to_cpu[board] = target_cpu;
496 mask = acquire_sbi(devid, 0xffffffff);
500 release_sbi(devid, mask);