drivers: move the early platform device support to arch/sh
[linux-2.6-block.git] / arch / sh / kernel / cpu / sh5 / setup-sh5.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * SH5-101/SH5-103 CPU Setup
4  *
5  *  Copyright (C) 2009  Paul Mundt
6  */
7 #include <linux/platform_device.h>
8 #include <linux/init.h>
9 #include <linux/serial.h>
10 #include <linux/serial_sci.h>
11 #include <linux/io.h>
12 #include <linux/mm.h>
13 #include <linux/sh_timer.h>
14 #include <asm/addrspace.h>
15 #include <asm/platform_early.h>
16
17 static struct plat_sci_port scif0_platform_data = {
18         .flags          = UPF_IOREMAP,
19         .scscr          = SCSCR_REIE,
20         .type           = PORT_SCIF,
21 };
22
23 static struct resource scif0_resources[] = {
24         DEFINE_RES_MEM(PHYS_PERIPHERAL_BLOCK + 0x01030000, 0x100),
25         DEFINE_RES_IRQ(39),
26         DEFINE_RES_IRQ(40),
27         DEFINE_RES_IRQ(42),
28 };
29
30 static struct platform_device scif0_device = {
31         .name           = "sh-sci",
32         .id             = 0,
33         .resource       = scif0_resources,
34         .num_resources  = ARRAY_SIZE(scif0_resources),
35         .dev            = {
36                 .platform_data  = &scif0_platform_data,
37         },
38 };
39
40 static struct resource rtc_resources[] = {
41         [0] = {
42                 .start  = PHYS_PERIPHERAL_BLOCK + 0x01040000,
43                 .end    = PHYS_PERIPHERAL_BLOCK + 0x01040000 + 0x58 - 1,
44                 .flags  = IORESOURCE_IO,
45         },
46         [1] = {
47                 /* Period IRQ */
48                 .start  = IRQ_PRI,
49                 .flags  = IORESOURCE_IRQ,
50         },
51         [2] = {
52                 /* Carry IRQ */
53                 .start  = IRQ_CUI,
54                 .flags  = IORESOURCE_IRQ,
55         },
56         [3] = {
57                 /* Alarm IRQ */
58                 .start  = IRQ_ATI,
59                 .flags  = IORESOURCE_IRQ,
60         },
61 };
62
63 static struct platform_device rtc_device = {
64         .name           = "sh-rtc",
65         .id             = -1,
66         .num_resources  = ARRAY_SIZE(rtc_resources),
67         .resource       = rtc_resources,
68 };
69
70 #define TMU_BLOCK_OFF   0x01020000
71 #define TMU_BASE        PHYS_PERIPHERAL_BLOCK + TMU_BLOCK_OFF
72
73 static struct sh_timer_config tmu0_platform_data = {
74         .channels_mask = 7,
75 };
76
77 static struct resource tmu0_resources[] = {
78         DEFINE_RES_MEM(TMU_BASE, 0x30),
79         DEFINE_RES_IRQ(IRQ_TUNI0),
80         DEFINE_RES_IRQ(IRQ_TUNI1),
81         DEFINE_RES_IRQ(IRQ_TUNI2),
82 };
83
84 static struct platform_device tmu0_device = {
85         .name           = "sh-tmu",
86         .id             = 0,
87         .dev = {
88                 .platform_data  = &tmu0_platform_data,
89         },
90         .resource       = tmu0_resources,
91         .num_resources  = ARRAY_SIZE(tmu0_resources),
92 };
93
94 static struct platform_device *sh5_early_devices[] __initdata = {
95         &scif0_device,
96         &tmu0_device,
97 };
98
99 static struct platform_device *sh5_devices[] __initdata = {
100         &rtc_device,
101 };
102
103 static int __init sh5_devices_setup(void)
104 {
105         int ret;
106
107         ret = platform_add_devices(sh5_early_devices,
108                                    ARRAY_SIZE(sh5_early_devices));
109         if (unlikely(ret != 0))
110                 return ret;
111
112         return platform_add_devices(sh5_devices,
113                                     ARRAY_SIZE(sh5_devices));
114 }
115 arch_initcall(sh5_devices_setup);
116
117 void __init plat_early_device_setup(void)
118 {
119         early_platform_add_devices(sh5_early_devices,
120                                    ARRAY_SIZE(sh5_early_devices));
121 }