OSDN Git Service

756d98a64f33e99d20374732d33004ea7e703723
[uclinux-h8/linux.git] / arch / h8300 / kernel / cpu / h83069 / setup.c
1 /*
2  * H8/3069 Internal peripheral setup
3  *
4  *  Copyright (C) 2009,2014 Yoshinori Sato <ysato@users.sourceforge.jp>
5  *
6  * This file is subject to the terms and conditions of the GNU General Public
7  * License.  See the file "COPYING" in the main directory of this archive
8  * for more details.
9  */
10
11 #include <linux/platform_device.h>
12 #include <linux/serial_sci.h>
13 #include <linux/init.h>
14 #include <linux/io.h>
15 #include <asm/timer.h>
16
17 static struct resource sci0_resources[] = {
18         DEFINE_RES_MEM(0xffffb0, 8),
19         DEFINE_RES_IRQ(52),
20         DEFINE_RES_IRQ(53),
21         DEFINE_RES_IRQ(54),
22         DEFINE_RES_IRQ(55),
23 };
24
25
26 static struct plat_sci_port sci0_platform_data = {
27         .flags          = UPF_BOOT_AUTOCONF,
28         .scscr          = SCSCR_RE | SCSCR_TE,
29         .type           = PORT_SCI,
30 };
31
32 static struct resource sci1_resources[] = {
33         DEFINE_RES_MEM(0xffffb8, 8),
34         DEFINE_RES_IRQ(56),
35         DEFINE_RES_IRQ(57),
36         DEFINE_RES_IRQ(58),
37         DEFINE_RES_IRQ(59),
38 };
39
40 static struct plat_sci_port sci1_platform_data = {
41         .flags          = UPF_BOOT_AUTOCONF,
42         .scscr          = SCSCR_RE | SCSCR_TE,
43         .type           = PORT_SCI,
44 };
45
46 static struct platform_device sci0_device = {
47         .name           = "sh-sci",
48         .id             = 0,
49         .resource       = sci0_resources,
50         .num_resources  = ARRAY_SIZE(sci0_resources),
51         .dev            = {
52                 .platform_data  = &sci0_platform_data,
53         },
54 };
55
56 static struct platform_device sci1_device = {
57         .name           = "sh-sci",
58         .id             = 1,
59         .resource       = sci1_resources,
60         .num_resources  = ARRAY_SIZE(sci1_resources),
61         .dev            = {
62                 .platform_data  = &sci1_platform_data,
63         },
64 };
65
66 static struct h8300_timer8_config timer8_platform_data = {
67         .mode   = H8300_TMR8_CLKSRC,
68         .div    = H8300_TMR8_DIV_64,
69         .rating = 200,
70 };
71
72 static struct resource tm8_unit0_resources[] = {
73         DEFINE_RES_MEM(0xffff80, 9),
74         DEFINE_RES_IRQ(36),
75         DEFINE_RES_IRQ(39),
76 };
77
78 static struct platform_device timer8_unit0_device = {
79         .name           = "h8300-8timer",
80         .id             = 0,
81         .dev = {
82                 .platform_data  = &timer8_platform_data,
83         },
84         .resource       = tm8_unit0_resources,
85         .num_resources  = ARRAY_SIZE(tm8_unit0_resources),
86 };
87
88 static struct resource tm8_unit1_resources[] = {
89         DEFINE_RES_MEM(0xffff90, 9),
90         DEFINE_RES_IRQ(40),
91         DEFINE_RES_IRQ(43),
92 };
93
94 static struct platform_device timer8_unit1_device = {
95         .name           = "h8300-8timer",
96         .id             = 1,
97         .dev = {
98                 .platform_data  = &timer8_platform_data,
99         },
100         .resource       = tm8_unit1_resources,
101         .num_resources  = ARRAY_SIZE(tm8_unit1_resources),
102 };
103
104
105 static struct h8300_timer16_config timer16data0 = {
106         .rating = 200,
107         .enb    = 0,
108         .imfa   = 0,
109         .imiea  = 4,
110 };
111
112 static struct h8300_timer16_config timer16data1 = {
113         .rating = 200,
114         .enb    = 1,
115         .imfa   = 1,
116         .imiea  = 5,
117 };
118
119 static struct h8300_timer16_config timer16data2 = {
120         .rating = 200,
121         .enb    = 2,
122         .imfa   = 2,
123         .imiea  = 6,
124 };
125
126 static struct resource tm16ch0_resources[] = {
127         DEFINE_RES_MEM(0xffff68, 8),
128         DEFINE_RES_MEM(0xffff60, 7),
129         DEFINE_RES_IRQ(24),
130 };
131
132 static struct resource tm16ch1_resources[] = {
133         DEFINE_RES_MEM(0xffff70, 8),
134         DEFINE_RES_MEM(0xffff60, 7),
135         DEFINE_RES_IRQ(28),
136 };
137
138 static struct resource tm16ch2_resources[] = {
139         DEFINE_RES_MEM(0xffff78, 8),
140         DEFINE_RES_MEM(0xffff60, 7),
141         DEFINE_RES_IRQ(32),
142 };
143
144 static struct platform_device timer16_ch0_device = {
145         .name   = "h8300h-16timer",
146         .id             = 0,
147         .dev            = {
148                 .platform_data  = &timer16data0,
149         },
150         .resource       = tm16ch0_resources,
151         .num_resources  = ARRAY_SIZE(tm16ch0_resources),
152 };
153
154 static struct platform_device timer16_ch1_device = {
155         .name   = "h8300h-16timer",
156         .id             = 1,
157         .dev            = {
158                 .platform_data  = &timer16data1,
159         },
160         .resource       = tm16ch1_resources,
161         .num_resources  = ARRAY_SIZE(tm16ch1_resources),
162 };
163
164 static struct platform_device timer16_ch2_device = {
165         .name   = "h8300h-16timer",
166         .id             = 2,
167         .dev            = {
168                 .platform_data  = &timer16data2,
169         },
170         .resource       = tm16ch2_resources,
171         .num_resources  = ARRAY_SIZE(tm16ch2_resources),
172 };
173
174 static struct platform_device *devices[] __initdata = {
175         &timer8_unit0_device,
176         &timer8_unit1_device,
177         &timer16_ch1_device,
178         &timer16_ch2_device,
179         &sci0_device,
180         &sci1_device,
181 };
182
183 static struct platform_device *early_devices[] __initdata = {
184         &timer16_ch0_device,
185         &sci0_device,
186         &sci1_device,
187 };
188
189 static int __init devices_register(void)
190 {
191         return platform_add_devices(devices,
192                                     ARRAY_SIZE(devices));
193 }
194
195 arch_initcall(devices_register);
196
197 void __init early_device_register(void)
198 {
199         early_platform_add_devices(early_devices,
200                                    ARRAY_SIZE(devices));
201         /* All interrupt priority high */
202         ctrl_outb(0xff, 0xfee018);
203         ctrl_outb(0xff, 0xfee019);
204 }