Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm
[linux-2.6] / arch / sh / boards / se / 770x / setup.c
1 /*
2  * linux/arch/sh/boards/se/770x/setup.c
3  *
4  * Copyright (C) 2000  Kazumoto Kojima
5  *
6  * Hitachi SolutionEngine Support.
7  *
8  */
9 #include <linux/init.h>
10 #include <linux/platform_device.h>
11 #include <asm/machvec.h>
12 #include <asm/se.h>
13 #include <asm/io.h>
14 #include <asm/smc37c93x.h>
15 #include <asm/heartbeat.h>
16
17 void init_se_IRQ(void);
18
19 /*
20  * Configure the Super I/O chip
21  */
22 static void __init smsc_config(int index, int data)
23 {
24         outb_p(index, INDEX_PORT);
25         outb_p(data, DATA_PORT);
26 }
27
28 /* XXX: Another candidate for a more generic cchip machine vector */
29 static void __init smsc_setup(char **cmdline_p)
30 {
31         outb_p(CONFIG_ENTER, CONFIG_PORT);
32         outb_p(CONFIG_ENTER, CONFIG_PORT);
33
34         /* FDC */
35         smsc_config(CURRENT_LDN_INDEX, LDN_FDC);
36         smsc_config(ACTIVATE_INDEX, 0x01);
37         smsc_config(IRQ_SELECT_INDEX, 6); /* IRQ6 */
38
39         /* AUXIO (GPIO): to use IDE1 */
40         smsc_config(CURRENT_LDN_INDEX, LDN_AUXIO);
41         smsc_config(GPIO46_INDEX, 0x00); /* nIOROP */
42         smsc_config(GPIO47_INDEX, 0x00); /* nIOWOP */
43
44         /* COM1 */
45         smsc_config(CURRENT_LDN_INDEX, LDN_COM1);
46         smsc_config(ACTIVATE_INDEX, 0x01);
47         smsc_config(IO_BASE_HI_INDEX, 0x03);
48         smsc_config(IO_BASE_LO_INDEX, 0xf8);
49         smsc_config(IRQ_SELECT_INDEX, 4); /* IRQ4 */
50
51         /* COM2 */
52         smsc_config(CURRENT_LDN_INDEX, LDN_COM2);
53         smsc_config(ACTIVATE_INDEX, 0x01);
54         smsc_config(IO_BASE_HI_INDEX, 0x02);
55         smsc_config(IO_BASE_LO_INDEX, 0xf8);
56         smsc_config(IRQ_SELECT_INDEX, 3); /* IRQ3 */
57
58         /* RTC */
59         smsc_config(CURRENT_LDN_INDEX, LDN_RTC);
60         smsc_config(ACTIVATE_INDEX, 0x01);
61         smsc_config(IRQ_SELECT_INDEX, 8); /* IRQ8 */
62
63         /* XXX: PARPORT, KBD, and MOUSE will come here... */
64         outb_p(CONFIG_EXIT, CONFIG_PORT);
65 }
66
67
68 static struct resource cf_ide_resources[] = {
69         [0] = {
70                 .start  = PA_MRSHPC_IO + 0x1f0,
71                 .end    = PA_MRSHPC_IO + 0x1f0 + 8,
72                 .flags  = IORESOURCE_MEM,
73         },
74         [1] = {
75                 .start  = PA_MRSHPC_IO + 0x1f0 + 0x206,
76                 .end    = PA_MRSHPC_IO + 0x1f0 +8 + 0x206 + 8,
77                 .flags  = IORESOURCE_MEM,
78         },
79         [2] = {
80                 .start  = IRQ_CFCARD,
81                 .flags  = IORESOURCE_IRQ,
82         },
83 };
84
85 static struct platform_device cf_ide_device  = {
86         .name           = "pata_platform",
87         .id             = -1,
88         .num_resources  = ARRAY_SIZE(cf_ide_resources),
89         .resource       = cf_ide_resources,
90 };
91
92 static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };
93
94 static struct heartbeat_data heartbeat_data = {
95         .bit_pos        = heartbeat_bit_pos,
96         .nr_bits        = ARRAY_SIZE(heartbeat_bit_pos),
97         .regsize        = 16,
98 };
99
100 static struct resource heartbeat_resources[] = {
101         [0] = {
102                 .start  = PA_LED,
103                 .end    = PA_LED,
104                 .flags  = IORESOURCE_MEM,
105         },
106 };
107
108 static struct platform_device heartbeat_device = {
109         .name           = "heartbeat",
110         .id             = -1,
111         .dev    = {
112                 .platform_data  = &heartbeat_data,
113         },
114         .num_resources  = ARRAY_SIZE(heartbeat_resources),
115         .resource       = heartbeat_resources,
116 };
117
118 static struct platform_device *se_devices[] __initdata = {
119         &heartbeat_device,
120         &cf_ide_device,
121 };
122
123 static int __init se_devices_setup(void)
124 {
125         return platform_add_devices(se_devices, ARRAY_SIZE(se_devices));
126 }
127 device_initcall(se_devices_setup);
128
129 /*
130  * The Machine Vector
131  */
132 static struct sh_machine_vector mv_se __initmv = {
133         .mv_name                = "SolutionEngine",
134         .mv_setup               = smsc_setup,
135 #if defined(CONFIG_CPU_SH4)
136         .mv_nr_irqs             = 48,
137 #elif defined(CONFIG_CPU_SUBTYPE_SH7708)
138         .mv_nr_irqs             = 32,
139 #elif defined(CONFIG_CPU_SUBTYPE_SH7709)
140         .mv_nr_irqs             = 61,
141 #elif defined(CONFIG_CPU_SUBTYPE_SH7705)
142         .mv_nr_irqs             = 86,
143 #elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
144         .mv_nr_irqs             = 104,
145 #endif
146
147         .mv_inb                 = se_inb,
148         .mv_inw                 = se_inw,
149         .mv_inl                 = se_inl,
150         .mv_outb                = se_outb,
151         .mv_outw                = se_outw,
152         .mv_outl                = se_outl,
153
154         .mv_inb_p               = se_inb_p,
155         .mv_inw_p               = se_inw,
156         .mv_inl_p               = se_inl,
157         .mv_outb_p              = se_outb_p,
158         .mv_outw_p              = se_outw,
159         .mv_outl_p              = se_outl,
160
161         .mv_insb                = se_insb,
162         .mv_insw                = se_insw,
163         .mv_insl                = se_insl,
164         .mv_outsb               = se_outsb,
165         .mv_outsw               = se_outsw,
166         .mv_outsl               = se_outsl,
167
168         .mv_init_irq            = init_se_IRQ,
169 };