Linux 3.14.25
[platform/adaptation/renesas_rcar/renesas_kernel.git] / arch / sh / kernel / cpu / sh5 / setup-sh5.c
1 /*
2  * SH5-101/SH5-103 CPU Setup
3  *
4  *  Copyright (C) 2009  Paul Mundt
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 #include <linux/platform_device.h>
11 #include <linux/init.h>
12 #include <linux/serial.h>
13 #include <linux/serial_sci.h>
14 #include <linux/io.h>
15 #include <linux/mm.h>
16 #include <linux/sh_timer.h>
17 #include <asm/addrspace.h>
18
19 static struct plat_sci_port scif0_platform_data = {
20         .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
21         .scscr          = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
22         .type           = PORT_SCIF,
23 };
24
25 static struct resource scif0_resources[] = {
26         DEFINE_RES_MEM(PHYS_PERIPHERAL_BLOCK + 0x01030000, 0x100),
27         DEFINE_RES_IRQ(39),
28         DEFINE_RES_IRQ(40),
29         DEFINE_RES_IRQ(42),
30 };
31
32 static struct platform_device scif0_device = {
33         .name           = "sh-sci",
34         .id             = 0,
35         .resource       = scif0_resources,
36         .num_resources  = ARRAY_SIZE(scif0_resources),
37         .dev            = {
38                 .platform_data  = &scif0_platform_data,
39         },
40 };
41
42 static struct resource rtc_resources[] = {
43         [0] = {
44                 .start  = PHYS_PERIPHERAL_BLOCK + 0x01040000,
45                 .end    = PHYS_PERIPHERAL_BLOCK + 0x01040000 + 0x58 - 1,
46                 .flags  = IORESOURCE_IO,
47         },
48         [1] = {
49                 /* Period IRQ */
50                 .start  = IRQ_PRI,
51                 .flags  = IORESOURCE_IRQ,
52         },
53         [2] = {
54                 /* Carry IRQ */
55                 .start  = IRQ_CUI,
56                 .flags  = IORESOURCE_IRQ,
57         },
58         [3] = {
59                 /* Alarm IRQ */
60                 .start  = IRQ_ATI,
61                 .flags  = IORESOURCE_IRQ,
62         },
63 };
64
65 static struct platform_device rtc_device = {
66         .name           = "sh-rtc",
67         .id             = -1,
68         .num_resources  = ARRAY_SIZE(rtc_resources),
69         .resource       = rtc_resources,
70 };
71
72 #define TMU_BLOCK_OFF   0x01020000
73 #define TMU_BASE        PHYS_PERIPHERAL_BLOCK + TMU_BLOCK_OFF
74 #define TMU0_BASE       (TMU_BASE + 0x8 + (0xc * 0x0))
75 #define TMU1_BASE       (TMU_BASE + 0x8 + (0xc * 0x1))
76 #define TMU2_BASE       (TMU_BASE + 0x8 + (0xc * 0x2))
77
78 static struct sh_timer_config tmu0_platform_data = {
79         .channel_offset = 0x04,
80         .timer_bit = 0,
81         .clockevent_rating = 200,
82 };
83
84 static struct resource tmu0_resources[] = {
85         [0] = {
86                 .start  = TMU0_BASE,
87                 .end    = TMU0_BASE + 0xc - 1,
88                 .flags  = IORESOURCE_MEM,
89         },
90         [1] = {
91                 .start  = IRQ_TUNI0,
92                 .flags  = IORESOURCE_IRQ,
93         },
94 };
95
96 static struct platform_device tmu0_device = {
97         .name           = "sh_tmu",
98         .id             = 0,
99         .dev = {
100                 .platform_data  = &tmu0_platform_data,
101         },
102         .resource       = tmu0_resources,
103         .num_resources  = ARRAY_SIZE(tmu0_resources),
104 };
105
106 static struct sh_timer_config tmu1_platform_data = {
107         .channel_offset = 0x10,
108         .timer_bit = 1,
109         .clocksource_rating = 200,
110 };
111
112 static struct resource tmu1_resources[] = {
113         [0] = {
114                 .start  = TMU1_BASE,
115                 .end    = TMU1_BASE + 0xc - 1,
116                 .flags  = IORESOURCE_MEM,
117         },
118         [1] = {
119                 .start  = IRQ_TUNI1,
120                 .flags  = IORESOURCE_IRQ,
121         },
122 };
123
124 static struct platform_device tmu1_device = {
125         .name           = "sh_tmu",
126         .id             = 1,
127         .dev = {
128                 .platform_data  = &tmu1_platform_data,
129         },
130         .resource       = tmu1_resources,
131         .num_resources  = ARRAY_SIZE(tmu1_resources),
132 };
133
134 static struct sh_timer_config tmu2_platform_data = {
135         .channel_offset = 0x1c,
136         .timer_bit = 2,
137 };
138
139 static struct resource tmu2_resources[] = {
140         [0] = {
141                 .start  = TMU2_BASE,
142                 .end    = TMU2_BASE + 0xc - 1,
143                 .flags  = IORESOURCE_MEM,
144         },
145         [1] = {
146                 .start  = IRQ_TUNI2,
147                 .flags  = IORESOURCE_IRQ,
148         },
149 };
150
151 static struct platform_device tmu2_device = {
152         .name           = "sh_tmu",
153         .id             = 2,
154         .dev = {
155                 .platform_data  = &tmu2_platform_data,
156         },
157         .resource       = tmu2_resources,
158         .num_resources  = ARRAY_SIZE(tmu2_resources),
159 };
160
161 static struct platform_device *sh5_early_devices[] __initdata = {
162         &scif0_device,
163         &tmu0_device,
164         &tmu1_device,
165         &tmu2_device,
166 };
167
168 static struct platform_device *sh5_devices[] __initdata = {
169         &rtc_device,
170 };
171
172 static int __init sh5_devices_setup(void)
173 {
174         int ret;
175
176         ret = platform_add_devices(sh5_early_devices,
177                                    ARRAY_SIZE(sh5_early_devices));
178         if (unlikely(ret != 0))
179                 return ret;
180
181         return platform_add_devices(sh5_devices,
182                                     ARRAY_SIZE(sh5_devices));
183 }
184 arch_initcall(sh5_devices_setup);
185
186 void __init plat_early_device_setup(void)
187 {
188         early_platform_add_devices(sh5_early_devices,
189                                    ARRAY_SIZE(sh5_early_devices));
190 }