1
The following changes since commit 5e7b204dbfae9a562fc73684986f936b97f63877:
1
The following changes since commit ed734377ab3f3f3cc15d7aa301a87ab6370f2eed:
2
2
3
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2020-12-09 20:08:54 +0000)
3
Merge tag 'linux-user-fix-gupnp-pull-request' of https://github.com/hdeller/qemu-hppa into staging (2025-01-24 14:43:07 -0500)
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-20201210
7
https://github.com/legoater/qemu/ tags/pull-aspeed-20250127
8
8
9
for you to fetch changes up to 6f5f6507e49df4820207a94f3aeaaeab08092d32:
9
for you to fetch changes up to 8b7ccc6ad10cd4a107b4627e9a5606d757607ff2:
10
10
11
aspeed: g220a-bmc: Add an FRU (2020-12-10 12:11:03 +0100)
11
docs/system/arm/aspeed: Remove tacoma-bmc from the documentation (2025-01-27 09:38:15 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Aspeed patches :
14
aspeed queue:
15
15
16
* New device model for EMC1413/EMC1414 temperature sensors (I2C)
16
* Fixed serial definitions on the command line
17
* New g220a-bmc Aspeed machine
17
* Fixed sdhci write protected pin on AST2600 EVB machine
18
* couple of Aspeed cleanups
18
* Added timer support on AST2700 SoC
19
* Updated buildroot and SDK images of functional tests
20
* Removed sd devices creation when -nodefaults is used
21
* Added software reset mode support on AST2600 SoC
19
22
20
----------------------------------------------------------------
23
----------------------------------------------------------------
21
Cédric Le Goater (1):
24
Cédric Le Goater (3):
22
aspeed/smc: Add support for address lane disablement
25
test/functional: Update the Aspeed aarch64 test
26
test/functional: Update buildroot images to 2024.11
27
aspeed: Create sd devices only when defaults are enabled
23
28
24
Joel Stanley (1):
29
Jamin Lin (7):
25
ast2600: SRAM is 89KB
30
hw/sd/sdhci: Introduce a new Write Protected pin inverted property
31
hw/arm/aspeed: Invert sdhci write protected pin for AST2600 EVB
32
hw/timer/aspeed: Refactor Timer Callbacks for SoC-Specific Implementations
33
hw/timer/aspeed: Add AST2700 Support
34
aspeed/soc: Support Timer for AST2700
35
aspeed/wdt: Fix coding style
36
aspeed/wdt: Support software reset mode for AST2600
26
37
27
John Wang (3):
38
Kenneth Jia (1):
28
hw/misc: add an EMC141{3,4} device model
39
hw/arm/aspeed: fix connect_serial_hds_to_uarts
29
aspeed: Add support for the g220a-bmc board
30
aspeed: g220a-bmc: Add an FRU
31
40
32
include/hw/misc/emc141x_regs.h | 37 +++++
41
Thomas Huth (1):
33
hw/arm/aspeed.c | 72 +++++++++
42
docs/system/arm/aspeed: Remove tacoma-bmc from the documentation
34
hw/arm/aspeed_ast2600.c | 2 +-
35
hw/misc/emc141x.c | 326 +++++++++++++++++++++++++++++++++++++++++
36
hw/ssi/aspeed_smc.c | 25 +++-
37
tests/qtest/emc141x-test.c | 81 ++++++++++
38
hw/arm/Kconfig | 1 +
39
hw/misc/Kconfig | 4 +
40
hw/misc/meson.build | 1 +
41
tests/qtest/meson.build | 1 +
42
10 files changed, 542 insertions(+), 8 deletions(-)
43
create mode 100644 include/hw/misc/emc141x_regs.h
44
create mode 100644 hw/misc/emc141x.c
45
create mode 100644 tests/qtest/emc141x-test.c
46
43
44
docs/system/arm/aspeed.rst | 4 +-
45
include/hw/arm/aspeed.h | 1 +
46
include/hw/sd/sdhci.h | 5 +
47
include/hw/timer/aspeed_timer.h | 1 +
48
hw/arm/aspeed.c | 15 +-
49
hw/arm/aspeed_ast27x0.c | 17 ++
50
hw/sd/sdhci.c | 6 +
51
hw/timer/aspeed_timer.c | 263 ++++++++++++++++++++++++++--
52
hw/watchdog/wdt_aspeed.c | 19 +-
53
hw/timer/trace-events | 2 +-
54
tests/functional/aspeed.py | 2 +-
55
tests/functional/test_aarch64_aspeed.py | 10 +-
56
tests/functional/test_arm_aspeed_ast2500.py | 8 +-
57
tests/functional/test_arm_aspeed_ast2600.py | 8 +-
58
14 files changed, 323 insertions(+), 38 deletions(-)
59
60
diff view generated by jsdifflib
1
From: John Wang <wangzhiqiang.bj@bytedance.com>
1
From: Kenneth Jia <kenneth_jia@asus.com>
2
2
3
Add an eeprom device and fill it with fru
3
In the loop, we need ignore the index increase when uart == uart_chosen
4
information
4
We should increase the index only after we allocate a serial.
5
5
6
$ ipmitool fru print 0
6
Signed-off-by: Kenneth Jia <kenneth_jia@asus.com>
7
Product Manufacturer : Bytedance
7
Fixes: d2b3eaefb4d7 ("aspeed: Refactor UART init for multi-SoC machines")
8
Product Name : G220A
8
Reviewed-by: Cédric Le Goater <clg@redhat.com>
9
9
Link: https://lore.kernel.org/r/5f9b0c53f1644922ba85522046e92f4c@asus.com
10
Signed-off-by: John Wang <wangzhiqiang.bj@bytedance.com>
10
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11
Reviewed-by: Cédric Le Goater <clg@kaod.org>
12
Message-Id: <20201210103607.556-1-wangzhiqiang.bj@bytedance.com>
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
14
---
11
---
15
hw/arm/aspeed.c | 12 ++++++++++++
12
hw/arm/aspeed.c | 4 ++--
16
1 file changed, 12 insertions(+)
13
1 file changed, 2 insertions(+), 2 deletions(-)
17
14
18
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
15
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/aspeed.c
17
--- a/hw/arm/aspeed.c
21
+++ b/hw/arm/aspeed.c
18
+++ b/hw/arm/aspeed.c
22
@@ -XXX,XX +XXX,XX @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc)
19
@@ -XXX,XX +XXX,XX @@ static void connect_serial_hds_to_uarts(AspeedMachineState *bmc)
23
object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abort);
20
int uart_chosen = bmc->uart_chosen ? bmc->uart_chosen : amc->uart_default;
24
object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abort);
21
25
object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abort);
22
aspeed_soc_uart_set_chr(s, uart_chosen, serial_hd(0));
26
+
23
- for (int i = 1, uart = sc->uarts_base; i < sc->uarts_num; i++, uart++) {
27
+ static uint8_t eeprom_buf[2 * 1024] = {
24
+ for (int i = 1, uart = sc->uarts_base; i < sc->uarts_num; uart++) {
28
+ 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xfe,
25
if (uart == uart_chosen) {
29
+ 0x01, 0x06, 0x00, 0xc9, 0x42, 0x79, 0x74, 0x65,
26
continue;
30
+ 0x64, 0x61, 0x6e, 0x63, 0x65, 0xc5, 0x47, 0x32,
27
}
31
+ 0x32, 0x30, 0x41, 0xc4, 0x41, 0x41, 0x42, 0x42,
28
- aspeed_soc_uart_set_chr(s, uart, serial_hd(i));
32
+ 0xc4, 0x43, 0x43, 0x44, 0x44, 0xc4, 0x45, 0x45,
29
+ aspeed_soc_uart_set_chr(s, uart, serial_hd(i++));
33
+ 0x46, 0x46, 0xc4, 0x48, 0x48, 0x47, 0x47, 0xc1,
30
}
34
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7,
35
+ };
36
+ smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 4), 0x57,
37
+ eeprom_buf);
38
}
31
}
39
32
40
static bool aspeed_get_mmio_exec(Object *obj, Error **errp)
41
--
33
--
42
2.26.2
34
2.48.1
43
35
44
36
diff view generated by jsdifflib
New patch
1
From: Jamin Lin <jamin_lin@aspeedtech.com>
1
2
3
The Write Protect pin of SDHCI model is default active low to match the SDHCI
4
spec. So, write enable the bit 19 should be 1 and write protected the bit 19
5
should be 0 at the Present State Register (0x24). However, some boards are
6
design Write Protected pin active high. In other words, write enable the bit 19
7
should be 0 and write protected the bit 19 should be 1 at the
8
Present State Register (0x24). To support it, introduces a new "wp-inverted"
9
property and set it false by default.
10
11
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
12
Acked-by: Cédric Le Goater <clg@redhat.com>
13
Acked-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Link: https://lore.kernel.org/r/20241114094839.4128404-3-jamin_lin@aspeedtech.com
15
Signed-off-by: Cédric Le Goater <clg@redhat.com>
16
---
17
include/hw/sd/sdhci.h | 5 +++++
18
hw/sd/sdhci.c | 6 ++++++
19
2 files changed, 11 insertions(+)
20
21
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
22
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/sd/sdhci.h
24
+++ b/include/hw/sd/sdhci.h
25
@@ -XXX,XX +XXX,XX @@ struct SDHCIState {
26
uint8_t sd_spec_version;
27
uint8_t uhs_mode;
28
uint8_t vendor; /* For vendor specific functionality */
29
+ /*
30
+ * Write Protect pin default active low for detecting SD card
31
+ * to be protected. Set wp_inverted to invert the signal.
32
+ */
33
+ bool wp_inverted;
34
};
35
typedef struct SDHCIState SDHCIState;
36
37
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/sd/sdhci.c
40
+++ b/hw/sd/sdhci.c
41
@@ -XXX,XX +XXX,XX @@ static void sdhci_set_readonly(DeviceState *dev, bool level)
42
{
43
SDHCIState *s = (SDHCIState *)dev;
44
45
+ if (s->wp_inverted) {
46
+ level = !level;
47
+ }
48
+
49
if (level) {
50
s->prnsts &= ~SDHC_WRITE_PROTECT;
51
} else {
52
@@ -XXX,XX +XXX,XX @@ static const Property sdhci_sysbus_properties[] = {
53
false),
54
DEFINE_PROP_LINK("dma", SDHCIState,
55
dma_mr, TYPE_MEMORY_REGION, MemoryRegion *),
56
+ DEFINE_PROP_BOOL("wp-inverted", SDHCIState,
57
+ wp_inverted, false),
58
};
59
60
static void sdhci_sysbus_init(Object *obj)
61
--
62
2.48.1
63
64
diff view generated by jsdifflib
New patch
1
From: Jamin Lin <jamin_lin@aspeedtech.com>
1
2
3
The Write Protect pin of SDHCI model is default active low to match the SDHCI
4
spec. So, write enable the bit 19 should be 1 and write protected the bit 19
5
should be 0 at the Present State Register (0x24).
6
7
According to the design of AST2600 EVB, the Write Protected pin is active
8
high by default. To support it, introduces a new "sdhci_wp_inverted"
9
property in ASPEED MACHINE State and set it true for AST2600 EVB
10
and set "wp_inverted" property true of sdhci-generic model.
11
12
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
13
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
14
Acked-by: Philippe Mathieu-Daudé <philmd@linaro.org>
15
Link: https://lore.kernel.org/r/20241114094839.4128404-4-jamin_lin@aspeedtech.com
16
Signed-off-by: Cédric Le Goater <clg@redhat.com>
17
---
18
include/hw/arm/aspeed.h | 1 +
19
hw/arm/aspeed.c | 7 +++++++
20
2 files changed, 8 insertions(+)
21
22
diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h
23
index XXXXXXX..XXXXXXX 100644
24
--- a/include/hw/arm/aspeed.h
25
+++ b/include/hw/arm/aspeed.h
26
@@ -XXX,XX +XXX,XX @@ struct AspeedMachineClass {
27
uint32_t macs_mask;
28
void (*i2c_init)(AspeedMachineState *bmc);
29
uint32_t uart_default;
30
+ bool sdhci_wp_inverted;
31
};
32
33
34
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/hw/arm/aspeed.c
37
+++ b/hw/arm/aspeed.c
38
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
39
OBJECT(get_system_memory()), &error_abort);
40
object_property_set_link(OBJECT(bmc->soc), "dram",
41
OBJECT(machine->ram), &error_abort);
42
+ if (amc->sdhci_wp_inverted) {
43
+ for (i = 0; i < bmc->soc->sdhci.num_slots; i++) {
44
+ object_property_set_bool(OBJECT(&bmc->soc->sdhci.slots[i]),
45
+ "wp-inverted", true, &error_abort);
46
+ }
47
+ }
48
if (machine->kernel_filename) {
49
/*
50
* When booting with a -kernel command line there is no u-boot
51
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data)
52
amc->num_cs = 1;
53
amc->macs_mask = ASPEED_MAC0_ON | ASPEED_MAC1_ON | ASPEED_MAC2_ON |
54
ASPEED_MAC3_ON;
55
+ amc->sdhci_wp_inverted = true;
56
amc->i2c_init = ast2600_evb_i2c_init;
57
mc->default_ram_size = 1 * GiB;
58
aspeed_machine_class_init_cpus_defaults(mc);
59
--
60
2.48.1
61
62
diff view generated by jsdifflib
New patch
1
1
From: Jamin Lin <jamin_lin@aspeedtech.com>
2
3
The register set have a significant change in AST2700. The TMC00-TMC3C
4
are used for TIMER0 and TMC40-TMC7C are used for TIMER1. In additional,
5
TMC20-TMC3C and TMC60-TMC7C are reserved registers for TIMER0 and TIMER1,
6
respectively.
7
8
Besides, each TIMER has their own control and interrupt status register.
9
In other words, users are able to set control and interrupt status for TIMER0
10
in one register. Both aspeed_timer_read and aspeed_timer_write callback
11
functions are not compatible AST2700.
12
13
Introduce common read and write functions for ASPEED timers.
14
Modify the aspeed_timer_read and aspeed_timer_write functions to delegate to
15
SoC-specific callbacks first.
16
Update the AST2400, AST2500, AST2600 and AST1030 specific read and write
17
functions to call the common implementations for common register accesses.
18
19
This refactoring improves the organization of call delegation and prepares the
20
codebase for future SoC-specific specializations, such as the AST2700.
21
22
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
23
Reviewed-by: Cédric Le Goater <clg@redhat.com>
24
Link: https://lore.kernel.org/r/20250113064455.1660564-2-jamin_lin@aspeedtech.com
25
Signed-off-by: Cédric Le Goater <clg@redhat.com>
26
---
27
hw/timer/aspeed_timer.c | 55 ++++++++++++++++++++++++++++++-----------
28
hw/timer/trace-events | 2 +-
29
2 files changed, 41 insertions(+), 16 deletions(-)
30
31
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/timer/aspeed_timer.c
34
+++ b/hw/timer/aspeed_timer.c
35
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_timer_get_value(AspeedTimer *t, int reg)
36
return value;
37
}
38
39
-static uint64_t aspeed_timer_read(void *opaque, hwaddr offset, unsigned size)
40
+static uint64_t aspeed_timer_read_common(AspeedTimerCtrlState *s, hwaddr offset)
41
{
42
- AspeedTimerCtrlState *s = opaque;
43
const int reg = (offset & 0xf) / 4;
44
uint64_t value;
45
46
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_timer_read(void *opaque, hwaddr offset, unsigned size)
47
value = aspeed_timer_get_value(&s->timers[(offset >> 4) - 1], reg);
48
break;
49
default:
50
- value = ASPEED_TIMER_GET_CLASS(s)->read(s, offset);
51
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
52
+ __func__, offset);
53
+ value = 0;
54
break;
55
}
56
- trace_aspeed_timer_read(offset, size, value);
57
return value;
58
}
59
60
@@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_ctrl2(AspeedTimerCtrlState *s, uint32_t value)
61
trace_aspeed_timer_set_ctrl2(value);
62
}
63
64
-static void aspeed_timer_write(void *opaque, hwaddr offset, uint64_t value,
65
- unsigned size)
66
+static void aspeed_timer_write_common(AspeedTimerCtrlState *s, hwaddr offset,
67
+ uint64_t value)
68
{
69
const uint32_t tv = (uint32_t)(value & 0xFFFFFFFF);
70
const int reg = (offset & 0xf) / 4;
71
- AspeedTimerCtrlState *s = opaque;
72
73
switch (offset) {
74
/* Control Registers */
75
@@ -XXX,XX +XXX,XX @@ static void aspeed_timer_write(void *opaque, hwaddr offset, uint64_t value,
76
aspeed_timer_set_value(s, (offset >> TIMER_NR_REGS) - 1, reg, tv);
77
break;
78
default:
79
- ASPEED_TIMER_GET_CLASS(s)->write(s, offset, value);
80
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
81
+ __func__, offset);
82
break;
83
}
84
}
85
86
+static uint64_t aspeed_timer_read(void *opaque, hwaddr offset, unsigned size)
87
+{
88
+ AspeedTimerCtrlState *s = ASPEED_TIMER(opaque);
89
+ return ASPEED_TIMER_GET_CLASS(s)->read(s, offset);
90
+}
91
+
92
+static void aspeed_timer_write(void *opaque, hwaddr offset, uint64_t value,
93
+ unsigned size)
94
+{
95
+ AspeedTimerCtrlState *s = ASPEED_TIMER(opaque);
96
+ ASPEED_TIMER_GET_CLASS(s)->write(s, offset, value);
97
+}
98
+
99
static const MemoryRegionOps aspeed_timer_ops = {
100
.read = aspeed_timer_read,
101
.write = aspeed_timer_write,
102
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_2400_timer_read(AspeedTimerCtrlState *s, hwaddr offset)
103
break;
104
case 0x38:
105
case 0x3C:
106
- default:
107
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
108
__func__, offset);
109
value = 0;
110
break;
111
+ default:
112
+ value = aspeed_timer_read_common(s, offset);
113
+ break;
114
}
115
+ trace_aspeed_timer_read(offset, value);
116
return value;
117
}
118
119
@@ -XXX,XX +XXX,XX @@ static void aspeed_2400_timer_write(AspeedTimerCtrlState *s, hwaddr offset,
120
break;
121
case 0x38:
122
case 0x3C:
123
- default:
124
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
125
__func__, offset);
126
break;
127
+ default:
128
+ aspeed_timer_write_common(s, offset, value);
129
+ break;
130
}
131
}
132
133
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_2500_timer_read(AspeedTimerCtrlState *s, hwaddr offset)
134
value = s->ctrl3 & BIT(0);
135
break;
136
case 0x3C:
137
- default:
138
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
139
__func__, offset);
140
value = 0;
141
break;
142
+ default:
143
+ value = aspeed_timer_read_common(s, offset);
144
+ break;
145
}
146
+ trace_aspeed_timer_read(offset, value);
147
return value;
148
}
149
150
@@ -XXX,XX +XXX,XX @@ static void aspeed_2500_timer_write(AspeedTimerCtrlState *s, hwaddr offset,
151
break;
152
153
default:
154
- qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
155
- __func__, offset);
156
+ aspeed_timer_write_common(s, offset, value);
157
break;
158
}
159
}
160
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_2600_timer_read(AspeedTimerCtrlState *s, hwaddr offset)
161
break;
162
case 0x38:
163
case 0x3C:
164
- default:
165
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
166
__func__, offset);
167
value = 0;
168
break;
169
+ default:
170
+ value = aspeed_timer_read_common(s, offset);
171
+ break;
172
}
173
+ trace_aspeed_timer_read(offset, value);
174
return value;
175
}
176
177
@@ -XXX,XX +XXX,XX @@ static void aspeed_2600_timer_write(AspeedTimerCtrlState *s, hwaddr offset,
178
aspeed_timer_set_ctrl(s, s->ctrl & ~tv);
179
break;
180
case 0x38:
181
- default:
182
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
183
__func__, offset);
184
break;
185
+ default:
186
+ aspeed_timer_write_common(s, offset, value);
187
+ break;
188
}
189
}
190
191
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
192
index XXXXXXX..XXXXXXX 100644
193
--- a/hw/timer/trace-events
194
+++ b/hw/timer/trace-events
195
@@ -XXX,XX +XXX,XX @@ aspeed_timer_ctrl_overflow_interrupt(uint8_t i, bool enable) "Timer %" PRIu8 ":
196
aspeed_timer_ctrl_pulse_enable(uint8_t i, bool enable) "Timer %" PRIu8 ": %d"
197
aspeed_timer_set_ctrl2(uint32_t value) "Value: 0x%" PRIx32
198
aspeed_timer_set_value(int timer, int reg, uint32_t value) "Timer %d register %d: 0x%" PRIx32
199
-aspeed_timer_read(uint64_t offset, unsigned size, uint64_t value) "From 0x%" PRIx64 ": of size %u: 0x%" PRIx64
200
+aspeed_timer_read(uint64_t offset, uint64_t value) "From 0x%" PRIx64 ": 0x%" PRIx64
201
202
# armv7m_systick.c
203
systick_reload(void) "systick reload"
204
--
205
2.48.1
206
207
diff view generated by jsdifflib
New patch
1
1
From: Jamin Lin <jamin_lin@aspeedtech.com>
2
3
The timer controller include 8 sets of 32-bit decrement counters, based on
4
either PCLK or 1MHZ clock and the design of timer controller between AST2600
5
and AST2700 are almost the same.
6
7
TIMER0 – TIMER7 has their own individual control and interrupt status register.
8
In other words, users are able to set timer control in register TMC10 with
9
different TIMER base address and clear timer control and interrupt status in
10
register TMC14 with different TIMER base address.
11
12
Introduce new "aspeed_2700_timer_read" and "aspeed_2700_timer_write" callback
13
functions and a new ast2700 class to support AST2700.
14
15
The base address of TIMER0 to TIMER7 as following.
16
Base Address of Timer 0 = 0x12C1_0000
17
Base Address of Timer 1 = 0x12C1_0040
18
Base Address of Timer 2 = 0x12C1_0080
19
Base Address of Timer 3 = 0x12C1_00C0
20
Base Address of Timer 4 = 0x12C1_0100
21
Base Address of Timer 5 = 0x12C1_0140
22
Base Address of Timer 6 = 0x12C1_0180
23
Base Address of Timer 7 = 0x12C1_01C0
24
25
The register address space of each TIMER is "0x40" , and uses the following
26
formula to get the index and register of each TIMER.
27
28
timer_index = offset >> 6;
29
timer_offset = offset & 0x3f;
30
31
The TMC010 is a counter control set and interrupt status register. Write "1" to
32
TMC10[3:0] will set the specific bits to "1". Introduce a new
33
"aspeed_2700_timer_set_ctrl" function to handle this register behavior.
34
35
The TMC014 is a counter control clear and interrupt status register, to clear
36
the specific bits to "0", it should write "1" to TMC14[3:0] on the same bit
37
position. Introduce a new "aspeed_2700_timer_clear_ctrl" function to handle
38
this register behavior. TMC014 does not support read operation.
39
40
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
41
Acked-by: Cédric Le Goater <clg@redhat.com>
42
Link: https://lore.kernel.org/r/20250113064455.1660564-3-jamin_lin@aspeedtech.com
43
Signed-off-by: Cédric Le Goater <clg@redhat.com>
44
---
45
include/hw/timer/aspeed_timer.h | 1 +
46
hw/timer/aspeed_timer.c | 208 ++++++++++++++++++++++++++++++++
47
2 files changed, 209 insertions(+)
48
49
diff --git a/include/hw/timer/aspeed_timer.h b/include/hw/timer/aspeed_timer.h
50
index XXXXXXX..XXXXXXX 100644
51
--- a/include/hw/timer/aspeed_timer.h
52
+++ b/include/hw/timer/aspeed_timer.h
53
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(AspeedTimerCtrlState, AspeedTimerClass, ASPEED_TIMER)
54
#define TYPE_ASPEED_2500_TIMER TYPE_ASPEED_TIMER "-ast2500"
55
#define TYPE_ASPEED_2600_TIMER TYPE_ASPEED_TIMER "-ast2600"
56
#define TYPE_ASPEED_1030_TIMER TYPE_ASPEED_TIMER "-ast1030"
57
+#define TYPE_ASPEED_2700_TIMER TYPE_ASPEED_TIMER "-ast2700"
58
59
#define ASPEED_TIMER_NR_TIMERS 8
60
61
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
62
index XXXXXXX..XXXXXXX 100644
63
--- a/hw/timer/aspeed_timer.c
64
+++ b/hw/timer/aspeed_timer.c
65
@@ -XXX,XX +XXX,XX @@ static void aspeed_2600_timer_write(AspeedTimerCtrlState *s, hwaddr offset,
66
}
67
}
68
69
+static void aspeed_2700_timer_set_ctrl(AspeedTimerCtrlState *s, int index,
70
+ uint32_t reg)
71
+{
72
+ const uint8_t overflow_interrupt_mask = BIT(op_overflow_interrupt);
73
+ const uint8_t external_clock_mask = BIT(op_external_clock);
74
+ const uint8_t pulse_enable_mask = BIT(op_pulse_enable);
75
+ const uint8_t enable_mask = BIT(op_enable);
76
+ AspeedTimer *t;
77
+ uint8_t t_old;
78
+ uint8_t t_new;
79
+ int shift;
80
+
81
+ /*
82
+ * Only 1 will set the specific bits to 1
83
+ * Handle a dependency between the 'enable' and remaining three
84
+ * configuration bits - i.e. if more than one bit in the control set has
85
+ * set, including the 'enable' bit, perform configuration and then
86
+ * enable the timer.
87
+ * Interrupt Status bit should not be set.
88
+ */
89
+
90
+ t = &s->timers[index];
91
+ shift = index * TIMER_CTRL_BITS;
92
+
93
+ t_old = (s->ctrl >> shift) & TIMER_CTRL_MASK;
94
+ t_new = reg & TIMER_CTRL_MASK;
95
+
96
+ if (!(t_old & external_clock_mask) &&
97
+ (t_new & external_clock_mask)) {
98
+ aspeed_timer_ctrl_external_clock(t, true);
99
+ s->ctrl = deposit32(s->ctrl, shift + op_external_clock, 1, 1);
100
+ }
101
+
102
+ if (!(t_old & overflow_interrupt_mask) &&
103
+ (t_new & overflow_interrupt_mask)) {
104
+ aspeed_timer_ctrl_overflow_interrupt(t, true);
105
+ s->ctrl = deposit32(s->ctrl, shift + op_overflow_interrupt, 1, 1);
106
+ }
107
+
108
+
109
+ if (!(t_old & pulse_enable_mask) &&
110
+ (t_new & pulse_enable_mask)) {
111
+ aspeed_timer_ctrl_pulse_enable(t, true);
112
+ s->ctrl = deposit32(s->ctrl, shift + op_pulse_enable, 1, 1);
113
+ }
114
+
115
+ /* If we are enabling, do so last */
116
+ if (!(t_old & enable_mask) &&
117
+ (t_new & enable_mask)) {
118
+ aspeed_timer_ctrl_enable(t, true);
119
+ s->ctrl = deposit32(s->ctrl, shift + op_enable, 1, 1);
120
+ }
121
+}
122
+
123
+static void aspeed_2700_timer_clear_ctrl(AspeedTimerCtrlState *s, int index,
124
+ uint32_t reg)
125
+{
126
+ const uint8_t overflow_interrupt_mask = BIT(op_overflow_interrupt);
127
+ const uint8_t external_clock_mask = BIT(op_external_clock);
128
+ const uint8_t pulse_enable_mask = BIT(op_pulse_enable);
129
+ const uint8_t enable_mask = BIT(op_enable);
130
+ AspeedTimer *t;
131
+ uint8_t t_old;
132
+ uint8_t t_new;
133
+ int shift;
134
+
135
+ /*
136
+ * Only 1 will clear the specific bits to 0
137
+ * Handle a dependency between the 'enable' and remaining three
138
+ * configuration bits - i.e. if more than one bit in the control set has
139
+ * clear, including the 'enable' bit, then disable the timer and perform
140
+ * configuration
141
+ */
142
+
143
+ t = &s->timers[index];
144
+ shift = index * TIMER_CTRL_BITS;
145
+
146
+ t_old = (s->ctrl >> shift) & TIMER_CTRL_MASK;
147
+ t_new = reg & TIMER_CTRL_MASK;
148
+
149
+ /* If we are disabling, do so first */
150
+ if ((t_old & enable_mask) &&
151
+ (t_new & enable_mask)) {
152
+ aspeed_timer_ctrl_enable(t, false);
153
+ s->ctrl = deposit32(s->ctrl, shift + op_enable, 1, 0);
154
+ }
155
+
156
+ if ((t_old & external_clock_mask) &&
157
+ (t_new & external_clock_mask)) {
158
+ aspeed_timer_ctrl_external_clock(t, false);
159
+ s->ctrl = deposit32(s->ctrl, shift + op_external_clock, 1, 0);
160
+ }
161
+
162
+ if ((t_old & overflow_interrupt_mask) &&
163
+ (t_new & overflow_interrupt_mask)) {
164
+ aspeed_timer_ctrl_overflow_interrupt(t, false);
165
+ s->ctrl = deposit32(s->ctrl, shift + op_overflow_interrupt, 1, 0);
166
+ }
167
+
168
+ if ((t_old & pulse_enable_mask) &&
169
+ (t_new & pulse_enable_mask)) {
170
+ aspeed_timer_ctrl_pulse_enable(t, false);
171
+ s->ctrl = deposit32(s->ctrl, shift + op_pulse_enable, 1, 0);
172
+ }
173
+
174
+ /* Clear interrupt status */
175
+ if (reg & 0x10000) {
176
+ s->irq_sts = deposit32(s->irq_sts, index, 1, 0);
177
+ }
178
+}
179
+
180
+static uint64_t aspeed_2700_timer_read(AspeedTimerCtrlState *s, hwaddr offset)
181
+{
182
+ uint32_t timer_offset = offset & 0x3f;
183
+ int timer_index = offset >> 6;
184
+ uint64_t value = 0;
185
+
186
+ if (timer_index >= ASPEED_TIMER_NR_TIMERS) {
187
+ qemu_log_mask(LOG_GUEST_ERROR,
188
+ "%s: offset 0x%" PRIx64 " out of bounds\n",
189
+ __func__, offset);
190
+ return 0;
191
+ }
192
+
193
+ switch (timer_offset) {
194
+ /*
195
+ * Counter Status
196
+ * Counter Reload
197
+ * Counter First Matching
198
+ * Counter Second Matching
199
+ */
200
+ case 0x00 ... 0x0C:
201
+ value = aspeed_timer_get_value(&s->timers[timer_index],
202
+ timer_offset >> 2);
203
+ break;
204
+ /* Counter Control and Interrupt Status */
205
+ case 0x10:
206
+ value = deposit64(value, 0, 4,
207
+ extract32(s->ctrl, timer_index * 4, 4));
208
+ value = deposit64(value, 16, 1,
209
+ extract32(s->irq_sts, timer_index, 1));
210
+ break;
211
+ default:
212
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: no getter for offset 0x%"
213
+ PRIx64"\n", __func__, offset);
214
+ value = 0;
215
+ break;
216
+ }
217
+ trace_aspeed_timer_read(offset, value);
218
+ return value;
219
+}
220
+
221
+static void aspeed_2700_timer_write(AspeedTimerCtrlState *s, hwaddr offset,
222
+ uint64_t value)
223
+{
224
+ const uint32_t timer_value = (uint32_t)(value & 0xFFFFFFFF);
225
+ uint32_t timer_offset = offset & 0x3f;
226
+ int timer_index = offset >> 6;
227
+
228
+ if (timer_index >= ASPEED_TIMER_NR_TIMERS) {
229
+ qemu_log_mask(LOG_GUEST_ERROR,
230
+ "%s: offset 0x%" PRIx64 " out of bounds\n",
231
+ __func__, offset);
232
+ }
233
+
234
+ switch (timer_offset) {
235
+ /*
236
+ * Counter Status
237
+ * Counter Reload
238
+ * Counter First Matching
239
+ * Counter Second Matching
240
+ */
241
+ case 0x00 ... 0x0C:
242
+ aspeed_timer_set_value(s, timer_index, timer_offset >> 2,
243
+ timer_value);
244
+ break;
245
+ /* Counter Control Set and Interrupt Status */
246
+ case 0x10:
247
+ aspeed_2700_timer_set_ctrl(s, timer_index, timer_value);
248
+ break;
249
+ /* Counter Control Clear and Interrupr Status */
250
+ case 0x14:
251
+ aspeed_2700_timer_clear_ctrl(s, timer_index, timer_value);
252
+ break;
253
+ default:
254
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: no setter for offset 0x%"
255
+ PRIx64"\n", __func__, offset);
256
+ break;
257
+ }
258
+}
259
+
260
static void aspeed_init_one_timer(AspeedTimerCtrlState *s, uint8_t id)
261
{
262
AspeedTimer *t = &s->timers[id];
263
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_1030_timer_info = {
264
.class_init = aspeed_1030_timer_class_init,
265
};
266
267
+static void aspeed_2700_timer_class_init(ObjectClass *klass, void *data)
268
+{
269
+ DeviceClass *dc = DEVICE_CLASS(klass);
270
+ AspeedTimerClass *awc = ASPEED_TIMER_CLASS(klass);
271
+
272
+ dc->desc = "ASPEED 2700 Timer";
273
+ awc->read = aspeed_2700_timer_read;
274
+ awc->write = aspeed_2700_timer_write;
275
+}
276
+
277
+static const TypeInfo aspeed_2700_timer_info = {
278
+ .name = TYPE_ASPEED_2700_TIMER,
279
+ .parent = TYPE_ASPEED_TIMER,
280
+ .class_init = aspeed_2700_timer_class_init,
281
+};
282
+
283
static void aspeed_timer_register_types(void)
284
{
285
type_register_static(&aspeed_timer_info);
286
@@ -XXX,XX +XXX,XX @@ static void aspeed_timer_register_types(void)
287
type_register_static(&aspeed_2500_timer_info);
288
type_register_static(&aspeed_2600_timer_info);
289
type_register_static(&aspeed_1030_timer_info);
290
+ type_register_static(&aspeed_2700_timer_info);
291
}
292
293
type_init(aspeed_timer_register_types)
294
--
295
2.48.1
296
297
diff view generated by jsdifflib
1
From: John Wang <wangzhiqiang.bj@bytedance.com>
1
From: Jamin Lin <jamin_lin@aspeedtech.com>
2
2
3
Largely inspired by the TMP421 temperature sensor, here is a model for
3
Add Timer model for AST2700 Timer support. The Timer controller include 8 sets
4
the EMC1413/EMC1414 temperature sensors.
4
of 32-bit decrement counters.
5
5
6
Specs can be found here :
6
The base address of TIMER0 to TIMER7 as following.
7
http://ww1.microchip.com/downloads/en/DeviceDoc/20005274A.pdf
7
Base Address of Timer 0 = 0x12C1_0000
8
Base Address of Timer 1 = 0x12C1_0040
9
Base Address of Timer 2 = 0x12C1_0080
10
Base Address of Timer 3 = 0x12C1_00C0
11
Base Address of Timer 4 = 0x12C1_0100
12
Base Address of Timer 5 = 0x12C1_0140
13
Base Address of Timer 6 = 0x12C1_0180
14
Base Address of Timer 7 = 0x12C1_01C0
8
15
9
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
16
The interrupt of TIMER0 to TIMER7 as following.
10
Signed-off-by: John Wang <wangzhiqiang.bj@bytedance.com>
17
GICINT16 = TIMER 0 interrupt
11
Reviewed-by: Cédric Le Goater <clg@kaod.org>
18
GICINT17 = TIMER 1 interrupt
12
Message-Id: <20201122105134.671-1-wangzhiqiang.bj@bytedance.com>
19
GICINT18 = TIMER 2 interrupt
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
20
GICINT19 = TIMER 3 interrupt
21
GICINT20 = TIMER 4 interrupt
22
GICINT21 = TIMER 5 interrupt
23
GICINT22 = TIMER 6 interrupt
24
GICINT23 = TIMER 7 interrupt
25
26
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
27
Reviewed-by: Cédric Le Goater <clg@redhat.com>
28
Link: https://lore.kernel.org/r/20250113064455.1660564-4-jamin_lin@aspeedtech.com
29
Signed-off-by: Cédric Le Goater <clg@redhat.com>
14
---
30
---
15
include/hw/misc/emc141x_regs.h | 37 ++++
31
hw/arm/aspeed_ast27x0.c | 17 +++++++++++++++++
16
hw/misc/emc141x.c | 326 +++++++++++++++++++++++++++++++++
32
1 file changed, 17 insertions(+)
17
tests/qtest/emc141x-test.c | 81 ++++++++
18
hw/arm/Kconfig | 1 +
19
hw/misc/Kconfig | 4 +
20
hw/misc/meson.build | 1 +
21
tests/qtest/meson.build | 1 +
22
7 files changed, 451 insertions(+)
23
create mode 100644 include/hw/misc/emc141x_regs.h
24
create mode 100644 hw/misc/emc141x.c
25
create mode 100644 tests/qtest/emc141x-test.c
26
33
27
diff --git a/include/hw/misc/emc141x_regs.h b/include/hw/misc/emc141x_regs.h
34
diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c
28
new file mode 100644
35
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX
36
--- a/hw/arm/aspeed_ast27x0.c
30
--- /dev/null
37
+++ b/hw/arm/aspeed_ast27x0.c
31
+++ b/include/hw/misc/emc141x_regs.h
38
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2700_memmap[] = {
32
@@ -XXX,XX +XXX,XX @@
39
[ASPEED_DEV_GPIO] = 0x14C0B000,
33
+/*
40
[ASPEED_DEV_RTC] = 0x12C0F000,
34
+ * SMSC EMC141X temperature sensor.
41
[ASPEED_DEV_SDHCI] = 0x14080000,
35
+ *
42
+ [ASPEED_DEV_TIMER1] = 0x12C10000,
36
+ * Browse the data sheet:
43
};
37
+ *
44
38
+ * http://ww1.microchip.com/downloads/en/DeviceDoc/20005274A.pdf
45
#define AST2700_MAX_IRQ 256
39
+ *
46
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2700_init(Object *obj)
40
+ * This work is licensed under the terms of the GNU GPL, version 2 or
47
41
+ * later. See the COPYING file in the top-level directory.
48
object_initialize_child(obj, "emmc-controller.sdhci", &s->emmc.slots[0],
42
+ */
49
TYPE_SYSBUS_SDHCI);
43
+
50
+
44
+#ifndef TMP105_REGS_H
51
+ snprintf(typename, sizeof(typename), "aspeed.timer-%s", socname);
45
+#define TMP105_REGS_H
52
+ object_initialize_child(obj, "timerctrl", &s->timerctrl, typename);
46
+
53
}
47
+#define EMC1413_DEVICE_ID 0x21
54
48
+#define EMC1414_DEVICE_ID 0x25
55
/*
49
+#define MANUFACTURER_ID 0x5d
56
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
50
+#define REVISION 0x04
57
sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc), 0,
51
+
58
aspeed_soc_get_irq(s, ASPEED_DEV_EMMC));
52
+/* the EMC141X registers */
59
53
+#define EMC141X_TEMP_HIGH0 0x00
60
+ /* Timer */
54
+#define EMC141X_TEMP_HIGH1 0x01
61
+ object_property_set_link(OBJECT(&s->timerctrl), "scu", OBJECT(&s->scu),
55
+#define EMC141X_TEMP_HIGH2 0x23
62
+ &error_abort);
56
+#define EMC141X_TEMP_HIGH3 0x2a
63
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) {
57
+#define EMC141X_TEMP_MAX_HIGH0 0x05
58
+#define EMC141X_TEMP_MIN_HIGH0 0x06
59
+#define EMC141X_TEMP_MAX_HIGH1 0x07
60
+#define EMC141X_TEMP_MIN_HIGH1 0x08
61
+#define EMC141X_TEMP_MAX_HIGH2 0x15
62
+#define EMC141X_TEMP_MIN_HIGH2 0x16
63
+#define EMC141X_TEMP_MAX_HIGH3 0x2c
64
+#define EMC141X_TEMP_MIN_HIGH3 0x2d
65
+#define EMC141X_DEVICE_ID 0xfd
66
+#define EMC141X_MANUFACTURER_ID 0xfe
67
+#define EMC141X_REVISION 0xff
68
+
69
+#endif
70
diff --git a/hw/misc/emc141x.c b/hw/misc/emc141x.c
71
new file mode 100644
72
index XXXXXXX..XXXXXXX
73
--- /dev/null
74
+++ b/hw/misc/emc141x.c
75
@@ -XXX,XX +XXX,XX @@
76
+/*
77
+ * SMSC EMC141X temperature sensor.
78
+ *
79
+ * Copyright (c) 2020 Bytedance Corporation
80
+ * Written by John Wang <wangzhiqiang.bj@bytedance.com>
81
+ *
82
+ * This program is free software; you can redistribute it and/or
83
+ * modify it under the terms of the GNU General Public License as
84
+ * published by the Free Software Foundation; either version 2 or
85
+ * (at your option) version 3 of the License.
86
+ *
87
+ * This program is distributed in the hope that it will be useful,
88
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
89
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
90
+ * GNU General Public License for more details.
91
+ *
92
+ * You should have received a copy of the GNU General Public License along
93
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
94
+ */
95
+
96
+#include "qemu/osdep.h"
97
+#include "hw/i2c/i2c.h"
98
+#include "migration/vmstate.h"
99
+#include "qapi/error.h"
100
+#include "qapi/visitor.h"
101
+#include "qemu/module.h"
102
+#include "qom/object.h"
103
+#include "hw/misc/emc141x_regs.h"
104
+
105
+#define SENSORS_COUNT_MAX 4
106
+
107
+struct EMC141XState {
108
+ I2CSlave parent_obj;
109
+ struct {
110
+ uint8_t raw_temp_min;
111
+ uint8_t raw_temp_current;
112
+ uint8_t raw_temp_max;
113
+ } sensor[SENSORS_COUNT_MAX];
114
+ uint8_t len;
115
+ uint8_t data;
116
+ uint8_t pointer;
117
+};
118
+
119
+struct EMC141XClass {
120
+ I2CSlaveClass parent_class;
121
+ uint8_t model;
122
+ unsigned sensors_count;
123
+};
124
+
125
+#define TYPE_EMC141X "emc141x"
126
+OBJECT_DECLARE_TYPE(EMC141XState, EMC141XClass, EMC141X)
127
+
128
+static void emc141x_get_temperature(Object *obj, Visitor *v, const char *name,
129
+ void *opaque, Error **errp)
130
+{
131
+ EMC141XState *s = EMC141X(obj);
132
+ EMC141XClass *sc = EMC141X_GET_CLASS(s);
133
+ int64_t value;
134
+ unsigned tempid;
135
+
136
+ if (sscanf(name, "temperature%u", &tempid) != 1) {
137
+ error_setg(errp, "error reading %s: %s", name, g_strerror(errno));
138
+ return;
64
+ return;
139
+ }
65
+ }
140
+
66
+ aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->timerctrl), 0,
141
+ if (tempid >= sc->sensors_count) {
67
+ sc->memmap[ASPEED_DEV_TIMER1]);
142
+ error_setg(errp, "error reading %s", name);
68
+ for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
143
+ return;
69
+ irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i);
70
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq);
144
+ }
71
+ }
145
+
72
+
146
+ value = s->sensor[tempid].raw_temp_current * 1000;
73
create_unimplemented_device("ast2700.dpmcu", 0x11000000, 0x40000);
147
+
74
create_unimplemented_device("ast2700.iomem0", 0x12000000, 0x01000000);
148
+ visit_type_int(v, name, &value, errp);
75
create_unimplemented_device("ast2700.iomem1", 0x14000000, 0x01000000);
149
+}
150
+
151
+static void emc141x_set_temperature(Object *obj, Visitor *v, const char *name,
152
+ void *opaque, Error **errp)
153
+{
154
+ EMC141XState *s = EMC141X(obj);
155
+ EMC141XClass *sc = EMC141X_GET_CLASS(s);
156
+ int64_t temp;
157
+ unsigned tempid;
158
+
159
+ if (!visit_type_int(v, name, &temp, errp)) {
160
+ return;
161
+ }
162
+
163
+ if (sscanf(name, "temperature%u", &tempid) != 1) {
164
+ error_setg(errp, "error reading %s: %s", name, g_strerror(errno));
165
+ return;
166
+ }
167
+
168
+ if (tempid >= sc->sensors_count) {
169
+ error_setg(errp, "error reading %s", name);
170
+ return;
171
+ }
172
+
173
+ s->sensor[tempid].raw_temp_current = temp / 1000;
174
+}
175
+
176
+static void emc141x_read(EMC141XState *s)
177
+{
178
+ EMC141XClass *sc = EMC141X_GET_CLASS(s);
179
+ switch (s->pointer) {
180
+ case EMC141X_DEVICE_ID:
181
+ s->data = sc->model;
182
+ break;
183
+ case EMC141X_MANUFACTURER_ID:
184
+ s->data = MANUFACTURER_ID;
185
+ break;
186
+ case EMC141X_REVISION:
187
+ s->data = REVISION;
188
+ break;
189
+ case EMC141X_TEMP_HIGH0:
190
+ s->data = s->sensor[0].raw_temp_current;
191
+ break;
192
+ case EMC141X_TEMP_HIGH1:
193
+ s->data = s->sensor[1].raw_temp_current;
194
+ break;
195
+ case EMC141X_TEMP_HIGH2:
196
+ s->data = s->sensor[2].raw_temp_current;
197
+ break;
198
+ case EMC141X_TEMP_HIGH3:
199
+ s->data = s->sensor[3].raw_temp_current;
200
+ break;
201
+ case EMC141X_TEMP_MAX_HIGH0:
202
+ s->data = s->sensor[0].raw_temp_max;
203
+ break;
204
+ case EMC141X_TEMP_MAX_HIGH1:
205
+ s->data = s->sensor[1].raw_temp_max;
206
+ break;
207
+ case EMC141X_TEMP_MAX_HIGH2:
208
+ s->data = s->sensor[2].raw_temp_max;
209
+ break;
210
+ case EMC141X_TEMP_MAX_HIGH3:
211
+ s->data = s->sensor[3].raw_temp_max;
212
+ break;
213
+ case EMC141X_TEMP_MIN_HIGH0:
214
+ s->data = s->sensor[0].raw_temp_min;
215
+ break;
216
+ case EMC141X_TEMP_MIN_HIGH1:
217
+ s->data = s->sensor[1].raw_temp_min;
218
+ break;
219
+ case EMC141X_TEMP_MIN_HIGH2:
220
+ s->data = s->sensor[2].raw_temp_min;
221
+ break;
222
+ case EMC141X_TEMP_MIN_HIGH3:
223
+ s->data = s->sensor[3].raw_temp_min;
224
+ break;
225
+ default:
226
+ s->data = 0;
227
+ }
228
+}
229
+
230
+static void emc141x_write(EMC141XState *s)
231
+{
232
+ switch (s->pointer) {
233
+ case EMC141X_TEMP_MAX_HIGH0:
234
+ s->sensor[0].raw_temp_max = s->data;
235
+ break;
236
+ case EMC141X_TEMP_MAX_HIGH1:
237
+ s->sensor[1].raw_temp_max = s->data;
238
+ break;
239
+ case EMC141X_TEMP_MAX_HIGH2:
240
+ s->sensor[2].raw_temp_max = s->data;
241
+ break;
242
+ case EMC141X_TEMP_MAX_HIGH3:
243
+ s->sensor[3].raw_temp_max = s->data;
244
+ break;
245
+ case EMC141X_TEMP_MIN_HIGH0:
246
+ s->sensor[0].raw_temp_min = s->data;
247
+ break;
248
+ case EMC141X_TEMP_MIN_HIGH1:
249
+ s->sensor[1].raw_temp_min = s->data;
250
+ break;
251
+ case EMC141X_TEMP_MIN_HIGH2:
252
+ s->sensor[2].raw_temp_min = s->data;
253
+ break;
254
+ case EMC141X_TEMP_MIN_HIGH3:
255
+ s->sensor[3].raw_temp_min = s->data;
256
+ break;
257
+ default:
258
+ s->data = 0;
259
+ }
260
+}
261
+
262
+static uint8_t emc141x_rx(I2CSlave *i2c)
263
+{
264
+ EMC141XState *s = EMC141X(i2c);
265
+
266
+ if (s->len == 0) {
267
+ s->len++;
268
+ return s->data;
269
+ } else {
270
+ return 0xff;
271
+ }
272
+}
273
+
274
+static int emc141x_tx(I2CSlave *i2c, uint8_t data)
275
+{
276
+ EMC141XState *s = EMC141X(i2c);
277
+
278
+ if (s->len == 0) {
279
+ /* first byte is the reg pointer */
280
+ s->pointer = data;
281
+ s->len++;
282
+ } else if (s->len == 1) {
283
+ s->data = data;
284
+ emc141x_write(s);
285
+ }
286
+
287
+ return 0;
288
+}
289
+
290
+static int emc141x_event(I2CSlave *i2c, enum i2c_event event)
291
+{
292
+ EMC141XState *s = EMC141X(i2c);
293
+
294
+ if (event == I2C_START_RECV) {
295
+ emc141x_read(s);
296
+ }
297
+
298
+ s->len = 0;
299
+ return 0;
300
+}
301
+
302
+static const VMStateDescription vmstate_emc141x = {
303
+ .name = "EMC141X",
304
+ .version_id = 0,
305
+ .minimum_version_id = 0,
306
+ .fields = (VMStateField[]) {
307
+ VMSTATE_UINT8(len, EMC141XState),
308
+ VMSTATE_UINT8(data, EMC141XState),
309
+ VMSTATE_UINT8(pointer, EMC141XState),
310
+ VMSTATE_I2C_SLAVE(parent_obj, EMC141XState),
311
+ VMSTATE_END_OF_LIST()
312
+ }
313
+};
314
+
315
+static void emc141x_reset(DeviceState *dev)
316
+{
317
+ EMC141XState *s = EMC141X(dev);
318
+ int i;
319
+
320
+ for (i = 0; i < SENSORS_COUNT_MAX; i++) {
321
+ s->sensor[i].raw_temp_max = 0x55;
322
+ }
323
+ s->pointer = 0;
324
+ s->len = 0;
325
+}
326
+
327
+static void emc141x_initfn(Object *obj)
328
+{
329
+ object_property_add(obj, "temperature0", "int",
330
+ emc141x_get_temperature,
331
+ emc141x_set_temperature, NULL, NULL);
332
+ object_property_add(obj, "temperature1", "int",
333
+ emc141x_get_temperature,
334
+ emc141x_set_temperature, NULL, NULL);
335
+ object_property_add(obj, "temperature2", "int",
336
+ emc141x_get_temperature,
337
+ emc141x_set_temperature, NULL, NULL);
338
+ object_property_add(obj, "temperature3", "int",
339
+ emc141x_get_temperature,
340
+ emc141x_set_temperature, NULL, NULL);
341
+}
342
+
343
+static void emc141x_class_init(ObjectClass *klass, void *data)
344
+{
345
+ DeviceClass *dc = DEVICE_CLASS(klass);
346
+ I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
347
+
348
+ dc->reset = emc141x_reset;
349
+ k->event = emc141x_event;
350
+ k->recv = emc141x_rx;
351
+ k->send = emc141x_tx;
352
+ dc->vmsd = &vmstate_emc141x;
353
+}
354
+
355
+static void emc1413_class_init(ObjectClass *klass, void *data)
356
+{
357
+ EMC141XClass *ec = EMC141X_CLASS(klass);
358
+
359
+ emc141x_class_init(klass, data);
360
+ ec->model = EMC1413_DEVICE_ID;
361
+ ec->sensors_count = 3;
362
+}
363
+
364
+static void emc1414_class_init(ObjectClass *klass, void *data)
365
+{
366
+ EMC141XClass *ec = EMC141X_CLASS(klass);
367
+
368
+ emc141x_class_init(klass, data);
369
+ ec->model = EMC1414_DEVICE_ID;
370
+ ec->sensors_count = 4;
371
+}
372
+
373
+static const TypeInfo emc141x_info = {
374
+ .name = TYPE_EMC141X,
375
+ .parent = TYPE_I2C_SLAVE,
376
+ .instance_size = sizeof(EMC141XState),
377
+ .class_size = sizeof(EMC141XClass),
378
+ .instance_init = emc141x_initfn,
379
+ .abstract = true,
380
+};
381
+
382
+static const TypeInfo emc1413_info = {
383
+ .name = "emc1413",
384
+ .parent = TYPE_EMC141X,
385
+ .class_init = emc1413_class_init,
386
+};
387
+
388
+static const TypeInfo emc1414_info = {
389
+ .name = "emc1414",
390
+ .parent = TYPE_EMC141X,
391
+ .class_init = emc1414_class_init,
392
+};
393
+
394
+static void emc141x_register_types(void)
395
+{
396
+ type_register_static(&emc141x_info);
397
+ type_register_static(&emc1413_info);
398
+ type_register_static(&emc1414_info);
399
+}
400
+
401
+type_init(emc141x_register_types)
402
diff --git a/tests/qtest/emc141x-test.c b/tests/qtest/emc141x-test.c
403
new file mode 100644
404
index XXXXXXX..XXXXXXX
405
--- /dev/null
406
+++ b/tests/qtest/emc141x-test.c
407
@@ -XXX,XX +XXX,XX @@
408
+/*
409
+ * QTest testcase for the EMC141X temperature sensor
410
+ *
411
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
412
+ * See the COPYING file in the top-level directory.
413
+ */
414
+
415
+#include "qemu/osdep.h"
416
+
417
+#include "libqtest-single.h"
418
+#include "libqos/qgraph.h"
419
+#include "libqos/i2c.h"
420
+#include "qapi/qmp/qdict.h"
421
+#include "hw/misc/emc141x_regs.h"
422
+
423
+#define EMC1414_TEST_ID "emc1414-test"
424
+
425
+static int qmp_emc1414_get_temperature(const char *id)
426
+{
427
+ QDict *response;
428
+ int ret;
429
+
430
+ response = qmp("{ 'execute': 'qom-get', 'arguments': { 'path': %s, "
431
+ "'property': 'temperature0' } }", id);
432
+ g_assert(qdict_haskey(response, "return"));
433
+ ret = qdict_get_int(response, "return");
434
+ qobject_unref(response);
435
+ return ret;
436
+}
437
+
438
+static void qmp_emc1414_set_temperature(const char *id, int value)
439
+{
440
+ QDict *response;
441
+
442
+ response = qmp("{ 'execute': 'qom-set', 'arguments': { 'path': %s, "
443
+ "'property': 'temperature0', 'value': %d } }", id, value);
444
+ g_assert(qdict_haskey(response, "return"));
445
+ qobject_unref(response);
446
+}
447
+
448
+static void send_and_receive(void *obj, void *data, QGuestAllocator *alloc)
449
+{
450
+ uint16_t value;
451
+ QI2CDevice *i2cdev = (QI2CDevice *)obj;
452
+
453
+ value = qmp_emc1414_get_temperature(EMC1414_TEST_ID);
454
+ g_assert_cmpuint(value, ==, 0);
455
+
456
+ value = i2c_get8(i2cdev, EMC141X_TEMP_HIGH0);
457
+ g_assert_cmphex(value, ==, 0);
458
+
459
+ /* The default max value is 85C, 0x55=85 */
460
+ value = i2c_get8(i2cdev, EMC141X_TEMP_MAX_HIGH0);
461
+ g_assert_cmphex(value, ==, 0x55);
462
+
463
+ value = i2c_get8(i2cdev, EMC141X_TEMP_MIN_HIGH0);
464
+ g_assert_cmphex(value, ==, 0);
465
+
466
+ /* 3000mc = 30C */
467
+ qmp_emc1414_set_temperature(EMC1414_TEST_ID, 30000);
468
+ value = qmp_emc1414_get_temperature(EMC1414_TEST_ID);
469
+ g_assert_cmpuint(value, ==, 30000);
470
+
471
+ value = i2c_get8(i2cdev, EMC141X_TEMP_HIGH0);
472
+ g_assert_cmphex(value, ==, 30);
473
+
474
+}
475
+
476
+static void emc1414_register_nodes(void)
477
+{
478
+ QOSGraphEdgeOptions opts = {
479
+ .extra_device_opts = "id=" EMC1414_TEST_ID ",address=0x70"
480
+ };
481
+ add_qi2c_address(&opts, &(QI2CAddress) { 0x70 });
482
+
483
+ qos_node_create_driver("emc1414", i2c_device_create);
484
+ qos_node_consumes("emc1414", "i2c-bus", &opts);
485
+
486
+ qos_add_test("tx-rx", "emc1414", send_and_receive, NULL);
487
+}
488
+libqos_init(emc1414_register_nodes);
489
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
490
index XXXXXXX..XXXXXXX 100644
491
--- a/hw/arm/Kconfig
492
+++ b/hw/arm/Kconfig
493
@@ -XXX,XX +XXX,XX @@ config ASPEED_SOC
494
select SSI_M25P80
495
select TMP105
496
select TMP421
497
+ select EMC141X
498
select UNIMP
499
select LED
500
501
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
502
index XXXXXXX..XXXXXXX 100644
503
--- a/hw/misc/Kconfig
504
+++ b/hw/misc/Kconfig
505
@@ -XXX,XX +XXX,XX @@ config TMP421
506
bool
507
depends on I2C
508
509
+config EMC141X
510
+ bool
511
+ depends on I2C
512
+
513
config ISA_DEBUG
514
bool
515
depends on ISA_BUS
516
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
517
index XXXXXXX..XXXXXXX 100644
518
--- a/hw/misc/meson.build
519
+++ b/hw/misc/meson.build
520
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_PCI_TESTDEV', if_true: files('pci-testdev.c'))
521
softmmu_ss.add(when: 'CONFIG_SGA', if_true: files('sga.c'))
522
softmmu_ss.add(when: 'CONFIG_TMP105', if_true: files('tmp105.c'))
523
softmmu_ss.add(when: 'CONFIG_TMP421', if_true: files('tmp421.c'))
524
+softmmu_ss.add(when: 'CONFIG_EMC141X', if_true: files('emc141x.c'))
525
softmmu_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c'))
526
softmmu_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c'))
527
softmmu_ss.add(when: 'CONFIG_LED', if_true: files('led.c'))
528
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
529
index XXXXXXX..XXXXXXX 100644
530
--- a/tests/qtest/meson.build
531
+++ b/tests/qtest/meson.build
532
@@ -XXX,XX +XXX,XX @@ qos_test_ss.add(
533
'sdhci-test.c',
534
'spapr-phb-test.c',
535
'tmp105-test.c',
536
+ 'emc141x-test.c',
537
'usb-hcd-ohci-test.c',
538
'virtio-test.c',
539
'virtio-blk-test.c',
540
--
76
--
541
2.26.2
77
2.48.1
542
78
543
79
diff view generated by jsdifflib
New patch
1
Bumped SDK version to v09.03. v09.04 is available but not yet
2
supported in QEMU.
1
3
4
Reviewed-by: Jamin Lin <jamin_lin@aspeedtech.com>
5
Link: https://lore.kernel.org/qemu-devel/20250122070909.1138598-8-clg@redhat.com
6
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7
---
8
tests/functional/test_aarch64_aspeed.py | 10 +++++-----
9
1 file changed, 5 insertions(+), 5 deletions(-)
10
11
diff --git a/tests/functional/test_aarch64_aspeed.py b/tests/functional/test_aarch64_aspeed.py
12
index XXXXXXX..XXXXXXX 100755
13
--- a/tests/functional/test_aarch64_aspeed.py
14
+++ b/tests/functional/test_aarch64_aspeed.py
15
@@ -XXX,XX +XXX,XX @@ def do_test_aarch64_aspeed_sdk_start(self, image):
16
wait_for_console_pattern(self, '## Loading kernel from FIT Image')
17
wait_for_console_pattern(self, 'Starting kernel ...')
18
19
- ASSET_SDK_V902_AST2700 = Asset(
20
- 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.02/ast2700-default-obmc.tar.gz',
21
- 'ac969c2602f4e6bdb69562ff466b89ae3fe1d86e1f6797bb7969d787f82116a7')
22
+ ASSET_SDK_V903_AST2700 = Asset(
23
+ 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.03/ast2700-default-obmc.tar.gz',
24
+ '91225f50d255e2905ba8d8e0c80b71b9d157c3609770c7a740cd786370d85a77')
25
26
- def test_aarch64_ast2700_evb_sdk_v09_02(self):
27
+ def test_aarch64_ast2700_evb_sdk_v09_03(self):
28
self.set_machine('ast2700-evb')
29
30
- self.archive_extract(self.ASSET_SDK_V902_AST2700)
31
+ self.archive_extract(self.ASSET_SDK_V903_AST2700)
32
33
num_cpu = 4
34
uboot_size = os.path.getsize(self.scratch_file('ast2700-default',
35
--
36
2.48.1
37
38
diff view generated by jsdifflib
New patch
1
The main changes compared to upstream 2024.11 buildroot are
1
2
3
- bumped Linux to version 6.11.11 with a custom config
4
- changed U-Boot to OpenBMC branch for more support
5
- included extra target packages
6
7
See branch [1] for more details.
8
9
There is a slight output change when powering off the machine,
10
the console now contains :
11
12
reboot: Power off not available: System halted
13
14
Adjust accordingly the expect string in
15
do_test_arm_aspeed_buildroot_poweroff().
16
17
[1] https://github.com/legoater/buildroot/commits/aspeed-2024.11
18
19
Reviewed-by: Jamin Lin <jamin_lin@aspeedtech.com>
20
Link: https://lore.kernel.org/qemu-devel/20250122070909.1138598-9-clg@redhat.com
21
Signed-off-by: Cédric Le Goater <clg@redhat.com>
22
---
23
tests/functional/aspeed.py | 2 +-
24
tests/functional/test_arm_aspeed_ast2500.py | 8 ++++----
25
tests/functional/test_arm_aspeed_ast2600.py | 8 ++++----
26
3 files changed, 9 insertions(+), 9 deletions(-)
27
28
diff --git a/tests/functional/aspeed.py b/tests/functional/aspeed.py
29
index XXXXXXX..XXXXXXX 100644
30
--- a/tests/functional/aspeed.py
31
+++ b/tests/functional/aspeed.py
32
@@ -XXX,XX +XXX,XX @@ def do_test_arm_aspeed_buildroot_start(self, image, cpu_id, pattern='Aspeed EVB'
33
34
def do_test_arm_aspeed_buildroot_poweroff(self):
35
exec_command_and_wait_for_pattern(self, 'poweroff',
36
- 'reboot: System halted');
37
+ 'System halted');
38
39
def do_test_arm_aspeed_sdk_start(self, image):
40
self.require_netdev('user')
41
diff --git a/tests/functional/test_arm_aspeed_ast2500.py b/tests/functional/test_arm_aspeed_ast2500.py
42
index XXXXXXX..XXXXXXX 100755
43
--- a/tests/functional/test_arm_aspeed_ast2500.py
44
+++ b/tests/functional/test_arm_aspeed_ast2500.py
45
@@ -XXX,XX +XXX,XX @@
46
47
class AST2500Machine(AspeedTest):
48
49
- ASSET_BR2_202311_AST2500_FLASH = Asset(
50
+ ASSET_BR2_202411_AST2500_FLASH = Asset(
51
('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
52
- 'images/ast2500-evb/buildroot-2023.11/flash.img'),
53
- 'c23db6160cf77d0258397eb2051162c8473a56c441417c52a91ba217186e715f')
54
+ 'images/ast2500-evb/buildroot-2024.11/flash.img'),
55
+ '641e6906c18c0f19a2aeb48099d66d4771929c361001d554d0d45c667413e13a')
56
57
def test_arm_ast2500_evb_buildroot(self):
58
self.set_machine('ast2500-evb')
59
60
- image_path = self.ASSET_BR2_202311_AST2500_FLASH.fetch()
61
+ image_path = self.ASSET_BR2_202411_AST2500_FLASH.fetch()
62
63
self.vm.add_args('-device',
64
'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
65
diff --git a/tests/functional/test_arm_aspeed_ast2600.py b/tests/functional/test_arm_aspeed_ast2600.py
66
index XXXXXXX..XXXXXXX 100755
67
--- a/tests/functional/test_arm_aspeed_ast2600.py
68
+++ b/tests/functional/test_arm_aspeed_ast2600.py
69
@@ -XXX,XX +XXX,XX @@
70
71
class AST2600Machine(AspeedTest):
72
73
- ASSET_BR2_202311_AST2600_FLASH = Asset(
74
+ ASSET_BR2_202411_AST2600_FLASH = Asset(
75
('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
76
- 'images/ast2600-evb/buildroot-2023.11/flash.img'),
77
- 'b62808daef48b438d0728ee07662290490ecfa65987bb91294cafb1bb7ad1a68')
78
+ 'images/ast2600-evb/buildroot-2024.11/flash.img'),
79
+ '4bb2f3dfdea31199b51d66b42f686dc5374c144a7346fdc650194a5578b73609')
80
81
def test_arm_ast2600_evb_buildroot(self):
82
self.set_machine('ast2600-evb')
83
84
- image_path = self.ASSET_BR2_202311_AST2600_FLASH.fetch()
85
+ image_path = self.ASSET_BR2_202411_AST2600_FLASH.fetch()
86
87
self.vm.add_args('-device',
88
'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
89
--
90
2.48.1
91
92
diff view generated by jsdifflib
1
From: John Wang <wangzhiqiang.bj@bytedance.com>
1
When the -nodefaults option is set, sd devices should not be
2
automatically created by the machine. Instead they should be defined
3
on the command line.
2
4
3
G220A is a 2 socket x86 motherboard supported by OpenBMC.
5
Note that it is not currently possible to define which bus an
4
Strapping configuration was obtained from hardware.
6
"sd-card" device is attached to:
5
7
6
Signed-off-by: John Wang <wangzhiqiang.bj@bytedance.com>
8
-blockdev node-name=drive0,driver=file,filename=/path/to/file.img \
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
-device sd-card,drive=drive0,id=sd0
8
Reviewed-by: Joel Stanley <joel@jms.id.au>
10
9
Message-Id: <20201122105134.671-2-wangzhiqiang.bj@bytedance.com>
11
and the first bus named "sd-bus" will be used.
10
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
13
Reviewed-by: Jamin Lin <jamin_lin@aspeedtech.com>
14
Acked-by: Philippe Mathieu-Daudé <philmd@linaro.org>
15
Link: https://lore.kernel.org/qemu-devel/20250122070909.1138598-10-clg@redhat.com
16
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11
---
17
---
12
hw/arm/aspeed.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
18
hw/arm/aspeed.c | 4 ++--
13
1 file changed, 60 insertions(+)
19
1 file changed, 2 insertions(+), 2 deletions(-)
14
20
15
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
21
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
16
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/aspeed.c
23
--- a/hw/arm/aspeed.c
18
+++ b/hw/arm/aspeed.c
24
+++ b/hw/arm/aspeed.c
19
@@ -XXX,XX +XXX,XX @@ struct AspeedMachineState {
25
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
20
SCU_AST2500_HW_STRAP_ACPI_ENABLE | \
26
amc->i2c_init(bmc);
21
SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
27
}
22
28
23
+#define G220A_BMC_HW_STRAP1 ( \
29
- for (i = 0; i < bmc->soc->sdhci.num_slots; i++) {
24
+ SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \
30
+ for (i = 0; i < bmc->soc->sdhci.num_slots && defaults_enabled(); i++) {
25
+ SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \
31
sdhci_attach_drive(&bmc->soc->sdhci.slots[i],
26
+ SCU_AST2500_HW_STRAP_UART_DEBUG | \
32
drive_get(IF_SD, 0, i), false, false);
27
+ SCU_AST2500_HW_STRAP_RESERVED28 | \
33
}
28
+ SCU_AST2500_HW_STRAP_DDR4_ENABLE | \
34
29
+ SCU_HW_STRAP_2ND_BOOT_WDT | \
35
boot_emmc = sc->boot_from_emmc(bmc->soc);
30
+ SCU_HW_STRAP_VGA_CLASS_CODE | \
36
31
+ SCU_HW_STRAP_LPC_RESET_PIN | \
37
- if (bmc->soc->emmc.num_slots) {
32
+ SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER) | \
38
+ if (bmc->soc->emmc.num_slots && defaults_enabled()) {
33
+ SCU_AST2500_HW_STRAP_SET_AXI_AHB_RATIO(AXI_AHB_RATIO_2_1) | \
39
emmc0 = drive_get(IF_SD, 0, bmc->soc->sdhci.num_slots);
34
+ SCU_HW_STRAP_VGA_SIZE_SET(VGA_64M_DRAM) | \
40
sdhci_attach_drive(&bmc->soc->emmc.slots[0], emmc0, true, boot_emmc);
35
+ SCU_AST2500_HW_STRAP_RESERVED1)
41
}
36
+
37
/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
38
#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
39
40
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)
41
/* Bus 11: TODO ucd90160@64 */
42
}
43
44
+static void g220a_bmc_i2c_init(AspeedMachineState *bmc)
45
+{
46
+ AspeedSoCState *soc = &bmc->soc;
47
+ DeviceState *dev;
48
+
49
+ dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3),
50
+ "emc1413", 0x4c));
51
+ object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abort);
52
+ object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abort);
53
+ object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abort);
54
+
55
+ dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 12),
56
+ "emc1413", 0x4c));
57
+ object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abort);
58
+ object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abort);
59
+ object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abort);
60
+
61
+ dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 13),
62
+ "emc1413", 0x4c));
63
+ object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abort);
64
+ object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abort);
65
+ object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abort);
66
+}
67
+
68
static bool aspeed_get_mmio_exec(Object *obj, Error **errp)
69
{
70
return ASPEED_MACHINE(obj)->mmio_exec;
71
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_tacoma_class_init(ObjectClass *oc, void *data)
72
aspeed_soc_num_cpus(amc->soc_name);
73
};
74
75
+static void aspeed_machine_g220a_class_init(ObjectClass *oc, void *data)
76
+{
77
+ MachineClass *mc = MACHINE_CLASS(oc);
78
+ AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
79
+
80
+ mc->desc = "Bytedance G220A BMC (ARM1176)";
81
+ amc->soc_name = "ast2500-a1";
82
+ amc->hw_strap1 = G220A_BMC_HW_STRAP1;
83
+ amc->fmc_model = "n25q512a";
84
+ amc->spi_model = "mx25l25635e";
85
+ amc->num_cs = 2;
86
+ amc->macs_mask = ASPEED_MAC1_ON | ASPEED_MAC2_ON;
87
+ amc->i2c_init = g220a_bmc_i2c_init;
88
+ mc->default_ram_size = 1024 * MiB;
89
+ mc->default_cpus = mc->min_cpus = mc->max_cpus =
90
+ aspeed_soc_num_cpus(amc->soc_name);
91
+};
92
+
93
static const TypeInfo aspeed_machine_types[] = {
94
{
95
.name = MACHINE_TYPE_NAME("palmetto-bmc"),
96
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_machine_types[] = {
97
.name = MACHINE_TYPE_NAME("tacoma-bmc"),
98
.parent = TYPE_ASPEED_MACHINE,
99
.class_init = aspeed_machine_tacoma_class_init,
100
+ }, {
101
+ .name = MACHINE_TYPE_NAME("g220a-bmc"),
102
+ .parent = TYPE_ASPEED_MACHINE,
103
+ .class_init = aspeed_machine_g220a_class_init,
104
}, {
105
.name = TYPE_ASPEED_MACHINE,
106
.parent = TYPE_MACHINE,
107
--
42
--
108
2.26.2
43
2.48.1
109
44
110
45
diff view generated by jsdifflib
New patch
1
From: Jamin Lin <jamin_lin@aspeedtech.com>
1
2
3
Fix coding style issues from checkpatch.pl.
4
5
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
6
Reviewed-by: Cédric Le Goater <clg@redhat.com>
7
Link: https://lore.kernel.org/qemu-devel/20250124030249.1706996-2-jamin_lin@aspeedtech.com
8
Signed-off-by: Cédric Le Goater <clg@redhat.com>
9
---
10
hw/watchdog/wdt_aspeed.c | 3 ++-
11
1 file changed, 2 insertions(+), 1 deletion(-)
12
13
diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/watchdog/wdt_aspeed.c
16
+++ b/hw/watchdog/wdt_aspeed.c
17
@@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp)
18
19
s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, aspeed_wdt_timer_expired, dev);
20
21
- /* FIXME: This setting should be derived from the SCU hw strapping
22
+ /*
23
+ * FIXME: This setting should be derived from the SCU hw strapping
24
* register SCU70
25
*/
26
s->pclk_freq = PCLK_HZ;
27
--
28
2.48.1
29
30
diff view generated by jsdifflib
1
The controller can be configured to disable or enable address and data
1
From: Jamin Lin <jamin_lin@aspeedtech.com>
2
byte lanes when issuing commands. This is useful in read command mode
3
to send SPI NOR commands that don't have an address space, such as
4
RDID. It's a good way to have a unified read operation for registers
5
and flash contents accesses.
6
2
7
A new SPI driver proposed by Aspeed makes use of this feature. Add
3
On the AST2400 and AST2500 platforms, the system can only be reset by enabling
8
support for address lanes to start with. We will do the same for the
4
the WDT (Watchdog Timer) and waiting for the WDT timeout. However, starting
9
data lanes if they are controlled one day.
5
from the AST2600 platform, the reset event can be triggered directly and
6
intentionally by software, without relying on the WDT timeout.
10
7
11
Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
8
This mechanism, referred to as "software restart", is implemented in hardware.
12
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
When using the software restart mechanism, the WDT counter is not enabled.
13
Reviewed-by: Joel Stanley <joel@jms.id.au>
10
14
Message-Id: <20201120161547.740806-2-clg@kaod.org>
11
To trigger a reset generation in software mode, write 0xAEEDF123 to register
15
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
0x24 and software mode reset only support SOC reset mode.
13
14
A new function, "aspeed_wdt_is_soc_reset_mode", is introduced to determine
15
whether the SoC reset mode is active.
16
17
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
18
Reviewed-by: Cédric Le Goater <clg@redhat.com>
19
Link: https://lore.kernel.org/qemu-devel/20250124030249.1706996-3-jamin_lin@aspeedtech.com
20
Signed-off-by: Cédric Le Goater <clg@redhat.com>
16
---
21
---
17
hw/ssi/aspeed_smc.c | 25 ++++++++++++++++++-------
22
hw/watchdog/wdt_aspeed.c | 16 +++++++++++++++-
18
1 file changed, 18 insertions(+), 7 deletions(-)
23
1 file changed, 15 insertions(+), 1 deletion(-)
19
24
20
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
25
diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c
21
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/ssi/aspeed_smc.c
27
--- a/hw/watchdog/wdt_aspeed.c
23
+++ b/hw/ssi/aspeed_smc.c
28
+++ b/hw/watchdog/wdt_aspeed.c
24
@@ -XXX,XX +XXX,XX @@
29
@@ -XXX,XX +XXX,XX @@
25
#define INTR_CTRL_CMD_ABORT_EN (1 << 2)
30
#define WDT_TIMEOUT_CLEAR (0x14 / 4)
26
#define INTR_CTRL_WRITE_PROTECT_EN (1 << 1)
31
27
32
#define WDT_RESTART_MAGIC 0x4755
28
+/* Command Control Register */
33
+#define WDT_SW_RESET_ENABLE 0xAEEDF123
29
+#define R_CE_CMD_CTRL (0x0C / 4)
34
30
+#define CTRL_ADDR_BYTE0_DISABLE_SHIFT 4
35
#define AST2600_SCU_RESET_CONTROL1 (0x40 / 4)
31
+#define CTRL_DATA_BYTE0_DISABLE_SHIFT 0
36
#define SCU_RESET_CONTROL1 (0x04 / 4)
37
#define SCU_RESET_SDRAM BIT(0)
38
39
+static bool aspeed_wdt_is_soc_reset_mode(const AspeedWDTState *s)
40
+{
41
+ uint32_t mode;
32
+
42
+
33
+#define aspeed_smc_addr_byte_enabled(s, i) \
43
+ mode = extract32(s->regs[WDT_CTRL], 5, 2);
34
+ (!((s)->regs[R_CE_CMD_CTRL] & (1 << (CTRL_ADDR_BYTE0_DISABLE_SHIFT + (i)))))
44
+ return (mode == WDT_CTRL_RESET_MODE_SOC);
35
+#define aspeed_smc_data_byte_enabled(s, i) \
45
+}
36
+ (!((s)->regs[R_CE_CMD_CTRL] & (1 << (CTRL_DATA_BYTE0_DISABLE_SHIFT + (i)))))
37
+
46
+
38
/* CEx Control Register */
47
static bool aspeed_wdt_is_enabled(const AspeedWDTState *s)
39
#define R_CTRL0 (0x10 / 4)
40
#define CTRL_IO_QPI (1 << 31)
41
@@ -XXX,XX +XXX,XX @@ static void aspeed_smc_flash_setup(AspeedSMCFlash *fl, uint32_t addr)
42
{
48
{
43
const AspeedSMCState *s = fl->controller;
49
return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE;
44
uint8_t cmd = aspeed_smc_flash_cmd(fl);
50
@@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data,
45
- int i;
51
case WDT_TIMEOUT_STATUS:
46
+ int i = aspeed_smc_flash_is_4byte(fl) ? 4 : 3;
52
case WDT_TIMEOUT_CLEAR:
47
53
case WDT_RESET_MASK2:
48
/* Flash access can not exceed CS segment */
54
- case WDT_SW_RESET_CTRL:
49
addr = aspeed_smc_check_segment_addr(fl, addr);
55
case WDT_SW_RESET_MASK1:
50
56
case WDT_SW_RESET_MASK2:
51
ssi_transfer(s->spi, cmd);
57
qemu_log_mask(LOG_UNIMP,
52
-
58
"%s: uninmplemented write at offset 0x%" HWADDR_PRIx "\n",
53
- if (aspeed_smc_flash_is_4byte(fl)) {
59
__func__, offset);
54
- ssi_transfer(s->spi, (addr >> 24) & 0xff);
60
break;
55
+ while (i--) {
61
+ case WDT_SW_RESET_CTRL:
56
+ if (aspeed_smc_addr_byte_enabled(s, i)) {
62
+ if (aspeed_wdt_is_soc_reset_mode(s) &&
57
+ ssi_transfer(s->spi, (addr >> (i * 8)) & 0xff);
63
+ (data == WDT_SW_RESET_ENABLE)) {
64
+ watchdog_perform_action();
58
+ }
65
+ }
59
}
66
+ break;
60
- ssi_transfer(s->spi, (addr >> 16) & 0xff);
67
default:
61
- ssi_transfer(s->spi, (addr >> 8) & 0xff);
68
qemu_log_mask(LOG_GUEST_ERROR,
62
- ssi_transfer(s->spi, (addr & 0xff));
69
"%s: Out-of-bounds write at offset 0x%" HWADDR_PRIx "\n",
63
64
/*
65
* Use fake transfers to model dummy bytes. The value should
66
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size)
67
(addr >= s->r_timings &&
68
addr < s->r_timings + s->ctrl->nregs_timings) ||
69
addr == s->r_ce_ctrl ||
70
+ addr == R_CE_CMD_CTRL ||
71
addr == R_INTR_CTRL ||
72
addr == R_DUMMY_DATA ||
73
(s->ctrl->has_dma && addr == R_DMA_CTRL) ||
74
@@ -XXX,XX +XXX,XX @@ static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data,
75
if (value != s->regs[R_SEG_ADDR0 + cs]) {
76
aspeed_smc_flash_set_segment(s, cs, value);
77
}
78
+ } else if (addr == R_CE_CMD_CTRL) {
79
+ s->regs[addr] = value & 0xff;
80
} else if (addr == R_DUMMY_DATA) {
81
s->regs[addr] = value & 0xff;
82
} else if (addr == R_INTR_CTRL) {
83
--
70
--
84
2.26.2
71
2.48.1
85
72
86
73
diff view generated by jsdifflib
1
From: Joel Stanley <joel@jms.id.au>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
On the AST2600A1, the SRAM size was increased to 89KB.
3
The tacoma-bmc machine has recently been removed, so let's remove
4
it from the documentation now, too.
4
5
5
Fixes: 7582591ae745 ("aspeed: Support AST2600A1 silicon revision")
6
Fixes: 2b1b66e01f ("arm: Remove tacoma-bmc machine")
6
Signed-off-by: Joel Stanley <joel@jms.id.au>
7
Signed-off-by: Thomas Huth <thuth@redhat.com>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Reviewed-by: Cédric Le Goater <clg@redhat.com>
8
Message-Id: <20201112012113.835858-1-joel@jms.id.au>
9
Link: https://lore.kernel.org/qemu-devel/20250124174507.27348-1-thuth@redhat.com
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
10
Signed-off-by: Cédric Le Goater <clg@redhat.com>
10
---
11
---
11
hw/arm/aspeed_ast2600.c | 2 +-
12
docs/system/arm/aspeed.rst | 4 ++--
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
1 file changed, 2 insertions(+), 2 deletions(-)
13
14
14
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
15
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/aspeed_ast2600.c
17
--- a/docs/system/arm/aspeed.rst
17
+++ b/hw/arm/aspeed_ast2600.c
18
+++ b/docs/system/arm/aspeed.rst
18
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
19
@@ -XXX,XX +XXX,XX @@
19
sc->name = "ast2600-a1";
20
-Aspeed family boards (``ast2500-evb``, ``ast2600-evb``, ``ast2700-evb``, ``bletchley-bmc``, ``fuji-bmc``, ``fby35-bmc``, ``fp5280g2-bmc``, ``g220a-bmc``, ``palmetto-bmc``, ``qcom-dc-scm-v1-bmc``, ``qcom-firework-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc``, ``sonorapass-bmc``, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``tacoma-bmc``, ``witherspoon-bmc``, ``yosemitev2-bmc``)
20
sc->cpu_type = ARM_CPU_TYPE_NAME("cortex-a7");
21
-==================================================================================================================================================================================================================================================================================================================================================================================================================================
21
sc->silicon_rev = AST2600_A1_SILICON_REV;
22
+Aspeed family boards (``ast2500-evb``, ``ast2600-evb``, ``ast2700-evb``, ``bletchley-bmc``, ``fuji-bmc``, ``fby35-bmc``, ``fp5280g2-bmc``, ``g220a-bmc``, ``palmetto-bmc``, ``qcom-dc-scm-v1-bmc``, ``qcom-firework-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc``, ``sonorapass-bmc``, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``witherspoon-bmc``, ``yosemitev2-bmc``)
22
- sc->sram_size = 0x10000;
23
+==================================================================================================================================================================================================================================================================================================================================================================================================================
23
+ sc->sram_size = 0x16400;
24
24
sc->spis_num = 2;
25
The QEMU Aspeed machines model BMCs of various OpenPOWER systems and
25
sc->ehcis_num = 2;
26
Aspeed evaluation boards. They are based on different releases of the
26
sc->wdts_num = 4;
27
--
27
--
28
2.26.2
28
2.48.1
29
29
30
30
diff view generated by jsdifflib