diff options
Diffstat (limited to 'arch/mn10300')
-rw-r--r-- | arch/mn10300/kernel/irq.c | 71 | ||||
-rw-r--r-- | arch/mn10300/kernel/time.c | 52 | ||||
-rw-r--r-- | arch/mn10300/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/mn10300/unit-asb2303/unit-init.c | 2 | ||||
-rw-r--r-- | arch/mn10300/unit-asb2305/unit-init.c | 2 |
5 files changed, 89 insertions, 40 deletions
diff --git a/arch/mn10300/kernel/irq.c b/arch/mn10300/kernel/irq.c index 761c434a2488..56c64ccc9c21 100644 --- a/arch/mn10300/kernel/irq.c +++ b/arch/mn10300/kernel/irq.c | |||
@@ -20,22 +20,8 @@ EXPORT_SYMBOL(__mn10300_irq_enabled_epsw); | |||
20 | atomic_t irq_err_count; | 20 | atomic_t irq_err_count; |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * MN10300 INTC controller operations | 23 | * MN10300 interrupt controller operations |
24 | */ | 24 | */ |
25 | static void mn10300_cpupic_disable(unsigned int irq) | ||
26 | { | ||
27 | u16 tmp = GxICR(irq); | ||
28 | GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_DETECT; | ||
29 | tmp = GxICR(irq); | ||
30 | } | ||
31 | |||
32 | static void mn10300_cpupic_enable(unsigned int irq) | ||
33 | { | ||
34 | u16 tmp = GxICR(irq); | ||
35 | GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE; | ||
36 | tmp = GxICR(irq); | ||
37 | } | ||
38 | |||
39 | static void mn10300_cpupic_ack(unsigned int irq) | 25 | static void mn10300_cpupic_ack(unsigned int irq) |
40 | { | 26 | { |
41 | u16 tmp; | 27 | u16 tmp; |
@@ -60,26 +46,54 @@ static void mn10300_cpupic_mask_ack(unsigned int irq) | |||
60 | static void mn10300_cpupic_unmask(unsigned int irq) | 46 | static void mn10300_cpupic_unmask(unsigned int irq) |
61 | { | 47 | { |
62 | u16 tmp = GxICR(irq); | 48 | u16 tmp = GxICR(irq); |
63 | GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE | GxICR_DETECT; | 49 | GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE; |
64 | tmp = GxICR(irq); | 50 | tmp = GxICR(irq); |
65 | } | 51 | } |
66 | 52 | ||
67 | static void mn10300_cpupic_end(unsigned int irq) | 53 | static void mn10300_cpupic_unmask_clear(unsigned int irq) |
68 | { | 54 | { |
55 | /* the MN10300 PIC latches its interrupt request bit, even after the | ||
56 | * device has ceased to assert its interrupt line and the interrupt | ||
57 | * channel has been disabled in the PIC, so for level-triggered | ||
58 | * interrupts we need to clear the request bit when we re-enable */ | ||
69 | u16 tmp = GxICR(irq); | 59 | u16 tmp = GxICR(irq); |
70 | GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE; | 60 | GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE | GxICR_DETECT; |
71 | tmp = GxICR(irq); | 61 | tmp = GxICR(irq); |
72 | } | 62 | } |
73 | 63 | ||
74 | static struct irq_chip mn10300_cpu_pic = { | 64 | /* |
75 | .name = "cpu", | 65 | * MN10300 PIC level-triggered IRQ handling. |
76 | .disable = mn10300_cpupic_disable, | 66 | * |
77 | .enable = mn10300_cpupic_enable, | 67 | * The PIC has no 'ACK' function per se. It is possible to clear individual |
68 | * channel latches, but each latch relatches whether or not the channel is | ||
69 | * masked, so we need to clear the latch when we unmask the channel. | ||
70 | * | ||
71 | * Also for this reason, we don't supply an ack() op (it's unused anyway if | ||
72 | * mask_ack() is provided), and mask_ack() just masks. | ||
73 | */ | ||
74 | static struct irq_chip mn10300_cpu_pic_level = { | ||
75 | .name = "cpu_l", | ||
76 | .disable = mn10300_cpupic_mask, | ||
77 | .enable = mn10300_cpupic_unmask_clear, | ||
78 | .ack = NULL, | ||
79 | .mask = mn10300_cpupic_mask, | ||
80 | .mask_ack = mn10300_cpupic_mask, | ||
81 | .unmask = mn10300_cpupic_unmask_clear, | ||
82 | }; | ||
83 | |||
84 | /* | ||
85 | * MN10300 PIC edge-triggered IRQ handling. | ||
86 | * | ||
87 | * We use the latch clearing function of the PIC as the 'ACK' function. | ||
88 | */ | ||
89 | static struct irq_chip mn10300_cpu_pic_edge = { | ||
90 | .name = "cpu_e", | ||
91 | .disable = mn10300_cpupic_mask, | ||
92 | .enable = mn10300_cpupic_unmask, | ||
78 | .ack = mn10300_cpupic_ack, | 93 | .ack = mn10300_cpupic_ack, |
79 | .mask = mn10300_cpupic_mask, | 94 | .mask = mn10300_cpupic_mask, |
80 | .mask_ack = mn10300_cpupic_mask_ack, | 95 | .mask_ack = mn10300_cpupic_mask_ack, |
81 | .unmask = mn10300_cpupic_unmask, | 96 | .unmask = mn10300_cpupic_unmask, |
82 | .end = mn10300_cpupic_end, | ||
83 | }; | 97 | }; |
84 | 98 | ||
85 | /* | 99 | /* |
@@ -114,7 +128,8 @@ void set_intr_level(int irq, u16 level) | |||
114 | */ | 128 | */ |
115 | void set_intr_postackable(int irq) | 129 | void set_intr_postackable(int irq) |
116 | { | 130 | { |
117 | set_irq_handler(irq, handle_level_irq); | 131 | set_irq_chip_and_handler(irq, &mn10300_cpu_pic_level, |
132 | handle_level_irq); | ||
118 | } | 133 | } |
119 | 134 | ||
120 | /* | 135 | /* |
@@ -126,8 +141,12 @@ void __init init_IRQ(void) | |||
126 | 141 | ||
127 | for (irq = 0; irq < NR_IRQS; irq++) | 142 | for (irq = 0; irq < NR_IRQS; irq++) |
128 | if (irq_desc[irq].chip == &no_irq_type) | 143 | if (irq_desc[irq].chip == &no_irq_type) |
129 | set_irq_chip_and_handler(irq, &mn10300_cpu_pic, | 144 | /* due to the PIC latching interrupt requests, even |
130 | handle_edge_irq); | 145 | * when the IRQ is disabled, IRQ_PENDING is superfluous |
146 | * and we can use handle_level_irq() for edge-triggered | ||
147 | * interrupts */ | ||
148 | set_irq_chip_and_handler(irq, &mn10300_cpu_pic_edge, | ||
149 | handle_level_irq); | ||
131 | unit_init_IRQ(); | 150 | unit_init_IRQ(); |
132 | } | 151 | } |
133 | 152 | ||
diff --git a/arch/mn10300/kernel/time.c b/arch/mn10300/kernel/time.c index babb7c2ac377..e4606586f94c 100644 --- a/arch/mn10300/kernel/time.c +++ b/arch/mn10300/kernel/time.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* MN10300 Low level time management | 1 | /* MN10300 Low level time management |
2 | * | 2 | * |
3 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. | 3 | * Copyright (C) 2007-2008 Red Hat, Inc. All Rights Reserved. |
4 | * Written by David Howells (dhowells@redhat.com) | 4 | * Written by David Howells (dhowells@redhat.com) |
5 | * - Derived from arch/i386/kernel/time.c | 5 | * - Derived from arch/i386/kernel/time.c |
6 | * | 6 | * |
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/smp.h> | 17 | #include <linux/smp.h> |
18 | #include <linux/profile.h> | 18 | #include <linux/profile.h> |
19 | #include <linux/cnt32_to_63.h> | ||
19 | #include <asm/irq.h> | 20 | #include <asm/irq.h> |
20 | #include <asm/div64.h> | 21 | #include <asm/div64.h> |
21 | #include <asm/processor.h> | 22 | #include <asm/processor.h> |
@@ -40,27 +41,54 @@ static struct irqaction timer_irq = { | |||
40 | .name = "timer", | 41 | .name = "timer", |
41 | }; | 42 | }; |
42 | 43 | ||
44 | static unsigned long sched_clock_multiplier; | ||
45 | |||
43 | /* | 46 | /* |
44 | * scheduler clock - returns current time in nanosec units. | 47 | * scheduler clock - returns current time in nanosec units. |
45 | */ | 48 | */ |
46 | unsigned long long sched_clock(void) | 49 | unsigned long long sched_clock(void) |
47 | { | 50 | { |
48 | union { | 51 | union { |
49 | unsigned long long l; | 52 | unsigned long long ll; |
50 | u32 w[2]; | 53 | unsigned l[2]; |
51 | } quot; | 54 | } tsc64, result; |
55 | unsigned long tsc, tmp; | ||
56 | unsigned product[3]; /* 96-bit intermediate value */ | ||
57 | |||
58 | /* read the TSC value | ||
59 | */ | ||
60 | tsc = 0 - get_cycles(); /* get_cycles() counts down */ | ||
52 | 61 | ||
53 | quot.w[0] = mn10300_last_tsc - get_cycles(); | 62 | /* expand to 64-bits. |
54 | quot.w[1] = 1000000000; | 63 | * - sched_clock() must be called once a minute or better or the |
64 | * following will go horribly wrong - see cnt32_to_63() | ||
65 | */ | ||
66 | tsc64.ll = cnt32_to_63(tsc) & 0x7fffffffffffffffULL; | ||
55 | 67 | ||
56 | asm("mulu %2,%3,%0,%1" | 68 | /* scale the 64-bit TSC value to a nanosecond value via a 96-bit |
57 | : "=r"(quot.w[1]), "=r"(quot.w[0]) | 69 | * intermediate |
58 | : "0"(quot.w[1]), "1"(quot.w[0]) | 70 | */ |
71 | asm("mulu %2,%0,%3,%0 \n" /* LSW * mult -> 0:%3:%0 */ | ||
72 | "mulu %2,%1,%2,%1 \n" /* MSW * mult -> %2:%1:0 */ | ||
73 | "add %3,%1 \n" | ||
74 | "addc 0,%2 \n" /* result in %2:%1:%0 */ | ||
75 | : "=r"(product[0]), "=r"(product[1]), "=r"(product[2]), "=r"(tmp) | ||
76 | : "0"(tsc64.l[0]), "1"(tsc64.l[1]), "2"(sched_clock_multiplier) | ||
59 | : "cc"); | 77 | : "cc"); |
60 | 78 | ||
61 | do_div(quot.l, MN10300_TSCCLK); | 79 | result.l[0] = product[1] << 16 | product[0] >> 16; |
80 | result.l[1] = product[2] << 16 | product[1] >> 16; | ||
62 | 81 | ||
63 | return quot.l; | 82 | return result.ll; |
83 | } | ||
84 | |||
85 | /* | ||
86 | * initialise the scheduler clock | ||
87 | */ | ||
88 | static void __init mn10300_sched_clock_init(void) | ||
89 | { | ||
90 | sched_clock_multiplier = | ||
91 | __muldiv64u(NSEC_PER_SEC, 1 << 16, MN10300_TSCCLK); | ||
64 | } | 92 | } |
65 | 93 | ||
66 | /* | 94 | /* |
@@ -128,4 +156,6 @@ void __init time_init(void) | |||
128 | /* start the watchdog timer */ | 156 | /* start the watchdog timer */ |
129 | watchdog_go(); | 157 | watchdog_go(); |
130 | #endif | 158 | #endif |
159 | |||
160 | mn10300_sched_clock_init(); | ||
131 | } | 161 | } |
diff --git a/arch/mn10300/mm/fault.c b/arch/mn10300/mm/fault.c index 78f092ca0316..33cf25025dac 100644 --- a/arch/mn10300/mm/fault.c +++ b/arch/mn10300/mm/fault.c | |||
@@ -174,7 +174,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long fault_code, | |||
174 | * If we're in an interrupt or have no user | 174 | * If we're in an interrupt or have no user |
175 | * context, we must not take the fault.. | 175 | * context, we must not take the fault.. |
176 | */ | 176 | */ |
177 | if (in_interrupt() || !mm) | 177 | if (in_atomic() || !mm) |
178 | goto no_context; | 178 | goto no_context; |
179 | 179 | ||
180 | down_read(&mm->mmap_sem); | 180 | down_read(&mm->mmap_sem); |
diff --git a/arch/mn10300/unit-asb2303/unit-init.c b/arch/mn10300/unit-asb2303/unit-init.c index 14b2c817cff8..70e8cb4ea266 100644 --- a/arch/mn10300/unit-asb2303/unit-init.c +++ b/arch/mn10300/unit-asb2303/unit-init.c | |||
@@ -51,7 +51,7 @@ void __init unit_init_IRQ(void) | |||
51 | switch (GET_XIRQ_TRIGGER(extnum)) { | 51 | switch (GET_XIRQ_TRIGGER(extnum)) { |
52 | case XIRQ_TRIGGER_HILEVEL: | 52 | case XIRQ_TRIGGER_HILEVEL: |
53 | case XIRQ_TRIGGER_LOWLEVEL: | 53 | case XIRQ_TRIGGER_LOWLEVEL: |
54 | set_irq_handler(XIRQ2IRQ(extnum), handle_level_irq); | 54 | set_intr_postackable(XIRQ2IRQ(extnum)); |
55 | break; | 55 | break; |
56 | default: | 56 | default: |
57 | break; | 57 | break; |
diff --git a/arch/mn10300/unit-asb2305/unit-init.c b/arch/mn10300/unit-asb2305/unit-init.c index 6a352414a358..72812a9439ac 100644 --- a/arch/mn10300/unit-asb2305/unit-init.c +++ b/arch/mn10300/unit-asb2305/unit-init.c | |||
@@ -52,7 +52,7 @@ void __init unit_init_IRQ(void) | |||
52 | switch (GET_XIRQ_TRIGGER(extnum)) { | 52 | switch (GET_XIRQ_TRIGGER(extnum)) { |
53 | case XIRQ_TRIGGER_HILEVEL: | 53 | case XIRQ_TRIGGER_HILEVEL: |
54 | case XIRQ_TRIGGER_LOWLEVEL: | 54 | case XIRQ_TRIGGER_LOWLEVEL: |
55 | set_irq_handler(XIRQ2IRQ(extnum), handle_level_irq); | 55 | set_intr_postackable(XIRQ2IRQ(extnum)); |
56 | break; | 56 | break; |
57 | default: | 57 | default: |
58 | break; | 58 | break; |