Commit | Line | Data |
---|---|---|
82e1d037 | 1 | // SPDX-License-Identifier: GPL-2.0 |
0fb849b9 PM |
2 | /* |
3 | * SH5-101/SH5-103 CPU Setup | |
4 | * | |
5 | * Copyright (C) 2009 Paul Mundt | |
0fb849b9 PM |
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> | |
add47067 | 13 | #include <linux/sh_timer.h> |
0fb849b9 | 14 | #include <asm/addrspace.h> |
507fd01d | 15 | #include <asm/platform_early.h> |
0fb849b9 | 16 | |
d8d3fbb0 | 17 | static struct plat_sci_port scif0_platform_data = { |
9c21ac50 | 18 | .flags = UPF_IOREMAP, |
c3fa400b | 19 | .scscr = SCSCR_REIE, |
d8d3fbb0 | 20 | .type = PORT_SCIF, |
d850acf9 LP |
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), | |
0fb849b9 PM |
28 | }; |
29 | ||
d8d3fbb0 | 30 | static struct platform_device scif0_device = { |
0fb849b9 | 31 | .name = "sh-sci", |
d8d3fbb0 | 32 | .id = 0, |
d850acf9 LP |
33 | .resource = scif0_resources, |
34 | .num_resources = ARRAY_SIZE(scif0_resources), | |
0fb849b9 | 35 | .dev = { |
d8d3fbb0 | 36 | .platform_data = &scif0_platform_data, |
0fb849b9 PM |
37 | }, |
38 | }; | |
39 | ||
c2ecb4c4 PM |
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 | ||
add47067 PM |
70 | #define TMU_BLOCK_OFF 0x01020000 |
71 | #define TMU_BASE PHYS_PERIPHERAL_BLOCK + TMU_BLOCK_OFF | |
add47067 PM |
72 | |
73 | static struct sh_timer_config tmu0_platform_data = { | |
1399c195 | 74 | .channels_mask = 7, |
add47067 PM |
75 | }; |
76 | ||
77 | static struct resource tmu0_resources[] = { | |
1399c195 LP |
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), | |
add47067 PM |
82 | }; |
83 | ||
84 | static struct platform_device tmu0_device = { | |
1399c195 | 85 | .name = "sh-tmu", |
add47067 PM |
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 | ||
add47067 | 94 | static struct platform_device *sh5_early_devices[] __initdata = { |
d8d3fbb0 | 95 | &scif0_device, |
add47067 | 96 | &tmu0_device, |
add47067 PM |
97 | }; |
98 | ||
0fb849b9 | 99 | static struct platform_device *sh5_devices[] __initdata = { |
c2ecb4c4 | 100 | &rtc_device, |
0fb849b9 PM |
101 | }; |
102 | ||
103 | static int __init sh5_devices_setup(void) | |
104 | { | |
add47067 PM |
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 | ||
0fb849b9 PM |
112 | return platform_add_devices(sh5_devices, |
113 | ARRAY_SIZE(sh5_devices)); | |
114 | } | |
ba9a6337 | 115 | arch_initcall(sh5_devices_setup); |
add47067 PM |
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 | } |