-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path0002-hw-misc-allwinner-f1c100s-ccu-add-allwinner-f1c100s-.patch
208 lines (204 loc) · 6.84 KB
/
0002-hw-misc-allwinner-f1c100s-ccu-add-allwinner-f1c100s-.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
From c79958ab5a01ffa259a29e828ac8a1ef6865865b Mon Sep 17 00:00:00 2001
From: LuHui <[email protected]>
Date: Sun, 5 Mar 2023 21:25:51 +0800
Subject: [PATCH 2/4] hw/misc/allwinner-f1c100s-ccu: add allwinner f1c100s
clock control support
Signed-off-by: LuHui <[email protected]>
---
hw/misc/allwinner-f1c100s-ccu.c | 129 ++++++++++++++++++++++++
hw/misc/meson.build | 1 +
include/hw/misc/allwinner-f1c100s-ccu.h | 37 +++++++
3 files changed, 167 insertions(+)
create mode 100644 hw/misc/allwinner-f1c100s-ccu.c
create mode 100644 include/hw/misc/allwinner-f1c100s-ccu.h
diff --git a/hw/misc/allwinner-f1c100s-ccu.c b/hw/misc/allwinner-f1c100s-ccu.c
new file mode 100644
index 0000000000..13adef7efd
--- /dev/null
+++ b/hw/misc/allwinner-f1c100s-ccu.c
@@ -0,0 +1,129 @@
+/*
+ * Allwinner f1c100s Clock Control Unit emulation
+ *
+ * Copyright (C) 2023 Lu Hui <[email protected]>
+ * some code from ./allwinner-h3-ccu.c:
+ * Copyright (C) 2019 Niek Linnenbank <[email protected]>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/units.h"
+#include "hw/sysbus.h"
+#include "migration/vmstate.h"
+#include "qemu/log.h"
+#include "qemu/module.h"
+#include "hw/misc/allwinner-f1c100s-ccu.h"
+
+enum {
+ REG_PLL_CPU_CTL = 0x00,
+ REG_PLL_AUDIO_CTL = 0x08,
+ REG_PLL_VIDEO_CTL = 0x10,
+ REG_PLL_VE_CTL = 0x18,
+ REG_PLL_DDR_CTL = 0x20,
+ REG_PLL_PERIPH_CTRL = 0x28,
+};
+
+static uint64_t allwinner_f1c100s_ccu_read(void *opaque, hwaddr offset,
+ unsigned size)
+{
+ const AwF1c100sClockCtlState *s = AW_F1C100S_CCU(opaque);
+ (void)s;
+ uint32_t val = 0x0;
+
+ switch (offset) {
+ case REG_PLL_CPU_CTL:
+ case REG_PLL_AUDIO_CTL:
+ case REG_PLL_VIDEO_CTL:
+ case REG_PLL_VE_CTL:
+ case REG_PLL_DDR_CTL:
+ case REG_PLL_PERIPH_CTRL:
+ val |= (1 << 28); /* always locked */
+ return val;
+ default:
+ return 0x0;
+ }
+}
+
+static void allwinner_f1c100s_ccu_write(void *opaque, hwaddr offset,
+ uint64_t val, unsigned size)
+{
+ AwF1c100sClockCtlState *s = AW_F1C100S_CCU(opaque);
+ (void)s;
+
+ switch (offset) {
+ default:
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented write offset 0x%04x\n",
+ __func__, (uint32_t)offset);
+ break;
+ }
+}
+
+static const MemoryRegionOps allwinner_f1c100s_ccu_ops = {
+ .read = allwinner_f1c100s_ccu_read,
+ .write = allwinner_f1c100s_ccu_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+ .valid = {
+ .min_access_size = 4,
+ .max_access_size = 4,
+ },
+ .impl.min_access_size = 4,
+};
+
+static void allwinner_f1c100s_ccu_reset(DeviceState *dev)
+{
+ AwF1c100sClockCtlState *s = AW_F1C100S_CCU(dev);
+ (void)s;
+}
+
+static void allwinner_f1c100s_ccu_init(Object *obj)
+{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+ AwF1c100sClockCtlState *s = AW_F1C100S_CCU(obj);
+
+ /* Memory mapping */
+ memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_f1c100s_ccu_ops, s,
+ TYPE_AW_F1C100S_CCU, 0x400);
+ sysbus_init_mmio(sbd, &s->iomem);
+}
+
+static const VMStateDescription allwinner_f1c100s_ccu_vmstate = {
+ .name = "allwinner-f1c100s-ccu",
+ .version_id = 1,
+ .minimum_version_id = 1,
+};
+
+static void allwinner_f1c100s_ccu_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ dc->reset = allwinner_f1c100s_ccu_reset;
+ dc->vmsd = &allwinner_f1c100s_ccu_vmstate;
+}
+
+static const TypeInfo allwinner_f1c100s_ccu_info = {
+ .name = TYPE_AW_F1C100S_CCU,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_init = allwinner_f1c100s_ccu_init,
+ .instance_size = sizeof(AwF1c100sClockCtlState),
+ .class_init = allwinner_f1c100s_ccu_class_init,
+};
+
+static void allwinner_f1c100s_ccu_register(void)
+{
+ type_register_static(&allwinner_f1c100s_ccu_info);
+}
+
+type_init(allwinner_f1c100s_ccu_register)
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
index fe869b98ca..3a21e8bca3 100644
--- a/hw/misc/meson.build
+++ b/hw/misc/meson.build
@@ -39,6 +39,7 @@ softmmu_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c'))
softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_CCM', if_true: files('allwinner-a10-ccm.c'))
softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_DRAMC', if_true: files('allwinner-a10-dramc.c'))
+softmmu_ss.add(when: 'CONFIG_ALLWINNER_F1C100S', if_true: files('allwinner-f1c100s-ccu.c'))
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c'))
specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c'))
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c'))
diff --git a/include/hw/misc/allwinner-f1c100s-ccu.h b/include/hw/misc/allwinner-f1c100s-ccu.h
new file mode 100644
index 0000000000..68da6c40dc
--- /dev/null
+++ b/include/hw/misc/allwinner-f1c100s-ccu.h
@@ -0,0 +1,37 @@
+/*
+ * Allwinner f1c100s Clock Control Unit emulation
+ *
+ * Copyright (C) 2023 Lu Hui <[email protected]>
+ * some code copy from: ./allwinner-h3-ccu.h
+ * Copyright (C) 2019 Niek Linnenbank <[email protected]>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef HW_MISC_ALLWINNER_F1C100S_CCU_H
+#define HW_MISC_ALLWINNER_F1C100S_CCU_H
+
+#include "qom/object.h"
+#include "hw/sysbus.h"
+
+#define TYPE_AW_F1C100S_CCU "allwinner-f1c100s-ccu"
+OBJECT_DECLARE_SIMPLE_TYPE(AwF1c100sClockCtlState, AW_F1C100S_CCU)
+
+struct AwF1c100sClockCtlState {
+ SysBusDevice parent_obj;
+
+ MemoryRegion iomem;
+};
+
+#endif /* HW_MISC_ALLWINNER_F1C100S_CCU_H */
--
2.35.7