blob: f8373c0695248fc573b22136fc9e2bb2120a0d72 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Hirokazu Takata3264f972007-08-01 21:09:31 +09002 * linux/arch/m32r/platforms/oaks32r/setup.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Setup routines for OAKS32R Board
5 *
Hirokazu Takata316240f2005-07-07 17:59:32 -07006 * Copyright (c) 2002-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Mamoru Sakugawa
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/irq.h>
11#include <linux/kernel.h>
12#include <linux/init.h>
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/m32r.h>
15#include <asm/io.h>
16
17#define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019icu_data_t icu_data[NR_IRQS];
20
21static void disable_oaks32r_irq(unsigned int irq)
22{
23 unsigned long port, data;
24
25 port = irq2port(irq);
26 data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
27 outl(data, port);
28}
29
30static void enable_oaks32r_irq(unsigned int irq)
31{
32 unsigned long port, data;
33
34 port = irq2port(irq);
35 data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
36 outl(data, port);
37}
38
Thomas Gleixnerce1104c2011-01-19 18:44:10 +010039static void mask_oaks32r(struct irq_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040{
Thomas Gleixnerce1104c2011-01-19 18:44:10 +010041 disable_oaks32r_irq(data->irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070042}
43
Thomas Gleixnerce1104c2011-01-19 18:44:10 +010044static void unmask_oaks32r(struct irq_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070045{
Thomas Gleixnerce1104c2011-01-19 18:44:10 +010046 enable_oaks32r_irq(data->irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047}
48
Thomas Gleixnerce1104c2011-01-19 18:44:10 +010049static void shutdown_oaks32r(struct irq_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
51 unsigned long port;
52
Thomas Gleixnerce1104c2011-01-19 18:44:10 +010053 port = irq2port(data->irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 outl(M32R_ICUCR_ILEVEL7, port);
55}
56
Thomas Gleixner189e91f2009-06-16 15:33:26 -070057static struct irq_chip oaks32r_irq_type =
Linus Torvalds1da177e2005-04-16 15:20:36 -070058{
Thomas Gleixnerce1104c2011-01-19 18:44:10 +010059 .name = "OAKS32R-IRQ",
60 .irq_shutdown = shutdown_oaks32r,
61 .irq_mask = mask_oaks32r,
62 .irq_unmask = unmask_oaks32r,
Linus Torvalds1da177e2005-04-16 15:20:36 -070063};
64
65void __init init_IRQ(void)
66{
67 static int once = 0;
68
69 if (once)
70 return;
71 else
72 once++;
73
74#ifdef CONFIG_NE2000
75 /* INT3 : LAN controller (RTL8019AS) */
Thomas Gleixner27e5c5a2011-03-24 17:32:45 +010076 irq_set_chip_and_handler(M32R_IRQ_INT3, &oaks32r_irq_type,
Thomas Gleixnerce1104c2011-01-19 18:44:10 +010077 handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
79 disable_oaks32r_irq(M32R_IRQ_INT3);
80#endif /* CONFIG_M32R_NE2000 */
81
82 /* MFT2 : system timer */
Thomas Gleixner27e5c5a2011-03-24 17:32:45 +010083 irq_set_chip_and_handler(M32R_IRQ_MFT2, &oaks32r_irq_type,
Thomas Gleixnerce1104c2011-01-19 18:44:10 +010084 handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
86 disable_oaks32r_irq(M32R_IRQ_MFT2);
87
88#ifdef CONFIG_SERIAL_M32R_SIO
89 /* SIO0_R : uart receive data */
Thomas Gleixner27e5c5a2011-03-24 17:32:45 +010090 irq_set_chip_and_handler(M32R_IRQ_SIO0_R, &oaks32r_irq_type,
Thomas Gleixnerce1104c2011-01-19 18:44:10 +010091 handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
93 disable_oaks32r_irq(M32R_IRQ_SIO0_R);
94
95 /* SIO0_S : uart send data */
Thomas Gleixner27e5c5a2011-03-24 17:32:45 +010096 irq_set_chip_and_handler(M32R_IRQ_SIO0_S, &oaks32r_irq_type,
Thomas Gleixnerce1104c2011-01-19 18:44:10 +010097 handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
99 disable_oaks32r_irq(M32R_IRQ_SIO0_S);
100
101 /* SIO1_R : uart receive data */
Thomas Gleixner27e5c5a2011-03-24 17:32:45 +0100102 irq_set_chip_and_handler(M32R_IRQ_SIO1_R, &oaks32r_irq_type,
Thomas Gleixnerce1104c2011-01-19 18:44:10 +0100103 handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
105 disable_oaks32r_irq(M32R_IRQ_SIO1_R);
106
107 /* SIO1_S : uart send data */
Thomas Gleixner27e5c5a2011-03-24 17:32:45 +0100108 irq_set_chip_and_handler(M32R_IRQ_SIO1_S, &oaks32r_irq_type,
Thomas Gleixnerce1104c2011-01-19 18:44:10 +0100109 handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
111 disable_oaks32r_irq(M32R_IRQ_SIO1_S);
112#endif /* CONFIG_SERIAL_M32R_SIO */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113}