Wu Zhangjin | 85749d2 | 2009-07-02 23:26:45 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology |
| 3 | * Author: Fuxin Zhang, zhangfx@lemote.com |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License as published by the |
| 7 | * Free Software Foundation; either version 2 of the License, or (at your |
| 8 | * option) any later version. |
| 9 | */ |
| 10 | #include <linux/delay.h> |
| 11 | #include <linux/interrupt.h> |
| 12 | |
| 13 | #include <loongson.h> |
| 14 | /* |
| 15 | * the first level int-handler will jump here if it is a bonito irq |
| 16 | */ |
| 17 | void bonito_irqdispatch(void) |
| 18 | { |
| 19 | u32 int_status; |
| 20 | int i; |
| 21 | |
| 22 | /* workaround the IO dma problem: let cpu looping to allow DMA finish */ |
Wu Zhangjin | e2fee57 | 2009-10-16 14:17:19 +0800 | [diff] [blame] | 23 | int_status = LOONGSON_INTISR; |
Shinya Kuribayashi | f5c1ca7 | 2010-06-27 22:52:01 +0900 | [diff] [blame] | 24 | while (int_status & (1 << 10)) { |
| 25 | udelay(1); |
| 26 | int_status = LOONGSON_INTISR; |
Wu Zhangjin | 85749d2 | 2009-07-02 23:26:45 +0800 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | /* Get pending sources, masked by current enables */ |
Wu Zhangjin | e2fee57 | 2009-10-16 14:17:19 +0800 | [diff] [blame] | 30 | int_status = LOONGSON_INTISR & LOONGSON_INTEN; |
Wu Zhangjin | 85749d2 | 2009-07-02 23:26:45 +0800 | [diff] [blame] | 31 | |
Shinya Kuribayashi | f5c1ca7 | 2010-06-27 22:52:01 +0900 | [diff] [blame] | 32 | if (int_status) { |
Wu Zhangjin | 85749d2 | 2009-07-02 23:26:45 +0800 | [diff] [blame] | 33 | i = __ffs(int_status); |
Wu Zhangjin | e2fee57 | 2009-10-16 14:17:19 +0800 | [diff] [blame] | 34 | do_IRQ(LOONGSON_IRQ_BASE + i); |
Wu Zhangjin | 85749d2 | 2009-07-02 23:26:45 +0800 | [diff] [blame] | 35 | } |
| 36 | } |
| 37 | |
| 38 | asmlinkage void plat_irq_dispatch(void) |
| 39 | { |
| 40 | unsigned int pending; |
| 41 | |
| 42 | pending = read_c0_cause() & read_c0_status() & ST0_IM; |
| 43 | |
| 44 | /* machine-specific plat_irq_dispatch */ |
| 45 | mach_irq_dispatch(pending); |
| 46 | } |
| 47 | |
| 48 | void __init arch_init_irq(void) |
| 49 | { |
| 50 | /* |
| 51 | * Clear all of the interrupts while we change the able around a bit. |
| 52 | * int-handler is not on bootstrap |
| 53 | */ |
| 54 | clear_c0_status(ST0_IM | ST0_BEV); |
Wu Zhangjin | 85749d2 | 2009-07-02 23:26:45 +0800 | [diff] [blame] | 55 | |
Wu Zhangjin | 85749d2 | 2009-07-02 23:26:45 +0800 | [diff] [blame] | 56 | /* no steer */ |
Wu Zhangjin | e2fee57 | 2009-10-16 14:17:19 +0800 | [diff] [blame] | 57 | LOONGSON_INTSTEER = 0; |
Wu Zhangjin | 85749d2 | 2009-07-02 23:26:45 +0800 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | * Mask out all interrupt by writing "1" to all bit position in |
| 61 | * the interrupt reset reg. |
| 62 | */ |
Wu Zhangjin | e2fee57 | 2009-10-16 14:17:19 +0800 | [diff] [blame] | 63 | LOONGSON_INTENCLR = ~0; |
Wu Zhangjin | 85749d2 | 2009-07-02 23:26:45 +0800 | [diff] [blame] | 64 | |
| 65 | /* machine specific irq init */ |
| 66 | mach_init_irq(); |
| 67 | } |