1
The following changes since commit 229a834518b950d56fd1bc94923276504d0ee9d4:
1
The following changes since commit a95260486aa7e78d7c7194eba65cf03311ad94ad:
2
2
3
Merge remote-tracking branch 'remotes/philmd-gitlab/tags/renesas-20210306' into staging (2021-03-08 15:45:48 +0000)
3
Merge tag 'pull-tcg-20231023' of https://gitlab.com/rth7680/qemu into staging (2023-10-23 14:45:46 -0700)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/legoater/qemu/ tags/pull-aspeed-20210309
7
https://github.com/legoater/qemu/ tags/pull-aspeed-20231025
8
8
9
for you to fetch changes up to c59f781e3bcca4a80aef5d229488fd45dbfdbd9a:
9
for you to fetch changes up to dd41ce7a6f13ad4f45ebaf52b9fa91fe5fc961df:
10
10
11
hw/misc: Model KCS devices in the Aspeed LPC controller (2021-03-09 12:01:28 +0100)
11
hw/arm/aspeed: Move AspeedSoCState::cpu/vic to Aspeed2400SoCState (2023-10-25 09:52:44 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Aspeed patches :
14
aspeed queue:
15
15
16
* New model for the Aspeed LPC controller
16
* Update of Andrew's email
17
* Misc cleanups
17
* Split of AspeedSoCState per 2400/2600/10x0
18
18
19
----------------------------------------------------------------
19
----------------------------------------------------------------
20
Andrew Jeffery (4):
20
Andrew Jeffery (1):
21
hw/arm: ast2600: Force a multiple of 32 of IRQs for the GIC
21
MAINTAINERS: aspeed: Update Andrew's email address
22
hw/arm: ast2600: Set AST2600_MAX_IRQ to value from datasheet
23
hw/arm: ast2600: Correct the iBT interrupt ID
24
hw/misc: Model KCS devices in the Aspeed LPC controller
25
22
26
Cédric Le Goater (2):
23
Philippe Mathieu-Daudé (11):
27
hw/arm/aspeed: Fix location of firmware images in documentation
24
hw/arm/aspeed: Extract code common to all boards to a common file
28
hw/misc: Add a basic Aspeed LPC controller model
25
hw/arm/aspeed: Rename aspeed_soc_init() as AST2400/2500 specific
26
hw/arm/aspeed: Rename aspeed_soc_realize() as AST2400/2500 specific
27
hw/arm/aspeed: Dynamically allocate AspeedMachineState::soc field
28
hw/arm/aspeed: Introduce TYPE_ASPEED10X0_SOC
29
hw/arm/aspeed: Introduce TYPE_ASPEED2600_SOC
30
hw/arm/aspeed: Introduce TYPE_ASPEED2400_SOC
31
hw/arm/aspeed: Check 'memory' link is set in common aspeed_soc_realize
32
hw/arm/aspeed: Move AspeedSoCState::armv7m to Aspeed10x0SoCState
33
hw/arm/aspeed: Move AspeedSoCState::a7mpcore to Aspeed2600SoCState
34
hw/arm/aspeed: Move AspeedSoCState::cpu/vic to Aspeed2400SoCState
29
35
30
Joel Stanley (1):
36
MAINTAINERS | 2 +-
31
arm/ast2600: Fix SMP booting with -kernel
37
include/hw/arm/aspeed_soc.h | 35 +++++-
38
hw/arm/aspeed.c | 101 +++++++--------
39
hw/arm/aspeed_ast10x0.c | 53 ++++----
40
hw/arm/{aspeed_soc.c => aspeed_ast2400.c} | 197 +++++++-----------------------
41
hw/arm/aspeed_ast2600.c | 75 ++++++------
42
hw/arm/aspeed_soc_common.c | 154 +++++++++++++++++++++++
43
hw/arm/fby35.c | 27 ++--
44
hw/arm/meson.build | 3 +-
45
9 files changed, 363 insertions(+), 284 deletions(-)
46
rename hw/arm/{aspeed_soc.c => aspeed_ast2400.c} (76%)
47
create mode 100644 hw/arm/aspeed_soc_common.c
32
48
33
docs/system/arm/aspeed.rst | 16 +-
34
include/hw/arm/aspeed_soc.h | 3 +
35
include/hw/misc/aspeed_lpc.h | 47 +++++
36
hw/arm/aspeed_ast2600.c | 51 ++++-
37
hw/arm/aspeed_soc.c | 34 ++-
38
hw/misc/aspeed_lpc.c | 486 +++++++++++++++++++++++++++++++++++++++++++
39
hw/misc/meson.build | 7 +-
40
7 files changed, 625 insertions(+), 19 deletions(-)
41
create mode 100644 include/hw/misc/aspeed_lpc.h
42
create mode 100644 hw/misc/aspeed_lpc.c
43
diff view generated by jsdifflib
1
From: Andrew Jeffery <andrew@aj.id.au>
1
From: Andrew Jeffery <andrew@codeconstruct.com.au>
2
2
3
The datasheet says we have 197 IRQs allocated, and we need more than 128
3
I've changed employers, have company email that deals with patch-based
4
to describe IRQs from LPC devices. Raise the value now to allow
4
workflows without too much of a headache, and am trying to steer some
5
modelling of the LPC devices.
5
content out of my personal mail.
6
6
7
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
7
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Cédric Le Goater <clg@kaod.org>
10
Message-Id: <20210302014317.915120-3-andrew@aj.id.au>
11
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
---
9
---
13
hw/arm/aspeed_ast2600.c | 2 +-
10
MAINTAINERS | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
11
1 file changed, 1 insertion(+), 1 deletion(-)
15
12
16
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
13
diff --git a/MAINTAINERS b/MAINTAINERS
17
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/aspeed_ast2600.c
15
--- a/MAINTAINERS
19
+++ b/hw/arm/aspeed_ast2600.c
16
+++ b/MAINTAINERS
20
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
17
@@ -XXX,XX +XXX,XX @@ F: docs/system/arm/emcraft-sf2.rst
21
18
ASPEED BMCs
22
#define ASPEED_A7MPCORE_ADDR 0x40460000
19
M: Cédric Le Goater <clg@kaod.org>
23
20
M: Peter Maydell <peter.maydell@linaro.org>
24
-#define AST2600_MAX_IRQ 128
21
-R: Andrew Jeffery <andrew@aj.id.au>
25
+#define AST2600_MAX_IRQ 197
22
+R: Andrew Jeffery <andrew@codeconstruct.com.au>
26
23
R: Joel Stanley <joel@jms.id.au>
27
/* Shared Peripheral Interrupt values below are offset by -32 from datasheet */
24
L: qemu-arm@nongnu.org
28
static const int aspeed_soc_ast2600_irqmap[] = {
25
S: Maintained
29
--
26
--
30
2.26.2
27
2.41.0
31
28
32
29
diff view generated by jsdifflib
New patch
1
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
3
aspeed_soc.c contains definitions specific to the AST2400
4
and AST2500 SoCs, but also some definitions for other AST
5
SoCs: move them to a common file.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
10
---
11
hw/arm/aspeed_soc.c | 96 -------------------------------
12
hw/arm/aspeed_soc_common.c | 114 +++++++++++++++++++++++++++++++++++++
13
hw/arm/meson.build | 1 +
14
3 files changed, 115 insertions(+), 96 deletions(-)
15
create mode 100644 hw/arm/aspeed_soc_common.c
16
17
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/aspeed_soc.c
20
+++ b/hw/arm/aspeed_soc.c
21
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_register_types(void)
22
};
23
24
type_init(aspeed_soc_register_types);
25
-
26
-qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev)
27
-{
28
- return ASPEED_SOC_GET_CLASS(s)->get_irq(s, dev);
29
-}
30
-
31
-bool aspeed_soc_uart_realize(AspeedSoCState *s, Error **errp)
32
-{
33
- AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
34
- SerialMM *smm;
35
-
36
- for (int i = 0, uart = ASPEED_DEV_UART1; i < sc->uarts_num; i++, uart++) {
37
- smm = &s->uart[i];
38
-
39
- /* Chardev property is set by the machine. */
40
- qdev_prop_set_uint8(DEVICE(smm), "regshift", 2);
41
- qdev_prop_set_uint32(DEVICE(smm), "baudbase", 38400);
42
- qdev_set_legacy_instance_id(DEVICE(smm), sc->memmap[uart], 2);
43
- qdev_prop_set_uint8(DEVICE(smm), "endianness", DEVICE_LITTLE_ENDIAN);
44
- if (!sysbus_realize(SYS_BUS_DEVICE(smm), errp)) {
45
- return false;
46
- }
47
-
48
- sysbus_connect_irq(SYS_BUS_DEVICE(smm), 0, aspeed_soc_get_irq(s, uart));
49
- aspeed_mmio_map(s, SYS_BUS_DEVICE(smm), 0, sc->memmap[uart]);
50
- }
51
-
52
- return true;
53
-}
54
-
55
-void aspeed_soc_uart_set_chr(AspeedSoCState *s, int dev, Chardev *chr)
56
-{
57
- AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
58
- int i = dev - ASPEED_DEV_UART1;
59
-
60
- g_assert(0 <= i && i < ARRAY_SIZE(s->uart) && i < sc->uarts_num);
61
- qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
62
-}
63
-
64
-/*
65
- * SDMC should be realized first to get correct RAM size and max size
66
- * values
67
- */
68
-bool aspeed_soc_dram_init(AspeedSoCState *s, Error **errp)
69
-{
70
- AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
71
- ram_addr_t ram_size, max_ram_size;
72
-
73
- ram_size = object_property_get_uint(OBJECT(&s->sdmc), "ram-size",
74
- &error_abort);
75
- max_ram_size = object_property_get_uint(OBJECT(&s->sdmc), "max-ram-size",
76
- &error_abort);
77
-
78
- memory_region_init(&s->dram_container, OBJECT(s), "ram-container",
79
- max_ram_size);
80
- memory_region_add_subregion(&s->dram_container, 0, s->dram_mr);
81
-
82
- /*
83
- * Add a memory region beyond the RAM region to let firmwares scan
84
- * the address space with load/store and guess how much RAM the
85
- * SoC has.
86
- */
87
- if (ram_size < max_ram_size) {
88
- DeviceState *dev = qdev_new(TYPE_UNIMPLEMENTED_DEVICE);
89
-
90
- qdev_prop_set_string(dev, "name", "ram-empty");
91
- qdev_prop_set_uint64(dev, "size", max_ram_size - ram_size);
92
- if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp)) {
93
- return false;
94
- }
95
-
96
- memory_region_add_subregion_overlap(&s->dram_container, ram_size,
97
- sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0), -1000);
98
- }
99
-
100
- memory_region_add_subregion(s->memory,
101
- sc->memmap[ASPEED_DEV_SDRAM], &s->dram_container);
102
- return true;
103
-}
104
-
105
-void aspeed_mmio_map(AspeedSoCState *s, SysBusDevice *dev, int n, hwaddr addr)
106
-{
107
- memory_region_add_subregion(s->memory, addr,
108
- sysbus_mmio_get_region(dev, n));
109
-}
110
-
111
-void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev,
112
- const char *name, hwaddr addr, uint64_t size)
113
-{
114
- qdev_prop_set_string(DEVICE(dev), "name", name);
115
- qdev_prop_set_uint64(DEVICE(dev), "size", size);
116
- sysbus_realize(dev, &error_abort);
117
-
118
- memory_region_add_subregion_overlap(s->memory, addr,
119
- sysbus_mmio_get_region(dev, 0), -1000);
120
-}
121
diff --git a/hw/arm/aspeed_soc_common.c b/hw/arm/aspeed_soc_common.c
122
new file mode 100644
123
index XXXXXXX..XXXXXXX
124
--- /dev/null
125
+++ b/hw/arm/aspeed_soc_common.c
126
@@ -XXX,XX +XXX,XX @@
127
+/*
128
+ * ASPEED SoC family
129
+ *
130
+ * Andrew Jeffery <andrew@aj.id.au>
131
+ * Jeremy Kerr <jk@ozlabs.org>
132
+ *
133
+ * Copyright 2016 IBM Corp.
134
+ *
135
+ * This code is licensed under the GPL version 2 or later. See
136
+ * the COPYING file in the top-level directory.
137
+ */
138
+
139
+#include "qemu/osdep.h"
140
+#include "qapi/error.h"
141
+#include "hw/misc/unimp.h"
142
+#include "hw/arm/aspeed_soc.h"
143
+#include "hw/char/serial.h"
144
+
145
+
146
+qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev)
147
+{
148
+ return ASPEED_SOC_GET_CLASS(s)->get_irq(s, dev);
149
+}
150
+
151
+bool aspeed_soc_uart_realize(AspeedSoCState *s, Error **errp)
152
+{
153
+ AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
154
+ SerialMM *smm;
155
+
156
+ for (int i = 0, uart = ASPEED_DEV_UART1; i < sc->uarts_num; i++, uart++) {
157
+ smm = &s->uart[i];
158
+
159
+ /* Chardev property is set by the machine. */
160
+ qdev_prop_set_uint8(DEVICE(smm), "regshift", 2);
161
+ qdev_prop_set_uint32(DEVICE(smm), "baudbase", 38400);
162
+ qdev_set_legacy_instance_id(DEVICE(smm), sc->memmap[uart], 2);
163
+ qdev_prop_set_uint8(DEVICE(smm), "endianness", DEVICE_LITTLE_ENDIAN);
164
+ if (!sysbus_realize(SYS_BUS_DEVICE(smm), errp)) {
165
+ return false;
166
+ }
167
+
168
+ sysbus_connect_irq(SYS_BUS_DEVICE(smm), 0, aspeed_soc_get_irq(s, uart));
169
+ aspeed_mmio_map(s, SYS_BUS_DEVICE(smm), 0, sc->memmap[uart]);
170
+ }
171
+
172
+ return true;
173
+}
174
+
175
+void aspeed_soc_uart_set_chr(AspeedSoCState *s, int dev, Chardev *chr)
176
+{
177
+ AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
178
+ int i = dev - ASPEED_DEV_UART1;
179
+
180
+ g_assert(0 <= i && i < ARRAY_SIZE(s->uart) && i < sc->uarts_num);
181
+ qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
182
+}
183
+
184
+/*
185
+ * SDMC should be realized first to get correct RAM size and max size
186
+ * values
187
+ */
188
+bool aspeed_soc_dram_init(AspeedSoCState *s, Error **errp)
189
+{
190
+ AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
191
+ ram_addr_t ram_size, max_ram_size;
192
+
193
+ ram_size = object_property_get_uint(OBJECT(&s->sdmc), "ram-size",
194
+ &error_abort);
195
+ max_ram_size = object_property_get_uint(OBJECT(&s->sdmc), "max-ram-size",
196
+ &error_abort);
197
+
198
+ memory_region_init(&s->dram_container, OBJECT(s), "ram-container",
199
+ max_ram_size);
200
+ memory_region_add_subregion(&s->dram_container, 0, s->dram_mr);
201
+
202
+ /*
203
+ * Add a memory region beyond the RAM region to let firmwares scan
204
+ * the address space with load/store and guess how much RAM the
205
+ * SoC has.
206
+ */
207
+ if (ram_size < max_ram_size) {
208
+ DeviceState *dev = qdev_new(TYPE_UNIMPLEMENTED_DEVICE);
209
+
210
+ qdev_prop_set_string(dev, "name", "ram-empty");
211
+ qdev_prop_set_uint64(dev, "size", max_ram_size - ram_size);
212
+ if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp)) {
213
+ return false;
214
+ }
215
+
216
+ memory_region_add_subregion_overlap(&s->dram_container, ram_size,
217
+ sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0), -1000);
218
+ }
219
+
220
+ memory_region_add_subregion(s->memory,
221
+ sc->memmap[ASPEED_DEV_SDRAM], &s->dram_container);
222
+ return true;
223
+}
224
+
225
+void aspeed_mmio_map(AspeedSoCState *s, SysBusDevice *dev, int n, hwaddr addr)
226
+{
227
+ memory_region_add_subregion(s->memory, addr,
228
+ sysbus_mmio_get_region(dev, n));
229
+}
230
+
231
+void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev,
232
+ const char *name, hwaddr addr, uint64_t size)
233
+{
234
+ qdev_prop_set_string(DEVICE(dev), "name", name);
235
+ qdev_prop_set_uint64(DEVICE(dev), "size", size);
236
+ sysbus_realize(dev, &error_abort);
237
+
238
+ memory_region_add_subregion_overlap(s->memory, addr,
239
+ sysbus_mmio_get_region(dev, 0), -1000);
240
+}
241
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
242
index XXXXXXX..XXXXXXX 100644
243
--- a/hw/arm/meson.build
244
+++ b/hw/arm/meson.build
245
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_FSL_IMX6', if_true: files('fsl-imx6.c'))
246
arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(
247
'aspeed_soc.c',
248
'aspeed.c',
249
+ 'aspeed_soc_common.c',
250
'aspeed_ast2600.c',
251
'aspeed_ast10x0.c',
252
'aspeed_eeprom.c',
253
--
254
2.41.0
255
256
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
5
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
---
7
hw/arm/aspeed_soc.c | 6 +++---
8
1 file changed, 3 insertions(+), 3 deletions(-)
9
10
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/arm/aspeed_soc.c
13
+++ b/hw/arm/aspeed_soc.c
14
@@ -XXX,XX +XXX,XX @@ static qemu_irq aspeed_soc_ast2400_get_irq(AspeedSoCState *s, int dev)
15
return qdev_get_gpio_in(DEVICE(&s->vic), sc->irqmap[dev]);
16
}
17
18
-static void aspeed_soc_init(Object *obj)
19
+static void aspeed_ast2400_soc_init(Object *obj)
20
{
21
AspeedSoCState *s = ASPEED_SOC(obj);
22
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
23
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data)
24
static const TypeInfo aspeed_soc_ast2400_type_info = {
25
.name = "ast2400-a1",
26
.parent = TYPE_ASPEED_SOC,
27
- .instance_init = aspeed_soc_init,
28
+ .instance_init = aspeed_ast2400_soc_init,
29
.instance_size = sizeof(AspeedSoCState),
30
.class_init = aspeed_soc_ast2400_class_init,
31
};
32
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data)
33
static const TypeInfo aspeed_soc_ast2500_type_info = {
34
.name = "ast2500-a1",
35
.parent = TYPE_ASPEED_SOC,
36
- .instance_init = aspeed_soc_init,
37
+ .instance_init = aspeed_ast2400_soc_init,
38
.instance_size = sizeof(AspeedSoCState),
39
.class_init = aspeed_soc_ast2500_class_init,
40
};
41
--
42
2.41.0
43
44
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
3
Keep aspeed_soc_class_init() generic, set the realize handler
4
to aspeed_ast2400_soc_realize() in each 2400/2500 class_init.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
---
10
hw/arm/aspeed_soc.c | 15 +++++++++++----
11
1 file changed, 11 insertions(+), 4 deletions(-)
12
13
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/aspeed_soc.c
16
+++ b/hw/arm/aspeed_soc.c
17
@@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_init(Object *obj)
18
object_initialize_child(obj, "video", &s->video, TYPE_UNIMPLEMENTED_DEVICE);
19
}
20
21
-static void aspeed_soc_realize(DeviceState *dev, Error **errp)
22
+static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)
23
{
24
int i;
25
AspeedSoCState *s = ASPEED_SOC(dev);
26
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data)
27
{
28
DeviceClass *dc = DEVICE_CLASS(oc);
29
30
- dc->realize = aspeed_soc_realize;
31
- /* Reason: Uses serial_hds and nd_table in realize() directly */
32
- dc->user_creatable = false;
33
device_class_set_props(dc, aspeed_soc_properties);
34
}
35
36
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_soc_type_info = {
37
static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data)
38
{
39
AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc);
40
+ DeviceClass *dc = DEVICE_CLASS(oc);
41
+
42
+ dc->realize = aspeed_ast2400_soc_realize;
43
+ /* Reason: Uses serial_hds and nd_table in realize() directly */
44
+ dc->user_creatable = false;
45
46
sc->name = "ast2400-a1";
47
sc->cpu_type = ARM_CPU_TYPE_NAME("arm926");
48
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_soc_ast2400_type_info = {
49
static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data)
50
{
51
AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc);
52
+ DeviceClass *dc = DEVICE_CLASS(oc);
53
+
54
+ dc->realize = aspeed_ast2400_soc_realize;
55
+ /* Reason: Uses serial_hds and nd_table in realize() directly */
56
+ dc->user_creatable = false;
57
58
sc->name = "ast2500-a1";
59
sc->cpu_type = ARM_CPU_TYPE_NAME("arm1176");
60
--
61
2.41.0
62
63
diff view generated by jsdifflib
New patch
1
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
3
We want to derivate the big AspeedSoCState object in some more
4
SoC-specific ones. Since the object size will vary, allocate it
5
dynamically.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
10
---
11
hw/arm/aspeed.c | 101 +++++++++++++++++++++++++-----------------------
12
1 file changed, 52 insertions(+), 49 deletions(-)
13
14
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/aspeed.c
17
+++ b/hw/arm/aspeed.c
18
@@ -XXX,XX +XXX,XX @@ struct AspeedMachineState {
19
MachineState parent_obj;
20
/* Public */
21
22
- AspeedSoCState soc;
23
+ AspeedSoCState *soc;
24
MemoryRegion boot_rom;
25
bool mmio_exec;
26
uint32_t uart_chosen;
27
@@ -XXX,XX +XXX,XX @@ static void write_boot_rom(BlockBackend *blk, hwaddr addr, size_t rom_size,
28
static void aspeed_install_boot_rom(AspeedMachineState *bmc, BlockBackend *blk,
29
uint64_t rom_size)
30
{
31
- AspeedSoCState *soc = &bmc->soc;
32
+ AspeedSoCState *soc = bmc->soc;
33
34
memory_region_init_rom(&bmc->boot_rom, NULL, "aspeed.boot_rom", rom_size,
35
&error_abort);
36
@@ -XXX,XX +XXX,XX @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo)
37
static void connect_serial_hds_to_uarts(AspeedMachineState *bmc)
38
{
39
AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(bmc);
40
- AspeedSoCState *s = &bmc->soc;
41
+ AspeedSoCState *s = bmc->soc;
42
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
43
int uart_chosen = bmc->uart_chosen ? bmc->uart_chosen : amc->uart_default;
44
45
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
46
int i;
47
NICInfo *nd = &nd_table[0];
48
49
- object_initialize_child(OBJECT(machine), "soc", &bmc->soc, amc->soc_name);
50
-
51
- sc = ASPEED_SOC_GET_CLASS(&bmc->soc);
52
+ bmc->soc = ASPEED_SOC(object_new(amc->soc_name));
53
+ object_property_add_child(OBJECT(machine), "soc", OBJECT(bmc->soc));
54
+ object_unref(OBJECT(bmc->soc));
55
+ sc = ASPEED_SOC_GET_CLASS(bmc->soc);
56
57
/*
58
* This will error out if the RAM size is not supported by the
59
* memory controller of the SoC.
60
*/
61
- object_property_set_uint(OBJECT(&bmc->soc), "ram-size", machine->ram_size,
62
+ object_property_set_uint(OBJECT(bmc->soc), "ram-size", machine->ram_size,
63
&error_fatal);
64
65
for (i = 0; i < sc->macs_num; i++) {
66
if ((amc->macs_mask & (1 << i)) && nd->used) {
67
qemu_check_nic_model(nd, TYPE_FTGMAC100);
68
- qdev_set_nic_properties(DEVICE(&bmc->soc.ftgmac100[i]), nd);
69
+ qdev_set_nic_properties(DEVICE(&bmc->soc->ftgmac100[i]), nd);
70
nd++;
71
}
72
}
73
74
- object_property_set_int(OBJECT(&bmc->soc), "hw-strap1", amc->hw_strap1,
75
+ object_property_set_int(OBJECT(bmc->soc), "hw-strap1", amc->hw_strap1,
76
&error_abort);
77
- object_property_set_int(OBJECT(&bmc->soc), "hw-strap2", amc->hw_strap2,
78
+ object_property_set_int(OBJECT(bmc->soc), "hw-strap2", amc->hw_strap2,
79
&error_abort);
80
- object_property_set_link(OBJECT(&bmc->soc), "memory",
81
+ object_property_set_link(OBJECT(bmc->soc), "memory",
82
OBJECT(get_system_memory()), &error_abort);
83
- object_property_set_link(OBJECT(&bmc->soc), "dram",
84
+ object_property_set_link(OBJECT(bmc->soc), "dram",
85
OBJECT(machine->ram), &error_abort);
86
if (machine->kernel_filename) {
87
/*
88
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
89
* that runs to unlock the SCU. In this case set the default to
90
* be unlocked as the kernel expects
91
*/
92
- object_property_set_int(OBJECT(&bmc->soc), "hw-prot-key",
93
+ object_property_set_int(OBJECT(bmc->soc), "hw-prot-key",
94
ASPEED_SCU_PROT_KEY, &error_abort);
95
}
96
connect_serial_hds_to_uarts(bmc);
97
- qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort);
98
+ qdev_realize(DEVICE(bmc->soc), NULL, &error_abort);
99
100
if (defaults_enabled()) {
101
- aspeed_board_init_flashes(&bmc->soc.fmc,
102
+ aspeed_board_init_flashes(&bmc->soc->fmc,
103
bmc->fmc_model ? bmc->fmc_model : amc->fmc_model,
104
amc->num_cs, 0);
105
- aspeed_board_init_flashes(&bmc->soc.spi[0],
106
+ aspeed_board_init_flashes(&bmc->soc->spi[0],
107
bmc->spi_model ? bmc->spi_model : amc->spi_model,
108
1, amc->num_cs);
109
}
110
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
111
amc->i2c_init(bmc);
112
}
113
114
- for (i = 0; i < bmc->soc.sdhci.num_slots; i++) {
115
- sdhci_attach_drive(&bmc->soc.sdhci.slots[i],
116
+ for (i = 0; i < bmc->soc->sdhci.num_slots; i++) {
117
+ sdhci_attach_drive(&bmc->soc->sdhci.slots[i],
118
drive_get(IF_SD, 0, i));
119
}
120
121
- if (bmc->soc.emmc.num_slots) {
122
- sdhci_attach_drive(&bmc->soc.emmc.slots[0],
123
- drive_get(IF_SD, 0, bmc->soc.sdhci.num_slots));
124
+ if (bmc->soc->emmc.num_slots) {
125
+ sdhci_attach_drive(&bmc->soc->emmc.slots[0],
126
+ drive_get(IF_SD, 0, bmc->soc->sdhci.num_slots));
127
}
128
129
if (!bmc->mmio_exec) {
130
- DeviceState *dev = ssi_get_cs(bmc->soc.fmc.spi, 0);
131
+ DeviceState *dev = ssi_get_cs(bmc->soc->fmc.spi, 0);
132
BlockBackend *fmc0 = dev ? m25p80_get_blk(dev) : NULL;
133
134
if (fmc0) {
135
- uint64_t rom_size = memory_region_size(&bmc->soc.spi_boot);
136
+ uint64_t rom_size = memory_region_size(&bmc->soc->spi_boot);
137
aspeed_install_boot_rom(bmc, fmc0, rom_size);
138
}
139
}
140
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
141
142
static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)
143
{
144
- AspeedSoCState *soc = &bmc->soc;
145
+ AspeedSoCState *soc = bmc->soc;
146
DeviceState *dev;
147
uint8_t *eeprom_buf = g_malloc0(32 * 1024);
148
149
@@ -XXX,XX +XXX,XX @@ static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)
150
151
static void quanta_q71l_bmc_i2c_init(AspeedMachineState *bmc)
152
{
153
- AspeedSoCState *soc = &bmc->soc;
154
+ AspeedSoCState *soc = bmc->soc;
155
156
/*
157
* The quanta-q71l platform expects tmp75s which are compatible with
158
@@ -XXX,XX +XXX,XX @@ static void quanta_q71l_bmc_i2c_init(AspeedMachineState *bmc)
159
160
static void ast2500_evb_i2c_init(AspeedMachineState *bmc)
161
{
162
- AspeedSoCState *soc = &bmc->soc;
163
+ AspeedSoCState *soc = bmc->soc;
164
uint8_t *eeprom_buf = g_malloc0(8 * 1024);
165
166
smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 3), 0x50,
167
@@ -XXX,XX +XXX,XX @@ static void ast2500_evb_i2c_init(AspeedMachineState *bmc)
168
169
static void ast2600_evb_i2c_init(AspeedMachineState *bmc)
170
{
171
- AspeedSoCState *soc = &bmc->soc;
172
+ AspeedSoCState *soc = bmc->soc;
173
uint8_t *eeprom_buf = g_malloc0(8 * 1024);
174
175
smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50,
176
@@ -XXX,XX +XXX,XX @@ static void ast2600_evb_i2c_init(AspeedMachineState *bmc)
177
178
static void yosemitev2_bmc_i2c_init(AspeedMachineState *bmc)
179
{
180
- AspeedSoCState *soc = &bmc->soc;
181
+ AspeedSoCState *soc = bmc->soc;
182
183
at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 4), 0x51, 128 * KiB);
184
at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 128 * KiB,
185
@@ -XXX,XX +XXX,XX @@ static void yosemitev2_bmc_i2c_init(AspeedMachineState *bmc)
186
187
static void romulus_bmc_i2c_init(AspeedMachineState *bmc)
188
{
189
- AspeedSoCState *soc = &bmc->soc;
190
+ AspeedSoCState *soc = bmc->soc;
191
192
/* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is
193
* good enough */
194
@@ -XXX,XX +XXX,XX @@ static void romulus_bmc_i2c_init(AspeedMachineState *bmc)
195
196
static void tiogapass_bmc_i2c_init(AspeedMachineState *bmc)
197
{
198
- AspeedSoCState *soc = &bmc->soc;
199
+ AspeedSoCState *soc = bmc->soc;
200
201
at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 4), 0x54, 128 * KiB);
202
at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 6), 0x54, 128 * KiB,
203
@@ -XXX,XX +XXX,XX @@ static void create_pca9552(AspeedSoCState *soc, int bus_id, int addr)
204
205
static void sonorapass_bmc_i2c_init(AspeedMachineState *bmc)
206
{
207
- AspeedSoCState *soc = &bmc->soc;
208
+ AspeedSoCState *soc = bmc->soc;
209
210
/* bus 2 : */
211
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), "tmp105", 0x48);
212
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)
213
{14, LED_COLOR_GREEN, "front-power-3", GPIO_POLARITY_ACTIVE_LOW},
214
{15, LED_COLOR_GREEN, "front-id-5", GPIO_POLARITY_ACTIVE_LOW},
215
};
216
- AspeedSoCState *soc = &bmc->soc;
217
+ AspeedSoCState *soc = bmc->soc;
218
uint8_t *eeprom_buf = g_malloc0(8 * 1024);
219
DeviceState *dev;
220
LEDState *led;
221
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)
222
223
static void g220a_bmc_i2c_init(AspeedMachineState *bmc)
224
{
225
- AspeedSoCState *soc = &bmc->soc;
226
+ AspeedSoCState *soc = bmc->soc;
227
DeviceState *dev;
228
229
dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3),
230
@@ -XXX,XX +XXX,XX @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc)
231
232
static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc)
233
{
234
- AspeedSoCState *soc = &bmc->soc;
235
+ AspeedSoCState *soc = bmc->soc;
236
I2CSlave *i2c_mux;
237
238
/* The at24c256 */
239
@@ -XXX,XX +XXX,XX @@ static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc)
240
241
static void rainier_bmc_i2c_init(AspeedMachineState *bmc)
242
{
243
- AspeedSoCState *soc = &bmc->soc;
244
+ AspeedSoCState *soc = bmc->soc;
245
I2CSlave *i2c_mux;
246
247
at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 0), 0x51, 32 * KiB);
248
@@ -XXX,XX +XXX,XX @@ static void get_pca9548_channels(I2CBus *bus, uint8_t mux_addr,
249
250
static void fuji_bmc_i2c_init(AspeedMachineState *bmc)
251
{
252
- AspeedSoCState *soc = &bmc->soc;
253
+ AspeedSoCState *soc = bmc->soc;
254
I2CBus *i2c[144] = {};
255
256
for (int i = 0; i < 16; i++) {
257
@@ -XXX,XX +XXX,XX @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)
258
259
static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)
260
{
261
- AspeedSoCState *soc = &bmc->soc;
262
+ AspeedSoCState *soc = bmc->soc;
263
I2CBus *i2c[13] = {};
264
for (int i = 0; i < 13; i++) {
265
if ((i == 8) || (i == 11)) {
266
@@ -XXX,XX +XXX,XX @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)
267
268
static void fby35_i2c_init(AspeedMachineState *bmc)
269
{
270
- AspeedSoCState *soc = &bmc->soc;
271
+ AspeedSoCState *soc = bmc->soc;
272
I2CBus *i2c[16];
273
274
for (int i = 0; i < 16; i++) {
275
@@ -XXX,XX +XXX,XX @@ static void fby35_i2c_init(AspeedMachineState *bmc)
276
277
static void qcom_dc_scm_bmc_i2c_init(AspeedMachineState *bmc)
278
{
279
- AspeedSoCState *soc = &bmc->soc;
280
+ AspeedSoCState *soc = bmc->soc;
281
282
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 15), "tmp105", 0x4d);
283
}
284
285
static void qcom_dc_scm_firework_i2c_init(AspeedMachineState *bmc)
286
{
287
- AspeedSoCState *soc = &bmc->soc;
288
+ AspeedSoCState *soc = bmc->soc;
289
I2CSlave *therm_mux, *cpuvr_mux;
290
291
/* Create the generic DC-SCM hardware */
292
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_bletchley_class_init(ObjectClass *oc, void *data)
293
static void fby35_reset(MachineState *state, ShutdownCause reason)
294
{
295
AspeedMachineState *bmc = ASPEED_MACHINE(state);
296
- AspeedGPIOState *gpio = &bmc->soc.gpio;
297
+ AspeedGPIOState *gpio = &bmc->soc->gpio;
298
299
qemu_devices_reset(reason);
300
301
@@ -XXX,XX +XXX,XX @@ static void aspeed_minibmc_machine_init(MachineState *machine)
302
sysclk = clock_new(OBJECT(machine), "SYSCLK");
303
clock_set_hz(sysclk, SYSCLK_FRQ);
304
305
- object_initialize_child(OBJECT(machine), "soc", &bmc->soc, amc->soc_name);
306
- qdev_connect_clock_in(DEVICE(&bmc->soc), "sysclk", sysclk);
307
+ bmc->soc = ASPEED_SOC(object_new(amc->soc_name));
308
+ object_property_add_child(OBJECT(machine), "soc", OBJECT(bmc->soc));
309
+ object_unref(OBJECT(bmc->soc));
310
+ qdev_connect_clock_in(DEVICE(bmc->soc), "sysclk", sysclk);
311
312
- object_property_set_link(OBJECT(&bmc->soc), "memory",
313
+ object_property_set_link(OBJECT(bmc->soc), "memory",
314
OBJECT(get_system_memory()), &error_abort);
315
connect_serial_hds_to_uarts(bmc);
316
- qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort);
317
+ qdev_realize(DEVICE(bmc->soc), NULL, &error_abort);
318
319
- aspeed_board_init_flashes(&bmc->soc.fmc,
320
+ aspeed_board_init_flashes(&bmc->soc->fmc,
321
bmc->fmc_model ? bmc->fmc_model : amc->fmc_model,
322
amc->num_cs,
323
0);
324
325
- aspeed_board_init_flashes(&bmc->soc.spi[0],
326
+ aspeed_board_init_flashes(&bmc->soc->spi[0],
327
bmc->spi_model ? bmc->spi_model : amc->spi_model,
328
amc->num_cs, amc->num_cs);
329
330
- aspeed_board_init_flashes(&bmc->soc.spi[1],
331
+ aspeed_board_init_flashes(&bmc->soc->spi[1],
332
bmc->spi_model ? bmc->spi_model : amc->spi_model,
333
amc->num_cs, (amc->num_cs * 2));
334
335
@@ -XXX,XX +XXX,XX @@ static void aspeed_minibmc_machine_init(MachineState *machine)
336
337
static void ast1030_evb_i2c_init(AspeedMachineState *bmc)
338
{
339
- AspeedSoCState *soc = &bmc->soc;
340
+ AspeedSoCState *soc = bmc->soc;
341
342
/* U10 24C08 connects to SDA/SCL Group 1 by default */
343
uint8_t *eeprom_buf = g_malloc0(32 * 1024);
344
--
345
2.41.0
346
347
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
3
TYPE_ASPEED10X0_SOC inherits from TYPE_ASPEED_SOC.
4
In few commits we'll add more fields, but to keep
5
review process simple, don't add any yet.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
10
---
11
include/hw/arm/aspeed_soc.h | 7 +++++++
12
hw/arm/aspeed_ast10x0.c | 26 +++++++++++++-------------
13
2 files changed, 20 insertions(+), 13 deletions(-)
14
15
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/arm/aspeed_soc.h
18
+++ b/include/hw/arm/aspeed_soc.h
19
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
20
#define TYPE_ASPEED_SOC "aspeed-soc"
21
OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC)
22
23
+struct Aspeed10x0SoCState {
24
+ AspeedSoCState parent;
25
+};
26
+
27
+#define TYPE_ASPEED10X0_SOC "aspeed10x0-soc"
28
+OBJECT_DECLARE_SIMPLE_TYPE(Aspeed10x0SoCState, ASPEED10X0_SOC)
29
+
30
struct AspeedSoCClass {
31
DeviceClass parent_class;
32
33
diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/arm/aspeed_ast10x0.c
36
+++ b/hw/arm/aspeed_ast10x0.c
37
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_class_init(ObjectClass *klass, void *data)
38
sc->get_irq = aspeed_soc_ast1030_get_irq;
39
}
40
41
-static const TypeInfo aspeed_soc_ast1030_type_info = {
42
- .name = "ast1030-a1",
43
- .parent = TYPE_ASPEED_SOC,
44
- .instance_size = sizeof(AspeedSoCState),
45
- .instance_init = aspeed_soc_ast1030_init,
46
- .class_init = aspeed_soc_ast1030_class_init,
47
- .class_size = sizeof(AspeedSoCClass),
48
+static const TypeInfo aspeed_soc_ast10x0_types[] = {
49
+ {
50
+ .name = TYPE_ASPEED10X0_SOC,
51
+ .parent = TYPE_ASPEED_SOC,
52
+ .instance_size = sizeof(Aspeed10x0SoCState),
53
+ .abstract = true,
54
+ }, {
55
+ .name = "ast1030-a1",
56
+ .parent = TYPE_ASPEED10X0_SOC,
57
+ .instance_init = aspeed_soc_ast1030_init,
58
+ .class_init = aspeed_soc_ast1030_class_init,
59
+ },
60
};
61
62
-static void aspeed_soc_register_types(void)
63
-{
64
- type_register_static(&aspeed_soc_ast1030_type_info);
65
-}
66
-
67
-type_init(aspeed_soc_register_types)
68
+DEFINE_TYPES(aspeed_soc_ast10x0_types)
69
--
70
2.41.0
71
72
diff view generated by jsdifflib
1
From: Andrew Jeffery <andrew@aj.id.au>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
This appears to be a requirement of the GIC model. The AST2600 allocates
3
TYPE_ASPEED2600_SOC inherits from TYPE_ASPEED_SOC.
4
197 GIC IRQs, which we will adjust shortly.
4
In few commits we'll add more fields, but to keep
5
review process simple, don't add any yet.
5
6
6
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Message-Id: <20210302014317.915120-2-andrew@aj.id.au>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
10
---
10
---
11
hw/arm/aspeed_ast2600.c | 4 ++--
11
include/hw/arm/aspeed_soc.h | 7 +++++++
12
1 file changed, 2 insertions(+), 2 deletions(-)
12
hw/arm/aspeed_ast2600.c | 26 +++++++++++++-------------
13
2 files changed, 20 insertions(+), 13 deletions(-)
13
14
15
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/arm/aspeed_soc.h
18
+++ b/include/hw/arm/aspeed_soc.h
19
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
20
#define TYPE_ASPEED_SOC "aspeed-soc"
21
OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC)
22
23
+struct Aspeed2600SoCState {
24
+ AspeedSoCState parent;
25
+};
26
+
27
+#define TYPE_ASPEED2600_SOC "aspeed2600-soc"
28
+OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2600SoCState, ASPEED2600_SOC)
29
+
30
struct Aspeed10x0SoCState {
31
AspeedSoCState parent;
32
};
14
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
33
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
15
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/aspeed_ast2600.c
35
--- a/hw/arm/aspeed_ast2600.c
17
+++ b/hw/arm/aspeed_ast2600.c
36
+++ b/hw/arm/aspeed_ast2600.c
18
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
37
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
19
38
sc->get_irq = aspeed_soc_ast2600_get_irq;
20
#define ASPEED_A7MPCORE_ADDR 0x40460000
39
}
21
40
22
-#define ASPEED_SOC_AST2600_MAX_IRQ 128
41
-static const TypeInfo aspeed_soc_ast2600_type_info = {
23
+#define AST2600_MAX_IRQ 128
42
- .name = "ast2600-a3",
24
43
- .parent = TYPE_ASPEED_SOC,
25
/* Shared Peripheral Interrupt values below are offset by -32 from datasheet */
44
- .instance_size = sizeof(AspeedSoCState),
26
static const int aspeed_soc_ast2600_irqmap[] = {
45
- .instance_init = aspeed_soc_ast2600_init,
27
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
46
- .class_init = aspeed_soc_ast2600_class_init,
28
object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", sc->num_cpus,
47
- .class_size = sizeof(AspeedSoCClass),
29
&error_abort);
48
+static const TypeInfo aspeed_soc_ast2600_types[] = {
30
object_property_set_int(OBJECT(&s->a7mpcore), "num-irq",
49
+ {
31
- ASPEED_SOC_AST2600_MAX_IRQ + GIC_INTERNAL,
50
+ .name = TYPE_ASPEED2600_SOC,
32
+ ROUND_UP(AST2600_MAX_IRQ + GIC_INTERNAL, 32),
51
+ .parent = TYPE_ASPEED_SOC,
33
&error_abort);
52
+ .instance_size = sizeof(Aspeed2600SoCState),
34
53
+ .abstract = true,
35
sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort);
54
+ }, {
55
+ .name = "ast2600-a3",
56
+ .parent = TYPE_ASPEED2600_SOC,
57
+ .instance_init = aspeed_soc_ast2600_init,
58
+ .class_init = aspeed_soc_ast2600_class_init,
59
+ },
60
};
61
62
-static void aspeed_soc_register_types(void)
63
-{
64
- type_register_static(&aspeed_soc_ast2600_type_info);
65
-};
66
-
67
-type_init(aspeed_soc_register_types)
68
+DEFINE_TYPES(aspeed_soc_ast2600_types)
36
--
69
--
37
2.26.2
70
2.41.0
38
71
39
72
diff view generated by jsdifflib
1
From: Andrew Jeffery <andrew@aj.id.au>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Keyboard-Controller-Style devices for IPMI purposes are exposed via LPC
3
TYPE_ASPEED2400_SOC inherits from TYPE_ASPEED_SOC.
4
IO cycles from the BMC to the host.
4
In few commits we'll add more fields, but to keep
5
review process simple, don't add any yet.
5
6
6
Expose support on the BMC side by implementing the usual MMIO
7
TYPE_ASPEED_SOC is common to various Aspeed SoCs,
7
behaviours, and expose the ability to inspect the KCS registers in
8
define it in aspeed_soc_common.c.
8
"host" style by accessing QOM properties associated with each register.
9
9
10
The model caters to the IRQ style of both the AST2600 and the earlier
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
SoCs (AST2400 and AST2500). The AST2600 allocates an IRQ for each LPC
12
sub-device, while there is a single IRQ shared across all subdevices on
13
the AST2400 and AST2500.
14
15
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
16
Reviewed-by: Cédric Le Goater <clg@kaod.org>
11
Reviewed-by: Cédric Le Goater <clg@kaod.org>
17
Message-Id: <20210302014317.915120-6-andrew@aj.id.au>
18
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
Signed-off-by: Cédric Le Goater <clg@kaod.org>
19
---
13
---
20
include/hw/arm/aspeed_soc.h | 1 +
14
include/hw/arm/aspeed_soc.h | 7 +++++
21
include/hw/misc/aspeed_lpc.h | 17 +-
15
hw/arm/aspeed_soc.c | 61 +++++++++++--------------------------
22
hw/arm/aspeed_ast2600.c | 28 ++-
16
hw/arm/aspeed_soc_common.c | 29 ++++++++++++++++++
23
hw/arm/aspeed_soc.c | 24 ++-
17
3 files changed, 53 insertions(+), 44 deletions(-)
24
hw/misc/aspeed_lpc.c | 359 ++++++++++++++++++++++++++++++++++-
25
5 files changed, 424 insertions(+), 5 deletions(-)
26
18
27
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
19
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
28
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
29
--- a/include/hw/arm/aspeed_soc.h
21
--- a/include/hw/arm/aspeed_soc.h
30
+++ b/include/hw/arm/aspeed_soc.h
22
+++ b/include/hw/arm/aspeed_soc.h
31
@@ -XXX,XX +XXX,XX @@ enum {
23
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
32
ASPEED_DEV_SDRAM,
24
#define TYPE_ASPEED_SOC "aspeed-soc"
33
ASPEED_DEV_XDMA,
25
OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC)
34
ASPEED_DEV_EMMC,
26
35
+ ASPEED_DEV_KCS,
27
+struct Aspeed2400SoCState {
36
};
28
+ AspeedSoCState parent;
37
38
#endif /* ASPEED_SOC_H */
39
diff --git a/include/hw/misc/aspeed_lpc.h b/include/hw/misc/aspeed_lpc.h
40
index XXXXXXX..XXXXXXX 100644
41
--- a/include/hw/misc/aspeed_lpc.h
42
+++ b/include/hw/misc/aspeed_lpc.h
43
@@ -XXX,XX +XXX,XX @@
44
45
#include "hw/sysbus.h"
46
47
+#include <stdint.h>
48
+
49
#define TYPE_ASPEED_LPC "aspeed.lpc"
50
#define ASPEED_LPC(obj) OBJECT_CHECK(AspeedLPCState, (obj), TYPE_ASPEED_LPC)
51
52
-#define ASPEED_LPC_NR_REGS (0x260 >> 2)
53
+#define ASPEED_LPC_NR_REGS (0x260 >> 2)
54
+
55
+enum aspeed_lpc_subdevice {
56
+ aspeed_lpc_kcs_1 = 0,
57
+ aspeed_lpc_kcs_2,
58
+ aspeed_lpc_kcs_3,
59
+ aspeed_lpc_kcs_4,
60
+ aspeed_lpc_ibt,
61
+};
29
+};
62
+
30
+
63
+#define ASPEED_LPC_NR_SUBDEVS 5
31
+#define TYPE_ASPEED2400_SOC "aspeed2400-soc"
64
32
+OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2400SoCState, ASPEED2400_SOC)
65
typedef struct AspeedLPCState {
66
/* <private> */
67
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedLPCState {
68
MemoryRegion iomem;
69
qemu_irq irq;
70
71
+ qemu_irq subdevice_irqs[ASPEED_LPC_NR_SUBDEVS];
72
+ uint32_t subdevice_irqs_pending;
73
+
33
+
74
uint32_t regs[ASPEED_LPC_NR_REGS];
34
struct Aspeed2600SoCState {
75
uint32_t hicr7;
35
AspeedSoCState parent;
76
} AspeedLPCState;
77
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/hw/arm/aspeed_ast2600.c
80
+++ b/hw/arm/aspeed_ast2600.c
81
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = {
82
[ASPEED_DEV_ETH2] = 3,
83
[ASPEED_DEV_ETH3] = 32,
84
[ASPEED_DEV_ETH4] = 33,
85
-
86
+ [ASPEED_DEV_KCS] = 138, /* 138 -> 142 */
87
};
36
};
88
89
static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl)
90
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
91
return;
92
}
93
sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]);
94
+
95
+ /* Connect the LPC IRQ to the GIC. It is otherwise unused. */
96
sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0,
97
aspeed_soc_get_irq(s, ASPEED_DEV_LPC));
98
+
99
+ /*
100
+ * On the AST2600 LPC subdevice IRQs are connected straight to the GIC.
101
+ *
102
+ * LPC subdevice IRQ sources are offset from 1 because the LPC model caters
103
+ * to the AST2400 and AST2500. SoCs before the AST2600 have one LPC IRQ
104
+ * shared across the subdevices, and the shared IRQ output to the VIC is at
105
+ * offset 0.
106
+ */
107
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_1,
108
+ qdev_get_gpio_in(DEVICE(&s->a7mpcore),
109
+ sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_1));
110
+
111
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_2,
112
+ qdev_get_gpio_in(DEVICE(&s->a7mpcore),
113
+ sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_2));
114
+
115
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_3,
116
+ qdev_get_gpio_in(DEVICE(&s->a7mpcore),
117
+ sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_3));
118
+
119
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4,
120
+ qdev_get_gpio_in(DEVICE(&s->a7mpcore),
121
+ sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_4));
122
}
123
124
static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
125
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
37
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
126
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
127
--- a/hw/arm/aspeed_soc.c
39
--- a/hw/arm/aspeed_soc.c
128
+++ b/hw/arm/aspeed_soc.c
40
+++ b/hw/arm/aspeed_soc.c
129
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = {
41
@@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)
130
[ASPEED_DEV_WDT] = 27,
42
sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
131
[ASPEED_DEV_PWM] = 28,
43
aspeed_soc_get_irq(s, ASPEED_DEV_HACE));
132
[ASPEED_DEV_LPC] = 8,
44
}
133
- [ASPEED_DEV_IBT] = 8, /* LPC */
45
-static Property aspeed_soc_properties[] = {
134
[ASPEED_DEV_I2C] = 12,
46
- DEFINE_PROP_LINK("memory", AspeedSoCState, memory, TYPE_MEMORY_REGION,
135
[ASPEED_DEV_ETH1] = 2,
47
- MemoryRegion *),
136
[ASPEED_DEV_ETH2] = 3,
48
- DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
137
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
49
- MemoryRegion *),
138
return;
50
- DEFINE_PROP_END_OF_LIST(),
139
}
51
-};
140
sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]);
52
-
53
-static void aspeed_soc_class_init(ObjectClass *oc, void *data)
54
-{
55
- DeviceClass *dc = DEVICE_CLASS(oc);
56
-
57
- device_class_set_props(dc, aspeed_soc_properties);
58
-}
59
-
60
-static const TypeInfo aspeed_soc_type_info = {
61
- .name = TYPE_ASPEED_SOC,
62
- .parent = TYPE_DEVICE,
63
- .instance_size = sizeof(AspeedSoCState),
64
- .class_size = sizeof(AspeedSoCClass),
65
- .class_init = aspeed_soc_class_init,
66
- .abstract = true,
67
-};
68
69
static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data)
70
{
71
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data)
72
sc->get_irq = aspeed_soc_ast2400_get_irq;
73
}
74
75
-static const TypeInfo aspeed_soc_ast2400_type_info = {
76
- .name = "ast2400-a1",
77
- .parent = TYPE_ASPEED_SOC,
78
- .instance_init = aspeed_ast2400_soc_init,
79
- .instance_size = sizeof(AspeedSoCState),
80
- .class_init = aspeed_soc_ast2400_class_init,
81
-};
82
-
83
static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data)
84
{
85
AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc);
86
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data)
87
sc->get_irq = aspeed_soc_ast2400_get_irq;
88
}
89
90
-static const TypeInfo aspeed_soc_ast2500_type_info = {
91
- .name = "ast2500-a1",
92
- .parent = TYPE_ASPEED_SOC,
93
- .instance_init = aspeed_ast2400_soc_init,
94
- .instance_size = sizeof(AspeedSoCState),
95
- .class_init = aspeed_soc_ast2500_class_init,
96
-};
97
-static void aspeed_soc_register_types(void)
98
-{
99
- type_register_static(&aspeed_soc_type_info);
100
- type_register_static(&aspeed_soc_ast2400_type_info);
101
- type_register_static(&aspeed_soc_ast2500_type_info);
102
+static const TypeInfo aspeed_soc_ast2400_types[] = {
103
+ {
104
+ .name = TYPE_ASPEED2400_SOC,
105
+ .parent = TYPE_ASPEED_SOC,
106
+ .instance_init = aspeed_ast2400_soc_init,
107
+ .instance_size = sizeof(Aspeed2400SoCState),
108
+ .abstract = true,
109
+ }, {
110
+ .name = "ast2400-a1",
111
+ .parent = TYPE_ASPEED2400_SOC,
112
+ .class_init = aspeed_soc_ast2400_class_init,
113
+ }, {
114
+ .name = "ast2500-a1",
115
+ .parent = TYPE_ASPEED2400_SOC,
116
+ .class_init = aspeed_soc_ast2500_class_init,
117
+ },
118
};
119
120
-type_init(aspeed_soc_register_types);
121
+DEFINE_TYPES(aspeed_soc_ast2400_types)
122
diff --git a/hw/arm/aspeed_soc_common.c b/hw/arm/aspeed_soc_common.c
123
index XXXXXXX..XXXXXXX 100644
124
--- a/hw/arm/aspeed_soc_common.c
125
+++ b/hw/arm/aspeed_soc_common.c
126
@@ -XXX,XX +XXX,XX @@
127
128
#include "qemu/osdep.h"
129
#include "qapi/error.h"
130
+#include "hw/qdev-properties.h"
131
#include "hw/misc/unimp.h"
132
#include "hw/arm/aspeed_soc.h"
133
#include "hw/char/serial.h"
134
@@ -XXX,XX +XXX,XX @@ void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev,
135
memory_region_add_subregion_overlap(s->memory, addr,
136
sysbus_mmio_get_region(dev, 0), -1000);
137
}
141
+
138
+
142
+ /* Connect the LPC IRQ to the VIC */
139
+static Property aspeed_soc_properties[] = {
143
sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0,
140
+ DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
144
aspeed_soc_get_irq(s, ASPEED_DEV_LPC));
141
+ MemoryRegion *),
145
+
142
+ DEFINE_PROP_LINK("memory", AspeedSoCState, memory, TYPE_MEMORY_REGION,
146
+ /*
143
+ MemoryRegion *),
147
+ * On the AST2400 and AST2500 the one LPC IRQ is shared between all of the
144
+ DEFINE_PROP_END_OF_LIST(),
148
+ * subdevices. Connect the LPC subdevice IRQs to the LPC controller IRQ (by
149
+ * contrast, on the AST2600, the subdevice IRQs are connected straight to
150
+ * the GIC).
151
+ *
152
+ * LPC subdevice IRQ sources are offset from 1 because the shared IRQ output
153
+ * to the VIC is at offset 0.
154
+ */
155
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_1,
156
+ qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_1));
157
+
158
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_2,
159
+ qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_2));
160
+
161
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_3,
162
+ qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_3));
163
+
164
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4,
165
+ qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_4));
166
}
167
static Property aspeed_soc_properties[] = {
168
DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
169
diff --git a/hw/misc/aspeed_lpc.c b/hw/misc/aspeed_lpc.c
170
index XXXXXXX..XXXXXXX 100644
171
--- a/hw/misc/aspeed_lpc.c
172
+++ b/hw/misc/aspeed_lpc.c
173
@@ -XXX,XX +XXX,XX @@
174
#include "qemu/error-report.h"
175
#include "hw/misc/aspeed_lpc.h"
176
#include "qapi/error.h"
177
+#include "qapi/visitor.h"
178
+#include "hw/irq.h"
179
#include "hw/qdev-properties.h"
180
#include "migration/vmstate.h"
181
182
#define TO_REG(offset) ((offset) >> 2)
183
184
#define HICR0 TO_REG(0x00)
185
+#define HICR0_LPC3E BIT(7)
186
+#define HICR0_LPC2E BIT(6)
187
+#define HICR0_LPC1E BIT(5)
188
#define HICR1 TO_REG(0x04)
189
#define HICR2 TO_REG(0x08)
190
+#define HICR2_IBFIE3 BIT(3)
191
+#define HICR2_IBFIE2 BIT(2)
192
+#define HICR2_IBFIE1 BIT(1)
193
#define HICR3 TO_REG(0x0C)
194
#define HICR4 TO_REG(0x10)
195
+#define HICR4_KCSENBL BIT(2)
196
+#define IDR1 TO_REG(0x24)
197
+#define IDR2 TO_REG(0x28)
198
+#define IDR3 TO_REG(0x2C)
199
+#define ODR1 TO_REG(0x30)
200
+#define ODR2 TO_REG(0x34)
201
+#define ODR3 TO_REG(0x38)
202
+#define STR1 TO_REG(0x3C)
203
+#define STR_OBF BIT(0)
204
+#define STR_IBF BIT(1)
205
+#define STR_CMD_DATA BIT(3)
206
+#define STR2 TO_REG(0x40)
207
+#define STR3 TO_REG(0x44)
208
#define HICR5 TO_REG(0x80)
209
#define HICR6 TO_REG(0x84)
210
#define HICR7 TO_REG(0x88)
211
#define HICR8 TO_REG(0x8C)
212
+#define HICRB TO_REG(0x100)
213
+#define HICRB_IBFIE4 BIT(1)
214
+#define HICRB_LPC4E BIT(0)
215
+#define IDR4 TO_REG(0x114)
216
+#define ODR4 TO_REG(0x118)
217
+#define STR4 TO_REG(0x11C)
218
+
219
+enum aspeed_kcs_channel_id {
220
+ kcs_channel_1 = 0,
221
+ kcs_channel_2,
222
+ kcs_channel_3,
223
+ kcs_channel_4,
224
+};
145
+};
225
+
146
+
226
+static const enum aspeed_lpc_subdevice aspeed_kcs_subdevice_map[] = {
147
+static void aspeed_soc_class_init(ObjectClass *oc, void *data)
227
+ [kcs_channel_1] = aspeed_lpc_kcs_1,
148
+{
228
+ [kcs_channel_2] = aspeed_lpc_kcs_2,
149
+ DeviceClass *dc = DEVICE_CLASS(oc);
229
+ [kcs_channel_3] = aspeed_lpc_kcs_3,
230
+ [kcs_channel_4] = aspeed_lpc_kcs_4,
231
+};
232
+
150
+
233
+struct aspeed_kcs_channel {
151
+ device_class_set_props(dc, aspeed_soc_properties);
234
+ enum aspeed_kcs_channel_id id;
152
+}
235
+
153
+
236
+ int idr;
154
+static const TypeInfo aspeed_soc_types[] = {
237
+ int odr;
155
+ {
238
+ int str;
156
+ .name = TYPE_ASPEED_SOC,
239
+};
157
+ .parent = TYPE_DEVICE,
240
+
158
+ .instance_size = sizeof(AspeedSoCState),
241
+static const struct aspeed_kcs_channel aspeed_kcs_channel_map[] = {
159
+ .class_size = sizeof(AspeedSoCClass),
242
+ [kcs_channel_1] = {
160
+ .class_init = aspeed_soc_class_init,
243
+ .id = kcs_channel_1,
161
+ .abstract = true,
244
+ .idr = IDR1,
245
+ .odr = ODR1,
246
+ .str = STR1
247
+ },
248
+
249
+ [kcs_channel_2] = {
250
+ .id = kcs_channel_2,
251
+ .idr = IDR2,
252
+ .odr = ODR2,
253
+ .str = STR2
254
+ },
255
+
256
+ [kcs_channel_3] = {
257
+ .id = kcs_channel_3,
258
+ .idr = IDR3,
259
+ .odr = ODR3,
260
+ .str = STR3
261
+ },
262
+
263
+ [kcs_channel_4] = {
264
+ .id = kcs_channel_4,
265
+ .idr = IDR4,
266
+ .odr = ODR4,
267
+ .str = STR4
268
+ },
162
+ },
269
+};
163
+};
270
+
164
+
271
+struct aspeed_kcs_register_data {
165
+DEFINE_TYPES(aspeed_soc_types)
272
+ const char *name;
273
+ int reg;
274
+ const struct aspeed_kcs_channel *chan;
275
+};
276
+
277
+static const struct aspeed_kcs_register_data aspeed_kcs_registers[] = {
278
+ {
279
+ .name = "idr1",
280
+ .reg = IDR1,
281
+ .chan = &aspeed_kcs_channel_map[kcs_channel_1],
282
+ },
283
+ {
284
+ .name = "odr1",
285
+ .reg = ODR1,
286
+ .chan = &aspeed_kcs_channel_map[kcs_channel_1],
287
+ },
288
+ {
289
+ .name = "str1",
290
+ .reg = STR1,
291
+ .chan = &aspeed_kcs_channel_map[kcs_channel_1],
292
+ },
293
+ {
294
+ .name = "idr2",
295
+ .reg = IDR2,
296
+ .chan = &aspeed_kcs_channel_map[kcs_channel_2],
297
+ },
298
+ {
299
+ .name = "odr2",
300
+ .reg = ODR2,
301
+ .chan = &aspeed_kcs_channel_map[kcs_channel_2],
302
+ },
303
+ {
304
+ .name = "str2",
305
+ .reg = STR2,
306
+ .chan = &aspeed_kcs_channel_map[kcs_channel_2],
307
+ },
308
+ {
309
+ .name = "idr3",
310
+ .reg = IDR3,
311
+ .chan = &aspeed_kcs_channel_map[kcs_channel_3],
312
+ },
313
+ {
314
+ .name = "odr3",
315
+ .reg = ODR3,
316
+ .chan = &aspeed_kcs_channel_map[kcs_channel_3],
317
+ },
318
+ {
319
+ .name = "str3",
320
+ .reg = STR3,
321
+ .chan = &aspeed_kcs_channel_map[kcs_channel_3],
322
+ },
323
+ {
324
+ .name = "idr4",
325
+ .reg = IDR4,
326
+ .chan = &aspeed_kcs_channel_map[kcs_channel_4],
327
+ },
328
+ {
329
+ .name = "odr4",
330
+ .reg = ODR4,
331
+ .chan = &aspeed_kcs_channel_map[kcs_channel_4],
332
+ },
333
+ {
334
+ .name = "str4",
335
+ .reg = STR4,
336
+ .chan = &aspeed_kcs_channel_map[kcs_channel_4],
337
+ },
338
+ { },
339
+};
340
+
341
+static const struct aspeed_kcs_register_data *
342
+aspeed_kcs_get_register_data_by_name(const char *name)
343
+{
344
+ const struct aspeed_kcs_register_data *pos = aspeed_kcs_registers;
345
+
346
+ while (pos->name) {
347
+ if (!strcmp(pos->name, name)) {
348
+ return pos;
349
+ }
350
+ pos++;
351
+ }
352
+
353
+ return NULL;
354
+}
355
+
356
+static const struct aspeed_kcs_channel *
357
+aspeed_kcs_get_channel_by_register(int reg)
358
+{
359
+ const struct aspeed_kcs_register_data *pos = aspeed_kcs_registers;
360
+
361
+ while (pos->name) {
362
+ if (pos->reg == reg) {
363
+ return pos->chan;
364
+ }
365
+ pos++;
366
+ }
367
+
368
+ return NULL;
369
+}
370
+
371
+static void aspeed_kcs_get_register_property(Object *obj,
372
+ Visitor *v,
373
+ const char *name,
374
+ void *opaque,
375
+ Error **errp)
376
+{
377
+ const struct aspeed_kcs_register_data *data;
378
+ AspeedLPCState *s = ASPEED_LPC(obj);
379
+ uint32_t val;
380
+
381
+ data = aspeed_kcs_get_register_data_by_name(name);
382
+ if (!data) {
383
+ return;
384
+ }
385
+
386
+ if (!strncmp("odr", name, 3)) {
387
+ s->regs[data->chan->str] &= ~STR_OBF;
388
+ }
389
+
390
+ val = s->regs[data->reg];
391
+
392
+ visit_type_uint32(v, name, &val, errp);
393
+}
394
+
395
+static bool aspeed_kcs_channel_enabled(AspeedLPCState *s,
396
+ const struct aspeed_kcs_channel *channel)
397
+{
398
+ switch (channel->id) {
399
+ case kcs_channel_1: return s->regs[HICR0] & HICR0_LPC1E;
400
+ case kcs_channel_2: return s->regs[HICR0] & HICR0_LPC2E;
401
+ case kcs_channel_3:
402
+ return (s->regs[HICR0] & HICR0_LPC3E) &&
403
+ (s->regs[HICR4] & HICR4_KCSENBL);
404
+ case kcs_channel_4: return s->regs[HICRB] & HICRB_LPC4E;
405
+ default: return false;
406
+ }
407
+}
408
+
409
+static bool
410
+aspeed_kcs_channel_ibf_irq_enabled(AspeedLPCState *s,
411
+ const struct aspeed_kcs_channel *channel)
412
+{
413
+ if (!aspeed_kcs_channel_enabled(s, channel)) {
414
+ return false;
415
+ }
416
+
417
+ switch (channel->id) {
418
+ case kcs_channel_1: return s->regs[HICR2] & HICR2_IBFIE1;
419
+ case kcs_channel_2: return s->regs[HICR2] & HICR2_IBFIE2;
420
+ case kcs_channel_3: return s->regs[HICR2] & HICR2_IBFIE3;
421
+ case kcs_channel_4: return s->regs[HICRB] & HICRB_IBFIE4;
422
+ default: return false;
423
+ }
424
+}
425
+
426
+static void aspeed_kcs_set_register_property(Object *obj,
427
+ Visitor *v,
428
+ const char *name,
429
+ void *opaque,
430
+ Error **errp)
431
+{
432
+ const struct aspeed_kcs_register_data *data;
433
+ AspeedLPCState *s = ASPEED_LPC(obj);
434
+ uint32_t val;
435
+
436
+ data = aspeed_kcs_get_register_data_by_name(name);
437
+ if (!data) {
438
+ return;
439
+ }
440
+
441
+ if (!visit_type_uint32(v, name, &val, errp)) {
442
+ return;
443
+ }
444
+
445
+ if (strncmp("str", name, 3)) {
446
+ s->regs[data->reg] = val;
447
+ }
448
+
449
+ if (!strncmp("idr", name, 3)) {
450
+ s->regs[data->chan->str] |= STR_IBF;
451
+ if (aspeed_kcs_channel_ibf_irq_enabled(s, data->chan)) {
452
+ enum aspeed_lpc_subdevice subdev;
453
+
454
+ subdev = aspeed_kcs_subdevice_map[data->chan->id];
455
+ qemu_irq_raise(s->subdevice_irqs[subdev]);
456
+ }
457
+ }
458
+}
459
+
460
+static void aspeed_lpc_set_irq(void *opaque, int irq, int level)
461
+{
462
+ AspeedLPCState *s = (AspeedLPCState *)opaque;
463
+
464
+ if (level) {
465
+ s->subdevice_irqs_pending |= BIT(irq);
466
+ } else {
467
+ s->subdevice_irqs_pending &= ~BIT(irq);
468
+ }
469
+
470
+ qemu_set_irq(s->irq, !!s->subdevice_irqs_pending);
471
+}
472
473
static uint64_t aspeed_lpc_read(void *opaque, hwaddr offset, unsigned size)
474
{
475
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_lpc_read(void *opaque, hwaddr offset, unsigned size)
476
return 0;
477
}
478
479
+ switch (reg) {
480
+ case IDR1:
481
+ case IDR2:
482
+ case IDR3:
483
+ case IDR4:
484
+ {
485
+ const struct aspeed_kcs_channel *channel;
486
+
487
+ channel = aspeed_kcs_get_channel_by_register(reg);
488
+ if (s->regs[channel->str] & STR_IBF) {
489
+ enum aspeed_lpc_subdevice subdev;
490
+
491
+ subdev = aspeed_kcs_subdevice_map[channel->id];
492
+ qemu_irq_lower(s->subdevice_irqs[subdev]);
493
+ }
494
+
495
+ s->regs[channel->str] &= ~STR_IBF;
496
+ break;
497
+ }
498
+ default:
499
+ break;
500
+ }
501
+
502
return s->regs[reg];
503
}
504
505
@@ -XXX,XX +XXX,XX @@ static void aspeed_lpc_write(void *opaque, hwaddr offset, uint64_t data,
506
return;
507
}
508
509
+
510
+ switch (reg) {
511
+ case ODR1:
512
+ case ODR2:
513
+ case ODR3:
514
+ case ODR4:
515
+ s->regs[aspeed_kcs_get_channel_by_register(reg)->str] |= STR_OBF;
516
+ break;
517
+ default:
518
+ break;
519
+ }
520
+
521
s->regs[reg] = data;
522
}
523
524
@@ -XXX,XX +XXX,XX @@ static void aspeed_lpc_reset(DeviceState *dev)
525
{
526
struct AspeedLPCState *s = ASPEED_LPC(dev);
527
528
+ s->subdevice_irqs_pending = 0;
529
+
530
memset(s->regs, 0, sizeof(s->regs));
531
532
s->regs[HICR7] = s->hicr7;
533
@@ -XXX,XX +XXX,XX @@ static void aspeed_lpc_realize(DeviceState *dev, Error **errp)
534
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
535
536
sysbus_init_irq(sbd, &s->irq);
537
+ sysbus_init_irq(sbd, &s->subdevice_irqs[aspeed_lpc_kcs_1]);
538
+ sysbus_init_irq(sbd, &s->subdevice_irqs[aspeed_lpc_kcs_2]);
539
+ sysbus_init_irq(sbd, &s->subdevice_irqs[aspeed_lpc_kcs_3]);
540
+ sysbus_init_irq(sbd, &s->subdevice_irqs[aspeed_lpc_kcs_4]);
541
+ sysbus_init_irq(sbd, &s->subdevice_irqs[aspeed_lpc_ibt]);
542
543
memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_lpc_ops, s,
544
TYPE_ASPEED_LPC, 0x1000);
545
546
sysbus_init_mmio(sbd, &s->iomem);
547
+
548
+ qdev_init_gpio_in(dev, aspeed_lpc_set_irq, ASPEED_LPC_NR_SUBDEVS);
549
+}
550
+
551
+static void aspeed_lpc_init(Object *obj)
552
+{
553
+ object_property_add(obj, "idr1", "uint32", aspeed_kcs_get_register_property,
554
+ aspeed_kcs_set_register_property, NULL, NULL);
555
+ object_property_add(obj, "odr1", "uint32", aspeed_kcs_get_register_property,
556
+ aspeed_kcs_set_register_property, NULL, NULL);
557
+ object_property_add(obj, "str1", "uint32", aspeed_kcs_get_register_property,
558
+ aspeed_kcs_set_register_property, NULL, NULL);
559
+ object_property_add(obj, "idr2", "uint32", aspeed_kcs_get_register_property,
560
+ aspeed_kcs_set_register_property, NULL, NULL);
561
+ object_property_add(obj, "odr2", "uint32", aspeed_kcs_get_register_property,
562
+ aspeed_kcs_set_register_property, NULL, NULL);
563
+ object_property_add(obj, "str2", "uint32", aspeed_kcs_get_register_property,
564
+ aspeed_kcs_set_register_property, NULL, NULL);
565
+ object_property_add(obj, "idr3", "uint32", aspeed_kcs_get_register_property,
566
+ aspeed_kcs_set_register_property, NULL, NULL);
567
+ object_property_add(obj, "odr3", "uint32", aspeed_kcs_get_register_property,
568
+ aspeed_kcs_set_register_property, NULL, NULL);
569
+ object_property_add(obj, "str3", "uint32", aspeed_kcs_get_register_property,
570
+ aspeed_kcs_set_register_property, NULL, NULL);
571
+ object_property_add(obj, "idr4", "uint32", aspeed_kcs_get_register_property,
572
+ aspeed_kcs_set_register_property, NULL, NULL);
573
+ object_property_add(obj, "odr4", "uint32", aspeed_kcs_get_register_property,
574
+ aspeed_kcs_set_register_property, NULL, NULL);
575
+ object_property_add(obj, "str4", "uint32", aspeed_kcs_get_register_property,
576
+ aspeed_kcs_set_register_property, NULL, NULL);
577
}
578
579
static const VMStateDescription vmstate_aspeed_lpc = {
580
.name = TYPE_ASPEED_LPC,
581
- .version_id = 1,
582
- .minimum_version_id = 1,
583
+ .version_id = 2,
584
+ .minimum_version_id = 2,
585
.fields = (VMStateField[]) {
586
VMSTATE_UINT32_ARRAY(regs, AspeedLPCState, ASPEED_LPC_NR_REGS),
587
+ VMSTATE_UINT32(subdevice_irqs_pending, AspeedLPCState),
588
VMSTATE_END_OF_LIST(),
589
}
590
};
591
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_lpc_info = {
592
.parent = TYPE_SYS_BUS_DEVICE,
593
.instance_size = sizeof(AspeedLPCState),
594
.class_init = aspeed_lpc_class_init,
595
+ .instance_init = aspeed_lpc_init,
596
};
597
598
static void aspeed_lpc_register_types(void)
599
--
166
--
600
2.26.2
167
2.41.0
601
168
602
169
diff view generated by jsdifflib
1
Firmware images can be found on the OpenBMC jenkins site and on the
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
OpenBMC GitHub release page.
3
2
4
Signed-off-by: Cédric Le Goater <clg@kaod.org>
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Reviewed-by: Joel Stanley <joel@jms.id.au>
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
6
Message-Id: <20210303072743.1551329-1-clg@kaod.org>
7
Signed-off-by: Cédric Le Goater <clg@kaod.org>
5
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
---
6
---
9
docs/system/arm/aspeed.rst | 14 +++++++++-----
7
hw/arm/aspeed_soc_common.c | 11 +++++++++++
10
1 file changed, 9 insertions(+), 5 deletions(-)
8
1 file changed, 11 insertions(+)
11
9
12
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
10
diff --git a/hw/arm/aspeed_soc_common.c b/hw/arm/aspeed_soc_common.c
13
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
14
--- a/docs/system/arm/aspeed.rst
12
--- a/hw/arm/aspeed_soc_common.c
15
+++ b/docs/system/arm/aspeed.rst
13
+++ b/hw/arm/aspeed_soc_common.c
16
@@ -XXX,XX +XXX,XX @@ Missing devices
14
@@ -XXX,XX +XXX,XX @@ void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev,
17
Boot options
15
sysbus_mmio_get_region(dev, 0), -1000);
18
------------
16
}
19
17
20
-The Aspeed machines can be started using the -kernel option to load a
18
+static void aspeed_soc_realize(DeviceState *dev, Error **errp)
21
-Linux kernel or from a firmware image which can be downloaded from the
19
+{
22
-OpenPOWER jenkins :
20
+ AspeedSoCState *s = ASPEED_SOC(dev);
23
+The Aspeed machines can be started using the ``-kernel`` option to
24
+load a Linux kernel or from a firmware. Images can be downloaded from
25
+the OpenBMC jenkins :
26
27
- https://openpower.xyz/
28
+ https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/distro=ubuntu,label=docker-builder
29
+
21
+
30
+or directly from the OpenBMC GitHub release repository :
22
+ if (!s->memory) {
23
+ error_setg(errp, "'memory' link is not set");
24
+ return;
25
+ }
26
+}
31
+
27
+
32
+ https://github.com/openbmc/openbmc/releases
28
static Property aspeed_soc_properties[] = {
33
29
DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
34
The image should be attached as an MTD drive. Run :
30
MemoryRegion *),
35
31
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data)
36
.. code-block:: bash
32
{
37
33
DeviceClass *dc = DEVICE_CLASS(oc);
38
$ qemu-system-arm -M romulus-bmc -nic user \
34
39
-    -drive file=flash-romulus,format=raw,if=mtd -nographic
35
+ dc->realize = aspeed_soc_realize;
40
+    -drive file=obmc-phosphor-image-romulus.static.mtd,format=raw,if=mtd -nographic
36
device_class_set_props(dc, aspeed_soc_properties);
41
37
}
42
Options specific to Aspeed machines are :
43
38
44
--
39
--
45
2.26.2
40
2.41.0
46
41
47
42
diff view generated by jsdifflib
1
This is a very minimal framework to access registers which are used to
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
configure the AHB memory mapping of the flash chips on the LPC HC
3
Firmware address space.
4
2
5
Signed-off-by: Cédric Le Goater <clg@kaod.org>
3
The v7-M core is specific to the Aspeed 10x0 series,
6
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
4
remove it from the common AspeedSoCState.
7
Message-Id: <20210302014317.915120-5-andrew@aj.id.au>
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
---
9
---
10
docs/system/arm/aspeed.rst | 2 +-
10
include/hw/arm/aspeed_soc.h | 5 ++---
11
include/hw/arm/aspeed_soc.h | 2 +
11
hw/arm/aspeed_ast10x0.c | 27 +++++++++++++++------------
12
include/hw/misc/aspeed_lpc.h | 32 +++++++++
12
hw/arm/fby35.c | 13 ++++++++-----
13
hw/arm/aspeed_ast2600.c | 10 +++
13
3 files changed, 25 insertions(+), 20 deletions(-)
14
hw/arm/aspeed_soc.c | 10 +++
15
hw/misc/aspeed_lpc.c | 131 +++++++++++++++++++++++++++++++++++
16
hw/misc/meson.build | 7 +-
17
7 files changed, 192 insertions(+), 2 deletions(-)
18
create mode 100644 include/hw/misc/aspeed_lpc.h
19
create mode 100644 hw/misc/aspeed_lpc.c
20
14
21
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
22
index XXXXXXX..XXXXXXX 100644
23
--- a/docs/system/arm/aspeed.rst
24
+++ b/docs/system/arm/aspeed.rst
25
@@ -XXX,XX +XXX,XX @@ Supported devices
26
* UART
27
* Ethernet controllers
28
* Front LEDs (PCA9552 on I2C bus)
29
+ * LPC Peripheral Controller (a subset of subdevices are supported)
30
31
32
Missing devices
33
@@ -XXX,XX +XXX,XX @@ Missing devices
34
* Coprocessor support
35
* ADC (out of tree implementation)
36
* PWM and Fan Controller
37
- * LPC Bus Controller
38
* Slave GPIO Controller
39
* Super I/O Controller
40
* Hash/Crypto Engine
41
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
15
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
42
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
43
--- a/include/hw/arm/aspeed_soc.h
17
--- a/include/hw/arm/aspeed_soc.h
44
+++ b/include/hw/arm/aspeed_soc.h
18
+++ b/include/hw/arm/aspeed_soc.h
45
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
46
#include "hw/sd/aspeed_sdhci.h"
20
#define ASPEED_JTAG_NUM 2
47
#include "hw/usb/hcd-ehci.h"
21
48
#include "qom/object.h"
22
struct AspeedSoCState {
49
+#include "hw/misc/aspeed_lpc.h"
23
- /*< private >*/
50
24
DeviceState parent;
51
#define ASPEED_SPIS_NUM 2
25
52
#define ASPEED_EHCIS_NUM 2
26
- /*< public >*/
53
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
27
ARMCPU cpu[ASPEED_CPUS_NUM];
54
AspeedGPIOState gpio_1_8v;
28
A15MPPrivState a7mpcore;
55
AspeedSDHCIState sdhci;
29
- ARMv7MState armv7m;
56
AspeedSDHCIState emmc;
30
MemoryRegion *memory;
57
+ AspeedLPCState lpc;
31
MemoryRegion *dram_mr;
32
MemoryRegion dram_container;
33
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2600SoCState, ASPEED2600_SOC)
34
35
struct Aspeed10x0SoCState {
36
AspeedSoCState parent;
37
+
38
+ ARMv7MState armv7m;
58
};
39
};
59
40
60
#define TYPE_ASPEED_SOC "aspeed-soc"
41
#define TYPE_ASPEED10X0_SOC "aspeed10x0-soc"
61
diff --git a/include/hw/misc/aspeed_lpc.h b/include/hw/misc/aspeed_lpc.h
42
diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c
62
new file mode 100644
43
index XXXXXXX..XXXXXXX 100644
63
index XXXXXXX..XXXXXXX
44
--- a/hw/arm/aspeed_ast10x0.c
64
--- /dev/null
45
+++ b/hw/arm/aspeed_ast10x0.c
65
+++ b/include/hw/misc/aspeed_lpc.h
46
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast1030_irqmap[] = {
66
@@ -XXX,XX +XXX,XX @@
47
67
+/*
48
static qemu_irq aspeed_soc_ast1030_get_irq(AspeedSoCState *s, int dev)
68
+ * ASPEED LPC Controller
49
{
69
+ *
50
+ Aspeed10x0SoCState *a = ASPEED10X0_SOC(s);
70
+ * Copyright (C) 2017-2018 IBM Corp.
51
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
71
+ *
52
72
+ * This code is licensed under the GPL version 2 or later. See
53
- return qdev_get_gpio_in(DEVICE(&s->armv7m), sc->irqmap[dev]);
73
+ * the COPYING file in the top-level directory.
54
+ return qdev_get_gpio_in(DEVICE(&a->armv7m), sc->irqmap[dev]);
74
+ */
55
}
56
57
static void aspeed_soc_ast1030_init(Object *obj)
58
{
59
+ Aspeed10x0SoCState *a = ASPEED10X0_SOC(obj);
60
AspeedSoCState *s = ASPEED_SOC(obj);
61
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
62
char socname[8];
63
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_init(Object *obj)
64
g_assert_not_reached();
65
}
66
67
- object_initialize_child(obj, "armv7m", &s->armv7m, TYPE_ARMV7M);
68
+ object_initialize_child(obj, "armv7m", &a->armv7m, TYPE_ARMV7M);
69
70
s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0);
71
72
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_init(Object *obj)
73
74
static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
75
{
76
+ Aspeed10x0SoCState *a = ASPEED10X0_SOC(dev_soc);
77
AspeedSoCState *s = ASPEED_SOC(dev_soc);
78
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
79
DeviceState *armv7m;
80
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
81
0x40000);
82
83
/* AST1030 CPU Core */
84
- armv7m = DEVICE(&s->armv7m);
85
+ armv7m = DEVICE(&a->armv7m);
86
qdev_prop_set_uint32(armv7m, "num-irq", 256);
87
qdev_prop_set_string(armv7m, "cpu-type", sc->cpu_type);
88
qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk);
89
- object_property_set_link(OBJECT(&s->armv7m), "memory",
90
+ object_property_set_link(OBJECT(&a->armv7m), "memory",
91
OBJECT(s->memory), &error_abort);
92
- sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), &error_abort);
93
+ sysbus_realize(SYS_BUS_DEVICE(&a->armv7m), &error_abort);
94
95
/* Internal SRAM */
96
sram_name = g_strdup_printf("aspeed.sram.%d",
97
- CPU(s->armv7m.cpu)->cpu_index);
98
+ CPU(a->armv7m.cpu)->cpu_index);
99
memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, &err);
100
if (err != NULL) {
101
error_propagate(errp, err);
102
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
103
}
104
aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]);
105
for (i = 0; i < ASPEED_I2C_GET_CLASS(&s->i2c)->num_busses; i++) {
106
- qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->armv7m),
107
+ qemu_irq irq = qdev_get_gpio_in(DEVICE(&a->armv7m),
108
sc->irqmap[ASPEED_DEV_I2C] + i);
109
/* The AST1030 I2C controller has one IRQ per bus. */
110
sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c.busses[i]), 0, irq);
111
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
112
}
113
aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]);
114
for (i = 0; i < ASPEED_I3C_NR_DEVICES; i++) {
115
- qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->armv7m),
116
+ qemu_irq irq = qdev_get_gpio_in(DEVICE(&a->armv7m),
117
sc->irqmap[ASPEED_DEV_I3C] + i);
118
/* The AST1030 I3C controller has one IRQ per bus. */
119
sysbus_connect_irq(SYS_BUS_DEVICE(&s->i3c.devices[i]), 0, irq);
120
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
121
* On the AST1030 LPC subdevice IRQs are connected straight to the GIC.
122
*/
123
sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_1,
124
- qdev_get_gpio_in(DEVICE(&s->armv7m),
125
+ qdev_get_gpio_in(DEVICE(&a->armv7m),
126
sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_1));
127
128
sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_2,
129
- qdev_get_gpio_in(DEVICE(&s->armv7m),
130
+ qdev_get_gpio_in(DEVICE(&a->armv7m),
131
sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_2));
132
133
sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_3,
134
- qdev_get_gpio_in(DEVICE(&s->armv7m),
135
+ qdev_get_gpio_in(DEVICE(&a->armv7m),
136
sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_3));
137
138
sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4,
139
- qdev_get_gpio_in(DEVICE(&s->armv7m),
140
+ qdev_get_gpio_in(DEVICE(&a->armv7m),
141
sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_4));
142
143
/* UART */
144
diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c
145
index XXXXXXX..XXXXXXX 100644
146
--- a/hw/arm/fby35.c
147
+++ b/hw/arm/fby35.c
148
@@ -XXX,XX +XXX,XX @@ struct Fby35State {
149
Clock *bic_sysclk;
150
151
AspeedSoCState bmc;
152
- AspeedSoCState bic;
153
+ Aspeed10x0SoCState bic;
154
155
bool mmio_exec;
156
};
157
@@ -XXX,XX +XXX,XX @@ static void fby35_bmc_init(Fby35State *s)
158
159
static void fby35_bic_init(Fby35State *s)
160
{
161
+ AspeedSoCState *soc;
75
+
162
+
76
+#ifndef ASPEED_LPC_H
163
s->bic_sysclk = clock_new(OBJECT(s), "SYSCLK");
77
+#define ASPEED_LPC_H
164
clock_set_hz(s->bic_sysclk, 200000000ULL);
78
+
165
79
+#include "hw/sysbus.h"
166
object_initialize_child(OBJECT(s), "bic", &s->bic, "ast1030-a1");
80
+
167
+ soc = ASPEED_SOC(&s->bic);
81
+#define TYPE_ASPEED_LPC "aspeed.lpc"
168
82
+#define ASPEED_LPC(obj) OBJECT_CHECK(AspeedLPCState, (obj), TYPE_ASPEED_LPC)
169
memory_region_init(&s->bic_memory, OBJECT(&s->bic), "bic-memory",
83
+
170
UINT64_MAX);
84
+#define ASPEED_LPC_NR_REGS (0x260 >> 2)
171
@@ -XXX,XX +XXX,XX @@ static void fby35_bic_init(Fby35State *s)
85
+
172
qdev_connect_clock_in(DEVICE(&s->bic), "sysclk", s->bic_sysclk);
86
+typedef struct AspeedLPCState {
173
object_property_set_link(OBJECT(&s->bic), "memory", OBJECT(&s->bic_memory),
87
+ /* <private> */
174
&error_abort);
88
+ SysBusDevice parent;
175
- aspeed_soc_uart_set_chr(&s->bic, ASPEED_DEV_UART5, serial_hd(1));
89
+
176
+ aspeed_soc_uart_set_chr(soc, ASPEED_DEV_UART5, serial_hd(1));
90
+ /*< public >*/
177
qdev_realize(DEVICE(&s->bic), NULL, &error_abort);
91
+ MemoryRegion iomem;
178
92
+ qemu_irq irq;
179
- aspeed_board_init_flashes(&s->bic.fmc, "sst25vf032b", 2, 2);
93
+
180
- aspeed_board_init_flashes(&s->bic.spi[0], "sst25vf032b", 2, 4);
94
+ uint32_t regs[ASPEED_LPC_NR_REGS];
181
- aspeed_board_init_flashes(&s->bic.spi[1], "sst25vf032b", 2, 6);
95
+ uint32_t hicr7;
182
+ aspeed_board_init_flashes(&soc->fmc, "sst25vf032b", 2, 2);
96
+} AspeedLPCState;
183
+ aspeed_board_init_flashes(&soc->spi[0], "sst25vf032b", 2, 4);
97
+
184
+ aspeed_board_init_flashes(&soc->spi[1], "sst25vf032b", 2, 6);
98
+#endif /* _ASPEED_LPC_H_ */
99
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
100
index XXXXXXX..XXXXXXX 100644
101
--- a/hw/arm/aspeed_ast2600.c
102
+++ b/hw/arm/aspeed_ast2600.c
103
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
104
105
object_initialize_child(obj, "emmc-controller.sdhci", &s->emmc.slots[0],
106
TYPE_SYSBUS_SDHCI);
107
+
108
+ object_initialize_child(obj, "lpc", &s->lpc, TYPE_ASPEED_LPC);
109
}
185
}
110
186
111
/*
187
static void fby35_init(MachineState *machine)
112
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
113
sysbus_mmio_map(SYS_BUS_DEVICE(&s->emmc), 0, sc->memmap[ASPEED_DEV_EMMC]);
114
sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc), 0,
115
aspeed_soc_get_irq(s, ASPEED_DEV_EMMC));
116
+
117
+ /* LPC */
118
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) {
119
+ return;
120
+ }
121
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]);
122
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0,
123
+ aspeed_soc_get_irq(s, ASPEED_DEV_LPC));
124
}
125
126
static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
127
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
128
index XXXXXXX..XXXXXXX 100644
129
--- a/hw/arm/aspeed_soc.c
130
+++ b/hw/arm/aspeed_soc.c
131
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
132
object_initialize_child(obj, "sdhci[*]", &s->sdhci.slots[i],
133
TYPE_SYSBUS_SDHCI);
134
}
135
+
136
+ object_initialize_child(obj, "lpc", &s->lpc, TYPE_ASPEED_LPC);
137
}
138
139
static void aspeed_soc_realize(DeviceState *dev, Error **errp)
140
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
141
sc->memmap[ASPEED_DEV_SDHCI]);
142
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0,
143
aspeed_soc_get_irq(s, ASPEED_DEV_SDHCI));
144
+
145
+ /* LPC */
146
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) {
147
+ return;
148
+ }
149
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]);
150
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0,
151
+ aspeed_soc_get_irq(s, ASPEED_DEV_LPC));
152
}
153
static Property aspeed_soc_properties[] = {
154
DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
155
diff --git a/hw/misc/aspeed_lpc.c b/hw/misc/aspeed_lpc.c
156
new file mode 100644
157
index XXXXXXX..XXXXXXX
158
--- /dev/null
159
+++ b/hw/misc/aspeed_lpc.c
160
@@ -XXX,XX +XXX,XX @@
161
+/*
162
+ * ASPEED LPC Controller
163
+ *
164
+ * Copyright (C) 2017-2018 IBM Corp.
165
+ *
166
+ * This code is licensed under the GPL version 2 or later. See
167
+ * the COPYING file in the top-level directory.
168
+ */
169
+
170
+#include "qemu/osdep.h"
171
+#include "qemu/log.h"
172
+#include "qemu/error-report.h"
173
+#include "hw/misc/aspeed_lpc.h"
174
+#include "qapi/error.h"
175
+#include "hw/qdev-properties.h"
176
+#include "migration/vmstate.h"
177
+
178
+#define TO_REG(offset) ((offset) >> 2)
179
+
180
+#define HICR0 TO_REG(0x00)
181
+#define HICR1 TO_REG(0x04)
182
+#define HICR2 TO_REG(0x08)
183
+#define HICR3 TO_REG(0x0C)
184
+#define HICR4 TO_REG(0x10)
185
+#define HICR5 TO_REG(0x80)
186
+#define HICR6 TO_REG(0x84)
187
+#define HICR7 TO_REG(0x88)
188
+#define HICR8 TO_REG(0x8C)
189
+
190
+static uint64_t aspeed_lpc_read(void *opaque, hwaddr offset, unsigned size)
191
+{
192
+ AspeedLPCState *s = ASPEED_LPC(opaque);
193
+ int reg = TO_REG(offset);
194
+
195
+ if (reg >= ARRAY_SIZE(s->regs)) {
196
+ qemu_log_mask(LOG_GUEST_ERROR,
197
+ "%s: Out-of-bounds read at offset 0x%" HWADDR_PRIx "\n",
198
+ __func__, offset);
199
+ return 0;
200
+ }
201
+
202
+ return s->regs[reg];
203
+}
204
+
205
+static void aspeed_lpc_write(void *opaque, hwaddr offset, uint64_t data,
206
+ unsigned int size)
207
+{
208
+ AspeedLPCState *s = ASPEED_LPC(opaque);
209
+ int reg = TO_REG(offset);
210
+
211
+ if (reg >= ARRAY_SIZE(s->regs)) {
212
+ qemu_log_mask(LOG_GUEST_ERROR,
213
+ "%s: Out-of-bounds write at offset 0x%" HWADDR_PRIx "\n",
214
+ __func__, offset);
215
+ return;
216
+ }
217
+
218
+ s->regs[reg] = data;
219
+}
220
+
221
+static const MemoryRegionOps aspeed_lpc_ops = {
222
+ .read = aspeed_lpc_read,
223
+ .write = aspeed_lpc_write,
224
+ .endianness = DEVICE_LITTLE_ENDIAN,
225
+ .valid = {
226
+ .min_access_size = 1,
227
+ .max_access_size = 4,
228
+ },
229
+};
230
+
231
+static void aspeed_lpc_reset(DeviceState *dev)
232
+{
233
+ struct AspeedLPCState *s = ASPEED_LPC(dev);
234
+
235
+ memset(s->regs, 0, sizeof(s->regs));
236
+
237
+ s->regs[HICR7] = s->hicr7;
238
+}
239
+
240
+static void aspeed_lpc_realize(DeviceState *dev, Error **errp)
241
+{
242
+ AspeedLPCState *s = ASPEED_LPC(dev);
243
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
244
+
245
+ sysbus_init_irq(sbd, &s->irq);
246
+
247
+ memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_lpc_ops, s,
248
+ TYPE_ASPEED_LPC, 0x1000);
249
+
250
+ sysbus_init_mmio(sbd, &s->iomem);
251
+}
252
+
253
+static const VMStateDescription vmstate_aspeed_lpc = {
254
+ .name = TYPE_ASPEED_LPC,
255
+ .version_id = 1,
256
+ .minimum_version_id = 1,
257
+ .fields = (VMStateField[]) {
258
+ VMSTATE_UINT32_ARRAY(regs, AspeedLPCState, ASPEED_LPC_NR_REGS),
259
+ VMSTATE_END_OF_LIST(),
260
+ }
261
+};
262
+
263
+static Property aspeed_lpc_properties[] = {
264
+ DEFINE_PROP_UINT32("hicr7", AspeedLPCState, hicr7, 0),
265
+ DEFINE_PROP_END_OF_LIST(),
266
+};
267
+
268
+static void aspeed_lpc_class_init(ObjectClass *klass, void *data)
269
+{
270
+ DeviceClass *dc = DEVICE_CLASS(klass);
271
+
272
+ dc->realize = aspeed_lpc_realize;
273
+ dc->reset = aspeed_lpc_reset;
274
+ dc->desc = "Aspeed LPC Controller",
275
+ dc->vmsd = &vmstate_aspeed_lpc;
276
+ device_class_set_props(dc, aspeed_lpc_properties);
277
+}
278
+
279
+static const TypeInfo aspeed_lpc_info = {
280
+ .name = TYPE_ASPEED_LPC,
281
+ .parent = TYPE_SYS_BUS_DEVICE,
282
+ .instance_size = sizeof(AspeedLPCState),
283
+ .class_init = aspeed_lpc_class_init,
284
+};
285
+
286
+static void aspeed_lpc_register_types(void)
287
+{
288
+ type_register_static(&aspeed_lpc_info);
289
+}
290
+
291
+type_init(aspeed_lpc_register_types);
292
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
293
index XXXXXXX..XXXXXXX 100644
294
--- a/hw/misc/meson.build
295
+++ b/hw/misc/meson.build
296
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c'))
297
softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c'))
298
softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c'))
299
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
300
-softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c'))
301
+softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(
302
+ 'aspeed_lpc.c',
303
+ 'aspeed_scu.c',
304
+ 'aspeed_sdmc.c',
305
+ 'aspeed_xdma.c'))
306
+
307
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c'))
308
softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_rng.c'))
309
310
--
188
--
311
2.26.2
189
2.41.0
312
190
313
191
diff view generated by jsdifflib
1
From: Andrew Jeffery <andrew@aj.id.au>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The AST2600 allocates distinct GIC IRQs for the LPC subdevices such as
3
The v7-A cluster is specific to the Aspeed 2600 series,
4
the iBT device. Previously on the AST2400 and AST2500 the LPC subdevices
4
remove it from the common AspeedSoCState.
5
shared a single LPC IRQ.
5
6
6
The ARM cores belong to the MP cluster, but the array
7
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
7
is currently used by TYPE_ASPEED2600_SOC. We'll clean
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
that soon, but for now keep it in Aspeed2600SoCState.
9
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Reviewed-by: Cédric Le Goater <clg@kaod.org>
11
Reviewed-by: Cédric Le Goater <clg@kaod.org>
10
Message-Id: <20210302014317.915120-4-andrew@aj.id.au>
11
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
---
13
---
13
hw/arm/aspeed_ast2600.c | 2 +-
14
include/hw/arm/aspeed_soc.h | 4 ++-
14
1 file changed, 1 insertion(+), 1 deletion(-)
15
hw/arm/aspeed_ast2600.c | 49 ++++++++++++++++++++-----------------
15
16
hw/arm/fby35.c | 14 ++++++-----
17
3 files changed, 37 insertions(+), 30 deletions(-)
18
19
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/include/hw/arm/aspeed_soc.h
22
+++ b/include/hw/arm/aspeed_soc.h
23
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
24
DeviceState parent;
25
26
ARMCPU cpu[ASPEED_CPUS_NUM];
27
- A15MPPrivState a7mpcore;
28
MemoryRegion *memory;
29
MemoryRegion *dram_mr;
30
MemoryRegion dram_container;
31
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2400SoCState, ASPEED2400_SOC)
32
33
struct Aspeed2600SoCState {
34
AspeedSoCState parent;
35
+
36
+ A15MPPrivState a7mpcore;
37
+ ARMCPU cpu[ASPEED_CPUS_NUM]; /* XXX belong to a7mpcore */
38
};
39
40
#define TYPE_ASPEED2600_SOC "aspeed2600-soc"
16
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
41
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
17
index XXXXXXX..XXXXXXX 100644
42
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/aspeed_ast2600.c
43
--- a/hw/arm/aspeed_ast2600.c
19
+++ b/hw/arm/aspeed_ast2600.c
44
+++ b/hw/arm/aspeed_ast2600.c
20
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = {
45
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = {
21
[ASPEED_DEV_WDT] = 24,
46
22
[ASPEED_DEV_PWM] = 44,
47
static qemu_irq aspeed_soc_ast2600_get_irq(AspeedSoCState *s, int dev)
23
[ASPEED_DEV_LPC] = 35,
48
{
24
- [ASPEED_DEV_IBT] = 35, /* LPC */
49
+ Aspeed2600SoCState *a = ASPEED2600_SOC(s);
25
+ [ASPEED_DEV_IBT] = 143,
50
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
26
[ASPEED_DEV_I2C] = 110, /* 110 -> 125 */
51
27
[ASPEED_DEV_ETH1] = 2,
52
- return qdev_get_gpio_in(DEVICE(&s->a7mpcore), sc->irqmap[dev]);
28
[ASPEED_DEV_ETH2] = 3,
53
+ return qdev_get_gpio_in(DEVICE(&a->a7mpcore), sc->irqmap[dev]);
54
}
55
56
static void aspeed_soc_ast2600_init(Object *obj)
57
{
58
+ Aspeed2600SoCState *a = ASPEED2600_SOC(obj);
59
AspeedSoCState *s = ASPEED_SOC(obj);
60
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
61
int i;
62
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
63
}
64
65
for (i = 0; i < sc->num_cpus; i++) {
66
- object_initialize_child(obj, "cpu[*]", &s->cpu[i], sc->cpu_type);
67
+ object_initialize_child(obj, "cpu[*]", &a->cpu[i], sc->cpu_type);
68
}
69
70
snprintf(typename, sizeof(typename), "aspeed.scu-%s", socname);
71
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
72
object_property_add_alias(obj, "hw-prot-key", OBJECT(&s->scu),
73
"hw-prot-key");
74
75
- object_initialize_child(obj, "a7mpcore", &s->a7mpcore,
76
+ object_initialize_child(obj, "a7mpcore", &a->a7mpcore,
77
TYPE_A15MPCORE_PRIV);
78
79
object_initialize_child(obj, "rtc", &s->rtc, TYPE_ASPEED_RTC);
80
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_calc_affinity(int cpu)
81
static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
82
{
83
int i;
84
+ Aspeed2600SoCState *a = ASPEED2600_SOC(dev);
85
AspeedSoCState *s = ASPEED_SOC(dev);
86
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
87
Error *err = NULL;
88
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
89
/* CPU */
90
for (i = 0; i < sc->num_cpus; i++) {
91
if (sc->num_cpus > 1) {
92
- object_property_set_int(OBJECT(&s->cpu[i]), "reset-cbar",
93
+ object_property_set_int(OBJECT(&a->cpu[i]), "reset-cbar",
94
ASPEED_A7MPCORE_ADDR, &error_abort);
95
}
96
- object_property_set_int(OBJECT(&s->cpu[i]), "mp-affinity",
97
+ object_property_set_int(OBJECT(&a->cpu[i]), "mp-affinity",
98
aspeed_calc_affinity(i), &error_abort);
99
100
- object_property_set_int(OBJECT(&s->cpu[i]), "cntfrq", 1125000000,
101
+ object_property_set_int(OBJECT(&a->cpu[i]), "cntfrq", 1125000000,
102
&error_abort);
103
- object_property_set_bool(OBJECT(&s->cpu[i]), "neon", false,
104
+ object_property_set_bool(OBJECT(&a->cpu[i]), "neon", false,
105
&error_abort);
106
- object_property_set_bool(OBJECT(&s->cpu[i]), "vfp-d32", false,
107
+ object_property_set_bool(OBJECT(&a->cpu[i]), "vfp-d32", false,
108
&error_abort);
109
- object_property_set_link(OBJECT(&s->cpu[i]), "memory",
110
+ object_property_set_link(OBJECT(&a->cpu[i]), "memory",
111
OBJECT(s->memory), &error_abort);
112
113
- if (!qdev_realize(DEVICE(&s->cpu[i]), NULL, errp)) {
114
+ if (!qdev_realize(DEVICE(&a->cpu[i]), NULL, errp)) {
115
return;
116
}
117
}
118
119
/* A7MPCORE */
120
- object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", sc->num_cpus,
121
+ object_property_set_int(OBJECT(&a->a7mpcore), "num-cpu", sc->num_cpus,
122
&error_abort);
123
- object_property_set_int(OBJECT(&s->a7mpcore), "num-irq",
124
+ object_property_set_int(OBJECT(&a->a7mpcore), "num-irq",
125
ROUND_UP(AST2600_MAX_IRQ + GIC_INTERNAL, 32),
126
&error_abort);
127
128
- sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort);
129
- aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->a7mpcore), 0, ASPEED_A7MPCORE_ADDR);
130
+ sysbus_realize(SYS_BUS_DEVICE(&a->a7mpcore), &error_abort);
131
+ aspeed_mmio_map(s, SYS_BUS_DEVICE(&a->a7mpcore), 0, ASPEED_A7MPCORE_ADDR);
132
133
for (i = 0; i < sc->num_cpus; i++) {
134
- SysBusDevice *sbd = SYS_BUS_DEVICE(&s->a7mpcore);
135
- DeviceState *d = DEVICE(&s->cpu[i]);
136
+ SysBusDevice *sbd = SYS_BUS_DEVICE(&a->a7mpcore);
137
+ DeviceState *d = DEVICE(&a->cpu[i]);
138
139
irq = qdev_get_gpio_in(d, ARM_CPU_IRQ);
140
sysbus_connect_irq(sbd, i, irq);
141
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
142
}
143
144
/* SRAM */
145
- sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&s->cpu[0])->cpu_index);
146
+ sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_index);
147
memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, &err);
148
if (err) {
149
error_propagate(errp, err);
150
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
151
}
152
aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]);
153
for (i = 0; i < ASPEED_I2C_GET_CLASS(&s->i2c)->num_busses; i++) {
154
- irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
155
+ irq = qdev_get_gpio_in(DEVICE(&a->a7mpcore),
156
sc->irqmap[ASPEED_DEV_I2C] + i);
157
/* The AST2600 I2C controller has one IRQ per bus. */
158
sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c.busses[i]), 0, irq);
159
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
160
* offset 0.
161
*/
162
sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_1,
163
- qdev_get_gpio_in(DEVICE(&s->a7mpcore),
164
+ qdev_get_gpio_in(DEVICE(&a->a7mpcore),
165
sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_1));
166
167
sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_2,
168
- qdev_get_gpio_in(DEVICE(&s->a7mpcore),
169
+ qdev_get_gpio_in(DEVICE(&a->a7mpcore),
170
sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_2));
171
172
sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_3,
173
- qdev_get_gpio_in(DEVICE(&s->a7mpcore),
174
+ qdev_get_gpio_in(DEVICE(&a->a7mpcore),
175
sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_3));
176
177
sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4,
178
- qdev_get_gpio_in(DEVICE(&s->a7mpcore),
179
+ qdev_get_gpio_in(DEVICE(&a->a7mpcore),
180
sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_4));
181
182
/* HACE */
183
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
184
}
185
aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]);
186
for (i = 0; i < ASPEED_I3C_NR_DEVICES; i++) {
187
- irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
188
+ irq = qdev_get_gpio_in(DEVICE(&a->a7mpcore),
189
sc->irqmap[ASPEED_DEV_I3C] + i);
190
/* The AST2600 I3C controller has one IRQ per bus. */
191
sysbus_connect_irq(SYS_BUS_DEVICE(&s->i3c.devices[i]), 0, irq);
192
diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c
193
index XXXXXXX..XXXXXXX 100644
194
--- a/hw/arm/fby35.c
195
+++ b/hw/arm/fby35.c
196
@@ -XXX,XX +XXX,XX @@ struct Fby35State {
197
MemoryRegion bic_memory;
198
Clock *bic_sysclk;
199
200
- AspeedSoCState bmc;
201
+ Aspeed2600SoCState bmc;
202
Aspeed10x0SoCState bic;
203
204
bool mmio_exec;
205
@@ -XXX,XX +XXX,XX @@ static void fby35_bmc_write_boot_rom(DriveInfo *dinfo, MemoryRegion *mr,
206
207
static void fby35_bmc_init(Fby35State *s)
208
{
209
+ AspeedSoCState *soc;
210
+
211
object_initialize_child(OBJECT(s), "bmc", &s->bmc, "ast2600-a3");
212
+ soc = ASPEED_SOC(&s->bmc);
213
214
memory_region_init(&s->bmc_memory, OBJECT(&s->bmc), "bmc-memory",
215
UINT64_MAX);
216
@@ -XXX,XX +XXX,XX @@ static void fby35_bmc_init(Fby35State *s)
217
&error_abort);
218
object_property_set_int(OBJECT(&s->bmc), "hw-strap2", 0x00000003,
219
&error_abort);
220
- aspeed_soc_uart_set_chr(&s->bmc, ASPEED_DEV_UART5, serial_hd(0));
221
+ aspeed_soc_uart_set_chr(soc, ASPEED_DEV_UART5, serial_hd(0));
222
qdev_realize(DEVICE(&s->bmc), NULL, &error_abort);
223
224
- aspeed_board_init_flashes(&s->bmc.fmc, "n25q00", 2, 0);
225
+ aspeed_board_init_flashes(&soc->fmc, "n25q00", 2, 0);
226
227
/* Install first FMC flash content as a boot rom. */
228
if (!s->mmio_exec) {
229
DriveInfo *mtd0 = drive_get(IF_MTD, 0, 0);
230
231
if (mtd0) {
232
- AspeedSoCState *bmc = &s->bmc;
233
- uint64_t rom_size = memory_region_size(&bmc->spi_boot);
234
+ uint64_t rom_size = memory_region_size(&soc->spi_boot);
235
236
memory_region_init_rom(&s->bmc_boot_rom, NULL, "aspeed.boot_rom",
237
rom_size, &error_abort);
238
- memory_region_add_subregion_overlap(&bmc->spi_boot_container, 0,
239
+ memory_region_add_subregion_overlap(&soc->spi_boot_container, 0,
240
&s->bmc_boot_rom, 1);
241
242
fby35_bmc_write_boot_rom(mtd0, &s->bmc_boot_rom,
29
--
243
--
30
2.26.2
244
2.41.0
31
245
32
246
diff view generated by jsdifflib
1
From: Joel Stanley <joel@jms.id.au>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The ast2600 machines do not have PSCI firmware, so this property should
3
The ARM array and VIC peripheral are only used by the
4
have never been set. Removing this node fixes SMP booting Linux kernels
4
2400 series, remove them from the common AspeedSoCState.
5
that have PSCI enabled, as Linux fails to find PSCI in the device tree
6
and falls back to the soc-specific method for enabling secondary CPUs.
7
5
8
The comment is out of date as Qemu has supported -kernel booting since
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
9bb6d14081ce ("aspeed: Add boot stub for smp booting"), in v5.1.
10
11
Fixes: f25c0ae1079d ("aspeed/soc: Add AST2600 support")
12
Signed-off-by: Joel Stanley <joel@jms.id.au>
13
Reviewed-by: Cédric Le Goater <clg@kaod.org>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
14
Tested-by: Cédric Le Goater <clg@kaod.org>
15
Message-Id: <20210303010505.635621-1-joel@jms.id.au>
16
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
Signed-off-by: Cédric Le Goater <clg@kaod.org>
17
---
9
---
18
hw/arm/aspeed_ast2600.c | 7 -------
10
include/hw/arm/aspeed_soc.h | 5 +++--
19
1 file changed, 7 deletions(-)
11
hw/arm/{aspeed_soc.c => aspeed_ast2400.c} | 27 +++++++++++++----------
12
hw/arm/meson.build | 2 +-
13
3 files changed, 19 insertions(+), 15 deletions(-)
14
rename hw/arm/{aspeed_soc.c => aspeed_ast2400.c} (95%)
20
15
21
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
16
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
22
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/arm/aspeed_ast2600.c
18
--- a/include/hw/arm/aspeed_soc.h
24
+++ b/hw/arm/aspeed_ast2600.c
19
+++ b/include/hw/arm/aspeed_soc.h
25
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
20
@@ -XXX,XX +XXX,XX @@
21
struct AspeedSoCState {
22
DeviceState parent;
23
24
- ARMCPU cpu[ASPEED_CPUS_NUM];
25
MemoryRegion *memory;
26
MemoryRegion *dram_mr;
27
MemoryRegion dram_container;
28
MemoryRegion sram;
29
MemoryRegion spi_boot_container;
30
MemoryRegion spi_boot;
31
- AspeedVICState vic;
32
AspeedRtcState rtc;
33
AspeedTimerCtrlState timerctrl;
34
AspeedI2CState i2c;
35
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC)
36
37
struct Aspeed2400SoCState {
38
AspeedSoCState parent;
39
+
40
+ ARMCPU cpu[ASPEED_CPUS_NUM];
41
+ AspeedVICState vic;
42
};
43
44
#define TYPE_ASPEED2400_SOC "aspeed2400-soc"
45
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_ast2400.c
46
similarity index 95%
47
rename from hw/arm/aspeed_soc.c
48
rename to hw/arm/aspeed_ast2400.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/arm/aspeed_soc.c
51
+++ b/hw/arm/aspeed_ast2400.c
52
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = {
53
54
static qemu_irq aspeed_soc_ast2400_get_irq(AspeedSoCState *s, int dev)
55
{
56
+ Aspeed2400SoCState *a = ASPEED2400_SOC(s);
57
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
58
59
- return qdev_get_gpio_in(DEVICE(&s->vic), sc->irqmap[dev]);
60
+ return qdev_get_gpio_in(DEVICE(&a->vic), sc->irqmap[dev]);
61
}
62
63
static void aspeed_ast2400_soc_init(Object *obj)
64
{
65
+ Aspeed2400SoCState *a = ASPEED2400_SOC(obj);
66
AspeedSoCState *s = ASPEED_SOC(obj);
67
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
68
int i;
69
@@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_init(Object *obj)
70
}
71
72
for (i = 0; i < sc->num_cpus; i++) {
73
- object_initialize_child(obj, "cpu[*]", &s->cpu[i], sc->cpu_type);
74
+ object_initialize_child(obj, "cpu[*]", &a->cpu[i], sc->cpu_type);
75
}
76
77
snprintf(typename, sizeof(typename), "aspeed.scu-%s", socname);
78
@@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_init(Object *obj)
79
object_property_add_alias(obj, "hw-prot-key", OBJECT(&s->scu),
80
"hw-prot-key");
81
82
- object_initialize_child(obj, "vic", &s->vic, TYPE_ASPEED_VIC);
83
+ object_initialize_child(obj, "vic", &a->vic, TYPE_ASPEED_VIC);
84
85
object_initialize_child(obj, "rtc", &s->rtc, TYPE_ASPEED_RTC);
86
87
@@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_init(Object *obj)
88
static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)
89
{
90
int i;
91
+ Aspeed2400SoCState *a = ASPEED2400_SOC(dev);
92
AspeedSoCState *s = ASPEED_SOC(dev);
93
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
94
Error *err = NULL;
95
@@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)
26
96
27
/* CPU */
97
/* CPU */
28
for (i = 0; i < sc->num_cpus; i++) {
98
for (i = 0; i < sc->num_cpus; i++) {
29
- object_property_set_int(OBJECT(&s->cpu[i]), "psci-conduit",
99
- object_property_set_link(OBJECT(&s->cpu[i]), "memory",
30
- QEMU_PSCI_CONDUIT_SMC, &error_abort);
100
+ object_property_set_link(OBJECT(&a->cpu[i]), "memory",
31
if (sc->num_cpus > 1) {
101
OBJECT(s->memory), &error_abort);
32
object_property_set_int(OBJECT(&s->cpu[i]), "reset-cbar",
102
- if (!qdev_realize(DEVICE(&s->cpu[i]), NULL, errp)) {
33
ASPEED_A7MPCORE_ADDR, &error_abort);
103
+ if (!qdev_realize(DEVICE(&a->cpu[i]), NULL, errp)) {
34
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
35
object_property_set_int(OBJECT(&s->cpu[i]), "cntfrq", 1125000000,
36
&error_abort);
37
38
- /*
39
- * TODO: the secondary CPUs are started and a boot helper
40
- * is needed when using -kernel
41
- */
42
-
43
if (!qdev_realize(DEVICE(&s->cpu[i]), NULL, errp)) {
44
return;
104
return;
45
}
105
}
106
}
107
108
/* SRAM */
109
- sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&s->cpu[0])->cpu_index);
110
+ sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_index);
111
memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, &err);
112
if (err) {
113
error_propagate(errp, err);
114
@@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)
115
aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]);
116
117
/* VIC */
118
- if (!sysbus_realize(SYS_BUS_DEVICE(&s->vic), errp)) {
119
+ if (!sysbus_realize(SYS_BUS_DEVICE(&a->vic), errp)) {
120
return;
121
}
122
- aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->vic), 0, sc->memmap[ASPEED_DEV_VIC]);
123
- sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 0,
124
- qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ));
125
- sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 1,
126
- qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
127
+ aspeed_mmio_map(s, SYS_BUS_DEVICE(&a->vic), 0, sc->memmap[ASPEED_DEV_VIC]);
128
+ sysbus_connect_irq(SYS_BUS_DEVICE(&a->vic), 0,
129
+ qdev_get_gpio_in(DEVICE(&a->cpu), ARM_CPU_IRQ));
130
+ sysbus_connect_irq(SYS_BUS_DEVICE(&a->vic), 1,
131
+ qdev_get_gpio_in(DEVICE(&a->cpu), ARM_CPU_FIQ));
132
133
/* RTC */
134
if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) {
135
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
136
index XXXXXXX..XXXXXXX 100644
137
--- a/hw/arm/meson.build
138
+++ b/hw/arm/meson.build
139
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_FSL_IMX25', if_true: files('fsl-imx25.c', 'imx25_pdk.c'
140
arm_ss.add(when: 'CONFIG_FSL_IMX31', if_true: files('fsl-imx31.c', 'kzm.c'))
141
arm_ss.add(when: 'CONFIG_FSL_IMX6', if_true: files('fsl-imx6.c'))
142
arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(
143
- 'aspeed_soc.c',
144
'aspeed.c',
145
'aspeed_soc_common.c',
146
+ 'aspeed_ast2400.c',
147
'aspeed_ast2600.c',
148
'aspeed_ast10x0.c',
149
'aspeed_eeprom.c',
46
--
150
--
47
2.26.2
151
2.41.0
48
152
49
153
diff view generated by jsdifflib