Hirokazu Takata | 9287d95 | 2006-01-06 00:18:41 -0800 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/m32r/kernel/setup_m32104ut.c |
| 3 | * |
| 4 | * Setup routines for M32104UT Board |
| 5 | * |
| 6 | * Copyright (c) 2002-2005 Hiroyuki Kondo, Hirokazu Takata, |
| 7 | * Hitoshi Yamamoto, Mamoru Sakugawa, |
| 8 | * Naoto Sugai, Hayato Fujiwara |
| 9 | */ |
| 10 | |
| 11 | #include <linux/config.h> |
| 12 | #include <linux/irq.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/device.h> |
| 16 | |
| 17 | #include <asm/system.h> |
| 18 | #include <asm/m32r.h> |
| 19 | #include <asm/io.h> |
| 20 | |
| 21 | #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long))) |
| 22 | |
Hirokazu Takata | 9287d95 | 2006-01-06 00:18:41 -0800 | [diff] [blame] | 23 | icu_data_t icu_data[NR_IRQS]; |
| 24 | |
| 25 | static void disable_m32104ut_irq(unsigned int irq) |
| 26 | { |
| 27 | unsigned long port, data; |
| 28 | |
| 29 | port = irq2port(irq); |
| 30 | data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7; |
| 31 | outl(data, port); |
| 32 | } |
| 33 | |
| 34 | static void enable_m32104ut_irq(unsigned int irq) |
| 35 | { |
| 36 | unsigned long port, data; |
| 37 | |
| 38 | port = irq2port(irq); |
| 39 | data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6; |
| 40 | outl(data, port); |
| 41 | } |
| 42 | |
| 43 | static void mask_and_ack_m32104ut(unsigned int irq) |
| 44 | { |
| 45 | disable_m32104ut_irq(irq); |
| 46 | } |
| 47 | |
| 48 | static void end_m32104ut_irq(unsigned int irq) |
| 49 | { |
| 50 | enable_m32104ut_irq(irq); |
| 51 | } |
| 52 | |
| 53 | static unsigned int startup_m32104ut_irq(unsigned int irq) |
| 54 | { |
| 55 | enable_m32104ut_irq(irq); |
| 56 | return (0); |
| 57 | } |
| 58 | |
| 59 | static void shutdown_m32104ut_irq(unsigned int irq) |
| 60 | { |
| 61 | unsigned long port; |
| 62 | |
| 63 | port = irq2port(irq); |
| 64 | outl(M32R_ICUCR_ILEVEL7, port); |
| 65 | } |
| 66 | |
| 67 | static struct hw_interrupt_type m32104ut_irq_type = |
| 68 | { |
| 69 | .typename = "M32104UT-IRQ", |
| 70 | .startup = startup_m32104ut_irq, |
| 71 | .shutdown = shutdown_m32104ut_irq, |
| 72 | .enable = enable_m32104ut_irq, |
| 73 | .disable = disable_m32104ut_irq, |
| 74 | .ack = mask_and_ack_m32104ut, |
| 75 | .end = end_m32104ut_irq |
| 76 | }; |
| 77 | |
| 78 | void __init init_IRQ(void) |
| 79 | { |
| 80 | static int once = 0; |
| 81 | |
| 82 | if (once) |
| 83 | return; |
| 84 | else |
| 85 | once++; |
| 86 | |
| 87 | #if defined(CONFIG_SMC91X) |
| 88 | /* INT#0: LAN controller on M32104UT-LAN (SMC91C111)*/ |
| 89 | irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED; |
| 90 | irq_desc[M32R_IRQ_INT0].handler = &m32104ut_irq_type; |
| 91 | irq_desc[M32R_IRQ_INT0].action = 0; |
| 92 | irq_desc[M32R_IRQ_INT0].depth = 1; |
| 93 | icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD11; /* "H" level sense */ |
| 94 | disable_m32104ut_irq(M32R_IRQ_INT0); |
| 95 | #endif /* CONFIG_SMC91X */ |
| 96 | |
| 97 | /* MFT2 : system timer */ |
| 98 | irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; |
| 99 | irq_desc[M32R_IRQ_MFT2].handler = &m32104ut_irq_type; |
| 100 | irq_desc[M32R_IRQ_MFT2].action = 0; |
| 101 | irq_desc[M32R_IRQ_MFT2].depth = 1; |
| 102 | icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; |
| 103 | disable_m32104ut_irq(M32R_IRQ_MFT2); |
| 104 | |
| 105 | #ifdef CONFIG_SERIAL_M32R_SIO |
| 106 | /* SIO0_R : uart receive data */ |
| 107 | irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; |
| 108 | irq_desc[M32R_IRQ_SIO0_R].handler = &m32104ut_irq_type; |
| 109 | irq_desc[M32R_IRQ_SIO0_R].action = 0; |
| 110 | irq_desc[M32R_IRQ_SIO0_R].depth = 1; |
| 111 | icu_data[M32R_IRQ_SIO0_R].icucr = M32R_ICUCR_IEN; |
| 112 | disable_m32104ut_irq(M32R_IRQ_SIO0_R); |
| 113 | |
| 114 | /* SIO0_S : uart send data */ |
| 115 | irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; |
| 116 | irq_desc[M32R_IRQ_SIO0_S].handler = &m32104ut_irq_type; |
| 117 | irq_desc[M32R_IRQ_SIO0_S].action = 0; |
| 118 | irq_desc[M32R_IRQ_SIO0_S].depth = 1; |
| 119 | icu_data[M32R_IRQ_SIO0_S].icucr = M32R_ICUCR_IEN; |
| 120 | disable_m32104ut_irq(M32R_IRQ_SIO0_S); |
| 121 | #endif /* CONFIG_SERIAL_M32R_SIO */ |
| 122 | } |
| 123 | |
| 124 | #if defined(CONFIG_SMC91X) |
| 125 | |
| 126 | #define LAN_IOSTART 0x300 |
| 127 | #define LAN_IOEND 0x320 |
| 128 | static struct resource smc91x_resources[] = { |
| 129 | [0] = { |
| 130 | .start = (LAN_IOSTART), |
| 131 | .end = (LAN_IOEND), |
| 132 | .flags = IORESOURCE_MEM, |
| 133 | }, |
| 134 | [1] = { |
| 135 | .start = M32R_IRQ_INT0, |
| 136 | .end = M32R_IRQ_INT0, |
| 137 | .flags = IORESOURCE_IRQ, |
| 138 | } |
| 139 | }; |
| 140 | |
| 141 | static struct platform_device smc91x_device = { |
| 142 | .name = "smc91x", |
| 143 | .id = 0, |
| 144 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 145 | .resource = smc91x_resources, |
| 146 | }; |
| 147 | #endif |
| 148 | |
| 149 | static int __init platform_init(void) |
| 150 | { |
| 151 | #if defined(CONFIG_SMC91X) |
| 152 | platform_device_register(&smc91x_device); |
| 153 | #endif |
| 154 | return 0; |
| 155 | } |
| 156 | arch_initcall(platform_init); |