OSDN Git Service

a2c79f77b785d0fc61e3b5e1338b89f80e974a59
[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 tm8_unit0_platform_data = {
67         .mode   = H8300_TMR8_CLKEVTDEV,
68         .div    = H8300_TMR8_DIV_8,
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  = &tm8_unit0_platform_data,
83         },
84         .resource       = tm8_unit0_resources,
85         .num_resources  = ARRAY_SIZE(tm8_unit0_resources),
86 };
87
88 static struct h8300_timer8_config tm8_unit1_platform_data = {
89         .mode   = H8300_TMR8_CLKSRC,
90         .div    = H8300_TMR8_DIV_8,
91         .rating = 200,
92 };
93
94 static struct resource tm8_unit1_resources[] = {
95         DEFINE_RES_MEM(0xffff90, 9),
96         DEFINE_RES_IRQ(40),
97         DEFINE_RES_IRQ(43),
98 };
99
100 static struct platform_device timer8_unit1_device = {
101         .name           = "h8300-8timer",
102         .id             = 1,
103         .dev = {
104                 .platform_data  = &tm8_unit1_platform_data,
105         },
106         .resource       = tm8_unit1_resources,
107         .num_resources  = ARRAY_SIZE(tm8_unit1_resources),
108 };
109
110
111 static struct h8300_timer16_config timer16data0 = {
112         .rating = 200,
113         .enb    = 0,
114         .imfa   = 0,
115         .imiea  = 4,
116 };
117
118 static struct h8300_timer16_config timer16data1 = {
119         .rating = 200,
120         .enb    = 1,
121         .imfa   = 1,
122         .imiea  = 5,
123 };
124
125 static struct h8300_timer16_config timer16data2 = {
126         .rating = 200,
127         .enb    = 2,
128         .imfa   = 2,
129         .imiea  = 6,
130 };
131
132 static struct resource tm16ch0_resources[] = {
133         DEFINE_RES_MEM(0xffff68, 8),
134         DEFINE_RES_MEM(0xffff60, 7),
135         DEFINE_RES_IRQ(24),
136 };
137
138 static struct resource tm16ch1_resources[] = {
139         DEFINE_RES_MEM(0xffff70, 8),
140         DEFINE_RES_MEM(0xffff60, 7),
141         DEFINE_RES_IRQ(28),
142 };
143
144 static struct resource tm16ch2_resources[] = {
145         DEFINE_RES_MEM(0xffff78, 8),
146         DEFINE_RES_MEM(0xffff60, 7),
147         DEFINE_RES_IRQ(32),
148 };
149
150 static struct platform_device timer16_ch0_device = {
151         .name   = "h8300h-16timer",
152         .id             = 0,
153         .dev            = {
154                 .platform_data  = &timer16data0,
155         },
156         .resource       = tm16ch0_resources,
157         .num_resources  = ARRAY_SIZE(tm16ch0_resources),
158 };
159
160 static struct platform_device timer16_ch1_device = {
161         .name   = "h8300h-16timer",
162         .id             = 1,
163         .dev            = {
164                 .platform_data  = &timer16data1,
165         },
166         .resource       = tm16ch1_resources,
167         .num_resources  = ARRAY_SIZE(tm16ch1_resources),
168 };
169
170 static struct platform_device timer16_ch2_device = {
171         .name   = "h8300h-16timer",
172         .id             = 2,
173         .dev            = {
174                 .platform_data  = &timer16data2,
175         },
176         .resource       = tm16ch2_resources,
177         .num_resources  = ARRAY_SIZE(tm16ch2_resources),
178 };
179
180 static struct platform_device *devices[] __initdata = {
181         &timer8_unit1_device,
182         &timer16_ch0_device,
183         &timer16_ch1_device,
184         &timer16_ch2_device,
185         &sci0_device,
186         &sci1_device,
187 };
188
189 static struct platform_device *early_devices[] __initdata = {
190         &timer8_unit0_device,
191         &sci0_device,
192         &sci1_device,
193 };
194
195 static int __init devices_register(void)
196 {
197         return platform_add_devices(devices,
198                                     ARRAY_SIZE(devices));
199 }
200
201 arch_initcall(devices_register);
202
203 void __init early_device_init(void)
204 {
205         early_platform_add_devices(early_devices,
206                                    ARRAY_SIZE(early_devices));
207 }